package org.opendaylight.restconf.nb.rfc8040;
import static java.util.Objects.requireNonNull;
-import static org.opendaylight.restconf.nb.rfc8040.ReceiveEventsParams.optionalParam;
+import static org.opendaylight.restconf.server.api.EventStreamGetParams.optionalParam;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import javax.ws.rs.sse.Sse;
import javax.ws.rs.sse.SseEventSink;
import javax.xml.xpath.XPathExpressionException;
-import org.opendaylight.restconf.nb.rfc8040.ReceiveEventsParams;
+import org.opendaylight.restconf.server.api.EventStreamGetParams;
import org.opendaylight.restconf.server.spi.RestconfStream;
import org.opendaylight.restconf.server.spi.RestconfStream.EncodingName;
import org.opendaylight.restconf.server.spi.RestconfStream.Sender;
private final PingExecutor pingExecutor;
private final RestconfStream<?> stream;
private final EncodingName encoding;
- private final ReceiveEventsParams params;
+ private final EventStreamGetParams params;
private final SseEventSink sink;
private final Sse sse;
private final int maximumFragmentLength;
* session up. Ping control frames are disabled if this parameter is set to 0.
*/
SSESender(final PingExecutor pingExecutor, final SseEventSink sink, final Sse sse, final RestconfStream<?> stream,
- final EncodingName encoding, final ReceiveEventsParams params, final int maximumFragmentLength,
+ final EncodingName encoding, final EventStreamGetParams params, final int maximumFragmentLength,
final long heartbeatMillis) {
this.pingExecutor = requireNonNull(pingExecutor);
this.sse = requireNonNull(sse);
import javax.ws.rs.sse.Sse;
import javax.ws.rs.sse.SseEventSink;
import javax.xml.xpath.XPathExpressionException;
-import org.opendaylight.restconf.nb.rfc8040.ReceiveEventsParams;
import org.opendaylight.restconf.nb.rfc8040.databind.jaxrs.QueryParams;
+import org.opendaylight.restconf.server.api.EventStreamGetParams;
import org.opendaylight.restconf.server.spi.RestconfStream;
import org.opendaylight.restconf.server.spi.RestconfStream.EncodingName;
import org.slf4j.Logger;
throw new BadRequestException(e.getMessage(), e);
}
- final ReceiveEventsParams params;
+ final EventStreamGetParams params;
try {
- params = ReceiveEventsParams.ofQueryParameters(queryParameters);
+ params = EventStreamGetParams.ofQueryParameters(queryParameters);
} catch (IllegalArgumentException e) {
throw new BadRequestException(e.getMessage(), e);
}
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketError;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
-import org.opendaylight.restconf.nb.rfc8040.ReceiveEventsParams;
+import org.opendaylight.restconf.server.api.EventStreamGetParams;
import org.opendaylight.restconf.server.spi.RestconfStream;
import org.opendaylight.restconf.server.spi.RestconfStream.EncodingName;
import org.opendaylight.restconf.server.spi.RestconfStream.Sender;
private final PingExecutor pingExecutor;
private final RestconfStream<?> stream;
private final EncodingName encodingName;
- private final ReceiveEventsParams params;
+ private final EventStreamGetParams params;
private final int maximumFragmentLength;
private final long heartbeatInterval;
* to keep session up. Ping control frames are disabled if this parameter is set to 0.
*/
WebSocketSender(final PingExecutor pingExecutor, final RestconfStream<?> stream, final EncodingName encodingName,
- final @Nullable ReceiveEventsParams params, final int maximumFragmentLength, final long heartbeatInterval) {
+ final @Nullable EventStreamGetParams params, final int maximumFragmentLength,
+ final long heartbeatInterval) {
this.pingExecutor = requireNonNull(pingExecutor);
this.stream = requireNonNull(stream);
this.encodingName = requireNonNull(encodingName);
* 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.nb.rfc8040;
+package org.opendaylight.restconf.server.api;
import static java.util.Objects.requireNonNull;
* Query parameters valid in the scope of a GET request on an event stream resource, as outline in
* <a href="https://www.rfc-editor.org/rfc/rfc8040#section-6.3">RFC8040 section 6.3</a>.
*/
-public record ReceiveEventsParams(
+public record EventStreamGetParams(
StartTimeParam startTime,
StopTimeParam stopTime,
FilterParam filter,
SkipNotificationDataParam skipNotificationData,
ChangedLeafNodesOnlyParam changedLeafNodesOnly,
ChildNodesOnlyParam childNodesOnly) {
- public ReceiveEventsParams {
+ public EventStreamGetParams {
if (stopTime != null && startTime == null) {
throw new IllegalArgumentException(StopTimeParam.uriName + " parameter has to be used with "
+ StartTimeParam.uriName + " parameter");
}
/**
- * Return {@link ReceiveEventsParams} for specified query parameters.
+ * Return {@link EventStreamGetParams} for specified query parameters.
*
* @param queryParameters Parameters and their values
- * @return A {@link ReceiveEventsParams}
+ * @return A {@link EventStreamGetParams}
* @throws NullPointerException if {@code queryParameters} is {@code null}
* @throws IllegalArgumentException if the parameters are invalid
*/
- public static @NonNull ReceiveEventsParams ofQueryParameters(final Map<String, String> queryParameters) {
+ public static @NonNull EventStreamGetParams ofQueryParameters(final Map<String, String> queryParameters) {
StartTimeParam startTime = null;
StopTimeParam stopTime = null;
FilterParam filter = null;
}
}
- return new ReceiveEventsParams(startTime, stopTime, filter, leafNodesOnly, skipNotificationData,
+ return new EventStreamGetParams(startTime, stopTime, filter, leafNodesOnly, skipNotificationData,
changedLeafNodesOnly, childNodesOnly);
}
return helper.toString();
}
- static <T> @Nullable T optionalParam(final Function<String, @NonNull T> factory, final String name,
+ // FIXME: find a better place for this method
+ public static <T> @Nullable T optionalParam(final Function<String, @NonNull T> factory, final String name,
final String value) {
try {
return factory.apply(requireNonNull(value));
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.restconf.common.errors.RestconfFuture;
-import org.opendaylight.restconf.nb.rfc8040.ReceiveEventsParams;
+import org.opendaylight.restconf.server.api.EventStreamGetParams;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.restconf.state.streams.stream.Access;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
* @throws XPathExpressionException if requested filter is not valid
*/
public @Nullable Registration addSubscriber(final Sender handler, final EncodingName encoding,
- final ReceiveEventsParams params) throws UnsupportedEncodingException, XPathExpressionException {
+ final EventStreamGetParams params) throws UnsupportedEncodingException, XPathExpressionException {
final var factory = source.encodings.get(requireNonNull(encoding));
if (factory == null) {
throw new UnsupportedEncodingException("Stream '" + name + "' does not support " + encoding);
import org.opendaylight.restconf.api.query.WithDefaultsParam;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.nb.rfc8040.Insert;
-import org.opendaylight.restconf.nb.rfc8040.ReceiveEventsParams;
import org.opendaylight.restconf.nb.rfc8040.legacy.InstanceIdentifierContext;
import org.opendaylight.restconf.nb.rfc8040.legacy.QueryParameters;
import org.opendaylight.restconf.nb.rfc8040.utils.parser.WriterFieldsTranslator;
import org.opendaylight.restconf.server.api.DatabindContext;
+import org.opendaylight.restconf.server.api.EventStreamGetParams;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.QName;
@Test
public void checkParametersTypesNegativeTest() {
final var mockDatabind = DatabindContext.ofModel(mock(EffectiveModelContext.class));
- assertInvalidIAE(ReceiveEventsParams::ofQueryParameters);
+ assertInvalidIAE(EventStreamGetParams::ofQueryParameters);
assertUnknownParam(QueryParams::newDataGetParams);
assertInvalidIAE(queryParams -> Insert.ofQueryParameters(mockDatabind, queryParams));
- assertInvalidIAE(ReceiveEventsParams::ofQueryParameters, ContentParam.ALL);
+ assertInvalidIAE(EventStreamGetParams::ofQueryParameters, ContentParam.ALL);
assertInvalidParam(QueryParams::newDataGetParams, InsertParam.LAST);
assertInvalidIAE(queryParams -> Insert.ofQueryParameters(mockDatabind, queryParams), ContentParam.ALL);
}
import org.opendaylight.restconf.api.query.ChildNodesOnlyParam;
import org.opendaylight.restconf.api.query.LeafNodesOnlyParam;
import org.opendaylight.restconf.api.query.SkipNotificationDataParam;
-import org.opendaylight.restconf.nb.rfc8040.ReceiveEventsParams;
import org.opendaylight.restconf.server.api.DatabindContext;
+import org.opendaylight.restconf.server.api.EventStreamGetParams;
import org.opendaylight.restconf.server.mdsal.MdsalRestconfStreamRegistry;
import org.opendaylight.restconf.server.mdsal.streams.dtcl.DataTreeChangeSource;
import org.opendaylight.restconf.server.spi.DatabindProvider;
case JSON -> EncodingName.RFC8040_JSON;
case XML -> EncodingName.RFC8040_XML;
},
- new ReceiveEventsParams(null, null, null,
+ new EventStreamGetParams(null, null, null,
leafNodesOnly ? LeafNodesOnlyParam.of(true) : null,
skipNotificationData ? SkipNotificationDataParam.of(true) : null,
changedLeafNodesOnly ? ChangedLeafNodesOnlyParam.of(true) : null,
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import org.opendaylight.restconf.nb.rfc8040.ReceiveEventsParams;
+import org.opendaylight.restconf.server.api.EventStreamGetParams;
import org.opendaylight.restconf.server.spi.RestconfStream;
import org.opendaylight.restconf.server.spi.RestconfStream.EncodingName;
import org.opendaylight.yangtools.concepts.Registration;
private SSESender setup(final int maxFragmentSize, final long heartbeatInterval) throws Exception {
final var sseSessionHandler = new SSESender(pingExecutor, eventSink, sse, stream,
- EncodingName.RFC8040_XML, new ReceiveEventsParams(null, null, null, null, null, null, null),
+ EncodingName.RFC8040_XML, new EventStreamGetParams(null, null, null, null, null, null, null),
maxFragmentSize, heartbeatInterval);
doReturn(reg).when(stream).addSubscriber(eq(sseSessionHandler), any(), any());
return sseSessionHandler;