JCLOUDS-40: Unasync Rackspace Cloud Identity

This commit is contained in:
Jeremy Daggett 2014-07-15 17:49:21 -07:00 committed by Jeremy Daggett
parent 717a545baa
commit 1a3ad75efd
22 changed files with 704 additions and 387 deletions

View File

@ -35,67 +35,56 @@ import org.jclouds.rest.annotations.SelectJson;
import com.google.inject.name.Named;
/**
* Provides synchronous access to the KeyStone Service API.
* <p/>
*
* @see <a href=
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Api_Operations.html"
* />
* Provides access to the OpenStack Keystone Service API.
*/
@Consumes(MediaType.APPLICATION_JSON)
@Path("/tokens")
public interface AuthenticationApi extends Closeable {
/**
* Authenticate to generate a token.
*
*
* @return access with token
*/
@Named("authenticate")
@POST
@SelectJson("access")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/tokens")
@MapBinder(BindAuthToJsonPayload.class)
Access authenticateWithTenantNameAndCredentials(@Nullable @PayloadParam("tenantName") String tenantName,
PasswordCredentials passwordCredentials);
/**
* Authenticate to generate a token.
*
*
* @return access with token
*/
@Named("authenticate")
@POST
@SelectJson("access")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/tokens")
@MapBinder(BindAuthToJsonPayload.class)
Access authenticateWithTenantIdAndCredentials(@Nullable @PayloadParam("tenantId") String tenantId,
PasswordCredentials passwordCredentials);
/**
* Authenticate to generate a token.
*
*
* @return access with token
*/
@Named("authenticate")
@POST
@SelectJson("access")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/tokens")
@MapBinder(BindAuthToJsonPayload.class)
Access authenticateWithTenantNameAndCredentials(@Nullable @PayloadParam("tenantName") String tenantName,
ApiAccessKeyCredentials apiAccessKeyCredentials);
/**
* Authenticate to generate a token.
*
*
* @return access with token
*/
@Named("authenticate")
@POST
@SelectJson("access")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/tokens")
@MapBinder(BindAuthToJsonPayload.class)
Access authenticateWithTenantIdAndCredentials(@Nullable @PayloadParam("tenantId") String tenantId,
ApiAccessKeyCredentials apiAccessKeyCredentials);

View File

@ -18,6 +18,13 @@ package org.jclouds.openstack.keystone.v2_0;
import java.io.Closeable;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.extensions.RoleAdminApi;
import org.jclouds.openstack.keystone.v2_0.extensions.ServiceAdminApi;
@ -29,75 +36,79 @@ import org.jclouds.openstack.keystone.v2_0.features.TokenApi;
import org.jclouds.openstack.keystone.v2_0.features.UserApi;
import org.jclouds.openstack.v2_0.features.ExtensionApi;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.SelectJson;
import com.google.common.base.Optional;
/**
* Provides access to OpenStack keystone resources via their REST API.
* <p/>
*
* @see <a href="http://keystone.openstack.org/" />
* @see KeystoneAsyncApi
* Provides access to the OpenStack Identity (Keystone) REST API.
*/
public interface KeystoneApi extends Closeable {
/**
* Discover API version information, links to documentation (PDF, HTML, WADL), and supported media types
*
* @return the requested information
* @return the {@link ApiMetadata}
*/
@Named("keystone:getApiMetadata")
@GET
@SelectJson("version")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
ApiMetadata getApiMetadata();
/**
* Provides synchronous access to Token features
/**
* Provides access to Token features
*/
@Delegate
ServiceApi getServiceApi();
/**
* Provides synchronous access to Extension features.
* Provides access to Extension features.
*/
@Delegate
ExtensionApi getExtensionApi();
/**
* Provides synchronous access to Token features
/**
* Provides access to Token features
*/
@Delegate
Optional<? extends TokenApi> getTokenApi();
/**
* Provides synchronous access to User features
/**
* Provides access to User features
*/
@Delegate
Optional<? extends UserApi> getUserApi();
/**
* Provides synchronous access to Tenant features
/**
* Provides access to Tenant features
*/
@Delegate
Optional<? extends TenantApi> getTenantApi();
/**
* Provides synchronous access to Admin user features
/**
* Provides access to Admin user features
*/
@Delegate
Optional<? extends UserAdminApi> getUserAdminApi();
/**
* Provides synchronous access to Admin tenant features
/**
* Provides access to Admin tenant features
*/
@Delegate
Optional<? extends TenantAdminApi> getTenantAdminApi();
/**
* Provides synchronous access to Admin role features
/**
* Provides access to Admin role features
*/
@Delegate
Optional<? extends RoleAdminApi> getRoleAdminApi();
/**
* Provides synchronous access to Admin service features
/**
* Provides access to Admin service features
*/
@Delegate
Optional<? extends ServiceAdminApi> getServiceAdminApi();

View File

@ -22,14 +22,14 @@ import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERV
import java.net.URI;
import java.util.Properties;
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.KeystoneHttpApiModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneHttpApiModule.KeystoneAdminURLModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneParserModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule.KeystoneAdminURLModule;
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;
@ -38,8 +38,8 @@ import com.google.inject.Module;
/**
* Implementation of {@link org.jclouds.apis.ApiMetadata} for Keystone 2.0 API
*/
public class KeystoneApiMetadata extends BaseRestApiMetadata {
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.
@ -63,37 +63,32 @@ public class KeystoneApiMetadata extends BaseRestApiMetadata {
}
public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
properties.setProperty(SERVICE_TYPE, ServiceType.IDENTITY);
Properties properties = BaseHttpApiMetadata.defaultProperties();
properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS);
properties.setProperty(SERVICE_TYPE, ServiceType.IDENTITY);
return properties;
}
public abstract static class Builder<T extends Builder<T>> extends BaseRestApiMetadata.Builder<T> {
@SuppressWarnings("deprecation")
protected Builder() {
this(KeystoneApi.class, KeystoneAsyncApi.class);
}
public abstract static class Builder<T extends Builder<T>> extends BaseHttpApiMetadata.Builder<KeystoneApi, T> {
protected Builder(Class<?> api, Class<?> asyncApi) {
super(api, asyncApi);
protected Builder() {
id("openstack-keystone")
.name("OpenStack Keystone Essex+ API")
.identityName("${tenantName}:${userName} or ${userName}, if your keystone supports a default tenant")
.credentialName("${password}")
.endpointName("KeyStone base url ending in /v${jclouds.api-version}/")
.endpointName("Keystone base url ending in /v${jclouds.api-version}/")
.documentation(URI.create("http://api.openstack.org/"))
.version("2.0")
.defaultEndpoint("http://localhost:5000/v${jclouds.api-version}/")
.defaultProperties(KeystoneApiMetadata.defaultProperties())
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(MappedAuthenticationApiModule.class)
.add(AuthenticationApiModule.class)
.add(KeystoneAuthenticationModule.class)
.add(KeystoneAdminURLModule.class)
.add(KeystoneParserModule.class)
.add(KeystoneRestClientModule.class).build());
.add(KeystoneHttpApiModule.class).build());
}
@Override
public KeystoneApiMetadata build() {
return new KeystoneApiMetadata(this);

View File

@ -0,0 +1,125 @@
/*
* 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.util.Suppliers2.getLastValueInMap;
import java.net.URI;
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.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.functions.PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet;
import org.jclouds.openstack.v2_0.services.Identity;
import org.jclouds.rest.ConfiguresHttpApi;
import org.jclouds.rest.annotations.ApiVersion;
import org.jclouds.rest.config.HttpApiModule;
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.ImmutableMultimap;
import com.google.common.collect.Multimap;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.assistedinject.FactoryModuleBuilder;
/**
* Configures the Keystone API.
*/
@ConfiguresHttpApi
public class KeystoneHttpApiModule extends HttpApiModule<KeystoneApi> {
public KeystoneHttpApiModule() {
}
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>> provideExtensionsByZone(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);
}
}

View File

@ -16,49 +16,88 @@
*/
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.javax.annotation.Nullable;
import org.jclouds.openstack.keystone.v2_0.domain.Role;
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.SelectJson;
import org.jclouds.rest.annotations.WrapWith;
import com.google.common.annotations.Beta;
import com.google.common.collect.FluentIterable;
/**
* Provides synchronous access to Role Administration actions.
* <p/>
*
* @see org.jclouds.openstack.keystone.v2_0.extensions.RoleAdminAsyncApi
* Provides access to the OpenStack Keystone Role Administration Extension API.
*
*/
@Beta
@Extension(of = ServiceType.IDENTITY, namespace = ExtensionNamespaces.OS_KSADM)
@Path("OS-KSADM/roles")
public interface RoleAdminApi {
/**
* Returns a summary list of roles.
*
*
* @return The list of roles
*/
@Named("role:list")
@GET
@SelectJson("roles")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
FluentIterable<? extends Role> list();
/**
* Creates a new Role
*
*
* @return the new Role
*/
Role create(String name);
@Named("role:create")
@POST
@SelectJson("role")
@Produces(MediaType.APPLICATION_JSON)
@WrapWith("role")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Role create(@PayloadParam("name") String name);
/**
* Gets the role
*
*
* @return the role
*/
Role get(String roleId);
@Named("role:get")
@GET
@SelectJson("role")
@Path("/{id}")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Role get(@PathParam("id") String roleId);
/**
* Deletes a role
*
*
* @return true if successful
*/
boolean delete(String roleId);
@Named("role:delete")
@DELETE
@Path("/{id}")
@Consumes
@Fallback(FalseOnNotFoundOr404.class)
boolean delete(@PathParam("id") String roleId);
}

View File

@ -16,54 +16,103 @@
*/
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.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.javax.annotation.Nullable;
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;
/**
* Provides synchronous access to Service Administration actions.
* <p/>
*
* @see org.jclouds.openstack.keystone.v2_0.extensions.ServiceAdminAsyncApi
* Provides access to Service Administration actions.
*/
@Beta
@Consumes(MediaType.APPLICATION_JSON)
@Extension(of = ServiceType.IDENTITY, namespace = ExtensionNamespaces.OS_KSADM)
@RequestFilters(AuthenticateRequest.class)
@Path("OS-KSADM/services")
public interface ServiceAdminApi {
/**
* Retrieve the list of services
* <p/>
*
*
* @return the list of services
*/
PagedIterable<? extends Service> list();
@Named("service:list")
@GET
@ResponseParser(ParseServices.class)
@Transform(ToPagedIterable.class)
@Fallback(EmptyPagedIterableOnNotFoundOr404.class)
PagedIterable<Service> list();
PaginatedCollection<? extends Service> list(PaginationOptions options);
@Named("service:list")
@GET
@ResponseParser(ParseServices.class)
@Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
PaginatedCollection<Service> list(PaginationOptions options);
/**
* Creates a new Service
*
*
* @return the new Service
*/
Service create(String name, String type, String description);
@Named("service:create")
@POST
@SelectJson("OS-KSADM:service")
@WrapWith("OS-KSADM:service")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Service create(@PayloadParam("name") String name, @PayloadParam("type") String type,
@PayloadParam("description") String description);
/**
* Gets the service
*
*
* @return the service
*/
Service get(String serviceId);
@Named("service:get")
@GET
@SelectJson("OS-KSADM:service")
@Path("/{serviceId}")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Service get(@PathParam("serviceId") String serviceId);
/**
* Deletes a service
*
*
* @return true if successful
*/
boolean delete(String serviceId);
@Named("service:delete")
@DELETE
@Path("/{id}")
@Fallback(FalseOnNotFoundOr404.class)
boolean delete(@PathParam("id") String serviceId);
}

View File

@ -16,64 +16,115 @@
*/
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.javax.annotation.Nullable;
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;
/**
* Provides synchronous access to Tenant Administration actions.
* <p/>
*
* @see org.jclouds.openstack.keystone.v2_0.extensions.TenantAdminAsyncApi
* Provides access to Tenant Administration actions.
*/
@Beta
@Consumes(MediaType.APPLICATION_JSON)
@Extension(of = ServiceType.IDENTITY, namespace = ExtensionNamespaces.OS_KSADM)
@RequestFilters(AuthenticateRequest.class)
@Path("/tenants")
public interface TenantAdminApi {
/**
* Creates a new tenant
*
*
* @return the new tenant
*/
Tenant create(String name);
@Named("tenant:create")
@POST
@SelectJson("tenant")
@Produces(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Tenant create(@PayloadParam("name") String name);
/**
* Creates a new tenant
*
*
* @return the new tenant
*/
Tenant create(String name, CreateTenantOptions options);
@Named("tenant:create")
@POST
@SelectJson("tenant")
@MapBinder(CreateTenantOptions.class)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Tenant create(@PayloadParam("name") String name, CreateTenantOptions options);
/**
* Deletes a tenant
*
*
* @return true if successful
*/
boolean delete(String userId);
@Named("tenant:delete")
@DELETE
@Path("/{id}")
@Fallback(FalseOnNotFoundOr404.class)
boolean delete(@PathParam("id") String userId);
/**
* Updates a tenant
*
*
* @return the updated tenant
*/
Tenant update(String id, UpdateTenantOptions options);
@Named("tenant:updateTenant")
@PUT
@Path("/{id}")
@SelectJson("tenant")
@MapBinder(UpdateTenantOptions.class)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Tenant update(@PathParam("id") String id, UpdateTenantOptions options);
/**
* Adds role to a user on a tenant
*
*
* @return true if successful
*/
boolean addRoleOnTenant(String tenantId, String userId, String roleId);
@Named("tenant:addRoleOnTenant")
@PUT
@Path("/{id}/users/{userId}/roles/OS-KSADM/{roleId}")
@Fallback(FalseOnNotFoundOr404.class)
boolean addRoleOnTenant(@PathParam("id") String tenantId, @PathParam("userId") String userId,
@PathParam("roleId") String roleId);
/**
* Deletes role to a user on tenant
*
*
* @return true if successful
*/
boolean deleteRoleOnTenant(String tenantId, String userId, String roleId);
@Named("tenant:deleteRoleOnTenant")
@DELETE
@Path("/{id}/users/{userId}/roles/OS-KSADM/{roleId}")
@Fallback(FalseOnNotFoundOr404.class)
boolean deleteRoleOnTenant(@PathParam("id") String tenantId, @PathParam("userId") String userdId,
@PathParam("roleId") String roleId);
}

View File

@ -16,50 +16,90 @@
*/
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.core.MediaType;
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.javax.annotation.Nullable;
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;
/**
* Provides synchronous access to User Administration actions.
* <p/>
*
* @see org.jclouds.openstack.keystone.v2_0.extensions.UserAdminAsyncApi
* Provides access to User Administration actions.
*/
@Beta
@Consumes(MediaType.APPLICATION_JSON)
@Extension(of = ServiceType.IDENTITY, namespace = ExtensionNamespaces.OS_KSADM)
@RequestFilters(AuthenticateRequest.class)
@Path("/users")
public interface UserAdminApi {
/**
* Creates a new user
*
* @return the new user
*/
User create(String name, String password);
/**
* Creates a new user
*
*
* @return the new user
*/
User create(String name, String password, CreateUserOptions options);
@Named("user:create")
@POST
@SelectJson("user")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
User create(@PayloadParam("name") String name, @PayloadParam("password") String password);
/**
* Creates a new user
*
* @return the new user
*/
@Named("user:create")
@POST
@SelectJson("user")
@MapBinder(CreateUserOptions.class)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
User create(@PayloadParam("name") String name,
@PayloadParam("password") String password, CreateUserOptions options);
/**
* Deletes an user
*
*
* @return true if successful
*/
boolean delete(String userId);
@Named("user:delete")
@DELETE
@Path("/{id}")
@Fallback(FalseOnNotFoundOr404.class)
boolean delete(@PathParam("id") String userId);
/**
* Updates an user
*
*
* @return the updated user
*/
User update(String id, UpdateUserOptions options);
@Named("user:updateUser")
@PUT
@Path("/{id}")
@SelectJson("user")
@MapBinder(UpdateUserOptions.class)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
User update(@PathParam("id") String id, UpdateUserOptions options);
}

View File

@ -17,21 +17,34 @@
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;
/**
* Provides synchronous access to the KeyStone Tenant API.
* <p/>
*
* @see ServiceAsyncApi
* @see <a href=
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Api_Operations.html"
* />
* Provides access to the Keystone Tenant API.
*/
@Consumes(MediaType.APPLICATION_JSON)
@RequestFilters(AuthenticateRequest.class)
@Path("/tenants")
public interface ServiceApi {
/**
* The operation returns a list of tenants which the current token provides access to.
*/
Set<? extends Tenant> listTenants();
@Named("service:listTenants")
@GET
@SelectJson("tenants")
@Fallback(EmptySetOnNotFoundOr404.class)
Set<Tenant> listTenants();
}

View File

@ -16,42 +16,83 @@
*/
package org.jclouds.openstack.keystone.v2_0.features;
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.v2_0.domain.PaginatedCollection;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
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.domain.PaginatedCollection;
import org.jclouds.openstack.v2_0.options.PaginationOptions;
import org.jclouds.openstack.v2_0.services.Identity;
import org.jclouds.rest.annotations.Endpoint;
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.inject.name.Named;
/**
* Provides synchronous access to the KeyStone Tenant API.
* <p/>
*
* @see TenantAsyncApi
* @see <a href=
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Tenant_Operations.html"
* />
* Provides access to the Keystone Tenant API.
*/
@Consumes(MediaType.APPLICATION_JSON)
@RequestFilters(AuthenticateRequest.class)
@Endpoint(Identity.class)
@Path("/tenants")
public interface TenantApi {
/**
* The operation returns a list of tenants which the current token provides access to.
*/
PagedIterable<? extends Tenant> list();
@Named("tenant:list")
@GET
@ResponseParser(ParseTenants.class)
@Transform(ToPagedIterable.class)
@Fallback(EmptyPagedIterableOnNotFoundOr404.class)
PagedIterable<Tenant> list();
PaginatedCollection<? extends Tenant> list(PaginationOptions options);
@Named("tenant:list")
@GET
@ResponseParser(ParseTenants.class)
@Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
PaginatedCollection<Tenant> list(PaginationOptions options);
/**
* Retrieve information about a tenant, by tenant ID
*
*
* @return the information about the tenant
*/
Tenant get(String tenantId);
@Named("tenant:get")
@GET
@SelectJson("tenant")
@Path("/{id}")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Tenant get(@PathParam("id") String tenantId);
/**
* Retrieve information about a tenant, by tenant name
* <p/>
* NOTE: currently not working in openstack ( https://bugs.launchpad.net/keystone/+bug/956687 )
*
*
* @return the information about the tenant
*/
Tenant getByName(String tenantName);
@Named("tenant:get")
@GET
@SelectJson("tenant")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Tenant getByName(@QueryParam("name") String tenantName);
}

View File

@ -17,46 +17,71 @@
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.javax.annotation.Nullable;
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 com.google.common.annotations.Beta;
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;
/**
* Provides synchronous access to the KeyStone Admin API.
* <p/>
*
* @see TokenAsyncApi
* @see <a href=
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Token_Operations.html"
* />
* Provides access to the Keystone Admin API.
*/
@Beta
@Consumes(MediaType.APPLICATION_JSON)
@RequestFilters(AuthenticateRequest.class)
@org.jclouds.rest.annotations.Endpoint(Identity.class)
@Path("/tokens/{token}")
public interface TokenApi {
/**
* Validate a token and, if it is valid, return access information regarding the tenant (though not the service catalog)/
*
* @return the requested information
*/
@Named("token:get")
@GET
@SelectJson("token")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Token get(@PathParam("token") String token);
/**
* Validate a token and, if it is valid, return access information regarding the tenant (though not the service catalog)/
*
* @return the requested information
*/
Token get(String token);
/**
* Validate a token and, if it is valid, return access information regarding the tenant (though not the service catalog)/
*
* @return the requested information
*/
User getUserOfToken(String token);
@Named("token:getuser")
@GET
@SelectJson("user")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
User getUserOfToken(@PathParam("token") String token);
/**
* Validate a token. This is a high-performance variant of the #getToken() call that does not return any further
* information.
*
* @return true if the token is valid
*/
boolean isValid(String token);
@Named("token:valid")
@HEAD
@Fallback(FalseOnNotFoundOr404.class)
boolean isValid(@PathParam("token") String token);
/**
* List all endpoints for a token
@ -65,6 +90,10 @@ public interface TokenApi {
*
* @return the set of endpoints
*/
Set<? extends Endpoint> listEndpointsForToken(String token);
@Named("token:listEndpoints")
@GET
@SelectJson("endpoints")
@Path("/endpoints")
@Fallback(EmptySetOnNotFoundOr404.class)
Set<Endpoint> listEndpointsForToken(@PathParam("token") String token);
}

View File

@ -17,67 +17,117 @@
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.v2_0.domain.PaginatedCollection;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
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.domain.PaginatedCollection;
import org.jclouds.openstack.v2_0.options.PaginationOptions;
import com.google.common.annotations.Beta;
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;
/**
* Provides synchronous access to the KeyStone User API.
* <p/>
*
* @see UserAsyncApi
* @see <a href=
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/User_Operations.html"
* />
* Provides access to the Keystone User API.
*/
@Beta
@Consumes(MediaType.APPLICATION_JSON)
@org.jclouds.rest.annotations.Endpoint(Identity.class)
@RequestFilters(AuthenticateRequest.class)
public interface UserApi {
/**
* Retrieve the list of users
* <p/>
* NOTE: this method is not in API documentation for keystone, but does work
*
*
* @return the list of users
*/
PagedIterable<? extends User> list();
@Named("user:list")
@GET
@Path("/users")
@ResponseParser(ParseUsers.class)
@Transform(ToPagedIterable.class)
@Fallback(EmptyPagedIterableOnNotFoundOr404.class)
PagedIterable<User> list();
PaginatedCollection<? extends User> list(PaginationOptions options);
@Named("user:list")
@GET
@Path("/users")
@ResponseParser(ParseUsers.class)
@Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
PaginatedCollection<User> list(PaginationOptions options);
/**
* Retrieve information about a user, by user ID
*
*
* @return the information about the user
*/
User get(String userId);
@Named("user:get")
@GET
@SelectJson("user")
@Path("/users/{userId}")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
User get(@PathParam("userId") String userId);
/**
* Retrieve information about a user, by user name
* <p/>
* NOTE: currently not working in openstack ( https://bugs.launchpad.net/keystone/+bug/956687 )
*
*
* @return the information about the user
*/
User getByName(String userName);
@Named("user:getByName")
@GET
@SelectJson("user")
@Path("/users")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
User getByName(@QueryParam("name") String userName);
/**
* Retrieves the list of global roles associated with a specific user (excludes tenant roles).
* <p/>
* NOTE: Broken in openstack ( https://bugs.launchpad.net/keystone/+bug/933565 )
*
*
* @return the set of Roles granted to the user
*/
Set<? extends Role> listRolesOfUser(String userId);
@Named("user:listRolesOfUser")
@GET
@SelectJson("roles")
@Path("/users/{userId}/roles")
@Fallback(EmptySetOnNotFoundOr404.class)
Set<Role> listRolesOfUser(@PathParam("userId") String userId);
/**
* List the roles a user has been granted on a specific tenant
*
*
* @return the set of roles
*/
Set<? extends Role> listRolesOfUserOnTenant(String userId, String tenantId);
@Named("user:listRolesOfUserOnTenant")
@GET
@SelectJson("roles")
@Path("/tenants/{tenantId}/users/{userId}/roles")
@Fallback(EmptySetOnNotFoundOr404.class)
Set<Role> listRolesOfUserOnTenant(@PathParam("userId") String userId,
@PathParam("tenantId") String tenantId);
}

View File

@ -27,6 +27,7 @@ import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.openstack.v2_0.domain.Extension;
import org.jclouds.rest.annotations.Fallback;
@ -34,27 +35,27 @@ import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
/**
* Provides asynchronous access to Extensions via their REST API.
* Provides access to OpenStack Extension APIs.
*/
@Consumes(MediaType.APPLICATION_JSON)
@RequestFilters(AuthenticateRequest.class)
@Path("/extensions")
public interface ExtensionApi {
/**
* Lists all available extensions
*
*
* @return all extensions
*/
@Named("extension:list")
@GET
@SelectJson("extensions")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/extensions")
@Fallback(EmptySetOnNotFoundOr404.class)
Set<Extension> list();
/**
* Extensions may also be queried individually by their unique alias.
*
*
* @param id
* id of the extension
* @return extension or null if not found
@ -62,8 +63,8 @@ public interface ExtensionApi {
@Named("extension:get")
@GET
@SelectJson("extension")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/extensions/{alias}")
@Path("/{alias}")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Extension get(@PathParam("alias") String id);
}

View File

@ -111,7 +111,9 @@ public class TokenApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneAp
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
HttpRequest.builder().method("HEAD")
.endpoint(endpoint + "/v2.0/tokens/sometokenorother")
.addHeader("X-Auth-Token", authToken).build(),
.addHeader("Accept", APPLICATION_JSON)
.addHeader("X-Auth-Token", authToken)
.build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build())
.getTokenApi().get();
assertTrue(api.isValid("sometokenorother"));
@ -122,7 +124,9 @@ public class TokenApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneAp
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
HttpRequest.builder().method("HEAD")
.endpoint(endpoint + "/v2.0/tokens/sometokenorother")
.addHeader("X-Auth-Token", authToken).build(),
.addHeader("Accept", APPLICATION_JSON)
.addHeader("X-Auth-Token", authToken)
.build(),
HttpResponse.builder().statusCode(404).build()).getTokenApi().get();
assertFalse(api.isValid("sometokenorother"));
}

View File

@ -16,40 +16,27 @@
*/
package org.jclouds.rackspace.cloudidentity.v2_0;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE;
import java.net.URI;
import java.util.Properties;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.KeystoneApiMetadata;
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncApi;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneHttpApiModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneHttpApiModule.KeystoneAdminURLModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneParserModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule.KeystoneAdminURLModule;
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.common.reflect.TypeToken;
import com.google.inject.Module;
/**
* Implementation of {@link ApiMetadata} for the Rackspace Cloud Identity Service
*/
public class CloudIdentityApiMetadata extends KeystoneApiMetadata {
/**
* @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() {
@ -63,7 +50,7 @@ public class CloudIdentityApiMetadata extends KeystoneApiMetadata {
protected CloudIdentityApiMetadata(Builder builder) {
super(builder);
}
public static Properties defaultProperties() {
Properties properties = KeystoneApiMetadata.defaultProperties();
properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS);
@ -71,9 +58,7 @@ public class CloudIdentityApiMetadata extends KeystoneApiMetadata {
}
public static class Builder extends KeystoneApiMetadata.Builder<Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
super(KeystoneApi.class, KeystoneAsyncApi.class);
id("rackspace-cloudidentity")
.name("Rackspace Cloud Identity Service")
.identityName("${userName}")
@ -81,16 +66,15 @@ public class CloudIdentityApiMetadata extends KeystoneApiMetadata {
.defaultEndpoint("https://identity.api.rackspacecloud.com/v${jclouds.api-version}/")
.endpointName("identity service url ending in /v${jclouds.api-version}/")
.defaultProperties(CloudIdentityApiMetadata.defaultProperties())
.context(CONTEXT_TOKEN)
.documentation(URI.create("http://docs.rackspace.com/auth/api/v2.0/auth-api-devguide/"))
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(SyncToAsyncCloudIdentityAuthenticationApiModule.class)
.add(CloudIdentityAuthenticationApiModule.class)
.add(CloudIdentityAuthenticationModule.class)
.add(KeystoneAdminURLModule.class)
.add(KeystoneParserModule.class)
.add(KeystoneRestClientModule.class).build());
.add(KeystoneHttpApiModule.class).build());
}
@Override
public CloudIdentityApiMetadata build() {
return new CloudIdentityApiMetadata(this);

View File

@ -32,41 +32,33 @@ import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.SelectJson;
/**
* Provides synchronous access to the KeyStone Service API.
* <p/>
*
* @see <a href=
* "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Api_Operations.html"
* />
* Provides access to the Rackspace Cloud Identity API.
*/
@Consumes(MediaType.APPLICATION_JSON)
@Path("/tokens")
public interface CloudIdentityAuthenticationApi extends AuthenticationApi {
/**
* Authenticate to generate a token.
*
*
* @return access with token
*/
@Named("authenticate")
@POST
@SelectJson("access")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/tokens")
@MapBinder(BindAuthToJsonPayload.class)
Access authenticateWithTenantNameAndCredentials(@Nullable @PayloadParam("tenantName") String tenantName,
ApiKeyCredentials apiKeyCredentials);
/**
* Authenticate to generate a token.
*
*
* @return access with token
*/
@Named("authenticate")
@POST
@SelectJson("access")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/tokens")
@MapBinder(BindAuthToJsonPayload.class)
Access authenticateWithTenantIdAndCredentials(@Nullable @PayloadParam("tenantId") String tenantId,
ApiKeyCredentials apiKeyCredentials);
}

View File

@ -1,73 +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.rackspace.cloudidentity.v2_0;
import javax.inject.Named;
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.AuthenticationAsyncApi;
import org.jclouds.openstack.keystone.v2_0.binders.BindAuthToJsonPayload;
import org.jclouds.openstack.keystone.v2_0.domain.Access;
import org.jclouds.rackspace.cloudidentity.v2_0.domain.ApiKeyCredentials;
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 CloudIdentityAuthenticationAsyncApi}
*/
@Deprecated
public interface CloudIdentityAuthenticationAsyncApi extends AuthenticationAsyncApi {
/**
* @see CloudIdentityAuthenticationAsyncApi#authenticateWithTenantNameAndCredentials(String,ApiKeyCredentials)
*/
@Named("auth:tenantnameandcreds")
@POST
@SelectJson("access")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/tokens")
@MapBinder(BindAuthToJsonPayload.class)
ListenableFuture<Access> authenticateWithTenantNameAndCredentials(@Nullable @PayloadParam("tenantName") String tenantName,
ApiKeyCredentials apiKeyCredentials);
/**
* @see CloudIdentityAuthenticationAsyncApi#authenticateWithTenantIdAndCredentials(String,ApiKeyCredentials)
*/
@Named("auth:tenantidandcreds")
@POST
@SelectJson("access")
@Consumes(MediaType.APPLICATION_JSON)
@Path("/tokens")
@MapBinder(BindAuthToJsonPayload.class)
ListenableFuture<Access> authenticateWithTenantIdAndCredentials(@Nullable @PayloadParam("tenantId") String tenantId,
ApiKeyCredentials apiKeyCredentials);
}

View File

@ -1,55 +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.rackspace.cloudidentity.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 org.jclouds.rackspace.cloudidentity.v2_0.CloudIdentityAuthenticationApi;
import org.jclouds.rackspace.cloudidentity.v2_0.CloudIdentityAuthenticationAsyncApi;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
/**
*
* @deprecated will be removed in jclouds 1.7, as async interfaces are no longer
* supported. please use
* {@link CloudIdentityAuthenticationApiModule}
*/
@Deprecated
public class SyncToAsyncCloudIdentityAuthenticationApiModule extends AbstractModule {
@Override
protected void configure() {
// AuthenticationApi is used directly for filters and retry handlers, so
// let's bind it explicitly
bindSyncToAsyncHttpApi(binder(), CloudIdentityAuthenticationApi.class, CloudIdentityAuthenticationAsyncApi.class);
}
@Provides
private AuthenticationApi provideAuthenticationApi(CloudIdentityAuthenticationApi in) {
return in;
}
@Provides
private AuthenticationAsyncApi provideAuthenticationAsyncApi(CloudIdentityAuthenticationAsyncApi in) {
return in;
}
}

View File

@ -17,14 +17,14 @@
package org.jclouds.rackspace.cloudidentity.v2_0;
import org.jclouds.View;
import org.jclouds.rest.internal.BaseRestApiMetadataTest;
import org.jclouds.apis.internal.BaseApiMetadataTest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
@Test(groups = "unit", testName = "CloudIdentityApiMetadataTest")
public class CloudIdentityApiMetadataTest extends BaseRestApiMetadataTest {
public class CloudIdentityApiMetadataTest extends BaseApiMetadataTest {
// no identity abstraction, yet
public CloudIdentityApiMetadataTest() {

View File

@ -29,24 +29,26 @@ 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)

View File

@ -15,18 +15,36 @@
* 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 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" />
* Provides access to OpenStack auth.
*/
@Path("/v{" + Constants.PROPERTY_API_VERSION + "}")
public interface OpenStackAuthClient {
AuthenticationResponse authenticate(String user, String key);
AuthenticationResponse authenticateStorage(String user, String key);
@Named("authenticate")
@GET
@Consumes
@ResponseParser(ParseAuthenticationResponseFromHeaders.class)
AuthenticationResponse authenticate(@HeaderParam(AuthHeaders.AUTH_USER) String user,
@HeaderParam(AuthHeaders.AUTH_KEY) String key);
@Named("authenticate")
@GET
@Consumes
@ResponseParser(ParseAuthenticationResponseFromHeaders.class)
AuthenticationResponse authenticateStorage(@HeaderParam(AuthHeaders.STORAGE_USER) String user,
@HeaderParam(AuthHeaders.STORAGE_PASS) String key);
}

View File

@ -16,22 +16,34 @@
*/
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.SelectJson;
import com.google.inject.name.Named;
/**
* Provides synchronous access to the KeyStone Service API.
* <p/>
*
* @see AuthenticationAsyncClient
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html"
* />
* Provides access to the Keystone v1.1 Service API.
*/
@Consumes(MediaType.APPLICATION_JSON)
@Path("/v1.1")
public interface AuthenticationClient {
/**
* Authenticate to generate a token.
*
*
* @return access with token
*/
@Named("authenticate")
@POST
@SelectJson("auth")
@Path("/auth")
@MapBinder(BindCredentialsToJsonPayload.class)
Auth authenticate(String username, String key);
}