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/features/NetworkApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/NetworkApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/NetworkApi.java new file mode 100644 index 0000000..08e5586 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/NetworkApi.java @@ -0,0 +1,151 @@ +/* + * 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.features; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks; +import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; +import org.jclouds.collect.PagedIterable; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.neutron.v2.domain.Network; +import org.jclouds.openstack.neutron.v2.domain.Networks; +import org.jclouds.openstack.neutron.v2.fallbacks.EmptyNetworksFallback; +import org.jclouds.openstack.neutron.v2.functions.NetworksToPagedIterable; +import org.jclouds.openstack.neutron.v2.functions.ParseNetworks; +import org.jclouds.openstack.v2_0.options.PaginationOptions; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.Transform; +import org.jclouds.rest.annotations.WrapWith; + +import com.google.common.annotations.Beta; +import com.google.common.collect.FluentIterable; +import com.google.common.collect.ImmutableList; + +/** + * Provides access to Network operations for the OpenStack Networking (Neutron) v2 API. + * <p/> + * Each tenant can define one or more networks. A network is a virtual isolated layer-2 broadcast domain reserved to the + * tenant. A tenant can create several ports for a network, and plug virtual interfaces into these ports. + * + * @see <a href= + * "http://docs.openstack.org/api/openstack-network/2.0/content/Networks.html">api doc</a> + */ +@Beta +@Path("/networks") +@RequestFilters(AuthenticateRequest.class) +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public interface NetworkApi { + + /** + * Returns all networks currently defined in Neutron for the current tenant. + * + * @return the list of all networks configured for the tenant + */ + @Named("network:list") + @GET + @ResponseParser(ParseNetworks.class) + @Transform(NetworksToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Network> list(); + + /** + * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a> + */ + @Named("network:list") + @GET + @ResponseParser(ParseNetworks.class) + @Fallback(EmptyNetworksFallback.class) + Networks list(PaginationOptions options); + + /** + * Return a specific network + * + * @param id the id of the network to return + * @return Network or null if not found + */ + @Named("network:get") + @GET + @Path("/{id}") + @SelectJson("network") + @Fallback(Fallbacks.NullOnNotFoundOr404.class) + @Nullable + Network get(@PathParam("id") String id); + + /** + * Create a new network with the specified type + * + * @param network Describes the network to be created. + * @return a reference of the newly-created network + */ + @Named("network:create") + @POST + @SelectJson("network") + Network create(@WrapWith("network") Network.CreateNetwork network); + + /** + * Create multiple networks + * + * @param networks the bulk of networks to create + * @return list of references of the newly-created networks + */ + @Named("network:createBulk") + @POST + @SelectJson("networks") + FluentIterable<Network> createBulk(@WrapWith("networks") ImmutableList<Network.CreateNetwork> networks); + + /** + * Update a network + * + * @param id the id of the network to update + * @param network the network to update + * @return true if update successful, false if not + */ + @Named("network:update") + @PUT + @Path("/{id}") + @SelectJson("network") + @Fallback(Fallbacks.NullOnNotFoundOr404.class) + @Nullable + Network update(@PathParam("id") String id, @WrapWith("network") Network.UpdateNetwork network); + + /** + * Deletes the specified network + * + * @param id the id of the network to delete + * @return true if delete was successful, false if not + */ + @Named("network:delete") + @DELETE + @Path("/{id}") + @Fallback(Fallbacks.FalseOnNotFoundOr404.class) + boolean delete(@PathParam("id") String id); +}
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/features/PortApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/PortApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/PortApi.java new file mode 100644 index 0000000..6466a90 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/PortApi.java @@ -0,0 +1,148 @@ +/* + * 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.features; + +import com.google.common.annotations.Beta; +import com.google.common.collect.FluentIterable; +import org.jclouds.Fallbacks; +import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; +import org.jclouds.collect.PagedIterable; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.neutron.v2.domain.Port; +import org.jclouds.openstack.neutron.v2.domain.Ports; +import org.jclouds.openstack.neutron.v2.fallbacks.EmptyPortsFallback; +import org.jclouds.openstack.neutron.v2.functions.ParsePorts; +import org.jclouds.openstack.neutron.v2.functions.PortsToPagedIterable; +import org.jclouds.openstack.v2_0.options.PaginationOptions; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.Transform; +import org.jclouds.rest.annotations.WrapWith; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; +import java.util.List; + +/** + * Provides access to Port operations for the OpenStack Networking (Neutron) v2 API. + * <p/> + * A port represents a virtual switch port on a logical network switch where all the interfaces attached to a given network are connected. + * <p/> + * A port has an administrative state which is either 'DOWN' or 'ACTIVE'. Ports which are administratively down will not be able to receive/send traffic. + * @see <a href= + * "http://docs.openstack.org/api/openstack-network/2.0/content/Ports.html">api doc</a> + */ +@Beta +@Path("/ports") +@RequestFilters(AuthenticateRequest.class) +@Consumes(MediaType.APPLICATION_JSON) +public interface PortApi { + + /** + * Returns the list of all ports currently defined in Neutron for the current tenant. The list provides the unique + * identifier of each network configured for the tenant. + * + * @return the list of all port references configured for the tenant + */ + @Named("port:list") + @GET + @Transform(PortsToPagedIterable.class) + @ResponseParser(ParsePorts.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Port> list(); + + /** + * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a> + */ + @Named("port:list") + @GET + @ResponseParser(ParsePorts.class) + @Fallback(EmptyPortsFallback.class) + Ports list(PaginationOptions options); + + /** + * Returns the specific port + * + * @param id the id of the port to return + * @return Port or null if not found + */ + @Named("port:get") + @GET + @Path("/{id}") + @SelectJson("port") + @Fallback(Fallbacks.NullOnNotFoundOr404.class) + @Nullable + Port get(@PathParam("id") String id); + + /** + * Create a new port in the specified network + * + * @param port the port details + * @return a reference of the newly-created port + */ + @Named("port:create") + @POST + @SelectJson("port") + Port create(@WrapWith("port") Port.CreatePort port); + + /** + * Create multiple ports + * + * @param ports the bulk of ports to create + * @return list of references of the newly-created ports + */ + @Named("port:createBulk") + @POST + @SelectJson("ports") + FluentIterable<Port> createBulk(@WrapWith("ports") List<Port.CreatePort> ports); + + /** + * Update a port + * + * @param id the id of the port to update + * @param port CreatePort with just the attributes to update + * @return true if update successful, false if not + */ + @Named("port:update") + @PUT + @Path("/{id}") + @SelectJson("port") + @Fallback(Fallbacks.NullOnNotFoundOr404.class) + Port update(@PathParam("id") String id, @WrapWith("port") Port.UpdatePort port); + + /** + * Delete a port + * + * @param id the id of the port to delete + * @return true if delete successful, false if not + */ + @Named("port:delete") + @DELETE + @Path("/{id}") + @Fallback(Fallbacks.FalseOnNotFoundOr404.class) + boolean delete(@PathParam("id") String id); +} 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/features/SubnetApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/SubnetApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/SubnetApi.java new file mode 100644 index 0000000..7b6f54e --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/features/SubnetApi.java @@ -0,0 +1,144 @@ +/* + * 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.features; + +import com.google.common.collect.FluentIterable; +import org.jclouds.Fallbacks; +import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; +import org.jclouds.collect.PagedIterable; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.neutron.v2.domain.Subnet; +import org.jclouds.openstack.neutron.v2.domain.Subnets; +import org.jclouds.openstack.neutron.v2.fallbacks.EmptySubnetsFallback; +import org.jclouds.openstack.neutron.v2.functions.ParseSubnets; +import org.jclouds.openstack.neutron.v2.functions.SubnetsToPagedIterable; +import org.jclouds.openstack.v2_0.options.PaginationOptions; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.Transform; +import org.jclouds.rest.annotations.WrapWith; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.List; + +/** + * Provides access to Subnet operations for the OpenStack Networking (Neutron) v2 API. + * + * @see <a href= + * "http://docs.openstack.org/api/openstack-network/2.0/content/Subnets.html">api doc</a> + */ +@Path("/subnets") +@RequestFilters(AuthenticateRequest.class) +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public interface SubnetApi { + + /** + * Returns the list of all subnets currently defined in Neutron for the current tenant. The list provides the unique + * identifier of each subnet configured for the tenant. + * + * @return the list of all subnet references configured for the tenant + */ + @Named("subnet:list") + @GET + @ResponseParser(ParseSubnets.class) + @Transform(SubnetsToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Subnet> list(); + + /** + * @see <a href="http://docs.openstack.org/api/openstack-network/2.0/content/pagination.html">api doc</a> + */ + @Named("subnet:list") + @GET + @ResponseParser(ParseSubnets.class) + @Fallback(EmptySubnetsFallback.class) + Subnets list(PaginationOptions options); + + /** + * Returns the specific Subnet. + * + * @param id the id of the subnet to return + * @return Subnet or null if not found + */ + @Named("subnet:get") + @GET + @Path("/{id}") + @SelectJson("subnet") + @Fallback(Fallbacks.NullOnNotFoundOr404.class) + @Nullable + Subnet get(@PathParam("id") String id); + + /** + * Create a subnet within a specified network + * + * @param subnet the subnet to be created + * @return a reference of the newly-created subnet + */ + @Named("subnet:create") + @POST + @SelectJson("subnet") + Subnet create(@WrapWith("subnet") Subnet.CreateSubnet subnet); + + /** + * Create multiple subnets + * + * @param subnets the bulk of subnets to create + * @return list of references of the newly-created subnets + */ + @Named("subnet:createBulk") + @POST + @SelectJson("subnets") + FluentIterable<Subnet> createBulk(@WrapWith("subnets") List<Subnet.CreateSubnet> subnets); + + /** + * Update a subnet + * + * @param id the id of the subnet to update + * @return true if update was successful, false if not + */ + @Named("subnet:update") + @PUT + @Path("/{id}") + @SelectJson("subnet") + @Fallback(Fallbacks.NullOnNotFoundOr404.class) + Subnet update(@PathParam("id") String id, @WrapWith("subnet") Subnet.UpdateSubnet subnet); + + /** + * Delete a subnet + * + * @param id the id of the subnet to delete + * @return true if delete successful, false if not + */ + @Named("subnet:delete") + @DELETE + @Path("/{id}") + @Fallback(Fallbacks.FalseOnNotFoundOr404.class) + boolean delete(@PathParam("id") String id); +} 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/functions/FloatingIPsToPagedIterable.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/FloatingIPsToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/FloatingIPsToPagedIterable.java new file mode 100644 index 0000000..4d54d1f --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/FloatingIPsToPagedIterable.java @@ -0,0 +1,64 @@ +/* + * 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.functions; + +import com.google.common.base.Function; +import com.google.common.base.Optional; +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.internal.Arg0ToPagedIterable; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.FloatingIP; +import org.jclouds.openstack.neutron.v2.extensions.FloatingIPApi; +import org.jclouds.openstack.v2_0.options.PaginationOptions; + +import javax.inject.Inject; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Ensures Floating IPs works as PagedIterable. + */ +public class FloatingIPsToPagedIterable extends Arg0ToPagedIterable.FromCaller<FloatingIP, FloatingIPsToPagedIterable> { + + private final NeutronApi api; + + @Inject + protected FloatingIPsToPagedIterable(NeutronApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<FloatingIP>> markerToNextForArg0(Optional<Object> arg0) { + String region = arg0.isPresent() ? arg0.get().toString() : null; + final FloatingIPApi floatingIPApi = api.getFloatingIPApi(region).get(); + return new Function<Object, IterableWithMarker<FloatingIP>>() { + + @SuppressWarnings("unchecked") + @Override + public IterableWithMarker<FloatingIP> apply(Object input) { + PaginationOptions paginationOptions = PaginationOptions.class.cast(input); + return IterableWithMarker.class.cast(floatingIPApi.list(paginationOptions)); + } + + @Override + public String toString() { + return "listfloatingIPs()"; + } + }; + } + +} 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/functions/NetworksToPagedIterable.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/NetworksToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/NetworksToPagedIterable.java new file mode 100644 index 0000000..c898381 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/NetworksToPagedIterable.java @@ -0,0 +1,64 @@ +/* + * 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.functions; + +import com.google.common.base.Function; +import com.google.common.base.Optional; +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.internal.Arg0ToPagedIterable; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.Network; +import org.jclouds.openstack.neutron.v2.features.NetworkApi; +import org.jclouds.openstack.v2_0.options.PaginationOptions; + +import javax.inject.Inject; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Makes Networks work as a PagedIterable. + */ +public class NetworksToPagedIterable extends Arg0ToPagedIterable.FromCaller<Network, NetworksToPagedIterable> { + + private final NeutronApi api; + + @Inject + protected NetworksToPagedIterable(NeutronApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<Network>> markerToNextForArg0(Optional<Object> arg0) { + String region = arg0.isPresent() ? arg0.get().toString() : null; + final NetworkApi networkApi = api.getNetworkApi(region); + return new Function<Object, IterableWithMarker<Network>>() { + + @SuppressWarnings("unchecked") + @Override + public IterableWithMarker<Network> apply(Object input) { + PaginationOptions paginationOptions = PaginationOptions.class.cast(input); + return IterableWithMarker.class.cast(networkApi.list(paginationOptions)); + } + + @Override + public String toString() { + return "listNetworks()"; + } + }; + } + +} 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/functions/ParseFloatingIPs.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFloatingIPs.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFloatingIPs.java new file mode 100644 index 0000000..6529627 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseFloatingIPs.java @@ -0,0 +1,37 @@ +/* + * 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.functions; + +import com.google.inject.TypeLiteral; +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.openstack.neutron.v2.domain.FloatingIPs; + +import javax.inject.Inject; +import javax.inject.Singleton; + +/** + * Used by jclouds to provide more specific collections and fallbacks. + */ +@Singleton +public class ParseFloatingIPs extends ParseJson<FloatingIPs> { + + @Inject + public ParseFloatingIPs(Json json) { + super(json, TypeLiteral.get(FloatingIPs.class)); + } +} 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/functions/ParseNetworks.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseNetworks.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseNetworks.java new file mode 100644 index 0000000..0f9b8aa --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseNetworks.java @@ -0,0 +1,38 @@ +/* + * 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.functions; + + +import com.google.inject.TypeLiteral; +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.openstack.neutron.v2.domain.Networks; + +import javax.inject.Inject; +import javax.inject.Singleton; + +/** + * Used by jclouds to provide more specific collections and fallbacks. + */ +@Singleton +public class ParseNetworks extends ParseJson<Networks> { + + @Inject + public ParseNetworks(Json json) { + super(json, TypeLiteral.get(Networks.class)); + } +} 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/functions/ParsePorts.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParsePorts.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParsePorts.java new file mode 100644 index 0000000..ab169dd --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParsePorts.java @@ -0,0 +1,37 @@ +/* + * 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.functions; + +import com.google.inject.TypeLiteral; +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.openstack.neutron.v2.domain.Ports; + +import javax.inject.Inject; +import javax.inject.Singleton; + +/** + * Used by jclouds to provide more specific collections and fallbacks. + */ +@Singleton +public class ParsePorts extends ParseJson<Ports> { + + @Inject + public ParsePorts(Json json) { + super(json, TypeLiteral.get(Ports.class)); + } +} 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/functions/ParseRouters.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseRouters.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseRouters.java new file mode 100644 index 0000000..f0acde7 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseRouters.java @@ -0,0 +1,37 @@ +/* + * 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.functions; + +import com.google.inject.TypeLiteral; +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.openstack.neutron.v2.domain.Routers; + +import javax.inject.Inject; +import javax.inject.Singleton; + +/** + * Used by jclouds to provide more specific collections and fallbacks. + */ +@Singleton +public class ParseRouters extends ParseJson<Routers> { + + @Inject + public ParseRouters(Json json) { + super(json, TypeLiteral.get(Routers.class)); + } +} 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/functions/ParseRules.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseRules.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseRules.java new file mode 100644 index 0000000..954180b --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseRules.java @@ -0,0 +1,38 @@ +/* + * 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.functions; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.openstack.neutron.v2.domain.Rules; + +import com.google.inject.TypeLiteral; + +/** + * Used by jclouds to provide more specific collections and fallbacks. + */ +@Singleton +public class ParseRules extends ParseJson<Rules> { + + @Inject + public ParseRules(Json json) { + super(json, TypeLiteral.get(Rules.class)); + } +} 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/functions/ParseSecurityGroups.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseSecurityGroups.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseSecurityGroups.java new file mode 100644 index 0000000..3864781 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseSecurityGroups.java @@ -0,0 +1,38 @@ +/* + * 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.functions; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.openstack.neutron.v2.domain.SecurityGroups; + +import com.google.inject.TypeLiteral; + +/** + * Used by jclouds to provide more specific collections and fallbacks. + */ +@Singleton +public class ParseSecurityGroups extends ParseJson<SecurityGroups> { + + @Inject + public ParseSecurityGroups(Json json) { + super(json, TypeLiteral.get(SecurityGroups.class)); + } +} 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/functions/ParseSubnets.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseSubnets.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseSubnets.java new file mode 100644 index 0000000..0c985ee --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/ParseSubnets.java @@ -0,0 +1,37 @@ +/* + * 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.functions; + +import com.google.inject.TypeLiteral; +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.openstack.neutron.v2.domain.Subnets; + +import javax.inject.Inject; +import javax.inject.Singleton; + +/** + * Used by jclouds to provide more specific collections and fallbacks. + */ +@Singleton +public class ParseSubnets extends ParseJson<Subnets> { + + @Inject + public ParseSubnets(Json json) { + super(json, TypeLiteral.get(Subnets.class)); + } +} 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/functions/PortsToPagedIterable.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/PortsToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/PortsToPagedIterable.java new file mode 100644 index 0000000..cad5517 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/PortsToPagedIterable.java @@ -0,0 +1,64 @@ +/* + * 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.functions; + +import com.google.common.base.Function; +import com.google.common.base.Optional; +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.internal.Arg0ToPagedIterable; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.Port; +import org.jclouds.openstack.neutron.v2.features.PortApi; +import org.jclouds.openstack.v2_0.options.PaginationOptions; + +import javax.inject.Inject; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Ensures Ports works as a paged iterable. + */ +public class PortsToPagedIterable extends Arg0ToPagedIterable.FromCaller<Port, PortsToPagedIterable> { + + private final NeutronApi api; + + @Inject + protected PortsToPagedIterable(NeutronApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<Port>> markerToNextForArg0(Optional<Object> arg0) { + String region = arg0.isPresent() ? arg0.get().toString() : null; + final PortApi portApi = api.getPortApi(region); + return new Function<Object, IterableWithMarker<Port>>() { + + @SuppressWarnings("unchecked") + @Override + public IterableWithMarker<Port> apply(Object input) { + PaginationOptions paginationOptions = PaginationOptions.class.cast(input); + return IterableWithMarker.class.cast(portApi.list(paginationOptions)); + } + + @Override + public String toString() { + return "listPortsInDetail()"; + } + }; + } + +} 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/functions/RouterToPagedIterable.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/RouterToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/RouterToPagedIterable.java new file mode 100644 index 0000000..5ce4def --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/RouterToPagedIterable.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.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.internal.Arg0ToPagedIterable; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.Router; +import org.jclouds.openstack.neutron.v2.extensions.RouterApi; +import org.jclouds.openstack.v2_0.options.PaginationOptions; + +import com.google.common.base.Function; +import com.google.common.base.Optional; + +/** + * Ensures Routers works as PagedIterable. + */ +public class RouterToPagedIterable extends Arg0ToPagedIterable.FromCaller<Router, RouterToPagedIterable> { + + private final NeutronApi api; + + @Inject + protected RouterToPagedIterable(NeutronApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<Router>> markerToNextForArg0(Optional<Object> arg0) { + String region = arg0.isPresent() ? arg0.get().toString() : null; + final RouterApi routerApi = api.getRouterApi(region).get(); + return new Function<Object, IterableWithMarker<Router>>() { + + @SuppressWarnings("unchecked") + @Override + public IterableWithMarker<Router> apply(Object input) { + PaginationOptions paginationOptions = PaginationOptions.class.cast(input); + return IterableWithMarker.class.cast(routerApi.list(paginationOptions)); + } + + @Override + public String toString() { + return "listRouters()"; + } + }; + } + +} 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/functions/RulesToPagedIterable.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/RulesToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/RulesToPagedIterable.java new file mode 100644 index 0000000..d664cd6 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/RulesToPagedIterable.java @@ -0,0 +1,66 @@ +/* + * 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.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.internal.Arg0ToPagedIterable; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.Rule; +import org.jclouds.openstack.neutron.v2.extensions.SecurityGroupApi; +import org.jclouds.openstack.v2_0.options.PaginationOptions; + +import com.google.common.base.Function; +import com.google.common.base.Optional; + +/** + * Ensures Routers works as PagedIterable. + */ +public class RulesToPagedIterable extends + Arg0ToPagedIterable.FromCaller<Rule, RulesToPagedIterable> { + + private final NeutronApi api; + + @Inject + protected RulesToPagedIterable(NeutronApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<Rule>> markerToNextForArg0(Optional<Object> arg0) { + String region = arg0.isPresent() ? arg0.get().toString() : null; + final SecurityGroupApi securityGroupApi = api.getSecurityGroupApi(region).get(); + return new Function<Object, IterableWithMarker<Rule>>() { + + @SuppressWarnings("unchecked") + @Override + public IterableWithMarker<Rule> apply(Object input) { + PaginationOptions paginationOptions = PaginationOptions.class.cast(input); + return IterableWithMarker.class.cast(securityGroupApi.listRules(paginationOptions)); + } + + @Override + public String toString() { + return "listRules()"; + } + }; + } + +} 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/functions/SecurityGroupsToPagedIterable.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/SecurityGroupsToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/SecurityGroupsToPagedIterable.java new file mode 100644 index 0000000..15c7c14 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/SecurityGroupsToPagedIterable.java @@ -0,0 +1,66 @@ +/* + * 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.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.internal.Arg0ToPagedIterable; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.SecurityGroup; +import org.jclouds.openstack.neutron.v2.extensions.SecurityGroupApi; +import org.jclouds.openstack.v2_0.options.PaginationOptions; + +import com.google.common.base.Function; +import com.google.common.base.Optional; + +/** + * Ensures Routers works as PagedIterable. + */ +public class SecurityGroupsToPagedIterable extends + Arg0ToPagedIterable.FromCaller<SecurityGroup, SecurityGroupsToPagedIterable> { + + private final NeutronApi api; + + @Inject + protected SecurityGroupsToPagedIterable(NeutronApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<SecurityGroup>> markerToNextForArg0(Optional<Object> arg0) { + String region = arg0.isPresent() ? arg0.get().toString() : null; + final SecurityGroupApi securityGroupApi = api.getSecurityGroupApi(region).get(); + return new Function<Object, IterableWithMarker<SecurityGroup>>() { + + @SuppressWarnings("unchecked") + @Override + public IterableWithMarker<SecurityGroup> apply(Object input) { + PaginationOptions paginationOptions = PaginationOptions.class.cast(input); + return IterableWithMarker.class.cast(securityGroupApi.listSecurityGroups(paginationOptions)); + } + + @Override + public String toString() { + return "listSecurityGroups()"; + } + }; + } + +} 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/functions/SubnetsToPagedIterable.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/SubnetsToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/SubnetsToPagedIterable.java new file mode 100644 index 0000000..a5e6abe --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/SubnetsToPagedIterable.java @@ -0,0 +1,64 @@ +/* + * 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.functions; + +import com.google.common.base.Function; +import com.google.common.base.Optional; +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.internal.Arg0ToPagedIterable; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.Subnet; +import org.jclouds.openstack.neutron.v2.features.SubnetApi; +import org.jclouds.openstack.v2_0.options.PaginationOptions; + +import javax.inject.Inject; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Ensures Subnets works as a PagedIterable. + */ +public class SubnetsToPagedIterable extends Arg0ToPagedIterable.FromCaller<Subnet, SubnetsToPagedIterable> { + + private final NeutronApi api; + + @Inject + protected SubnetsToPagedIterable(NeutronApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<Subnet>> markerToNextForArg0(Optional<Object> arg0) { + String region = arg0.isPresent() ? arg0.get().toString() : null; + final SubnetApi subnetApi = api.getSubnetApi(region); + return new Function<Object, IterableWithMarker<Subnet>>() { + + @SuppressWarnings("unchecked") + @Override + public IterableWithMarker<Subnet> apply(Object input) { + PaginationOptions paginationOptions = PaginationOptions.class.cast(input); + return IterableWithMarker.class.cast(subnetApi.list(paginationOptions)); + } + + @Override + public String toString() { + return "listSubnets()"; + } + }; + } + +} 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/functions/lbaas/v1/HealthMonitorsToPagedIterable.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/HealthMonitorsToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/HealthMonitorsToPagedIterable.java new file mode 100644 index 0000000..e925b81 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/HealthMonitorsToPagedIterable.java @@ -0,0 +1,66 @@ +/* + * 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.functions.lbaas.v1; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.internal.Arg0ToPagedIterable; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitor; +import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi; +import org.jclouds.openstack.v2_0.options.PaginationOptions; + +import com.google.common.base.Function; +import com.google.common.base.Optional; + +/** + * Makes HealthMonitors work as a PagedIterable. + */ +public class HealthMonitorsToPagedIterable extends + Arg0ToPagedIterable.FromCaller<HealthMonitor, HealthMonitorsToPagedIterable> { + + private final NeutronApi api; + + @Inject + protected HealthMonitorsToPagedIterable(NeutronApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<HealthMonitor>> markerToNextForArg0(Optional<Object> arg0) { + String region = arg0.isPresent() ? arg0.get().toString() : null; + final LBaaSApi lbaasApi = api.getLBaaSApi(region).get(); + return new Function<Object, IterableWithMarker<HealthMonitor>>() { + + @SuppressWarnings("unchecked") + @Override + public IterableWithMarker<HealthMonitor> apply(Object input) { + PaginationOptions paginationOptions = PaginationOptions.class.cast(input); + return IterableWithMarker.class.cast(lbaasApi.listHealthMonitors(paginationOptions)); + } + + @Override + public String toString() { + return "listHealthMonitors()"; + } + }; + } + +} 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/functions/lbaas/v1/MembersToPagedIterable.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/MembersToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/MembersToPagedIterable.java new file mode 100644 index 0000000..23b1719 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/MembersToPagedIterable.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.functions.lbaas.v1; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.internal.Arg0ToPagedIterable; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Member; +import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi; +import org.jclouds.openstack.v2_0.options.PaginationOptions; + +import com.google.common.base.Function; +import com.google.common.base.Optional; + +/** + * Makes Members work as a PagedIterable. + */ +public class MembersToPagedIterable extends Arg0ToPagedIterable.FromCaller<Member, MembersToPagedIterable> { + + private final NeutronApi api; + + @Inject + protected MembersToPagedIterable(NeutronApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<Member>> markerToNextForArg0(Optional<Object> arg0) { + String region = arg0.isPresent() ? arg0.get().toString() : null; + final LBaaSApi lbaasApi = api.getLBaaSApi(region).get(); + return new Function<Object, IterableWithMarker<Member>>() { + + @SuppressWarnings("unchecked") + @Override + public IterableWithMarker<Member> apply(Object input) { + PaginationOptions paginationOptions = PaginationOptions.class.cast(input); + return IterableWithMarker.class.cast(lbaasApi.listMembers(paginationOptions)); + } + + @Override + public String toString() { + return "listMembers()"; + } + }; + } + +} 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/functions/lbaas/v1/ParseHealthMonitors.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseHealthMonitors.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseHealthMonitors.java new file mode 100644 index 0000000..d74ceaf --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseHealthMonitors.java @@ -0,0 +1,38 @@ +/* + * 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.functions.lbaas.v1; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitors; + +import com.google.inject.TypeLiteral; + +/** + * Used by jclouds to provide more specific collections and fallbacks. + */ +@Singleton +public class ParseHealthMonitors extends ParseJson<HealthMonitors> { + + @Inject + public ParseHealthMonitors(Json json) { + super(json, TypeLiteral.get(HealthMonitors.class)); + } +} 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/functions/lbaas/v1/ParseMembers.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseMembers.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseMembers.java new file mode 100644 index 0000000..252a5b0 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseMembers.java @@ -0,0 +1,38 @@ +/* + * 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.functions.lbaas.v1; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Members; + +import com.google.inject.TypeLiteral; + +/** + * Used by jclouds to provide more specific collections and fallbacks. + */ +@Singleton +public class ParseMembers extends ParseJson<Members> { + + @Inject + public ParseMembers(Json json) { + super(json, TypeLiteral.get(Members.class)); + } +} 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/functions/lbaas/v1/ParsePools.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParsePools.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParsePools.java new file mode 100644 index 0000000..adf81da --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParsePools.java @@ -0,0 +1,38 @@ +/* + * 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.functions.lbaas.v1; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pools; + +import com.google.inject.TypeLiteral; + +/** + * Used by jclouds to provide more specific collections and fallbacks. + */ +@Singleton +public class ParsePools extends ParseJson<Pools> { + + @Inject + public ParsePools(Json json) { + super(json, TypeLiteral.get(Pools.class)); + } +} 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/functions/lbaas/v1/ParseVIPs.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseVIPs.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseVIPs.java new file mode 100644 index 0000000..d97710c --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseVIPs.java @@ -0,0 +1,38 @@ +/* + * 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.functions.lbaas.v1; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.http.functions.ParseJson; +import org.jclouds.json.Json; +import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIPs; + +import com.google.inject.TypeLiteral; + +/** + * Used by jclouds to provide more specific collections and fallbacks. + */ +@Singleton +public class ParseVIPs extends ParseJson<VIPs> { + + @Inject + public ParseVIPs(Json json) { + super(json, TypeLiteral.get(VIPs.class)); + } +} 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/functions/lbaas/v1/PoolsToPagedIterable.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/PoolsToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/PoolsToPagedIterable.java new file mode 100644 index 0000000..c59b966 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/PoolsToPagedIterable.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.functions.lbaas.v1; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.internal.Arg0ToPagedIterable; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pool; +import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi; +import org.jclouds.openstack.v2_0.options.PaginationOptions; + +import com.google.common.base.Function; +import com.google.common.base.Optional; + +/** + * Makes Pools work as a PagedIterable. + */ +public class PoolsToPagedIterable extends Arg0ToPagedIterable.FromCaller<Pool, PoolsToPagedIterable> { + + private final NeutronApi api; + + @Inject + protected PoolsToPagedIterable(NeutronApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<Pool>> markerToNextForArg0(Optional<Object> arg0) { + String region = arg0.isPresent() ? arg0.get().toString() : null; + final LBaaSApi lbaasApi = api.getLBaaSApi(region).get(); + return new Function<Object, IterableWithMarker<Pool>>() { + + @SuppressWarnings("unchecked") + @Override + public IterableWithMarker<Pool> apply(Object input) { + PaginationOptions paginationOptions = PaginationOptions.class.cast(input); + return IterableWithMarker.class.cast(lbaasApi.listPools(paginationOptions)); + } + + @Override + public String toString() { + return "listPools()"; + } + }; + } + +} 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/functions/lbaas/v1/VIPsToPagedIterable.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/VIPsToPagedIterable.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/VIPsToPagedIterable.java new file mode 100644 index 0000000..5731b2f --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/VIPsToPagedIterable.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.functions.lbaas.v1; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.internal.Arg0ToPagedIterable; +import org.jclouds.openstack.neutron.v2.NeutronApi; +import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIP; +import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi; +import org.jclouds.openstack.v2_0.options.PaginationOptions; + +import com.google.common.base.Function; +import com.google.common.base.Optional; + +/** + * Makes VIPs work as a PagedIterable. + */ +public class VIPsToPagedIterable extends Arg0ToPagedIterable.FromCaller<VIP, VIPsToPagedIterable> { + + private final NeutronApi api; + + @Inject + protected VIPsToPagedIterable(NeutronApi api) { + this.api = checkNotNull(api, "api"); + } + + @Override + protected Function<Object, IterableWithMarker<VIP>> markerToNextForArg0(Optional<Object> arg0) { + String region = arg0.isPresent() ? arg0.get().toString() : null; + final LBaaSApi lbaasApi = api.getLBaaSApi(region).get(); + return new Function<Object, IterableWithMarker<VIP>>() { + + @SuppressWarnings("unchecked") + @Override + public IterableWithMarker<VIP> apply(Object input) { + PaginationOptions paginationOptions = PaginationOptions.class.cast(input); + return IterableWithMarker.class.cast(lbaasApi.listVIPs(paginationOptions)); + } + + @Override + public String toString() { + return "listVIPs()"; + } + }; + } + +} 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/handlers/NeutronErrorHandler.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/handlers/NeutronErrorHandler.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/handlers/NeutronErrorHandler.java new file mode 100644 index 0000000..5aaaae5 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/handlers/NeutronErrorHandler.java @@ -0,0 +1,62 @@ +/* + * 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.handlers; + +import org.jclouds.http.HttpCommand; +import org.jclouds.http.HttpErrorHandler; +import org.jclouds.http.HttpResponse; +import org.jclouds.http.HttpResponseException; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.ResourceNotFoundException; + +import javax.inject.Singleton; + +import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream; + +/** + * This will parse and set an appropriate exception on the command object. + */ +@Singleton +public class NeutronErrorHandler implements HttpErrorHandler { + public void handleError(HttpCommand command, HttpResponse response) { + // it is important to always read fully and close streams + byte[] data = closeClientButKeepContentStream(response); + String message = data != null ? new String(data) : null; + + Exception exception = message != null ? new HttpResponseException(command, response, message) + : new HttpResponseException(command, response); + message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), + response.getStatusLine()); + switch (response.getStatusCode()) { + case 400: + break; + case 401: + case 403: + exception = new AuthorizationException(message, exception); + break; + case 404: + if (!command.getCurrentRequest().getMethod().equals("DELETE")) { + exception = new ResourceNotFoundException(message, exception); + } + break; + case 409: + exception = new IllegalStateException(exception.getMessage(), exception); + break; + } + command.setException(exception); + } +} 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/options/EmptyOptions.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/options/EmptyOptions.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/options/EmptyOptions.java new file mode 100644 index 0000000..98205fc --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2/options/EmptyOptions.java @@ -0,0 +1,45 @@ +/* + * 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.options; + +import com.google.inject.Inject; +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.MapBinder; +import org.jclouds.rest.binders.BindToJsonPayload; + +import java.util.Map; + +/** + * This class is used for methods who don't need a wrapper around their JSON body + * + */ +public class EmptyOptions implements MapBinder { + + @Inject + private BindToJsonPayload jsonBinder; + + @Override + public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { + return bindToRequest(request, (Object) postParams); + } + + @Override + public <R extends HttpRequest> R bindToRequest(R request, Object input) { + return jsonBinder.bindToRequest(request, input); + } + +} 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_0/NeutronApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/NeutronApi.java b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/NeutronApi.java new file mode 100644 index 0000000..a5ff027 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-neutron/1.8.1-stratos/src/main/java/org/jclouds/openstack/neutron/v2_0/NeutronApi.java @@ -0,0 +1,134 @@ +/* + * 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_0; + +import java.io.Closeable; +import java.util.Set; + +import org.jclouds.location.Region; +import org.jclouds.location.Zone; +import org.jclouds.location.functions.RegionToEndpoint; +import org.jclouds.location.functions.ZoneToEndpoint; +import org.jclouds.openstack.neutron.v2_0.extensions.RouterApi; +import org.jclouds.openstack.neutron.v2_0.features.NetworkApi; +import org.jclouds.openstack.neutron.v2_0.features.PortApi; +import org.jclouds.openstack.neutron.v2_0.features.SubnetApi; +import org.jclouds.openstack.v2_0.features.ExtensionApi; +import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; + +import com.google.common.base.Optional; +import com.google.inject.Provides; + +/** + * Provides access to the OpenStack Networking (Neutron) v2 API. + * <p/> + * + * @deprecated Please use {@link org.jclouds.openstack.neutron.v2.NeutronApi} as this + * interface will be removed in jclouds 3.0. + */ +@Deprecated +public interface NeutronApi extends Closeable { + + /** + * @return the Region codes configured + */ + @Provides + @Region + Set<String> getConfiguredRegions(); + + /** + * Provides access to Extension features. + */ + @Delegate + ExtensionApi getExtensionApi(@EndpointParam(parser = RegionToEndpoint.class) String region); + + /** + * Provides access to Network features. + */ + @Delegate + NetworkApi getNetworkApi(@EndpointParam(parser = RegionToEndpoint.class) String region); + + /** + * Provides access to Subnet features. + */ + @Delegate + SubnetApi getSubnetApi(@EndpointParam(parser = RegionToEndpoint.class) String region); + + /** + * Provides access to Port features. + */ + @Delegate + PortApi getPortApi(@EndpointParam(parser = RegionToEndpoint.class) String region); + + /** + * Provides access to Router features. + */ + @Delegate + Optional<? extends RouterApi> getRouterApi(@EndpointParam(parser = RegionToEndpoint.class) String region); + + /** + * @return the Zone codes configured + * @deprecated Please use {@link #getConfiguredRegions()} as this method will be removed in jclouds 3.0. + */ + @Deprecated + @Provides + @Zone + Set<String> getConfiguredZones(); + + /** + * Provides access to Extension features. + * @deprecated Please use {@link #getExtensionApi(String)} as this method will be removed in jclouds 3.0. + */ + @Deprecated + @Delegate + ExtensionApi getExtensionApiForZone( + @EndpointParam(parser = ZoneToEndpoint.class) String zone); + + /** + * Provides access to Network features. + * @deprecated Please use {@link #getNetworkApi(String)} as this method will be removed in jclouds 3.0. + */ + @Deprecated + @Delegate + NetworkApi getNetworkApiForZone(@EndpointParam(parser = ZoneToEndpoint.class) String zone); + + /** + * Provides access to Subnet features. + * @deprecated Please use {@link #getSubnetApi(String)} as this method will be removed in jclouds 3.0. + */ + @Deprecated + @Delegate + SubnetApi getSubnetApiForZone(@EndpointParam(parser = ZoneToEndpoint.class) String zone); + + /** + * Provides access to Port features. + * @deprecated Please use {@link #getPortApi(String)} as this method will be removed in jclouds 3.0. + */ + @Deprecated + @Delegate + PortApi getPortApiForZone(@EndpointParam(parser = ZoneToEndpoint.class) String zone); + + /** + * Provides access to Router features. + * @deprecated Please use {@link #getRouterApi(String)} as this method will be removed in jclouds 3.0. + */ + @Deprecated + @Delegate + Optional<? extends RouterApi> getRouterExtensionForZone(@EndpointParam(parser = ZoneToEndpoint.class) String zone); +}
