cleaner way to handle swagger serialization issue
[policy/api.git] / main / src / main / java / org / onap / policy / api / main / rest / provider / NodeTemplateProvider.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy API
4  * ================================================================================
5  * Copyright (C) 2022 Nordix Foundation. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * SPDX-License-Identifier: Apache-2.0
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.api.main.rest.provider;
24
25 import java.util.List;
26 import org.onap.policy.models.base.PfModelException;
27 import org.onap.policy.models.provider.PolicyModelsProvider;
28 import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
29 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.stereotype.Service;
32
33 @Service
34 public class NodeTemplateProvider extends CommonModelProvider {
35
36     /**
37      * Default constructor.
38      */
39     @Autowired
40     public NodeTemplateProvider(PolicyModelsProvider modelsProvider) throws PfModelException {
41         super(modelsProvider);
42     }
43
44
45     /**
46      * Retrieves a node template matching specified ID and version.
47      *
48      * @param name the name of the node template, null to return all entries
49      * @param version the version of node template, null to return all entries
50      *
51      * @return the List of node templates
52      *
53      * @throws PfModelException the PfModel parsing exception
54      */
55     public List<ToscaNodeTemplate> fetchToscaNodeTemplates(final String name, final String version)
56         throws PfModelException {
57
58         return modelsProvider.getToscaNodeTemplate(name, version);
59     }
60
61
62     /**
63      * Creates one or more new node templates.
64      *
65      * @param serviceTemplate service template containing node template definitions
66      *
67      * @return the ToscaServiceTemplate object
68      *
69      * @throws PfModelException the PfModel parsing exception
70      */
71     public ToscaServiceTemplate createNodeTemplates(ToscaServiceTemplate serviceTemplate)
72         throws PfModelException {
73
74         return modelsProvider.createToscaNodeTemplates(serviceTemplate);
75     }
76
77
78     /**
79      * Update one or more node templates.
80      *
81      * @param serviceTemplate service template with updated node templates
82      * @return the ToscaServiceTemplate object
83      *
84      * @throws PfModelException the PfModel parsing exception
85      */
86     public ToscaServiceTemplate updateToscaNodeTemplates(ToscaServiceTemplate serviceTemplate)
87         throws PfModelException {
88
89         return modelsProvider.updateToscaNodeTemplates(serviceTemplate);
90     }
91
92
93     /**
94      * Deletes the node template matching specified ID and version.
95      *
96      * @param name the name of the node template
97      * @param version the version of the node template
98      *
99      * @return the ToscaServiceTemplate object
100      *
101      * @throws PfModelException the PfModel parsing exception
102      */
103     public ToscaServiceTemplate deleteToscaNodeTemplate(String name, String version)
104         throws PfModelException {
105
106         return modelsProvider.deleteToscaNodeTemplate(name, version);
107     }
108
109
110 }