16650d4a3d288d41df2e59775d7a797382b4dccd
[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. Will send request and respond with the subscription that you subscribed to, if
57      * 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. Will return a list of all subscriptions currently active. Section Number: 10.4.7
72      * 
73      * @return All of the current active subscriptions. Object: List<InlineResponse2002> Response Code: 200 OK
74      */
75     @GetMapping(value = "/subscriptions")
76     public ResponseEntity<List<InlineResponse2002>> getSubscriptions() {
77         logger.info(LOG_REQUEST_RECEIVED, " getSubscriptions.");
78         return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
79     }
80
81     /**
82      * GET a specific subscription, by subscriptionId. Section Number: 10.4.8
83      * 
84      * @param subscriptionId The ID of the subscription that you wish to retrieve.
85      * @return A subscription based on subscriptionId. Object: InlineResponse2002 Response Code: 200 OK
86      */
87     @GetMapping(value = "/subscriptions/{subscriptionId}")
88     public ResponseEntity<InlineResponse2002> getSubscription(
89             @PathVariable("subscriptionId") final String subscriptionId) {
90         logger.info(LOG_REQUEST_RECEIVED, " Getting Subscription: ", subscriptionId);
91         return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
92     }
93
94     /**
95      * DELETE a specific subscription, by subscriptionId. Section Number: 10.4.7
96      * 
97      * @param subscriptionId The ID of the subscription that you wish to delete.
98      * @return Empty response if successful. Object: Void Response Code: 204 No Content
99      */
100     @DeleteMapping(value = "/subscriptions/{subscriptionId}")
101     public ResponseEntity<Void> deleteSubscription(@PathVariable("subscriptionId") final String subscriptionId) {
102         logger.info(LOG_REQUEST_RECEIVED, " Deleting Subscription: ", subscriptionId);
103         return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
104     }
105
106
107 }