Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.HashSet;
import java.util.Set;

final class ApiStandardTerminology {
public final class ApiStandardTerminology {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why public?


private static final Set<String> COMMON_PREFIXES = Set.of("Batch");
private static final Set<String> READ_ONLY_TERMS =
Expand Down Expand Up @@ -40,8 +40,16 @@ final class ApiStandardTerminology {
"Untag",
"Update");

static final Set<String> READ_ONLY_API_PREFIXES = withCommonsPrefixes(READ_ONLY_TERMS);
static final Set<String> WRITE_API_PREFIXES = withCommonsPrefixes(WRITE_TERMS);
private static final Set<String> READ_ONLY_API_PREFIXES = withCommonsPrefixes(READ_ONLY_TERMS);
private static final Set<String> WRITE_API_PREFIXES = withCommonsPrefixes(WRITE_TERMS);

public static Set<String> getReadOnlyApiPrefixes() {
return READ_ONLY_API_PREFIXES;
}

public static Set<String> getWriteApiPrefixes() {
return WRITE_API_PREFIXES;
}
Comment on lines +43 to +55

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We don't need to keep computing these every time.Just store those in the constants, make them private but expose them via the getters.


private ApiStandardTerminology() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public Builder blockedOperations(Set<String> blockedOperations) {
}

public Builder readOnlyOperations() {
this.allowedPrefixes(ApiStandardTerminology.READ_ONLY_API_PREFIXES);
this.blockedPrefixes(ApiStandardTerminology.WRITE_API_PREFIXES);
this.allowedPrefixes(ApiStandardTerminology.getReadOnlyApiPrefixes());
this.blockedPrefixes(ApiStandardTerminology.getWriteApiPrefixes());
return this;
}

Expand Down Expand Up @@ -239,8 +239,11 @@ Map<String, String> parseEndpoints(ObjectNode endpointTests) {
continue;
}

if (endpoint.startsWith("https://") && endpoint.endsWith(region + ".amazonaws.com")) {
if (endpoint.endsWith(region + ".amazonaws.com") || endpoint.contains(region + ".amazonaws.com.")) {
if (endpoint.startsWith("https://")) {
if (endpoint.endsWith(region + ".amazonaws.com")
|| endpoint.contains(region + ".amazonaws.com.")
|| endpoint.endsWith(region + ".api.aws")
) {
var prev = endpoints.put(region, endpoint);
if (prev != null && !endpoint.equals(prev)) {
throw new RuntimeException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public void testReadAndWritePrefixes() {
var bundler = AwsServiceBundler.builder()
.serviceName("dynamodb")
.resolver(serviceName -> getModel("dynamodb-2012-08-10.json"))
.allowedPrefixes(ApiStandardTerminology.READ_ONLY_API_PREFIXES)
.blockedPrefixes(ApiStandardTerminology.WRITE_API_PREFIXES)
.allowedPrefixes(ApiStandardTerminology.getReadOnlyApiPrefixes())
.blockedPrefixes(ApiStandardTerminology.getWriteApiPrefixes())
.build();
var bundle = bundler.bundle();
var bundleModel = new ModelAssembler().addUnparsedModel("model.json", bundle.getModel())
Expand Down
Loading