danielhanrahan | c0b6f3a | 2024-04-29 16:16:42 +0100 | [diff] [blame] | 1 | /* |
| 2 | * ============LICENSE_START======================================================= |
| 3 | * Copyright (C) 2024 Nordix Foundation |
| 4 | * ================================================================================ |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | * SPDX-License-Identifier: Apache-2.0 |
| 18 | * ============LICENSE_END========================================================= |
| 19 | */ |
| 20 | |
sourabh_sourabh | 175d12d | 2024-08-30 16:25:04 +0100 | [diff] [blame] | 21 | import {performPostRequest, NCMP_BASE_URL} from './utils.js'; |
| 22 | |
| 23 | export function executeCmHandleSearch(scenario) { |
| 24 | return executeSearchRequest('searches', scenario); |
| 25 | } |
| 26 | |
| 27 | export function executeCmHandleIdSearch(scenario) { |
| 28 | return executeSearchRequest('id-searches', scenario); |
| 29 | } |
| 30 | |
| 31 | function executeSearchRequest(searchType, scenario) { |
| 32 | const searchParameters = SEARCH_PARAMETERS_PER_SCENARIO[scenario]; |
| 33 | const payload = JSON.stringify(searchParameters); |
| 34 | const url = `${NCMP_BASE_URL}/ncmp/v1/ch/${searchType}`; |
| 35 | return performPostRequest(url, payload, searchType); |
| 36 | } |
danielhanrahan | c0b6f3a | 2024-04-29 16:16:42 +0100 | [diff] [blame] | 37 | |
danielhanrahan | 0e00600 | 2024-06-06 20:43:21 +0100 | [diff] [blame] | 38 | const SEARCH_PARAMETERS_PER_SCENARIO = { |
danielhanrahan | a9de166 | 2024-09-21 16:47:43 +0100 | [diff] [blame] | 39 | "no-filter": { |
| 40 | "cmHandleQueryParameters": [] |
| 41 | }, |
| 42 | "module": { |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 43 | "cmHandleQueryParameters": [ |
danielhanrahan | 0e00600 | 2024-06-06 20:43:21 +0100 | [diff] [blame] | 44 | { |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 45 | "conditionName": "hasAllModules", |
| 46 | "conditionParameters": [{"moduleName": "ietf-yang-types"}] |
danielhanrahan | a9de166 | 2024-09-21 16:47:43 +0100 | [diff] [blame] | 47 | } |
| 48 | ] |
| 49 | }, |
| 50 | "property": { |
| 51 | "cmHandleQueryParameters": [ |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 52 | { |
| 53 | "conditionName": "hasAllProperties", |
| 54 | "conditionParameters": [{"Color": "yellow"}] |
danielhanrahan | 0e00600 | 2024-06-06 20:43:21 +0100 | [diff] [blame] | 55 | } |
| 56 | ] |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 57 | }, |
danielhanrahan | a9de166 | 2024-09-21 16:47:43 +0100 | [diff] [blame] | 58 | "trust-level": { |
| 59 | "cmHandleQueryParameters": [ |
| 60 | { |
| 61 | "conditionName": "cmHandleWithTrustLevel", |
| 62 | "conditionParameters": [ {"trustLevel": "COMPLETE"} ] |
| 63 | } |
| 64 | ] |
| 65 | }, |
| 66 | "cps-path-for-ready-cm-handles": { |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 67 | "cmHandleQueryParameters": [ |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 68 | { |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 69 | "conditionName": "cmHandleWithCpsPath", |
| 70 | "conditionParameters": [{"cpsPath": "//state[@cm-handle-state='READY']"}] |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 71 | } |
| 72 | ] |
danielhanrahan | 0e00600 | 2024-06-06 20:43:21 +0100 | [diff] [blame] | 73 | } |
| 74 | }; |