blob: 6f87a2ab079b8959614e957342dc4ce505e6afbc [file] [log] [blame]
sangho6a9ff0d2017-03-27 11:23:37 +09001/*
2 * Copyright 2017-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.openstacknetworking.api;
17
18import org.onosproject.event.AbstractEvent;
19import org.openstack4j.model.network.SecurityGroup;
20import org.openstack4j.model.network.SecurityGroupRule;
21
22/**
23 * Describes OpenStack security group event.
24 */
25public class OpenstackSecurityGroupEvent
26 extends AbstractEvent<OpenstackSecurityGroupEvent.Type, SecurityGroup> {
27
28 private SecurityGroupRule sgRule;
29
30 public enum Type {
31 /**
32 * Signifies that a new OpenStack security group is created.
33 */
34 OPENSTACK_SECURITY_GROUP_CREATED,
35
36 /**
37 * Signifies that the OpenStack security group is removed.
38 */
39 OPENSTACK_SECURITY_GROUP_REMOVED,
40
41 /**
42 * Signifies that a new OpenStack security group rule is created.
43 */
44 OPENSTACK_SECURITY_GROUP_RULE_CREATED,
45
46 /**
47 * Signifies that the OpenStack security group rule is removed.
48 */
49 OPENSTACK_SECURITY_GROUP_RULE_REMOVED,
50 }
51
52 /**
53 * SecurityGroupEvent constructor.
54 *
55 * @param type SecurityGroupEvent type
56 * @param sg SecurityGroup object
57 */
58 public OpenstackSecurityGroupEvent(OpenstackSecurityGroupEvent.Type type, SecurityGroup sg) {
59 super(type, sg);
60 }
61
62 /**
63 * SecurityGroupEvent constructor.
64 *
65 * @param type SecurityGroupEvent type
66 * @param sgRule SecurityGroup object
67 */
68 public OpenstackSecurityGroupEvent(OpenstackSecurityGroupEvent.Type type, SecurityGroupRule sgRule) {
69 super(type, null);
70 this.sgRule = sgRule;
71 }
72
73 /**
74 * Returns security group rule.
75 *
76 * @return SecurityGroupRule
77 */
78 public SecurityGroupRule securityGroupRule() {
79 return this.sgRule;
80 }
81}