http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Port.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Port.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Port.java new file mode 100644 index 0000000..a9ab61e --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Port.java @@ -0,0 +1,763 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.openstack.neutron.v2.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.beans.ConstructorProperties; + +import javax.inject.Named; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; + +/** + * A Neutron port + * + * @see <a + * href="http://docs.openstack.org/api/openstack-network/1.0/content/Ports.html">api + * doc</a> + */ +public class Port { + + private String id; + private NetworkStatus status; + + // Extensions + + // portbindings.py + // The service will return the vif type for the specific port. + @Named("binding:vif_type") + private VIFType vifType; + // The service may return a dictionary containing additional + // information needed by the interface driver. The set of items + // returned may depend on the value of VIF_TYPE. + @Named("binding:vif_details") + private ImmutableMap<String, Object> vifDetails; + + // Plugins + + // qos.py + @Named("queue_id") + private String qosQueueId; + + private String name; + @Named("network_id") + private String networkId; + @Named("admin_state_up") + private Boolean adminStateUp; + @Named("mac_address") + private String macAddress; + @Named("fixed_ips") + private ImmutableSet<IP> fixedIps; + @Named("device_id") + private String deviceId; + @Named("device_owner") + private String deviceOwner; + @Named("tenant_id") + private String tenantId; + @Named("security_groups") + private ImmutableSet<String> securityGroups; + + // Extensions + + // allowedaddresspairs.py + @Named("allowed_address_pairs") + private ImmutableSet<AddressPair> allowedAddressPairs; + + // extra_dhcp_opt.py + @Named("extra_dhcp_opts") + private ImmutableSet<ExtraDhcpOption> extraDhcpOptions; + + // portbindings.py + // The type of vnic that this port should be attached to + @Named("binding:vnic_type") + private VNICType vnicType; + // In some cases different implementations may be run on different hosts. + // The host on which the port will be allocated. + @Named("binding:host_id") + private String hostId; + // The profile will be a dictionary that enables the application running + // on the specific host to pass and receive vif port specific information to + // the plugin. + @Named("binding:profile") + private ImmutableMap<String, Object> profile; + + // portsecurity.py + @Named("port_security_enabled") + private Boolean portSecurity; + + // Plugins + + // n1kv.py + @Named("n1kv:profile_id") + private String profileId; + + // maclearning.py + @Named("mac_learning_enabled") + private Boolean macLearning; + + // qos.py + @Named("rxtx_factor") + private Integer qosRxtxFactor; + + @ConstructorProperties({"id", "status", "binding:vif_type", "binding:vif_details", "queue_id", "name", "network_id", + "admin_state_up", "mac_address", "fixed_ips", "device_id", "device_owner", "tenant_id", "security_groups", + "allowed_address_pairs", "extra_dhcp_opts", "binding:vnic_type", "binding:host_id", "binding:profile", + "port_security_enabled", "n1kv:profile_id", "mac_learning_enabled", "rxtx_factor"}) + protected Port(String id, NetworkStatus status, VIFType vifType, ImmutableMap<String, Object> vifDetails, String qosQueueId, + String name, String networkId, Boolean adminStateUp, String macAddress, ImmutableSet<IP> fixedIps, String deviceId, + String deviceOwner, String tenantId, ImmutableSet<String> securityGroups, ImmutableSet<AddressPair> allowedAddressPairs, + ImmutableSet<ExtraDhcpOption> extraDhcpOptions, VNICType vnicType, String hostId, ImmutableMap<String, Object> profile, + Boolean portSecurity, String profileId, Boolean macLearning, Integer qosRxtxFactor) { + this.id = id; + this.status = status; + this.vifType = vifType; + this.vifDetails = vifDetails; + this.qosQueueId = qosQueueId; + this.name = name; + this.networkId = networkId; + this.adminStateUp = adminStateUp; + this.macAddress = macAddress; + this.fixedIps = fixedIps; + this.deviceId = deviceId; + this.deviceOwner = deviceOwner; + this.tenantId = tenantId; + this.securityGroups = securityGroups; + this.allowedAddressPairs = allowedAddressPairs; + this.extraDhcpOptions = extraDhcpOptions; + this.vnicType = vnicType; + this.hostId = hostId; + this.profile = profile; + this.portSecurity = portSecurity; + this.profileId = profileId; + this.macLearning = macLearning; + this.qosRxtxFactor = qosRxtxFactor; + } + + /** + * Default constructor. + */ + private Port() {} + + /** + * Copy constructor + * @param port + */ + private Port(Port port) { + this(port.id, + port.status, + port.vifType, + port.vifDetails, + port.qosQueueId, + port.name, + port.networkId, + port.adminStateUp, + port.macAddress, + port.fixedIps, + port.deviceId, + port.deviceOwner, + port.tenantId, + port.securityGroups, + port.allowedAddressPairs, + port.extraDhcpOptions, + port.vnicType, + port.hostId, + port.profile, + port.portSecurity, + port.profileId, + port.macLearning, + port.qosRxtxFactor); + } + + /** + * @return the id of the Port + */ + @Nullable + public String getId() { + return id; + } + + /** + * @return the status of the Port + */ + @Nullable + public NetworkStatus getStatus() { + return status; + } + + /** + * + * @return the vifType of the Port. Visible to only administrative users. + * + */ + @Nullable + public VIFType getVifType() { + return vifType; + } + + /** + * @return the vifDetails of the Port. A dictionary that enables the application to pass information about functions + * that Networking API v2.0 provides. Specify the following value: port_filter : Boolean to define whether + * Networking API v2.0 provides port filtering features such as security group and anti-MAC/IP spoofing. Visible to + * only administrative users. + */ + @Nullable + public ImmutableMap<String, Object> getVifDetails() { + return vifDetails; + } + + /** + * @return the qosQueueId of the Port + */ + @Nullable + public String getQosQueueId() { + return qosQueueId; + } + + /** + * @return the name of the Port + */ + @Nullable + public String getName() { + return name; + } + + /** + * @return the id of the network where this port is associated with. + */ + @Nullable + public String getNetworkId() { + return networkId; + } + + /** + * @return the administrative state of port. If false, port does not forward packets. + */ + @Nullable + public Boolean getAdminStateUp() { + return adminStateUp; + } + + /** + * @return the macAddress of the Port + */ + @Nullable + public String getMacAddress() { + return macAddress; + } + + /** + * @return the set of fixed ips this port has been assigned. + */ + @Nullable + public ImmutableSet<IP> getFixedIps() { + return fixedIps; + } + + /** + * @return the id of the device (e.g. server) using this port. + */ + @Nullable + public String getDeviceId() { + return deviceId; + } + + /** + * @return the entity (e.g.: dhcp agent) using this port. + */ + @Nullable + public String getDeviceOwner() { + return deviceOwner; + } + + /** + * @return the tenantId of the Port + */ + @Nullable + public String getTenantId() { + return tenantId; + } + + /** + * @return the set of security groups + */ + @Nullable + public ImmutableSet<String> getSecurityGroups() { + return securityGroups; + } + + /** + * @return the allowedAddressPairs of the Port + */ + @Nullable + public ImmutableSet<AddressPair> getAllowedAddressPairs() { + return allowedAddressPairs; + } + + /** + * @return the extraDhcpOptions of the Port + */ + @Nullable + public ImmutableSet<ExtraDhcpOption> getExtraDhcpOptions() { + return extraDhcpOptions; + } + + /** + * @return the vnicType of the Port. This extended attribute is visible to only port owners and administrative users. + * Specifies a value of normal (virtual nic), direct (pci passthrough), or macvtap (virtual interface with a + * tap-like software interface). These values support SR-IOV PCI passthrough networking. The ML2 plug-in supports + * the vnic_type. + */ + @Nullable + public VNICType getVnicType() { + return vnicType; + } + + /** + * @return the hostId of the Port. The ID of the host where the port is allocated. In some cases, different + * implementations can run on different hosts. Visible to only administrative users. + */ + @Nullable + public String getHostId() { + return hostId; + } + + /** + * @return the profile of the Port. A dictionary that enables the application to pass information about functions + * that the Networking API provides. To enable or disable port filtering features such as security group and + * anti-MAC/IP spoofing, specify port_filter: True or port_filter: False. Visible to only administrative users. + */ + @Nullable + public ImmutableMap<String, Object> getProfile() { + return profile; + } + + /** + * @return the portSecurity of the Port + */ + @Nullable + public Boolean getPortSecurity() { + return portSecurity; + } + + /** + * @return the profileId of the Port + */ + @Nullable + public String getProfileId() { + return profileId; + } + + /** + * @return the macLearning of the Port + */ + @Nullable + public Boolean getMacLearning() { + return macLearning; + } + + /** + * @return the qosRxtxFactor of the Port + */ + @Nullable + public Integer getQosRxtxFactor() { + return qosRxtxFactor; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Port that = (Port) o; + + return Objects.equal(this.id, that.id) && + Objects.equal(this.status, that.status) && + Objects.equal(this.vifType, that.vifType) && + Objects.equal(this.vifDetails, that.vifDetails) && + Objects.equal(this.qosQueueId, that.qosQueueId) && + Objects.equal(this.name, that.name) && + Objects.equal(this.networkId, that.networkId) && + Objects.equal(this.adminStateUp, that.adminStateUp) && + Objects.equal(this.macAddress, that.macAddress) && + Objects.equal(this.fixedIps, that.fixedIps) && + Objects.equal(this.deviceId, that.deviceId) && + Objects.equal(this.deviceOwner, that.deviceOwner) && + Objects.equal(this.tenantId, that.tenantId) && + Objects.equal(this.securityGroups, that.securityGroups) && + Objects.equal(this.allowedAddressPairs, that.allowedAddressPairs) && + Objects.equal(this.extraDhcpOptions, that.extraDhcpOptions) && + Objects.equal(this.vnicType, that.vnicType) && + Objects.equal(this.hostId, that.hostId) && + Objects.equal(this.profile, that.profile) && + Objects.equal(this.portSecurity, that.portSecurity) && + Objects.equal(this.profileId, that.profileId) && + Objects.equal(this.macLearning, that.macLearning) && + Objects.equal(this.qosRxtxFactor, that.qosRxtxFactor); + } + + @Override + public int hashCode() { + return Objects.hashCode(id, status, vifType, vifDetails, qosQueueId, name, + networkId, adminStateUp, macAddress, fixedIps, deviceId, + deviceOwner, tenantId, securityGroups, allowedAddressPairs, extraDhcpOptions, + vnicType, hostId, profile, portSecurity, profileId, + macLearning, qosRxtxFactor); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("id", id) + .add("status", status) + .add("vifType", vifType) + .add("vifDetails", vifDetails) + .add("qosQueueId", qosQueueId) + .add("name", name) + .add("networkId", networkId) + .add("adminStateUp", adminStateUp) + .add("macAddress", macAddress) + .add("fixedIps", fixedIps) + .add("deviceId", deviceId) + .add("deviceOwner", deviceOwner) + .add("tenantId", tenantId) + .add("securityGroups", securityGroups) + .add("allowedAddressPairs", allowedAddressPairs) + .add("extraDhcpOptions", extraDhcpOptions) + .add("vnicType", vnicType) + .add("hostId", hostId) + .add("profile", profile) + .add("portSecurity", portSecurity) + .add("profileId", profileId) + .add("macLearning", macLearning) + .add("qosRxtxFactor", qosRxtxFactor) + .toString(); + } + + /* + * Methods to get the Create and Update builders follow + */ + + /** + * @return the Builder for creating a new Router + */ + public static CreateBuilder createBuilder(String networkId) { + return new CreateBuilder(networkId); + } + + /** + * @return the Builder for updating a Router + */ + public static UpdateBuilder updateBuilder() { + return new UpdateBuilder(); + } + + private abstract static class Builder<ParameterizedBuilderType> { + protected Port port; + + /** + * No-parameters constructor used when updating. + */ + private Builder() { + port = new Port(); + } + + protected abstract ParameterizedBuilderType self(); + + /** + * Provide the name to the Port's Builder. + * + * @return the Builder. + * @see Port#getName() + */ + public ParameterizedBuilderType name(String name) { + port.name = name; + return self(); + } + + /** + * Provide the networkId to the Port's Builder. + * + * @return the Builder. + * @see Port#getNetworkId() + */ + public ParameterizedBuilderType networkId(String networkId) { + port.networkId = networkId; + return self(); + } + + /** + * Provide the adminStateUp to the Port's Builder. + * + * @return the Builder. + * @see Port#getAdminStateUp() + */ + public ParameterizedBuilderType adminStateUp(Boolean adminStateUp) { + port.adminStateUp = adminStateUp; + return self(); + } + + /** + * Provide the macAddress to the Port's Builder. + * + * @return the Builder. + * @see Port#getMacAddress() + */ + public ParameterizedBuilderType macAddress(String macAddress) { + port.macAddress = macAddress; + return self(); + } + + /** + * Provide the fixedIps to the Port's Builder. + * + * @return the Builder. + * @see Port#getFixedIps() + */ + public ParameterizedBuilderType fixedIps(ImmutableSet<IP> fixedIps) { + port.fixedIps = fixedIps; + return self(); + } + + /** + * Provide the deviceId to the Port's Builder. + * + * @return the Builder. + * @see Port#getDeviceId() + */ + public ParameterizedBuilderType deviceId(String deviceId) { + port.deviceId = deviceId; + return self(); + } + + /** + * Provide the deviceOwner to the Port's Builder. + * + * @return the Builder. + * @see Port#getDeviceOwner() + */ + public ParameterizedBuilderType deviceOwner(String deviceOwner) { + port.deviceOwner = deviceOwner; + return self(); + } + + /** + * Provide the tenantId to the Port's Builder. + * + * @return the Builder. + * @see Port#getTenantId() + */ + public ParameterizedBuilderType tenantId(String tenantId) { + port.tenantId = tenantId; + return self(); + } + + /** + * Provide the tenantId to the Port's Builder. + * + * @return the Builder. + * @see Port#getSecurityGroups() + */ + public ParameterizedBuilderType securityGroups(ImmutableSet<String> securityGroups) { + port.securityGroups = securityGroups; + return self(); + } + + /** + * Provide the allowedAddressPairs to the Port's Builder. + * + * @return the Builder. + * @see Port#getAllowedAddressPairs() + */ + public ParameterizedBuilderType allowedAddressPairs(ImmutableSet<AddressPair> allowedAddressPairs) { + port.allowedAddressPairs = allowedAddressPairs; + return self(); + } + + /** + * Provide the extraDhcpOptions to the Port's Builder. + * + * @return the Builder. + * @see Port#getExtraDhcpOptions() + */ + public ParameterizedBuilderType extraDhcpOptions(ImmutableSet<ExtraDhcpOption> extraDhcpOptions) { + port.extraDhcpOptions = extraDhcpOptions; + return self(); + } + + /** + * Provide the vnicType to the Port's Builder. + * Specify a value of normal (virtual nic), direct (pci passthrough), or macvtap (virtual interface with a + * tap-like software interface). These values support SR-IOV PCI passthrough networking. The ML2 plug-in supports + * the vnic_type. + * + * @return the Builder. + * @see Port#getVnicType() + */ + public ParameterizedBuilderType vnicType(VNICType vnicType) { + port.vnicType = vnicType; + return self(); + } + + /** + * Provide the hostId to the Port's Builder. + * + * @return the Builder. + * @see Port#getHostId() + */ + public ParameterizedBuilderType hostId(String hostId) { + port.hostId = hostId; + return self(); + } + + /** + * Provide the profile to the Port's Builder. + * This attribute is a dictionary that can be used (with admin credentials) to supply information influencing the + * binding of the port. This functionality is needed for SR-IOV PCI passthrough. + * + * @return the Builder. + * @see Port#getProfile() + */ + public ParameterizedBuilderType profile(ImmutableMap<String, Object> profile) { + port.profile = profile; + return self(); + } + + /** + * Provide the portSecurity to the Port's Builder. + * + * @return the Builder. + * @see Port#getPortSecurity() + */ + public ParameterizedBuilderType portSecurity(Boolean portSecurity) { + port.portSecurity = portSecurity; + return self(); + } + + /** + * Provide the profileId to the Port's Builder. + * + * @return the Builder. + * @see Port#getProfileId() + */ + public ParameterizedBuilderType profileId(String profileId) { + port.profileId = profileId; + return self(); + } + + /** + * Provide the macLearning to the Port's Builder. + * + * @return the Builder. + * @see Port#getMacLearning() + */ + public ParameterizedBuilderType macLearning(Boolean macLearning) { + port.macLearning = macLearning; + return self(); + } + + /** + * Provide the qosRxtxFactor to the Port's Builder. + * + * @return the Builder. + * @see Port#getQosRxtxFactor() + */ + public ParameterizedBuilderType qosRxtxFactor(int qosRxtxFactor) { + port.qosRxtxFactor = qosRxtxFactor; + return self(); + } + } + + /** + * Create and Update builders (inheriting from Builder) + */ + public static class CreateBuilder extends Builder<CreateBuilder> { + /** + * + * Supply required properties for creating a Builder + */ + private CreateBuilder(String networkId) { + port.networkId = networkId; + } + + /** + * @return a CreatePort constructed with this Builder. + */ + public CreatePort build() { + return new CreatePort(port); + } + + protected CreateBuilder self() { + return this; + } + } + + /** + * Create and Update builders (inheriting from Builder) + */ + public static class UpdateBuilder extends Builder<UpdateBuilder> { + /** + * Supply required properties for updating a Builder + */ + private UpdateBuilder() { + } + + /** + * @return a UpdatePort constructed with this Builder. + */ + public UpdatePort build() { + return new UpdatePort(port); + } + + protected UpdateBuilder self() { + return this; + } + } + + /** + * Create and Update options - extend the domain class, passed to API update and create calls. + * Essentially the same as the domain class. Ensure validation and safe typing. + */ + public static class CreatePort extends Port { + /** + * Copy constructor + */ + private CreatePort(Port port) { + super(port); + checkNotNull(port.networkId, "networkId should not be null"); + } + } + + /** + * Create and Update options - extend the domain class, passed to API update and create calls. + * Essentially the same as the domain class. Ensure validation and safe typing. + */ + public static class UpdatePort extends Port { + /** + * Copy constructor + */ + private UpdatePort(Port port) { + super(port); + } + } +}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Ports.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Ports.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Ports.java new file mode 100644 index 0000000..8cf449b --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Ports.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.openstack.neutron.v2.domain; + +import java.beans.ConstructorProperties; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; + +import com.google.common.collect.ImmutableSet; + +/** + * A collection of Ports + */ +public class Ports extends PaginatedCollection<Port> { + public static final Ports EMPTY = new Ports(ImmutableSet.<Port> of(), ImmutableSet.<Link> of()); + + @ConstructorProperties({"ports", "ports_links"}) + protected Ports(Iterable<Port> ports, Iterable<Link> portsLinks) { + super(ports, portsLinks); + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Router.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Router.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Router.java new file mode 100644 index 0000000..0b06531 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Router.java @@ -0,0 +1,285 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.openstack.neutron.v2.domain; + +import java.beans.ConstructorProperties; + +import javax.inject.Named; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; + +/** + * A Neutron Router + * + * @see <a + * href="http://docs.openstack.org/api/openstack-network/2.0/content/router_ext_concepts.html">api + * doc</a> + */ +public class Router { + + private String id; + private NetworkStatus status; + + private String name; + @Named("tenant_id") + private String tenantId; + @Named("admin_state_up") + private Boolean adminStateUp; + @Named("external_gateway_info") + private ExternalGatewayInfo externalGatewayInfo; + + /** + * @param id + * @param status + * @param name + * @param tenantId + * @param adminStateUp + * @param externalGatewayInfo + */ + @ConstructorProperties({"id", "status", "name", "tenant_id", "admin_state_up", "external_gateway_info"}) + private Router(String id, NetworkStatus status, String name, String tenantId, Boolean adminStateUp, ExternalGatewayInfo externalGatewayInfo) { + this.id = id; + this.status = status; + this.name = name; + this.tenantId = tenantId; + this.adminStateUp = adminStateUp; + this.externalGatewayInfo = externalGatewayInfo; + } + + /** + * Default constructor. + */ + private Router() {} + + /** + * Copy constructor + * @param router + */ + private Router(Router router) { + this(router.id, router.status, router.name, router.tenantId, router.adminStateUp, router.externalGatewayInfo); + } + + /** + * @return the id of the Router + */ + @Nullable + public String getId() { + return id; + } + + /** + * @return the status of the Router + */ + @Nullable + public NetworkStatus getStatus() { + return status; + } + + /** + * @return the name of the Router + */ + @Nullable + public String getName() { + return name; + } + + /** + * @return the tenantId of the Router + */ + @Nullable + public String getTenantId() { + return tenantId; + } + + /** + * @return the adminStateUp of the Router + */ + @Nullable + public Boolean getAdminStateUp() { + return adminStateUp; + } + + /** + * @return the externalGatewayInfo of the Router + */ + @Nullable + public ExternalGatewayInfo getExternalGatewayInfo() { + return externalGatewayInfo; + } + + /** + * @return the Builder for creating a new Router + */ + public static CreateBuilder createBuilder() { + return new CreateBuilder(); + } + + /** + * @return the Builder for updating a Router + */ + public static UpdateBuilder updateBuilder() { + return new UpdateBuilder(); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Router that = (Router) o; + + return Objects.equal(this.id, that.id) && + Objects.equal(this.status, that.status) && + Objects.equal(this.name, that.name) && + Objects.equal(this.tenantId, that.tenantId) && + Objects.equal(this.adminStateUp, that.adminStateUp) && + Objects.equal(this.externalGatewayInfo, that.externalGatewayInfo); + } + + @Override + public int hashCode() { + return Objects.hashCode(id, status, name, tenantId, adminStateUp, externalGatewayInfo); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("id", id) + .add("status", status) + .add("name", name) + .add("tenantId", tenantId) + .add("adminStateUp", adminStateUp) + .add("externalGatewayInfo", externalGatewayInfo) + .toString(); + } + + private abstract static class Builder<ParameterizedBuilderType> { + protected Router router; + + /** + * No-parameters constructor used when updating. + * */ + private Builder() { + router = new Router(); + } + + protected abstract ParameterizedBuilderType self(); + + /** + * Provide the name to the Router's Builder. + * + * @return the Builder. + * @see Router#getName() + */ + public ParameterizedBuilderType name(String name) { + router.name = name; + return self(); + } + + /** + * Provide the tenantId to the Router's Builder. + * + * @return the Builder. + * @see Router#getTenantId() + */ + public ParameterizedBuilderType tenantId(String tenantId) { + router.tenantId = tenantId; + return self(); + } + + /** + * Provide the adminStateUp to the Router's Builder. + * + * @return the Builder. + * @see Router#getAdminStateUp() + */ + public ParameterizedBuilderType adminStateUp(Boolean adminStateUp) { + router.adminStateUp = adminStateUp; + return self(); + } + + /** + * Provide the externalGatewayInfo to the Router's Builder. + * + * @return the Builder. + * @see Router#getExternalGatewayInfo() + */ + public ParameterizedBuilderType externalGatewayInfo(ExternalGatewayInfo externalGatewayInfo) { + router.externalGatewayInfo = externalGatewayInfo; + return self(); + } + } + + public static class CreateBuilder extends Builder<CreateBuilder> { + /** + * Supply required properties for creating a Builder + */ + private CreateBuilder() { + } + + /** + * @return a CreateRouter constructed with this Builder. + */ + public CreateRouter build() { + return new CreateRouter(router); + } + + protected CreateBuilder self() { + return this; + } + } + + public static class UpdateBuilder extends Builder<UpdateBuilder> { + /** + * Supply required properties for updating a Builder + */ + private UpdateBuilder() { + } + + /** + * @return a UpdateRouter constructed with this Builder. + */ + public UpdateRouter build() { + return new UpdateRouter(router); + } + + protected UpdateBuilder self() { + return this; + } + } + + public static class CreateRouter extends Router{ + /** + * Copy constructor + */ + private CreateRouter(Router router) { + super(router); + } + } + public static class UpdateRouter extends Router{ + /** + * Copy constructor + */ + private UpdateRouter(Router router) { + super(router); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RouterInterface.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RouterInterface.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RouterInterface.java new file mode 100644 index 0000000..3a86612 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RouterInterface.java @@ -0,0 +1,139 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.openstack.neutron.v2.domain; + +import com.google.common.base.Objects; +import org.jclouds.javax.annotation.Nullable; + +import javax.inject.Named; +import java.beans.ConstructorProperties; + +/** + * A Neutron Router Interface + * + * @see <a + * href="http://docs.openstack.org/api/openstack-network/2.0/content/router_add_interface.html">api + * doc</a> + */ +public class RouterInterface { + + @Named("subnet_id") + protected final String subnetId; + @Named("port_id") + protected final String portId; + + @ConstructorProperties({"subnet_id", "port_id"}) + protected RouterInterface(String subnetId, String portId) { + this.subnetId = subnetId; + this.portId = portId; + } + + /** + * @return the subnetId of the RouterInterface + */ + @Nullable + public String getSubnetId() { + return subnetId; + } + + /** + * @return the portId of the RouterInterface + */ + @Nullable + public String getPortId() { + return portId; + } + + @Override + public int hashCode() { + return Objects.hashCode(subnetId, portId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + RouterInterface that = RouterInterface.class.cast(obj); + return Objects.equal(this.subnetId, that.subnetId) && Objects.equal(this.portId, that.portId); + } + + protected Objects.ToStringHelper string() { + return Objects.toStringHelper(this).add("subnetId", subnetId).add("portId", portId); + } + + @Override + public String toString() { + return string().toString(); + } + + /** + * @return the Builder for RouterInterface + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Gets a Builder configured as this object. + */ + public Builder toBuilder() { + return new Builder().fromRouterInterface(this); + } + + public static class Builder { + protected String subnetId; + protected String portId; + + /** + * Provide the subnetId to the RouterInterface's Builder. + * + * @return the Builder. + * @see RouterInterface#getSubnetId() + */ + public Builder subnetId(String subnetId) { + this.subnetId = subnetId; + return this; + } + + /** + * Provide the portId to the RouterInterface's Builder. + * + * @return the Builder. + * @see RouterInterface#getPortId() + */ + public Builder portId(String portId) { + this.portId = portId; + return this; + } + + /** + * @return a RouterInterface constructed with this Builder. + */ + public RouterInterface build() { + return new RouterInterface(subnetId, portId); + } + + /** + * @return a Builder from another RouterInterface. + */ + public Builder fromRouterInterface(RouterInterface in) { + return this.subnetId(in.getSubnetId()).portId(in.getPortId()); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Routers.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Routers.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Routers.java new file mode 100644 index 0000000..c02c382 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Routers.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.openstack.neutron.v2.domain; + +import java.beans.ConstructorProperties; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; + +import com.google.common.collect.ImmutableSet; + +/** + * A collection of Routers + */ +public class Routers extends PaginatedCollection<Router> { + public static final Routers EMPTY = new Routers(ImmutableSet.<Router> of(), ImmutableSet.<Link> of()); + + @ConstructorProperties({"routers", "routers_links"}) + protected Routers(Iterable<Router> routers, Iterable<Link> routersLinks) { + super(routers, routersLinks); + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rule.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rule.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rule.java new file mode 100644 index 0000000..89e9d19 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rule.java @@ -0,0 +1,376 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.openstack.neutron.v2.domain; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.beans.ConstructorProperties; + +import javax.inject.Named; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; + +/** + * Contains a mapping between a MAC address and an IP address. + */ +public class Rule { + + private String id; + @Named("tenant_id") + private String tenantId; + private RuleDirection direction; + @Named("security_group_id") + private String securityGroupId; + private RuleEthertype ethertype; + @Named("port_range_min") + private Integer portRangeMin; + @Named("port_range_max") + private Integer portRangeMax; + private RuleProtocol protocol; + @Named("remote_group_id") + private String remoteGroupId; + @Named("remote_ip_prefix") + private String remoteIpPrefix; + + @ConstructorProperties({"id", "tenant_id", "direction", "security_group_id", "ethertype", "port_range_min", + "port_range_max", "protocol", "remote_group_id", "remote_ip_prefix"}) + protected Rule(String id, String tenantId, RuleDirection direction, String securityGroupId, + RuleEthertype ethertype, Integer portRangeMin, Integer portRangeMax, + RuleProtocol protocol, String remoteGroupId, String remoteIpPrefix) { + this.id = id; + this.tenantId = tenantId; + this.direction = direction; + this.securityGroupId = securityGroupId; + this.ethertype = ethertype; + this.portRangeMin = portRangeMin; + this.portRangeMax = portRangeMax; + this.protocol = protocol; + this.remoteGroupId = remoteGroupId; + this.remoteIpPrefix = remoteIpPrefix; + } + + private Rule(Rule rule) { + this(rule.id, + rule.tenantId, + rule.direction, + rule.securityGroupId, + rule.ethertype, + rule.portRangeMin, + rule.portRangeMax, + rule.protocol, + rule.remoteGroupId, + rule.remoteIpPrefix + ); + } + + private Rule() {} + + /** + * @return The identifier for this rule. + */ + @Nullable + public String getId() { + return id; + } + + /** + * @return The identifier of the tenant for this rule. + */ + @Nullable + public String getTenantId() { + return tenantId; + } + + /** + * @return The direction in which the security group rule is applied. + */ + @Nullable + public RuleDirection getDirection() { + return direction; + } + + /** + * @return The security group ID to associate with this security group rule. + */ + @Nullable + public String getSecurityGroupId() { + return securityGroupId; + } + + /** + * @return The internet protocol version type of this rule. + */ + @Nullable + public RuleEthertype getEthertype() { + return ethertype; + } + + /** + * @return The minimum port number in the range that is matched by the security group rule. If the protocol is TCP + * or UDP, this value must be less than or equal to the value of the port_range_max attribute. If the protocol is + * ICMP, this value must be an ICMP type. + */ + @Nullable + public Integer getPortRangeMin() { + return portRangeMin; + } + + /** + * @return The maximum port number in the range that is matched by the security group rule. The port_range_min + * attribute constrains the port_range_max attribute. If the protocol is ICMP, this value must be an ICMP type. + */ + @Nullable + public Integer getPortRangeMax() { + return portRangeMax; + } + + /** + * @return The protocol that is matched by the security group rule. Valid values are null, tcp, udp, and icmp. + */ + @Nullable + public RuleProtocol getProtocol() { + return protocol; + } + + /** + * @return The remote group ID to be associated with this security group rule. + */ + @Nullable + public String getRemoteGroupId() { + return remoteGroupId; + } + + /** + * @return The remote IP prefix to be associated with this security group rule. This attribute matches the specified + * IP prefix as the source IP address of the IP packet. + */ + @Nullable + public String getRemoteIpPrefix() { + return remoteIpPrefix; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Rule that = (Rule) o; + + return Objects.equal(this.id, that.id) && + Objects.equal(this.tenantId, that.tenantId) && + Objects.equal(this.direction, that.direction) && + Objects.equal(this.securityGroupId, that.securityGroupId) && + Objects.equal(this.ethertype, that.ethertype) && + Objects.equal(this.portRangeMin, that.portRangeMin) && + Objects.equal(this.portRangeMax, that.portRangeMax) && + Objects.equal(this.protocol, that.protocol) && + Objects.equal(this.remoteGroupId, that.remoteGroupId) && + Objects.equal(this.remoteIpPrefix, that.remoteIpPrefix); + } + + @Override + public int hashCode() { + return Objects.hashCode(id, tenantId, direction, securityGroupId, ethertype, portRangeMin, + portRangeMax, protocol, remoteGroupId, remoteIpPrefix); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("id", id) + .add("tenantId", tenantId) + .add("direction", direction) + .add("securityGroupId", securityGroupId) + .add("ethertype", ethertype) + .add("portRangeMin", portRangeMin) + .add("portRangeMax", portRangeMax) + .add("protocol", protocol) + .add("remoteGroupId", remoteGroupId) + .add("remoteIpPrefix", remoteIpPrefix) + .toString(); + } + + + /* + * Methods to get the Create and Update builders follow + */ + + /** + * @return the Builder for creating a new SecurityGroupRule + */ + public static CreateBuilder createBuilder(RuleDirection direction, String securityGroupId) { + return new CreateBuilder(direction, securityGroupId); + } + + public abstract static class Builder<ParameterizedBuilderType> { + // Keep track of the builder's state. + protected Rule rule; + + private Builder() { + rule = new Rule(); + } + + protected abstract ParameterizedBuilderType self(); + + /** + * The tenant id for this rule. Usually can only be specified by administrators. + * + * @return the Builder. + * @see Rule#getTenantId() + */ + public ParameterizedBuilderType tenantId(String tenantId) { + rule.tenantId = tenantId; + return self(); + } + + /** + * The direction in which the security group rule is applied. + * + * @return the Builder. + * @see Rule#getDirection() + */ + public ParameterizedBuilderType direction(RuleDirection direction) { + rule.direction = direction; + return self(); + } + + /** + * The security group ID to associate with this security group rule. + * + * @return the Builder. + * @see Rule#getSecurityGroupId() + */ + public ParameterizedBuilderType securityGroupId(String securityGroupId) { + rule.securityGroupId = securityGroupId; + return self(); + } + + /** + * The internet protocol version for this rule. + * + * @return the Builder. + * @see Rule#getEthertype() + */ + public ParameterizedBuilderType ethertype(RuleEthertype ethertype) { + rule.ethertype = ethertype; + return self(); + } + + /** + * The minimum port number in the range that is matched by the security group rule. + * + * @return the Builder. + * @see Rule#getPortRangeMin() + */ + public ParameterizedBuilderType portRangeMin(Integer portRangeMin) { + rule.portRangeMin = portRangeMin; + return self(); + } + + /** + * The maximum port number in the range that is matched by the security group rule. + * + * @return the Builder. + * @see Rule#getPortRangeMax() + */ + public ParameterizedBuilderType portRangeMax(Integer portRangeMax) { + rule.portRangeMax = portRangeMax; + return self(); + } + + /** + * The protocol that is matched by the security group rule. Valid values are null, tcp, udp, and icmp. + * + * @return the Builder. + * @see Rule#getProtocol() + */ + public ParameterizedBuilderType protocol(RuleProtocol protocol) { + rule.protocol = protocol; + return self(); + } + + /** + * The remote group ID to be associated with this security group rule. You can specify either remote_group_id or + * remote_ip_prefix in the request body. + * + * @return the Builder. + * @see Rule#getRemoteGroupId() + */ + public ParameterizedBuilderType remoteGroupId(String remoteGroupId) { + rule.remoteGroupId = remoteGroupId; + return self(); + } + + /** + * The remote IP prefix to be associated with this security group rule. You can specify either remote_group_id + * or remote_ip_prefix in the request body. This attribute matches the specified IP prefix as the source IP + * address of the IP packet. + * + * @return the Builder. + * @see Rule#getRemoteIpPrefix() + */ + public ParameterizedBuilderType remoteIpPrefix(String remoteIpPrefix) { + rule.remoteIpPrefix = remoteIpPrefix; + return self(); + } + } + + /** + * This is used to build a CreateBuilder object. + */ + public static class CreateBuilder extends Builder<CreateBuilder> { + /** + * Supply required properties for creating a Builder + */ + private CreateBuilder(RuleDirection direction, String securityGroupId) { + rule.direction = direction; + rule.securityGroupId = securityGroupId; + } + + /** + * @return a CreateRule constructed with this Builder. + */ + public CreateRule build() { + return new CreateRule(rule); + } + + protected CreateBuilder self() { + return this; + } + } + + /** + * Create and Update options - extend the domain class, passed to API update and create calls. + * Essentially the same as the domain class. Ensure validation and safe typing. + */ + public static class CreateRule extends Rule { + private CreateRule(Rule rule) { + super(rule); + checkNotNull(this.getDirection(), "direction should not be null"); + checkNotNull(this.getSecurityGroupId(), "security group id should not be null"); + checkArgument(this.getPortRangeMax() >= this.getPortRangeMin(), + "port range max should be greater than or equal to port range min"); + checkArgument(this.getRemoteGroupId() == null || this.getRemoteIpPrefix() == null, + "You can specify either remote_group_id or remote_ip_prefix in the request body."); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleDirection.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleDirection.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleDirection.java new file mode 100644 index 0000000..52e4273 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleDirection.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.openstack.neutron.v2.domain; + +/** + * The direction in which the security group rule is applied. + */ +public enum RuleDirection { + /** + * For a compute instance, an âingressâ security group rule matches traffic that is incoming (ingress) for that instance. + */ + INGRESS("ingress"), + /** + * An âegressâ rule is applied to traffic leaving the instance. + */ + EGRESS("egress"), + /** + * Used by jclouds when the service returns an unknown value other than null. + */ + UNRECOGNIZED("unrecognized"); + + private String name; + + private RuleDirection(String name) { + this.name = name; + } + + public String toString() { + return name; + } + + /* + * This provides GSON enum support in jclouds. + * */ + public static RuleDirection fromValue(String name){ + if (name != null) { + for (RuleDirection value : RuleDirection.values()) { + if (name.equalsIgnoreCase(value.name)) { + return value; + } + } + return UNRECOGNIZED; + } + return null; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleEthertype.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleEthertype.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleEthertype.java new file mode 100644 index 0000000..dd3aa3f --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleEthertype.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.openstack.neutron.v2.domain; + +/** + * The direction in which the security group rule is applied. + */ +public enum RuleEthertype { + /** + * Internet Protocol version 4 + */ + IPV4("IPv4"), + /** + * Internet Protocol version 6 + */ + IPV6("IPv6"), + /** + * Used by jclouds when the service returns an unknown value other than null. + */ + UNRECOGNIZED("unrecognized"); + + private String name; + + private RuleEthertype(String name) { + this.name = name; + } + + public String toString() { + return name; + } + + /* + * This provides GSON enum support in jclouds. + * */ + public static RuleEthertype fromValue(String name){ + if (name != null) { + for (RuleEthertype value : RuleEthertype.values()) { + if (name.equalsIgnoreCase(value.name)) { + return value; + } + } + return UNRECOGNIZED; + } + return null; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleProtocol.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleProtocol.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleProtocol.java new file mode 100644 index 0000000..f6a4574 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/RuleProtocol.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.openstack.neutron.v2.domain; + +/** + * The protocol that is matched by the security group rule. Valid values are null, tcp, udp, and icmp. + */ +public enum RuleProtocol { + /** + * Transmission Control Protocol + */ + TCP("tcp"), + /** + * User Datagram Protocol + */ + UDP("udp"), + /** + * Internet Control Message Protocol + */ + ICMP("icmp"), + /** + * Used by jclouds when the service returns an unknown value other than null. + */ + UNRECOGNIZED("unrecognized"); + + private String name; + + private RuleProtocol(String name) { + this.name = name; + } + + public String toString() { + return name; + } + + /* + * This provides GSON enum support in jclouds. + * */ + public static RuleProtocol fromValue(String name){ + if (name != null) { + for (RuleProtocol value : RuleProtocol.values()) { + if (name.equalsIgnoreCase(value.name)) { + return value; + } + } + return UNRECOGNIZED; + } + return null; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rules.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rules.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rules.java new file mode 100644 index 0000000..4794a18 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Rules.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.openstack.neutron.v2.domain; + +import java.beans.ConstructorProperties; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; +import com.google.common.collect.ImmutableSet; + +/** + * A collection of Networks + */ +public class Rules extends PaginatedCollection<Rule> { + public static final Rules EMPTY = new Rules(ImmutableSet.<Rule> of(), ImmutableSet.<Link> of()); + + @ConstructorProperties({"security_group_rules", "security_group_rules_links"}) + protected Rules(Iterable<Rule> securityGroups, Iterable<Link> securityGroupRulesLinks) { + super(securityGroups, securityGroupRulesLinks); + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroup.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroup.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroup.java new file mode 100644 index 0000000..d9b08aa --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroup.java @@ -0,0 +1,218 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.openstack.neutron.v2.domain; + +import java.beans.ConstructorProperties; + +import javax.inject.Named; +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableList; + +/** + * Contains a mapping between a MAC address and an IP address. + */ +public class SecurityGroup { + + private String id; + @Named("tenant_id") + private String tenantId; + private String name; + private String description; + @Named("security_group_rules") + private ImmutableList<Rule> rules; + + @ConstructorProperties({"id", "tenant_id", "name", "description", "security_group_rules"}) + protected SecurityGroup(String id, String tenantId, String name, String description, + ImmutableList<Rule> rules) { + this.id = id; + this.tenantId = tenantId; + this.name = name; + this.description = description; + this.rules = rules; + } + + private SecurityGroup(SecurityGroup securityGroup) { + this(securityGroup.id, + securityGroup.tenantId, + securityGroup.name, + securityGroup.description, + securityGroup.rules + ); + } + + private SecurityGroup() {} + + /** + * @return The identifier for this Security Group. + */ + @Nullable + public String getId() { + return id; + } + + /** + * @return The identifier of the tenant for this Security Group. + */ + @Nullable + public String getTenantId() { + return tenantId; + } + + /** + * @return The name of the Security Group. + */ + @Nullable + public String getName() { + return name; + } + + /** + * @return The description of the Security Group. + */ + @Nullable + public String getDescription() { + return description; + } + + /** + * @return The collection of rules for this Security Group. + */ + public ImmutableList<Rule> getRules() { + return rules != null ? rules : ImmutableList.<Rule>of(); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + SecurityGroup that = (SecurityGroup) o; + + return Objects.equal(this.id, that.id) && + Objects.equal(this.tenantId, that.tenantId) && + Objects.equal(this.name, that.name) && + Objects.equal(this.description, that.description) && + Objects.equal(this.rules, that.rules); + } + + @Override + public int hashCode() { + return Objects.hashCode(id, tenantId, name, description, rules); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("id", id) + .add("tenantId", tenantId) + .add("name", name) + .add("description", description) + .add("securityGroupRules", rules) + .toString(); + } + + /* + * Methods to get the Create and Update builders follow + */ + + /** + * @return the Builder for creating a new SecurityGroup + */ + public static CreateBuilder createBuilder() { + return new CreateBuilder(); + } + + private abstract static class Builder<ParameterizedBuilderType> { + // Keep track of the builder's state. + protected SecurityGroup securityGroup; + + private Builder() { + securityGroup = new SecurityGroup(); + } + + protected abstract ParameterizedBuilderType self(); + + /** + * The tenant id for this Security Group. Usually can only be specified by administrators. + * + * @return the Builder. + * @see SecurityGroup#getTenantId() + */ + public ParameterizedBuilderType tenantId(String tenantId) { + securityGroup.tenantId = tenantId; + return self(); + } + + /** + * The name for this Security Group. + * + * @return the Builder. + * @see SecurityGroup#getName() + */ + public ParameterizedBuilderType name(String name) { + securityGroup.name = name; + return self(); + } + + /** + * The description for this Security Group. + * + * @return the Builder. + * @see SecurityGroup#getDescription() + */ + public ParameterizedBuilderType description(String description) { + securityGroup.description = description; + return self(); + } + } + + /** + * Create and Update builders (inheriting from Builder) + */ + public static class CreateBuilder extends Builder<CreateBuilder> { + /** + * Supply required properties for creating a Builder + */ + private CreateBuilder() { + } + + /** + * @return a CreateSecurityGroup constructed with this Builder. + */ + public CreateSecurityGroup build() { + return new CreateSecurityGroup(securityGroup); + } + + protected CreateBuilder self() { + return this; + } + } + + /** + * Create and Update options - extend the domain class, passed to API update and create calls. + * Essentially the same as the domain class. Ensure validation and safe typing. + */ + public static class CreateSecurityGroup extends SecurityGroup { + private CreateSecurityGroup(SecurityGroup securityGroup) { + super(securityGroup); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroups.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroups.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroups.java new file mode 100644 index 0000000..044ce1c --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/SecurityGroups.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.openstack.neutron.v2.domain; + +import java.beans.ConstructorProperties; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; + +import com.google.common.collect.ImmutableSet; + +/** + * A collection of Networks + */ +public class SecurityGroups extends PaginatedCollection<SecurityGroup> { + public static final SecurityGroups EMPTY = new SecurityGroups(ImmutableSet.<SecurityGroup> of(), ImmutableSet.<Link> of()); + + @ConstructorProperties({"security_groups", "security_groups_links"}) + protected SecurityGroups(Iterable<SecurityGroup> securityGroups, Iterable<Link> securityGroupsLinks) { + super(securityGroups, securityGroupsLinks); + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnet.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnet.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnet.java new file mode 100644 index 0000000..6e0cfc0 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnet.java @@ -0,0 +1,466 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.openstack.neutron.v2.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.beans.ConstructorProperties; +import java.util.Collection; + +import javax.inject.Named; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +/** + * A Neutron subnet + * + * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api doc</a> + */ +public class Subnet { + + private String id; + + private String name; + @Named("network_id") + private String networkId; + @Named("tenant_id") + private String tenantId; + // Cannot be used for updates. + @Named("allocation_pools") + private ImmutableSet<AllocationPool> allocationPools; + @Named("gateway_ip") + private String gatewayIp; + @Named("ip_version") + private Integer ipVersion; + private String cidr; + @Named("enable_dhcp") + private Boolean enableDhcp; + @Named("dns_nameservers") + private ImmutableSet<String> dnsNameServers; + @Named("host_routes") + private ImmutableSet<HostRoute> hostRoutes; + @Named("ipv6_address_mode") + private IPv6DHCPMode ipv6AddressMode; + @Named("ipv6_ra_mode") + private IPv6DHCPMode ipv6RaMode; + + @ConstructorProperties({"id", "name", "network_id", "tenant_id", "allocation_pools", "gateway_ip", "ip_version", + "cidr", "enable_dhcp", "dns_nameservers", "host_routes", "ipv6_address_mode", "ipv6_ra_mode"}) + private Subnet(String id, String name, String networkId, String tenantId, ImmutableSet<AllocationPool> allocationPools, + String gatewayIp, Integer ipVersion, String cidr, Boolean enableDhcp, ImmutableSet<String> dnsNameServers, ImmutableSet<HostRoute> hostRoutes, + IPv6DHCPMode ipv6AddressMode, IPv6DHCPMode ipv6RaMode) { + this.id = id; + this.name = name; + this.networkId = networkId; + this.tenantId = tenantId; + this.allocationPools = allocationPools; + this.gatewayIp = gatewayIp; + this.ipVersion = ipVersion; + this.cidr = cidr; + this.enableDhcp = enableDhcp; + this.dnsNameServers = dnsNameServers; + this.hostRoutes = hostRoutes; + this.ipv6AddressMode = ipv6AddressMode; + this.ipv6RaMode = ipv6RaMode; + } + + /** + * Default constructor. + */ + private Subnet() {} + + /** + * Copy constructor + * @param subnet + */ + private Subnet(Subnet subnet) { + this(subnet.id, + subnet.name, + subnet.networkId, + subnet.tenantId, + subnet.allocationPools, + subnet.gatewayIp, + subnet.ipVersion, + subnet.cidr, + subnet.enableDhcp, + subnet.dnsNameServers, + subnet.hostRoutes, + subnet.ipv6AddressMode, + subnet.ipv6RaMode); + } + + /** + * @return the id of the subnet + */ + @Nullable + public String getId() { + return this.id; + } + + /** + * @return the name of the subnet + */ + @Nullable + public String getName() { + return this.name; + } + + /** + * @return the id of the network this subnet is associated with. + */ + @Nullable + public String getNetworkId() { + return networkId; + } + + /** + * @return the id of the tenant where this entity is associated with. + */ + @Nullable + public String getTenantId() { + return tenantId; + } + + /** + * @return the sub-ranges of CIDR available for dynamic allocation to ports. + */ + @Nullable + public ImmutableSet<AllocationPool> getAllocationPools() { + return allocationPools; + } + + /** + * @return the default gateway used by devices in this subnet. + */ + @Nullable + public String getGatewayIp() { + return gatewayIp; + } + + /** + * @return the IP version used by this subnet. + */ + @Nullable + public Integer getIpVersion() { + return ipVersion; + } + + /** + * @return the CIDR representing the IP range for this subnet, based on IP version. + */ + @Nullable + public String getCidr() { + return cidr; + } + + /** + * @return true if DHCP is enabled for this subnet, false if not. + */ + @Nullable + public Boolean getEnableDhcp() { + return enableDhcp; + } + + /** + * @return Configurable maximum amount of name servers per subnet. The default is 5. + */ + @Nullable + public ImmutableSet<String> getDnsNameservers() { + return dnsNameServers; + } + + /** + * @return Configurable maximum amount of routes per subnet. The default is 20. + */ + @Nullable + public ImmutableSet<HostRoute> getHostRoutes() { + return hostRoutes; + } + + /** + * @return The IP v6 Address Mode. + */ + @Nullable + public IPv6DHCPMode getIPv6AddressMode() { + return ipv6AddressMode; + } + + /** + * @return The IP v6 Router Advertisement mode. + */ + @Nullable + public IPv6DHCPMode getIPv6RAMode() { + return ipv6RaMode; + } + + @Override + public int hashCode() { + return Objects.hashCode(id, name, networkId, tenantId, allocationPools, gatewayIp, + ipVersion, cidr, enableDhcp, dnsNameServers, hostRoutes, + ipv6AddressMode, ipv6RaMode); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Subnet that = (Subnet) o; + + return Objects.equal(this.id, that.id) && + Objects.equal(this.name, that.name) && + Objects.equal(this.networkId, that.networkId) && + Objects.equal(this.tenantId, that.tenantId) && + Objects.equal(this.allocationPools, that.allocationPools) && + Objects.equal(this.gatewayIp, that.gatewayIp) && + Objects.equal(this.ipVersion, that.ipVersion) && + Objects.equal(this.cidr, that.cidr) && + Objects.equal(this.enableDhcp, that.enableDhcp) && + Objects.equal(this.dnsNameServers, that.dnsNameServers) && + Objects.equal(this.hostRoutes, that.hostRoutes) && + Objects.equal(this.ipv6AddressMode, that.ipv6AddressMode) && + Objects.equal(this.ipv6RaMode, that.ipv6RaMode); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("id", id) + .add("name", name) + .add("networkId", networkId) + .add("tenantId", tenantId) + .add("allocationPools", allocationPools) + .add("gatewayIp", gatewayIp) + .add("ipVersion", ipVersion) + .add("cidr", cidr) + .add("enableDhcp", enableDhcp) + .add("dnsNameServers", dnsNameServers) + .add("hostRoutes", hostRoutes) + .add("ipv6AddressMode", ipv6AddressMode) + .add("ipv6RaMode", ipv6RaMode) + .toString(); + } + + /* + * Methods to get the Create and Update builders follow + */ + + /** + * @return the Builder for creating a new Router + */ + public static CreateBuilder createBuilder(String networkId, String cidr) { + return new CreateBuilder(networkId, cidr); + } + + /** + * @return the Builder for updating a Router + */ + public static UpdateBuilder updateBuilder() { + return new UpdateBuilder(); + } + + private abstract static class Builder<ParameterizedBuilderType> { + protected Subnet subnet; + + /** + * No-parameters constructor used when updating. + */ + private Builder() { + subnet = new Subnet(); + } + + protected abstract ParameterizedBuilderType self(); + + /** + * @see Subnet#getName() + */ + public ParameterizedBuilderType name(String name) { + subnet.name = name; + return self(); + } + + /** + * @see Subnet#getNetworkId() + */ + public ParameterizedBuilderType networkId(String networkId) { + subnet.networkId = networkId; + return self(); + } + + /** + * Only administrators can specify a tenant ID that is not their own. + * As it is optional, this is usually omitted in requests. + * @see Subnet#getTenantId() + */ + public ParameterizedBuilderType tenantId(String tenantId) { + subnet.tenantId = tenantId; + return self(); + } + + /** + * @see Subnet#getAllocationPools() + */ + public ParameterizedBuilderType allocationPools(Collection<AllocationPool> allocationPools) { + subnet.allocationPools = ImmutableSet.copyOf(allocationPools); + return self(); + } + + /** + * @see Subnet#getGatewayIp() + */ + public ParameterizedBuilderType gatewayIp(String gatewayIp) { + subnet.gatewayIp = gatewayIp; + return self(); + } + + /** + * @see Subnet#getIpVersion() + */ + public ParameterizedBuilderType ipVersion(int ipVersion) { + subnet.ipVersion = ipVersion; + return self(); + } + + /** + * @see Subnet#getCidr() + */ + public ParameterizedBuilderType cidr(String cidr) { + subnet.cidr = cidr; + return self(); + } + + /** + * @see Subnet#getEnableDhcp() + */ + public ParameterizedBuilderType enableDhcp(Boolean enableDhcp) { + subnet.enableDhcp = enableDhcp; + return self(); + } + + /** + * @see Subnet#getDnsNameservers() + */ + public ParameterizedBuilderType dnsNameServers(ImmutableSet<String> dnsNameServers) { + subnet.dnsNameServers = dnsNameServers; + return self(); + } + + /** + * @see Subnet#getHostRoutes() + */ + public ParameterizedBuilderType hostRoutes(ImmutableSet<HostRoute> hostRoutes) { + subnet.hostRoutes = hostRoutes; + return self(); + } + + /** + * @see Subnet#getIPv6RAMode() + */ + public ParameterizedBuilderType ipv6RaMode(IPv6DHCPMode ipv6RaMode) { + subnet.ipv6RaMode = ipv6RaMode; + return self(); + } + + /** + * @see Subnet#getIPv6AddressMode() + */ + public ParameterizedBuilderType ipv6AddressMode(IPv6DHCPMode ipv6AddressMode) { + subnet.ipv6AddressMode = ipv6AddressMode; + return self(); + } + } + + /** + * Create and Update builders (inheriting from Builder) + */ + public static class CreateBuilder extends Builder<CreateBuilder> { + /** + * + * Supply required properties for creating a Builder + */ + private CreateBuilder(String networkId, String cidr) { + subnet.networkId = networkId; + subnet.cidr = cidr; + } + + /** + * @return a CreateSubnet constructed with this Builder. + */ + public CreateSubnet build() { + return new CreateSubnet(subnet); + } + + protected CreateBuilder self() { + return this; + } + } + + /** + * Create and Update builders (inheriting from Builder) + */ + public static class UpdateBuilder extends Builder<UpdateBuilder> { + /** + * Supply required properties for updating a Builder + */ + private UpdateBuilder() { + } + + /** + * @return a UpdateSubnet constructed with this Builder. + */ + public UpdateSubnet build() { + return new UpdateSubnet(subnet); + } + + protected UpdateBuilder self() { + return this; + } + } + + /** + * Create and Update options - extend the domain class, passed to API update and create calls. + * Essentially the same as the domain class. Ensure validation and safe typing. + */ + public static class CreateSubnet extends Subnet { + /** + * Copy constructor + */ + private CreateSubnet(Subnet subnet) { + super(subnet); + checkNotNull(subnet.networkId, "networkId should not be null"); + checkNotNull(subnet.cidr, "cidr should not be null"); + } + } + + /** + * Create and Update options - extend the domain class, passed to API update and create calls. + * Essentially the same as the domain class. Ensure validation and safe typing. + */ + public static class UpdateSubnet extends Subnet { + /** + * Copy constructor + */ + private UpdateSubnet(Subnet subnet) { + super(subnet); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnets.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnets.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnets.java new file mode 100644 index 0000000..fb9896e --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/domain/Subnets.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.jclouds.openstack.neutron.v2.domain; + +import java.beans.ConstructorProperties; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; + +import com.google.common.collect.ImmutableSet; + +/** + * A collection of Subnets + */ +public class Subnets extends PaginatedCollection<Subnet> { + public static final Subnets EMPTY = new Subnets(ImmutableSet.<Subnet> of(), ImmutableSet.<Link> of()); + + @ConstructorProperties({"subnets", "subnets_links"}) + protected Subnets(Iterable<Subnet> subnets, Iterable<Link> subnetsLinks) { + super(subnets, subnetsLinks); + } +}
