6fac952aa8f42d624a146cc1b92e1eaddc428f84
[so.git] /
1 /*-
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.adapters.vnfmadapter.rest;
22
23 import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL;
24 import static org.slf4j.LoggerFactory.getLogger;
25 import java.util.List;
26 import javax.ws.rs.core.MediaType;
27 import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002;
28 import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
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.DeleteMapping;
34 import org.springframework.web.bind.annotation.GetMapping;
35 import org.springframework.web.bind.annotation.PathVariable;
36 import org.springframework.web.bind.annotation.PostMapping;
37 import org.springframework.web.bind.annotation.RequestBody;
38 import org.springframework.web.bind.annotation.RequestMapping;
39
40 /**
41  * Controller for handling the Subscription Management. For further information please read:
42  * https://www.etsi.org/deliver/etsi_gs/NFV-SOL/001_099/003/02.05.01_60/gs_nfv-sol003v020501p.pdf Use the section number
43  * above each endpoint to find the corresponding section in the above document.
44  *
45  * @author gareth.roper@est.tech
46  */
47 @Controller
48 @RequestMapping(value = PACKAGE_MANAGEMENT_BASE_URL, produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
49         consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
50 public class Sol003SubscriptionManagementController {
51
52     private static final String LOG_REQUEST_RECEIVED = "Subscription Management Controller: {} {}";
53     private static final Logger logger = getLogger(Sol003SubscriptionManagementController.class);
54
55     /**
56      * POST Subscribe request. Direction: VNFM -> VNFM Adapter. Will send request and respond with the subscription that
57      * you subscribed to, if successful. Section Number: 10.4.7
58      *
59      * @param pkgmSubscriptionRequest This includes the details of the subscription to be created.
60      * @return The subscription requested, if successful. Object: InlineRespone2002 Response Code: 201 Created Response
61      *         Code: 303 Duplicate Subscription
62      */
63     @PostMapping(value = "/subscriptions")
64     public ResponseEntity<InlineResponse2002> postSubscriptionRequest(
65             @RequestBody final PkgmSubscriptionRequest pkgmSubscriptionRequest) {
66         logger.info(LOG_REQUEST_RECEIVED, " postSubscriptionRequest: ", pkgmSubscriptionRequest);
67         return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
68     }
69
70     /**
71      * GET all subscriptions. Direction: VNFM -> VNFM Adapter. Will return a list of all subscriptions currently active.
72      * Section Number: 10.4.7
73      *
74      * @return All of the current active subscriptions. Object: List<InlineResponse2002> Response Code: 200 OK
75      */
76     @GetMapping(value = "/subscriptions")
77     public ResponseEntity<List<InlineResponse2002>> getSubscriptions() {
78         logger.info(LOG_REQUEST_RECEIVED, " getSubscriptions.");
79         return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
80     }
81
82     /**
83      * GET a specific subscription, by subscriptionId. Direction: VNFM -> VNFM Adapter. Section Number: 10.4.8
84      *
85      * @param subscriptionId The ID of the subscription that you wish to retrieve.
86      * @return A subscription based on subscriptionId. Object: InlineResponse2002 Response Code: 200 OK
87      */
88     @GetMapping(value = "/subscriptions/{subscriptionId}")
89     public ResponseEntity<InlineResponse2002> getSubscription(
90             @PathVariable("subscriptionId") final String subscriptionId) {
91         logger.info(LOG_REQUEST_RECEIVED, " Getting Subscription: ", subscriptionId);
92         return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
93     }
94
95     /**
96      * DELETE a specific subscription, by subscriptionId. Direction: VNFM -> VNFM Adapter. Section Number: 10.4.7
97      *
98      * @param subscriptionId The ID of the subscription that you wish to delete.
99      * @return Empty response if successful. Object: Void Response Code: 204 No Content
100      */
101     @DeleteMapping(value = "/subscriptions/{subscriptionId}")
102     public ResponseEntity<Void> deleteSubscription(@PathVariable("subscriptionId") final String subscriptionId) {
103         logger.info(LOG_REQUEST_RECEIVED, " Deleting Subscription: ", subscriptionId);
104         return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
105     }
106
107
108 }