X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fservices%2Fanr-xapp%2Fanr-xapp.service.ts;h=e06b708160439a8d7d2ce0ce5157bc910486e709;hb=036e63834ec23b08ceb2f9cece1eaa602d3082bd;hp=f9403f1f9c3473da042da5763bfc64a286a8d42c;hpb=a4c7cdd075d372de0ab352abc46359d88a570d90;p=portal%2Fric-dashboard.git diff --git a/webapp-frontend/src/app/services/anr-xapp/anr-xapp.service.ts b/webapp-frontend/src/app/services/anr-xapp/anr-xapp.service.ts index f9403f1f..e06b7081 100644 --- a/webapp-frontend/src/app/services/anr-xapp/anr-xapp.service.ts +++ b/webapp-frontend/src/app/services/anr-xapp/anr-xapp.service.ts @@ -2,14 +2,14 @@ * ========================LICENSE_START================================= * O-RAN-SC * %% - * Copyright (C) 2019 AT&T Intellectual Property and Nokia + * Copyright (C) 2019 AT&T Intellectual Property * %% * Licensed 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. @@ -21,27 +21,43 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpParams } from '@angular/common/http'; import { Observable } from 'rxjs'; +import { map } from 'rxjs/operators'; import { DashboardSuccessTransport } from '../../interfaces/dashboard.types'; import { ANRNeighborCellRelation, ANRNeighborCellRelationMod } from '../../interfaces/anr-xapp.types'; @Injectable({ providedIn: 'root' }) -export class AnrXappService { +export class ANRXappService { - private basePath = 'api/xapp/anr/'; - private cellPath = 'cell/cellIdentifier/'; + // Trailing slashes are confusing so omit them here + private basePath = 'api/xapp/anr'; + private ncrtPath = 'ncrt'; + private servingPath = 'servingcells'; + private neighborPath = 'neighborcells'; constructor(private httpClient: HttpClient) { // injects to variable httpClient } + private buildPath(...args: any[]) { + let result = this.basePath; + args.forEach(part => { + result = result + '/' + part; + }); + return result; + } + /** * Gets ANR xApp client version details - * @returns Observable that should yield a DashboardSuccessTransport + * @returns Observable that should yield a String */ - getVersion(): Observable { - return this.httpClient.get(this.basePath + 'version'); + getVersion(): Observable { + const url = this.buildPath('version'); + return this.httpClient.get(url).pipe( + // Extract the string here + map(res => res['data']) + ); } /** @@ -49,7 +65,8 @@ export class AnrXappService { * @returns Observable that should yield a response code (no data) */ getHealthAlive(): Observable { - return this.httpClient.get(this.basePath + 'health/alive'); + const url = this.buildPath('health/alive'); + return this.httpClient.get(url, { observe: 'response' }); } /** @@ -57,62 +74,63 @@ export class AnrXappService { * @returns Observable that should yield a response code (no data) */ getHealthReady(): Observable { - return this.httpClient.get(this.basePath + 'health/ready'); + const url = this.buildPath('health/ready'); + return this.httpClient.get(url, { observe: 'response' }); + } + +/** + * Gets array of gNodeB IDs + * @returns Observable that should yield a string array + */ + getgNodeBs(): Observable { + const url = this.buildPath('gnodebs'); + return this.httpClient.get(url).pipe( + // Extract the array of IDs here + map(res => res['gNodeBIds']) + ); } /** - * Query NCRT of all cells, all or one gNB(s) + * Gets the neighbor cell relation table for all gNodeBs or based on query parameters * @param ggnbId Optional parameter for the gNB ID - * @param startIndex Optional parameter for the start index - * @param limit Optional parameter for the limit (page size) - * @returns Observable of ANRNeighborCellRelation + * @param servingCellNrcgi Serving cell NRCGI + * @param neighborCellNrpci Neighbor cell NRPCI + * @returns Observable of ANR neighbor cell relation array */ - getNcrtInfo(ggnbId?: string, startIndex?: string, limit?: number): Observable { - const queryParams = new HttpParams(); - if (ggnbId) { - queryParams.set('ggnbid', ggnbId); - } - if (startIndex) { - queryParams.set('startIndex', startIndex); - } - if (limit) { - queryParams.set('limit', limit.toString()); - } - return this.httpClient.get(this.basePath + 'cell', { params: queryParams } ); + getNcrtInfo(ggnodeb: string = '', servingCellNrcgi: string = '', neighborCellNrpci: string = ''): Observable { + const url = this.buildPath(this.ncrtPath); + return this.httpClient.get(url, { + params: new HttpParams() + .set('ggnodeb', ggnodeb) + .set('servingCellNrcgi', servingCellNrcgi) + .set('neighborCellNrpci', neighborCellNrpci) + }).pipe( + // Extract the array of relations here + map(res => res['ncrtRelations']) + ); } /** - * Query NCRT of a single serving cell, all or one gNB(s) - * @param cellId cell ID - * @param ggnbid Optional parameter for the gNB ID - * @param startIndex Optional parameter for the start index - * @param limit Optional parameter for the limit (page size) - * @returns Observable of ANRNeighborCellRelation + * Modify neighbor cell relation based on Serving Cell NRCGI and Neighbor Cell NRPCI + * @param servingCellNrcgi Serving cell NRCGI + * @param neighborCellNrpci Neighbor cell NRPCI + * @param mod Values to store in the specified relation + * @returns Observable that yields a response code only, no data */ - getCellNcrtInfo(cellId: string, ggnbId?: string, startIndex?: string, limit?: number): Observable { - const queryParams = new HttpParams(); - if (ggnbId) { - queryParams.set('ggnbid', ggnbId); - } - if (startIndex) { - queryParams.set('startIndex', startIndex); - } - if (limit) { - queryParams.set('limit', limit.toString()); - } - return this.httpClient.get(this.basePath + this.cellPath + cellId, { params: queryParams } ); + modifyNcr(servingCellNrcgi: string, neighborCellNrpci: string, mod: ANRNeighborCellRelationMod): Observable { + const url = this.buildPath(this.ncrtPath, this.servingPath, servingCellNrcgi, this.neighborPath, neighborCellNrpci); + return this.httpClient.put(url, mod, { observe: 'response' }); } /** - * Modify neighbor cell relations based on Source Cell NR CGI and Target Cell NR PCI / NR CGI - * @param cellId cell ID - * @param table Array of ANRNeighborCellRelationMod - * @returns Observable that should yield a response code (no data) + * Deletes neighbor cell relation based on Serving Cell NRCGI and Neighbor Cell NRPCI + * @param servingCellNrcgi Serving cell NRCGI + * @param neighborCellNrpci Neighbor cell NRPCI + * @returns Observable that yields a response code only, no data */ - modifyNcrt(cellId: string, table: ANRNeighborCellRelationMod []): Observable { - return this.httpClient.put(this.basePath + this.cellPath + cellId, table); + deleteNcr(servingCellNrcgi: string, neighborCellNrpci: string): Observable { + const url = this.buildPath(this.ncrtPath, this.servingPath, servingCellNrcgi, this.neighborPath, neighborCellNrpci); + return this.httpClient.delete(url, { observe: 'response' }); } - /** TODO: deleteNcrt */ - }