summaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorValerij Fredriksen <valerij92@gmail.com>2021-03-18 18:13:02 +0100
committerValerij Fredriksen <valerij92@gmail.com>2021-03-19 09:38:28 +0100
commitce66c156bfad8d01fb471d0e6bdf2189c4914055 (patch)
tree45e1d6ebc4c6af9139ec09955b1b63c49897a7b0 /controller-api
parenteb345d955d47577f300170cbf5d4850f9b75893d (diff)
Remove optional /api prefix
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java94
1 files changed, 23 insertions, 71 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java
index d03df9523bd..a0da8cbddba 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java
@@ -6,7 +6,6 @@ import com.yahoo.restapi.Path;
import java.net.URI;
import java.util.EnumSet;
import java.util.List;
-import java.util.Objects;
import java.util.Optional;
import java.util.Set;
@@ -21,13 +20,11 @@ import java.util.Set;
enum PathGroup {
/** Paths exclusive to operators (including read), used for system management. */
- classifiedOperator(PathPrefix.api,
- "/configserver/v1/{*}",
+ classifiedOperator("/configserver/v1/{*}",
"/deployment/v1/{*}"),
/** Paths used for system management by operators. */
- operator(PathPrefix.none,
- "/controller/v1/{*}",
+ operator("/controller/v1/{*}",
"/flags/v1/{*}",
"/loadbalancers/v1/{*}",
"/nodes/v2/{*}",
@@ -42,64 +39,51 @@ enum PathGroup {
"/changemanagement/v1/{*}"),
/** Paths used for creating and reading user resources. */
- user(PathPrefix.api,
- "/application/v4/user",
+ user("/application/v4/user",
"/athenz/v1/{*}"),
/** Paths used for creating tenants with proper access control. */
tenant(Matcher.tenant,
- PathPrefix.api,
"/application/v4/tenant/{tenant}"),
/** Paths used for user management on the tenant level. */
tenantUsers(Matcher.tenant,
- PathPrefix.api,
"/user/v1/tenant/{tenant}"),
/** Paths used by tenant administrators. */
tenantInfo(Matcher.tenant,
- PathPrefix.api,
"/application/v4/tenant/{tenant}/application/",
"/application/v4/tenant/{tenant}/info/",
"/routing/v1/status/tenant/{tenant}/{*}"),
tenantKeys(Matcher.tenant,
- PathPrefix.api,
"/application/v4/tenant/{tenant}/key/"),
tenantArchiveAccess(Matcher.tenant,
- PathPrefix.api,
"/application/v4/tenant/{tenant}/archive-access"),
billingToken(Matcher.tenant,
- PathPrefix.api,
"/billing/v1/tenant/{tenant}/token"),
billingInstrument(Matcher.tenant,
- PathPrefix.api,
"/billing/v1/tenant/{tenant}/instrument/{*}"),
billingPlan(Matcher.tenant,
- PathPrefix.api,
"/billing/v1/tenant/{tenant}/plan/{*}"),
billingCollection(Matcher.tenant,
- PathPrefix.api,
"/billing/v1/tenant/{tenant}/collection/{*}"),
billingList(Matcher.tenant,
- PathPrefix.api,
"/billing/v1/tenant/{tenant}/billing/{*}"),
applicationKeys(Matcher.tenant,
Matcher.application,
- PathPrefix.api,
"/application/v4/tenant/{tenant}/application/{application}/key/"),
/** Path for the base application resource. */
application(Matcher.tenant,
Matcher.application,
- PathPrefix.api,
"/application/v4/tenant/{tenant}/application/{application}",
"/application/v4/tenant/{tenant}/application/{application}/instance/",
"/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}"),
@@ -107,13 +91,11 @@ enum PathGroup {
/** Paths used for user management on the application level. */
applicationUsers(Matcher.tenant,
Matcher.application,
- PathPrefix.api,
"/user/v1/tenant/{tenant}/application/{application}"),
/** Paths used by application administrators. */
applicationInfo(Matcher.tenant,
Matcher.application,
- PathPrefix.api,
"/application/v4/tenant/{tenant}/application/{application}/package",
"/application/v4/tenant/{tenant}/application/{application}/compile-version",
"/application/v4/tenant/{tenant}/application/{application}/deployment",
@@ -142,7 +124,6 @@ enum PathGroup {
developmentRestart(Matcher.tenant,
Matcher.application,
Matcher.instance,
- PathPrefix.api,
"/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/dev/region/{region}/restart",
"/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/perf/region/{region}/restart",
"/application/v4/tenant/{tenant}/application/{application}/environment/dev/region/{region}/instance/{instance}/restart",
@@ -152,7 +133,6 @@ enum PathGroup {
/** Path used to restart production nodes. */
productionRestart(Matcher.tenant,
Matcher.application,
- PathPrefix.api,
"/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/prod/region/{region}/restart",
"/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/test/region/{region}/restart",
"/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/staging/region/{region}/restart",
@@ -163,7 +143,6 @@ enum PathGroup {
/** Path used to manipulate reindexing status. */
reindexing(Matcher.tenant,
Matcher.application,
- PathPrefix.api,
"/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/{environment}/region/{region}/reindex",
"/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/{environment}/region/{region}/reindexing"),
@@ -171,7 +150,6 @@ enum PathGroup {
developmentDeployment(Matcher.tenant,
Matcher.application,
Matcher.instance,
- PathPrefix.api,
"/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/deploy/{job}",
"/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/dev/region/{region}",
"/application/v4/tenant/{tenant}/application/{application}/instance/{instance}/environment/dev/region/{region}/deploy",
@@ -188,7 +166,6 @@ enum PathGroup {
/** Paths used for production deployments. */
productionDeployment(Matcher.tenant,
Matcher.application,
- PathPrefix.api,
"/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/prod/region/{region}",
"/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/prod/region/{region}/deploy",
"/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/environment/test/region/{region}",
@@ -205,84 +182,76 @@ enum PathGroup {
/** Paths used for continuous deployment to production. */
submission(Matcher.tenant,
Matcher.application,
- PathPrefix.api,
"/application/v4/tenant/{tenant}/application/{application}/submit",
"/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/submit"),
/** Paths used for other tasks by build services. */ // TODO: This will vanish.
buildService(Matcher.tenant,
Matcher.application,
- PathPrefix.api,
"/application/v4/tenant/{tenant}/application/{application}/jobreport",
"/application/v4/tenant/{tenant}/application/{application}/instance/{ignored}/jobreport"),
/** Paths which contain (not very strictly) classified information about customers. */
- classifiedTenantInfo(PathPrefix.api,
- "/application/v4/",
+ classifiedTenantInfo("/application/v4/",
"/application/v4/tenant/"),
/** Paths which contain (not very strictly) classified information about, e.g., customers. */
- classifiedInfo(PathPrefix.none,
- "/",
+ classifiedInfo("/",
"/d/{*}"),
/** Paths providing public information. */
- publicInfo(PathPrefix.api,
- "/user/v1/user", // Information about who you are.
+ publicInfo("/user/v1/user", // Information about who you are.
"/badge/v1/{*}", // Badges for deployment jobs.
"/zone/v1/{*}"), // Lists environment and regions.
/** Paths used for deploying system-wide feature flags. */
- systemFlagsDeploy(PathPrefix.none, "/system-flags/v1/deploy"),
+ systemFlagsDeploy("/system-flags/v1/deploy"),
/** Paths used for "dry-running" system-wide feature flags. */
- systemFlagsDryrun(PathPrefix.none, "/system-flags/v1/dryrun"),
+ systemFlagsDryrun("/system-flags/v1/dryrun"),
/** Paths used for receiving payment callbacks */
- paymentProcessor(PathPrefix.none, "/payment/notification"),
+ paymentProcessor("/payment/notification"),
/** Paths used for invoice management */
- hostedAccountant(PathPrefix.api,
- "/billing/v1/invoice/{*}",
- "/billing/v1/billing"),
+ hostedAccountant("/billing/v1/invoice/{*}",
+ "/billing/v1/billing"),
/** Path used for listing endpoint certificate request info */
- endpointCertificateRequestInfo(PathPrefix.none, "/certificateRequests/"),
+ endpointCertificateRequestInfo("/certificateRequests/"),
/** Path used for secret store management */
- secretStore(Matcher.tenant, PathPrefix.api, "/application/v4/tenant/{tenant}/secret-store/{*}");
+ secretStore(Matcher.tenant, "/application/v4/tenant/{tenant}/secret-store/{*}");
final List<String> pathSpecs;
- final PathPrefix prefix;
final List<Matcher> matchers;
- PathGroup(PathPrefix prefix, String... pathSpecs) {
- this(List.of(), prefix, List.of(pathSpecs));
+ PathGroup(String... pathSpecs) {
+ this(List.of(), List.of(pathSpecs));
}
- PathGroup(Matcher first, PathPrefix prefix, String... pathSpecs) {
- this(List.of(first), prefix, List.of(pathSpecs));
+ PathGroup(Matcher first, String... pathSpecs) {
+ this(List.of(first), List.of(pathSpecs));
}
- PathGroup(Matcher first, Matcher second, PathPrefix prefix, String... pathSpecs) {
- this(List.of(first, second), prefix, List.of(pathSpecs));
+ PathGroup(Matcher first, Matcher second, String... pathSpecs) {
+ this(List.of(first, second), List.of(pathSpecs));
}
- PathGroup(Matcher first, Matcher second, Matcher third, PathPrefix prefix, String... pathSpecs) {
- this(List.of(first, second, third), prefix, List.of(pathSpecs));
+ PathGroup(Matcher first, Matcher second, Matcher third, String... pathSpecs) {
+ this(List.of(first, second, third), List.of(pathSpecs));
}
/** Creates a new path group, if the given context matchers are each present exactly once in each of the given specs. */
- PathGroup(List<Matcher> matchers, PathPrefix prefix, List<String> pathSpecs) {
+ PathGroup(List<Matcher> matchers, List<String> pathSpecs) {
this.matchers = matchers;
- this.prefix = prefix;
this.pathSpecs = pathSpecs;
}
/** Returns path if it matches any spec in this group, with match groups set by the match. */
private Optional<Path> get(URI uri) {
- Path matcher = new Path(uri, prefix.prefix);
+ Path matcher = new Path(uri);
for (String spec : pathSpecs) // Iterate to be sure the Path's state is that of the match.
if (matcher.matches(spec)) return Optional.of(matcher);
return Optional.empty();
@@ -355,21 +324,4 @@ enum PathGroup {
}
- /**
- * The valid prefixes of paths in a {@link PathGroup}. Provides flexibility in cases where paths are made available
- * under a non-root path.
- */
- enum PathPrefix {
-
- none(""),
- api("/api");
-
- private final String prefix;
-
- PathPrefix(String prefix) {
- this.prefix = Objects.requireNonNull(prefix);
- }
-
- }
-
}