Github user iraghumitra commented on a diff in the pull request:
https://github.com/apache/metron/pull/620#discussion_r126957989
--- Diff: metron-interface/metron-alerts/src/app/service/data-source.ts ---
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {Observable} from 'rxjs/Rx';
+import {Injectable} from '@angular/core';
+import {Http} from '@angular/http';
+
+import {Alert} from '../model/alert';
+import {ColumnMetadata} from '../model/column-metadata';
+import {ColumnNames} from '../model/column-names';
+import {TableMetadata} from '../model/table-metadata';
+import {SaveSearch} from '../model/save-search';
+import {AlertsSearchResponse} from '../model/alerts-search-response';
+import {SearchRequest} from '../model/search-request';
+
+@Injectable()
+export abstract class DataSource {
+ defaultHeaders: {'Content-Type': 'application/json', 'X-Requested-With':
'XMLHttpRequest'};
+
+ constructor(protected http: Http) {}
+
+ // Calls to fetch alerts
+ abstract getAlerts(searchRequest: SearchRequest):
Observable<AlertsSearchResponse>
+ abstract getAlert(index: string, type: string, alertId: string):
Observable<Alert>
+ abstract updateAlertState(request: any): Observable<{}>
+
+ // Calls to fetch default alert table column names and all the field
names across all indexes
+ abstract getDefaultAlertTableColumnNames(): Observable<ColumnMetadata[]>
+ abstract getAllFieldNames(): Observable<ColumnMetadata[]>
+
+ // Calls to rename field names and to fetch the renamed field names
+ abstract getAlertTableColumnNames(): Observable<ColumnNames[]>
+ abstract saveAlertTableColumnNames(columns: ColumnNames[]):
Observable<{}>
+
+ // Calls to fetch and save alerts table settings like refresh interval,
page size, default selected table column names
+ abstract getAlertTableSettings(): Observable<TableMetadata>
--- End diff --
The idea here is to provide an abstraction for all the API's not just the
ES API's.
In theory, if we want GUI to use rest API instead of directly querying ES
and storing data in the local browser cache the API provider should support all
the API's defined in data-source.ts.
The API's can be written in phases we would create a separate Impl class
that extends Datasource and use the API's that are available.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---