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

feat(StringArrayEndpointParams) Codegen String Array Enpoint params and Auth schemes params based on end-point-rule-set.json. #5122

Conversation

joviegas
Copy link
Contributor

@joviegas joviegas commented Apr 19, 2024

Motivation and Context

  • Generate Endpoint Params and Auth Scheme Params for StringArray type of parameters in endpoint-rule-set.json

Modifications

  • Added case for StringArray parameter type

Testing

  • Added Junits ,
  • Generated a sample S3 code as below

Screenshots (if appropriate)

endpoint-rule-set.json

{
    "version": "1.0",
    "parameters": {
        "Bucket": {
            "required": false,
            "documentation": "The S3 bucket used to send the request. This is an optional parameter that will be set automatically for operations that are scoped to an S3 bucket.",
            "type": "String"
        },
        "DeleteObjectKeys": {
            "required": false,
            "documentation": "Need delete object keys",
            "type": "StringArray"
        },
        "DefaultDeleteObjectKeys": {
            "required": false,
            "default": ["one", "two", "three"],
            "type": "StringArray"
        },

S3EndpointParams Class

@Generated("software.amazon.awssdk:codegen")
@SdkPublicApi
public final class S3EndpointParams implements ToCopyableBuilder<S3EndpointParams.Builder, S3EndpointParams> {
    private final List<String> deleteObjectKeys;

    private final List<String> defaultDeleteObjectKeys;
    private S3EndpointParams(BuilderImpl builder) {
        this.deleteObjectKeys = builder.deleteObjectKeys;
        this.defaultDeleteObjectKeys = builder.defaultDeleteObjectKeys;
    }

    public static Builder builder() {
        return new BuilderImpl();
    }


    public List<String> deleteObjectKeys() {
        return deleteObjectKeys;
    }

    public List<String> defaultDeleteObjectKeys() {
        return defaultDeleteObjectKeys;
    }


    public Builder toBuilder() {
        return new BuilderImpl(this);
    }

    public interface Builder extends CopyableBuilder<Builder, S3EndpointParams> {

        Builder deleteObjectKeys(List<String> deleteObjectKeys);

        Builder defaultDeleteObjectKeys(List<String> defaultDeleteObjectKeys);
        S3EndpointParams build();
    }

    private static class BuilderImpl implements Builder {
        private List<String> deleteObjectKeys;

        private List<String> defaultDeleteObjectKeys = Arrays.asList("one", "two", "three");

        private BuilderImpl() {
        }

        private BuilderImpl(S3EndpointParams builder) {
            this.deleteObjectKeys = builder.deleteObjectKeys;
            this.defaultDeleteObjectKeys = builder.defaultDeleteObjectKeys;
        }
        
        @Override
        public Builder deleteObjectKeys(List<String> deleteObjectKeys) {
            this.deleteObjectKeys = deleteObjectKeys;
            return this;
        }

        @Override
        public Builder defaultDeleteObjectKeys(List<String> defaultDeleteObjectKeys) {
            this.defaultDeleteObjectKeys = defaultDeleteObjectKeys;
            if (this.defaultDeleteObjectKeys == null) {
                this.defaultDeleteObjectKeys = Arrays.asList("one", "two", "three");
            }
            return this;
        }
        @Override
        public S3EndpointParams build() {
            return new S3EndpointParams(this);
        }
    }
}

DefaultS3AuthSchemeParams

@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public final class DefaultS3AuthSchemeParams implements S3AuthSchemeParams, S3EndpointResolverAware {
    private final List<String> deleteObjectKeys;
    private final List<String> defaultDeleteObjectKeys;
    private DefaultS3AuthSchemeParams(Builder builder) {
        this.deleteObjectKeys = builder.deleteObjectKeys;
        this.defaultDeleteObjectKeys = Validate.paramNotNull(builder.defaultDeleteObjectKeys, "defaultDeleteObjectKeys");
    }
    public static S3AuthSchemeParams.Builder builder() {
        return new Builder();
    }
    @Override
    public List<String> deleteObjectKeys() {
        return deleteObjectKeys;
    }
    @Override
    public List<String> defaultDeleteObjectKeys() {
        return defaultDeleteObjectKeys;
    }
    @Override
    public S3AuthSchemeParams.Builder toBuilder() {
        return new Builder(this);
    }
    private static final class Builder implements S3AuthSchemeParams.Builder, S3EndpointResolverAware.Builder {
        private List<String> deleteObjectKeys;
        private List<String> defaultDeleteObjectKeys = Arrays.asList("one", "two", "three");
        Builder() {
        }
        Builder(DefaultS3AuthSchemeParams params) {
            this.deleteObjectKeys = params.deleteObjectKeys;
            this.defaultDeleteObjectKeys = params.defaultDeleteObjectKeys;
        }
        @Override
        public Builder deleteObjectKeys(List<String> deleteObjectKeys) {
            this.deleteObjectKeys = deleteObjectKeys;
            return this;
        }
        @Override
        public Builder defaultDeleteObjectKeys(List<String> defaultDeleteObjectKeys) {
            this.defaultDeleteObjectKeys = defaultDeleteObjectKeys;
            if (this.defaultDeleteObjectKeys == null) {
                this.defaultDeleteObjectKeys = Arrays.asList("one", "two", "three");
            }
            return this;
        }
        @Override
        public S3AuthSchemeParams build() {
            return new DefaultS3AuthSchemeParams(this);
        }
    }
}

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 19, 2024 00:43
@joviegas joviegas force-pushed the joviegas/endoints_paramAndAuthSchemes_codegen branch 2 times, most recently from fc0c6a1 to 060a7c4 Compare April 21, 2024 01:34
…nd Auth schemes params based on end-point-rule-set.json.
@joviegas joviegas force-pushed the joviegas/endoints_paramAndAuthSchemes_codegen branch from 060a7c4 to e573852 Compare April 21, 2024 01:39
Copy link

sonarcloud bot commented Apr 21, 2024

JrsValue v = elementValuesIter.next();
b.add("\"" + v.asText() + "\"");
if (elementValuesIter.hasNext()) {
b.add(",");
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, seems like we can use stringjoiner?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@joviegas joviegas merged commit 0332975 into feature/StringArrayEndpointParams Apr 22, 2024
14 of 16 checks passed
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>
@joviegas joviegas deleted the joviegas/endoints_paramAndAuthSchemes_codegen branch May 15, 2024 20:31
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