checkstyle: enable JavadocParagraph
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronSecurityRule.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 package org.opendaylight.neutron.spi;
10
11 import java.io.Serializable;
12 import java.util.List;
13 import javax.xml.bind.annotation.XmlAccessType;
14 import javax.xml.bind.annotation.XmlAccessorType;
15 import javax.xml.bind.annotation.XmlElement;
16 import javax.xml.bind.annotation.XmlRootElement;
17
18 /**
19  * See OpenStack Network API v2.0 Reference for description of
20  * annotated attributes. The current fields are as follows:
21  *
22  * <p>
23  * id                uuid (String) UUID for the security group rule.
24  * direction         String Direction the VM traffic  (ingress/egress).
25  * security_group_id The security group to associate rule with.
26  * protocol          String IP Protocol (icmp, tcp, udp, etc) or uint8.
27  * port_range_min    Integer Port at start of range
28  * port_range_max    Integer Port at end of range
29  * ethertype         String ethertype in L2 packet (IPv4, IPv6, etc)
30  * remote_ip_prefix  String (IP cidr) CIDR for address range.
31  * remote_group_id   uuid-str Source security group to apply to rule.
32  * tenant_id         uuid-str Owner of security rule. Admin only outside tenant.
33  */
34
35 @XmlRootElement
36 @XmlAccessorType(XmlAccessType.NONE)
37 public final class NeutronSecurityRule extends NeutronObject<NeutronSecurityRule>
38         implements Serializable, INeutronObject<NeutronSecurityRule> {
39     private static final long serialVersionUID = 1L;
40
41     @XmlElement(name = "direction")
42     String securityRuleDirection;
43
44     @XmlElement(name = "protocol")
45     String securityRuleProtocol;
46
47     @XmlElement(name = "port_range_min")
48     Integer securityRulePortMin;
49
50     @XmlElement(name = "port_range_max")
51     Integer securityRulePortMax;
52
53     @XmlElement(name = "ethertype")
54     String securityRuleEthertype;
55
56     @XmlElement(name = "remote_ip_prefix")
57     String securityRuleRemoteIpPrefix;
58
59     @XmlElement(name = "remote_group_id")
60     String securityRemoteGroupID;
61
62     @XmlElement(name = "security_group_id")
63     String securityRuleGroupID;
64
65     public NeutronSecurityRule() {
66     }
67
68     public String getSecurityRuleDirection() {
69         return securityRuleDirection;
70     }
71
72     public void setSecurityRuleDirection(String securityRuleDirection) {
73         this.securityRuleDirection = securityRuleDirection;
74     }
75
76     public String getSecurityRuleProtocol() {
77         return securityRuleProtocol;
78     }
79
80     public void setSecurityRuleProtocol(String securityRuleProtocol) {
81         this.securityRuleProtocol = securityRuleProtocol;
82     }
83
84     public Integer getSecurityRulePortMin() {
85         return securityRulePortMin;
86     }
87
88     public void setSecurityRulePortMin(Integer securityRulePortMin) {
89         this.securityRulePortMin = securityRulePortMin;
90     }
91
92     public Integer getSecurityRulePortMax() {
93         return securityRulePortMax;
94     }
95
96     public void setSecurityRulePortMax(Integer securityRulePortMax) {
97         this.securityRulePortMax = securityRulePortMax;
98     }
99
100     public String getSecurityRuleEthertype() {
101         return securityRuleEthertype;
102     }
103
104     public void setSecurityRuleEthertype(String securityRuleEthertype) {
105         this.securityRuleEthertype = securityRuleEthertype;
106     }
107
108     public String getSecurityRuleRemoteIpPrefix() {
109         return securityRuleRemoteIpPrefix;
110     }
111
112     public void setSecurityRuleRemoteIpPrefix(String securityRuleRemoteIpPrefix) {
113         this.securityRuleRemoteIpPrefix = securityRuleRemoteIpPrefix;
114     }
115
116     public String getSecurityRemoteGroupID() {
117         return securityRemoteGroupID;
118     }
119
120     public void setSecurityRemoteGroupID(String securityRemoteGroupID) {
121         this.securityRemoteGroupID = securityRemoteGroupID;
122     }
123
124     public String getSecurityRuleGroupID() {
125         return securityRuleGroupID;
126     }
127
128     public void setSecurityRuleGroupID(String securityRuleGroupID) {
129         this.securityRuleGroupID = securityRuleGroupID;
130     }
131
132     public NeutronSecurityRule extractFields(List<String> fields) {
133         NeutronSecurityRule ans = new NeutronSecurityRule();
134         for (String s : fields) {
135             extractField(s, ans);
136             if (s.equals("direction")) {
137                 ans.setSecurityRuleDirection(this.getSecurityRuleDirection());
138             }
139             if (s.equals("protocol")) {
140                 ans.setSecurityRuleProtocol(this.getSecurityRuleProtocol());
141             }
142             if (s.equals("port_range_min")) {
143                 ans.setSecurityRulePortMin(this.getSecurityRulePortMin());
144             }
145             if (s.equals("port_range_max")) {
146                 ans.setSecurityRulePortMax(this.getSecurityRulePortMax());
147             }
148             if (s.equals("ethertype")) {
149                 ans.setSecurityRuleEthertype(this.getSecurityRuleEthertype());
150             }
151             if (s.equals("remote_ip_prefix")) {
152                 ans.setSecurityRuleRemoteIpPrefix(this.getSecurityRuleRemoteIpPrefix());
153             }
154             if (s.equals("remote_group_id")) {
155                 ans.setSecurityRemoteGroupID(this.getSecurityRemoteGroupID());
156             }
157             if (s.equals("security_group_id")) {
158                 ans.setSecurityRuleGroupID(this.getSecurityRuleGroupID());
159             }
160         }
161         return ans;
162     }
163
164     @Override
165     public String toString() {
166         return "NeutronSecurityRule{" + "securityRuleUUID='" + uuid + '\'' + ", securityRuleDirection='"
167                 + securityRuleDirection + '\'' + ", securityRuleProtocol='" + securityRuleProtocol + '\''
168                 + ", securityRulePortMin=" + securityRulePortMin + ", securityRulePortMax=" + securityRulePortMax
169                 + ", securityRuleEthertype='" + securityRuleEthertype + '\'' + ", securityRuleRemoteIpPrefix='"
170                 + securityRuleRemoteIpPrefix + '\'' + ", securityRemoteGroupID=" + securityRemoteGroupID
171                 + ", securityRuleGroupID='" + securityRuleGroupID + '\'' + ", securityRuleTenantID='" + tenantID + '\''
172                 + '}';
173     }
174
175     @Override
176     public void initDefaults() {
177         //TODO verify no defaults values are nessecary required.
178     }
179 }