1 import {Injectable} from "@angular/core";
2 import {HttpClient} from "@angular/common/http";
3 import {NgRedux} from "@angular-redux/store";
4 import {AppState} from "../../store/reducers";
5 import {Observable} from "rxjs";
6 import {ServiceInstance} from "../../models/serviceInstance";
7 import {Constants} from "../../utils/constants";
8 import {createServiceInstance} from "../../storeUtil/utils/service/service.actions";
11 export class InstantiationTemplatesService {
12 constructor(private http: HttpClient, private store: NgRedux<AppState>) {
15 retrieveInstantiationTemplateTopology(jobId: string): Observable<ServiceInstance> {
16 let pathQuery: string = `${Constants.Path.INSTANTIATION_TEMPLATE_TOPOLOGY}/${jobId}`;
17 return this.http.get<ServiceInstance>(pathQuery)
20 public retrieveAndStoreInstantiationTemplateTopology(jobId: string, serviceModelId: string): Observable<ServiceInstance> {
21 return this.retrieveInstantiationTemplateTopology(jobId).do((instantiationTemplate: ServiceInstance) => {
22 this.store.dispatch(createServiceInstance(instantiationTemplate, serviceModelId));