From 7e383919edbead6d5f10f7b534af9d05dcdcf275 Mon Sep 17 00:00:00 2001 From: Martin Sottnik Date: Mon, 1 Jul 2024 13:17:13 +0200 Subject: [PATCH 1/4] encode uniconfig nodeId in requests (#441) --- src/external-api/uniconfig.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/external-api/uniconfig.ts b/src/external-api/uniconfig.ts index 950a0324..f6177ae0 100644 --- a/src/external-api/uniconfig.ts +++ b/src/external-api/uniconfig.ts @@ -175,7 +175,9 @@ export async function getUniconfigDatastore( const json = await sendGetRequest( [ baseURL, - `/data/network-topology:network-topology/network-topology:topology=uniconfig/network-topology:node=${nodeId}/frinx-uniconfig-topology:configuration?content=${DATA_STORE_MAP[datastoreType]}`, + `/data/network-topology:network-topology/network-topology:topology=uniconfig/network-topology:node=${encodeURIComponent( + nodeId, + )}/frinx-uniconfig-topology:configuration?content=${DATA_STORE_MAP[datastoreType]}`, ], cookie, ); @@ -194,7 +196,9 @@ export async function updateUniconfigDataStore( await sendPutRequest( [ baseURL, - `/data/network-topology:network-topology/network-topology:topology=uniconfig/network-topology:node=${nodeId}/frinx-uniconfig-topology:configuration`, + `/data/network-topology:network-topology/network-topology:topology=uniconfig/network-topology:node=${encodeURIComponent( + nodeId, + )}/frinx-uniconfig-topology:configuration`, ], params, cookie, From b19a88fba298e47840c82ce5691d2cf7bbefa731 Mon Sep 17 00:00:00 2001 From: Martin Sottnik Date: Mon, 1 Jul 2024 16:10:00 +0200 Subject: [PATCH 2/4] stream parameters fix (#442) * stream parameters fix * eslint fix * merge mountParameters and streamParameters --- src/helpers/stream-helpers.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/helpers/stream-helpers.ts b/src/helpers/stream-helpers.ts index 35e8c4be..cb3f5217 100644 --- a/src/helpers/stream-helpers.ts +++ b/src/helpers/stream-helpers.ts @@ -23,7 +23,8 @@ export function getMountParamsForStream(mountParameters: JsonValue, streamParame return { cli: { ...cli, - ...parsedStreamParameters, + ...parsedMountParameters, + 'subscriptions:stream': parsedStreamParameters, // eslint-disable-line @typescript-eslint/naming-convention ...getDisabledSyncConfig(), }, }; @@ -34,7 +35,8 @@ export function getMountParamsForStream(mountParameters: JsonValue, streamParame return { gnmi: { ...gnmi, - ...parsedStreamParameters, + ...parsedMountParameters, + 'subscriptions:stream': parsedStreamParameters, // eslint-disable-line @typescript-eslint/naming-convention ...getDisabledSyncConfig(), }, }; @@ -45,6 +47,7 @@ export function getMountParamsForStream(mountParameters: JsonValue, streamParame netconf: { ...netconf, ...parsedMountParameters, + 'subscriptions:stream': parsedStreamParameters, // eslint-disable-line @typescript-eslint/naming-convention ...getDisabledSyncConfig(), }, }; From 91635859c80094e636e5c658f02a31b52ea73efa Mon Sep 17 00:00:00 2001 From: Martin Sottnik Date: Tue, 2 Jul 2024 08:48:47 +0200 Subject: [PATCH 3/4] stream parameters fix (#443) * stream parameters fix (final) * remove unused code --- src/helpers/stream-helpers.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/helpers/stream-helpers.ts b/src/helpers/stream-helpers.ts index cb3f5217..8fd6babd 100644 --- a/src/helpers/stream-helpers.ts +++ b/src/helpers/stream-helpers.ts @@ -13,7 +13,6 @@ function getDisabledSyncConfig() { } export function getMountParamsForStream(mountParameters: JsonValue, streamParameters: JsonValue): JsonValue { - const parsedMountParameters = typeof mountParameters === 'string' ? JSON.parse(mountParameters) : mountParameters; const parsedStreamParameters = typeof streamParameters === 'string' ? JSON.parse(streamParameters) : streamParameters; const decodedMountParams = decodeMountParams(mountParameters); @@ -23,7 +22,6 @@ export function getMountParamsForStream(mountParameters: JsonValue, streamParame return { cli: { ...cli, - ...parsedMountParameters, 'subscriptions:stream': parsedStreamParameters, // eslint-disable-line @typescript-eslint/naming-convention ...getDisabledSyncConfig(), }, @@ -35,7 +33,6 @@ export function getMountParamsForStream(mountParameters: JsonValue, streamParame return { gnmi: { ...gnmi, - ...parsedMountParameters, 'subscriptions:stream': parsedStreamParameters, // eslint-disable-line @typescript-eslint/naming-convention ...getDisabledSyncConfig(), }, @@ -46,7 +43,6 @@ export function getMountParamsForStream(mountParameters: JsonValue, streamParame return { netconf: { ...netconf, - ...parsedMountParameters, 'subscriptions:stream': parsedStreamParameters, // eslint-disable-line @typescript-eslint/naming-convention ...getDisabledSyncConfig(), }, From fe784a42686f7e319006957c9f35ce2061751b6d Mon Sep 17 00:00:00 2001 From: Martin Sottnik Date: Tue, 2 Jul 2024 13:06:57 +0200 Subject: [PATCH 4/4] handle array and object stream parameters (#444) --- src/helpers/stream-helpers.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/helpers/stream-helpers.ts b/src/helpers/stream-helpers.ts index 8fd6babd..8d9b30fb 100644 --- a/src/helpers/stream-helpers.ts +++ b/src/helpers/stream-helpers.ts @@ -14,6 +14,9 @@ function getDisabledSyncConfig() { export function getMountParamsForStream(mountParameters: JsonValue, streamParameters: JsonValue): JsonValue { const parsedStreamParameters = typeof streamParameters === 'string' ? JSON.parse(streamParameters) : streamParameters; + const sanitizedStreamParameters = Array.isArray(parsedStreamParameters) + ? parsedStreamParameters + : [parsedStreamParameters]; const decodedMountParams = decodeMountParams(mountParameters); @@ -22,7 +25,7 @@ export function getMountParamsForStream(mountParameters: JsonValue, streamParame return { cli: { ...cli, - 'subscriptions:stream': parsedStreamParameters, // eslint-disable-line @typescript-eslint/naming-convention + 'subscriptions:stream': sanitizedStreamParameters, // eslint-disable-line @typescript-eslint/naming-convention ...getDisabledSyncConfig(), }, }; @@ -33,7 +36,7 @@ export function getMountParamsForStream(mountParameters: JsonValue, streamParame return { gnmi: { ...gnmi, - 'subscriptions:stream': parsedStreamParameters, // eslint-disable-line @typescript-eslint/naming-convention + 'subscriptions:stream': sanitizedStreamParameters, // eslint-disable-line @typescript-eslint/naming-convention ...getDisabledSyncConfig(), }, }; @@ -43,7 +46,7 @@ export function getMountParamsForStream(mountParameters: JsonValue, streamParame return { netconf: { ...netconf, - 'subscriptions:stream': parsedStreamParameters, // eslint-disable-line @typescript-eslint/naming-convention + 'subscriptions:stream': sanitizedStreamParameters, // eslint-disable-line @typescript-eslint/naming-convention ...getDisabledSyncConfig(), }, };