Merge "Musings towards making dummyprovider accessible"
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronSecurityGroup.java
1 /*
2  * Copyright (C) 2014 Red Hat, Inc.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  *
8  */
9
10 package org.opendaylight.neutron.spi;
11
12 import java.io.Serializable;
13 import java.util.ArrayList;
14 import java.util.Iterator;
15 import java.util.List;
16
17 import javax.xml.bind.annotation.XmlAccessType;
18 import javax.xml.bind.annotation.XmlAccessorType;
19 import javax.xml.bind.annotation.XmlElement;
20 import javax.xml.bind.annotation.XmlRootElement;
21
22 /**
23  * OpenStack Neutron v2.0 Security Group bindings.
24  * See OpenStack Network API v2.0 Reference for description of
25  * annotated attributes. The current fields are as follows:
26  * <p/>
27  * id                   uuid-str unique ID for the security group.
28  * name                 String name of the security group.
29  * description          String name of the security group.
30  * tenant_id            uuid-str Owner of security rule..
31  * security_group_rules List<NeutronSecurityRule> nested RO in the sec group.
32  */
33
34 @XmlRootElement
35 @XmlAccessorType(XmlAccessType.NONE)
36
37 public class NeutronSecurityGroup implements Serializable {
38     private static final long serialVersionUID = 1L;
39
40     @XmlElement(name = "id")
41     String securityGroupUUID;
42
43     @XmlElement(name = "name")
44     String securityGroupName;
45
46     @XmlElement(name = "description")
47     String securityGroupDescription;
48
49     @XmlElement(name = "tenant_id")
50     String securityGroupTenantID;
51
52     @XmlElement(name = "security_group_rules")
53     List<NeutronSecurityRule> neutronSecurityRule;
54
55     List<NeutronPort> neutronPorts;
56
57     public NeutronSecurityGroup() {
58         neutronPorts = new ArrayList<NeutronPort> ();
59         List<NeutronSecurityRule> securityRules;
60
61     }
62
63     public String getSecurityGroupUUID() {
64         return securityGroupUUID;
65     }
66
67     public void setSecurityGroupUUID(String securityGroupUUID) {
68         this.securityGroupUUID = securityGroupUUID;
69     }
70
71     public String getSecurityGroupName() {
72         return securityGroupName;
73     }
74
75     public void setSecurityGroupName(String securityGroupName) {
76         this.securityGroupName = securityGroupName;
77     }
78
79     public String getSecurityGroupDescription() {
80         return securityGroupDescription;
81     }
82
83     public void setSecurityGroupDescription(String securityGroupDescription) {
84         this.securityGroupDescription = securityGroupDescription;
85     }
86
87     public String getSecurityGroupTenantID() {
88         return securityGroupTenantID;
89     }
90
91     public void setSecurityGroupTenantID(String securityGroupTenantID) {
92         this.securityGroupTenantID = securityGroupTenantID;
93     }
94
95     // Rules In Group
96     public List<NeutronSecurityRule> getSecurityRules() {
97         return neutronSecurityRule;
98     }
99
100     public void setSecurityRules(List<NeutronSecurityRule> neutronSecurityRule) {
101         this.neutronSecurityRule = neutronSecurityRule;
102     }
103
104     public NeutronSecurityGroup extractFields(List<String> fields) {
105         NeutronSecurityGroup ans = new NeutronSecurityGroup ();
106         Iterator<String> i = fields.iterator ();
107         while (i.hasNext ()) {
108             String s = i.next ();
109             if (s.equals ("id")) {
110                 ans.setSecurityGroupUUID (this.getSecurityGroupUUID ());
111             }
112             if (s.equals ("name")) {
113                 ans.setSecurityGroupName (this.getSecurityGroupName ());
114             }
115             if (s.equals ("description")) {
116                 ans.setSecurityGroupDescription (this.getSecurityGroupDescription ());
117             }
118             if (s.equals ("tenant_id")) {
119                 ans.setSecurityGroupTenantID (this.getSecurityGroupTenantID ());
120             }
121             if (s.equals ("security_group_rules")) {
122                 ans.setSecurityRules (this.getSecurityRules ());
123             }
124         }
125         return ans;
126     }
127
128     @Override
129     public String toString() {
130         return "NeutronSecurityGroup{" +
131                 "securityGroupUUID='" + securityGroupUUID + '\'' +
132                 ", securityGroupName='" + securityGroupName + '\'' +
133                 ", securityGroupDescription='" + securityGroupDescription + '\'' +
134                 ", securityGroupTenantID='" + securityGroupTenantID + '\'' +
135                 ", securityRules=" + neutronSecurityRule + "]";
136     }
137
138     public void initDefaults() {
139         //TODO verify no defaults values are nessecary required.
140     }
141 }