2 * ========================LICENSE_START=================================
5 * Copyright (C) 2019 AT&T Intellectual Property
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ========================LICENSE_END===================================
21 import { Injectable } from '@angular/core';
22 import { HttpClient, HttpParams } from '@angular/common/http';
23 import { Observable } from 'rxjs';
24 import { map } from 'rxjs/operators';
25 import { DashboardSuccessTransport } from '../../interfaces/dashboard.types';
26 import { ANRNeighborCellRelation, ANRNeighborCellRelationMod } from '../../interfaces/anr-xapp.types';
31 export class ANRXappService {
33 // Trailing slashes are confusing so omit them here
34 private basePath = 'api/xapp/anr';
35 private ncrtPath = 'ncrt';
36 private servingPath = 'servingcells';
37 private neighborPath = 'neighborcells';
39 constructor(private httpClient: HttpClient) {
40 // injects to variable httpClient
43 private buildPath(...args: any[]) {
44 let result = this.basePath;
45 args.forEach(part => {
46 result = result + '/' + part;
52 * Gets ANR xApp client version details
53 * @returns Observable that should yield a String
55 getVersion(): Observable<string> {
56 const url = this.buildPath('version');
57 return this.httpClient.get<DashboardSuccessTransport>(url).pipe(
58 // Extract the string here
59 map(res => res['data'])
64 * Performs a liveness probe
65 * @returns Observable that should yield a response code (no data)
67 getHealthAlive(): Observable<any> {
68 const url = this.buildPath('health/alive');
69 return this.httpClient.get(url, { observe: 'response' });
73 * Performs a readiness probe
74 * @returns Observable that should yield a response code (no data)
76 getHealthReady(): Observable<any> {
77 const url = this.buildPath('health/ready');
78 return this.httpClient.get(url, { observe: 'response' });
82 * Gets array of gNodeB IDs
83 * @returns Observable that should yield a string array
85 getgNodeBs(): Observable<string[]> {
86 const url = this.buildPath('gnodebs');
87 return this.httpClient.get<string[]>(url).pipe(
88 // Extract the array of IDs here
89 map(res => res['gNodeBIds'])
94 * Gets the neighbor cell relation table for all gNodeBs or based on query parameters
95 * @param ggnbId Optional parameter for the gNB ID
96 * @param servingCellNrcgi Serving cell NRCGI
97 * @param neighborCellNrpci Neighbor cell NRPCI
98 * @returns Observable of ANR neighbor cell relation array
100 getNcrtInfo(ggnodeb: string = '', servingCellNrcgi: string = '', neighborCellNrpci: string = ''): Observable<ANRNeighborCellRelation[]> {
101 const url = this.buildPath(this.ncrtPath);
102 return this.httpClient.get<ANRNeighborCellRelation[]>(url, {
103 params: new HttpParams()
104 .set('ggnodeb', ggnodeb)
105 .set('servingCellNrcgi', servingCellNrcgi)
106 .set('neighborCellNrpci', neighborCellNrpci)
108 // Extract the array of relations here
109 map(res => res['ncrtRelations'])
114 * Modify neighbor cell relation based on Serving Cell NRCGI and Neighbor Cell NRPCI
115 * @param servingCellNrcgi Serving cell NRCGI
116 * @param neighborCellNrpci Neighbor cell NRPCI
117 * @param mod Values to store in the specified relation
118 * @returns Observable that yields a response code only, no data
120 modifyNcr(servingCellNrcgi: string, neighborCellNrpci: string, mod: ANRNeighborCellRelationMod): Observable<Object> {
121 const url = this.buildPath(this.ncrtPath, this.servingPath, servingCellNrcgi, this.neighborPath, neighborCellNrpci);
122 return this.httpClient.put(url, mod, { observe: 'response' });
126 * Deletes neighbor cell relation based on Serving Cell NRCGI and Neighbor Cell NRPCI
127 * @param servingCellNrcgi Serving cell NRCGI
128 * @param neighborCellNrpci Neighbor cell NRPCI
129 * @returns Observable that yields a response code only, no data
131 deleteNcr(servingCellNrcgi: string, neighborCellNrpci: string): Observable<Object> {
132 const url = this.buildPath(this.ncrtPath, this.servingPath, servingCellNrcgi, this.neighborPath, neighborCellNrpci);
133 return this.httpClient.delete(url, { observe: 'response' });