From fe4afd47955705bb377583649cb53e2cf4508493 Mon Sep 17 00:00:00 2001 From: talio Date: Sun, 14 Apr 2019 15:37:20 +0300 Subject: Declare properties as policies Change-Id: I54dc7b444e08117097c314cf5f51bd356ac5287d Issue-ID: SDC-2240 Signed-off-by: talio --- .../component-services/component.service.ts | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'catalog-ui/src/app/ng2/services/component-services') diff --git a/catalog-ui/src/app/ng2/services/component-services/component.service.ts b/catalog-ui/src/app/ng2/services/component-services/component.service.ts index 3243291483..fd746516b7 100644 --- a/catalog-ui/src/app/ng2/services/component-services/component.service.ts +++ b/catalog-ui/src/app/ng2/services/component-services/component.service.ts @@ -25,7 +25,7 @@ import 'rxjs/add/operator/map'; import 'rxjs/add/operator/toPromise'; import {Response, URLSearchParams} from '@angular/http'; import { Component, ComponentInstance, InputBEModel, InstancePropertiesAPIMap, FilterPropertiesAssignmentData, - PropertyBEModel, OperationModel, BEOperationModel, Capability, Requirement} from "app/models"; + PropertyBEModel, OperationModel, BEOperationModel, Capability, Requirement, PolicyInstance} from "app/models"; import {COMPONENT_FIELDS, CommonUtils, SERVICE_FIELDS} from "app/utils"; import {downgradeInjectable} from '@angular/upgrade/static'; import {ComponentGenericResponse} from "../responses/component-generic-response"; @@ -285,6 +285,30 @@ export class ComponentServiceNg2 { }) } + createPolicy(component:Component, policiesToCreate:InstancePropertiesAPIMap, isSelf:boolean):Observable { + const policiesList = + isSelf ? + {'componentPropertiesToPolicies': { + ...policiesToCreate.componentInstanceProperties + } + } : + {'componentInstancePropertiesToPolicies': { + ...policiesToCreate.componentInstanceProperties + } + }; + return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/create/policies', policiesList) + .map(res => { + return res.json(); + }); + } + + deletePolicy(component:Component, policy: PolicyInstance) { + return this.http.put(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/policies/' + policy.uniqueId + '/undeclare', policy) + .map(res => { + return res.json(); + }); + } + restoreComponent(componentType:string, componentId:string){ return this.http.post(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/restore', {}) } -- cgit 1.2.3-korg