import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.restconf.api.query.ChangedLeafNodesOnlyParam;
+import org.opendaylight.restconf.api.query.ChildNodesOnlyParam;
import org.opendaylight.restconf.api.query.ContentParam;
import org.opendaylight.restconf.api.query.DepthParam;
import org.opendaylight.restconf.api.query.FieldsParam;
import org.opendaylight.restconf.api.query.StartTimeParam;
import org.opendaylight.restconf.api.query.StopTimeParam;
import org.opendaylight.restconf.api.query.WithDefaultsParam;
-import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError;
-import org.opendaylight.restconf.nb.rfc8040.NotificationQueryParams;
+import org.opendaylight.restconf.nb.rfc8040.Insert;
import org.opendaylight.restconf.nb.rfc8040.ReadDataParams;
-import org.opendaylight.restconf.nb.rfc8040.WriteDataParams;
+import org.opendaylight.restconf.nb.rfc8040.ReceiveEventsParams;
+import org.opendaylight.restconf.nb.rfc8040.legacy.InstanceIdentifierContext;
import org.opendaylight.restconf.nb.rfc8040.legacy.QueryParameters;
import org.opendaylight.restconf.nb.rfc8040.utils.parser.NetconfFieldsTranslator;
import org.opendaylight.restconf.nb.rfc8040.utils.parser.WriterFieldsTranslator;
+import org.opendaylight.restconf.nb.rfc8040.utils.parser.YangInstanceIdentifierDeserializer;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
@Beta
public final class QueryParams {
InsertParam.uriName, PointParam.uriName,
// Notifications
FilterParam.uriName, StartTimeParam.uriName, StopTimeParam.uriName,
- LeafNodesOnlyParam.uriName, SkipNotificationDataParam.uriName, ChangedLeafNodesOnlyParam.uriName);
+ // ODL extensions
+ LeafNodesOnlyParam.uriName, SkipNotificationDataParam.uriName, ChangedLeafNodesOnlyParam.uriName,
+ ChildNodesOnlyParam.uriName);
private QueryParams() {
// Utility class
}
- public static @NonNull NotificationQueryParams newNotificationQueryParams(final UriInfo uriInfo) {
+ public static @NonNull ReceiveEventsParams newReceiveEventsParams(final UriInfo uriInfo) {
StartTimeParam startTime = null;
StopTimeParam stopTime = null;
FilterParam filter = null;
LeafNodesOnlyParam leafNodesOnly = null;
SkipNotificationDataParam skipNotificationData = null;
ChangedLeafNodesOnlyParam changedLeafNodesOnly = null;
+ ChildNodesOnlyParam childNodesOnly = null;
for (Entry<String, List<String>> entry : uriInfo.getQueryParameters().entrySet()) {
final String paramName = entry.getKey();
changedLeafNodesOnly = optionalParam(ChangedLeafNodesOnlyParam::forUriValue, paramName,
paramValues);
break;
+ case ChildNodesOnlyParam.uriName:
+ childNodesOnly = optionalParam(ChildNodesOnlyParam::forUriValue, paramName, paramValues);
+ break;
default:
throw unhandledParam("notification", paramName);
}
}
try {
- return NotificationQueryParams.of(startTime, stopTime, filter, leafNodesOnly, skipNotificationData,
- changedLeafNodesOnly);
+ return new ReceiveEventsParams(startTime, stopTime, filter, leafNodesOnly, skipNotificationData,
+ changedLeafNodesOnly, childNodesOnly);
} catch (IllegalArgumentException e) {
throw new RestconfDocumentedException("Invalid query parameters: " + e.getMessage(), e);
}
FieldsParam fields = null;
WithDefaultsParam withDefaults = null;
PrettyPrintParam prettyPrint = null;
- boolean tagged = false;
for (Entry<String, List<String>> entry : uriInfo.getQueryParameters().entrySet()) {
final String paramName = entry.getKey();
fields = optionalParam(FieldsParam::forUriValue, paramName, paramValues);
break;
case WithDefaultsParam.uriName:
- final var defaultsVal = optionalParam(WithDefaultsParam::forUriValue, paramName, paramValues);
- if (defaultsVal != null) {
- tagged = switch (defaultsVal) {
- case REPORT_ALL -> {
- withDefaults = null;
- yield false;
- }
- case REPORT_ALL_TAGGED -> {
- withDefaults = null;
- yield true;
- }
- default -> {
- withDefaults = defaultsVal;
- yield false;
- }
- };
- }
+ withDefaults = optionalParam(WithDefaultsParam::forUriValue, paramName, paramValues);
break;
case PrettyPrintParam.uriName:
prettyPrint = optionalParam(PrettyPrintParam::forUriValue, paramName, paramValues);
}
}
- return ReadDataParams.of(content, depth, fields, withDefaults, tagged, prettyPrint);
+ return new ReadDataParams(content, depth, fields, withDefaults, prettyPrint);
}
- public static @NonNull WriteDataParams newWriteDataParams(final UriInfo uriInfo) {
+ public static @Nullable Insert parseInsert(final EffectiveModelContext modelContext, final UriInfo uriInfo) {
InsertParam insert = null;
PointParam point = null;
- for (final Entry<String, List<String>> entry : uriInfo.getQueryParameters().entrySet()) {
- final String paramName = entry.getKey();
- final List<String> paramValues = entry.getValue();
+ for (var entry : uriInfo.getQueryParameters().entrySet()) {
+ final var paramName = entry.getKey();
+ final var paramValues = entry.getValue();
try {
switch (paramName) {
}
try {
- return WriteDataParams.of(insert, point);
+ return Insert.forParams(insert, point,
+ // TODO: instead of a EffectiveModelContext, we should have received
+ // YangInstanceIdentifierDeserializer.Result, from which we can use to seed the parser. This
+ // call-site should not support 'yang-ext:mount' and should just reuse DataSchemaContextTree,
+ // saving a lookup
+ value -> YangInstanceIdentifierDeserializer.create(modelContext, value).path.getLastPathArgument());
} catch (IllegalArgumentException e) {
throw new RestconfDocumentedException("Invalid query parameters: " + e.getMessage(), e);
}