+
+ final NormalizedNode schemasNode = optSchemasNode.get();
+ checkState(schemasNode instanceof ContainerNode, "Expecting container containing schemas, but was %s",
+ schemasNode);
+ return create(id, (ContainerNode) schemasNode);
+ }
+
+ /**
+ * Parse response of get(netconf-state/schemas) to find all schemas under netconf-state/schemas.
+ */
+ @VisibleForTesting
+ protected static NetconfStateSchemas create(final RemoteDeviceId id, final ContainerNode schemasNode) {
+ final Set<RemoteYangSchema> availableYangSchemas = new HashSet<>();
+
+ final Optional<DataContainerChild> child =
+ schemasNode.findChildByArg(toId(Schema.QNAME));
+ checkState(child.isPresent(), "Unable to find list: %s in response: %s", Schema.QNAME.withoutRevision(),
+ schemasNode);
+ checkState(child.get() instanceof MapNode,
+ "Unexpected structure for container: %s in response: %s. Expecting a list",
+ Schema.QNAME.withoutRevision(), schemasNode);
+
+ for (final MapEntryNode schemaNode : ((MapNode) child.get()).body()) {
+ final Optional<RemoteYangSchema> fromCompositeNode =
+ RemoteYangSchema.createFromNormalizedNode(id, schemaNode);
+ fromCompositeNode.ifPresent(availableYangSchemas::add);
+ }
+
+ return new NetconfStateSchemas(availableYangSchemas);