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 { XMDeployableApp, XMDeployedApp, XMXappInfo } from '../../interfaces/app-mgr.types';
24 import { CommonService } from '../common/common.service';
27 export class AppMgrService {
29 private component = 'appmgr';
32 private httpClient: HttpClient,
33 private commonSvc: CommonService) {
36 getDeployable(instanceKey: string): Observable<XMDeployableApp[]> {
37 const url = this.commonSvc.buildPath(instanceKey, this.component, 'xapps', 'list');
38 return this.httpClient.get<XMDeployableApp[]>(url);
41 getDeployed(instanceKey: string): Observable<XMDeployedApp[]> {
42 const url = this.commonSvc.buildPath(instanceKey, this.component, 'xapps');
43 return this.httpClient.get<XMDeployedApp[]>(url);
46 deployXapp(instanceKey: string, name: string): Observable<HttpResponse<Object>> {
47 const xappInfo: XMXappInfo = { name: name };
48 const url = this.commonSvc.buildPath(instanceKey, this.component, 'xapps');
49 return this.httpClient.post(url, xappInfo, { observe: 'response' });
52 undeployXapp(instanceKey: string, name: string): Observable<HttpResponse<Object>> {
53 const url = this.commonSvc.buildPath(instanceKey, this.component, 'xapps', name);
54 return this.httpClient.delete(url, { observe: 'response' });
57 getConfig(instanceKey: string): Observable<any[]> {
58 // For demo purpose, pull example config from local
59 return this.httpClient.get<any[]>("/assets/mockdata/config.json");
60 // Once Xapp manager contains layout, should call backend to get xapp config
61 //const url = this.commonSvc.buildPath(instanceKey, this.component, 'config');
62 //return this.httpClient.get<any[]>(url);
65 putConfig(instanceKey: string, config: any): Observable<HttpResponse<Object>> {
66 const url = this.commonSvc.buildPath(instanceKey, this.component, 'config');
67 return this.httpClient.put(url, config, { observe: 'response' });