From 5c1f5756bcb5856e2d8b35e3c6ac206f891f8695 Mon Sep 17 00:00:00 2001 From: aribeiro Date: Thu, 19 Nov 2020 13:28:43 +0000 Subject: Add support for updating interface operations Allows to update interface operations on a component instance. Issue-ID: SDC-3446 Signed-off-by: aribeiro Signed-off-by: andre.schmid Change-Id: I6a2c44997c04d9d9ea298e3d0bc971da7b137799 --- .../topology-template.service.ts | 31 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'catalog-ui/src/app/ng2/services') diff --git a/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts b/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts index 492acdc1d6..953f0a1960 100644 --- a/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts +++ b/catalog-ui/src/app/ng2/services/component-services/topology-template.service.ts @@ -35,7 +35,7 @@ import { PropertyModel, IFileDownload, AttributeModel, - Capability, Requirement + Capability, Requirement, BEOperationModel, InterfaceModel } from "app/models"; import {ArtifactGroupType, COMPONENT_FIELDS} from "app/utils"; import {ComponentGenericResponse} from "../responses/component-generic-response"; @@ -65,6 +65,11 @@ import { PolicyInstance } from "../../../models/graph/zones/policy-instance"; import { PropertyBEModel } from "../../../models/properties-inputs/property-be-model"; import {map} from "rxjs/operators"; import {CapabilitiesConstraintObject} from "../../components/logic/capabilities-constraint/capabilities-constraint.component"; +import { + BEInterfaceOperationModel, + ComponentInstanceInterfaceModel, + InterfaceOperationModel +} from "../../../models/interfaceOperation"; /* we need to use this service from now, we will remove component.service when we finish remove the angular1. The service is duplicated since we can not use downgrades service with NGXS*/ @@ -108,8 +113,8 @@ export class TopologyTemplateService { [COMPONENT_FIELDS.COMPONENT_INSTANCES, COMPONENT_FIELDS.COMPONENT_POLICIES, COMPONENT_FIELDS.COMPONENT_NON_EXCLUDED_GROUPS]); } - getComponentResourceInstances(component: Component): Observable { - return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INSTANCES]); + getComponentInstances(componentType: string, componentId: string): Observable { + return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_INSTANCES]); } getComponentInputs(component: Component): Observable { @@ -478,6 +483,7 @@ export class TopologyTemplateService { } protected getComponentDataByFieldsName(componentType: string, componentId: string, fields: string[]): Observable { + console.info("Topology template -> getComponentDataByFieldsName with id:", componentId) let params: HttpParams = new HttpParams(); _.forEach(fields, (field: string): void => { params = params.append(API_QUERY_PARAMS.INCLUDE, field); @@ -485,6 +491,7 @@ export class TopologyTemplateService { // tslint:disable-next-line:object-literal-shorthand return this.http.get(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/filteredDataByParams', {params: params}) .map((res) => { + console.info("Topology template -> getComponentDataByFieldsName response:", res); return componentType === ComponentType.SERVICE ? new ServiceGenericResponse().deserialize(res) : new ComponentGenericResponse().deserialize(res); }); @@ -564,4 +571,22 @@ export class TopologyTemplateService { .pipe(map(response => response.directives)); } + updateComponentInstanceInterfaceOperation(componentMetaDataId: string, + componentMetaDataType: string, + componentInstanceId: string, + operation: InterfaceOperationModel): Observable { + const operationList = { + interfaces: { + [operation.interfaceType]: { + type: operation.interfaceType, + operations: { + [operation.name]: new BEInterfaceOperationModel(operation) + } + } + } + }; + return this.http.put(this.baseUrl + this + .getServerTypeUrl(componentMetaDataType) + componentMetaDataId + '/componentInstance/' + componentInstanceId + '/interfaceOperation', operationList); + } + } -- cgit 1.2.3-korg