private static Route buildRouteWithServiceNameAndInstance(final RequestContext ctx, final String serviceName, final DittoHeaders dittoHeaders, final RouteBuilderWithOptionalServiceNameAndInstance routeBuilder) { return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), instance -> // /devops/<logging|piggyback>/<serviceName>/<instance> routeBuilder.build(ctx, serviceName, Integer.parseInt(instance), dittoHeaders) ); }
private Route featuresEntryInboxOutbox(final RequestContext ctx, final DittoHeaders dittoHeaders, final String thingId) { return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), featureId -> // POST /features/{featureId}/<inbox|outbox> messagesRoute.buildFeaturesInboxOutboxRoute(ctx, dittoHeaders, thingId, featureId) ); } }
/** * Builds the {@code /{inbox|outbox}} sub route for the features route. * * @return the {@code /{inbox|outbox}} route. */ public Route buildFeaturesInboxOutboxRoute(final RequestContext ctx, final DittoHeaders dittoHeaders, final String thingId, final String featureId) { return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment(INBOX_OUTBOX_PATTERN)), inboxOutbox -> // /<inbox|outbox> post(() -> featureMessages(ctx, dittoHeaders, thingId, featureId, inboxOutbox)) ); }
private static Route buildRouteWithServiceNameAndOptionalInstance(final RequestContext ctx, final DittoHeaders dittoHeaders, final RouteBuilderWithOptionalServiceNameAndInstance routeBuilder) { return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), serviceName -> route( // /devops/<logging|piggyback>/<serviceName>/<instance> buildRouteWithServiceNameAndInstance(ctx, serviceName, dittoHeaders, routeBuilder), // /devops/<logging|piggyback>/<serviceName> routeBuilder.build(ctx, serviceName, null, dittoHeaders) ) ); }
/** * Builds the {@code /{inbox|outbox}} sub route for the things route. * * @return the {@code /{inbox|outbox}} route. */ public Route buildThingsInboxOutboxRoute(final RequestContext ctx, final DittoHeaders dittoHeaders, final String thingId) { return route( claimMessages(ctx, dittoHeaders, thingId), // /inbox/claim rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment(INBOX_OUTBOX_PATTERN)), inboxOutbox -> // /<inbox|outbox> post(() -> thingMessages(ctx, dittoHeaders, thingId, inboxOutbox)) ) ); }
/** * Builds the {@code /policies} route. * * @return the {@code /policies} route. */ public Route buildPoliciesRoute(final RequestContext ctx, final DittoHeaders dittoHeaders) { return rawPathPrefix(mergeDoubleSlashes().concat(PATH_POLICIES), () -> rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), policyId -> // /policies/<policyId> route( policyEntry(ctx, dittoHeaders, policyId), policyEntryEntries(ctx, dittoHeaders, policyId) ) ) ); }
private Route thingMessages(final RequestContext ctx, final DittoHeaders dittoHeaders, final String thingId, final String inboxOutbox) { final MessageDirection direction = PATH_INBOX.equalsIgnoreCase(inboxOutbox) ? MessageDirection.TO : MessageDirection.FROM; return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment(PATH_MESSAGES).slash()), () -> // /messages extractUnmatchedPath(msgSubject -> // <msgSubject/with/slashes> parameterOptional(Unmarshaller.sync(Long::parseLong), TIMEOUT_PARAMETER, optionalTimeout -> withCustomRequestTimeout(optionalTimeout, this::checkMessageTimeout, defaultMessageTimeout, timeout -> extractDataBytes(payloadSource -> handleMessage(ctx, payloadSource, buildSendThingMessage( direction, ctx, dittoHeaders, thingId, msgSubject, timeout ) ) ) ) ) ) ); }
final MessageDirection direction = PATH_INBOX.equalsIgnoreCase(inboxOutbox) ? MessageDirection.TO : MessageDirection.FROM; return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment(PATH_MESSAGES).slash()),
private Route featuresEntry(final RequestContext ctx, final DittoHeaders dittoHeaders, final String thingId) { return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), featureId -> pathEndOrSingleSlash(() -> route(
/** * Builds the {@code /things} route. * * @return the {@code /things} route. */ public Route buildThingsRoute(final RequestContext ctx, final DittoHeaders dittoHeaders) { return rawPathPrefix(mergeDoubleSlashes().concat(PATH_THINGS), () -> route( things(ctx, dittoHeaders), rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), thingId -> // /things/<thingId> route( thingsEntry(ctx, dittoHeaders, thingId), thingsEntryPolicyId(ctx, dittoHeaders, thingId), thingsEntryAcl(ctx, dittoHeaders, thingId), thingsEntryAclEntry(ctx, dittoHeaders, thingId), thingsEntryAttributes(ctx, dittoHeaders, thingId), thingsEntryAttributesEntry(ctx, dittoHeaders, thingId), thingsEntryFeatures(ctx, dittoHeaders, thingId), thingsEntryInboxOutbox(ctx, dittoHeaders, thingId) ) ) ) ); }
private Route featuresEntryProperties(final RequestContext ctx, final DittoHeaders dittoHeaders, final String thingId) { return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), featureId -> rawPathPrefix(mergeDoubleSlashes().concat(PATH_PROPERTIES), () -> pathEndOrSingleSlash(() ->
private Route thingsEntryPolicyEntry(final RequestContext ctx, final DittoHeaders dittoHeaders, final String policyId) { return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), label -> pathEndOrSingleSlash(() -> route( get(() -> // GET /entries/<label> handlePerRequest(ctx, RetrievePolicyEntry.of(policyId, Label.of(label), dittoHeaders)) ), put(() -> // PUT /entries/<label> extractDataBytes(payloadSource -> handlePerRequest(ctx, dittoHeaders, payloadSource, policyEntryJson -> ModifyPolicyEntry .of(policyId, createPolicyEntryForPut(policyEntryJson, label), dittoHeaders)) ) ), delete(() -> // DELETE /entries/<label> handlePerRequest(ctx, DeletePolicyEntry.of(policyId, Label.of(label), dittoHeaders))) ) ) ); }
private Route featuresEntryDefinition(final RequestContext ctx, final DittoHeaders dittoHeaders, final String thingId) { return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), featureId -> rawPathPrefix(mergeDoubleSlashes().concat(PATH_DEFINITION), () -> pathEndOrSingleSlash(() -> route( get(() -> // GET /features/{featureId}/definition handlePerRequest(ctx, RetrieveFeatureDefinition.of(thingId, featureId, dittoHeaders)) ), put(() -> // PUT /features/{featureId}/definition extractDataBytes(payloadSource -> handlePerRequest(ctx, dittoHeaders, payloadSource, definitionJson -> ModifyFeatureDefinition.of(thingId, featureId, ThingsModelFactory. newFeatureDefinition( definitionJson), dittoHeaders)) ) ), delete(() -> // DELETE /features/{featureId}/definition handlePerRequest(ctx, DeleteFeatureDefinition.of(thingId, featureId, dittoHeaders)) ) ) ) ) ); }
private Route thingsEntryPolicyEntryResources(final RequestContext ctx, final DittoHeaders dittoHeaders, final String policyId) { return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), label -> rawPathPrefix(mergeDoubleSlashes().concat(PATH_SUFFIX_RESOURCES), () -> pathEndOrSingleSlash(() -> route( get(() -> // GET /entries/<label>/resources handlePerRequest(ctx, RetrieveResources.of(policyId, Label.of(label), dittoHeaders)) ), put(() -> // PUT /entries/<label>/resources extractDataBytes(payloadSource -> handlePerRequest(ctx, dittoHeaders, payloadSource, policyEntryResourcesJson -> ModifyResources.of(policyId, Label.of( label), PoliciesModelFactory.newResources( JsonFactory.newObject( policyEntryResourcesJson)), dittoHeaders))) ) ) ) ) ); }
private Route thingsEntryPolicyEntrySubjects(final RequestContext ctx, final DittoHeaders dittoHeaders, final String policyId) { return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), label -> rawPathPrefix(mergeDoubleSlashes().concat(PATH_SUFFIX_SUBJECTS), () -> pathEndOrSingleSlash(() -> route( get(() -> // GET /entries/<label>/subjects handlePerRequest(ctx, RetrieveSubjects.of(policyId, Label.of(label), dittoHeaders)) ), put(() -> // PUT /entries/<label>/subjects extractDataBytes(payloadSource -> handlePerRequest(ctx, dittoHeaders, payloadSource, subjectsJson -> ModifySubjects.of(policyId, Label.of(label), PoliciesModelFactory.newSubjects( JsonFactory.newObject( subjectsJson)), dittoHeaders))) ) ) ) ) ); }
private Route thingsEntryAclEntry(final RequestContext ctx, final DittoHeaders dittoHeaders, final String thingId) { return rawPathPrefix(mergeDoubleSlashes().concat(PATH_ACL), () -> rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), subject -> pathEndOrSingleSlash(() -> route(
path(segment("products").slash(longSegment()), (productId) ->
private Route thingsEntryPolicyEntryResourcesEntry(final RequestContext ctx, final DittoHeaders dittoHeaders, final String policyId) { return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), label -> rawPathPrefix(mergeDoubleSlashes().concat(PATH_SUFFIX_RESOURCES), () -> extractUnmatchedPath(resource ->
private Route thingsEntryPolicyEntrySubjectsEntry(final RequestContext ctx, final DittoHeaders dittoHeaders, final String policyId) { return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), label -> rawPathPrefix(mergeDoubleSlashes().concat(PATH_SUFFIX_SUBJECTS), () -> rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.remaining()), subjectId ->
private Route featuresEntryPropertiesEntry(final RequestContext ctx, final DittoHeaders dittoHeaders, final String thingId) { return rawPathPrefix(mergeDoubleSlashes().concat(PathMatchers.segment()), featureId -> rawPathPrefix(mergeDoubleSlashes().concat(PATH_PROPERTIES), () -> route(