<groupId>org.opendaylight.netconf</groupId>
<artifactId>restconf-common</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991-ietf-yang-types</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
<artifactId>rfc8525</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>ietf-restconf-monitoring</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>netconf-api</artifactId>
<artifactId>yang-model-export</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
- <artifactId>rfc6991-ietf-yang-types</artifactId>
- </dependency>
-
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-dom-spi</artifactId>
*/
package org.opendaylight.restconf.nb.rfc8040;
+import com.google.common.annotations.Beta;
import java.net.URI;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.RestconfState;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.restconf.state.Streams;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.$YangModuleInfoImpl;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.list.Module;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.list.module.Deviation;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
/**
* Base Draft for Restconf project.
* <li>Constants for modules
* <ul>
* <li>{@link RestconfModule}
- * <li>{@link MonitoringModule}
* </ul>
* </ul>
*/
public final class Rfc8040 {
+ private static final YangInstanceIdentifier RESTCONF_STATE_STREAMS = YangInstanceIdentifier.create(
+ NodeIdentifier.create(RestconfState.QNAME), NodeIdentifier.create(Streams.QNAME));
+ private static final QName STREAM_QNAME = QName.create(Streams.QNAME, "stream").intern();
+
private Rfc8040() {
// Hidden on purpose
}
+ @Beta
+ // FIXME: move this method somewhere else
+ public static @NonNull YangInstanceIdentifier restconfStateStreamPath(final String streamName) {
+ return restconfStateStreamPath(NodeIdentifierWithPredicates.of(Streams.QNAME, STREAM_QNAME, streamName));
+ }
+
+ @Beta
+ // FIXME: move this method somewhere else
+ public static @NonNull YangInstanceIdentifier restconfStateStreamPath(final NodeIdentifierWithPredicates arg) {
+ return RESTCONF_STATE_STREAMS.node(arg);
+ }
+
/**
- * Set of application specific media types to identify each of the available resource types.
+ * Constants for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-11.4">RESTCONF Capability URNs</a>.
*/
- public static final class MediaTypes {
- private MediaTypes() {
+ public static final class Capabilities {
+ /**
+ * Support for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.2">depth</a> Query Parameter.
+ */
+ public static final String DEPTH = "urn:ietf:params:restconf:capability:depth:1.0";
+ /**
+ * Support for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.3">fields</a> Query Parameter.
+ */
+ public static final String FIELDS = "urn:ietf:params:restconf:capability:fields:1.0";
+ /**
+ * Support for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.4">filter</a> Query Parameter.
+ */
+ public static final String FILTER = "urn:ietf:params:restconf:capability:filter:1.0";
+ /**
+ * Support for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.7">start-time</a>
+ * and <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.7">stop-time</a> Query Parameters.
+ */
+ public static final String REPLAY = "urn:ietf:params:restconf:capability:replay:1.0";
+ /**
+ * Support for
+ * <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.9">with-defaults</a> Query Parameter.
+ */
+ public static final String WITH_DEFAULTS = "urn:ietf:params:restconf:capability:with-defaults:1.0";
+
+ private Capabilities() {
// Hidden on purpose
}
+ }
+ /**
+ * Set of application specific media types to identify each of the available resource types.
+ */
+ public static final class MediaTypes {
/**
* See: <a href="https://tools.ietf.org/html/rfc6415">rfc6415</a>.
*/
public static final String DATA = "application/yang-data";
public static final String YANG_PATCH = "application/yang.patch";
public static final String YANG_PATCH_STATUS = "application/yang.patch-status";
+
+ private MediaTypes() {
+ // Hidden on purpose
+ }
}
/**
* Constants for restconf module.
*/
+ // FIXME: split this out
public static final class RestconfModule {
- private RestconfModule() {
- throw new UnsupportedOperationException("Util class");
- }
-
public static final Revision REVISION = Revision.of("2017-01-26");
public static final String NAME = "ietf-restconf";
public static final String NAMESPACE = "urn:ietf:params:xml:ns:yang:ietf-restconf";
public static final QName ERROR_MESSAGE_QNAME = QName.create(IETF_RESTCONF_QNAME, "error-message").intern();
public static final QName ERROR_INFO_QNAME = QName.create(IETF_RESTCONF_QNAME, "error-info").intern();
public static final QName ERROR_PATH_QNAME = QName.create(IETF_RESTCONF_QNAME, "error-path").intern();
+
+ private RestconfModule() {
+ // Hidden on purpose
+ }
}
/**
* Constants for ietf-yang-library model.
*/
+ // FIXME: split this out
public static final class IetfYangLibrary {
- private IetfYangLibrary() {
- // Hidden on purpose
- }
-
public static final QNameModule MODULE_QNAME = $YangModuleInfoImpl.getInstance().getName().getModule();
public static final Revision REVISION = MODULE_QNAME.getRevision().orElseThrow();
QName.create(MODULE_QNAME, "conformance-type").intern();
public static final QName SPECIFIC_MODULE_SUBMODULE_LIST_QNAME = Submodule.QNAME;
- }
- /**
- * Constants for ietf-restconf-monitoring module.
- */
- public static final class MonitoringModule {
- private MonitoringModule() {
+ private IetfYangLibrary() {
// Hidden on purpose
}
-
- public static final String NAME = "ietf-restconf-monitoring";
- public static final String NAMESPACE = "urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring";
- public static final Revision REVISION = Revision.of("2017-01-26");
- public static final String PATH_TO_STREAM_WITHOUT_KEY =
- "ietf-restconf-monitoring:restconf-state/streams/stream=";
-
- public static final URI URI_MODULE = URI.create(NAMESPACE);
-
- public static final QNameModule MODULE_QNAME = QNameModule.create(URI_MODULE, REVISION).intern();
-
- public static final QName CONT_RESTCONF_STATE_QNAME = QName.create(MODULE_QNAME, "restconf-state").intern();
-
- public static final QName CONT_CAPABILITES_QNAME = QName.create(MODULE_QNAME, "capabilities").intern();
-
- public static final QName LEAF_LIST_CAPABILITY_QNAME = QName.create(MODULE_QNAME, "capability").intern();
-
- public static final QName CONT_STREAMS_QNAME = QName.create(MODULE_QNAME, "streams").intern();
-
- public static final QName LIST_STREAM_QNAME = QName.create(MODULE_QNAME, "stream").intern();
-
- public static final QName LEAF_NAME_STREAM_QNAME = QName.create(MODULE_QNAME, "name").intern();
-
- public static final QName LEAF_DESCR_STREAM_QNAME = QName.create(MODULE_QNAME, "description").intern();
-
- public static final QName LEAF_REPLAY_SUPP_STREAM_QNAME = QName.create(MODULE_QNAME, "replay-support").intern();
-
- public static final QName LEAF_START_TIME_STREAM_QNAME = QName.create(MODULE_QNAME, "replay-log-creation-time")
- .intern();
-
- public static final QName LIST_ACCESS_STREAM_QNAME = QName.create(MODULE_QNAME, "access").intern();
-
- public static final QName LEAF_ENCODING_ACCESS_QNAME = QName.create(MODULE_QNAME, "encoding").intern();
-
- public static final QName LEAF_LOCATION_ACCESS_QNAME = QName.create(MODULE_QNAME, "location").intern();
-
- /**
- * Constants for capabilities.
- */
- public static final class QueryParams {
- private QueryParams() {
- // Hidden on purpose
- }
-
- public static final String URI_BASE = "urn:ietf:params:restconf:capability:";
-
- public static final String DEPTH = URI_BASE + "depth:1.0";
- public static final String FIELDS = URI_BASE + "fields:1.0";
- public static final String FILTER = URI_BASE + "filter:1.0";
- public static final String REPLAY = URI_BASE + "replay:1.0";
- public static final String WITH_DEFAULTS = URI_BASE + "with-defaults:1.0";
- }
}
}
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040.IetfYangLibrary;
-import org.opendaylight.restconf.nb.rfc8040.Rfc8040.MonitoringModule;
import org.opendaylight.restconf.nb.rfc8040.utils.mapping.RestconfMappingNodeUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.RestconfState;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
String.valueOf(this.moduleSetId.incrementAndGet())));
}
- final Module monitoringModule = schemaContext.findModule(MonitoringModule.MODULE_QNAME).orElse(null);
+ final Module monitoringModule = schemaContext.findModule(RestconfState.QNAME.getModule()).orElse(null);
if (monitoringModule != null) {
putData(RestconfMappingNodeUtil.mapCapabilites(monitoringModule));
}
import org.opendaylight.restconf.nb.rfc8040.streams.Configuration;
import org.opendaylight.restconf.nb.rfc8040.streams.listeners.NotificationListenerAdapter;
import org.opendaylight.restconf.nb.rfc8040.utils.mapping.RestconfMappingNodeUtil;
-import org.opendaylight.restconf.nb.rfc8040.utils.parser.IdentifierCodec;
import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType;
import org.opendaylight.yangtools.concepts.Immutable;
listener.getSchemaPath().lastNodeIdentifier(), schemaContext.getNotifications(), null,
listener.getOutputType(), uri);
- final String name = listener.getSchemaPath().lastNodeIdentifier().getLocalName();
transaction.merge(LogicalDatastoreType.OPERATIONAL,
- IdentifierCodec.deserialize(Rfc8040.MonitoringModule.PATH_TO_STREAM_WITHOUT_KEY + name, schemaContext),
- mapToStreams);
+ Rfc8040.restconfStateStreamPath(mapToStreams.getIdentifier()), mapToStreams);
}
@Override
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteOperations;
import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
import org.opendaylight.mdsal.dom.api.DOMNotificationService;
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
import org.opendaylight.restconf.common.util.DataChangeScope;
-import org.opendaylight.restconf.nb.rfc8040.Rfc8040.MonitoringModule;
+import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfStreamsSubscriptionServiceImpl.HandlersHolder;
import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfStreamsSubscriptionServiceImpl.NotificationQueryParams;
import org.opendaylight.restconf.nb.rfc8040.rests.utils.ResolveEnumUtil;
notificationListenerAdapter.getSchemaPath().lastNodeIdentifier(),
schemaContext.getNotifications(), notificationQueryParams.getStart(),
notificationListenerAdapter.getOutputType(), uri);
- writeDataToDS(schemaContext,
- notificationListenerAdapter.getSchemaPath().lastNodeIdentifier().getLocalName(), writeTransaction,
- mapToStreams);
+ writeDataToDS(writeTransaction, mapToStreams);
submitData(writeTransaction);
transactionChain.close();
return uri;
final MapEntryNode mapToStreams =
RestconfMappingNodeUtil.mapDataChangeNotificationStreamByIetfRestconfMonitoring(listener.get().getPath(),
notificationQueryParams.getStart(), listener.get().getOutputType(), uri, schemaContext, serializedPath);
- writeDataToDS(schemaContext, serializedPath, writeTransaction, mapToStreams);
+ writeDataToDS(writeTransaction, mapToStreams);
submitData(writeTransaction);
transactionChain.close();
return uri;
}
- private static void writeDataToDS(final EffectiveModelContext schemaContext, final String name,
- final DOMDataTreeReadWriteTransaction readWriteTransaction, final MapEntryNode mapToStreams) {
- readWriteTransaction.merge(LogicalDatastoreType.OPERATIONAL,
- // FIXME: do not use IdentifierCodec here
- IdentifierCodec.deserialize(MonitoringModule.PATH_TO_STREAM_WITHOUT_KEY + name, schemaContext),
+ // FIXME: callers are utter duplicates, refactor them
+ private static void writeDataToDS(final DOMDataTreeWriteOperations tx, final MapEntryNode mapToStreams) {
+ // FIXME: use put() here
+ tx.merge(LogicalDatastoreType.OPERATIONAL, Rfc8040.restconfStateStreamPath(mapToStreams.getIdentifier()),
mapToStreams);
}
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
-import org.opendaylight.restconf.nb.rfc8040.Rfc8040.MonitoringModule;
+import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
-import org.opendaylight.restconf.nb.rfc8040.utils.parser.IdentifierCodec;
import org.opendaylight.yangtools.util.xml.UntrustedXML;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
/**
* Transaction chain for delete data in DS on close().
*
- * @param transactionChainHandler
- * creating new write transaction for delete data on close
- * @param schemaHandler
- * for getting schema to deserialize
- * {@link MonitoringModule#PATH_TO_STREAM_WITHOUT_KEY} to
- * {@link YangInstanceIdentifier}
+ * @param transactionChainHandler creating new write transaction for delete data on close
+ * @param schemaHandler for formatting notifications
*/
@SuppressWarnings("checkstyle:hiddenField")
public void setCloseVars(final TransactionChainHandler transactionChainHandler,
protected void deleteDataInDS() throws Exception {
final DOMTransactionChain transactionChain = this.transactionChainHandler.get();
final DOMDataTreeWriteTransaction wTx = transactionChain.newWriteOnlyTransaction();
- wTx.delete(LogicalDatastoreType.OPERATIONAL, IdentifierCodec
- .deserialize(MonitoringModule.PATH_TO_STREAM_WITHOUT_KEY + this.localName, this.schemaHandler.get()));
+ wTx.delete(LogicalDatastoreType.OPERATIONAL, Rfc8040.restconfStateStreamPath(this.localName));
wTx.commit().get();
transactionChain.close();
}
*/
package org.opendaylight.restconf.nb.rfc8040.utils.mapping;
+import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.$YangModuleInfoImpl.qnameOf;
+
+import com.google.common.annotations.VisibleForTesting;
import java.net.URI;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.util.Map;
import java.util.Optional;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
+import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040.IetfYangLibrary;
-import org.opendaylight.restconf.nb.rfc8040.Rfc8040.MonitoringModule;
-import org.opendaylight.restconf.nb.rfc8040.Rfc8040.MonitoringModule.QueryParams;
import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.RestconfState;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.restconf.state.Capabilities;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.restconf.state.streams.Stream;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.restconf.state.streams.stream.Access;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.ModulesState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.list.Module.ConformanceType;
import org.opendaylight.yangtools.yang.common.QName;
/**
* Util class for mapping nodes.
- *
*/
public final class RestconfMappingNodeUtil {
+ private static final QName CAPABILITY_QNAME = qnameOf("capability");
+ @VisibleForTesting
+ static final QName DESCRIPTION_QNAME = qnameOf("description");
+ @VisibleForTesting
+ static final QName ENCODING_QNAME = qnameOf("encoding");
+ @VisibleForTesting
+ static final QName LOCATION_QNAME = qnameOf("location");
+ @VisibleForTesting
+ static final QName NAME_QNAME = qnameOf("name");
+ @VisibleForTesting
+ static final QName REPLAY_SUPPORT_QNAME = qnameOf("replay-support");
+ @VisibleForTesting
+ static final QName REPLAY_LOG_CREATION_TIME = qnameOf("replay-log-creation-time");
+
private RestconfMappingNodeUtil() {
// Hidden on purpose
}
*/
public static ContainerNode mapCapabilites(final Module monitoringModule) {
return Builders.containerBuilder()
- .withNodeIdentifier(new NodeIdentifier(MonitoringModule.CONT_RESTCONF_STATE_QNAME))
+ .withNodeIdentifier(new NodeIdentifier(RestconfState.QNAME))
.withChild(Builders.containerBuilder()
- .withNodeIdentifier(new NodeIdentifier(MonitoringModule.CONT_CAPABILITES_QNAME))
+ .withNodeIdentifier(new NodeIdentifier(Capabilities.QNAME))
.withChild(Builders.<String>orderedLeafSetBuilder()
- .withNodeIdentifier(new NodeIdentifier(MonitoringModule.LEAF_LIST_CAPABILITY_QNAME))
- .withChildValue(QueryParams.DEPTH)
- .withChildValue(QueryParams.FIELDS)
- .withChildValue(QueryParams.FILTER)
- .withChildValue(QueryParams.REPLAY)
- .withChildValue(QueryParams.WITH_DEFAULTS)
+ .withNodeIdentifier(new NodeIdentifier(CAPABILITY_QNAME))
+ .withChildValue(Rfc8040.Capabilities.DEPTH)
+ .withChildValue(Rfc8040.Capabilities.FIELDS)
+ .withChildValue(Rfc8040.Capabilities.FILTER)
+ .withChildValue(Rfc8040.Capabilities.REPLAY)
+ .withChildValue(Rfc8040.Capabilities.WITH_DEFAULTS)
.build())
.build())
.build();
final String streamName = notifiQName.getLocalName();
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> streamEntry =
Builders.mapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(MonitoringModule.LIST_STREAM_QNAME,
- MonitoringModule.LEAF_NAME_STREAM_QNAME, streamName))
- .withChild(ImmutableNodes.leafNode(MonitoringModule.LEAF_NAME_STREAM_QNAME, streamName));
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(Stream.QNAME, NAME_QNAME, streamName))
+ .withChild(ImmutableNodes.leafNode(NAME_QNAME, streamName));
notificationDefinition.getDescription().ifPresent(
- desc -> streamEntry.withChild(ImmutableNodes.leafNode(MonitoringModule.LEAF_DESCR_STREAM_QNAME,
- desc)));
- streamEntry.withChild(ImmutableNodes.leafNode(MonitoringModule.LEAF_REPLAY_SUPP_STREAM_QNAME,
- Boolean.TRUE));
+ desc -> streamEntry.withChild(ImmutableNodes.leafNode(DESCRIPTION_QNAME, desc)));
+ streamEntry.withChild(ImmutableNodes.leafNode(REPLAY_SUPPORT_QNAME, Boolean.TRUE));
if (start != null) {
- streamEntry.withChild(ImmutableNodes.leafNode(MonitoringModule.LEAF_START_TIME_STREAM_QNAME,
+ streamEntry.withChild(ImmutableNodes.leafNode(REPLAY_LOG_CREATION_TIME,
DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(OffsetDateTime.ofInstant(start,
ZoneId.systemDefault()))));
}
private static MapNode createAccessList(final String outputType, final URI uriToWebsocketServer) {
return Builders.mapBuilder()
- .withNodeIdentifier(new NodeIdentifier(MonitoringModule.LIST_ACCESS_STREAM_QNAME))
+ .withNodeIdentifier(new NodeIdentifier(Access.QNAME))
.withChild(Builders.mapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(MonitoringModule.LIST_ACCESS_STREAM_QNAME,
- MonitoringModule.LEAF_ENCODING_ACCESS_QNAME, outputType))
- .withChild(ImmutableNodes.leafNode(MonitoringModule.LEAF_ENCODING_ACCESS_QNAME, outputType))
- .withChild(ImmutableNodes.leafNode(MonitoringModule.LEAF_LOCATION_ACCESS_QNAME,
- uriToWebsocketServer.toString()))
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(Access.QNAME, ENCODING_QNAME, outputType))
+ .withChild(ImmutableNodes.leafNode(ENCODING_QNAME, outputType))
+ .withChild(ImmutableNodes.leafNode(LOCATION_QNAME, uriToWebsocketServer.toString()))
.build())
.build();
}
.getSchemaNode();
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> streamEntry =
Builders.mapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(MonitoringModule.LIST_STREAM_QNAME,
- MonitoringModule.LEAF_NAME_STREAM_QNAME, streamName))
- .withChild(ImmutableNodes.leafNode(MonitoringModule.LEAF_NAME_STREAM_QNAME, streamName));
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(Stream.QNAME, NAME_QNAME, streamName))
+ .withChild(ImmutableNodes.leafNode(NAME_QNAME, streamName));
schemaNode.getDescription().ifPresent(desc ->
- streamEntry.withChild(ImmutableNodes.leafNode(MonitoringModule.LEAF_DESCR_STREAM_QNAME, desc)));
+ streamEntry.withChild(ImmutableNodes.leafNode(DESCRIPTION_QNAME, desc)));
return streamEntry
- .withChild(ImmutableNodes.leafNode(MonitoringModule.LEAF_REPLAY_SUPP_STREAM_QNAME, Boolean.TRUE))
- .withChild(ImmutableNodes.leafNode(MonitoringModule.LEAF_START_TIME_STREAM_QNAME,
+ .withChild(ImmutableNodes.leafNode(REPLAY_SUPPORT_QNAME, Boolean.TRUE))
+ .withChild(ImmutableNodes.leafNode(REPLAY_LOG_CREATION_TIME,
DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(OffsetDateTime.ofInstant(start, ZoneId.systemDefault()))))
.withChild(createAccessList(outputType, uri))
.build();
import java.util.Map;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040.IetfYangLibrary;
-import org.opendaylight.restconf.nb.rfc8040.Rfc8040.MonitoringModule;
-import org.opendaylight.restconf.nb.rfc8040.Rfc8040.MonitoringModule.QueryParams;
import org.opendaylight.restconf.nb.rfc8040.Rfc8040.RestconfModule;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.RestconfState;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.restconf.state.Capabilities;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@Test
public void restconfStateCapabilitesTest() {
- final Module monitoringModule = schemaContextMonitoring.findModule(MonitoringModule.MODULE_QNAME).get();
+ final Module monitoringModule = schemaContextMonitoring.findModule(RestconfState.QNAME.getModule()).get();
final ContainerNode normNode = RestconfMappingNodeUtil.mapCapabilites(monitoringModule);
assertNotNull(normNode);
final List<Object> listOfValues = new ArrayList<>();
for (final DataContainerChild<?, ?> child : normNode.getValue()) {
- if (child.getNodeType().equals(MonitoringModule.CONT_CAPABILITES_QNAME)) {
+ if (child.getNodeType().equals(Capabilities.QNAME)) {
for (final DataContainerChild<?, ?> dataContainerChild : ((ContainerNode) child).getValue()) {
for (final Object entry : ((LeafSetNode<?>) dataContainerChild).getValue()) {
listOfValues.add(((LeafSetEntryNode<?>) entry).getValue());
}
}
}
- assertTrue(listOfValues.contains(QueryParams.DEPTH));
- assertTrue(listOfValues.contains(QueryParams.FIELDS));
- assertTrue(listOfValues.contains(QueryParams.FILTER));
- assertTrue(listOfValues.contains(QueryParams.REPLAY));
- assertTrue(listOfValues.contains(QueryParams.WITH_DEFAULTS));
+ assertTrue(listOfValues.contains(Rfc8040.Capabilities.DEPTH));
+ assertTrue(listOfValues.contains(Rfc8040.Capabilities.FIELDS));
+ assertTrue(listOfValues.contains(Rfc8040.Capabilities.FILTER));
+ assertTrue(listOfValues.contains(Rfc8040.Capabilities.REPLAY));
+ assertTrue(listOfValues.contains(Rfc8040.Capabilities.WITH_DEFAULTS));
}
@Test
final URI uri = new URI("uri");
final Map<QName, Object> map = prepareMap("notifi", uri, start, outputType);
- map.put(MonitoringModule.LEAF_DESCR_STREAM_QNAME, "Notifi");
+ map.put(RestconfMappingNodeUtil.DESCRIPTION_QNAME, "Notifi");
final QName notifiQName = QName.create("urn:nested:module", "2014-06-03", "notifi");
final MapEntryNode mappedData = RestconfMappingNodeUtil.mapYangNotificationStreamByIetfRestconfMonitoring(
private static Map<QName, Object> prepareMap(final String name, final URI uri, final Instant start,
final String outputType) {
final Map<QName, Object> map = new HashMap<>();
- map.put(MonitoringModule.LEAF_NAME_STREAM_QNAME, name);
- map.put(MonitoringModule.LEAF_LOCATION_ACCESS_QNAME, uri.toString());
- map.put(MonitoringModule.LEAF_REPLAY_SUPP_STREAM_QNAME, Boolean.TRUE);
- map.put(MonitoringModule.LEAF_START_TIME_STREAM_QNAME, DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(
+ map.put(RestconfMappingNodeUtil.NAME_QNAME, name);
+ map.put(RestconfMappingNodeUtil.LOCATION_QNAME, uri.toString());
+ map.put(RestconfMappingNodeUtil.REPLAY_SUPPORT_QNAME, Boolean.TRUE);
+ map.put(RestconfMappingNodeUtil.REPLAY_LOG_CREATION_TIME, DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(
OffsetDateTime.ofInstant(start, ZoneId.systemDefault())));
- map.put(MonitoringModule.LEAF_ENCODING_ACCESS_QNAME, outputType);
+ map.put(RestconfMappingNodeUtil.ENCODING_QNAME, outputType);
return map;
}