2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.api.main.rest.provider;
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;
34 public class NodeTemplateProvider extends CommonModelProvider {
37 * Default constructor.
40 public NodeTemplateProvider(PolicyModelsProvider modelsProvider) throws PfModelException {
41 super(modelsProvider);
46 * Retrieves a node template matching specified ID and version.
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
51 * @return the List of node templates
53 * @throws PfModelException the PfModel parsing exception
55 public List<ToscaNodeTemplate> fetchToscaNodeTemplates(final String name, final String version)
56 throws PfModelException {
58 return modelsProvider.getToscaNodeTemplate(name, version);
63 * Creates one or more new node templates.
65 * @param serviceTemplate service template containing node template definitions
67 * @return the ToscaServiceTemplate object
69 * @throws PfModelException the PfModel parsing exception
71 public ToscaServiceTemplate createNodeTemplates(ToscaServiceTemplate serviceTemplate)
72 throws PfModelException {
74 return modelsProvider.createToscaNodeTemplates(serviceTemplate);
79 * Update one or more node templates.
81 * @param serviceTemplate service template with updated node templates
82 * @return the ToscaServiceTemplate object
84 * @throws PfModelException the PfModel parsing exception
86 public ToscaServiceTemplate updateToscaNodeTemplates(ToscaServiceTemplate serviceTemplate)
87 throws PfModelException {
89 return modelsProvider.updateToscaNodeTemplates(serviceTemplate);
94 * Deletes the node template matching specified ID and version.
96 * @param name the name of the node template
97 * @param version the version of the node template
99 * @return the ToscaServiceTemplate object
101 * @throws PfModelException the PfModel parsing exception
103 public ToscaServiceTemplate deleteToscaNodeTemplate(String name, String version)
104 throws PfModelException {
106 return modelsProvider.deleteToscaNodeTemplate(name, version);