Updated Branches: refs/heads/master 86147cd96 -> 7651657cf
Remove async interface support from OpenStack Cinder API Project: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/commit/7651657c Tree: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/tree/7651657c Diff: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/diff/7651657c Branch: refs/heads/master Commit: 7651657cfc3cd5ca14e083a588a369a3929c0530 Parents: 86147cd Author: Jeremy Daggett <[email protected]> Authored: Tue Jun 4 15:17:50 2013 -0700 Committer: Everett Toews <[email protected]> Committed: Thu Jun 6 11:08:21 2013 -0500 ---------------------------------------------------------------------- .../openstack/cinder/v1/CinderApiMetadata.java | 28 +--- .../openstack/cinder/v1/CinderAsyncApi.java | 79 ----------- .../cinder/v1/config/CinderHttpApiModule.java | 64 +++++++++ .../cinder/v1/config/CinderRestClientModule.java | 94 ------------- .../openstack/cinder/v1/features/SnapshotApi.java | 59 ++++++++- .../cinder/v1/features/SnapshotAsyncApi.java | 109 --------------- .../openstack/cinder/v1/features/VolumeApi.java | 58 ++++++++- .../cinder/v1/features/VolumeAsyncApi.java | 109 --------------- .../cinder/v1/features/VolumeTypeApi.java | 30 ++++- .../cinder/v1/features/VolumeTypeAsyncApi.java | 69 --------- .../uk/CloudBlockStorageUKProviderMetadata.java | 8 +- .../us/CloudBlockStorageUSProviderMetadata.java | 8 +- 12 files changed, 219 insertions(+), 496 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/7651657c/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/CinderApiMetadata.java ---------------------------------------------------------------------- diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/CinderApiMetadata.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/CinderApiMetadata.java index 580a6fc..28e0c5b 100644 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/CinderApiMetadata.java +++ b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/CinderApiMetadata.java @@ -23,17 +23,16 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.openstack.cinder.v1.config.CinderHttpApiModule; import org.jclouds.openstack.cinder.v1.config.CinderParserModule; -import org.jclouds.openstack.cinder.v1.config.CinderRestClientModule; +import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule; import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule; -import org.jclouds.openstack.keystone.v2_0.config.MappedAuthenticationApiModule; import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.rest.internal.BaseHttpApiMetadata; import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; import com.google.inject.Module; /** @@ -41,17 +40,8 @@ import com.google.inject.Module; * * @author Everett Toews */ -public class CinderApiMetadata extends BaseRestApiMetadata { +public class CinderApiMetadata extends BaseHttpApiMetadata<CinderApi> { - /** - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CinderApi.class)} as - * {@link CinderAsyncApi} interface will be removed in jclouds 1.7. - */ - @Deprecated - public static final TypeToken<org.jclouds.rest.RestContext<CinderApi, CinderAsyncApi>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<CinderApi, CinderAsyncApi>>() { - private static final long serialVersionUID = 1L; - }; - @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -66,17 +56,15 @@ public class CinderApiMetadata extends BaseRestApiMetadata { } public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); + Properties properties = BaseHttpApiMetadata.defaultProperties(); properties.setProperty(SERVICE_TYPE, ServiceType.BLOCK_STORAGE); properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS); return properties; } - public static class Builder extends BaseRestApiMetadata.Builder<Builder> { + public static class Builder extends BaseHttpApiMetadata.Builder<CinderApi, Builder> { - @SuppressWarnings("deprecation") protected Builder() { - super(CinderApi.class, CinderAsyncApi.class); id("openstack-cinder") .name("OpenStack Cinder Folsom API") .identityName("${tenantName}:${userName} or ${userName}, if your keystone supports a default tenant") @@ -87,11 +75,11 @@ public class CinderApiMetadata extends BaseRestApiMetadata { .defaultEndpoint("http://localhost:5000/v2.0/") .defaultProperties(CinderApiMetadata.defaultProperties()) .defaultModules(ImmutableSet.<Class<? extends Module>>builder() - .add(MappedAuthenticationApiModule.class) + .add(AuthenticationApiModule.class) .add(KeystoneAuthenticationModule.class) .add(ZoneModule.class) .add(CinderParserModule.class) - .add(CinderRestClientModule.class) + .add(CinderHttpApiModule.class) .build()); } http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/7651657c/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/CinderAsyncApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/CinderAsyncApi.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/CinderAsyncApi.java deleted file mode 100644 index a54448c..0000000 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/CinderAsyncApi.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.cinder.v1; - -import java.io.Closeable; -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.Zone; -import org.jclouds.location.functions.ZoneToEndpoint; -import org.jclouds.openstack.cinder.v1.features.SnapshotAsyncApi; -import org.jclouds.openstack.cinder.v1.features.VolumeAsyncApi; -import org.jclouds.openstack.cinder.v1.features.VolumeTypeAsyncApi; -import org.jclouds.openstack.v2_0.features.ExtensionAsyncApi; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.EndpointParam; - -import com.google.inject.Provides; - -/** - * Provides asynchronous access to Cinder via its REST API. - * - * @see CinderApi - * @see <a href="http://api.openstack.org/">API Doc</a> - * @author Everett Toews - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CinderApi.class)} as - * {@link CinderAsyncApi} interface will be removed in jclouds 1.7. - */ -@Deprecated -public interface CinderAsyncApi extends Closeable { - /** - * @return the Zone codes configured - */ - @Provides - @Zone - Set<String> getConfiguredZones(); - - /** - * Provides asynchronous access to Extension features. - */ - @Delegate - ExtensionAsyncApi getExtensionApiForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Volume features. - */ - @Delegate - VolumeAsyncApi getVolumeApiForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to VolumeType features. - */ - @Delegate - VolumeTypeAsyncApi getVolumeTypeApiForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Snapshot features. - */ - @Delegate - SnapshotAsyncApi getSnapshotApiForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); -} http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/7651657c/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/config/CinderHttpApiModule.java ---------------------------------------------------------------------- diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/config/CinderHttpApiModule.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/config/CinderHttpApiModule.java new file mode 100644 index 0000000..311135c --- /dev/null +++ b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/config/CinderHttpApiModule.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.cinder.v1.config; + +import java.net.URI; + +import javax.inject.Singleton; + +import org.jclouds.http.HttpErrorHandler; +import org.jclouds.http.annotation.ClientError; +import org.jclouds.http.annotation.Redirection; +import org.jclouds.http.annotation.ServerError; +import org.jclouds.json.config.GsonModule.DateAdapter; +import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; +import org.jclouds.openstack.cinder.v1.CinderApi; +import org.jclouds.openstack.cinder.v1.handlers.CinderErrorHandler; +import org.jclouds.rest.ConfiguresHttpApi; +import org.jclouds.rest.config.HttpApiModule; + +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.Multimap; +import com.google.inject.Provides; + +/** + * Configures the Cinder connection. + * + * @author Everett Toews + */ +@ConfiguresHttpApi +public class CinderHttpApiModule extends HttpApiModule<CinderApi> { + + @Override + protected void configure() { + bind(DateAdapter.class).to(Iso8601DateAdapter.class); + super.configure(); + } + + @Provides + @Singleton + public Multimap<URI, URI> aliases() { + return ImmutableMultimap.<URI, URI>builder().build(); + } + + @Override + protected void bindErrorHandlers() { + bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(CinderErrorHandler.class); + bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(CinderErrorHandler.class); + bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(CinderErrorHandler.class); + } +} http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/7651657c/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/config/CinderRestClientModule.java ---------------------------------------------------------------------- diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/config/CinderRestClientModule.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/config/CinderRestClientModule.java deleted file mode 100644 index 3de17b5..0000000 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/config/CinderRestClientModule.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.cinder.v1.config; - -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.net.URI; -import java.util.Map; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.json.config.GsonModule.DateAdapter; -import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; -import org.jclouds.openstack.cinder.v1.CinderApi; -import org.jclouds.openstack.cinder.v1.CinderAsyncApi; -import org.jclouds.openstack.cinder.v1.features.SnapshotApi; -import org.jclouds.openstack.cinder.v1.features.SnapshotAsyncApi; -import org.jclouds.openstack.cinder.v1.features.VolumeApi; -import org.jclouds.openstack.cinder.v1.features.VolumeAsyncApi; -import org.jclouds.openstack.cinder.v1.features.VolumeTypeApi; -import org.jclouds.openstack.cinder.v1.features.VolumeTypeAsyncApi; -import org.jclouds.openstack.cinder.v1.handlers.CinderErrorHandler; -import org.jclouds.openstack.v2_0.features.ExtensionApi; -import org.jclouds.openstack.v2_0.features.ExtensionAsyncApi; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; -import com.google.common.reflect.TypeToken; -import com.google.inject.Provides; - -/** - * Configures the Cinder connection. - * - * @author Everett Toews - */ -@ConfiguresRestClient -public class CinderRestClientModule<S extends CinderApi, A extends CinderAsyncApi> extends RestClientModule<S, A> { - - public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder() - .put(ExtensionApi.class, ExtensionAsyncApi.class) - .put(VolumeApi.class, VolumeAsyncApi.class) - .put(VolumeTypeApi.class, VolumeTypeAsyncApi.class) - .put(SnapshotApi.class, SnapshotAsyncApi.class) - .build(); - - @SuppressWarnings("unchecked") - public CinderRestClientModule() { - super(TypeToken.class.cast(typeToken(CinderApi.class)), TypeToken.class.cast(typeToken(CinderAsyncApi.class)), DELEGATE_MAP); - } - - protected CinderRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType, Map<Class<?>, Class<?>> sync2Async) { - super(syncClientType, asyncClientType, sync2Async); - } - - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - super.configure(); - } - - @Provides - @Singleton - public Multimap<URI, URI> aliases() { - return ImmutableMultimap.<URI, URI>builder().build(); - } - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(CinderErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(CinderErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(CinderErrorHandler.class); - } -} http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/7651657c/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/SnapshotApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/SnapshotApi.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/SnapshotApi.java index b6511b6..ab16211 100644 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/SnapshotApi.java +++ b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/SnapshotApi.java @@ -16,24 +16,51 @@ */ package org.jclouds.openstack.cinder.v1.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.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; +import org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.openstack.cinder.v1.domain.Snapshot; import org.jclouds.openstack.cinder.v1.options.CreateSnapshotOptions; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +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.SelectJson; +import org.jclouds.rest.annotations.SkipEncoding; import com.google.common.collect.FluentIterable; /** * Provides synchronous access to Volume Snapshots via their REST API. * - * @see SnapshotAsyncApi * @see <a href="http://api.openstack.org/">API Doc</a> * @author Everett Toews */ +@SkipEncoding({'/', '='}) +@RequestFilters(AuthenticateRequest.class) public interface SnapshotApi { /** * Returns a summary list of Snapshots. * * @return The list of Snapshots */ + @Named("snapshot:list") + @GET + @Path("/snapshots") + @SelectJson("snapshots") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptyFluentIterableOnNotFoundOr404.class) FluentIterable<? extends Snapshot> list(); /** @@ -41,6 +68,12 @@ public interface SnapshotApi { * * @return The list of Snapshots */ + @Named("snapshot:list") + @GET + @Path("/snapshots/detail") + @SelectJson("snapshots") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptyFluentIterableOnNotFoundOr404.class) FluentIterable<? extends Snapshot> listInDetail(); /** @@ -49,7 +82,13 @@ public interface SnapshotApi { * @param snapshotId Id of the Snapshot * @return Details of a specific Snapshot */ - Snapshot get(String snapshotId); + @Named("snapshot:get") + @GET + @Path("/snapshots/{id}") + @SelectJson("snapshot") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + Snapshot get(@PathParam("id") String snapshotId); /** * Creates a new Snapshot. The Volume status must be Available. @@ -58,7 +97,14 @@ public interface SnapshotApi { * @param options See CreateSnapshotOptions * @return The new Snapshot */ - Snapshot create(String volumeId, CreateSnapshotOptions... options); + @Named("snapshot:create") + @POST + @Path("/snapshots") + @SelectJson("snapshot") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @MapBinder(CreateSnapshotOptions.class) + Snapshot create(@PayloadParam("volume_id") String volumeId, CreateSnapshotOptions... options); /** * Delete a Snapshot. @@ -66,5 +112,10 @@ public interface SnapshotApi { * @param snapshotId Id of the Snapshot * @return true if successful, false otherwise */ - boolean delete(String snapshotId); + @Named("snapshot:delete") + @DELETE + @Path("/snapshots/{id}") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(FalseOnNotFoundOr404.class) + boolean delete(@PathParam("id") String snapshotId); } http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/7651657c/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/SnapshotAsyncApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/SnapshotAsyncApi.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/SnapshotAsyncApi.java deleted file mode 100644 index 838a4da..0000000 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/SnapshotAsyncApi.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.cinder.v1.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.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; -import org.jclouds.Fallbacks.FalseOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.openstack.cinder.v1.domain.Snapshot; -import org.jclouds.openstack.cinder.v1.options.CreateSnapshotOptions; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -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.SelectJson; -import org.jclouds.rest.annotations.SkipEncoding; - -import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Snapshots. - * - * @see SnapshotApi - * @see <a href="http://api.openstack.org/">API Doc</a> - * @author Everett Toews - */ -@SkipEncoding({'/', '='}) -@RequestFilters(AuthenticateRequest.class) -public interface SnapshotAsyncApi { - /** - * @see SnapshotApi#list() - */ - @Named("snapshot:list") - @GET - @Path("/snapshots") - @SelectJson("snapshots") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture<? extends FluentIterable<? extends Snapshot>> list(); - - /** - * @see SnapshotApi#listInDetail() - */ - @Named("snapshot:list") - @GET - @Path("/snapshots/detail") - @SelectJson("snapshots") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture<? extends FluentIterable<? extends Snapshot>> listInDetail(); - - /** - * @see SnapshotApi#get(String) - */ - @Named("snapshot:get") - @GET - @Path("/snapshots/{id}") - @SelectJson("snapshot") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends Snapshot> get(@PathParam("id") String snapshotId); - - /** - * @see SnapshotApi#create(String, CreateSnapshotOptions...) - */ - @Named("snapshot:create") - @POST - @Path("/snapshots") - @SelectJson("snapshot") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @MapBinder(CreateSnapshotOptions.class) - ListenableFuture<? extends Snapshot> create(@PayloadParam("volume_id") String volumeId, CreateSnapshotOptions... options); - - /** - * @see SnapshotApi#delete(String) - */ - @Named("snapshot:delete") - @DELETE - @Path("/snapshots/{id}") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture<Boolean> delete(@PathParam("id") String snapshotId); -} http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/7651657c/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeApi.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeApi.java index fd92a54..f6fbc8a 100644 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeApi.java +++ b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeApi.java @@ -16,8 +16,28 @@ */ package org.jclouds.openstack.cinder.v1.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.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; +import org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.openstack.cinder.v1.domain.Volume; import org.jclouds.openstack.cinder.v1.options.CreateVolumeOptions; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +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.SelectJson; +import org.jclouds.rest.annotations.SkipEncoding; import com.google.common.collect.FluentIterable; @@ -31,12 +51,20 @@ import com.google.common.collect.FluentIterable; * @see <a href="http://api.openstack.org/">API Doc</a> * @author Everett Toews */ +@SkipEncoding({'/', '='}) +@RequestFilters(AuthenticateRequest.class) public interface VolumeApi { /** * Returns a summary list of Volumes. * * @return The list of Volumes */ + @Named("volume:list") + @GET + @Path("/volumes") + @SelectJson("volumes") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptyFluentIterableOnNotFoundOr404.class) FluentIterable<? extends Volume> list(); /** @@ -44,6 +72,12 @@ public interface VolumeApi { * * @return The list of Volumes */ + @Named("volume:list") + @GET + @Path("/volumes/detail") + @SelectJson("volumes") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptyFluentIterableOnNotFoundOr404.class) FluentIterable<? extends Volume> listInDetail(); /** @@ -52,7 +86,13 @@ public interface VolumeApi { * @param volumeId Id of the Volume * @return Details of a specific Volume */ - Volume get(String volumeId); + @Named("volume:get") + @GET + @Path("/volumes/{id}") + @SelectJson("volume") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + Volume get(@PathParam("id") String volumeId); /** * Creates a new Volume @@ -61,7 +101,14 @@ public interface VolumeApi { * @param options See CreateVolumeOptions * @return The new Volume */ - Volume create(int sizeGB, CreateVolumeOptions... options); + @Named("volume:create") + @POST + @Path("/volumes") + @SelectJson("volume") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @MapBinder(CreateVolumeOptions.class) + Volume create(@PayloadParam("size") int sizeGB, CreateVolumeOptions... options); /** * Delete a Volume. The Volume status must be Available or Error. @@ -69,5 +116,10 @@ public interface VolumeApi { * @param volumeId Id of the Volume * @return true if successful, false otherwise */ - boolean delete(String volumeId); + @Named("volume:delete") + @DELETE + @Path("/volumes/{id}") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(FalseOnNotFoundOr404.class) + boolean delete(@PathParam("id") String volumeId); } http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/7651657c/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeAsyncApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeAsyncApi.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeAsyncApi.java deleted file mode 100644 index 83d6f00..0000000 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeAsyncApi.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.cinder.v1.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.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; -import org.jclouds.Fallbacks.FalseOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.openstack.cinder.v1.domain.Volume; -import org.jclouds.openstack.cinder.v1.options.CreateVolumeOptions; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -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.SelectJson; -import org.jclouds.rest.annotations.SkipEncoding; - -import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Volumes. - * - * @see VolumeApi - * @see <a href="http://api.openstack.org/">API Doc</a> - * @author Everett Toews - */ -@SkipEncoding({'/', '='}) -@RequestFilters(AuthenticateRequest.class) -public interface VolumeAsyncApi { - /** - * @see VolumeApi#list() - */ - @Named("volume:list") - @GET - @Path("/volumes") - @SelectJson("volumes") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture<? extends FluentIterable<? extends Volume>> list(); - - /** - * @see VolumeApi#listInDetail() - */ - @Named("volume:list") - @GET - @Path("/volumes/detail") - @SelectJson("volumes") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture<? extends FluentIterable<? extends Volume>> listInDetail(); - - /** - * @see VolumeApi#get(String) - */ - @Named("volume:get") - @GET - @Path("/volumes/{id}") - @SelectJson("volume") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends Volume> get(@PathParam("id") String volumeId); - - /** - * @see VolumeApi#create(int, CreateVolumeOptions...) - */ - @Named("volume:create") - @POST - @Path("/volumes") - @SelectJson("volume") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @MapBinder(CreateVolumeOptions.class) - ListenableFuture<? extends Volume> create(@PayloadParam("size") int sizeGB, CreateVolumeOptions... options); - - /** - * @see VolumeApi#delete(String) - */ - @Named("volume:delete") - @DELETE - @Path("/volumes/{id}") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture<Boolean> delete(@PathParam("id") String volumeId); -} http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/7651657c/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeApi.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeApi.java index 9163185..7ee4c7d 100644 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeApi.java +++ b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeApi.java @@ -16,7 +16,21 @@ */ package org.jclouds.openstack.cinder.v1.features; +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.openstack.cinder.v1.domain.VolumeType; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.SkipEncoding; import com.google.common.collect.FluentIterable; @@ -27,12 +41,20 @@ import com.google.common.collect.FluentIterable; * @see <a href="http://api.openstack.org/">API Doc</a> * @author Everett Toews */ +@SkipEncoding({'/', '='}) +@RequestFilters(AuthenticateRequest.class) public interface VolumeTypeApi { /** * Returns a summary list of VolumeTypes. * * @return The list of VolumeTypes */ + @Named("volumetype:list") + @GET + @Path("/types") + @SelectJson("volume_types") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptyFluentIterableOnNotFoundOr404.class) FluentIterable<? extends VolumeType> list(); /** @@ -41,5 +63,11 @@ public interface VolumeTypeApi { * @param volumeTypeId Id of the VolumeType * @return Details of a specific VolumeType */ - VolumeType get(String volumeTypeId); + @Named("volumetype:get") + @GET + @Path("/types/{id}") + @SelectJson("volume_type") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + VolumeType get(@PathParam("id") String volumeTypeId); } http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/7651657c/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeAsyncApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeAsyncApi.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeAsyncApi.java deleted file mode 100644 index 0d066f9..0000000 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/features/VolumeTypeAsyncApi.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.cinder.v1.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.openstack.cinder.v1.domain.VolumeType; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.annotations.SkipEncoding; - -import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to VolumeTypes. - * - * @see VolumeTypeApi - * @see <a href="http://api.openstack.org/">API Doc</a> - * @author Everett Toews - */ -@SkipEncoding({'/', '='}) -@RequestFilters(AuthenticateRequest.class) -public interface VolumeTypeAsyncApi { - /** - * @see VolumeTypeApi#list() - */ - @Named("volumetype:list") - @GET - @Path("/types") - @SelectJson("volume_types") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture<? extends FluentIterable<? extends VolumeType>> list(); - - /** - * @see VolumeTypeApi#get(String) - */ - @Named("volumetype:get") - @GET - @Path("/types/{id}") - @SelectJson("volume_type") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends VolumeType> get(@PathParam("id") String volumeTypeId); -} http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/7651657c/providers/rackspace-cloudblockstorage-uk/src/main/java/org/jclouds/rackspace/cloudblockstorage/uk/CloudBlockStorageUKProviderMetadata.java ---------------------------------------------------------------------- diff --git a/providers/rackspace-cloudblockstorage-uk/src/main/java/org/jclouds/rackspace/cloudblockstorage/uk/CloudBlockStorageUKProviderMetadata.java b/providers/rackspace-cloudblockstorage-uk/src/main/java/org/jclouds/rackspace/cloudblockstorage/uk/CloudBlockStorageUKProviderMetadata.java index 00f2df4..5b72e79 100644 --- a/providers/rackspace-cloudblockstorage-uk/src/main/java/org/jclouds/rackspace/cloudblockstorage/uk/CloudBlockStorageUKProviderMetadata.java +++ b/providers/rackspace-cloudblockstorage-uk/src/main/java/org/jclouds/rackspace/cloudblockstorage/uk/CloudBlockStorageUKProviderMetadata.java @@ -25,14 +25,14 @@ import java.net.URI; import java.util.Properties; import org.jclouds.openstack.cinder.v1.CinderApiMetadata; +import org.jclouds.openstack.cinder.v1.config.CinderHttpApiModule; import org.jclouds.openstack.cinder.v1.config.CinderParserModule; -import org.jclouds.openstack.cinder.v1.config.CinderRestClientModule; import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; +import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; -import org.jclouds.rackspace.cloudidentity.v2_0.config.SyncToAsyncCloudIdentityAuthenticationApiModule; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; @@ -81,11 +81,11 @@ public class CloudBlockStorageUKProviderMetadata extends BaseProviderMetadata { .endpointName("identity service url ending in /v2.0/") .documentation(URI.create("http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/overview.html")) .defaultModules(ImmutableSet.<Class<? extends Module>>builder() - .add(SyncToAsyncCloudIdentityAuthenticationApiModule.class) + .add(CloudIdentityAuthenticationApiModule.class) .add(CloudIdentityAuthenticationModule.class) .add(ZoneModule.class) .add(CinderParserModule.class) - .add(CinderRestClientModule.class).build()) + .add(CinderHttpApiModule.class).build()) .build()) .homepage(URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-block-storage/")) .console(URI.create("https://mycloud.rackspace.co.uk")) http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/7651657c/providers/rackspace-cloudblockstorage-us/src/main/java/org/jclouds/rackspace/cloudblockstorage/us/CloudBlockStorageUSProviderMetadata.java ---------------------------------------------------------------------- diff --git a/providers/rackspace-cloudblockstorage-us/src/main/java/org/jclouds/rackspace/cloudblockstorage/us/CloudBlockStorageUSProviderMetadata.java b/providers/rackspace-cloudblockstorage-us/src/main/java/org/jclouds/rackspace/cloudblockstorage/us/CloudBlockStorageUSProviderMetadata.java index 1b1cdc8..1500003 100644 --- a/providers/rackspace-cloudblockstorage-us/src/main/java/org/jclouds/rackspace/cloudblockstorage/us/CloudBlockStorageUSProviderMetadata.java +++ b/providers/rackspace-cloudblockstorage-us/src/main/java/org/jclouds/rackspace/cloudblockstorage/us/CloudBlockStorageUSProviderMetadata.java @@ -25,14 +25,14 @@ import java.net.URI; import java.util.Properties; import org.jclouds.openstack.cinder.v1.CinderApiMetadata; +import org.jclouds.openstack.cinder.v1.config.CinderHttpApiModule; import org.jclouds.openstack.cinder.v1.config.CinderParserModule; -import org.jclouds.openstack.cinder.v1.config.CinderRestClientModule; import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; +import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule; import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; -import org.jclouds.rackspace.cloudidentity.v2_0.config.SyncToAsyncCloudIdentityAuthenticationApiModule; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; @@ -82,11 +82,11 @@ public class CloudBlockStorageUSProviderMetadata extends BaseProviderMetadata { .endpointName("identity service url ending in /v2.0/") .documentation(URI.create("http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/overview.html")) .defaultModules(ImmutableSet.<Class<? extends Module>>builder() - .add(SyncToAsyncCloudIdentityAuthenticationApiModule.class) + .add(CloudIdentityAuthenticationApiModule.class) .add(CloudIdentityAuthenticationModule.class) .add(ZoneModule.class) .add(CinderParserModule.class) - .add(CinderRestClientModule.class).build()) + .add(CinderHttpApiModule.class).build()) .build()) .homepage(URI.create("http://www.rackspace.com/cloud/public/blockstorage/")) .console(URI.create("https://mycloud.rackspace.com"))
