diff options
author | herbert <herbert.eiselt@highstreet-technologies.com> | 2019-12-14 01:05:47 +0100 |
---|---|---|
committer | Herbert Eiselt <herbert.eiselt@highstreet-technologies.com> | 2019-12-16 12:52:11 +0000 |
commit | e6d0d67fdbe3fc70c996c8df33bd65d3b151dfad (patch) | |
tree | 0d2da7d1da74c6ebca6b53039741617d35f65d96 /sdnr/wt/odlux/apps/configurationApp/src/services | |
parent | 6b98928b7b1b0ebc28d2ef286e8c932fca67c305 (diff) |
update odlux and featureaggregator
v2 update odlux and featureaggregator bundles
Issue-ID: SDNC-1008
Signed-off-by: herbert <herbert.eiselt@highstreet-technologies.com>
Change-Id: I0018d7bfa3a0e6896c1b210b539a574af9808e22
Signed-off-by: herbert <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/odlux/apps/configurationApp/src/services')
-rw-r--r-- | sdnr/wt/odlux/apps/configurationApp/src/services/restServices.ts | 38 | ||||
-rw-r--r-- | sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts | 25 |
2 files changed, 63 insertions, 0 deletions
diff --git a/sdnr/wt/odlux/apps/configurationApp/src/services/restServices.ts b/sdnr/wt/odlux/apps/configurationApp/src/services/restServices.ts new file mode 100644 index 000000000..061be05ec --- /dev/null +++ b/sdnr/wt/odlux/apps/configurationApp/src/services/restServices.ts @@ -0,0 +1,38 @@ +import { requestRest, requestRestExt } from "../../../../framework/src/services/restService"; +import { convertPropertyNames, replaceHyphen } from "../../../../framework/src/utilities/yangHelper"; + +import { NetworkElementConnection } from "../models/networkElementConnection"; + +class RestService { + public async getMountedNetworkElementByMountId(nodeId: string): Promise<NetworkElementConnection | null> { + // const path = 'restconf/operational/network-topology:network-topology/topology/topology-netconf/node/' + nodeId; + // const connectedNetworkElement = await requestRest<NetworkElementConnection>(path, { method: "GET" }); + // return connectedNetworkElement || null; + + const path = "/restconf/operations/data-provider:read-network-element-connection-list"; + const body = { "input": { "filter": [{ "property": "node-id", "filtervalue": nodeId }], "sortorder": [], "pagination": { "size": 1, "page": 1 } } }; + const networkElementResult = await requestRest<{ output: { data: NetworkElementConnection[] } }>(path, { method: "POST", body: JSON.stringify(body) }); + return networkElementResult && networkElementResult.output && networkElementResult.output.data && + networkElementResult.output.data.map(obj => convertPropertyNames(obj, replaceHyphen))[0] || null; + } + + /** Reads the config data by restconf path. + * @param path The restconf path to be used for read. + * @returns The data. + */ + public getConfigData(path: string) { + return requestRestExt<{ [key: string]: any }>(path, { method: "GET" }); + } + + /** Updates or creates the config data by restconf path using data. + * @param path The restconf path to identify the note to update. + * @param data The data to be updated. + * @returns The written data. + */ + public setConfigData(path: string, data: any) { + return requestRestExt<{ [key: string]: any }>(path, { method: "PUT", body: JSON.stringify(data) }); + } + } + +export const restService = new RestService(); +export default restService;
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts b/sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts new file mode 100644 index 000000000..17a4e43a7 --- /dev/null +++ b/sdnr/wt/odlux/apps/configurationApp/src/services/yangService.ts @@ -0,0 +1,25 @@ +type YangInfo = [string, (string | null | undefined)]; + +const cache: { [path: string]: string } = { + +}; + +class YangService { + + public async getCapability(capability: string, version?: string) { + const url = `/yang-schema/${capability}${version ? `/${version}` : ""}`; + + const cacheHit = cache[url]; + if (cacheHit) return cacheHit; + + const res = await fetch(url); + const yangFile = res.ok && await res.text(); + if (yangFile !== false && yangFile !== null) { + cache[url] = yangFile; + } + return yangFile; + } +} + +export const yangService = new YangService(); +export default yangService;
\ No newline at end of file |