JCLOUDS-296 unasync keystone used by swift derivatives and cloudfiles.
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/dda43dfc Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/dda43dfc Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/dda43dfc Branch: refs/heads/use-agentproxy-008 Commit: dda43dfc32955e2a0ab17f02577d69a2ec58282c Parents: c13220d Author: Adrian Cole <[email protected]> Authored: Fri Oct 3 19:09:40 2014 -0700 Committer: Adrian Cole <[email protected]> Committed: Fri Oct 3 23:13:54 2014 -0700 ---------------------------------------------------------------------- .../keystone/v2_0/AuthenticationAsyncApi.java | 93 ----------- .../keystone/v2_0/KeystoneApiMetadata.java | 9 - .../keystone/v2_0/KeystoneAsyncApi.java | 117 ------------- .../config/KeystoneAuthenticationModule.java | 2 +- .../v2_0/config/KeystoneRestClientModule.java | 167 ------------------- .../config/MappedAuthenticationApiModule.java | 40 ----- .../v2_0/extensions/RoleAdminAsyncApi.java | 110 ------------ .../v2_0/extensions/ServiceAdminAsyncApi.java | 126 -------------- .../v2_0/extensions/TenantAdminAsyncApi.java | 137 --------------- .../v2_0/extensions/UserAdminAsyncApi.java | 113 ------------- .../keystone/v2_0/features/ServiceAsyncApi.java | 58 ------- .../keystone/v2_0/features/TenantAsyncApi.java | 101 ----------- .../keystone/v2_0/features/TokenAsyncApi.java | 94 ----------- .../keystone/v2_0/features/UserAsyncApi.java | 125 -------------- .../config/OpenStackAuthenticationModule.java | 5 +- .../internal/OpenStackAuthAsyncClient.java | 57 ------- .../openstack/internal/OpenStackAuthClient.java | 6 +- .../v1_1/AuthenticationAsyncClient.java | 54 ------ .../keystone/v1_1/AuthenticationClient.java | 11 +- .../config/AuthenticationServiceModule.java | 5 +- .../internal/OpenStackAuthAsyncClientTest.java | 80 --------- .../internal/OpenStackAuthClientTest.java | 77 +++++++++ 22 files changed, 93 insertions(+), 1494 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationAsyncApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationAsyncApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationAsyncApi.java deleted file mode 100644 index 295f9ff..0000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationAsyncApi.java +++ /dev/null @@ -1,93 +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.keystone.v2_0; - -import java.io.Closeable; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.keystone.v2_0.binders.BindAuthToJsonPayload; -import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.keystone.v2_0.domain.ApiAccessKeyCredentials; -import org.jclouds.openstack.keystone.v2_0.domain.PasswordCredentials; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.SelectJson; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Service via their REST API. - * <p/> - * - * @see AuthenticationApi - * @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Api_Operations.html" - * /> - * @deprecated will be removed in jclouds 1.7, as async interfaces are no longer - * supported. please use {@link AuthenticationApi} - */ -@Deprecated -public interface AuthenticationAsyncApi extends Closeable { - - /** - * @see AuthenticationApi#authenticateWithTenantNameAndCredentials(String,PasswordCredentials) - */ - @POST - @SelectJson("access") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tokens") - @MapBinder(BindAuthToJsonPayload.class) - ListenableFuture<Access> authenticateWithTenantNameAndCredentials(@Nullable @PayloadParam("tenantName") String tenantName, - PasswordCredentials passwordCredentials); - - /** - * @see AuthenticationApi#authenticateWithTenantIdAndCredentials(String,PasswordCredentials) - */ - @POST - @SelectJson("access") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tokens") - @MapBinder(BindAuthToJsonPayload.class) - ListenableFuture<Access> authenticateWithTenantIdAndCredentials(@Nullable @PayloadParam("tenantId") String tenantId, - PasswordCredentials passwordCredentials); - - /** - * @see AuthenticationApi#authenticateWithTenantNameAndCredentials(String,ApiAccessKeyCredentials) - */ - @POST - @SelectJson("access") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tokens") - @MapBinder(BindAuthToJsonPayload.class) - ListenableFuture<Access> authenticateWithTenantNameAndCredentials(@Nullable @PayloadParam("tenantName") String tenantName, - ApiAccessKeyCredentials apiAccessKeyCredentials); - - /** - * @see AuthenticationApi#authenticateWithTenantIdAndCredentials(String,ApiAccessKeyCredentials) - */ - @POST - @SelectJson("access") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tokens") - @MapBinder(BindAuthToJsonPayload.class) - ListenableFuture<Access> authenticateWithTenantIdAndCredentials(@Nullable @PayloadParam("tenantId") String tenantId, - ApiAccessKeyCredentials apiAccessKeyCredentials); -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java index ff21237..a46df20 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java @@ -40,15 +40,6 @@ import com.google.inject.Module; */ public class KeystoneApiMetadata extends BaseHttpApiMetadata<KeystoneApi> { - /** - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(KeystoneApi.class)} as - * {@link KeystoneAsyncApi} interface will be removed in jclouds 1.7. - */ - @Deprecated - public static final TypeToken<org.jclouds.rest.RestContext<KeystoneApi, KeystoneAsyncApi>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<KeystoneApi, KeystoneAsyncApi>>() { - private static final long serialVersionUID = 1L; - }; - @Override public Builder<?> toBuilder() { return new ConcreteBuilder().fromApiMetadata(this); http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncApi.java deleted file mode 100644 index 426cce6..0000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncApi.java +++ /dev/null @@ -1,117 +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.keystone.v2_0; - -import java.io.Closeable; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; -import org.jclouds.openstack.keystone.v2_0.extensions.RoleAdminAsyncApi; -import org.jclouds.openstack.keystone.v2_0.extensions.ServiceAdminAsyncApi; -import org.jclouds.openstack.keystone.v2_0.extensions.TenantAdminAsyncApi; -import org.jclouds.openstack.keystone.v2_0.extensions.UserAdminAsyncApi; -import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncApi; -import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncApi; -import org.jclouds.openstack.keystone.v2_0.features.TokenAsyncApi; -import org.jclouds.openstack.keystone.v2_0.features.UserAsyncApi; -import org.jclouds.openstack.v2_0.features.ExtensionAsyncApi; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.SelectJson; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to OpenStack keystone resources via their REST API. - * <p/> - * - * @see <a href="http://keystone.openstack.org/" /> - * @see KeystoneApi - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(KeystoneApi.class)} as - * {@link KeystoneAsyncApi} interface will be removed in jclouds 1.7. - */ -@Deprecated -public interface KeystoneAsyncApi extends Closeable { - - /** - * @see KeystoneApi#getApiMetadata() - */ - @GET - @SelectJson("version") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<ApiMetadata> getApiMetadata(); - - /** - * @see KeystoneApi#getServiceApi() - */ - @Delegate - ServiceAsyncApi getServiceApi(); - - /** - * Provides asynchronous access to Extension features. - */ - @Delegate - ExtensionAsyncApi getExtensionApi(); - - /** - * @see KeystoneApi#getTokenApi() - */ - @Delegate - Optional<? extends TokenAsyncApi> getTokenApi(); - - /** - * @see KeystoneApi#getUserApi() - */ - @Delegate - Optional<? extends UserAsyncApi> getUserApi(); - - /** - * @see KeystoneApi#getTenantApi() - */ - @Delegate - Optional<? extends TenantAsyncApi> getTenantApi(); - - /** - * @see KeystoneApi#getUserAdminApi() - */ - @Delegate - Optional<? extends UserAdminAsyncApi> getUserAdminApi(); - - /** - * @see KeystoneApi#getTenantAdminApi() - */ - @Delegate - Optional<? extends TenantAdminAsyncApi> getTenantAdminApi(); - - /** - * @see KeystoneApi#getRoleAdminApi() - */ - @Delegate - Optional<? extends RoleAdminAsyncApi> getRoleAdminApi(); - - /** - * @see KeystoneApi#getServiceAdminApi() - */ - @Delegate - Optional<? extends ServiceAdminAsyncApi> getServiceAdminApi(); -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java index eaff908..90e5488 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java @@ -77,7 +77,7 @@ public class KeystoneAuthenticationModule extends AbstractModule { * <li>add this module to your {@link org.jclouds.apis.ApiMetadata#getDefaultModules()}</li> * <li>create a service-specific annotation, such as {@code @CloudDNS}, and make sure that has the meta-annotation * {@link javax.inject.Qualifier}</li> - * <li>add the above annotation to any {@link AsyncApi} classes by placing it on the type. ex. + * <li>add the above annotation to any {@code Api} classes by placing it on the type. ex. * {@code @Endpoint(CloudDNS.class)}</li> * <li>add the following to your {@link org.jclouds.rest.config.RestClientModule}</li> * http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java deleted file mode 100644 index 4824edf..0000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java +++ /dev/null @@ -1,167 +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.keystone.v2_0.config; - -import static org.jclouds.reflect.Reflection2.typeToken; -import static org.jclouds.util.Suppliers2.getLastValueInMap; - -import java.net.URI; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -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.location.Provider; -import org.jclouds.openstack.keystone.v2_0.KeystoneApi; -import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncApi; -import org.jclouds.openstack.keystone.v2_0.extensions.RoleAdminApi; -import org.jclouds.openstack.keystone.v2_0.extensions.RoleAdminAsyncApi; -import org.jclouds.openstack.keystone.v2_0.extensions.ServiceAdminApi; -import org.jclouds.openstack.keystone.v2_0.extensions.ServiceAdminAsyncApi; -import org.jclouds.openstack.keystone.v2_0.extensions.TenantAdminApi; -import org.jclouds.openstack.keystone.v2_0.extensions.TenantAdminAsyncApi; -import org.jclouds.openstack.keystone.v2_0.extensions.UserAdminApi; -import org.jclouds.openstack.keystone.v2_0.extensions.UserAdminAsyncApi; -import org.jclouds.openstack.keystone.v2_0.features.ServiceApi; -import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncApi; -import org.jclouds.openstack.keystone.v2_0.features.TenantApi; -import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncApi; -import org.jclouds.openstack.keystone.v2_0.features.TokenApi; -import org.jclouds.openstack.keystone.v2_0.features.TokenAsyncApi; -import org.jclouds.openstack.keystone.v2_0.features.UserApi; -import org.jclouds.openstack.keystone.v2_0.features.UserAsyncApi; -import org.jclouds.openstack.keystone.v2_0.handlers.KeystoneErrorHandler; -import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURIFromAccessForTypeAndVersion; -import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURISupplier; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.domain.Extension; -import org.jclouds.openstack.v2_0.features.ExtensionApi; -import org.jclouds.openstack.v2_0.features.ExtensionAsyncApi; -import org.jclouds.openstack.v2_0.functions.PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet; -import org.jclouds.openstack.v2_0.services.Identity; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.annotations.ApiVersion; -import org.jclouds.rest.config.RestClientModule; -import org.jclouds.rest.functions.ImplicitOptionalConverter; -import org.jclouds.util.Suppliers2; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -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.AbstractModule; -import com.google.inject.Provides; -import com.google.inject.assistedinject.FactoryModuleBuilder; - -/** - * Configures the Keystone connection. - */ -@ConfiguresRestClient -public class KeystoneRestClientModule<S extends KeystoneApi, A extends KeystoneAsyncApi> extends - RestClientModule<S, A> { - - public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder() - .put(ServiceApi.class, ServiceAsyncApi.class) - .put(ExtensionApi.class, ExtensionAsyncApi.class) - .put(TokenApi.class, TokenAsyncApi.class) - .put(UserApi.class, UserAsyncApi.class) - .put(TenantApi.class, TenantAsyncApi.class) - .put(UserAdminApi.class, UserAdminAsyncApi.class) - .put(TenantAdminApi.class, TenantAdminAsyncApi.class) - .put(RoleAdminApi.class, RoleAdminAsyncApi.class) - .put(ServiceAdminApi.class, ServiceAdminAsyncApi.class) - .build(); - - @SuppressWarnings("unchecked") - public KeystoneRestClientModule() { - super(TypeToken.class.cast(typeToken(KeystoneApi.class)), TypeToken.class.cast(typeToken(KeystoneAsyncApi.class)), DELEGATE_MAP); - } - - protected KeystoneRestClientModule(TypeToken<S> syncApiType, TypeToken<A> asyncApiType, Map<Class<?>, Class<?>> sync2Async) { - super(syncApiType, asyncApiType, sync2Async); - } - - public static class KeystoneAdminURLModule extends AbstractModule { - - @Override - protected void configure() { - install(new FactoryModuleBuilder().implement(RegionIdToAdminURISupplier.class, - RegionIdToAdminURIFromAccessForTypeAndVersion.class).build(RegionIdToAdminURISupplier.Factory.class)); - } - - /** - * in some cases, there is no {@link ServiceType#IDENTITY} entry in the service catalog. In - * other cases, there's no adminURL entry present. Fallback to the provider in this case. - */ - @Provides - @Singleton - @Identity - protected Supplier<URI> provideStorageUrl(final RegionIdToAdminURISupplier.Factory factory, - @ApiVersion final String version, @Provider final Supplier<URI> providerURI) { - Supplier<URI> identityServiceForVersion = getLastValueInMap(factory.createForApiTypeAndVersion( - ServiceType.IDENTITY, version)); - Supplier<URI> whenIdentityServiceIsntListedFallbackToProviderURI = Suppliers2.onThrowable( - identityServiceForVersion, NoSuchElementException.class, providerURI); - Supplier<URI> whenIdentityServiceHasNoAdminURLFallbackToProviderURI = Suppliers2.or( - whenIdentityServiceIsntListedFallbackToProviderURI, providerURI); - return whenIdentityServiceHasNoAdminURLFallbackToProviderURI; - } - } - - @Override - protected void configure() { - bind(ImplicitOptionalConverter.class).to(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class); - super.configure(); - } - - @Provides - @Singleton - public Multimap<URI, URI> aliases() { - return ImmutableMultimap.<URI, URI>builder() - .build(); - } - - @Provides - @Singleton - public LoadingCache<String, Set<? extends Extension>> provideExtensionsByRegion(final javax.inject.Provider<KeystoneApi> keystoneApi) { - return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS) - .build(CacheLoader.from(Suppliers.memoize(new Supplier<Set<? extends Extension>>() { - @Override - public Set<? extends Extension> get() { - return keystoneApi.get().getExtensionApi().list(); - } - }))); - } - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(KeystoneErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(KeystoneErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(KeystoneErrorHandler.class); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/MappedAuthenticationApiModule.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/MappedAuthenticationApiModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/MappedAuthenticationApiModule.java deleted file mode 100644 index 6c0dfba..0000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/MappedAuthenticationApiModule.java +++ /dev/null @@ -1,40 +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.keystone.v2_0.config; - -import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncHttpApi; - -import org.jclouds.openstack.keystone.v2_0.AuthenticationApi; -import org.jclouds.openstack.keystone.v2_0.AuthenticationAsyncApi; - -import com.google.inject.AbstractModule; - -/** - * - * @deprecated will be removed in jclouds 1.7, as async interfaces are no longer - * supported. please use {@link AuthenticationApiModule} - */ -@Deprecated -public class MappedAuthenticationApiModule extends AbstractModule { - - @Override - protected void configure() { - // AuthenticationApi is used directly for filters and retry handlers, so let's bind it explicitly - bindSyncToAsyncHttpApi(binder(), AuthenticationApi.class, AuthenticationAsyncApi.class); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminAsyncApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminAsyncApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminAsyncApi.java deleted file mode 100644 index fe4ef53..0000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminAsyncApi.java +++ /dev/null @@ -1,110 +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.keystone.v2_0.extensions; - -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.keystone.v2_0.domain.Role; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.annotations.WrapWith; - -import com.google.common.annotations.Beta; -import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to roles Administration actions. - * <p/> - * - * @see org.jclouds.openstack.keystone.v2_0.extensions.RoleAdminApi - */ -@Beta -@Extension(of = ServiceType.IDENTITY, namespace = ExtensionNamespaces.OS_KSADM) -@RequestFilters(AuthenticateRequest.class) -public interface RoleAdminAsyncApi { - - /** - * Returns a summary list of roles. - * - * @return The list of roles - */ - @Named("role:list") - @GET - @Path("OS-KSADM/roles") - @SelectJson("roles") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture<? extends FluentIterable<? extends Role>> list(); - - /** - * Creates a new role - * - * @return the new role - */ - @Named("role:create") - @POST - @Path("OS-KSADM/roles") - @SelectJson("role") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - @WrapWith("role") - ListenableFuture<? extends Role> create(@PayloadParam("name") String name); - - /** - * Gets the role - * - * @return the role - */ - @Named("role:get") - @GET - @SelectJson("role") - @Consumes(MediaType.APPLICATION_JSON) - @Path("OS-KSADM/roles/{roleId}") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends Role> get(@PathParam("roleId") String roleId); - - /** - * Deletes an role. - * - * @return true if successful - */ - @Named("role:delete") - @DELETE - @Path("OS-KSADM/roles/{id}") - @Consumes - @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture<Boolean> delete(@PathParam("id") String id); - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminAsyncApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminAsyncApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminAsyncApi.java deleted file mode 100644 index 1dc0f3d..0000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminAsyncApi.java +++ /dev/null @@ -1,126 +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.keystone.v2_0.extensions; - -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.EmptyPagedIterableOnNotFoundOr404; -import org.jclouds.Fallbacks.FalseOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.collect.PagedIterable; -import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.domain.Service; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseServices; -import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseServices.ToPagedIterable; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.domain.PaginatedCollection; -import org.jclouds.openstack.v2_0.options.PaginationOptions; -import org.jclouds.openstack.v2_0.services.Extension; -import org.jclouds.rest.annotations.Fallback; -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.WrapWith; - -import com.google.common.annotations.Beta; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to services Administration actions. - * <p/> - * - * @see org.jclouds.openstack.keystone.v2_0.extensions.ServiceAdminApi - */ -@Beta -@Extension(of = ServiceType.IDENTITY, namespace = ExtensionNamespaces.OS_KSADM) -@RequestFilters(AuthenticateRequest.class) -public interface ServiceAdminAsyncApi { - - /** - * @see ServiceApi#list() - */ - @Named("service:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("OS-KSADM/services") - @ResponseParser(ParseServices.class) - @Transform(ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture<? extends PagedIterable<? extends Service>> list(); - - /** @see ServiceApi#list(PaginationOptions) */ - @Named("service:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("OS-KSADM/services") - @ResponseParser(ParseServices.class) - @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class) - ListenableFuture<? extends PaginatedCollection<? extends Service>> list(PaginationOptions options); - - /** - * Creates a new service - * - * @return the new service - */ - @Named("service:create") - @POST - @Path("OS-KSADM/services") - @SelectJson("OS-KSADM:service") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @WrapWith("OS-KSADM:service") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends Service> create(@PayloadParam("name") String name, @PayloadParam("type") String type, - @PayloadParam("description") String description); - - /** - * Gets the service - * - * @return the service - */ - @Named("service:get") - @GET - @SelectJson("OS-KSADM:service") - @Consumes(MediaType.APPLICATION_JSON) - @Path("OS-KSADM/services/{serviceId}") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends Service> get(@PathParam("serviceId") String serviceId); - - /** - * Deletes a service. - * - * @return true if successful - */ - @Named("service:delete") - @DELETE - @Path("OS-KSADM/services/{id}") - @Consumes - @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture<Boolean> delete(@PathParam("id") String id); - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminAsyncApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminAsyncApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminAsyncApi.java deleted file mode 100644 index 8a4ca7f..0000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminAsyncApi.java +++ /dev/null @@ -1,137 +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.keystone.v2_0.extensions; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -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.FalseOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.domain.Tenant; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.openstack.keystone.v2_0.options.CreateTenantOptions; -import org.jclouds.openstack.keystone.v2_0.options.UpdateTenantOptions; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; -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 com.google.common.annotations.Beta; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to tenants Administration actions. - * <p/> - * - * @see org.jclouds.openstack.keystone.v2_0.extensions.TenantAdminApi - */ -@Beta -@Extension(of = ServiceType.IDENTITY, namespace = ExtensionNamespaces.OS_KSADM) -@RequestFilters(AuthenticateRequest.class) -public interface TenantAdminAsyncApi { - - /** - * Creates a new tenant - * - * @return the new tenant - */ - @Named("tenant:create") - @POST - @Path("/tenants") - @SelectJson("tenant") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends Tenant> create(@PayloadParam("name") String name); - - /** - * Creates a new tenant - * - * @return the new tenant - */ - @Named("tenant:create") - @POST - @Path("/tenants") - @SelectJson("tenant") - @Consumes(MediaType.APPLICATION_JSON) - @MapBinder(CreateTenantOptions.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends Tenant> create(@PayloadParam("name") String name, CreateTenantOptions options); - - /** - * Deletes a tenant. - * - * @return true if successful - */ - @Named("tenant:delete") - @DELETE - @Path("/tenants/{id}") - @Consumes - @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture<Boolean> delete(@PathParam("id") String id); - - /** - * Updates a tenant - * - * @return the updated tenant - */ - @Named("tenant:updatetenant") - @PUT - @Path("/tenants/{id}") - @SelectJson("tenant") - @Consumes(MediaType.APPLICATION_JSON) - @MapBinder(UpdateTenantOptions.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends Tenant> update(@PathParam("id") String id, UpdateTenantOptions options); - - /** - * Adds role to a user on a tenant - * - * @return true if successful - */ - @Named("tenant:addroleontenant") - @PUT - @Path("/tenants/{id}/users/{userId}/roles/OS-KSADM/{roleId}") - @Consumes - @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture<Boolean> addRoleOnTenant(@PathParam("id") String tenantId, @PathParam("userId") String userdId, - @PathParam("roleId") String roleId); - - /** - * Deletes role to a user on tenant - * - * @return - */ - @Named("tenant:deleteroleontenant") - @DELETE - @Path("/tenants/{id}/users/{userId}/roles/OS-KSADM/{roleId}") - @Consumes - @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture<Boolean> deleteRoleOnTenant(@PathParam("id") String tenantId, @PathParam("userId") String userdId, - @PathParam("roleId") String roleId); - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminAsyncApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminAsyncApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminAsyncApi.java deleted file mode 100644 index b343c28..0000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminAsyncApi.java +++ /dev/null @@ -1,113 +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.keystone.v2_0.extensions; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -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.FalseOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.domain.User; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.openstack.keystone.v2_0.options.CreateUserOptions; -import org.jclouds.openstack.keystone.v2_0.options.UpdateUserOptions; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; -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 com.google.common.annotations.Beta; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Users Administration actions. - * <p/> - * - * @see org.jclouds.openstack.keystone.v2_0.extensions.UserAdminApi - */ -@Beta -@Extension(of = ServiceType.IDENTITY, namespace = ExtensionNamespaces.OS_KSADM) -@RequestFilters(AuthenticateRequest.class) -public interface UserAdminAsyncApi { - - /** - * Creates a new user - * - * @return the new user - */ - @Named("user:create") - @POST - @Path("/users") - @SelectJson("user") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends User> create(@PayloadParam("name") String name, - @PayloadParam("password") String password); - - /** - * Creates a new user - * - * @return the new user - */ - @Named("user:create") - @POST - @Path("/users") - @SelectJson("user") - @Consumes(MediaType.APPLICATION_JSON) - @MapBinder(CreateUserOptions.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends User> create(@PayloadParam("name") String name, - @PayloadParam("password") String password, CreateUserOptions options); - - /** - * Deletes an user. - * - * @return true if successful - */ - @Named("user:delete") - @DELETE - @Path("/users/{id}") - @Consumes - @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture<Boolean> delete(@PathParam("id") String id); - - /** - * Updates an user - * - * @return the updated user - */ - @Named("user:updateuser") - @PUT - @Path("/users/{id}") - @SelectJson("user") - @Consumes(MediaType.APPLICATION_JSON) - @MapBinder(UpdateUserOptions.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends User> update(@PathParam("id") String id, UpdateUserOptions options); - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceAsyncApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceAsyncApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceAsyncApi.java deleted file mode 100644 index 5b70c59..0000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceAsyncApi.java +++ /dev/null @@ -1,58 +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.keystone.v2_0.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.domain.Tenant; -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 com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Service via their REST API. - * <p/> - * - * @see ServiceApi - * @see <a href= - * "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Api_Operations.html" - * /> - */ -public interface ServiceAsyncApi { - - /** - * @see ServiceApi#listTenants() - */ - @Named("service:listtenants") - @GET - @SelectJson("tenants") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tenants") - @RequestFilters(AuthenticateRequest.class) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture<? extends Set<? extends Tenant>> listTenants(); -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TenantAsyncApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TenantAsyncApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TenantAsyncApi.java deleted file mode 100644 index 7ce0b75..0000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TenantAsyncApi.java +++ /dev/null @@ -1,101 +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.keystone.v2_0.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.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -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.domain.Tenant; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseTenants; -import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseTenants.ToPagedIterable; -import org.jclouds.openstack.v2_0.options.PaginationOptions; -import org.jclouds.openstack.v2_0.services.Identity; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Tenant via their REST API. - * <p/> - * - * @see TenantApi - * @see <a href= - * "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Tenant_Operations.html" - * /> - */ [email protected](Identity.class) -public interface TenantAsyncApi { - - /** - * @see TenantApi#list() - */ - @Named("tenant:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tenants") - @RequestFilters(AuthenticateRequest.class) - @ResponseParser(ParseTenants.class) - @Transform(ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture<? extends PagedIterable<? extends Tenant>> list(); - - /** @see TenantApi#list(PaginationOptions) */ - @Named("tenant:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tenants") - @RequestFilters(AuthenticateRequest.class) - @ResponseParser(ParseTenants.class) - @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class) - ListenableFuture<? extends PaginatedCollection<? extends Tenant>> list(PaginationOptions options); - - /** @see TenantApi#get(String) */ - @Named("tenant:get") - @GET - @SelectJson("tenant") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tenants/{tenantId}") - @RequestFilters(AuthenticateRequest.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends Tenant> get(@PathParam("tenantId") String tenantId); - - /** @see TenantApi#getByName(String) */ - @Named("tenant:get") - @GET - @SelectJson("tenant") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tenants") - @RequestFilters(AuthenticateRequest.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends Tenant> getByName(@QueryParam("name") String tenantName); - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenAsyncApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenAsyncApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenAsyncApi.java deleted file mode 100644 index ed8d807..0000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenAsyncApi.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.keystone.v2_0.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HEAD; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.FalseOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; -import org.jclouds.openstack.keystone.v2_0.domain.Token; -import org.jclouds.openstack.keystone.v2_0.domain.User; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.openstack.v2_0.services.Identity; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.SelectJson; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Token via their REST API. - * <p/> - * - * @see TokenApi - * @see <a href= - * "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Token_Operations.html" - * /> - */ [email protected](Identity.class) -public interface TokenAsyncApi { - - - /** @see TokenApi#get(String) */ - @Named("token:get") - @GET - @SelectJson("token") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tokens/{token}") - @RequestFilters(AuthenticateRequest.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends Token> get(@PathParam("token") String token); - - /** @see TokenApi#getUserOfToken(String) */ - @Named("token:getuser") - @GET - @SelectJson("user") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tokens/{token}") - @RequestFilters(AuthenticateRequest.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends User> getUserOfToken(@PathParam("token") String token); - - /** @see TokenApi#isValid(String) */ - @Named("token:valid") - @HEAD - @Path("/tokens/{token}") - @RequestFilters(AuthenticateRequest.class) - @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture<Boolean> isValid(@PathParam("token") String token); - - /** @see TokenApi#listEndpointsForToken(String) */ - @Named("token:listendpoints") - @GET - @SelectJson("endpoints") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tokens/{token}/endpoints") - @RequestFilters(AuthenticateRequest.class) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture<? extends Set<? extends Endpoint>> listEndpointsForToken(@PathParam("token") String token); - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserAsyncApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserAsyncApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserAsyncApi.java deleted file mode 100644 index c17728d..0000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserAsyncApi.java +++ /dev/null @@ -1,125 +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.keystone.v2_0.features; - -import java.util.Set; - -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.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -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.domain.Role; -import org.jclouds.openstack.keystone.v2_0.domain.User; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseUsers; -import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseUsers.ToPagedIterable; -import org.jclouds.openstack.v2_0.options.PaginationOptions; -import org.jclouds.openstack.v2_0.services.Identity; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to User via their REST API. - * <p/> - * - * @see UserApi - * @see <a href= - * "http://docs.openstack.org/api/openstack-identity-service/2.0/content/User_Operations.html" - * /> - */ [email protected](Identity.class) -public interface UserAsyncApi { - - /** - * @see UserApi#list() - */ - @Named("user:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/users") - @RequestFilters(AuthenticateRequest.class) - @ResponseParser(ParseUsers.class) - @Transform(ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture<? extends PagedIterable<? extends User>> list(); - - /** @see UserApi#list(PaginationOptions) */ - @Named("user:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/users") - @RequestFilters(AuthenticateRequest.class) - @ResponseParser(ParseUsers.class) - @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class) - ListenableFuture<? extends PaginatedCollection<? extends User>> list(PaginationOptions options); - - /** @see UserApi#get(String) */ - @Named("user:get") - @GET - @SelectJson("user") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/users/{userId}") - @RequestFilters(AuthenticateRequest.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends User> get(@PathParam("userId") String userId); - - /** @see UserApi#getByName(String) */ - @Named("user:get") - @GET - @SelectJson("user") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/users") - @RequestFilters(AuthenticateRequest.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture<? extends User> getByName(@QueryParam("name") String userName); - - /** @see UserApi#listRolesOfUser(String) */ - @Named("user:listroles") - @GET - @SelectJson("roles") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/users/{userId}/roles") - @RequestFilters(AuthenticateRequest.class) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture<? extends Set<? extends Role>> listRolesOfUser(@PathParam("userId") String userId); - - /** @see UserApi#listRolesOfUserOnTenant(String, String) */ - @Named("user:listroles") - @GET - @SelectJson("roles") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tenants/{tenantId}/users/{userId}/roles") - @RequestFilters(AuthenticateRequest.class) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture<? extends Set<? extends Role>> listRolesOfUserOnTenant(@PathParam("userId") String userId, - @PathParam("tenantId") String tenantId); -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java ---------------------------------------------------------------------- diff --git a/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java b/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java index 9d675fa..9a98f7f 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java @@ -17,7 +17,7 @@ package org.jclouds.openstack.config; import static com.google.common.base.Suppliers.memoizeWithExpiration; -import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncHttpApi; +import static org.jclouds.rest.config.BinderUtils.bindHttpApi; import java.util.Date; import java.util.concurrent.ExecutionException; @@ -36,7 +36,6 @@ import org.jclouds.openstack.domain.AuthenticationResponse; import org.jclouds.openstack.functions.URIFromAuthenticationResponseForService; import org.jclouds.openstack.handlers.RetryOnRenew; import org.jclouds.openstack.internal.Authentication; -import org.jclouds.openstack.internal.OpenStackAuthAsyncClient; import org.jclouds.openstack.internal.OpenStackAuthClient; import com.google.common.base.Supplier; @@ -55,7 +54,7 @@ public class OpenStackAuthenticationModule extends AbstractModule { @Override protected void configure() { // OpenStackAuthClient is used directly for filters and retry handlers, so let's bind it explicitly - bindSyncToAsyncHttpApi(binder(), OpenStackAuthClient.class, OpenStackAuthAsyncClient.class); + bindHttpApi(binder(), OpenStackAuthClient.class); install(new FactoryModuleBuilder().build(URIFromAuthenticationResponseForService.Factory.class)); bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(RetryOnRenew.class); } http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClient.java ---------------------------------------------------------------------- diff --git a/common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClient.java b/common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClient.java deleted file mode 100644 index 622b636..0000000 --- a/common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClient.java +++ /dev/null @@ -1,57 +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.internal; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.Path; - -import org.jclouds.Constants; -import org.jclouds.openstack.domain.AuthenticationResponse; -import org.jclouds.openstack.functions.ParseAuthenticationResponseFromHeaders; -import org.jclouds.openstack.reference.AuthHeaders; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.VirtualHost; - -import com.google.common.util.concurrent.ListenableFuture; -import com.google.inject.name.Named; - -/** - * Provides access to Rackspace resources via their REST API. - * <p/> - * - * @see <a href="http://docs.rackspacecloud.com/servers/api/cs-devguide-latest.pdf" /> - */ -@Path("/v{" + Constants.PROPERTY_API_VERSION + "}") -@VirtualHost -public interface OpenStackAuthAsyncClient { - - @Named("authenticate") - @GET - @Consumes - @ResponseParser(ParseAuthenticationResponseFromHeaders.class) - ListenableFuture<AuthenticationResponse> authenticate(@HeaderParam(AuthHeaders.AUTH_USER) String user, - @HeaderParam(AuthHeaders.AUTH_KEY) String key); - - @Named("authenticate") - @GET - @Consumes - @ResponseParser(ParseAuthenticationResponseFromHeaders.class) - ListenableFuture<AuthenticationResponse> authenticateStorage(@HeaderParam(AuthHeaders.STORAGE_USER) String user, - @HeaderParam(AuthHeaders.STORAGE_PASS) String key); -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthClient.java ---------------------------------------------------------------------- diff --git a/common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthClient.java b/common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthClient.java index 9802c38..34355ce 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthClient.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthClient.java @@ -15,6 +15,8 @@ * limitations under the License. */ package org.jclouds.openstack.internal; +import java.io.Closeable; + import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.HeaderParam; @@ -25,6 +27,7 @@ import org.jclouds.openstack.domain.AuthenticationResponse; import org.jclouds.openstack.functions.ParseAuthenticationResponseFromHeaders; import org.jclouds.openstack.reference.AuthHeaders; import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.VirtualHost; import com.google.inject.name.Named; @@ -32,7 +35,8 @@ import com.google.inject.name.Named; * Provides access to OpenStack auth. */ @Path("/v{" + Constants.PROPERTY_API_VERSION + "}") -public interface OpenStackAuthClient { +@VirtualHost +public interface OpenStackAuthClient extends Closeable { @Named("authenticate") @GET http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/AuthenticationAsyncClient.java ---------------------------------------------------------------------- diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/AuthenticationAsyncClient.java b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/AuthenticationAsyncClient.java deleted file mode 100644 index b801e3b..0000000 --- a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/AuthenticationAsyncClient.java +++ /dev/null @@ -1,54 +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.keystone.v1_1; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.openstack.keystone.v1_1.binders.BindCredentialsToJsonPayload; -import org.jclouds.openstack.keystone.v1_1.domain.Auth; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.SelectJson; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Service via their REST API. - * <p/> - * - * @see AuthenticationClient - * @see <a href= - * "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html" - * /> - */ -@Path("/v1.1") -public interface AuthenticationAsyncClient { - - /** - * @see AuthenticationClient#authenticate - */ - @POST - @SelectJson("auth") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/auth") - @MapBinder(BindCredentialsToJsonPayload.class) - ListenableFuture<Auth> authenticate(@PayloadParam("username") String username, @PayloadParam("key") String key); - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/AuthenticationClient.java ---------------------------------------------------------------------- diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/AuthenticationClient.java b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/AuthenticationClient.java index b05a26e..6e470af 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/AuthenticationClient.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/AuthenticationClient.java @@ -16,6 +16,8 @@ */ package org.jclouds.openstack.keystone.v1_1; +import java.io.Closeable; + import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -24,26 +26,25 @@ import javax.ws.rs.core.MediaType; import org.jclouds.openstack.keystone.v1_1.binders.BindCredentialsToJsonPayload; import org.jclouds.openstack.keystone.v1_1.domain.Auth; import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.SelectJson; -import com.google.inject.name.Named; - /** * Provides access to the Keystone v1.1 Service API. */ @Consumes(MediaType.APPLICATION_JSON) @Path("/v1.1") -public interface AuthenticationClient { +public interface AuthenticationClient extends Closeable { /** * Authenticate to generate a token. * * @return access with token */ - @Named("authenticate") @POST @SelectJson("auth") + @Consumes(MediaType.APPLICATION_JSON) @Path("/auth") @MapBinder(BindCredentialsToJsonPayload.class) - Auth authenticate(String username, String key); + Auth authenticate(@PayloadParam("username") String username, @PayloadParam("key") String key); } http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java ---------------------------------------------------------------------- diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java index 7d9c048..f8d32e1 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java @@ -16,7 +16,7 @@ */ package org.jclouds.openstack.keystone.v1_1.config; -import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncHttpApi; +import static org.jclouds.rest.config.BinderUtils.bindHttpApi; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import java.util.concurrent.ExecutionException; @@ -33,7 +33,6 @@ import org.jclouds.location.Provider; import org.jclouds.location.suppliers.ImplicitRegionIdSupplier; import org.jclouds.location.suppliers.RegionIdToURISupplier; import org.jclouds.openstack.internal.Authentication; -import org.jclouds.openstack.keystone.v1_1.AuthenticationAsyncClient; import org.jclouds.openstack.keystone.v1_1.AuthenticationClient; import org.jclouds.openstack.keystone.v1_1.domain.Auth; import org.jclouds.openstack.keystone.v1_1.handlers.RetryOnRenew; @@ -54,7 +53,7 @@ public class AuthenticationServiceModule extends AbstractModule { @Override protected void configure() { // ServiceClient is used directly for filters and retry handlers, so let's bind it explicitly - bindSyncToAsyncHttpApi(binder(), AuthenticationClient.class, AuthenticationAsyncClient.class); + bindHttpApi(binder(), AuthenticationClient.class); install(new FactoryModuleBuilder().implement(RegionIdToURISupplier.class, RegionIdToURIFromAuthForServiceSupplier.class).build(RegionIdToURISupplier.Factory.class)); install(new FactoryModuleBuilder().implement(ImplicitRegionIdSupplier.class, V1DefaultRegionIdSupplier.class) http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java ---------------------------------------------------------------------- diff --git a/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java b/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java deleted file mode 100644 index 1b7e884..0000000 --- a/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java +++ /dev/null @@ -1,80 +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.internal; - -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.IntegrationTestAsyncClient; -import org.jclouds.http.IntegrationTestClient; -import org.jclouds.openstack.functions.ParseAuthenticationResponseFromHeaders; -import org.jclouds.rest.AnonymousRestApiMetadata; -import org.jclouds.rest.internal.BaseAsyncClientTest; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; -/** - * Tests behavior of {@code OpenStackAuthAsyncClient} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "OpenStackAuthAsyncClientTest") -public class OpenStackAuthAsyncClientTest extends BaseAsyncClientTest<OpenStackAuthAsyncClient> { - - public void testAuthenticate() throws SecurityException, NoSuchMethodException, IOException { - Invokable<?, ?> method = method(OpenStackAuthAsyncClient.class, "authenticate", String.class, String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("foo", "bar")); - - assertRequestLineEquals(httpRequest, "GET http://localhost:8080/v1.0 HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: */*\nHost: localhost:8080\nX-Auth-Key: bar\nX-Auth-User: foo\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseAuthenticationResponseFromHeaders.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - } - - public void testAuthenticateStorage() throws SecurityException, NoSuchMethodException, IOException { - Invokable<?, ?> method = method(OpenStackAuthAsyncClient.class, "authenticateStorage", String.class, String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("foo", "bar")); - - assertRequestLineEquals(httpRequest, "GET http://localhost:8080/v1.0 HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: */*\nHost: localhost:8080\nX-Storage-Pass: bar\nX-Storage-User: foo\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseAuthenticationResponseFromHeaders.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - } - - @Override - public ApiMetadata createApiMetadata() { - return AnonymousRestApiMetadata.forClientMappedToAsyncClient(IntegrationTestClient.class, IntegrationTestAsyncClient.class).toBuilder().defaultEndpoint( - "http://localhost:8080").version("1.0").build(); - } - - @Override - protected void checkFilters(HttpRequest request) { - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/dda43dfc/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthClientTest.java ---------------------------------------------------------------------- diff --git a/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthClientTest.java b/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthClientTest.java new file mode 100644 index 0000000..9e14ba7 --- /dev/null +++ b/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthClientTest.java @@ -0,0 +1,77 @@ +/* + * 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.internal; + +import static org.jclouds.reflect.Reflection2.method; + +import java.io.IOException; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; +import org.jclouds.openstack.functions.ParseAuthenticationResponseFromHeaders; +import org.jclouds.rest.AnonymousRestApiMetadata; +import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.internal.GeneratedHttpRequest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; +import com.google.common.reflect.Invokable; + +@Test(groups = "unit", testName = "OpenStackAuthClientTest") +public class OpenStackAuthClientTest extends BaseAsyncClientTest<OpenStackAuthClient> { + + public void testAuthenticate() throws SecurityException, NoSuchMethodException, IOException { + Invokable<?, ?> method = method(OpenStackAuthClient.class, "authenticate", String.class, String.class); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("foo", "bar")); + + assertRequestLineEquals(httpRequest, "GET http://localhost:8080/v1.0 HTTP/1.1"); + assertNonPayloadHeadersEqual(httpRequest, "Accept: */*\nHost: localhost:8080\nX-Auth-Key: bar\nX-Auth-User: foo\n"); + assertPayloadEquals(httpRequest, null, null, false); + + assertResponseParserClassEquals(method, httpRequest, ParseAuthenticationResponseFromHeaders.class); + assertSaxResponseParserClassEquals(method, null); + assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); + + } + + public void testAuthenticateStorage() throws SecurityException, NoSuchMethodException, IOException { + Invokable<?, ?> method = method(OpenStackAuthClient.class, "authenticateStorage", String.class, String.class); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("foo", "bar")); + + assertRequestLineEquals(httpRequest, "GET http://localhost:8080/v1.0 HTTP/1.1"); + assertNonPayloadHeadersEqual(httpRequest, "Accept: */*\nHost: localhost:8080\nX-Storage-Pass: bar\nX-Storage-User: foo\n"); + assertPayloadEquals(httpRequest, null, null, false); + + assertResponseParserClassEquals(method, httpRequest, ParseAuthenticationResponseFromHeaders.class); + assertSaxResponseParserClassEquals(method, null); + assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); + + } + + @Override + public ApiMetadata createApiMetadata() { + return AnonymousRestApiMetadata.forClientMappedToAsyncClient(IntegrationTestClient.class, IntegrationTestAsyncClient.class).toBuilder().defaultEndpoint( + "http://localhost:8080").version("1.0").build(); + } + + @Override + protected void checkFilters(HttpRequest request) { + } +}
