return RestconfFuture.of(new NormalizedNodePayload(reqPath.inference(), node, queryParams));
}
+ @Override
+ public RestconfFuture<Empty> dataPATCH(final ResourceBody body) {
+ return dataPATCH(bindRequestRoot(), body);
+ }
+
+ @Override
+ public RestconfFuture<Empty> dataPATCH(final String identifier, final ResourceBody body) {
+ return dataPATCH(bindRequestPath(identifier), body);
+ }
+
+ private @NonNull RestconfFuture<Empty> dataPATCH(final InstanceIdentifierContext reqPath, final ResourceBody body) {
+ final var req = bindResourceRequest(reqPath, body);
+ return req.strategy().merge(req.path(), req.data());
+ }
+
// FIXME: should follow the same pattern as operationsPOST() does
RestconfFuture<DOMActionResult> dataInvokePOST(final InstanceIdentifierContext reqPath,
final OperationInputBody body) {
return uriInfo.getBaseUriBuilder().path("data").path(IdentifierCodec.serialize(path, schemaContext)).build();
}
- /**
- * Partially modify the target data store, as defined in
- * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
- *
- * @param body data node for put to config DS
- * @param ar {@link AsyncResponse} which needs to be completed
- */
- @PATCH
- @Path("/data")
- @Consumes({
- MediaTypes.APPLICATION_YANG_DATA_XML,
- MediaType.APPLICATION_XML,
- MediaType.TEXT_XML
- })
- public void plainPatchDataXML(final InputStream body, @Suspended final AsyncResponse ar) {
- try (var xmlBody = new XmlResourceBody(body)) {
- plainPatchData(xmlBody, ar);
- }
- }
-
- /**
- * Partially modify the target data resource, as defined in
- * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
- *
- * @param identifier path to target
- * @param body data node for put to config DS
- * @param ar {@link AsyncResponse} which needs to be completed
- */
- @PATCH
- @Path("/data/{identifier:.+}")
- @Consumes({
- MediaTypes.APPLICATION_YANG_DATA_XML,
- MediaType.APPLICATION_XML,
- MediaType.TEXT_XML
- })
- public void plainPatchDataXML(@Encoded @PathParam("identifier") final String identifier, final InputStream body,
- @Suspended final AsyncResponse ar) {
- try (var xmlBody = new XmlResourceBody(body)) {
- plainPatchData(identifier, xmlBody, ar);
- }
- }
-
- /**
- * Partially modify the target data store, as defined in
- * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
- *
- * @param body data node for put to config DS
- * @param ar {@link AsyncResponse} which needs to be completed
- */
- @PATCH
- @Path("/data")
- @Consumes({
- MediaTypes.APPLICATION_YANG_DATA_JSON,
- MediaType.APPLICATION_JSON,
- })
- public void plainPatchDataJSON(final InputStream body, @Suspended final AsyncResponse ar) {
- try (var jsonBody = new JsonResourceBody(body)) {
- plainPatchData(jsonBody, ar);
- }
- }
-
- /**
- * Partially modify the target data resource, as defined in
- * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
- *
- * @param identifier path to target
- * @param body data node for put to config DS
- * @param ar {@link AsyncResponse} which needs to be completed
- */
- @PATCH
- @Path("/data/{identifier:.+}")
- @Consumes({
- MediaTypes.APPLICATION_YANG_DATA_JSON,
- MediaType.APPLICATION_JSON,
- })
- public void plainPatchDataJSON(@Encoded @PathParam("identifier") final String identifier, final InputStream body,
- @Suspended final AsyncResponse ar) {
- try (var jsonBody = new JsonResourceBody(body)) {
- plainPatchData(identifier, jsonBody, ar);
- }
- }
-
- /**
- * Partially modify the target data resource, as defined in
- * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
- *
- * @param body data node for put to config DS
- * @param ar {@link AsyncResponse} which needs to be completed
- */
- private void plainPatchData(final ResourceBody body, final AsyncResponse ar) {
- plainPatchData(server.bindRequestRoot(), body, ar);
- }
-
- /**
- * Partially modify the target data resource, as defined in
- * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
- *
- * @param identifier path to target
- * @param body data node for put to config DS
- * @param ar {@link AsyncResponse} which needs to be completed
- */
- private void plainPatchData(final String identifier, final ResourceBody body, final AsyncResponse ar) {
- plainPatchData(server.bindRequestPath(identifier), body, ar);
- }
-
- /**
- * Partially modify the target data resource, as defined in
- * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
- *
- * @param reqPath path to target
- * @param body data node for put to config DS
- * @param ar {@link AsyncResponse} which needs to be completed
- */
- private void plainPatchData(final InstanceIdentifierContext reqPath, final ResourceBody body,
- final AsyncResponse ar) {
- final var req = server.bindResourceRequest(reqPath, body);
- req.strategy().merge(req.path(), req.data()).addCallback(new JaxRsRestconfCallback<>(ar) {
- @Override
- Response transform(final Empty result) {
- return Response.ok().build();
- }
- });
- }
-
/**
* Ordered list of edits that are applied to the target datastore by the server, as defined in
* <a href="https://www.rfc-editor.org/rfc/rfc8072#section-2">RFC8072, section 2</a>.
import javax.ws.rs.Encoded;
import javax.ws.rs.GET;
import javax.ws.rs.NotFoundException;
+import javax.ws.rs.PATCH;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import org.opendaylight.restconf.nb.rfc8040.MediaTypes;
import org.opendaylight.restconf.nb.rfc8040.ReadDataParams;
import org.opendaylight.restconf.nb.rfc8040.databind.JsonOperationInputBody;
+import org.opendaylight.restconf.nb.rfc8040.databind.JsonResourceBody;
import org.opendaylight.restconf.nb.rfc8040.databind.OperationInputBody;
import org.opendaylight.restconf.nb.rfc8040.databind.XmlOperationInputBody;
+import org.opendaylight.restconf.nb.rfc8040.databind.XmlResourceBody;
import org.opendaylight.restconf.nb.rfc8040.databind.jaxrs.QueryParams;
import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
import org.opendaylight.restconf.server.api.OperationsContent;
});
}
+ /**
+ * Partially modify the target data store, as defined in
+ * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
+ *
+ * @param body data node for put to config DS
+ * @param ar {@link AsyncResponse} which needs to be completed
+ */
+ @PATCH
+ @Path("/data")
+ @Consumes({
+ MediaTypes.APPLICATION_YANG_DATA_XML,
+ MediaType.APPLICATION_XML,
+ MediaType.TEXT_XML
+ })
+ public void dataXmlPATCH(final InputStream body, @Suspended final AsyncResponse ar) {
+ try (var xmlBody = new XmlResourceBody(body)) {
+ completeDataPATCH(server.dataPATCH(xmlBody), ar);
+ }
+ }
+
+ /**
+ * Partially modify the target data resource, as defined in
+ * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
+ *
+ * @param identifier path to target
+ * @param body data node for put to config DS
+ * @param ar {@link AsyncResponse} which needs to be completed
+ */
+ @PATCH
+ @Path("/data/{identifier:.+}")
+ @Consumes({
+ MediaTypes.APPLICATION_YANG_DATA_XML,
+ MediaType.APPLICATION_XML,
+ MediaType.TEXT_XML
+ })
+ public void dataXmlPATCH(@Encoded @PathParam("identifier") final String identifier, final InputStream body,
+ @Suspended final AsyncResponse ar) {
+ try (var xmlBody = new XmlResourceBody(body)) {
+ completeDataPATCH(server.dataPATCH(identifier, xmlBody), ar);
+ }
+ }
+
+ /**
+ * Partially modify the target data store, as defined in
+ * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
+ *
+ * @param body data node for put to config DS
+ * @param ar {@link AsyncResponse} which needs to be completed
+ */
+ @PATCH
+ @Path("/data")
+ @Consumes({
+ MediaTypes.APPLICATION_YANG_DATA_JSON,
+ MediaType.APPLICATION_JSON,
+ })
+ public void dataJsonPATCH(final InputStream body, @Suspended final AsyncResponse ar) {
+ try (var jsonBody = new JsonResourceBody(body)) {
+ completeDataPATCH(server.dataPATCH(jsonBody), ar);
+ }
+ }
+
+ /**
+ * Partially modify the target data resource, as defined in
+ * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
+ *
+ * @param identifier path to target
+ * @param body data node for put to config DS
+ * @param ar {@link AsyncResponse} which needs to be completed
+ */
+ @PATCH
+ @Path("/data/{identifier:.+}")
+ @Consumes({
+ MediaTypes.APPLICATION_YANG_DATA_JSON,
+ MediaType.APPLICATION_JSON,
+ })
+ public void dataJsonPATCH(@Encoded @PathParam("identifier") final String identifier, final InputStream body,
+ @Suspended final AsyncResponse ar) {
+ try (var jsonBody = new JsonResourceBody(body)) {
+ completeDataPATCH(server.dataPATCH(identifier, jsonBody), ar);
+ }
+ }
+
+ private static void completeDataPATCH(final RestconfFuture<Empty> future, final AsyncResponse ar) {
+ future.addCallback(new JaxRsRestconfCallback<>(ar) {
+ @Override
+ Response transform(final Empty result) {
+ return Response.ok().build();
+ }
+ });
+ }
+
/**
* List RPC and action operations in RFC7951 format.
*
import org.opendaylight.restconf.common.errors.RestconfFuture;
import org.opendaylight.restconf.nb.rfc8040.ReadDataParams;
import org.opendaylight.restconf.nb.rfc8040.databind.OperationInputBody;
+import org.opendaylight.restconf.nb.rfc8040.databind.ResourceBody;
import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
import org.opendaylight.restconf.server.spi.OperationOutput;
import org.opendaylight.yangtools.yang.common.Empty;
*/
RestconfFuture<NormalizedNodePayload> dataGET(String identifier, ReadDataParams readParams);
+ /**
+ * Partially modify the target data resource, as defined in
+ * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
+ *
+ * @param body data node for put to config DS
+ * @return A {@link RestconfFuture} of the operation
+ */
+ RestconfFuture<Empty> dataPATCH(ResourceBody body);
+
+ /**
+ * Partially modify the target data resource, as defined in
+ * <a href="https://www.rfc-editor.org/rfc/rfc8040#section-4.6.1">RFC8040, section 4.6.1</a>.
+ *
+ * @param identifier resource identifier
+ * @param body data node for put to config DS
+ * @return A {@link RestconfFuture} of the operation
+ */
+ RestconfFuture<Empty> dataPATCH(String identifier, ResourceBody body);
+
/**
* Return the set of supported RPCs supported by {@link #operationsPOST(URI, String, OperationInputBody)}.
*