import org.opendaylight.restconf.server.api.DataPutResult;
import org.opendaylight.restconf.server.api.ModulesGetResult;
import org.opendaylight.restconf.server.api.OperationsGetResult;
+import org.opendaylight.restconf.server.api.OperationsPostResult;
import org.opendaylight.restconf.server.api.RestconfServer;
-import org.opendaylight.restconf.server.spi.OperationOutput;
import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.common.YangConstants;
private void operationsPOST(final ApiPath identifier, final UriInfo uriInfo, final AsyncResponse ar,
final OperationInputBody body) {
server.operationsPOST(uriInfo.getBaseUri(), identifier, body)
- .addCallback(new JaxRsRestconfCallback<OperationOutput>(ar) {
+ .addCallback(new JaxRsRestconfCallback<OperationsPostResult>(ar) {
@Override
- Response transform(final OperationOutput result) {
+ Response transform(final OperationsPostResult result) {
final var body = result.output();
return body == null ? Response.noContent().build()
: Response.ok().entity(new NormalizedNodePayload(result.operation(), body)).build();
import org.opendaylight.restconf.server.api.DataPostResult.CreateResource;
import org.opendaylight.restconf.server.api.DataPutResult;
import org.opendaylight.restconf.server.api.DatabindContext;
+import org.opendaylight.restconf.server.api.OperationsPostResult;
import org.opendaylight.restconf.server.spi.OperationInput;
-import org.opendaylight.restconf.server.spi.OperationOutput;
import org.opendaylight.restconf.server.spi.RpcImplementation;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.with.defaults.rev110601.WithDefaultsMode;
import org.opendaylight.yangtools.yang.common.Empty;
y -> builder.addChild((T) prepareData(y.getValue(), stateMap.get(y.getKey()))));
}
- public @NonNull RestconfFuture<OperationOutput> invokeRpc(final URI restconfURI, final QName type,
+ public @NonNull RestconfFuture<OperationsPostResult> invokeRpc(final URI restconfURI, final QName type,
final OperationInput input) {
final var local = localRpcs.get(type);
if (local != null) {
ErrorType.PROTOCOL, ErrorTag.OPERATION_NOT_SUPPORTED));
}
- final var ret = new SettableRestconfFuture<OperationOutput>();
+ final var ret = new SettableRestconfFuture<OperationsPostResult>();
Futures.addCallback(rpcService.invokeRpc(requireNonNull(type), input.input()),
new FutureCallback<DOMRpcResult>() {
@Override
* 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.server.spi;
+package org.opendaylight.restconf.server.api;
import static java.util.Objects.requireNonNull;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.restconf.server.api.DatabindAware;
-import org.opendaylight.restconf.server.api.DatabindContext;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
/**
- * Output of {@link RpcImplementation#invoke(java.net.URI, OperationInput)}.
+ * RESTCONF {@code /operations} content for a {@code POST} operation as per
+ * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-3.6">RFC8040 Operation Resource</a>.
+ *
+ * @param databind Associated {@link DatabindContext}
+ * @param operation An {@link Inference} pointing to the invoked operation
+ * @param output Operation output, or {@code null} if output would be empty
*/
-public record OperationOutput(
+public record OperationsPostResult(
@NonNull DatabindContext databind,
@NonNull Inference operation,
@Nullable ContainerNode output) implements DatabindAware {
- public OperationOutput {
+ public OperationsPostResult {
requireNonNull(databind);
requireNonNull(operation);
if (output != null && output.isEmpty()) {
import org.opendaylight.restconf.nb.rfc8040.databind.ResourceBody;
import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
import org.opendaylight.restconf.server.api.DataPostResult.CreateResource;
-import org.opendaylight.restconf.server.spi.OperationOutput;
import org.opendaylight.yangtools.yang.common.Empty;
/**
* @param restconfURI Base URI of the request
* @param operation {@code <operation>} path, really an {@link ApiPath} to an {@code rpc}
* @param body RPC operation
- * @return A {@link RestconfFuture} completing with {@link OperationOutput}
+ * @return A {@link RestconfFuture} completing with {@link OperationsPostResult}
*/
// FIXME: 'operation' should really be an ApiIdentifier with non-null module, but we also support ang-ext:mount,
// and hence it is a path right now
// FIXME: use ApiPath instead of String
- RestconfFuture<OperationOutput> operationsPOST(URI restconfURI, ApiPath operation, OperationInputBody body);
+ RestconfFuture<OperationsPostResult> operationsPOST(URI restconfURI, ApiPath operation, OperationInputBody body);
/**
* Return the revision of {@code ietf-yang-library} module implemented by this server, as defined in
import org.opendaylight.restconf.server.api.DatabindContext;
import org.opendaylight.restconf.server.api.ModulesGetResult;
import org.opendaylight.restconf.server.api.OperationsGetResult;
+import org.opendaylight.restconf.server.api.OperationsPostResult;
import org.opendaylight.restconf.server.api.RestconfServer;
import org.opendaylight.restconf.server.spi.DatabindProvider;
import org.opendaylight.restconf.server.spi.OperationInput;
-import org.opendaylight.restconf.server.spi.OperationOutput;
import org.opendaylight.restconf.server.spi.RpcImplementation;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev170126.YangApi;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev170126.restconf.Restconf;
}
@Override
- public RestconfFuture<OperationOutput> operationsPOST(final URI restconfURI, final ApiPath apiPath,
+ public RestconfFuture<OperationsPostResult> operationsPOST(final URI restconfURI, final ApiPath apiPath,
final OperationInputBody body) {
final var reqPath = bindRequestPath(localStrategy(), apiPath);
final var inference = reqPath.inference();
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfFuture;
import org.opendaylight.restconf.nb.rfc8040.utils.parser.IdentifierCodec;
+import org.opendaylight.restconf.server.api.OperationsPostResult;
import org.opendaylight.restconf.server.spi.OperationInput;
-import org.opendaylight.restconf.server.spi.OperationOutput;
import org.opendaylight.restconf.server.spi.RestconfStream;
import org.opendaylight.restconf.server.spi.RpcImplementation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.device.notification.rev221106.SubscribeDeviceNotification;
}
@Override
- public RestconfFuture<OperationOutput> invoke(final URI restconfURI, final OperationInput input) {
+ public RestconfFuture<OperationsPostResult> invoke(final URI restconfURI, final OperationInput input) {
final var body = input.input();
final var pathLeaf = body.childByArg(DEVICE_NOTIFICATION_PATH_NODEID);
if (pathLeaf == null) {
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfFuture;
import org.opendaylight.restconf.nb.rfc8040.utils.parser.IdentifierCodec;
+import org.opendaylight.restconf.server.api.OperationsPostResult;
import org.opendaylight.restconf.server.spi.DatabindProvider;
import org.opendaylight.restconf.server.spi.OperationInput;
-import org.opendaylight.restconf.server.spi.OperationOutput;
import org.opendaylight.restconf.server.spi.RestconfStream;
import org.opendaylight.restconf.server.spi.RpcImplementation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateDataChangeEventSubscription;
* </pre>
*/
@Override
- public RestconfFuture<OperationOutput> invoke(final URI restconfURI, final OperationInput input) {
+ public RestconfFuture<OperationsPostResult> invoke(final URI restconfURI, final OperationInput input) {
final var body = input.input();
final var datastoreName = leaf(body, DATASTORE_NODEID, String.class);
final var datastore = datastoreName != null ? LogicalDatastoreType.valueOf(datastoreName)
import org.opendaylight.mdsal.dom.api.DOMNotificationService;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfFuture;
+import org.opendaylight.restconf.server.api.OperationsPostResult;
import org.opendaylight.restconf.server.spi.DatabindProvider;
import org.opendaylight.restconf.server.spi.OperationInput;
-import org.opendaylight.restconf.server.spi.OperationOutput;
import org.opendaylight.restconf.server.spi.RestconfStream;
import org.opendaylight.restconf.server.spi.RpcImplementation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.CreateDataChangeEventSubscriptionOutput;
}
@Override
- public RestconfFuture<OperationOutput> invoke(final URI restconfURI, final OperationInput input) {
+ public RestconfFuture<OperationsPostResult> invoke(final URI restconfURI, final OperationInput input) {
final var body = input.input();
final var qnames = ((LeafSetNode<String>) body.getChildByArg(NOTIFICATIONS)).body().stream()
.map(LeafSetEntryNode::body)
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.restconf.server.api.DatabindAware;
import org.opendaylight.restconf.server.api.DatabindContext;
+import org.opendaylight.restconf.server.api.OperationsPostResult;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
}
/**
- * Create an {@link OperationOutput} with equal {@link #databind()} and {@link #operation()}.
+ * Create an {@link OperationsPostResult} with equal {@link #databind()} and {@link #operation()}.
*
* @param output Output payload
- * @return An {@link OperationOutput}
+ * @return An {@link OperationsPostResult}
*/
- public OperationOutput newOperationOutput(final @Nullable ContainerNode output) {
- return new OperationOutput(databind, operation, output);
+ public OperationsPostResult newOperationOutput(final @Nullable ContainerNode output) {
+ return new OperationsPostResult(databind, operation, output);
}
}
\ No newline at end of file
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.restconf.common.errors.RestconfFuture;
+import org.opendaylight.restconf.server.api.OperationsPostResult;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
* @param input RPC input
* @return Future RPC output
*/
- public abstract RestconfFuture<OperationOutput> invoke(URI restconfURI, OperationInput input);
+ public abstract RestconfFuture<OperationsPostResult> invoke(URI restconfURI, OperationInput input);
@Override
public final String toString() {