All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.huawei.openstack4j.openstack.networking.domain.ext.NeutronFirewallRule Maven / Gradle / Ivy

There is a newer version: 1.0.26
Show newest version
/*******************************************************************************
 * 	Copyright 2016 ContainX and OpenStack4j                                          
 * 	                                                                                 
 * 	Licensed under the Apache License, Version 2.0 (the "License"); you may not      
 * 	use this file except in compliance with the License. You may obtain a copy of    
 * 	the License at                                                                   
 * 	                                                                                 
 * 	    http://www.apache.org/licenses/LICENSE-2.0                                   
 * 	                                                                                 
 * 	Unless required by applicable law or agreed to in writing, software              
 * 	distributed under the License is distributed on an "AS IS" BASIS, WITHOUT        
 * 	WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the         
 * 	License for the specific language governing permissions and limitations under    
 * 	the License.                                                                     
 *******************************************************************************/
package com.huawei.openstack4j.openstack.networking.domain.ext;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.annotation.JsonValue;
import com.huawei.openstack4j.model.network.IPVersionType;
import com.huawei.openstack4j.model.network.ext.FirewallRule;
import com.huawei.openstack4j.model.network.ext.builder.FirewallRuleBuilder;
import com.huawei.openstack4j.openstack.common.ListResult;

import com.google.common.base.MoreObjects;

/**
 * A Neutron Firewall (FwaaS) : Firewall Rule Entity.
 *
 * @author Vishvesh Deshmukh
 */
@JsonRootName("firewall_rule")
@JsonIgnoreProperties(ignoreUnknown = true)
public class NeutronFirewallRule implements FirewallRule {

	private static final long serialVersionUID = 1L;

	/**
	 * 

Action of a Neutron (Firewall Rule - FwaaS) entity.

* *

Indicates whether firewall rule resource has action ALLOW/DENY.

* * @author Vishvesh Deshmukh */ public enum FirewallRuleAction { ALLOW, DENY, UNRECOGNIZED; @JsonCreator public static FirewallRuleAction value(String v) { if (v == null) return UNRECOGNIZED; try { return valueOf(v.toUpperCase()); } catch (IllegalArgumentException e) { return UNRECOGNIZED; } } @JsonValue public String value() { return name().toLowerCase(); } } /** *

IPProtocolType of a Neutron (Firewall Rule - FwaaS) entity.

* *

Represents an IPProtocolType of a Neutron (Firewall Rule - FwaaS) entity.

* * @author Vishvesh Deshmukh */ public enum IPProtocol { TCP, UDP, ICMP, UNRECOGNIZED; @JsonCreator public static IPProtocol value(String v) { if (v == null) return UNRECOGNIZED; try { return valueOf(v.toUpperCase()); } catch (IllegalArgumentException e) { return UNRECOGNIZED; } } @JsonValue public String value() { return name().toLowerCase(); } } private String id; private String name; @JsonProperty("tenant_id") private String tenantId; private String description; private Boolean enabled; private Boolean shared; @JsonProperty("firewall_policy_id") private String policyId; private FirewallRuleAction action; @JsonProperty("source_ip_address") private String sourceIpAddress; @JsonProperty("destination_ip_address") private String destinationIpAddress; private Integer position; private IPProtocol protocol; @JsonProperty("ip_version") private IPVersionType ipVersion; @JsonProperty("source_port") private String sourcePort; @JsonProperty("destination_port") private String destinationPort; /** * Wrap this FirewallRule to a builder * @return FirewallRuleBuilder */ @Override public FirewallRuleBuilder toBuilder() { return new FirewallRuleConcreteBuilder(this); } /** * @return FirewallRuleBuilder */ public static FirewallRuleBuilder builder() { return new FirewallRuleConcreteBuilder(); } @Override public String getId() { return id; } @Override public String getName() { return name; } @Override public String getTenantId() { return tenantId; } @Override public String getDescription() { return description; } @Override public Boolean isShared() { return shared != null && shared; } @Override public String getPolicy() { return policyId; } @Override public IPProtocol getProtocol() { return protocol; } @Override public IPVersionType getIpVersion() { return ipVersion; } @Override public String getSourceIpAddress() { return sourceIpAddress; } @Override public String getDestinationIpAddress() { return destinationIpAddress; } @Override public String getSourcePort() { return sourcePort; } @Override public String getDestinationPort() { return destinationPort; } @Override public Integer getPosition() { return position; } @Override public FirewallRuleAction getAction() { return action; } @Override public Boolean isEnabled() { return enabled != null && enabled; } @Override public String toString() { return MoreObjects.toStringHelper(this).omitNullValues() .add("id", id).add("name", name).add("position", position) .add("action", action).add("ipVersion", ipVersion) .add("policyId", policyId).add("enabled", enabled) .add("shared", shared).add("tenantId", tenantId) .add("sourceIpAddress", sourceIpAddress) .add("destinationIpAddress", destinationIpAddress) .add("sourcePort", sourcePort).add("destinationPort", destinationPort) .add("description", description).add("protocol", protocol) .toString(); } public static class FirewallRules extends ListResult { private static final long serialVersionUID = 1L; @JsonProperty("firewall_rules") List firewallRules; @Override public List value() { return firewallRules; } @Override public String toString() { return MoreObjects.toStringHelper(this).omitNullValues() .add("firewall_rules", firewallRules).toString(); } } public static class FirewallRuleConcreteBuilder implements FirewallRuleBuilder { NeutronFirewallRule f; @Override public FirewallRule build() { return f; } public FirewallRuleConcreteBuilder() { this(new NeutronFirewallRule()); } public FirewallRuleConcreteBuilder(NeutronFirewallRule f){ this.f = f; } @Override public FirewallRuleBuilder from(FirewallRule in) { this.f = (NeutronFirewallRule) in; return this; } @Override public FirewallRuleBuilder tenantId(String tenantId) { f.tenantId = tenantId; return this; } @Override public FirewallRuleBuilder name(String name) { f.name = name; return this; } @Override public FirewallRuleBuilder description(String description) { f.description = description; return this; } @Override public FirewallRuleBuilder shared(Boolean shared) { f.shared = shared; return this; } @Override public FirewallRuleBuilder protocol(IPProtocol protocol) { f.protocol = protocol; return this; } @Override public FirewallRuleBuilder ipVersion(IPVersionType ipVersion) { f.ipVersion = ipVersion; return this; } @Override public FirewallRuleBuilder sourceIpAddress(String sourceIpAddress) { f.sourceIpAddress = sourceIpAddress; return this; } @Override public FirewallRuleBuilder destinationIpAddress(String destinationIpAddress) { f.destinationIpAddress = destinationIpAddress; return this; } @Override public FirewallRuleBuilder sourcePort(String sourcePort) { f.sourcePort = sourcePort; return this; } @Override public FirewallRuleBuilder destinationPort(String destinationPort) { f.destinationPort = destinationPort; return this; } @Override public FirewallRuleBuilder action(FirewallRuleAction action) { f.action = action; return this; } @Override public FirewallRuleBuilder enabled(Boolean enabled) { f.enabled = enabled; return this; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy