• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  *  http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 package software.amazon.awssdk.regions;
17 
18 import software.amazon.awssdk.annotations.SdkPublicApi;
19 import software.amazon.awssdk.regions.internal.MetadataLoader;
20 
21 /**
22  * Metadata about a partition such as aws or aws-cn.
23  *
24  * <p>This is useful for building meta-functionality around AWS services. Partition metadata helps to provide
25  * data about regions which may not yet be in the endpoints.json file but have a specific prefix.</p>
26  */
27 @SdkPublicApi
28 public interface PartitionMetadata {
29     /**
30      * Returns the DNS suffix, such as amazonaws.com for this partition. This is the DNS suffix with no
31      * {@link EndpointTag}s.
32      *
33      * @return The DNS suffix for this partition with no endpoint tags.
34      * @see #dnsSuffix(PartitionEndpointKey)
35      */
dnsSuffix()36     default String dnsSuffix() {
37         return dnsSuffix(PartitionEndpointKey.builder().build());
38     }
39 
40     /**
41      * Returns the DNS suffix, such as amazonaws.com for this partition. This returns the DNS suffix associated with the tags in
42      * the provided {@link PartitionEndpointKey}.
43      *
44      * @return The DNS suffix for this partition with the endpoint tags specified in the endpoint key, or null if one is not
45      * known.
46      */
dnsSuffix(PartitionEndpointKey key)47     default String dnsSuffix(PartitionEndpointKey key) {
48         throw new UnsupportedOperationException();
49     }
50 
51     /**
52      * Returns the hostname pattern, such as {service}.{region}.{dnsSuffix} for this partition. This is the hostname pattern
53      * with no {@link EndpointTag}s.
54      *
55      * @return The hostname pattern for this partition with no endpoint tags.
56      * @see #hostname(PartitionEndpointKey)
57      */
hostname()58     default String hostname() {
59         return hostname(PartitionEndpointKey.builder().build());
60     }
61 
62     /**
63      * Returns the hostname pattern, such as {service}.{region}.{dnsSuffix} for this partition. This returns the hostname
64      * associated with the tags in the provided {@link PartitionEndpointKey}.
65      *
66      * @return The hostname pattern for this partition with the endpoint tags specified in the endpoint key, or null if one is
67      * not known.
68      */
hostname(PartitionEndpointKey key)69     default String hostname(PartitionEndpointKey key) {
70         throw new UnsupportedOperationException();
71     }
72 
73     /**
74      * Returns the identifier for this partition, such as aws.
75      *
76      * @return The identifier for this partition.
77      */
id()78     String id();
79 
80     /**
81      * Returns the partition name for this partition, such as AWS Standard
82      *
83      * @return The name of this partition
84      */
name()85     String name();
86 
87     /**
88      * Returns the region regex used for pattern matching for this partition.
89      *
90      * @return The region regex of this partition.
91      */
regionRegex()92     String regionRegex();
93 
94     /**
95      * Retrieves the partition metadata for a given partition.
96      *
97      * @param partition The partition to get metadata for.
98      *
99      * @return {@link PartitionMetadata} for the given partition.
100      */
of(String partition)101     static PartitionMetadata of(String partition) {
102         return MetadataLoader.partitionMetadata(partition);
103     }
104 
105     /**
106      * Retrieves the partition metadata for a given region.
107      *
108      * @param region The region to get the partition metadata for.
109      *
110      * @return {@link PartitionMetadata} for the given region.
111      */
of(Region region)112     static PartitionMetadata of(Region region) {
113         return MetadataLoader.partitionMetadata(region);
114     }
115 }
116