2  * ============LICENSE_START=======================================================
 
   3  *  Copyright (C) 2020 Nordix. All rights reserved.
 
   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=========================================================
 
  20 package org.onap.so.etsi.nfvo.ns.lcm.rest;
 
  22 import static org.onap.so.etsi.nfvo.ns.lcm.Constants.HTTP_GLOBAL_CUSTOMER_ID_HTTP_HEADER_PARM_NAME;
 
  23 import static org.onap.so.etsi.nfvo.ns.lcm.Constants.HTTP_SERVICETYPE_HEADER_DEFAULT_VALUE;
 
  24 import static org.onap.so.etsi.nfvo.ns.lcm.Constants.HTTP_SERVICETYPE_HEADER_PARM_NAME;
 
  25 import static org.onap.so.etsi.nfvo.ns.lcm.Constants.NS_LIFE_CYCLE_MANAGEMENT_BASE_URL;
 
  26 import static org.slf4j.LoggerFactory.getLogger;
 
  27 import javax.ws.rs.core.MediaType;
 
  28 import org.onap.so.etsi.nfvo.ns.lcm.model.Body;
 
  29 import org.onap.so.etsi.nfvo.ns.lcm.model.CreateNsRequest;
 
  30 import org.onap.so.etsi.nfvo.ns.lcm.model.InstantiateNsRequest;
 
  31 import org.onap.so.etsi.nfvo.ns.lcm.model.TerminateNsRequest;
 
  32 import org.slf4j.Logger;
 
  33 import org.springframework.http.HttpStatus;
 
  34 import org.springframework.http.ResponseEntity;
 
  35 import org.springframework.stereotype.Controller;
 
  36 import org.springframework.web.bind.annotation.DeleteMapping;
 
  37 import org.springframework.web.bind.annotation.PathVariable;
 
  38 import org.springframework.web.bind.annotation.PostMapping;
 
  39 import org.springframework.web.bind.annotation.RequestBody;
 
  40 import org.springframework.web.bind.annotation.RequestHeader;
 
  41 import org.springframework.web.bind.annotation.RequestMapping;
 
  44  * Controller for handling the NS Lifecycle Management. For further information please read:
 
  45  * https://www.etsi.org/deliver/etsi_gs/NFV-SOL/001_099/005/02.07.01_60/gs_NFV-SOL005v020701p.pdf Use the section number
 
  46  * above each endpoint to find the corresponding section in the above document.
 
  48  * @author Waqas Ikram (waqas.ikram@est.tech)
 
  52 @RequestMapping(value = NS_LIFE_CYCLE_MANAGEMENT_BASE_URL)
 
  53 public class NsLifecycleManagementController {
 
  54     private static final Logger logger = getLogger(NsLifecycleManagementController.class);
 
  58      * The POST method creates new {@link Body new NS instance resource} request. See Section Number: 6.3.1 for more
 
  61      * @param globalCustomerId The global customer ID
 
  62      * @param serviceType The service type
 
  63      * @param createNsRequest create network service request (see clause 6.5.2.9)
 
  64      * @return "201 Created" response containing a representation of the NS instance resource {@link NsInstance} just
 
  65      *         created by the NFVO, and provides the URI of the newly-created resource in the "Location:" HTTP header
 
  67     @PostMapping(value = "/ns_instances", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
 
  68             consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
 
  69     public ResponseEntity<?> createNs(
 
  70             @RequestHeader(value = HTTP_GLOBAL_CUSTOMER_ID_HTTP_HEADER_PARM_NAME,
 
  71                     required = true) final String globalCustomerId,
 
  72             @RequestHeader(value = HTTP_SERVICETYPE_HEADER_PARM_NAME, required = false,
 
  73                     defaultValue = HTTP_SERVICETYPE_HEADER_DEFAULT_VALUE) final String serviceType,
 
  74             @RequestBody final CreateNsRequest createNsRequest) {
 
  75         logger.info("Received Create NS Request: {}\n with globalCustomerId: {}\n serviceType: {}\n", createNsRequest,
 
  76                 globalCustomerId, serviceType);
 
  77         return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).body("Operation is not supported yet");
 
  81      * The DELETE method delete NS instance
 
  83      * @param nsInstanceId Identifier of the NS instance to be deleted.
 
  84      * @return "202 Accepted" response with an empty entity body
 
  86     @DeleteMapping(value = "/ns_instances/{nsInstanceId}",
 
  87             produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
 
  88     public ResponseEntity<?> deleteNs(@PathVariable("nsInstanceId") final String nsInstanceId) {
 
  89         logger.debug("Received delete NS request for nsInstanceId: {}", nsInstanceId);
 
  90         return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).body("Operation is not supported yet");
 
  94      * The POST method instantiate NS instance
 
  96      * @param nsInstanceId Identifier of the NS instance to be instantiated.
 
  97      * @param instantiateNsRequest Instantiate network service request (see clause 6.5.2.11)
 
  98      * @return "202 Accepted" response with an empty entity body and a "Location" HTTP header that points to the new "NS
 
  99      *         Lifecycle Operation Occurrence" resource
 
 101     @PostMapping(value = "/ns_instances/{nsInstanceId}/instantiate",
 
 102             produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
 
 103             consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
 
 104     public ResponseEntity<?> instantiateNs(@PathVariable("nsInstanceId") final String nsInstanceId,
 
 105             @RequestBody final InstantiateNsRequest instantiateNsRequest) {
 
 106         logger.debug("Received instantiate NS request: {}\n with nsInstanceId: {}", instantiateNsRequest, nsInstanceId);
 
 107         return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).body("Operation is not supported yet");
 
 111      * The POST method terminate NS instance
 
 113      * @param nsInstanceId Identifier of the NS instance to be terminated.
 
 114      * @param terminateNsRequest The terminate NS request parameters (see clause 6.5.2.15)
 
 115      * @return "202 Accepted" response with an empty entity body and a "Location" HTTP header that points to the new "NS
 
 116      *         Lifecycle Operation Occurrence" resource
 
 118     @PostMapping(value = "/ns_instances/{nsInstanceId}/terminate",
 
 119             produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
 
 120             consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
 
 121     public ResponseEntity<?> terminateNs(@PathVariable("nsInstanceId") final String nsInstanceId,
 
 122             @RequestBody final TerminateNsRequest terminateNsRequest) {
 
 123         logger.debug("Received terminate NS request: {}\n with nsInstanceId: {}", terminateNsRequest, nsInstanceId);
 
 124         return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).body("Operation is not supported yet");