netconf.git
11 hours agoBump versions to 7.0.6-SNAPSHOT 34/111734/1 master
Robert Varga [Mon, 20 May 2024 07:29:22 +0000 (09:29 +0200)]
Bump versions to 7.0.6-SNAPSHOT

This starts the next development iteration.

Change-Id: Iee9f890451738a8a151ecf057647074447b82e5f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
24 hours agoRelease netconf v7.0.5
jenkins-releng [Sun, 19 May 2024 18:03:50 +0000 (18:03 +0000)]
Release netconf

25 hours agoOpenApi: Refactor inconsistent naming of modelContext 94/111694/5
lubos-cicut [Tue, 14 May 2024 16:17:32 +0000 (18:17 +0200)]
OpenApi: Refactor inconsistent naming of modelContext

In restconf-openapi is inconsistent naming of EffectiveModelContext,
this patch unify it to modelContext.

JIRA: NETCONF-1313
Change-Id: I64face48ef43b59bc489c3058fa5dfa4bcbb4e41
Signed-off-by: lubos-cicut <lubos.cicut@pantheon.tech>
27 hours agoUse ServerException in JaxRsRestconfCallback.transform() 29/111729/2
Robert Varga [Sun, 19 May 2024 15:23:26 +0000 (17:23 +0200)]
Use ServerException in JaxRsRestconfCallback.transform()

We have only a single implementation which throws, convert it to
ServerException.

JIRA: NETCONF-1188
Change-Id: I8127549346956632c311252c57e1dcb4c9d587e6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
27 hours agoReport ServerException from ApiPathCanonizer 28/111728/3
Robert Varga [Sun, 19 May 2024 13:29:45 +0000 (15:29 +0200)]
Report ServerException from ApiPathCanonizer

This is the next step in RDE eradication.

JIRA: NETCONF-1188
Change-Id: I9123b37849636e7d38167b280265d0d900565a96
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
27 hours agoReport ServerException from ApiPathNormalizer 24/111724/4
Robert Varga [Sat, 18 May 2024 22:54:15 +0000 (00:54 +0200)]
Report ServerException from ApiPathNormalizer

This patch takes a step away from RestconfDocumentedException by making
APiPath normalization requests report ServerException instead.

We also update ServerException to match RestconfDocumentedException's
behaviour of reporting cause message in error-info.

JIRA: NETCONF-1188
Change-Id: I51aa91d4b3c914a421fe28a9ed8a517be1e47571
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
27 hours agoEnhance Netconf message handling 74/111474/8
Yaroslav Lastivka [Mon, 22 Apr 2024 08:55:42 +0000 (11:55 +0300)]
Enhance Netconf message handling

Enhance the `onMessage` method in the NetconfServerSession handler to
include detailed response handling and error logging for outgoing
Netconf messages. This update introduces a listener to the
`sendMessage` call, which logs failures to send messages and
confirms successful transmissions. The changes aim to improve
debugging capabilities by providing specific message IDs for
each failed or successful send operation, aiding in better
traceability and error handling in the communication process.

JIRA: NETCONF-1261
Change-Id: I088da6832d3ab267717ee122d53371bf05e8360c
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
44 hours agoMigrate SessionNotificationProducer 23/111723/1
Robert Varga [Sat, 18 May 2024 22:52:10 +0000 (00:52 +0200)]
Migrate SessionNotificationProducer

Sessions pertain to oper state, hence in terms of notifications they are
cluster-global. This changes behaviour towards reflecting what the
injected DOMDataBroker is bound to see.

Change-Id: I35549c5a8ec59364de05fd18e5192992d7d69906
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
46 hours agoRemove DatabindFormattableBody 22/111722/1
Robert Varga [Sat, 18 May 2024 20:37:32 +0000 (22:37 +0200)]
Remove DatabindFormattableBody

This class does not bring much to the party, integrate it into its sole
subclass.

JIRA: NETCONF-773
Change-Id: I8caeedca764b7045ab40ad6d27e9c0af5be5a658
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
46 hours agoUse ServerError in PatchStatus{Context,Entity} 21/111721/1
Robert Varga [Sat, 18 May 2024 20:11:31 +0000 (22:11 +0200)]
Use ServerError in PatchStatus{Context,Entity}

RestconfError is not properly structured, use ServerError, which
correctly models errors. This in turn allows PatchStatusContext to not
have a DatabindContext.

JIRA: NETCONF-1188
Change-Id: I288ad55de771474930362eb570ba315f5b700905
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 days agoUse non-deprecated writeValue() 16/111716/2
Robert Varga [Fri, 17 May 2024 12:32:56 +0000 (14:32 +0200)]
Use non-deprecated writeValue()

Inline the behaviour of the default method to remove two sources of
warnings.

Change-Id: I5716cafff41d33ae916759f761ca48eb59b7456c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 days agoUse simpler parseValue() 15/111715/2
Robert Varga [Fri, 17 May 2024 12:32:04 +0000 (14:32 +0200)]
Use simpler parseValue()

We have parseValue(String), use that instead of playing tricks with
null.

Change-Id: I7c4567ed0fb2db9d018c5aa8e5166910a8e02ed7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 days agoMigrate a user of Builders 14/111714/2
Robert Varga [Fri, 17 May 2024 12:31:33 +0000 (14:31 +0200)]
Migrate a user of Builders

We have ImmutableNodes as a replacement, use that.

Change-Id: I9a41d87982f8ea992e379b75c18e72edc70322ae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 days agoCatch correct exceptions when decrypting password 15/110515/10
Samuel Schneider [Thu, 7 Mar 2024 09:11:13 +0000 (10:11 +0100)]
Catch correct exceptions when decrypting password

Catch correct exceptions when we fail to decrypt password.
It has been changed from IAE to ISE by: 15f04f0 which adopts
improvement made in AAA-266.

This adaptation makes our workaround to work again.

JIRA: NETCONF-1114
Change-Id: I86741e51855cfee687e56b5991ae39a8b08cd9f7
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
3 days agoRemove HackJsonWriter 10/111710/2
Robert Varga [Thu, 16 May 2024 17:04:16 +0000 (19:04 +0200)]
Remove HackJsonWriter

We have a fix for JSONCodec.unparseValue() available, hence we can
remove our HackJsonWriter.

Change-Id: I2c42920835236c3090f3f7fa6752962583b9c1d5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 days agoRemove OperationOutputBody 09/111709/4
Robert Varga [Thu, 16 May 2024 16:36:54 +0000 (18:36 +0200)]
Remove OperationOutputBody

We have a fix for YANGTOOLS-1570 integrated, hence we do not need
to special-case anything -- a plain ContainerNode can we used with an
inference pointing to the operation.

JIRA: NETCONF-773
Change-Id: I0a70e067a796a7197a80d0312fdce90f793f08df
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 days agoCapabilities unavailable for yang models without revision 51/111351/4
Yaroslav Lastivka [Thu, 11 Apr 2024 06:18:10 +0000 (09:18 +0300)]
Capabilities unavailable for yang models without revision

The updated logic now gracefully handles optional revisions
by defaulting to an empty string ("") when the revision is not present.
This change ensures that capabilities for Yang models without
a specified revision can be retrieved successfully, aligning
with modifications in the netconf module that now require an
empty string to represent models without a revision.

JIRA: NETCONF-1263
Change-Id: I65da21f877f572cc227ac5ec1ca8c76bf66a8b77
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
3 days agoOpenAPI: Generate document for module without revision 22/111522/5
lubos-cicut [Fri, 26 Apr 2024 04:08:49 +0000 (06:08 +0200)]
OpenAPI: Generate document for module without revision

Changed revision to @QueryParam. So now we have to use
/mounts/1/toaster?revision=2009-11-20 for module with revision and
/mounts/1/definition-test for module without revision.

JIRA: NETCONF-1303
Change-Id: Ia75180a9aad95182248041c117d0868bae94a856
Signed-off-by: lubos-cicut <lubos.cicut@pantheon.tech>
4 days agoBump upstreams 02/111702/5
Robert Varga [Wed, 15 May 2024 15:13:02 +0000 (17:13 +0200)]
Bump upstreams

Adopt:
- odlparent-13.1.2
- infrautils-6.0.8
- yangtools-13.0.5
- mdsal-13.0.3
- controller-9.0.3
- aaa-0.19.4

Change-Id: I8b65d1e89d8ae00c81a94aaf7f3c992aa6014fb1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 days agoOpenApi for TransportPCE with controller resources fix 81/111281/18
lubos-cicut [Fri, 5 Apr 2024 11:54:13 +0000 (13:54 +0200)]
OpenApi for TransportPCE with controller resources fix

Openapi did not fully work for TransportPCE when we selected
"Controller resource - Restconf RFC 8040". This was due to multiple
generation of the API for models with a different revision, now it
is only generated for the latest version.

Added tests for this case which show that the models are loaded
correctly and targeting to a model with an old revision returns the
correct output.

JIRA: NETCONF-1279
Change-Id: I3042c51715eddfaabe0a1179f1fd0d6cabc9c976
Signed-off-by: lubos-cicut <lubos.cicut@pantheon.tech>
4 days agoCleanup document tests 05/111705/1
Ivan Hrasko [Thu, 16 May 2024 07:49:57 +0000 (09:49 +0200)]
Cleanup document tests

Remove unnecessary empty lines from *DocumentTest(s).

Change-Id: I8548b6f7171ec2a22310a74edad767035da0cf4c
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
5 days agoFix incorect pattern for mac-address 96/111696/2
Yaroslav Lastivka [Wed, 15 May 2024 09:06:47 +0000 (12:06 +0300)]
Fix incorect pattern for mac-address

The length parameter has to be equally limiting or more limiting than
the pattern length constraint.
Length parameter has been removed.MacAddress pattern has been
replaced with correct from ietf-yang-types model.

JIRA: NETCONF-1312
Change-Id: I7553c934f375f0b0d4e77647528cb6b624b44af9
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
6 days agoTests improvement for duplicated schemas 30/111230/4
Samuel Schneider [Wed, 3 Apr 2024 16:15:50 +0000 (18:15 +0200)]
Tests improvement for duplicated schemas

Improve test for duplicated schemas to better test
usage of discriminator.

JIRA: NETCONF-1270
Change-Id: I7cabefed15a798b89d200cf6338a65253d89c5c6
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
13 days agoFix instance-identifier key being not recognized properly 44/111644/1
Ruslan Kashapov [Tue, 7 May 2024 11:09:19 +0000 (14:09 +0300)]
Fix instance-identifier key being not recognized properly

List key of type instance-identifier require own context
based codec to properly parse the value. Previous usage
TypeDefinitionAwareCodec (serves primitive types) resulted
NPE due to absence of associated codec.

JIRA: NETCONF-1214
Change-Id: Iaefe44b2be8346f55d4087b4512c010354fd2da6
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
3 weeks agoBind OutboundChannelHandler to ChannelAsyncOutputStream 35/111535/2
Robert Varga [Thu, 25 Apr 2024 22:53:59 +0000 (00:53 +0200)]
Bind OutboundChannelHandler to ChannelAsyncOutputStream

Our Netty/SSHD integration uses asynchronous streams. This means that we
get to use ChannelAsyncOutputStream, which does not allow multiple
writes to be issued.

Make sure we verify this assumption when we are attaching the IO
underlay and make sure we perform out internal buffering.

JIRA: NETCONF-1299
Change-Id: I30baa080989dc9aabd134977575f47bdaa9e18d2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoAdd MapBodyOrder 64/111464/6
Robert Varga [Fri, 19 Apr 2024 07:06:15 +0000 (09:06 +0200)]
Add MapBodyOrder

Make DefaultNormalizedNodeWriter a final class by extracting out the
child sorting logic into a pair of classes.

This exposes the fact that ordered and unordered output behaves
differently -- the latter includes map entry keys. This output is not
possible to trigger under normal circumstances, so we adjust the tests
to assert the ordered behaviour.

JIRA: NETCONF-773
Change-Id: Ia70295cd048b97dfc284f014e477cfd72a5d347a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoClean up InOrder assertion 69/111469/1
Robert Varga [Fri, 19 Apr 2024 15:39:48 +0000 (17:39 +0200)]
Clean up InOrder assertion

The use of times(2) is confusing -- we actually want the invocations in
strict order.

Change-Id: Ib723347b9ae9cc6cee546f98bc77710d05b145fd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoRefactor NormalizedNodeWriter 53/111453/2
Robert Varga [Thu, 18 Apr 2024 23:01:04 +0000 (01:01 +0200)]
Refactor NormalizedNodeWriter

Split out the baseline abstract class, which performs dispatch. Keep the
actual logic separately. This will allow us to specialize
implementations further.

JIRA: NETCONF-773
Change-Id: I6840eb5a21c326d7788679c7fd246c3f04dcdefb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoPropagate DatabindContext to RestconfTransaction 42/111442/2
Robert Varga [Wed, 17 Apr 2024 16:06:35 +0000 (18:06 +0200)]
Propagate DatabindContext to RestconfTransaction

We will need to be producing ServerErrorPaths from RestconfTransactions,
for which we need more than just the EffectiveModelContext.

JIRA: NETCONF-1188
Change-Id: I10e63d7759f9351455242e99c14c70957f6c8e30
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoYangErrorsBody is a FormattableBody 37/111437/2
Robert Varga [Tue, 16 Apr 2024 19:54:11 +0000 (21:54 +0200)]
YangErrorsBody is a FormattableBody

We have a well-defined mapping to both JSON and XML formats, let's reuse
that binding.

JIRA: NETCONF-1188
Change-Id: I4e120a6f8403cd46f2487127ad08786a71da62e2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoAdd YangErrorsBody 35/111435/2
Robert Varga [Tue, 16 Apr 2024 16:28:43 +0000 (18:28 +0200)]
Add YangErrorsBody

YangErrorsBody is the canonical server-side representation of a set of
reported errors.

Shift serialization logic to this server.api construct, eliminating the
use of intermediate transformers in favor of a centralized indenting
constract.

JIRA: NETCONF-1188
Change-Id: If9f0b8c91a93726444e45b9c261aeb198cc9cc00
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoUpdate notification subscription user guide 38/111338/3
Samuel Schneider [Tue, 9 Apr 2024 15:19:49 +0000 (17:19 +0200)]
Update notification subscription user guide

Update notification subscription user guide to reflect
usage of random UUIDs for stream names and necessity to
specify encoding in url.

JIRA: NETCONF-1272
Change-Id: I6dc49670e55df1b6fdf8256dde6ab07274dd882c
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
4 weeks agoRemove "/" sign in AbstractRestconfStreamRegistry 72/111272/5
Yaroslav Lastivka [Fri, 5 Apr 2024 06:31:28 +0000 (09:31 +0300)]
Remove "/" sign in AbstractRestconfStreamRegistry

In AbstractRestconfStreamRegistry#baseStreamLocation, the method generated
incorrect paths containing a double slash after `rests` in the device
notification stream URL. This error occurred because URI.getPath()
always includes a trailing slash. Additionally, the UriInfo.getBaseUri()
method, used within JaxRsRestconf, also consistently appends a slash
at the end.

Document this fact in RestconfServer and do not append it in
AbstractRestconfStreamRegistry.

JIRA: NETCONF-1274
Change-Id: Ib5074dc150d27a8482c7e49f89549973ab707270
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 weeks agoFix 500 server error in PUT request 28/111228/3
Oleksandr Zharov [Wed, 3 Apr 2024 15:34:03 +0000 (17:34 +0200)]
Fix 500 server error in PUT request

Fixed error response for PUT create device request. One of the catch
cases didn't throw errors in the correct way causing a 500 server
error response instead of a proper message.

JIRA: NETCONF-1268
Change-Id: Iaf94814c5f5b1f4ad3bb12c8408ffa72acf0d25c
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
4 weeks agoMigrate netconf-topology tests to JUnit 5 19/111319/9
lubos-cicut [Mon, 8 Apr 2024 06:30:24 +0000 (08:30 +0200)]
Migrate netconf-topology tests to JUnit 5

Migrated tests in netconf-topology package to JUnit 5.

JIRA: NETCONF-1282
Change-Id: Iee0ddc762309e9c9329805db68593b30f88e98f7
Signed-off-by: lubos-cicut <lubos.cicut@pantheon.tech>
5 weeks agoWrap operationsPOST result with JaxRsFormattableBody 88/111388/2
Robert Varga [Mon, 15 Apr 2024 08:38:40 +0000 (10:38 +0200)]
Wrap operationsPOST result with JaxRsFormattableBody

We need to wrap the entity with formatting metadata for it to be picked
up by JaxRsFormattableBodyWriter.

JIRA: NETCONF-1296
Change-Id: I68366ba56c2d62901ffaf938739d94d3667f7ffd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoMake SSEStreamService class public 87/111387/2
Yaroslav Lastivka [Mon, 15 Apr 2024 07:16:30 +0000 (10:16 +0300)]
Make SSEStreamService class public

The SSEStreamService class was previously package-private, which
restricted access from classes not within the same package.
This limitation was causing an IllegalAccessException when
methods from this class were being accessed reflectively
by the Jersey framework, which is outside of its package.

JIRA: NETCONF-1273
Change-Id: I2c0ce558a7ccd53e9a8636690d2676d5d7ebb9df
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>
5 weeks agoDefine a replacement for Restconf{Error,Exception,Future} 63/111363/8
Robert Varga [Thu, 11 Apr 2024 23:33:24 +0000 (01:33 +0200)]
Define a replacement for Restconf{Error,Exception,Future}

Server-side API is opinionated about how it reports errors. This patch
defines:
- ErrorMessage to hold the RFC6241 definition of what is an error
  message
- ServerError to replace RestconfError
- ServerErrorInfo to hold the error-info element
- ServerErrorPath to hold the error-path element
- ServerException to replace RestconfDocumentedException

ServerException has a more logical API, holding only a single error and
performing explicit mapping when instantiated with just a Throwable
cause. This mode of operation maps:
- IllegalArgumentException to ErrorTag.INVALID_VALUE
- UnsupportedOperationException to ErrorTag.OPERATION_NOT_SUPPORTED

JIRA: NETCONF-1188
Change-Id: I07e7a9a56e4e02c699ead96bed1c115136767c4c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoFix dataGet() of MapEntries 69/111369/2
Robert Varga [Fri, 12 Apr 2024 16:26:32 +0000 (18:26 +0200)]
Fix dataGet() of MapEntries

Expand RestconfDataGetTest to cover more NormalizedNode structures,
verifying we are producing what we need.

This flushes out an alignment problem between XML and JSON: the latter
does need the entrypoint to be MapNode, the other does not care.

Change-Id: Ic11863b6dec5bd1a5bb860dd3d3732c5e3c53384
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoClean up NormalizedNodeWriter tests 64/111364/1
Robert Varga [Fri, 12 Apr 2024 07:56:32 +0000 (09:56 +0200)]
Clean up NormalizedNodeWriter tests

We have a bit of duplication with data, collect that into a common
superclass.

While we are at it, migrate to JUnit5, which allows us to remove the use
of verifyNoMoreInteractions().

Change-Id: I0599e400665e36b5005eab5cbe2ab08fbf72f1a1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoImprove JaxRsFormattableBody.toString() 62/111362/1
Robert Varga [Thu, 11 Apr 2024 22:03:55 +0000 (00:03 +0200)]
Improve JaxRsFormattableBody.toString()

Output the pretty-print boolean instead of a class, improving
experience.

JIRA: NETCONF-773
Change-Id: I1cded9f21a7e4a36df3110ddece4db0d2c3eec85
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoMove ErrorTags 61/111361/3
Robert Varga [Thu, 11 Apr 2024 21:53:26 +0000 (23:53 +0200)]
Move ErrorTags

ErrorTags now only defines a single ErrorTag. Move it to
restconf.nb.rfc8040 for the time being.

JIRA: NETCONF-773
Change-Id: I9025682cd563002111dbc2ecf2ba4737810d54fb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoEliminate restconf.nb.rfc8040.jersey 60/111360/3
Robert Varga [Thu, 11 Apr 2024 21:32:48 +0000 (23:32 +0200)]
Eliminate restconf.nb.rfc8040.jersey

There are only a couple of classes left in this hierachy. This patch
moves them around:
- RestconfDocumentedExceptionMapper moves to restconf.nb.rfc8040.legacy
- RestconfNormalizedNodeWriter moves to restconf.server.spi

JIRA: NETCONF-773
Change-Id: I9b9311c3a4f22922f8c435b12f7071b1ea6b6b6b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoEliminate NormalizedNodePayload 59/111359/4
Robert Varga [Thu, 11 Apr 2024 19:18:07 +0000 (21:18 +0200)]
Eliminate NormalizedNodePayload

NormalizedNodePayload is only used in RestconfStrategy.dataGET() and is
one of the two last places where we use old JAX-RS serialization.

This patch introduces {Data,Root}FormattableBody class to act as a
combination of NormalizedFormattableBody and NormalizedNodePayload.

This also refactors the interface towards RestconfNormalizedNodeWriter
by introducing a factory which is under control of the RestconfStrategy
which produces the result.

JIRA: NETCONF-773
Change-Id: I867944ab260828fb19e3ba829d1188a215e0bd9f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoIntegrate RestconfNormalizedNodeWriter 58/111358/1
Robert Varga [Thu, 11 Apr 2024 14:22:44 +0000 (16:22 +0200)]
Integrate RestconfNormalizedNodeWriter

RestconfNormalizedNodeWriter is an interface with a single
implementation, integrate it there and simplify naming.

JIRA: NETCONF-773
Change-Id: I552aad11b4cc2c3db9eb46f5d2d4410e1c30ccb0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoFix JaxRsFormattableBodyWriter 56/111356/2
Robert Varga [Thu, 11 Apr 2024 11:21:25 +0000 (13:21 +0200)]
Fix JaxRsFormattableBodyWriter

We should be checking for JaxRsFormattableBody.

JIRA: NETCONF-1294
Change-Id: I821181ec6749c4558a135bcfe7aaf98ff65065b4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoFix NPE with QNameModule 52/111352/1
Robert Varga [Thu, 11 Apr 2024 09:47:16 +0000 (11:47 +0200)]
Fix NPE with QNameModule

QNameModule.of() requires a non-null revision, but we have a nullable.
Use QNameModule.ofRevision() to fix that.

JIRA: NETCONF-1285
Change-Id: Ic583707699930ce235d1e53d9eeceeef3e6ece2e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoSimplify HttpStatusCode.toString() 44/111344/2
Robert Varga [Tue, 9 Apr 2024 22:49:38 +0000 (00:49 +0200)]
Simplify HttpStatusCode.toString()

Use plain 'code( phrase)?' string, which makes it easier to compare.

JIRA: NETCONF-1188
Change-Id: Idf62b672a38e8a6d1f25b5055b54f5954f123de7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoEliminate FormatParameters 43/111343/1
Robert Varga [Tue, 9 Apr 2024 21:21:28 +0000 (23:21 +0200)]
Eliminate FormatParameters

We are just dancing around the pretty-print parameter. Let's ditch the
wrapping and use the parameter all around.

JIRA: NETCONF-773
Change-Id: I469c2f364956506578655bdc40bcbd3004a1c96a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoIntroduce HttpStatusCode 42/111342/1
Robert Varga [Tue, 9 Apr 2024 20:35:33 +0000 (22:35 +0200)]
Introduce HttpStatusCode

RESTCONF fall into two categories a success, indicating a 20x status or
a failure, indicating a 40x status. RestconfDocumentedException acts as
a wrapper for the latter case, with the additional twist of being able
to report multiple errors via the 'yang-errors' template.

All failure modes in RESTCONF end up being driven by a YANG ErrorTag,
hence our server-size response structure really wants to be split along
success/failure lines.

This patch takes the first step towards that split, defining a
restconf.api.HttpStatusCode, which acts as a semantic capture of a HTTP
Status Code and use that in error mapping logic.

While we are visiting here, we make the status code for data-missing
configurable for each northbound instance -- rather than our previous
use of a global property.

JIRA: NETCONF-1188
Change-Id: I1365256f9fad4ffe66358e6e9da4dfa337a755fd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoRework body formatting wiring 39/111339/3
Robert Varga [Mon, 8 Apr 2024 21:03:35 +0000 (23:03 +0200)]
Rework body formatting wiring

Output formatting is a policy decision of a particular HTTP endpoint,
not of a RestconfServer implementation.

This patch performs some very invasive surgery to rehost this
information which minimizing method churn to express prepare the code
for fitting in access control.

FormatParameters are now a simple record encapsulating PrettyPrintParam.
These get routed by JaxRsRestconf through interpretation and
communicated to body writers without passing them directly to
RestconfServer.

ServerRequest is introduced and passed instead of QueryParameters or
QueryParams -- it exposes post-processed QueryParameters.

QueryParameters is turned into an immutable class instead of an
interface + record. This is a tad more convenient and easier to
understand.

Most notably we disconnect WriterParametes from FormatParameters, as
they serve different domains:
- FormatParameters are about formatting any particular content
- WriterParameters are about controlling how we iterate over a
  NormalizedNode (which in turn has two parts, but that's for later)

JIRA: NETCONF-773
Change-Id: I0848ff5deb5dc55ff3b45ef7155f04cfe3ab50f7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 weeks agoAdd ApiPath.empty() 22/111322/1
Robert Varga [Mon, 8 Apr 2024 19:19:57 +0000 (21:19 +0200)]
Add ApiPath.empty()

This is a convenience method, making the code flow a bit more organized.

Change-Id: If537750e44c2a113754d8e68c2dfc0688baec59a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoSmall improvement in NetconfNodeHandlerTest 20/111320/2
lubos-cicut [Mon, 8 Apr 2024 08:21:28 +0000 (10:21 +0200)]
Small improvement in NetconfNodeHandlerTest

Fix wrong annotation for NetconfNodeHandlerTest#afterClass method.

JIRA: NETCONF-1282
Change-Id: I05edbd3ddd9fa3e1eff092ef3382b81c9bd7e590
Signed-off-by: lubos-cicut <lubos.cicut@pantheon.tech>
6 weeks agoIntroduce restconf.server.api.HttpGetResource 13/111313/7
Robert Varga [Sun, 7 Apr 2024 12:54:36 +0000 (14:54 +0200)]
Introduce restconf.server.api.HttpGetResource

HttpGetResource is a useful tool which forces all implementations to
behave in the same manner.

We want httpGet() to return a FormattableBody, which we achieve here for
both OperationsResource and YangLibraryVersionResource.

The latter also gives a useful utility in NormalizedFormattableBody,
which captures the essence of NormalizedNodePayload sans special
handling.

JIRA: NETCONF-773
Change-Id: I48f2c7dec979639c3466024677a36a89919281b7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoSplit out YangLibraryVersionResource 10/111310/4
Robert Varga [Sun, 7 Apr 2024 12:20:00 +0000 (14:20 +0200)]
Split out YangLibraryVersionResource

Juggle the implementation around, allowing us to capture failure early.

JIRA: NETCONF-773
Change-Id: Ib2a587f3a73698ca2b4da1f6775dc0bdf0436be3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoAdd QueryParameters.isEmpty() 12/111312/2
Robert Varga [Sun, 7 Apr 2024 12:56:49 +0000 (14:56 +0200)]
Add QueryParameters.isEmpty()

This is a useful invariant, expose it.

JIRA: NETCONF-773
Change-Id: Ie5e0d63c298149af6ff3aa8e9bf4141a236bdf1e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoAllow odl-pretty-print to be configured to true 05/111305/8
Robert Varga [Sat, 6 Apr 2024 02:47:31 +0000 (04:47 +0200)]
Allow odl-pretty-print to be configured to true

Expose a configuration knob, pretty-print, which controls the default
value of pretty-printing.

This also cleans up our handling of arguments, as it was all over the
place.

JIRA: NETCONF-1290
Change-Id: Ie4fab3450bceef6d04fc28fe8b908e937a69e4c3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoUse pretty printing in RestconfDataPatchTest 04/111304/1
Robert Varga [Sat, 6 Apr 2024 02:22:11 +0000 (04:22 +0200)]
Use pretty printing in RestconfDataPatchTest

Demonstrate that the pretty-printing options are honoured by specifying
them in RestconfDataPatchTest. This increases verbosity a bit, but makes
the payloads much more readable.

JIRA: NETCONF-773
Change-Id: Icefc77c7ab1abf1e929acc9e159ecaac697d46e6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoAdd DataYangPatchParams 03/111303/1
Robert Varga [Sat, 6 Apr 2024 02:12:08 +0000 (04:12 +0200)]
Add DataYangPatchParams

YANG Data Patch produces a FormattableBody, create an appropriate
DataYangPatchParams to capture this fact and propagate this information.

JIRA: NETCONF-773
Change-Id: I62ab9a3295b769bea4954ce3f3c08685e1d67738
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoPropagate query parameters to YANG dataPATCH() 02/111302/1
Robert Varga [Sat, 6 Apr 2024 01:42:27 +0000 (03:42 +0200)]
Propagate query parameters to YANG dataPATCH()

We should be honoring odl-pretty-print query parameter, this takes the
first step towards that.

JIRA: NETCONF-773
Change-Id: Id5a1d3445ef632f00d8d33539f76c8e5d420561c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoUse pretty-printing in YangPatchStatusBodyTest 01/111301/1
Robert Varga [Sat, 6 Apr 2024 01:24:16 +0000 (03:24 +0200)]
Use pretty-printing in YangPatchStatusBodyTest

Now that we have integrated pretty printing, we can use it to make our
tests easier to read.

JIRA: NETCONF-773
Change-Id: I3e00747457dba675e988aabb49aa7a1c3628ca28
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoIntegrate YangPatchStatusBody with FormattableBodySupport 00/111300/1
Robert Varga [Sat, 6 Apr 2024 01:11:08 +0000 (03:11 +0200)]
Integrate YangPatchStatusBody with FormattableBodySupport

Use FormattableBodySupport to acquire properly-configured writers, which
allows for proper pretty printing, once we can pass the query
parameters.

JIRA: NETCONF-773
Change-Id: I0cba89cfbf20007c8bd18fed9003143506d2bba6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoIntroduce YangPatchStatusBody 99/111299/6
Robert Varga [Sat, 6 Apr 2024 00:45:21 +0000 (02:45 +0200)]
Introduce YangPatchStatusBody

Add a dedicated FormattableBody for YANG Patch status, eliminating
the need for dedicated MessageBodyWriters. This has the nice result of
unifying tests as well.

JIRA: NETCONF-773
Change-Id: I06cb44fa4ea88b1e6505e5d3911ba3167503afa2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoReduce use of Status 97/111297/1
Robert Varga [Fri, 5 Apr 2024 23:33:26 +0000 (01:33 +0200)]
Reduce use of Status

Use Response's created()/noContent()/ok() methods instead.

Change-Id: I850f5d40cec147df37b46eaf9b28209dbb58e17f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoMake insertWithPointPost() static 96/111296/1
Robert Varga [Fri, 5 Apr 2024 23:29:46 +0000 (01:29 +0200)]
Make insertWithPointPost() static

Eclipse is pointing out this method is not touching state: make it
static.

Change-Id: Ie6291638c2b9ba89e9a72a1aa09ef0ae64354dda
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoCentralize AbstractPatchStatusBodyWriter.writeBody() 95/111295/1
Robert Varga [Fri, 5 Apr 2024 23:16:00 +0000 (01:16 +0200)]
Centralize AbstractPatchStatusBodyWriter.writeBody()

We are providing two distinct implementations, let's cut down the
verbosity by having a shared entrypoint into them.

JIRA: NETCONF-773
Change-Id: I86ac22d13f2049201d9833a60c81ee2b45aa0aa9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoMove PatchStatus{Context,Entity} 94/111294/1
Robert Varga [Fri, 5 Apr 2024 22:55:11 +0000 (00:55 +0200)]
Move PatchStatus{Context,Entity}

These two classes want to express a FormattableBody on the server side.
Move them out to server.api where they can be evolved further.

An immediate benefit is integration with DatabindContext's codecs.

JIRA: NETCONF-773
Change-Id: I67fe024c3701ab39797db3f6d5afa6f02d1385ee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoClean up body implementation placement 93/111293/1
Robert Varga [Fri, 5 Apr 2024 22:32:40 +0000 (00:32 +0200)]
Clean up body implementation placement

OperationOutputBody is a server.spi thing, as we only need the
FormattableBody trait in server.api.

DataPostResult.CreateResource is needlessly nested, as its sibling is
already a top-level construct. Rename it to
server.api.CreateResourceResult.

JIRA: NETCONF-773
Change-Id: I0a8ecb2c6635b6a11ba7836b12cb829bb5a70c72
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoIntroduce restconf.api.ConsumableBody 92/111292/3
Robert Varga [Fri, 5 Apr 2024 21:56:22 +0000 (23:56 +0200)]
Introduce restconf.api.ConsumableBody

The server-side RequestBody contains the idea it is backed by an
InputStream, making it a mirror of a FormattableBody.

Expose ConsumableBody, which captures that essence, making RequestBody
its subclass. We give up use of VarHandles in favor of an
AtomicReference, which is more friendly to static analysis and human
understanding.

JIRA: NETCONF-773
Change-Id: Icc34a60da460c258d13591df7d2fbf68416a9778
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoPromote FormattableBody to restconf.api 91/111291/1
Robert Varga [Fri, 5 Apr 2024 21:31:31 +0000 (23:31 +0200)]
Promote FormattableBody to restconf.api

FormattableBody is not specific to server-side of things. Promote it to
restconf.api along with FormatParameters.

JIRA: NETCONF-773
Change-Id: I31f3426b90483964468dba5d38f73f2c472330f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRefactor OperationsGetResult 90/111290/3
Robert Varga [Fri, 5 Apr 2024 20:19:19 +0000 (22:19 +0200)]
Refactor OperationsGetResult

We have FormattableBody, which is pretty much what OperationsGetResult
attempts to do with strings.

Move OperationsGetResult to server.spi as OperationsBody, where it is
given out by an OperaetionsResource.

The baseline server.spi footprint then becomes just plain
FormattableBody, which allows us to simplify JaxRsRestconf and
RestconfStrategy.

JIRA: NETCONF-773
Change-Id: Ic54921187e6f83a2477c4126718f053dc366df38
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRefactor pretty printing 89/111289/1
Robert Varga [Fri, 5 Apr 2024 15:56:49 +0000 (17:56 +0200)]
Refactor pretty printing

PrettyPrintParam is a common operation, introduce FormatParameters
to expose it. This interface will be useful for controlling other
parameters as well.

This really makes ReplyBody a FormattableBody, so we perform this
renaming as well and make FormatParameters a required argument.

This flushes out the fact we are not accepting this parameter for invoke
operations. Correctly propagate these parameters, which forces us to
clean up the RPC/action invocation paths -- further simplifying the
interface and creating proper place where these parameters get applied.

JIRA: NETCONF-773
Change-Id: I3382b27c0b4f7d727d792ead5c1ad364bd69624c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoSplit out operation output serialization 71/111271/4
Robert Varga [Thu, 4 Apr 2024 15:16:45 +0000 (17:16 +0200)]
Split out operation output serialization

NormalizedNodePayload is quite overloaded, handling a ton of different
options.

This patch renames AbstractBody to RequestBody and creates its
counterpart ReplyBody. The JAX-RS serialization bit is handled through a
pair of MessageBodyWriters, which end up just calling ReplyBody methods.

We then define an OperationOutputBody, which handles the case of
RPC/action invocation result and stop using NormalizedNodePayload for
that purpose.

This also speeds up the entire process, as we can reuse JSON codecs
and not look them up again.

JIRA: NETCONF-773
Change-Id: Ib711451498f9bad485b69d14f6ae8195038ff506
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRefactor transport-http response delivery 67/111267/2
Robert Varga [Thu, 4 Apr 2024 14:16:57 +0000 (16:16 +0200)]
Refactor transport-http response delivery

Using a ListenableFuture brings in lifecycle headache, as the reported
value is retained indefinitely -- forcing us to make copies of the
response.

Rework the APIs in terms of FutureCallback instead -- i.e. we report the
response while having a reference to it and the callback can retain it
if need be (in which case it takes ownership of it).

Also introduce ClientRequestDispatcher to eliminate a bit of duplicate
code.

Change-Id: I350467582b5f5bd67d5241d47a5d4cbaef19adaa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoDocument get module source 19/111219/2
lubos-cicut [Wed, 3 Apr 2024 11:05:55 +0000 (13:05 +0200)]
Document get module source

Document how to get module source.

JIRA: NETCONF-1287
Change-Id: Ica59f07a6086f0b9f17e1228160e7b335780057c
Signed-off-by: lubos-cicut <lubos.cicut@pantheon.tech>
6 weeks agoProperly encapsulate PatchBody normalization 54/111254/2
Robert Varga [Thu, 4 Apr 2024 02:54:28 +0000 (04:54 +0200)]
Properly encapsulate PatchBody normalization

Every PatchBody needs to be interpreted in terms of a ResourceContext,
which is capable of resolving sub-resources.

Structuring the code this way disconnects PatchBody from server.spi
contract. The prerequisite wiring is then provided through a
restconf.server.spi.DefaultResourceContext based a Data path and
ApiPathNormalizer.

This makes the semantics crispy-clear, allowing us to ditch a few
re-lookups which are no longer necessary.

JIRA: NETCONF-1288
Change-Id: I37d4903d1cc1bbb8eb3e8db3ac08c2142f661c88
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoEliminate restconf.nb.rfc8040.utils package 53/111253/3
Robert Varga [Thu, 4 Apr 2024 01:20:17 +0000 (03:20 +0200)]
Eliminate restconf.nb.rfc8040.utils package

Move WriterFieldsTranslator to restconf.nb.rfc8040.rests.transactions,
exposed for testing. This eliminates the utils package, simplifying
layout a bit.

Change-Id: I2a5e79aa5c942bd9226b9c5b981f89ffe0e96865
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoHide NetconfFieldsTranslator 52/111252/2
Robert Varga [Thu, 4 Apr 2024 01:16:11 +0000 (03:16 +0200)]
Hide NetconfFieldsTranslator

There is only one user of this class, move it to the same package and
hide it by inlining it into NetconfRestconfStrategy.

Change-Id: Ib614b046bd6dcdf51e4b09d8b7cdec3b43c16629
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoSplit out ApiPathCanonizer 47/111247/1
Robert Varga [Thu, 4 Apr 2024 00:32:21 +0000 (02:32 +0200)]
Split out ApiPathCanonizer

ApiPathNormalizer has grown quite complicated, simplify it by splitting
canonicalize() into ApiPathCanonizer.dataToApiPath().

JIRA: NETCONF-1288
Change-Id: Ia7f36de2f27d511fb6e2230d1c8a83b443a09f11
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoImprove ApiPathNormalizer.normalizeSubResource() 37/111237/2
Robert Varga [Wed, 3 Apr 2024 20:37:52 +0000 (22:37 +0200)]
Improve ApiPathNormalizer.normalizeSubResource()

Split out the normalization logic so that we can restart at a given
point -- which conveniently is pretty much covered by the semantics of
DatabindPath.Data.

This allows us to skip the canonicalize()/parse() step and proceed to
normalization directly.

JIRA: NETCONF-1288
Change-Id: I642dd0286dea60efa1fade3b7edc37fbb4f0536c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoMove patch target resolution 36/111236/1
Robert Varga [Wed, 3 Apr 2024 20:13:54 +0000 (22:13 +0200)]
Move patch target resolution

We now have a lingua franca between PatchBody and ApiPathNormalizer.
Take advantage of that and define the normalizeSubResource() utility
method.

JIRA: NETCONF-1288
Change-Id: Ie3aa238be767918a7c4c795fda04649823aa2824
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRemove OperationsPostPath 35/111235/3
Robert Varga [Wed, 3 Apr 2024 17:24:02 +0000 (19:24 +0200)]
Remove OperationsPostPath

DatabindPath.OperationPath provides a more powerful tool, use that
instead.

JIRA: NETCONF-1288
Change-Id: If234477cf6f304945c4e0dc574c59f0e2983d725
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRemove DataPostPath 34/111234/3
Robert Varga [Wed, 3 Apr 2024 16:49:00 +0000 (18:49 +0200)]
Remove DataPostPath

We have a more powerful tool in DatabindPath.Data, use that instead.

JIRA: NETCONF-1288
Change-Id: I80e1e122aebec9348d83b0a8d28cd82cea7ad840
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoEliminate DataPatchPath 33/111233/2
Robert Varga [Wed, 3 Apr 2024 16:27:21 +0000 (18:27 +0200)]
Eliminate DataPatchPath

We have DatabindPath.Data, which is exactly what we are getting from
normalization, only more powerful. Use that instead.

JIRA: NETCONF-1288
Change-Id: I095f7080585d30dd29b2afcf94dea9544bea574a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoEliminate DataPutPath 32/111232/2
Robert Varga [Wed, 3 Apr 2024 16:17:21 +0000 (18:17 +0200)]
Eliminate DataPutPath

This interface has been useful, but now we have DatabindPath.Data, which
is a more powerful tool with equivalent semantics.

JIRA: NETCONF-1288
Change-Id: Ie135a1f7e6260bec0b6190fc331dc3ad559879f4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoPromote ApiPathNormalizer.Path to server.api.DatabindPath 31/111231/2
Robert Varga [Wed, 3 Apr 2024 15:45:44 +0000 (17:45 +0200)]
Promote ApiPathNormalizer.Path to server.api.DatabindPath

A DatabindPath is an ApiPath bound to a DatabindContext, having the
corresponding databind() method.

This naturally fix into server.api, as it provides a semantic capture of
the request, which we already do in this package.

JIRA: NETCONF-1288
Change-Id: I55552caf24d999d5523c51b872ff77e7bcc0aece
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoBump versions to 7.0.5-SNAPSHOT 23/111223/1
Robert Varga [Wed, 3 Apr 2024 14:46:09 +0000 (16:46 +0200)]
Bump versions to 7.0.5-SNAPSHOT

This starts the next development iteration.

Change-Id: I54909500c90cca82c3d8440e4fe0241789029594
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRelease netconf v7.0.4
jenkins-releng [Wed, 3 Apr 2024 12:22:55 +0000 (12:22 +0000)]
Release netconf

6 weeks agoRework YangInstanceIdentifier/URI path conversion 73/111073/24
lubos-cicut [Tue, 26 Mar 2024 14:27:41 +0000 (15:27 +0100)]
Rework YangInstanceIdentifier/URI path conversion

YangInstanceIdentifierSerializer has a rather ambiguous name and
description, but essentially it does what it advertizes: it takes a
YangInstanceIdentifier and creates a String corresponding to
ApiPath.parse().

Unfortunately this process handles values through String.valueOf(),
which obviously does the wrong thing for non-trivial values, such as
identityref and instance-identifier.

We already have a component handling ApiPath -> YangInstanceIdentifier
conversion, the ApiPathNormalizer.

This patch completely replaces
YangInstanceIdentifierSerializer.serializePath() with
ApiPathNormalizer.canonicalize(). It essentially does the same thing,
but returns an ApiPath as the result. Users can use ApiPath.toString()
to then get the String representation, if needed.

JIRA: NETCONF-1264
Change-Id: I1093eb2cbd84ae269430f918e48b98cc2fb4e805
Signed-off-by: lubos-cicut <lubos.cicut@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoRequire ApiIdentifier to be instantiated with Unqualified 15/111215/5
Robert Varga [Wed, 3 Apr 2024 08:56:34 +0000 (10:56 +0200)]
Require ApiIdentifier to be instantiated with Unqualified

We are using Unqualified internally, require users to pass it down.

JIRA: NETCONF-1264
Change-Id: I273a384331c175a34621c634071e46bb6cd035ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoFix full lists removal for remote devices via Restconf. 25/109125/14
Ruslan Kashapov [Thu, 30 Nov 2023 07:59:17 +0000 (09:59 +0200)]
Fix full lists removal for remote devices via Restconf.

When full list removal by yang instance identifier is
requested via restconf on remote device (topology node)
the command wasn't properly translated into netconf message,
because there is no single XML node which describes whole
list, the 'remove' or 'delete' operation can be assigned to.
Invalid netconf message constructed did cause parse error
on device side.

The fix converts list removal command into list elements
removals one by one, with instance identifier of each item
defined explicitly.

JIRA: NETCONF-1245
Change-Id: I78e008845b486aeb011530123b9fe081af482fdf
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
6 weeks agoFix serializeMapWithOneKeyTest() 12/111212/1
Robert Varga [Tue, 2 Apr 2024 17:21:19 +0000 (19:21 +0200)]
Fix serializeMapWithOneKeyTest()

Yet again we are passing the wrong key, fix this up before the test
starts failing due to correct serialization.

JIRA: NETCONF-1264
Change-Id: I71f30735174383e5914253490d9912779802e6b9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoFix serializeNoPercentEncodingTest() 10/111210/1
Robert Varga [Tue, 2 Apr 2024 17:19:00 +0000 (19:19 +0200)]
Fix serializeNoPercentEncodingTest()

We do not specify the correct key here. Fix this mistake, as the test
will start failing once we do proper encoding.

JIRA: NETCONF-1264
Change-Id: I8c8eafcd221535a4d1e011bcb2f0096cad4f3409
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoFix serializeMapWithMultipleKeysTest() 09/111209/1
Robert Varga [Tue, 2 Apr 2024 17:13:31 +0000 (19:13 +0200)]
Fix serializeMapWithMultipleKeysTest()

The keys are expected to be Uint8 and Boolean, not strings. Fix this up,
as the test will start failing when we perform proper encoding.

JIRA: NETCONF-1264
Change-Id: I29f141984550a787a6f8837bef0467d0ab0d426e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoFix serializePercentEncodingTest() 08/111208/1
Robert Varga [Tue, 2 Apr 2024 16:56:15 +0000 (18:56 +0200)]
Fix serializePercentEncodingTest()

The test is passing the wrong QName for key leaf, which should be
'name'. Fix this as this test will start failing when we perform proper
encoding.

JIRA: NETCONF-1264
Change-Id: Ida98ac1e0c486a25bcb02d2728f6ea389d297538
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoExpose ListInstance.of() methods 06/111206/1
Robert Varga [Tue, 2 Apr 2024 15:59:52 +0000 (17:59 +0200)]
Expose ListInstance.of() methods

ListInstance assumes there is at least one item. Static factory methods
to create ListInstances which validate this invariant. Parser code uses
the now-private-again constructor.

JIRA: NETCONF-1264
Change-Id: I969df7f60c89cf7259830dae584d833f1217d949
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoFix serializeLeafListTest() 05/111205/1
Robert Varga [Tue, 2 Apr 2024 15:43:56 +0000 (17:43 +0200)]
Fix serializeLeafListTest()

leaf-list-0 has 'type boolean' and hence 'instance' is not a valid
value. This test demonstrates that YangInstanceIdentifier is not
validating values, letting garbage in.

This test will start failing once we process values correctly, hence fix
it up ahead of time.

JIRA: NETCONF-1264
Change-Id: I23c7e21eb4e0ca3474debe7faafd7a22aa7f5103
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoOpenAPI: do not generate duplicated schemas 10/111010/4
Samuel Schneider [Mon, 25 Mar 2024 17:23:05 +0000 (18:23 +0100)]
OpenAPI: do not generate duplicated schemas

Skip processing of node if it was already processed.
Currently, we generate multiple schemas with different name
for the same node and the last one is used.

JIRA: NETCONF-1270
Change-Id: I817f5d5db9183b0162b663bd2e80f5971ea8366a
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
6 weeks agoExpose ListInstance constructor 70/111170/2
Robert Varga [Tue, 2 Apr 2024 07:45:19 +0000 (09:45 +0200)]
Expose ListInstance constructor

The only way to create a ListInstance is through parsing. Expose the
constructor so it can be externally instantiated, just like
ApiIdentifier.

JIRA: NETCONF-1264
Change-Id: I917b18266cc1acda5bc5c4108df228c368c4ff33
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 weeks agoUpdate swagger UI to version 5.13.0 73/111173/2
Oleksandr Zharov [Tue, 2 Apr 2024 08:25:20 +0000 (10:25 +0200)]
Update swagger UI to version 5.13.0

It seems that some bugs in the Swagger UI caused problems with
missing action input and output. This is fixed by simply updating
Swagger to a newer version.

Updated Swager UI from 5.11.8 to latest current version:
https://github.com/swagger-api/swagger-ui/releases/tag/v5.12.0
https://github.com/swagger-api/swagger-ui/releases/tag/v5.13.0

JIRA: NETCONF-1286
Change-Id: I47c2982f3d475a1523ec83683b83d6d3b2eea99e
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>