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===================================
20 import { HttpClient, HttpResponse } from '@angular/common/http';
21 import { Injectable } from '@angular/core';
22 import { Observable } from 'rxjs';
23 import { map } from 'rxjs/operators';
24 import { DashboardSuccessTransport } from '../../interfaces/dashboard.types';
25 import { E2RanDetails, E2SetupRequest } from '../../interfaces/e2-mgr.types';
26 import { CommonService } from '../common/common.service';
32 export class E2ManagerService {
34 private component = 'e2mgr';
37 private httpClient: HttpClient,
38 private commonSvc: CommonService) {
39 // injects to variable httpClient
43 * Gets E2 client version details
44 * @returns Observable that should yield a String
46 getVersion(instanceKey: string): Observable<string> {
47 const url = 'api/e2mgr/version';
48 return this.httpClient.get<DashboardSuccessTransport>(url).pipe(
49 // Extract the string here
50 map(res => res['data'])
56 * @returns Observable that should yield an array of objects
58 getRan(instanceKey: string): Observable<Array<E2RanDetails>> {
59 const url = this.commonSvc.buildPath(instanceKey, this.component, 'nodeb', 'ran');
60 return this.httpClient.get<Array<E2RanDetails>>(url);
64 * Sends a request to setup an ENDC/gNodeB connection
65 * @returns Observable. On success there is no data, only a code.
67 endcSetup(instanceKey: string, req: E2SetupRequest): Observable<HttpResponse<Object>> {
68 const url = this.commonSvc.buildPath(instanceKey, this.component, 'nodeb', 'endc-setup');
69 return this.httpClient.post(url, req, { observe: 'response' });
73 * Sends a request to setup an X2/eNodeB connection
74 * @returns Observable. On success there is no data, only a code.
76 x2Setup(instanceKey: string, req: E2SetupRequest): Observable<HttpResponse<Object>> {
77 const url = this.commonSvc.buildPath(instanceKey, this.component, 'nodeb', 'x2-setup');
78 return this.httpClient.post(url, req, { observe: 'response' });
82 * Sends a request to drop all RAN connections
83 * @returns Observable with body.
85 nodebPut(instanceKey: string): Observable<any> {
86 const url = this.commonSvc.buildPath(instanceKey, this.component, 'nodeb', 'shutdown');
87 return this.httpClient.put(url, { observe: 'body' });