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;
29 public enum HeatResourcesTypes {
30 NOVA_SERVER_RESOURCE_TYPE("OS::Nova::Server"),
31 NOVA_SERVER_GROUP_RESOURCE_TYPE("OS::Nova::ServerGroup"),
32 NEUTRON_PORT_RESOURCE_TYPE("OS::Neutron::Port"),
33 CONTRAIL_NETWORK_RULE_RESOURCE_TYPE("OS::Contrail::NetworkPolicy"),
34 CONTRAIL_NETWORK_ATTACH_RULE_RESOURCE_TYPE("OS::Contrail::AttachPolicy"),
35 CONTRAIL_VIRTUAL_NETWORK_RESOURCE_TYPE("OS::Contrail::VirtualNetwork"),
36 CINDER_VOLUME_RESOURCE_TYPE("OS::Cinder::Volume"),
37 CINDER_VOLUME_ATTACHMENT_RESOURCE_TYPE("OS::Cinder::VolumeAttachment"),
38 NEUTRON_NET_RESOURCE_TYPE("OS::Neutron::Net"),
39 NEUTRON_SUBNET_RESOURCE_TYPE("OS::Neutron::Subnet"),
40 NEUTRON_SECURITY_GROUP_RESOURCE_TYPE("OS::Neutron::SecurityGroup"),
41 HEAT_SOFTWARE_CONFIG_TYPE("OS::Heat::SoftwareConfig"),
42 HEAT_CLOUD_CONFIG_TYPE("OS::Heat::CloudConfig"),
43 HEAT_MULTIPART_MIME_TYPE("OS::Heat::MultipartMime"),
44 HEAT_CONTRAIL_NETWORK_IPAM_TYPE("OS::Contrail::NetworkIpam"),
45 CONTRAIL_V2_VIRTUAL_NETWORK_RESOURCE_TYPE("OS::ContrailV2::VirtualNetwork"),
46 CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE("OS::ContrailV2::VirtualMachineInterface"),
47 CONTRAIL_SERVICE_TEMPLATE("OS::Contrail::ServiceTemplate"),
48 CONTRAIL_SERVICE_INSTANCE("OS::Contrail::ServiceInstance"),
49 CONTRAIL_V2_NETWORK_RULE_RESOURCE_TYPE("OS::ContrailV2::NetworkPolicy"),
50 RESOURCE_GROUP_RESOURCE_TYPE("OS::Heat::ResourceGroup");
52 private static Map<String, HeatResourcesTypes> stringToHeatResourceTypeMap;
55 stringToHeatResourceTypeMap = new HashMap<>();
57 for (HeatResourcesTypes type : HeatResourcesTypes.values()) {
58 stringToHeatResourceTypeMap.put(type.heatResource, type);
62 private String heatResource;
65 HeatResourcesTypes(String heatResource) {
66 this.heatResource = heatResource;
69 public static HeatResourcesTypes findByHeatResource(String heatResource) {
70 return stringToHeatResourceTypeMap.get(heatResource);
73 public static boolean isResourceTypeValid(String resourceType) {
74 return Objects.nonNull(findByHeatResource(resourceType));
78 * Is resource expected to be exposed boolean.
80 * @param resourceType the resource type
83 public static boolean isResourceExpectedToBeExposed(String resourceType) {
85 return (resourceType.equals(NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource())
86 || resourceType.equals(CONTRAIL_VIRTUAL_NETWORK_RESOURCE_TYPE.getHeatResource())
87 || resourceType.equals(NEUTRON_NET_RESOURCE_TYPE.getHeatResource())
88 || resourceType.equals(CINDER_VOLUME_RESOURCE_TYPE.getHeatResource())
89 || resourceType.equals(NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource())
94 * Gets list for resource type.
96 * @param types the types
97 * @return the list for resource type
99 public static Map<HeatResourcesTypes, List<String>> getListForResourceType(
100 HeatResourcesTypes... types) {
101 Map<HeatResourcesTypes, List<String>> result = new HashMap<>();
103 for (HeatResourcesTypes type : types) {
104 result.put(type, new ArrayList<>());
110 public String getHeatResource() {
115 public void setHeatResource(String heatResource) {
116 this.heatResource = heatResource;