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

new(StringArrayEndpointParams) Codegeneration of OperationContextParams defined for a Operation. #5146

Conversation

joviegas
Copy link
Contributor

@joviegas joviegas commented Apr 25, 2024

Codegeneration of OperationContextParams defined for a Operation.

Note : After JMesPathRuntime implementation , the JMESPath parsing of List will be added. For now I have added a TODO as a place holder.

Motivation and Context

Modifications

  • Added codegen in EndpointResolverInterceptorSpec to generate code for binding of OperationContext Params to StringArray Endpoint params

Testing

  • Junit test cases
  • Below is code Generated for S3ResolveEndpointInterceptor
  • Junit added with a List structure similar to DeleteObjects Keys
    "DeleteObjects":{
      "name":"DeleteObjects",
      "http":{
        "method":"POST",
        "requestUri":"/{Bucket}?delete"
      },
      "input":{"shape":"DeleteObjectsRequest"},
      "output":{"shape":"DeleteObjectsOutput"},
      "documentationUrl":"http://docs.amazonwebservices.com/AmazonS3/latest/API/multiobjectdeleteapi.html",
      "alias":"DeleteMultipleObjects",
      "operationContextParams":{
        "DeleteObjectKeys":{"value":"Delete.Objects[*].Key"}
      },
      "httpChecksum":{
        "requestAlgorithmMember":"ChecksumAlgorithm",
        "requestChecksumRequired":true
      }
    },
public final class S3ResolveEndpointInterceptor implements ExecutionInterceptor {

    public static S3EndpointParams ruleParams(SdkRequest request, ExecutionAttributes executionAttributes) {
        S3EndpointParams.Builder builder = S3EndpointParams.builder();
// Existing code
        setStaticContextParams(builder, executionAttributes.getAttribute(AwsExecutionAttribute.OPERATION_NAME));
        setOperationContextParams(builder, executionAttributes.getAttribute(AwsExecutionAttribute.OPERATION_NAME), request);
        return builder.build();
    }

    private static void setOperationContextParams(S3EndpointParams.Builder params, String operationName, SdkRequest request) {
        switch (operationName) {
        case "DeleteObjects":
            setOperationContextParams(params, (DeleteObjectsRequest) request);
            break;
        default:
            break;
        }
    }

    private static void setOperationContextParams(S3EndpointParams.Builder params, DeleteObjectsRequest request) {
        // TODO: Add JMESPathRuntime for Delete.Objects[*].Key
        params.deleteObjectKeys(new ArrayList<>());
    }



}

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@joviegas joviegas requested a review from a team as a code owner April 25, 2024 00:23
@joviegas joviegas force-pushed the joviegas/operationContextParams_codegen branch from 5f43b58 to c1e665e Compare April 25, 2024 00:23
@joviegas joviegas force-pushed the joviegas/operationContextParams_codegen branch from c1e665e to 229253d Compare April 25, 2024 00:32
Copy link
Contributor

@millems millems left a comment

Choose a reason for hiding this comment

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

LGTM, just some minor nits.

Comment on lines 389 to 390
Map<String, OperationContextParam> operationContextParams = opModel.getOperationContextParams();
return operationContextParams != null && !operationContextParams.isEmpty();
Copy link
Contributor

Choose a reason for hiding this comment

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

CollectionUtils.isNotEmpty(opModel.getOperationContextParams())?

if (Objects.requireNonNull(value.getValue().asToken()) == JsonToken.VALUE_STRING) {
b.addComment("TODO: Add JMESPathRuntime for $L", ((JrsString) value.getValue()).getValue());
} else {
throw new RuntimeException("Don't know how to set parameter of type " + value.getValue().asToken());
Copy link
Contributor

@millems millems Apr 25, 2024

Choose a reason for hiding this comment

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

I feel like people could make this mistake. Can we be more useful in the error message? Something like... "Invalid operation context parameter path for {operation-name}. Expected VALUE_STRING, but got {actual-value-type}".

@joviegas joviegas merged commit b85710c into feature/StringArrayEndpointParams Apr 25, 2024
10 of 16 checks passed
Copy link

sonarcloud bot commented Apr 25, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
3.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

cenedhryn added a commit that referenced this pull request May 13, 2024
* feat(StringArrayEndpointParams) Codegen String Array Enpoint params and Auth schemes params based on end-point-rule-set.json. (#5122)

* Support Customization string array endpoint params for S3 access grants, until all SDKs add support for string array. (#5137)

* new(StringArrayEndpointParams) Codegeneration of OperationContextParams defined for a Operation. (#5146)

* Extracting existing JMESPath runtime to a separate class (#5155)

* new(StringArrayEndpointParams) Customization of Operation Context params and adding customizations for S3 (#5159)

* Converts endpoint param list of string to list of value (#5169)

* Generates JmesPath expressions for operation context parameters (#5172)

* Supporting wildcard and keys fn in JmesPathRuntime (#5198)

* Adds functional tests for list of string auth params (#5216)

* Changelog

---------

Co-authored-by: John Viegas <70235430+joviegas@users.noreply.github.com>
Co-authored-by: John Viegas <joviegas@amazon.com>
akidambisrinivasan pushed a commit to akidambisrinivasan/aws-sdk-java-v2 that referenced this pull request Jun 28, 2024
* feat(StringArrayEndpointParams) Codegen String Array Enpoint params and Auth schemes params based on end-point-rule-set.json. (aws#5122)

* Support Customization string array endpoint params for S3 access grants, until all SDKs add support for string array. (aws#5137)

* new(StringArrayEndpointParams) Codegeneration of OperationContextParams defined for a Operation. (aws#5146)

* Extracting existing JMESPath runtime to a separate class (aws#5155)

* new(StringArrayEndpointParams) Customization of Operation Context params and adding customizations for S3 (aws#5159)

* Converts endpoint param list of string to list of value (aws#5169)

* Generates JmesPath expressions for operation context parameters (aws#5172)

* Supporting wildcard and keys fn in JmesPathRuntime (aws#5198)

* Adds functional tests for list of string auth params (aws#5216)

* Changelog

---------

Co-authored-by: John Viegas <70235430+joviegas@users.noreply.github.com>
Co-authored-by: John Viegas <joviegas@amazon.com>
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.

None yet

2 participants