diff options
author | kaixiliu <liukaixi@chinamobile.com> | 2024-12-25 17:30:05 +0800 |
---|---|---|
committer | kaixiliu <liukaixi@chinamobile.com> | 2024-12-26 14:14:03 +0800 |
commit | 4f2ee468370622d8e45382087f0599032b9afeba (patch) | |
tree | bccead7b01c9536e349013facf985a67702975ea /usecaseui-portal/src/app/api | |
parent | b71bd34b5baa8e3dfedf83f777d62c988c6b9c97 (diff) |
Optimize your code and add editing capabilities for your knowledge base and apps.
Issue-ID: USECASEUI-844
Change-Id: I439f61a3068ea839185b58f3a2d3afb0739a0d0f
Signed-off-by: kaixiliu <liukaixi@chinamobile.com>
Diffstat (limited to 'usecaseui-portal/src/app/api')
-rw-r--r-- | usecaseui-portal/src/app/api/maas.api.ts | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/usecaseui-portal/src/app/api/maas.api.ts b/usecaseui-portal/src/app/api/maas.api.ts new file mode 100644 index 00000000..f7a558f7 --- /dev/null +++ b/usecaseui-portal/src/app/api/maas.api.ts @@ -0,0 +1,91 @@ +/* + Copyright (C) 2022 CMCC, Inc. and others. All rights reserved. + + 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. + See the License for the specific language governing permissions and + limitations under the License. +*/ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs/Observable'; +import { of } from 'rxjs/observable/of'; +import { KnowledgeBaseResponse, KnowledgeBasesResponse, OperatorsResponse, ResponseHeader } from '../views/maas/knowledge-base-management/knowledge-base.type' +import { Application, ApplicationResponse, ApplicationsResponse } from '../views/maas/build/application.type'; +@Injectable() +export class MaasApi { + + constructor(private http: HttpClient) { } + baseUrl = "/api/usecaseui-llm-adaptation/v1/"; + url = { + getKnowledgeBaseRecord: this.baseUrl + "knowledgeBase/query", + removeKnowledgeBase: this.baseUrl + "knowledgeBase/delete/", + getKnowledgeBaseById: this.baseUrl + "knowledgeBase/queryById/", + updateKnowledgeBaseRecord: this.baseUrl + "knowledgeBase/edit", + createKnowledgeBase: this.baseUrl + "knowledgeBase/create", + maasUrl: this.baseUrl + "maas/getAll", + getAllApplication: this.baseUrl + "application/query", + deleteApplicationById: this.baseUrl + "application/delete/", + getApplicationById: this.baseUrl + "application/queryById/", + operatorsUrl: this.baseUrl + 'operator/maas/getAll', + KnowledgeBaseByMaas: this.baseUrl + 'knowledgeBase/queryByMaaSId/', + createApplicationUrl: this.baseUrl + "application/create", + updateApplication: this.baseUrl + "application/edit" + }; + + getKnowledgeBaseRecord() { + return this.http.get<KnowledgeBasesResponse>(this.url.getKnowledgeBaseRecord); + } + + updateKnowledgeBase(body: any) { + return this.http.post<ResponseHeader>(this.url.updateKnowledgeBaseRecord, body); + } + + createKnowledgeBase(body: FormData) { + return this.http.post<ResponseHeader>(this.url.createKnowledgeBase, body); + } + + deleteKnowledgeBaseData(id: string) { + return this.http.delete<ResponseHeader>(this.url.removeKnowledgeBase + id); + } + + getKnowledgeBaseById(id: string) { + return this.http.get<KnowledgeBaseResponse>(this.url.getKnowledgeBaseById + id); + } + + getAllApplication() { + return this.http.get<ApplicationsResponse>(this.url.getAllApplication); + } + + deleteApplicationById(id: string) { + return this.http.delete<ResponseHeader>(this.url.deleteApplicationById + id); + } + + getApplicationById(id: string) { + return this.http.get<ApplicationResponse>(this.url.getApplicationById + id); + } + + getOperators() { + return this.http.get<OperatorsResponse>(this.url.operatorsUrl); + } + + fetchKnowledgeBaseByMaasId(id: string) { + return this.http.get<KnowledgeBasesResponse>(this.url.KnowledgeBaseByMaas + id); + } + + createApplication(body: Application) { + return this.http.post<ResponseHeader>(this.url.createApplicationUrl, body) + } + + updateApplication(body: Application) { + return this.http.post<ResponseHeader>(this.url.updateApplication, body) + } + +} |