blob: 1e98e9b07b5dba096fd2327f87817170b2641b00 [file] [log] [blame]
danielhanrahanc0b6f3a2024-04-29 16:16:42 +01001/*
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_sourabh175d12d2024-08-30 16:25:04 +010021import {performPostRequest, NCMP_BASE_URL} from './utils.js';
22
23export function executeCmHandleSearch(scenario) {
24 return executeSearchRequest('searches', scenario);
25}
26
27export function executeCmHandleIdSearch(scenario) {
28 return executeSearchRequest('id-searches', scenario);
29}
30
31function 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}
danielhanrahanc0b6f3a2024-04-29 16:16:42 +010037
danielhanrahan0e006002024-06-06 20:43:21 +010038const SEARCH_PARAMETERS_PER_SCENARIO = {
danielhanrahana9de1662024-09-21 16:47:43 +010039 "no-filter": {
40 "cmHandleQueryParameters": []
41 },
42 "module": {
danielhanrahanf2e1e252024-08-25 21:35:19 +010043 "cmHandleQueryParameters": [
danielhanrahan0e006002024-06-06 20:43:21 +010044 {
danielhanrahanf2e1e252024-08-25 21:35:19 +010045 "conditionName": "hasAllModules",
46 "conditionParameters": [{"moduleName": "ietf-yang-types"}]
danielhanrahana9de1662024-09-21 16:47:43 +010047 }
48 ]
49 },
50 "property": {
51 "cmHandleQueryParameters": [
danielhanrahanf2e1e252024-08-25 21:35:19 +010052 {
53 "conditionName": "hasAllProperties",
54 "conditionParameters": [{"Color": "yellow"}]
danielhanrahan0e006002024-06-06 20:43:21 +010055 }
56 ]
danielhanrahan4e9f68c2024-06-28 13:43:35 +010057 },
danielhanrahana9de1662024-09-21 16:47:43 +010058 "trust-level": {
59 "cmHandleQueryParameters": [
60 {
61 "conditionName": "cmHandleWithTrustLevel",
62 "conditionParameters": [ {"trustLevel": "COMPLETE"} ]
63 }
64 ]
65 },
66 "cps-path-for-ready-cm-handles": {
danielhanrahanf2e1e252024-08-25 21:35:19 +010067 "cmHandleQueryParameters": [
danielhanrahan4e9f68c2024-06-28 13:43:35 +010068 {
danielhanrahanf2e1e252024-08-25 21:35:19 +010069 "conditionName": "cmHandleWithCpsPath",
70 "conditionParameters": [{"cpsPath": "//state[@cm-handle-state='READY']"}]
danielhanrahan4e9f68c2024-06-28 13:43:35 +010071 }
72 ]
danielhanrahan0e006002024-06-06 20:43:21 +010073 }
74};