2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. 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.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.heat.datatypes.model;
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
27 import java.util.Objects;
30 * The enum Heat resources types.
32 public enum HeatResourcesTypes {
34 * Nova server resource type heat resources types.
36 NOVA_SERVER_RESOURCE_TYPE("OS::Nova::Server"),
38 * Nova server group resource type heat resources types.
40 NOVA_SERVER_GROUP_RESOURCE_TYPE("OS::Nova::ServerGroup"),
42 * Neutron port resource type heat resources types.
44 NEUTRON_PORT_RESOURCE_TYPE("OS::Neutron::Port"),
46 * Contrail network rule resource type heat resources types.
48 CONTRAIL_NETWORK_RULE_RESOURCE_TYPE("OS::Contrail::NetworkPolicy"),
50 * Contrail network attach rule resource type heat resources types.
52 CONTRAIL_NETWORK_ATTACH_RULE_RESOURCE_TYPE("OS::Contrail::AttachPolicy"),
54 * Contrail virtual network resource type heat resources types.
56 CONTRAIL_VIRTUAL_NETWORK_RESOURCE_TYPE("OS::Contrail::VirtualNetwork"),
58 * Cinder volume resource type heat resources types.
60 CINDER_VOLUME_RESOURCE_TYPE("OS::Cinder::Volume"),
62 * Cinder volume attachment resource type heat resources types.
64 CINDER_VOLUME_ATTACHMENT_RESOURCE_TYPE("OS::Cinder::VolumeAttachment"),
66 * Neutron net resource type heat resources types.
68 NEUTRON_NET_RESOURCE_TYPE("OS::Neutron::Net"),
70 * Neutron subnet resource type heat resources types.
72 NEUTRON_SUBNET_RESOURCE_TYPE("OS::Neutron::Subnet"),
74 * Neutron security group resource type heat resources types.
76 NEUTRON_SECURITY_GROUP_RESOURCE_TYPE("OS::Neutron::SecurityGroup"),
78 * Heat software config type heat resources types.
80 HEAT_SOFTWARE_CONFIG_TYPE("OS::Heat::SoftwareConfig"),
82 * Heat cloud config type heat resources types.
84 HEAT_CLOUD_CONFIG_TYPE("OS::Heat::CloudConfig"),
86 * Heat multipart mime type heat resources types.
88 HEAT_MULTIPART_MIME_TYPE("OS::Heat::MultipartMime"),
90 * Heat contrail network ipam type heat resources types.
92 HEAT_CONTRAIL_NETWORK_IPAM_TYPE("OS::Contrail::NetworkIpam"),
94 * Contrail v 2 virtual network resource type heat resources types.
96 CONTRAIL_V2_VIRTUAL_NETWORK_RESOURCE_TYPE("OS::ContrailV2::VirtualNetwork"),
98 * Contrail v 2 virtual machine interface resource type heat resources types.
100 CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE("OS::ContrailV2::VirtualMachineInterface"),
102 * Contrail service template heat resources types.
104 CONTRAIL_SERVICE_TEMPLATE("OS::Contrail::ServiceTemplate"),
106 * Contrail service instance heat resources types.
108 CONTRAIL_SERVICE_INSTANCE("OS::Contrail::ServiceInstance"),
110 * Contrail v 2 network rule resource type heat resources types.
112 CONTRAIL_V2_NETWORK_RULE_RESOURCE_TYPE("OS::ContrailV2::NetworkPolicy"),
114 * Resource group resource type heat resources types.
116 RESOURCE_GROUP_RESOURCE_TYPE("OS::Heat::ResourceGroup");
118 private static Map<String, HeatResourcesTypes> stringToHeatResourceTypeMap;
121 stringToHeatResourceTypeMap = new HashMap<>();
123 for (HeatResourcesTypes type : HeatResourcesTypes.values()) {
124 stringToHeatResourceTypeMap.put(type.heatResource, type);
128 private String heatResource;
131 HeatResourcesTypes(String heatResource) {
132 this.heatResource = heatResource;
136 * Find by heat resource heat resources types.
138 * @param heatResource the heat resource
139 * @return the heat resources types
141 public static HeatResourcesTypes findByHeatResource(String heatResource) {
142 return stringToHeatResourceTypeMap.get(heatResource);
146 * Is resource type valid boolean.
148 * @param resourceType the resource type
149 * @return the boolean
151 public static boolean isResourceTypeValid(String resourceType) {
152 return Objects.nonNull(findByHeatResource(resourceType));
156 * Is resource expected to be exposed boolean.
158 * @param resourceType the resource type
159 * @return the boolean
161 public static boolean isResourceExpectedToBeExposed(String resourceType) {
162 return (resourceType.equals(NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource())
163 || resourceType.equals(CONTRAIL_VIRTUAL_NETWORK_RESOURCE_TYPE.getHeatResource())
164 || resourceType.equals(NEUTRON_NET_RESOURCE_TYPE.getHeatResource())
165 || resourceType.equals(CINDER_VOLUME_RESOURCE_TYPE.getHeatResource())
166 || resourceType.equals(NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource())
171 * Gets list for resource type.
173 * @param types the types
174 * @return the list for resource type
176 public static Map<HeatResourcesTypes, List<String>> getListForResourceType(
177 HeatResourcesTypes... types) {
178 Map<HeatResourcesTypes, List<String>> result = new HashMap<>();
180 for (HeatResourcesTypes type : types) {
181 result.put(type, new ArrayList<>());
188 * Gets heat resource.
190 * @return the heat resource
192 public String getHeatResource() {
198 * Sets heat resource.
200 * @param heatResource the heat resource
202 public void setHeatResource(String heatResource) {
203 this.heatResource = heatResource;