[AAI-92 Amsterdam] Update license
[aai/sparky-fe.git] / src / app / networking / NetworkUtil.js
1 /*
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  *
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23 import {
24   AUDIT_SEARCH_DATE_FORMAT,
25   AUDIT_SEARCH_DATE_TIME_ZONE
26 } from './NetworkConstants.js';
27
28 export function getTableDateQueryString(requestObject) {
29   return {
30     'queryParameters': {
31       'startDate': requestObject.dateRange.startDate.format(
32         AUDIT_SEARCH_DATE_FORMAT),
33       'endDate': requestObject.dateRange.endDate.format(
34         AUDIT_SEARCH_DATE_FORMAT),
35       'time_zone': requestObject.dateRange.startDate.format(
36         AUDIT_SEARCH_DATE_TIME_ZONE),
37       'typeData': {
38         'type': 'pagination',
39         'from': requestObject.startIndex,
40         'size': requestObject.resultCount
41       }
42     }
43   };
44 }
45
46 export function getTSUIElasticSearchQueryString(query) {
47   // Create the query request
48   let posFirstEqualSign = query.indexOf('=');
49   let newQuery = query.substring(posFirstEqualSign + 1);  // remove the first
50                                                           // 'attrName=' from
51                                                           //'attrName=attrValue'
52   newQuery = newQuery.replace(/\,[^\=]+\=/gi, ' ');  // remove all ', attrName='
53   newQuery = newQuery.trim(); // remove whitespace at both ends, if any
54
55   return {
56     'maxResults': '10',
57     'queryStr': newQuery
58   };
59 }
60 export function getSeverityVisualizationQueryString(requestObject) {
61   return {
62     'queryParameters': {
63       'startDate': requestObject.dateRange.startDate.format(
64         AUDIT_SEARCH_DATE_FORMAT),
65       'endDate': requestObject.dateRange.endDate.format(
66         AUDIT_SEARCH_DATE_FORMAT),
67       'time_zone': requestObject.dateRange.startDate.format(
68         AUDIT_SEARCH_DATE_TIME_ZONE),
69       'typeData': {
70         'type': 'groupBy',
71         'groupByField': 'severity'
72       }
73     }
74   };
75 }
76
77 export function getStatusVisualizationQueryString(requestObject) {
78   return {
79     'queryParameters': {
80       'startDate': requestObject.dateRange.startDate.format(
81         AUDIT_SEARCH_DATE_FORMAT),
82       'endDate': requestObject.dateRange.endDate.format(
83         AUDIT_SEARCH_DATE_FORMAT),
84       'time_zone': requestObject.dateRange.startDate.format(
85         AUDIT_SEARCH_DATE_TIME_ZONE),
86       'typeData': {
87         'type': 'groupBy',
88         'groupByField': 'category'
89       }
90     }
91   };
92 }
93
94 export function getEntityTypeVisualizationQueryString(requestObject) {
95   return {
96     'queryParameters': {
97       'startDate': requestObject.dateRange.startDate.format(
98         AUDIT_SEARCH_DATE_FORMAT),
99       'endDate': requestObject.dateRange.endDate.format(
100         AUDIT_SEARCH_DATE_FORMAT),
101       'time_zone': requestObject.dateRange.startDate.format(
102         AUDIT_SEARCH_DATE_TIME_ZONE),
103       'typeData': {
104         'type': 'groupBy',
105         'groupByField': 'entityType'
106       }
107     }
108   };
109 }
110
111 export function getDateVisualizationQueryString(requestObject) {
112   return {
113     'queryParameters': {
114       'startDate': requestObject.dateRange.startDate.format(
115         AUDIT_SEARCH_DATE_FORMAT),
116       'endDate': requestObject.dateRange.endDate.format(
117         AUDIT_SEARCH_DATE_FORMAT),
118       'time_zone': requestObject.dateRange.startDate.format(
119         AUDIT_SEARCH_DATE_TIME_ZONE),
120       'typeData': {
121         'type': 'dateHistogram'
122       }
123     }
124   };
125 }
126
127 export function getVnfOrchStatusQueryString(requestObject) {
128   return {
129     'hashId': requestObject,
130     'groupby': 'orchestration-status'
131   };
132 }
133 export function getVnfProvStatusQueryString(requestObject) {
134   return {
135     'hashId': requestObject,
136     'groupby': 'prov-status'
137   };
138 }
139 export function getVnfCountQueryString(requestObject) {
140   return {
141     'hashId': requestObject
142   };
143 }
144
145
146
147
148