--- /dev/null
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.restconf.nb.rfc8040;
+
+import java.net.URI;
+import org.eclipse.jdt.annotation.NonNull;
+
+/**
+ * OpenDaylight extension parameter. When used as {@code odl-leaf-nodes-only=true}, it will instruct the listener
+ * streams to only emit leaf nodes.
+ */
+public final class LeafNodesOnlyParam implements RestconfQueryParam<LeafNodesOnlyParam> {
+ // API consistency: must not be confused with enum constants
+ @SuppressWarnings("checkstyle:ConstantName")
+ public static final String uriName = "odl-leaf-nodes-only";
+
+ private static final @NonNull URI CAPABILITY =
+ URI.create("urn:opendaylight:params:restconf:capability:leaf-nodes-only:1.0");
+ private static final @NonNull LeafNodesOnlyParam FALSE = new LeafNodesOnlyParam(false);
+ private static final @NonNull LeafNodesOnlyParam TRUE = new LeafNodesOnlyParam(true);
+
+ private final boolean value;
+
+ private LeafNodesOnlyParam(final boolean value) {
+ this.value = value;
+ }
+
+ public static @NonNull LeafNodesOnlyParam of(final boolean value) {
+ return value ? TRUE : FALSE;
+ }
+
+ public static @NonNull LeafNodesOnlyParam forUriValue(final String uriValue) {
+ switch (uriValue) {
+ case "false":
+ return FALSE;
+ case "true":
+ return TRUE;
+ default:
+ throw new IllegalArgumentException("Value can be 'false' or 'true', not '" + uriValue + "'");
+ }
+ }
+
+ @Override
+ public Class<@NonNull LeafNodesOnlyParam> javaClass() {
+ return LeafNodesOnlyParam.class;
+ }
+
+ @Override
+ public String paramName() {
+ return uriName;
+ }
+
+ @Override
+ public String paramValue() {
+ return String.valueOf(value);
+ }
+
+ public boolean value() {
+ return value;
+ }
+
+ public static @NonNull URI capabilityUri() {
+ return CAPABILITY;
+ }
+}
*/
public final class NotificationQueryParams implements Immutable {
private final SkipNotificationDataParam skipNotificationData;
+ private final LeafNodesOnlyParam leafNodesOnly;
private final StartTimeParam startTime;
private final StopTimeParam stopTime;
private final FilterParam filter;
private NotificationQueryParams(final StartTimeParam startTime, final StopTimeParam stopTime,
- final FilterParam filter, final SkipNotificationDataParam skipNotificationData) {
+ final FilterParam filter, final LeafNodesOnlyParam leafNodesOnly,
+ final SkipNotificationDataParam skipNotificationData) {
this.startTime = startTime;
this.stopTime = stopTime;
this.filter = filter;
+ this.leafNodesOnly = leafNodesOnly;
this.skipNotificationData = skipNotificationData;
}
public static @NonNull NotificationQueryParams of(final StartTimeParam startTime, final StopTimeParam stopTime,
- final FilterParam filter, final SkipNotificationDataParam skipNotificationData) {
+ final FilterParam filter, final LeafNodesOnlyParam leafNodesOnly,
+ final SkipNotificationDataParam skipNotificationData) {
checkArgument(stopTime == null || startTime != null,
"Stop-time parameter has to be used with start-time parameter.");
- return new NotificationQueryParams(startTime, stopTime, filter, skipNotificationData);
+ return new NotificationQueryParams(startTime, stopTime, filter, leafNodesOnly, skipNotificationData);
}
/**
return filter;
}
+ /**
+ * Get odl-leaf-nodes-only query parameter.
+ *
+ * @return odl-leaf-nodes-only
+ */
+ public @Nullable LeafNodesOnlyParam leafNodesOnly() {
+ return leafNodesOnly;
+ }
+
/**
* Get odl-skip-notification-data query parameter.
*
if (filter != null) {
helper.add("filter", filter.paramValue());
}
+ if (leafNodesOnly != null) {
+ helper.add("leafNodesOnly", leafNodesOnly.value());
+ }
if (skipNotificationData != null) {
helper.add("skipNotificationData", skipNotificationData.value());
}
import org.opendaylight.restconf.nb.rfc8040.FieldsParam;
import org.opendaylight.restconf.nb.rfc8040.FilterParam;
import org.opendaylight.restconf.nb.rfc8040.InsertParam;
+import org.opendaylight.restconf.nb.rfc8040.LeafNodesOnlyParam;
import org.opendaylight.restconf.nb.rfc8040.NotificationQueryParams;
import org.opendaylight.restconf.nb.rfc8040.PointParam;
import org.opendaylight.restconf.nb.rfc8040.ReadDataParams;
StartTimeParam startTime = null;
StopTimeParam stopTime = null;
FilterParam filter = null;
+ LeafNodesOnlyParam leafNodesOnly = null;
SkipNotificationDataParam skipNotificationData = null;
for (Entry<String, List<String>> entry : uriInfo.getQueryParameters().entrySet()) {
case StopTimeParam.uriName:
stopTime = optionalParam(StopTimeParam::forUriValue, paramName, paramValues);
break;
+ case LeafNodesOnlyParam.uriName:
+ leafNodesOnly = optionalParam(LeafNodesOnlyParam::forUriValue, paramName, paramValues);
+ break;
case SkipNotificationDataParam.uriName:
skipNotificationData = optionalParam(SkipNotificationDataParam::forUriValue, paramName,
paramValues);
}
try {
- return NotificationQueryParams.of(startTime, stopTime, filter, skipNotificationData);
+ return NotificationQueryParams.of(startTime, stopTime, filter, leafNodesOnly, skipNotificationData);
} catch (IllegalArgumentException e) {
throw new RestconfDocumentedException("Invalid query parameters: " + e.getMessage(), e);
}
import org.opendaylight.restconf.nb.rfc8040.DepthParam;
import org.opendaylight.restconf.nb.rfc8040.FieldsParam;
import org.opendaylight.restconf.nb.rfc8040.FilterParam;
+import org.opendaylight.restconf.nb.rfc8040.LeafNodesOnlyParam;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040.IetfYangLibrary;
import org.opendaylight.restconf.nb.rfc8040.SkipNotificationDataParam;
import org.opendaylight.restconf.nb.rfc8040.WithDefaultsParam;
.withChildValue(FilterParam.capabilityUri().toString())
.withChildValue(AbstractReplayParam.capabilityUri().toString())
.withChildValue(WithDefaultsParam.capabilityUri().toString())
+ .withChildValue(LeafNodesOnlyParam.capabilityUri().toString())
.withChildValue(SkipNotificationDataParam.capabilityUri().toString())
.build())
.build())
notificationQueryParams.startTime(),
notificationQueryParams.stopTime(),
notificationQueryParams.filter(),
- false, notificationQueryParams.skipNotificationData());
+ notificationQueryParams.leafNodesOnly(),
+ notificationQueryParams.skipNotificationData());
final DOMDataBroker dataBroker = handlersHolder.getDataBroker();
notificationListenerAdapter.setCloseVars(dataBroker, handlersHolder.getSchemaHandler());
final MapEntryNode mapToStreams = RestconfMappingNodeUtil.mapYangNotificationStreamByIetfRestconfMonitoring(
notificationQueryParams.startTime(),
notificationQueryParams.stopTime(),
notificationQueryParams.filter(),
- false, notificationQueryParams.skipNotificationData());
+ notificationQueryParams.leafNodesOnly(),
+ notificationQueryParams.skipNotificationData());
final DOMDataBroker dataBroker = handlersHolder.getDataBroker();
final SchemaContextHandler schemaHandler = handlersHolder.getSchemaHandler();
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.nb.rfc8040.FilterParam;
+import org.opendaylight.restconf.nb.rfc8040.LeafNodesOnlyParam;
import org.opendaylight.restconf.nb.rfc8040.SkipNotificationDataParam;
import org.opendaylight.restconf.nb.rfc8040.StartTimeParam;
import org.opendaylight.restconf.nb.rfc8040.StopTimeParam;
*/
@SuppressWarnings("checkstyle:hiddenField")
public final void setQueryParams(final StartTimeParam startTime, final StopTimeParam stopTime,
- final FilterParam filter, final boolean leafNodesOnly,
+ final FilterParam filter, final LeafNodesOnlyParam leafNodesOnly,
final SkipNotificationDataParam skipNotificationData) {
start = startTime == null ? Instant.now() : parseDateAndTime(startTime.value());
stop = stopTime == null ? null : parseDateAndTime(stopTime.value());
- this.leafNodesOnly = leafNodesOnly;
+ this.leafNodesOnly = leafNodesOnly == null ? false : leafNodesOnly.value();
this.skipNotificationData = skipNotificationData == null ? false : skipNotificationData.value();
if (filter != null) {
equalTo("urn:ietf:params:restconf:capability:filter:1.0"),
equalTo("urn:ietf:params:restconf:capability:replay:1.0"),
equalTo("urn:ietf:params:restconf:capability:with-defaults:1.0"),
+ equalTo("urn:opendaylight:params:restconf:capability:leaf-nodes-only:1.0"),
equalTo("urn:opendaylight:params:restconf:capability:skip-notification-data:1.0")));
}
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.restconf.nb.rfc8040.LeafNodesOnlyParam;
import org.opendaylight.restconf.nb.rfc8040.SkipNotificationDataParam;
import org.opendaylight.restconf.nb.rfc8040.StartTimeParam;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
final NotificationOutputTypeGrouping.NotificationOutputType outputType,
final boolean leafNodesOnly, final boolean skipNotificationData) {
super(path, streamName, outputType);
- setQueryParams(StartTimeParam.forUriValue("1970-01-01T00:00:00Z"), null, null, leafNodesOnly,
- SkipNotificationDataParam.of(skipNotificationData));
+ setQueryParams(StartTimeParam.forUriValue("1970-01-01T00:00:00Z"), null, null,
+ LeafNodesOnlyParam.of(leafNodesOnly), SkipNotificationDataParam.of(skipNotificationData));
}
@Override