Skip to content

ARN Parser #960

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

Closed
ghost opened this issue Dec 17, 2018 · 6 comments
Closed

ARN Parser #960

ghost opened this issue Dec 17, 2018 · 6 comments
Labels
feature-request A feature should be added or improved.

Comments

@ghost
Copy link

ghost commented Dec 17, 2018

I am prepared to invest in the necessary development effort to at least make a first public version of this available.

Expected Behavior

A class able to parse the useful pieces of information and delineate them within an ARN string. This does not need to happen automatically to begin with (i.e. where ARNs are represented in API responses, these need not for today have to be converted from the String type they typically are). It would also make sense that the Object also carries a .toString() method that returns the ARN as it's usually transmitted.

Current Behavior

Presently the Java SDK provides no means of supporting this as ARNs are typically reprsented as String types within fields.
There is however several examples of prior art: The Go SDK provides the ability to do so, in addition to a 3rd part library in Java.

Possible Solution

I propose including a new parser inside of the util package space, as well as a new object to represent all the common fields. Additional classes may be created in their respective service namespaces and extended as needed however I feel that may be outside of scope for the initial work.

Steps to Reproduce (for bugs)

N/A as this is a feature request.

Context

Within my organisation I have noticed several different implementations of trying to perform this task (e.g. wanting to extract the account ID from an ARN, or other such values). This reinvention and use of splitting on colon has lead to poor code showing up in our code base and I believe as there is usage elsewhere there would be a benefit to all having it present within the core SDK.

Your Environment

N/A as this is a feature request.

@ghost
Copy link
Author

ghost commented Dec 18, 2018

In tigertoes/aws-sdk-java-v2@18f791e I've made a first past go at including this functionality - early feedback on this would be greatly appreciated. I'll be looking to add more tests and address the TODOs that should be removed prior to raising a pull request alongside with any other comments given to me.

@usmanovbf
Copy link

@zoewangg @TigerToes please, apply this fix to main branch

@justnance justnance added feature-request A feature should be added or improved. and removed Feature Request labels Apr 19, 2019
@nathanagood
Copy link

@TigerToes, I really like that you have done this. The only feedback that I have is that the "getter" methods do not follow the fairly ubiquitous Java naming conventions for getters, such as "getPartition", "getService", "getRegion", etc., so as a long-time Java developer I was a little confused when trying to pull up the methods with code completion. I recommend naming them to follow the common "Java-isms". The same with the Builder--naming that many Java developers will be familiar with would be "withPartition", "withService", etc. This is nitpicking but might make it a bit easier to use.

@ghost
Copy link
Author

ghost commented Apr 25, 2019

@nathanagood thank you for the feedback, I've incorporated those changes into tigertoes/aws-sdk-java-v2@eaf7d1a.

@millems millems changed the title Implement ARN parsing ARN Parser Jul 8, 2019
@zoewangg
Copy link
Contributor

zoewangg commented Oct 9, 2019

This is implemented in #1462. You can parse an arn string via Arn#fromString

@zoewangg
Copy link
Contributor

The feature has been released as part of 2.9.18. Closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

4 participants