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(); }
@Override public SchemaPath getPath() { return delegate.getPath(); }
@Override public Optional<String> getDescription() { return delegate.getDescription(); }
@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); } }
private Method findRpcMethod(final Class<? extends RpcService> key, final RpcDefinition rpcDef) throws NoSuchMethodException { final String methodName = BindingMapping.getMethodName(rpcDef.getQName()); if(rpcDef.getInput() != null) { final Class<?> inputClz = runtimeContext().getClassForSchema(rpcDef.getInput()); return key.getMethod(methodName, inputClz); } return key.getMethod(methodName); }
@Override public QName getQName() { return delegate.getQName(); }
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); }
public static CharSequence writeRPC(final RpcDefinition rpc) { StringConcatenation _builder = new StringConcatenation(); _builder.append("rpc "); QName _qName = rpc.getQName(); String _localName = _qName.getLocalName(); _builder.append(_localName, ""); String _description = rpc.getDescription(); boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(_description); boolean _not = (!_isNullOrEmpty); _builder.append(" "); _builder.append("\""); String _description_1 = rpc.getDescription(); _builder.append(_description_1, " "); _builder.append("\";"); Set<GroupingDefinition> _groupings = rpc.getGroupings(); boolean _isNullOrEmpty_1 = IterableExtensions.isNullOrEmpty(_groupings); boolean _not_1 = (!_isNullOrEmpty_1); if (_not_1) { _builder.append(" "); Set<GroupingDefinition> _groupings_1 = rpc.getGroupings(); CharSequence _writeGroupingDefs = YangTemplate.writeGroupingDefs(_groupings_1); _builder.append(_writeGroupingDefs, " "); ContainerSchemaNode _input = rpc.getInput(); boolean _notEquals = (!Objects.equal(_input, null)); if (_notEquals) { _builder.append(" ");
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; }
public Object invoke(final Object o,final Method method, final Object[] objects) throws Exception { for (RpcDefinition rpcDef:module.getRpcs()){ if (method.getName().equals(BindingMapping.getMethodName(rpcDef.getQName()))){ String rpcMethodName = rpcDef.getQName().getLocalName(); Document rpcInputDoc = null; for (Object component:objects){ final DataSchemaNode rpcOutputSchema = rpcDef.getOutput(); return client.post(ResourceUri.OPERATIONS.getPath() + "/" + moduleName + ":" + rpcMethodName,payloadString,new Function<ClientResponse, Object>() { @Override
public ContainerSchemaNode getInput() { return delegate.getInput(); }
public ContainerSchemaNode getOutput() { return delegate.getOutput(); }
@Override public boolean apply(final RpcDefinition input) { return input.getQName().getLocalName().equals(CreateSubscription.CREATE_SUBSCRIPTION); } }), null);
public static RpcRoutingStrategy from(final RpcDefinition rpc) { ContainerSchemaNode input = rpc.getInput(); if (input != null) { for (DataSchemaNode schemaNode : input.getChildNodes()) { Optional<QName> context = getRoutingContext(schemaNode); if (context.isPresent()) { return new RoutedRpcStrategy(rpc.getQName(), context.get(), schemaNode.getQName()); } } } return new GlobalRpcStrategy(rpc.getQName()); }
final String rpcName = BindingMapping.getClassName(rpc.getQName()); final String rpcMethodName = BindingMapping.getPropertyName(rpcName); final String rpcComment = rpc.getDescription(); final MethodSignatureBuilder method = interfaceBuilder.addMethod(rpcMethodName); final ContainerSchemaNode input = rpc.getInput(); final ContainerSchemaNode output = rpc.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); } } }
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());
if(currentMappedRpcs.get(rpcQName).getInput() == null) { return new NetconfMessage(prepareDomResultForRpcRequest(rpcQName).getNode().getOwnerDocument());