summaryrefslogtreecommitdiffstats
path: root/dcaedt_be/src/main/java/org/onap/sdc/dcae/composition/controller/ServicesController.java
blob: da408b509e9c86bf0252c08c57b9a38ffa144ca6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package org.onap.sdc.dcae.composition.controller;

import org.onap.sdc.common.onaplog.enums.LogLevel;
import org.onap.sdc.dcae.composition.impl.ServiceBusinessLogic;
import org.onap.sdc.dcae.composition.restmodels.AttachVFCMTServiceRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@EnableAutoConfiguration
@CrossOrigin
public class ServicesController extends BaseController {

	@Autowired
	private ServiceBusinessLogic serviceBusinessLogic;
	/***
	 * GET services list by VFCMT
	 * @param userId
	 * @param vfcmtUuid
	 * @return ResponseEntity
	 */
	@RequestMapping(value = { "/services/{vfcmtUuid}" }, method = { RequestMethod.GET }, produces = {"application/json" })
	public ResponseEntity services(@RequestHeader("USER_ID") String userId, @PathVariable String vfcmtUuid, @ModelAttribute("requestId") String requestId) {

		debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Starting services");
		return serviceBusinessLogic.services(userId,vfcmtUuid,requestId);
	}

	/***
	 * GET a single service
	 * @param theServiceId
	 * @return ResponseEntity
	 */
	@RequestMapping(value = { "/service/{theServiceId}" }, method = { RequestMethod.GET }, produces = {"application/json" })
	public ResponseEntity service(@PathVariable String theServiceId, @ModelAttribute("requestId") String requestId) {

		debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Starting service");
		return serviceBusinessLogic.service(theServiceId,requestId);
	}

	
	/***
	 * Attach service and service instance to VFCMT 
	 * @param userId
	 * @param request
	 * @return ResponseEntity
	 */
	@Deprecated
	@RequestMapping(value = "/{vfcmtUuid}/attachment", method = RequestMethod.POST, produces = {"application/json" })
	public ResponseEntity attachService(
			@PathVariable("vfcmtUuid") String vfcmtUuid, 
			@RequestHeader("USER_ID") String userId,
			@RequestBody AttachVFCMTServiceRequest request,
			@ModelAttribute("requestId") String requestId) {

		debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Starting attachService");
		return serviceBusinessLogic.attachService(vfcmtUuid,userId,request,requestId);
	}

	@RequestMapping(value = { "/{vfcmtUuid}/attachment" }, method = { RequestMethod.GET }, produces = {"application/json" })
	public ResponseEntity getAttachedService(@PathVariable("vfcmtUuid") String vfcmtUuid, @ModelAttribute("requestId") String requestId) {

		debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Starting getAttachedService");
		return serviceBusinessLogic.getAttachedService(vfcmtUuid,requestId);
	}

}