public ContainerSchemaNode getOutput() { return delegate.getOutput(); }
@Override public Collection<DataSchemaNode> getChildNodes() { final ContainerSchemaNode input = rpcDefinition.getInput(); final ContainerSchemaNode output = rpcDefinition.getOutput(); if (input == null && output == null) { return ImmutableList.of(); } else if (input != null && output != null) { return ImmutableList.of(input,output); } else if (input != null) { return ImmutableList.of(input); } else { return ImmutableList.of(output); } }
@Override public Collection<DataSchemaNode> getChildNodes() { final ContainerSchemaNode input = rpcDefinition.getInput(); final ContainerSchemaNode output = rpcDefinition.getOutput(); if (input == null && output == null) { return ImmutableList.of(); } else if (input != null && output != null) { return ImmutableList.of(input,output); } else if (input != null) { return ImmutableList.of(input); } else { return ImmutableList.of(output); } }
@Override public Optional<DataSchemaNode> findDataChildByName(final QName name) { switch (name.getLocalName()) { case "input": return Optional.of(rpcDefinition.getInput()); case "output": return Optional.of(rpcDefinition.getOutput()); default: return Optional.empty(); } }
@Override public Optional<DataSchemaNode> findDataChildByName(final QName name) { switch (name.getLocalName()) { case "input": return Optional.of(rpcDefinition.getInput()); case "output": return Optional.of(rpcDefinition.getOutput()); default: return Optional.empty(); } }
@Override public Optional<DataSchemaNode> findDataChildByName(final QName name) { // FIXME: check QNameModule switch (name.getLocalName()) { case "input": return Optional.of(delegate.getInput()); case "output": return Optional.of(delegate.getOutput()); default: return Optional.empty(); } }
private static Optional<DataNodeContainer> findInputOutput(final RpcDefinition rpc, final String targetType) { final String rpcName = BindingMapping.getClassName(rpc.getQName()); final String rpcInputName = rpcName + BindingMapping.RPC_INPUT_SUFFIX; if (targetType.equals(rpcInputName)) { return Optional.of(rpc.getInput()); } final String rpcOutputName = rpcName + BindingMapping.RPC_OUTPUT_SUFFIX; if (targetType.equals(rpcOutputName)) { return Optional.of(rpc.getOutput()); } return Optional.empty(); }
private static Optional<DataNodeContainer> findInputOutput(final RpcDefinition rpc, final String targetType) { String rpcName = BindingMapping.getClassName(rpc.getQName()); String rpcInputName = rpcName + BindingMapping.RPC_INPUT_SUFFIX; String rpcOutputName = rpcName + BindingMapping.RPC_OUTPUT_SUFFIX; if(targetType.equals(rpcInputName)) { return Optional.<DataNodeContainer>of(rpc.getInput()); } else if (targetType.equals(rpcOutputName)) { return Optional.<DataNodeContainer>of(rpc.getOutput()); } return Optional.absent(); }
/** * Returns RPC input or output schema based on supplied QName. * * @param rpc RPC Definition * @param qname input or output QName with namespace same as RPC * @return input or output schema. Returns null if RPC does not have input/output specified. */ public static @Nullable ContainerSchemaNode getRpcDataSchema(final @NonNull RpcDefinition rpc, final @NonNull QName qname) { requireNonNull(rpc, "Rpc Schema must not be null"); switch (requireNonNull(qname, "QName must not be null").getLocalName()) { case "input": return rpc.getInput(); case "output": return rpc.getOutput(); default: throw new IllegalArgumentException("Supplied qname " + qname + " does not represent rpc input or output."); } } }
/** * Returns RPC input or output schema based on supplied QName. * * @param rpc RPC Definition * @param qname input or output QName with namespace same as RPC * @return input or output schema. Returns null if RPC does not have input/output specified. */ public static @Nullable ContainerSchemaNode getRpcDataSchema(final @NonNull RpcDefinition rpc, final @NonNull QName qname) { requireNonNull(rpc, "Rpc Schema must not be null"); switch (requireNonNull(qname, "QName must not be null").getLocalName()) { case "input": return rpc.getInput(); case "output": return rpc.getOutput(); default: throw new IllegalArgumentException("Supplied qname " + qname + " does not represent rpc input or output."); } } }
static List<TypeDefinition<?>> getAllTypedefs(final Module module) { final List<TypeDefinition<?>> ret = new ArrayList<>(); fillRecursively(ret, module); final Set<NotificationDefinition> notifications = module.getNotifications(); for (NotificationDefinition notificationDefinition : notifications) { fillRecursively(ret, notificationDefinition); } final Set<RpcDefinition> rpcs = module.getRpcs(); for (RpcDefinition rpcDefinition : rpcs) { ret.addAll(rpcDefinition.getTypeDefinitions()); fillRecursively(ret, rpcDefinition.getInput()); fillRecursively(ret, rpcDefinition.getOutput()); } return ret; }
/** * Process the RPCs for a Module Spits out a file each of the name <rpcName>-input.json and <rpcName>-output.json * for each RPC that contains input & output elements * * @param module * @throws JSONException * @throws IOException */ private void processRPCs(final Module module, final JSONObject models, final SchemaContext schemaContext) throws JSONException, IOException { Set<RpcDefinition> rpcs = module.getRpcs(); String moduleName = module.getName(); for (RpcDefinition rpc : rpcs) { ContainerSchemaNode input = rpc.getInput(); if (input != null) { JSONObject inputJSON = processDataNodeContainer(input, moduleName, models, schemaContext); String filename = "(" + rpc.getQName().getLocalName() + ")input"; inputJSON.put("id", filename); // writeToFile(filename, inputJSON.toString(2), moduleName); models.put(filename, inputJSON); } ContainerSchemaNode output = rpc.getOutput(); if (output != null) { JSONObject outputJSON = processDataNodeContainer(output, moduleName, models, schemaContext); String filename = "(" + rpc.getQName().getLocalName() + ")output"; outputJSON.put("id", filename); models.put(filename, outputJSON); } } }
if (rpcDefinition.getOutput() == null) { Preconditions.checkArgument(XmlElement.fromDomDocument(message.getDocument()).getOnlyChildElementWithSameNamespaceOptionally("ok").isPresent(), "Unexpected content in response of rpc: %s, %s", rpcDefinition.getQName(), message); normalizedNode = null; } else { normalizedNode = parserFactory.getContainerNodeParser().parse(documentElement, rpcDefinition.getOutput());
private void traverseModule(final DataNodeContainer dataNode) { final Module module; if (dataNode instanceof Module) { module = (Module) dataNode; } else { return; } final Set<NotificationDefinition> notifications = module.getNotifications(); for (NotificationDefinition notificationDefinition : notifications) { traverse(notificationDefinition); } final Set<RpcDefinition> rpcs = module.getRpcs(); for (RpcDefinition rpcDefinition : rpcs) { this.allTypedefs.addAll(rpcDefinition.getTypeDefinitions()); ContainerSchemaNode input = rpcDefinition.getInput(); if (input != null) { traverse(input); } ContainerSchemaNode output = rpcDefinition.getOutput(); if (output != null) { traverse(output); } } }
private void traverseModule(final DataNodeContainer dataNode) { final Module module; if (dataNode instanceof Module) { module = (Module) dataNode; } else { return; } final Set<NotificationDefinition> notifications = module.getNotifications(); for (NotificationDefinition notificationDefinition : notifications) { traverse(notificationDefinition); } final Set<RpcDefinition> rpcs = module.getRpcs(); for (RpcDefinition rpcDefinition : rpcs) { this.allTypedefs.addAll(rpcDefinition.getTypeDefinitions()); ContainerSchemaNode input = rpcDefinition.getInput(); if (input != null) { traverse(input); } ContainerSchemaNode output = rpcDefinition.getOutput(); if (output != null) { traverse(output); } } }
return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0)); return (Element) transformNormalizedNode(document, result.getResult(), rpcDefinition.getOutput().getPath()); } catch (DOMRpcException e) { throw DocumentedException.wrap(e);
path = ((RpcDefinition) context.getSchemaNode()).getOutput().getPath(); nnWriter = createNormalizedNodeWriter(context,path,jsonWriter, depth); jsonWriter.name("output");
protected void addRpcs(RpcDefinition rpcDefn, List<Api> apis, String parentPath, SchemaContext schemaContext) { Api rpc = new Api(); String resourcePath = parentPath + resolvePathArgumentsName(rpcDefn, schemaContext); rpc.setPath(resourcePath); Operation operationSpec = new Operation(); operationSpec.setMethod("POST"); operationSpec.setNotes(rpcDefn.getDescription()); operationSpec.setNickname(rpcDefn.getQName().getLocalName()); if (rpcDefn.getOutput() != null) { operationSpec.setType("(" + rpcDefn.getQName().getLocalName() + ")output"); } if (rpcDefn.getInput() != null) { Parameter payload = new Parameter(); payload.setParamType("body"); payload.setType("(" + rpcDefn.getQName().getLocalName() + ")input"); operationSpec.setParameters(Collections.singletonList(payload)); operationSpec.setConsumes(OperationBuilder.CONSUMES_PUT_POST); } rpc.setOperations(Arrays.asList(operationSpec)); apis.add(rpc); }
"Create stream RPC output can not be null!"); final QName outputQname = rpcSchemaNode.getOutput().getQName(); final QName streamNameQname = QName.create(rpcQName, "stream-name");
private void writeNormalizedNode(XMLStreamWriter xmlWriter, SchemaPath schemaPath, InstanceIdentifierContext<?> pathContext, NormalizedNode<?, ?> data, Optional<Integer> depth) throws IOException { final RestconfNormalizedNodeWriter nnWriter; final SchemaContext schemaCtx = pathContext.getSchemaContext(); if (SchemaPath.ROOT.equals(schemaPath)) { nnWriter = createNormalizedNodeWriter(xmlWriter, schemaCtx, schemaPath, depth); writeElements(xmlWriter, nnWriter, (ContainerNode) data); } else if (pathContext.getSchemaNode() instanceof RpcDefinition) { nnWriter = createNormalizedNodeWriter(xmlWriter, schemaCtx, ((RpcDefinition) pathContext.getSchemaNode()).getOutput().getPath(), depth); writeElements(xmlWriter, nnWriter, (ContainerNode) data); } else { nnWriter = createNormalizedNodeWriter(xmlWriter, schemaCtx, schemaPath.getParent(), depth); if (data instanceof MapEntryNode) { // Restconf allows returning one list item. We need to wrap it // in map node in order to serialize it properly data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).addChild((MapEntryNode) data).build(); } nnWriter.write(data); } nnWriter.flush(); }