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

Support query compatible trait only for json protocol #3204

Merged
merged 16 commits into from
Nov 26, 2024
Merged

Support query compatible trait only for json protocol #3204

merged 16 commits into from
Nov 26, 2024

Conversation

sbera87
Copy link
Contributor

@sbera87 sbera87 commented Nov 21, 2024

Issue #, if available:

Description of changes:

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

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

@@ -602,12 +602,16 @@ namespace Aws
SSOCredentialsClient::SSOCredentialsClient(const Aws::Client::ClientConfiguration& clientConfiguration, Aws::Http::Scheme scheme, const Aws::String& region)
: AWSHttpResourceClient(clientConfiguration, SSO_RESOURCE_CLIENT_LOG_TAG)
{
SetErrorMarshaller(Aws::MakeUnique<Aws::Client::JsonErrorMarshaller>(SSO_RESOURCE_CLIENT_LOG_TAG));
(Aws::MakeUnique<Aws::Client::JsonErrorMarshaller>(
Copy link
Contributor

Choose a reason for hiding this comment

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

???
why this file is even changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure. I will revert this

@@ -356,6 +358,7 @@ namespace Aws
Aws::String m_serviceName = "AWSBaseClient";
Aws::Client::RequestCompressionConfig m_requestCompressionConfig;
Aws::Vector<std::shared_ptr<smithy::interceptor::Interceptor>> m_interceptors;
Aws::Http::HeaderValueCollection m_featureHeaders;
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess smithy client needs to be updated as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will extend this to smithy client

@@ -56,7 +56,7 @@ jobs:
run: |
clang-format --version
if [ -s diff_output.patch ]; then
python3 clang-format-diff.py -p1 -style=file:.clang-format < diff_output.patch > formatted_differences.patch 2> error.log || true
python3 clang-format-diff.py -iregex '.*\.(cpp|cc|c\+\+|cxx|c|h|hh|hpp)' -p1 -style=file:.clang-format < diff_output.patch > formatted_differences.patch 2> error.log || true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

without this just the java file fails clang format in the pipeline, locally , no matter which version

@@ -39,6 +39,9 @@ namespace ${serviceNamespace}
headers.emplace(Aws::Http::HeaderValuePair(Aws::Http::CONTENT_TYPE_HEADER, ${CppViewHelper.computeRequestContentType($metadata)} ));
#if($metadata.acceptHeader)
headers.emplace(Aws::Http::HeaderValuePair(Aws::Http::ACCEPT_HEADER, "${metadata.acceptHeader}"));
#end
#if ($metadata.awsQueryCompatible)
headers.emplace(Aws::Http::HeaderValuePair(Aws::Http::X_AMZN_QUERY_MODE,"True"));
Copy link
Contributor

Choose a reason for hiding this comment

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

the specification uses lowercase "true" here.
while http headers must be case-insensitive, I'd prefer to be consistent "just in case".

@@ -21,6 +21,9 @@ namespace ${serviceNamespace}
class ${CppViewHelper.computeExportValue($metadata.classNamePrefix)} $className : public Aws::Client::JsonErrorMarshaller
{
public:
#if ($metadata.awsQueryCompatible)
explicit $className(bool queryCompatibilityMode) : Aws::Client::JsonErrorMarshaller(queryCompatibilityMode){}
Copy link
Contributor

@sbiscigl sbiscigl Nov 25, 2024

Choose a reason for hiding this comment

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

I think that we can make this code a little bit more maintainable using a decorator instead of a boolean. This also forces the query compatible decision to compile time and not runtime. i.e. we could do

class JsonErrorMarshallerQueryCompatible: public JsonErrorMarshaller {
  public:
    AWSError<CoreErrors> Marshall(const Aws::Http::HttpResponse& response) const override {
       //do special query compatible stuff
    }

AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Http::HttpResponse>& httpResponse) const override {
       //do special query compatible stuff
    }
};

then at code generation time we could do

  explicit $className : public Aws::Client::JsonErrorMarshallerQueryCompatible

and avoid passing around true and falses

@sbera87 sbera87 merged commit ceca736 into main Nov 26, 2024
4 of 5 checks passed
@sbera87 sbera87 deleted the query branch November 26, 2024 14:17
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.

3 participants