2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.vnfmadapter.rest;
23 import static org.onap.so.adapters.vnfmadapter.Constants.APPLICATION_ZIP;
24 import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL;
25 import static org.slf4j.LoggerFactory.getLogger;
26 import java.util.List;
27 import javax.ws.rs.core.MediaType;
28 import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001;
29 import org.slf4j.Logger;
30 import org.springframework.http.HttpStatus;
31 import org.springframework.http.ResponseEntity;
32 import org.springframework.stereotype.Controller;
33 import org.springframework.web.bind.annotation.GetMapping;
34 import org.springframework.web.bind.annotation.PathVariable;
35 import org.springframework.web.bind.annotation.RequestMapping;
38 * Controller for handling the VNF Package Management. For further information please read:
39 * https://www.etsi.org/deliver/etsi_gs/NFV-SOL/001_099/003/02.05.01_60/gs_nfv-sol003v020501p.pdf Use the section number
40 * above each endpoint to find the corresponding section in the above document.
42 * @author gareth.roper@est.tech
45 @RequestMapping(value = PACKAGE_MANAGEMENT_BASE_URL, consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
46 public class Sol003PackageManagementController {
48 private static final String LOG_REQUEST_RECEIVED = "VNF Package Management Controller: {} {} {} {} {}";
49 private static final Logger logger = getLogger(Sol003PackageManagementController.class);
52 * GET VNF packages information. Direction: VNFM -> VNFM-Adapter. Will return zero or more VNF package
53 * representations that match the attribute filter. These representations will be in a list. Section Number: 10.4.2
55 * @return A List of all VNF packages. Object: List<InlineResponse2001> Response Code: 200 OK
58 @GetMapping(value = "/vnf_packages", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
59 public ResponseEntity<List<InlineResponse2001>> getVnfPackages() {
60 logger.info(LOG_REQUEST_RECEIVED, "getVnfPackages.");
61 return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
65 * GET VNF package information. Direction: VNFM -> VNFM-Adapter. Will return a specific VNF package representation
66 * that match the attribute filter. Section Number: 10.4.3
68 * @param vnfPkgId The ID of the VNF Package that you want to query.
69 * @return A VNF package based on vnfPkgId. Object: VnfPkgInfo Response Code: 200 OK
71 @GetMapping(value = "/vnf_packages/{vnfPkgId}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
72 public ResponseEntity<InlineResponse2001> getVnfPackage(@PathVariable("vnfPkgId") final String vnfPkgId) {
73 logger.info(LOG_REQUEST_RECEIVED, "getVnfPackage: ", vnfPkgId);
74 return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
78 * GET VNFD, from VNF package. Direction: VNFM -> VNFM-Adapter. Will return a copy of the file representing the VNFD
79 * or a ZIP file that contains the file/multiple files representing the VNFD specified. Section Number: 10.4.4
81 * @param vnfPkgId The ID of the VNF Package that you want to retrieve the VNFD from.
82 * @return The VNFD of a VNF Package as a single file or within a ZIP file. Object: byte[] Response Code: 200 OK
84 @GetMapping(value = "/vnf_packages/{vnfPkgId}/vnfd", produces = {MediaType.TEXT_PLAIN, APPLICATION_ZIP})
85 public ResponseEntity<byte[]> getVnfPackageVnfd(@PathVariable("vnfPkgId") final String vnfPkgId) {
86 logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageVnfd: ", vnfPkgId);
87 return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
91 * GET Package Content, from VNF Package. Direction: VNFM -> VNFM-Adapter. Will return a copy of the VNF package
92 * file that you specified. Section Number: 10.4.5
94 * @param vnfPkgId The ID of the VNF Package that you want to retrieve the "package_content" from.
95 * @return The Package Content of a VNF Package. Object: byte[] Response Code: 200 OK
97 @GetMapping(value = "/vnf_packages/{vnfPkgId}/package_content", produces = {APPLICATION_ZIP})
98 public ResponseEntity<byte[]> getVnfPackageContent(@PathVariable("vnfPkgId") final String vnfPkgId) {
99 logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageContent: ", vnfPkgId);
100 return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
104 * GET Artifact, from VNF Package. Direction: VNFM -> VNFM-Adapter. Will return a the content of the artifact that
105 * you specified. Section Number: 10.4.6
107 * @param vnfPkgId The ID of the VNF Package that you want to retrieve an artifact from.
108 * @param artifactPath The path of the artifact that you want to retrieve.
109 * @return An Artifact from a VNF Package. Object: byte[] Response Code: 200 OK
111 @GetMapping(value = "/vnf_packages/{vnfPkgId}/artifacts/{artifactPath}",
112 produces = {MediaType.APPLICATION_OCTET_STREAM})
113 public ResponseEntity<byte[]> getVnfPackageArtifact(@PathVariable("vnfPkgId") final String vnfPkgId,
114 @PathVariable("artifactPath") final String artifactPath) {
115 logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageArtifact: vnfPkgId=", vnfPkgId, " artifactPath=", artifactPath);
116 return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);