@Override public RetrieveFeatureDefinitionLiveCommand setDittoHeaders(final DittoHeaders dittoHeaders) { return of(RetrieveFeatureDefinition.of(getThingId(), getFeatureId(), dittoHeaders)); }
@Override public RetrieveFeatureDefinitionLiveCommand setDittoHeaders(final DittoHeaders dittoHeaders) { return of(RetrieveFeatureDefinition.of(getThingId(), getFeatureId(), dittoHeaders)); }
/** * Creates a new {@code RetrieveFeatureProperties} from a JSON object. * * @param jsonObject the JSON object of which the command is to be created. * @param dittoHeaders the headers of the command. * @return the command. * @throws NullPointerException if any argument is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * format. * @throws org.eclipse.ditto.json.JsonMissingFieldException if {@code jsonObject} did not contain any of the * required fields * <ul> * <li>{@link ThingQueryCommand.JsonFields#JSON_THING_ID} or</li> * <li>{@link #JSON_FEATURE_ID}.</li> * </ul> * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveFeatureDefinition fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandJsonDeserializer<RetrieveFeatureDefinition>(TYPE, jsonObject).deserialize(() -> { final String extractedThingId = jsonObject.getValueOrThrow(ThingQueryCommand.JsonFields.JSON_THING_ID); final String extractedFeatureId = jsonObject.getValueOrThrow(JSON_FEATURE_ID); return of(extractedThingId, extractedFeatureId, dittoHeaders); }); }
/** * Creates a new {@code RetrieveFeatureProperties} from a JSON object. * * @param jsonObject the JSON object of which the command is to be created. * @param dittoHeaders the headers of the command. * @return the command. * @throws NullPointerException if any argument is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * format. * @throws org.eclipse.ditto.json.JsonMissingFieldException if {@code jsonObject} did not contain any of the * required fields * <ul> * <li>{@link ThingQueryCommand.JsonFields#JSON_THING_ID} or</li> * <li>{@link #JSON_FEATURE_ID}.</li> * </ul> * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveFeatureDefinition fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandJsonDeserializer<RetrieveFeatureDefinition>(TYPE, jsonObject).deserialize(() -> { final String extractedThingId = jsonObject.getValueOrThrow(ThingQueryCommand.JsonFields.JSON_THING_ID); final String extractedFeatureId = jsonObject.getValueOrThrow(JSON_FEATURE_ID); return of(extractedThingId, extractedFeatureId, dittoHeaders); }); }
RetrieveFeatureDefinition.of(thingIdFrom(adaptable), featureIdFrom(adaptable), dittoHeadersFrom(adaptable)));
RetrieveFeatureDefinition.of(thingIdFrom(adaptable), featureIdFrom(adaptable), dittoHeadersFrom(adaptable)));
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)) ) ) ) ) ); }