Class Arn
- java.lang.Object
-
- software.amazon.awssdk.arns.Arn
-
- All Implemented Interfaces:
ToCopyableBuilder<Arn.Builder,Arn>
@SdkPublicApi public final class Arn extends Object implements ToCopyableBuilder<Arn.Builder,Arn>
The Arns generated and recognized by this code are the Arns described here: https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.htmlThe primary supported Arn format is:
arn:<partition>:<service>:<region>:<account>:<resource>resourceAsString()returns everything after the account section of the Arn as a single string.However, the following Arn formats are supported where the values are present and well formatted through
resource():arn:<partition>:<service>:<region>:<account>:<resourcetype>/resource arn:<partition>:<service>:<region>:<account>:<resourcetype>/resource/qualifier arn:<partition>:<service>:<region>:<account>:<resourcetype>/resource:qualifier arn:<partition>:<service>:<region>:<account>:<resourcetype>:resource arn:<partition>:<service>:<region>:<account>:<resourcetype>:resource:qualifier
resource()returns aArnResourcewhich has access toArnResource.resourceType(),ArnResource.resource()andArnResource.qualifier().To parse an Arn from a string use Arn.fromString(). To convert an Arn to it's string representation use Arn.toString().
For instance, for a string s, containing a well-formed Arn the following should always be true:
Arn theArn = Arn.fromString(s); s.equals(theArn.toString());
- See Also:
ArnResource
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceArn.BuilderA builder for aArn.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<String>accountId()static Arn.Builderbuilder()booleanequals(Object o)static ArnfromString(String arn)Parses a given string into anArn.inthashCode()Stringpartition()Optional<String>region()ArnResourceresource()StringresourceAsString()Stringservice()Arn.BuildertoBuilder()StringtoString()static Optional<Arn>tryFromString(String arn)Attempts to parse the given string into anArn.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface software.amazon.awssdk.utils.builder.ToCopyableBuilder
copy
-
-
-
-
Method Detail
-
partition
public String partition()
- Returns:
- The partition that the resource is in.
-
service
public String service()
- Returns:
- The service namespace that identifies the AWS product (for example, Amazon S3, IAM, or Amazon RDS).
-
accountId
public Optional<String> accountId()
- Returns:
- The ID of the AWS account that owns the resource, without the hyphens.
-
resource
public ArnResource resource()
- Returns:
ArnResource
-
resourceAsString
public String resourceAsString()
- Returns:
- the resource as string
-
builder
public static Arn.Builder builder()
- Returns:
- a builder for
Arn.
-
tryFromString
public static Optional<Arn> tryFromString(String arn)
Attempts to parse the given string into anArn. If the input string is not a valid ARN, this method returnsOptional.empty()instead of throwing an exception.When successful, the resource is accessible entirely as a string through
resourceAsString(). Where correctly formatted, a parsed resource containing resource type, resource and qualifier is available throughresource().- Parameters:
arn- A string containing an ARN to parse.- Returns:
- An
Optionalcontaining the parsedArnif valid, or empty if invalid. - Throws:
IllegalArgumentException- if the ARN contains empty partition or service fields
-
fromString
public static Arn fromString(String arn)
Parses a given string into anArn. The resource is accessible entirely as a string throughresourceAsString(). Where correctly formatted, a parsed resource containing resource type, resource and qualifier is available throughresource().- Parameters:
arn- - A string containing an Arn.- Returns:
Arn- A modeled Arn.
-
toBuilder
public Arn.Builder toBuilder()
- Specified by:
toBuilderin interfaceToCopyableBuilder<Arn.Builder,Arn>
-
-