Skip to content

Conversation

@aajtodd
Copy link
Contributor

@aajtodd aajtodd commented Mar 12, 2021

Issue #, if available:

closes #85

Description of changes:

  • (feat): Adds a middleware component that sets the X-Amz-User-Agent and User-Agent headers (the former is the new SEP)
  • (feat): generate the SDK version into the client package (we already generated the sdkId and api version)
  • (fix): fix the generated SDK package version by reading from gradle.properties when generating smithy-build.json
  • (refactor): moves some files around to be nested under middleware

This PR implements most but not all of the SEP. There are a few optional metadata types left and we will need to figure out how to allow callers to add to/extend this metadata (e.g. amplify would be a good candidate for setting lib/* type metadata). See #86

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

@rcoh rcoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you haven't thought about it already, it's worth considering how you'll allow users (eg. HLLs) to customize your user agent

@aajtodd
Copy link
Contributor Author

aajtodd commented Mar 12, 2021

if you haven't thought about it already, it's worth considering how you'll allow users (eg. HLLs) to customize your user agent

This is explicitly called out that we haven't done this but need to. The linked ticket is for that purpose. Good call out though.

Copy link
Contributor

@kggilmer kggilmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions but nothing found that should block pushing.


override fun create(block: Config.() -> Unit): UserAgent {
val config = Config().apply(block)
val metadata = requireNotNull(config.metadata) { "metadata is required" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question

I'm not sure where to look but in serde I know we require specific exception types. Is IllegalArgumentException what we want to throw in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so far I've been ok with throwing IllegalArgumentException from the standpoint that the only way this should really be happening is if we generated the code wrong. Whatever exception is thrown wouldn't matter because you can't do anything about it anyway, it would need fixed in codegen.

It's a good question though, I just don't have an answer that improves the situation in any measurable way


internal actual fun platformLanguageMetadata(): LanguageMetadata {
val jvmMetadata = mutableMapOf<String, String>(
"javaVersion" to System.getProperty("java.version"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case that some JVM doesn't return these values would be safer to guard the null and specify a default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing

@aajtodd aajtodd merged commit 461a7aa into main Mar 12, 2021
@aajtodd aajtodd deleted the feat-ua-header branch March 12, 2021 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User Agent Header SEP

3 participants