awslabs / aws-sdk-kotlin

Multiplatform AWS SDK for Kotlin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GroupGrantee

mgroth0 opened this issue · comments

Describe the feature

In the java V1 S3 SDK, we have com.amazonaws.services.s3.model.GroupGrantee, an enum of URIs making grantees such as AllUsers typesafe for the user. I have searched this repo, and I could not find any trace of it here.

Is your Feature Request related to a problem?

This is just about type safety. We can easily copy and paste the string into our own variable, but this is a downgrade from the type safety offered from the java library.

Proposed Solution

The GroupGrantee enum can be copied into the kotlin sdk.

Describe alternative solutions or features you've considered

No response

Acknowledge

  • I may be able to implement this feature request

AWS Kotlin SDK version used

1.0.73

Platform (JVM/JS/Native)

JVM

Operating System and version

Mac

Hi, thanks for the feature request. Java V1 was the first AWS SDK ever published (March 25, 2010), and most of these "convenience" features were implemented and maintained manually at the time.

Now, almost all of the SDKs are auto-generated by models that the service team (in this case, S3) owns. That helps us maintain the 300+ AWS services with little manual, per-service effort.

S3 models the fields as a string and the Kotlin SDK must respect that. S3 can't easily change the field to an enum because it would be considered a breaking change.

// s3.json
        "com.amazonaws.s3#Grantee": {
            ...
            "URI": {
                "target": "com.amazonaws.s3#URI",
                "traits": {
                    "smithy.api#documentation": "<p>URI of the grantee group.</p>"
                }
            },
        }
...
        "com.amazonaws.s3#URI": {
            "type": "string"
        },

Thank you for providing me with this very helpful context. I understand if this cannot be fixed, But I just to want to clarify my thoughts.

It seems to me that a standard feature offered by software libraries is type safety. Raw strings that have a functional role are represented as enums, variables, or whatever so that library consumers don't have to worry about the raw strings, the strings are abstracted away. This helps the code that consumes the library be as robust as possible, since strings are not type-checked.

I know that's all very basic, but just want to make sure I'm being clear with my request.

Given that the AWS has such sophisticated code generation, I don't see why it cannot also generate some typesafe API for things such as GroupGrantee. The way I mean my request was that this sort of feature would be only adding new API to the library, not removing or modifying existing API. You said this would be a "breaking change" which I do not understand, because this is not requesting any existing API to be changed or modified. That's why I am just making sure to clarify.

I also might be misunderstanding something, in which case I appreciate your patience.

It wouldn't be a breaking change for S3 to simply add a new GroupGrantee enum. If they did that, Kotlin SDK would begin generating it and you could use it. But it wouldn't be explicitly linked to the com.amazonaws.s3#URI shape, users would need to know that GroupGrantee exists and where to use it.

It would be a breaking change for S3 to modify the URI shape like this:

"com.amazonaws.s3#URI": {
    "type": "com.amazonaws.s3#GroupGrantee" // new enum
},

To avoid a breaking change, S3 would need to keep the type as string. So, no new type safety would be introduced. I agree it could be convenient to make a GroupGrantee enum with the common values used by S3, but the type of com.amazonaws.s3#URI will still need to be a string.

That makes sense. I am actually proposing something more like this:

object GroupGrantee {
    val AllUsers = "http://acs.amazonaws.com/groups/global/AllUsers"
    val AuthenticatedUsers = "http://acs.amazonaws.com/groups/global/AuthenticatedUsers"
}

This would place the responsibility on the library to ensure the URIs are the correct string, which I think is beneficial for special URIs like this so that users don't have to worry. I realize now that "typesafe" was the wrong phrase to use since it doesn't have any new types. Sorry for miscommunicating. But even just providing public string variables like this will provide increased safety.

This is something I would recommend to implement yourself in your own projects. S3 models the URIs as a string and does not provide a GroupGrantee enum. Even if they were to add a GroupGrantee enum, it could not be linked to com.amazonaws.s3#URI (because of the breaking change implications discussed above). Users would need to know when and where to use the GroupGrantee enum since it would not be tied to any shapes, and the experience would still be flawed.

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Makes sense. Thanks.