You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2014/03/31 09:13:56 UTC
[43/52] [partial] Moving jclouds dependencies to accurate parent
directories
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageAsyncApi.java
new file mode 100644
index 0000000..f45826c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageAsyncApi.java
@@ -0,0 +1,206 @@
+/*
+ * 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.nova.v2_0.features;
+
+import java.util.Map;
+
+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.EmptyMapOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.binders.BindMetadataToJsonPayload;
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+import org.jclouds.openstack.nova.v2_0.functions.internal.OnlyMetadataValueOrNull;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseImageDetails;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseImages;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+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.binders.BindToJsonPayload;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to Images via the REST API.
+ * <p/>
+ *
+ * @see ImageApi
+ * @author Jeremy Daggett
+ */
+@RequestFilters(AuthenticateRequest.class)
+public interface ImageAsyncApi {
+
+ /**
+ * @see ImageApi#list()
+ */
+ @Named("image:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/images")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseImages.class)
+ @Transform(ParseImages.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends PagedIterable<? extends Resource>> list();
+
+ /** @see ImageApi#list(PaginationOptions) */
+ @Named("image:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/images")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseImages.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ ListenableFuture<? extends PaginatedCollection<? extends Resource>> list(PaginationOptions options);
+
+ /**
+ * @see ImageApi#listInDetail()
+ */
+ @Named("image:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/images/detail")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseImageDetails.class)
+ @Transform(ParseImageDetails.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends PagedIterable<? extends Image>> listInDetail();
+
+ /** @see ImageApi#listInDetail(PaginationOptions) */
+ @Named("image:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/images/detail")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseImageDetails.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ ListenableFuture<? extends PaginatedCollection<? extends Image>> listInDetail(PaginationOptions options);
+
+ /**
+ * @see ImageApi#get
+ */
+ @Named("image:get")
+ @GET
+ @SelectJson("image")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/images/{id}")
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends Image> get(@PathParam("id") String id);
+
+ /**
+ * @see ImageApi#delete
+ */
+ @Named("image:delete")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/images/{id}")
+ @Fallback(VoidOnNotFoundOr404.class)
+ ListenableFuture<Void> delete(@PathParam("id") String id);
+
+ /**
+ * @see ImageApi#getMetadata
+ */
+ @Named("image:getmetadata")
+ @GET
+ @SelectJson("metadata")
+ @Path("/images/{id}/metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyMapOnNotFoundOr404.class)
+ ListenableFuture<Map<String, String>> getMetadata(@PathParam("id") String id);
+
+ /**
+ * @see ImageApi#setMetadata
+ */
+ @Named("image:setmetadata")
+ @PUT
+ @SelectJson("metadata")
+ @Path("/images/{id}/metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyMapOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ ListenableFuture<Map<String, String>> setMetadata(@PathParam("id") String id, @PayloadParam("metadata") Map<String, String> metadata);
+
+ /**
+ * @see ImageApi#updateMetadata
+ */
+ @Named("image:updatemetadata")
+ @POST
+ @SelectJson("metadata")
+ @Path("/images/{id}/metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyMapOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ ListenableFuture<? extends Map<String, String>> updateMetadata(@PathParam("id") String id, @PayloadParam("metadata") Map<String, String> metadata);
+
+ /**
+ * @see ImageApi#getMetadata
+ */
+ @Named("image:getmetadata")
+ @GET
+ @Path("/images/{id}/metadata/{key}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(OnlyMetadataValueOrNull.class)
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<String> getMetadata(@PathParam("id") String id, @PathParam("key") String key);
+
+ /**
+ * @see ImageApi#updateMetadata
+ */
+ @Named("image:updatemetadata")
+ @PUT
+ @Path("/images/{id}/metadata/{key}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ResponseParser(OnlyMetadataValueOrNull.class)
+ @MapBinder(BindMetadataToJsonPayload.class)
+ ListenableFuture<String> updateMetadata(@PathParam("id") String id,
+ @PathParam("key") @PayloadParam("key") String key, @PathParam("value") @PayloadParam("value") String value);
+
+
+ /**
+ * @see ImageApi#deleteMetadata
+ */
+ @Named("image:deletemetadata")
+ @DELETE
+ @Consumes
+ @Path("/images/{id}/metadata/{key}")
+ @Fallback(VoidOnNotFoundOr404.class)
+ ListenableFuture<Void> deleteMetadata(@PathParam("id") String id, @PathParam("key") String key);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java
new file mode 100644
index 0000000..9354d9a
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java
@@ -0,0 +1,276 @@
+/*
+ * 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.nova.v2_0.features;
+
+import com.google.common.base.Optional;
+import java.util.Map;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.domain.RebootType;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
+import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions;
+import org.jclouds.openstack.nova.v2_0.options.RebuildServerOptions;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * Provides synchronous access to Server.
+ * <p/>
+ *
+ * @see ServerAsyncApi
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-compute/1.1/content/Servers-d1e2073.html"
+ * />
+ * @author Adrian Cole
+ */
+public interface ServerApi {
+
+ /**
+ * List all servers (IDs, names, links)
+ *
+ * @return all servers (IDs, names, links)
+ */
+ PagedIterable<? extends Resource> list();
+
+ PaginatedCollection<? extends Resource> list(PaginationOptions options);
+
+ /**
+ * List all servers (all details)
+ *
+ * @return all servers (all details)
+ */
+ PagedIterable<? extends Server> listInDetail();
+
+ PaginatedCollection<? extends Server> listInDetail(PaginationOptions options);
+
+ /**
+ * List details of the specified server
+ *
+ * @param id
+ * id of the server
+ * @return server or null if not found
+ */
+ Server get(String id);
+
+ /**
+ * Create a new server
+ *
+ * @param name
+ * name of the server to create
+ * @param imageRef
+ * reference to the image for the server to use
+ * @param flavorRef
+ * reference to the flavor to use when creating the server
+ * @param options
+ * optional parameters to be passed into the server creation
+ * request
+ * @return the newly created server
+ */
+ ServerCreated create(String name, String imageRef, String flavorRef, CreateServerOptions... options);
+
+ /**
+ * Terminate and delete a server.
+ *
+ * @param id
+ * id of the server
+ * @return True if successful, False otherwise
+ */
+ boolean delete(String id);
+
+ /**
+ * Start a server
+ *
+ * @param id
+ * id of the server
+ */
+ void start(String id);
+
+ /**
+ * Stop a server
+ *
+ * @param id
+ * id of the server
+ */
+ void stop(String id);
+
+ /**
+ * Reboot a server.
+ *
+ * @param id
+ * id of the server
+ * @param rebootType
+ * The type of reboot to perform (Hard/Soft)
+ */
+ void reboot(String id, RebootType rebootType);
+
+ /**
+ * Resize a server to a new flavor size.
+ *
+ * @param id
+ * id of the server
+ * @param flavorId
+ * id of the new flavor to use
+ */
+ void resize(String id, String flavorId);
+
+ /**
+ * Confirm a resize operation.
+ *
+ * @param id
+ * id of the server
+ */
+ void confirmResize(String id);
+
+ /**
+ * Revert a resize operation.
+ *
+ * @param id
+ * id of the server
+ */
+ void revertResize(String id);
+
+ /**
+ * Rebuild a server.
+ *
+ * @param id
+ * id of the server
+ * @param options
+ * Optional parameters to the rebuilding operation.
+ */
+ void rebuild(String id, RebuildServerOptions... options);
+
+ /**
+ * Change the administrative password to a server.
+ *
+ * @param id
+ * id of the server
+ * @param adminPass
+ * The new administrative password to use
+ */
+ void changeAdminPass(String id, String adminPass);
+
+ /**
+ * Rename a server.
+ *
+ * @param id
+ * id of the server
+ * @param newName
+ * The new name for the server
+ */
+ void rename(String id, String newName);
+
+ /**
+ * Create an image from a server.
+ *
+ * @param name
+ * The name of the new image
+ * @param id
+ * id of the server
+ *
+ * @return ID of the new / updated image
+ */
+ String createImageFromServer(String name, String id);
+
+ /**
+ * List all metadata for a server.
+ *
+ * @param id
+ * id of the server
+ *
+ * @return the metadata as a Map<String, String>
+ */
+ Map<String, String> getMetadata(String id);
+
+ /**
+ * Set the metadata for a server.
+ *
+ * @param id
+ * id of the server
+ * @param metadata
+ * a Map containing the metadata
+ * @return the metadata as a Map<String, String>
+ */
+ Map<String, String> setMetadata(String id, Map<String, String> metadata);
+
+ /**
+ * Update the metadata for a server.
+ *
+ * @param id
+ * id of the server
+ * @param metadata
+ * a Map containing the metadata
+ * @return the metadata as a Map<String, String>
+ */
+ Map<String, String> updateMetadata(String id, Map<String, String> metadata);
+
+ /**
+ * Update the metadata for a server.
+ *
+ * @param id
+ * id of the image
+ * @param metadata
+ * a Map containing the metadata
+ * @return the value or null if not present
+ */
+ @Nullable
+ String getMetadata(String id, String key);
+
+ /**
+ * Set a metadata item for a server.
+ *
+ * @param id
+ * id of the image
+ * @param key
+ * the name of the metadata item
+ * @param value
+ * the value of the metadata item
+ * @return the value you updated
+ */
+ String updateMetadata(String id, String key, String value);
+
+ /**
+ * Delete a metadata item from a server.
+ *
+ * @param id
+ * id of the image
+ * @param key
+ * the name of the metadata item
+ */
+ void deleteMetadata(String id, String key);
+
+
+ /**
+ * Get usage information about the server such as CPU usage, Memory and IO.
+ * The information returned by this method is dependent on the hypervisor
+ * in use by the OpenStack installation and whether that hypervisor supports
+ * this method. More information can be found in the
+ * <a href="http://api.openstack.org/api-ref.html"> OpenStack API
+ * reference</a>. <br/>
+ * At the moment the returned response is a generic map. In future versions
+ * of OpenStack this might be subject to change.
+ *
+ * @param id
+ * id of the server
+ * @return A Map containing the collected values organized by key - value.
+ * @Beta
+ */
+ Optional<Map<String, String>> getDiagnostics(String id);
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncApi.java
new file mode 100644
index 0000000..2d63d65
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncApi.java
@@ -0,0 +1,356 @@
+/*
+ * 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.nova.v2_0.features;
+
+import java.util.Map;
+
+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.AbsentOn403Or404Or500;
+import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
+import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.binders.BindMetadataToJsonPayload;
+import org.jclouds.openstack.nova.v2_0.domain.RebootType;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
+import org.jclouds.openstack.nova.v2_0.functions.ParseImageIdFromLocationHeader;
+import org.jclouds.openstack.nova.v2_0.functions.internal.OnlyMetadataValueOrNull;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseDiagnostics;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServerDetails;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServers;
+import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions;
+import org.jclouds.openstack.nova.v2_0.options.RebuildServerOptions;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.Payload;
+import org.jclouds.rest.annotations.PayloadParam;
+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.Unwrap;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to Server via their REST API.
+ * <p/>
+ *
+ * @see ServerApi
+ * @see <a href= "http://docs.openstack.org/api/openstack-compute/1.1/content/Servers-d1e2073.html"
+ * />
+ * @author Adrian Cole
+ */
+@RequestFilters(AuthenticateRequest.class)
+public interface ServerAsyncApi {
+
+ /**
+ * @see ServerApi#list()
+ */
+ @Named("server:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/servers")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseServers.class)
+ @Transform(ParseServers.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends PagedIterable<? extends Resource>> list();
+
+ /** @see ServerApi#list(PaginationOptions) */
+ @Named("server:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/servers")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseServers.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ ListenableFuture<? extends PaginatedCollection<? extends Resource>> list(PaginationOptions options);
+
+ /**
+ * @see ServerApi#listInDetail()
+ */
+ @Named("server:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/servers/detail")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseServerDetails.class)
+ @Transform(ParseServerDetails.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends PagedIterable<? extends Server>> listInDetail();
+
+ /** @see ServerApi#listInDetail(PaginationOptions) */
+ @Named("server:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/servers/detail")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseServerDetails.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ ListenableFuture<? extends PaginatedCollection<? extends Server>> listInDetail(PaginationOptions options);
+
+ /**
+ * @see ServerApi#get
+ */
+ @Named("server:get")
+ @GET
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/servers/{id}")
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends Server> get(@PathParam("id") String id);
+
+ /**
+ * @see ServerApi#delete
+ */
+ @Named("server:delete")
+ @DELETE
+ @Consumes
+ @Fallback(FalseOnNotFoundOr404.class)
+ @Path("/servers/{id}")
+ ListenableFuture<Boolean> delete(@PathParam("id") String id);
+
+ /**
+ * @see ServerApi#start
+ */
+ @Named("server:start")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"os-start\":null}")
+ ListenableFuture<Void> start(@PathParam("id") String id);
+
+ /**
+ * @see ServerApi#stop
+ */
+ @Named("server:stop")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"os-stop\":null}")
+ ListenableFuture<Void> stop(@PathParam("id") String id);
+
+ /**
+ * @see ServerApi#reboot
+ */
+ @Named("server:reboot")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"reboot\":%7B\"type\":\"{type}\"%7D%7D")
+ ListenableFuture<Void> reboot(@PathParam("id") String id, @PayloadParam("type") RebootType rebootType);
+
+ /**
+ * @see ServerApi#resize
+ */
+ @Named("server:resize")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"resize\":%7B\"flavorRef\":{flavorId}%7D%7D")
+ ListenableFuture<Void> resize(@PathParam("id") String id, @PayloadParam("flavorId") String flavorId);
+
+ /**
+ * @see ServerApi#confirmResize
+ */
+ @Named("server:resize")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"confirmResize\":null}")
+ ListenableFuture<Void> confirmResize(@PathParam("id") String id);
+
+ /**
+ * @see ServerApi#revertResize
+ */
+ @Named("server:resize")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"revertResize\":null}")
+ ListenableFuture<Void> revertResize(@PathParam("id") String id);
+
+ /**
+ * @see ServerApi#create
+ */
+ @Named("server:create")
+ @POST
+ @Unwrap
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/servers")
+ @MapBinder(CreateServerOptions.class)
+ ListenableFuture<ServerCreated> create(@PayloadParam("name") String name, @PayloadParam("imageRef") String imageRef,
+ @PayloadParam("flavorRef") String flavorRef, CreateServerOptions... options);
+
+ /**
+ * @see ServerApi#rebuild
+ */
+ @Named("server:rebuild")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @MapBinder(RebuildServerOptions.class)
+ ListenableFuture<Void> rebuild(@PathParam("id") String id, RebuildServerOptions... options);
+
+ /**
+ * @see ServerApi#changeAdminPass
+ */
+ @Named("server:changeadminpass")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"changePassword\":%7B\"adminPass\":\"{adminPass}\"%7D%7D")
+ ListenableFuture<Void> changeAdminPass(@PathParam("id") String id, @PayloadParam("adminPass") String adminPass);
+
+ /**
+ * @see ServerApi#rename
+ */
+ @Named("server:rename")
+ @PUT
+ @Path("/servers/{id}")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"server\":%7B\"name\":\"{name}\"%7D%7D")
+ ListenableFuture<Void> rename(@PathParam("id") String id, @PayloadParam("name") String newName);
+
+ /**
+ * @see ServerApi#createImageFromServer
+ */
+ @Named("server:create")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"createImage\":%7B\"name\":\"{name}\", \"metadata\": %7B%7D%7D%7D")
+ @Fallback(MapHttp4xxCodesToExceptions.class)
+ @ResponseParser(ParseImageIdFromLocationHeader.class)
+ ListenableFuture<String> createImageFromServer(@PayloadParam("name") String name, @PathParam("id") String id);
+
+ /**
+ * @see ServerApi#getMetadata
+ */
+ @Named("server:getmetadata")
+ @GET
+ @SelectJson("metadata")
+ @Path("/servers/{id}/metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyMapOnNotFoundOr404.class)
+ ListenableFuture<? extends Map<String, String>> getMetadata(@PathParam("id") String id);
+
+ /**
+ * @see ServerApi#setMetadata
+ */
+ @Named("server:setmetadata")
+ @PUT
+ @SelectJson("metadata")
+ @Path("/servers/{id}/metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyMapOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ ListenableFuture<? extends Map<String, String>> setMetadata(@PathParam("id") String id,
+ @PayloadParam("metadata") Map<String, String> metadata);
+
+ /**
+ * @see ServerApi#updateMetadata
+ */
+ @Named("server:updatemetadata")
+ @POST
+ @SelectJson("metadata")
+ @Path("/servers/{id}/metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyMapOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ ListenableFuture<? extends Map<String, String>> updateMetadata(@PathParam("id") String id,
+ @PayloadParam("metadata") Map<String, String> metadata);
+
+ /**
+ * @see ServerApi#getMetadata
+ */
+ @Named("server:getmetadata")
+ @GET
+ @Path("/servers/{id}/metadata/{key}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(OnlyMetadataValueOrNull.class)
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<String> getMetadata(@PathParam("id") String id, @PathParam("key") String key);
+
+ /**
+ * @see ServerApi#updateMetadata
+ */
+ @Named("server:updatemetadata")
+ @PUT
+ @Path("/servers/{id}/metadata/{key}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ResponseParser(OnlyMetadataValueOrNull.class)
+ @MapBinder(BindMetadataToJsonPayload.class)
+ ListenableFuture<String> updateMetadata(@PathParam("id") String id,
+ @PathParam("key") @PayloadParam("key") String key, @PathParam("value") @PayloadParam("value") String value);
+
+ /**
+ * @see ServerApi#deleteMetadata
+ */
+ @Named("server:deletemetadata")
+ @DELETE
+ @Consumes
+ @Path("/servers/{id}/metadata/{key}")
+ @Fallback(VoidOnNotFoundOr404.class)
+ ListenableFuture<Void> deleteMetadata(@PathParam("id") String id, @PathParam("key") String key);
+
+
+ /**
+ * @see ServerApi#getDiagnostics
+ */
+ @Named("server:getdiagnostics")
+ @GET
+ @Path("/servers/{id}/diagnostics")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(AbsentOn403Or404Or500.class)
+ @ResponseParser(ParseDiagnostics.class)
+ ListenableFuture<Optional<Map<String, String>>> getDiagnostics(@PathParam("id") String id);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/FieldValueResponseParsers.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/FieldValueResponseParsers.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/FieldValueResponseParsers.java
new file mode 100644
index 0000000..f137c59
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/FieldValueResponseParsers.java
@@ -0,0 +1,105 @@
+/*
+ * 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.nova.v2_0.functions;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.functions.ParseFirstJsonValueNamed;
+import org.jclouds.json.internal.GsonWrapper;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Parsers for extracting a single field value from a response and comparing it to an expected value
+ */
+public class FieldValueResponseParsers {
+ @Singleton
+ public static class StatusEnabledResponseParser extends FieldValueResponseParser<String> {
+ @Inject
+ public StatusEnabledResponseParser(GsonWrapper wrapper) {
+ super(wrapper, "status", "enabled");
+ }
+ }
+
+ @Singleton
+ public static class StatusDisabledResponseParser extends FieldValueResponseParser<String> {
+ @Inject
+ public StatusDisabledResponseParser(GsonWrapper wrapper) {
+ super(wrapper, "status", "disabled");
+ }
+ }
+
+ @Singleton
+ public static class MaintenanceModeEnabledResponseParser extends FieldValueResponseParser<String> {
+ @Inject
+ public MaintenanceModeEnabledResponseParser(GsonWrapper wrapper) {
+ super(wrapper, "maintenance_mode", "on_maintenance");
+ }
+ }
+
+ @Singleton
+ public static class MaintenanceModeDisabledResponseParser extends FieldValueResponseParser<String> {
+ @Inject
+ public MaintenanceModeDisabledResponseParser(GsonWrapper wrapper) {
+ super(wrapper, "maintenance_mode", "off_maintenance");
+ }
+ }
+
+ @Singleton
+ public static class PowerIsStartupResponseParser extends FieldValueResponseParser<String> {
+ @Inject
+ public PowerIsStartupResponseParser(GsonWrapper wrapper) {
+ super(wrapper, "power_action", "startup");
+ }
+ }
+
+ @Singleton
+ public static class PowerIsShutdownResponseParser extends FieldValueResponseParser<String> {
+ @Inject
+ public PowerIsShutdownResponseParser(GsonWrapper wrapper) {
+ super(wrapper, "power_action", "shutdown");
+ }
+ }
+
+ @Singleton
+ public static class PowerIsRebootResponseParser extends FieldValueResponseParser<String> {
+ @Inject
+ public PowerIsRebootResponseParser(GsonWrapper wrapper) {
+ super(wrapper, "power_action", "reboot");
+ }
+ }
+
+ public abstract static class FieldValueResponseParser<T> implements Function<HttpResponse, Boolean> {
+ private final T expectedValue;
+ private final ParseFirstJsonValueNamed<T> valueParser;
+
+ public FieldValueResponseParser(GsonWrapper wrapper, String fieldName, T expectedValue) {
+ valueParser = new ParseFirstJsonValueNamed<T>(wrapper, new TypeLiteral<T>() {
+ }, fieldName);
+ this.expectedValue = expectedValue;
+ }
+
+ @Override
+ public Boolean apply(HttpResponse response) {
+ return Objects.equal(expectedValue, valueParser.apply(response));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.java
new file mode 100644
index 0000000..9627ece
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.java
@@ -0,0 +1,92 @@
+/*
+ * 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.nova.v2_0.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+
+import org.jclouds.json.Json;
+import org.jclouds.logging.Logger;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ *
+ * The expected body contains the time as in this (real) response
+ *
+ * <pre>
+ * {
+ * "overLimit" : {
+ * "code" : 413,
+ * "message" : "OverLimit Retry...",
+ * "details" : "Error Details...",
+ * "retryAt" : "2012-11-14T21:51:28UTC"
+ * }
+ * }
+ * </pre>
+ *
+ * or
+ *
+ * <pre>
+ * {
+ * "overLimit": {
+ * "message": "This request was rate-limited.",
+ * "code": 413,
+ * "retryAfter": "54",
+ * "details": "Only 1 POST request(s) can be made to \"*\" every minute."
+ * }
+ * }
+ * </pre>
+ *
+ * @author Adrian Cole, Steve Loughran
+ *
+ */
+public class OverLimitParser implements Function<String, Map<String, String>> {
+
+ @Resource
+ private Logger logger = Logger.NULL;
+ private final Json json;
+
+ @Inject
+ public OverLimitParser(Json json) {
+ this.json = checkNotNull(json, "json");
+ }
+
+ private static class Holder {
+ Map<String, String> overLimit = ImmutableMap.of();
+ }
+
+ /**
+ * parses or returns an empty map.
+ */
+ @Override
+ public Map<String, String> apply(String in) {
+ try {
+ return json.fromJson(in, OverLimitParser.Holder.class).overLimit;
+ } catch (RuntimeException e) {
+ // an error was raised during parsing -which can include badly
+ // formatted fields.
+ logger.error("Failed to parse " + in + "", e);
+ return ImmutableMap.of();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java
new file mode 100644
index 0000000..1ca6f68
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java
@@ -0,0 +1,39 @@
+/*
+ * 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.nova.v2_0.functions;
+
+import javax.inject.Singleton;
+import javax.ws.rs.core.HttpHeaders;
+
+import org.jclouds.http.HttpResponse;
+
+import com.google.common.base.Function;
+
+/**
+ * This parses {@link Image} from the body of the link in the Location header of the HTTPResponse.
+ *
+ * @author Tim Miller
+ */
+@Singleton
+public class ParseImageIdFromLocationHeader implements Function<HttpResponse, String> {
+
+ public String apply(HttpResponse response) {
+ String location = response.getFirstHeaderOrNull(HttpHeaders.LOCATION);
+ String[] parts = location.split("/");
+ return parts[parts.length - 1];
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java
new file mode 100644
index 0000000..8183f84
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java
@@ -0,0 +1,63 @@
+/*
+ * 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.nova.v2_0.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.internal.GsonWrapper;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class OnlyMetadataValueOrNull implements Function<HttpResponse, String> {
+ private final ParseJson<Wrapper> parser;
+
+ private static class Wrapper implements Supplier<String> {
+ private Map<String, String> metadata;
+
+ @Override
+ public String get() {
+ return metadata == null ? null : Iterables.get(metadata.values(), 0, null);
+ }
+
+ }
+
+ @Inject
+ public OnlyMetadataValueOrNull(GsonWrapper gsonView) {
+ this.parser = new ParseJson<Wrapper>(checkNotNull(gsonView, "gsonView"), new TypeLiteral<Wrapper>() {
+ });
+ }
+
+ public String apply(HttpResponse response) {
+ checkNotNull(response, "response");
+ return parser.apply(response).get();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java
new file mode 100644
index 0000000..366aa4c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java
@@ -0,0 +1,47 @@
+/*
+ * 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.nova.v2_0.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.functions.ParseJson;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.inject.Inject;
+import java.util.Map;
+
+/**
+ * @author Leander Beernaert
+ */
+public class ParseDiagnostics implements Function<HttpResponse, Optional <Map<String,String>>> {
+
+
+ private final ParseJson<Optional <Map<String,String>>> parser;
+
+ @Inject
+ public ParseDiagnostics(ParseJson<Optional <Map<String,String>>> parser) {
+ this.parser = parser;
+ }
+
+ @Override
+ public Optional <Map<String,String>> apply(HttpResponse response) {
+ checkNotNull(response, "response");
+ return parser.apply(response);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java
new file mode 100644
index 0000000..7e15016
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java
@@ -0,0 +1,94 @@
+/*
+ * 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.nova.v2_0.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavorDetails.Flavors;
+import org.jclouds.openstack.v2_0.domain.Link;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * boiler plate until we determine a better way
+ *
+ * @author Adrian Cole
+ */
+@Beta
+@Singleton
+public class ParseFlavorDetails extends ParseJson<Flavors> {
+ static class Flavors extends PaginatedCollection<Flavor> {
+
+ @ConstructorProperties({ "flavors", "flavors_links" })
+ protected Flavors(Iterable<Flavor> flavors, Iterable<Link> flavors_links) {
+ super(flavors, flavors_links);
+ }
+
+ }
+
+ @Inject
+ public ParseFlavorDetails(Json json) {
+ super(json, TypeLiteral.get(Flavors.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Flavor, ToPagedIterable> {
+
+ private final NovaApi api;
+
+ @Inject
+ protected ToPagedIterable(NovaApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Flavor>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.get().toString();
+ final FlavorApi flavorApi = api.getFlavorApiForZone(zone);
+ return new Function<Object, IterableWithMarker<Flavor>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Flavor> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(flavorApi.listInDetail(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listFlavorsInDetail()";
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java
new file mode 100644
index 0000000..5d183f4
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java
@@ -0,0 +1,96 @@
+/*
+ * 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.nova.v2_0.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavors.Flavors;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * boiler plate until we determine a better way
+ *
+ * @author Adrian Cole
+ */
+@Beta
+@Singleton
+public class ParseFlavors extends ParseJson<Flavors> {
+ static class Flavors extends PaginatedCollection<Resource> {
+
+ @ConstructorProperties({ "flavors", "flavors_links" })
+ protected Flavors(Iterable<Resource> flavors, Iterable<Link> flavors_links) {
+ super(flavors, flavors_links);
+ }
+
+ }
+
+ @Inject
+ public ParseFlavors(Json json) {
+ super(json, TypeLiteral.get(Flavors.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Resource, ToPagedIterable> {
+
+ private final NovaApi api;
+
+ @Inject
+ protected ToPagedIterable(NovaApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.get().toString();
+ final FlavorApi flavorApi = api.getFlavorApiForZone(zone);
+ return new Function<Object, IterableWithMarker<Resource>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Resource> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(flavorApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listFlavors()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java
new file mode 100644
index 0000000..c69103a
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java
@@ -0,0 +1,95 @@
+/*
+ * 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.nova.v2_0.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+import org.jclouds.openstack.nova.v2_0.features.ImageApi;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseImageDetails.Images;
+import org.jclouds.openstack.v2_0.domain.Link;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * boiler plate until we determine a better way
+ *
+ * @author Adrian Cole
+ */
+@Beta
+@Singleton
+public class ParseImageDetails extends ParseJson<Images> {
+ static class Images extends PaginatedCollection<Image> {
+
+ @ConstructorProperties({ "images", "images_links" })
+ protected Images(Iterable<Image> images, Iterable<Link> images_links) {
+ super(images, images_links);
+ }
+
+ }
+
+ @Inject
+ public ParseImageDetails(Json json) {
+ super(json, TypeLiteral.get(Images.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Image, ToPagedIterable> {
+
+ private final NovaApi api;
+
+ @Inject
+ protected ToPagedIterable(NovaApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Image>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.get().toString();
+ final ImageApi imageApi = api.getImageApiForZone(zone);
+ return new Function<Object, IterableWithMarker<Image>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Image> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(imageApi.listInDetail(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listInDetail()";
+ }
+ };
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java
new file mode 100644
index 0000000..a939134
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java
@@ -0,0 +1,96 @@
+/*
+ * 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.nova.v2_0.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.features.ImageApi;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseImages.Images;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * boiler plate until we determine a better way
+ *
+ * @author Adrian Cole
+ */
+@Beta
+@Singleton
+public class ParseImages extends ParseJson<Images> {
+ static class Images extends PaginatedCollection<Resource> {
+
+ @ConstructorProperties({ "images", "images_links" })
+ protected Images(Iterable<Resource> images, Iterable<Link> images_links) {
+ super(images, images_links);
+ }
+
+ }
+
+ @Inject
+ public ParseImages(Json json) {
+ super(json, TypeLiteral.get(Images.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Resource, ToPagedIterable> {
+
+ private final NovaApi api;
+
+ @Inject
+ protected ToPagedIterable(NovaApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.get().toString();
+ final ImageApi imageApi = api.getImageApiForZone(zone);
+ return new Function<Object, IterableWithMarker<Resource>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Resource> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(imageApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "list()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.java
new file mode 100644
index 0000000..96566ff
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.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.nova.v2_0.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.functions.ParseFirstJsonValueNamed;
+import org.jclouds.json.internal.GsonWrapper;
+import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.FluentIterable;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class ParseKeyPairs implements Function<HttpResponse, FluentIterable<? extends KeyPair>> {
+ private final ParseFirstJsonValueNamed<FluentIterable<Wrapper>> parser;
+
+ private static class Wrapper implements Supplier<KeyPair> {
+ private KeyPair keypair;
+
+ @Override
+ public KeyPair get() {
+ return keypair;
+ }
+
+ }
+
+ @Inject
+ public ParseKeyPairs(GsonWrapper gsonView) {
+ this.parser = new ParseFirstJsonValueNamed<FluentIterable<Wrapper>>(checkNotNull(gsonView, "gsonView"),
+ new TypeLiteral<FluentIterable<Wrapper>>() {
+ }, "keypairs");
+ }
+
+ public FluentIterable<? extends KeyPair> apply(HttpResponse response) {
+ checkNotNull(response, "response");
+ return parser.apply(response).transform(Suppliers.<KeyPair> supplierFunction());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java
new file mode 100644
index 0000000..4af2cea
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java
@@ -0,0 +1,94 @@
+/*
+ * 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.nova.v2_0.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.features.ServerApi;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServerDetails.Servers;
+import org.jclouds.openstack.v2_0.domain.Link;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * boiler plate until we determine a better way
+ *
+ * @author Adrian Cole
+ */
+@Beta
+@Singleton
+public class ParseServerDetails extends ParseJson<Servers> {
+ static class Servers extends PaginatedCollection<Server> {
+
+ @ConstructorProperties({ "servers", "servers_links" })
+ protected Servers(Iterable<Server> servers, Iterable<Link> servers_links) {
+ super(servers, servers_links);
+ }
+
+ }
+
+ @Inject
+ public ParseServerDetails(Json json) {
+ super(json, TypeLiteral.get(Servers.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Server, ToPagedIterable> {
+
+ private final NovaApi api;
+
+ @Inject
+ protected ToPagedIterable(NovaApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Server>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.get().toString();
+ final ServerApi serverApi = api.getServerApiForZone(zone);
+ return new Function<Object, IterableWithMarker<Server>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Server> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(serverApi.listInDetail(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listInDetail()";
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java
new file mode 100644
index 0000000..2de8c76
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java
@@ -0,0 +1,96 @@
+/*
+ * 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.nova.v2_0.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.features.ServerApi;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServers.Servers;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * boiler plate until we determine a better way
+ *
+ * @author Adrian Cole
+ */
+@Beta
+@Singleton
+public class ParseServers extends ParseJson<Servers> {
+ static class Servers extends PaginatedCollection<Resource> {
+
+ @ConstructorProperties({ "servers", "servers_links" })
+ protected Servers(Iterable<Resource> servers, Iterable<Link> servers_links) {
+ super(servers, servers_links);
+ }
+
+ }
+
+ @Inject
+ public ParseServers(Json json) {
+ super(json, TypeLiteral.get(Servers.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Resource, ToPagedIterable> {
+
+ private final NovaApi api;
+
+ @Inject
+ protected ToPagedIterable(NovaApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.get().toString();
+ final ServerApi serverApi = api.getServerApiForZone(zone);
+ return new Function<Object, IterableWithMarker<Resource>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Resource> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(serverApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "list()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java
new file mode 100644
index 0000000..4bfb51b
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java
@@ -0,0 +1,129 @@
+/*
+ * 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.nova.v2_0.handlers;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Predicates.in;
+import static com.google.common.base.Strings.emptyToNull;
+import static com.google.common.collect.Maps.filterKeys;
+import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
+
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.date.DateCodecFactory;
+import org.jclouds.fallbacks.HeaderToRetryAfterException;
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.logging.Logger;
+import org.jclouds.openstack.nova.v2_0.functions.OverLimitParser;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.InsufficientResourcesException;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.jclouds.rest.RetryAfterException;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Ticker;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * This will parse and set an appropriate exception on the command object.
+ *
+ * @author Adrian Cole, Steve Loughran
+ *
+ */
+// TODO: is there error spec someplace? let's type errors, etc.
+@Singleton
+public class NovaErrorHandler implements HttpErrorHandler {
+
+ @Resource
+ protected Logger logger = Logger.NULL;
+ protected final HeaderToRetryAfterException retryAfterParser;
+ protected final OverLimitParser overLimitParser;
+
+ protected NovaErrorHandler(HeaderToRetryAfterException retryAfterParser, OverLimitParser overLimitParser) {
+ this.retryAfterParser = checkNotNull(retryAfterParser, "retryAfterParser");
+ this.overLimitParser = checkNotNull(overLimitParser, "overLimitParser");
+ }
+
+ /**
+ * in current format, retryAt has a value of {@code 2012-11-14T21:51:28UTC}, which is an ISO-8601 seconds (not milliseconds) format.
+ */
+ @Inject
+ public NovaErrorHandler(DateCodecFactory factory, OverLimitParser overLimitParser) {
+ this(HeaderToRetryAfterException.create(Ticker.systemTicker(), factory.iso8601Seconds()), overLimitParser);
+ }
+
+ public void handleError(HttpCommand command, HttpResponse response) {
+ // it is important to always read fully and close streams
+ byte[] data = closeClientButKeepContentStream(response);
+ String content = data != null ? emptyToNull(new String(data)) : null;
+
+ Exception exception = content != null ? new HttpResponseException(command, response, content)
+ : new HttpResponseException(command, response);
+ String requestLine = command.getCurrentRequest().getRequestLine();
+ String message = content != null ? content : String.format("%s -> %s", requestLine, response.getStatusLine());
+ switch (response.getStatusCode()) {
+ case 400:
+ if (message.indexOf("quota exceeded") != -1)
+ exception = new InsufficientResourcesException(message, exception);
+ else if (message.indexOf("has no fixed_ips") != -1)
+ exception = new IllegalStateException(message, exception);
+ else if (message.indexOf("already exists") != -1)
+ exception = new IllegalStateException(message, exception);
+ 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 413:
+ if (content == null) {
+ exception = new InsufficientResourcesException(message, exception);
+ break;
+ }
+ exception = parseAndBuildRetryException(content, message, exception);
+ }
+ command.setException(exception);
+ }
+
+ /**
+ * Build an exception from the response. If it contains the JSON payload then
+ * that is parsed to create a {@link RetryAfterException}, otherwise a
+ * {@link InsufficientResourcesException} is returned
+ *
+ */
+ private Exception parseAndBuildRetryException(String json, String message, Exception exception) {
+ Set<String> retryFields = ImmutableSet.of("retryAfter", "retryAt");
+ for (String value : filterKeys(overLimitParser.apply(json), in(retryFields)).values()) {
+ Optional<RetryAfterException> retryException = retryAfterParser.tryCreateRetryAfterException(exception, value);
+ if (retryException.isPresent())
+ return retryException.get();
+ }
+ return new InsufficientResourcesException(message, exception);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java
new file mode 100644
index 0000000..e6002e5
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java
@@ -0,0 +1,105 @@
+/*
+ * 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.nova.v2_0.options;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+/**
+ * @author Adam Lowe
+ */
+public class CreateBackupOfServerOptions implements MapBinder {
+ public static final CreateBackupOfServerOptions NONE = new CreateBackupOfServerOptions();
+
+ @Inject
+ protected BindToJsonPayload jsonBinder;
+
+ private Map<String, String> metadata = ImmutableMap.of();
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ Map<String, Object> data = Maps.newHashMap();
+ data.putAll(postParams);
+ data.put("metadata", metadata);
+ return jsonBinder.bindToRequest(request, ImmutableMap.of("createBackup", data));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
+ throw new IllegalStateException("createBackup is a POST operation");
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (!(object instanceof CreateBackupOfServerOptions)) return false;
+ final CreateBackupOfServerOptions other = CreateBackupOfServerOptions.class.cast(object);
+ return equal(metadata, other.metadata);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(metadata);
+ }
+
+ protected ToStringHelper string() {
+ return toStringHelper("").add("metadata", metadata);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ /** @see #getMetadata() */
+ public CreateBackupOfServerOptions metadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ return this;
+ }
+
+ /**
+ * Extra image properties to include
+ */
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public static class Builder {
+ /**
+ * @see CreateBackupOfServerOptions#getMetadata()
+ */
+ public static CreateBackupOfServerOptions metadata(Map<String, String> metadata) {
+ return new CreateBackupOfServerOptions().metadata(metadata);
+ }
+ }
+
+}