openstack-keystone extensibility

This commit is contained in:
Andrew Donald Kennedy 2012-08-12 12:04:54 +01:00
parent 4fad770eaf
commit 6c9524dabc
16 changed files with 33 additions and 33 deletions

View File

@ -40,5 +40,5 @@ public interface ServiceApi {
/** /**
* The operation returns a list of tenants which the current token provides access to. * The operation returns a list of tenants which the current token provides access to.
*/ */
Set<Tenant> listTenants(); Set<? extends Tenant> listTenants();
} }

View File

@ -57,5 +57,5 @@ public interface ServiceAsyncApi {
@Path("/tenants") @Path("/tenants")
@RequestFilters(AuthenticateRequest.class) @RequestFilters(AuthenticateRequest.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Tenant>> listTenants(); ListenableFuture<? extends Set<? extends Tenant>> listTenants();
} }

View File

@ -40,7 +40,7 @@ public interface TenantApi {
/** /**
* The operation returns a list of tenants which the current token provides access to. * The operation returns a list of tenants which the current token provides access to.
*/ */
Set<Tenant> list(); Set<? extends Tenant> list();
/** /**
* Retrieve information about a tenant, by tenant ID * Retrieve information about a tenant, by tenant ID

View File

@ -62,7 +62,7 @@ public interface TenantAsyncApi {
@Path("/tenants") @Path("/tenants")
@RequestFilters(AuthenticateRequest.class) @RequestFilters(AuthenticateRequest.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Tenant>> list(); ListenableFuture<? extends Set<? extends Tenant>> list();
/** @see TenantApi#get(String) */ /** @see TenantApi#get(String) */
@GET @GET
@ -71,7 +71,7 @@ public interface TenantAsyncApi {
@Path("/tenants/{tenantId}") @Path("/tenants/{tenantId}")
@RequestFilters(AuthenticateRequest.class) @RequestFilters(AuthenticateRequest.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Tenant> get(@PathParam("tenantId") String tenantId); ListenableFuture<? extends Tenant> get(@PathParam("tenantId") String tenantId);
/** @see TenantApi#getByName(String) */ /** @see TenantApi#getByName(String) */
@GET @GET
@ -80,6 +80,6 @@ public interface TenantAsyncApi {
@Path("/tenants") @Path("/tenants")
@RequestFilters(AuthenticateRequest.class) @RequestFilters(AuthenticateRequest.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Tenant> getByName(@QueryParam("name") String tenantName); ListenableFuture<? extends Tenant> getByName(@QueryParam("name") String tenantName);
} }

View File

@ -72,6 +72,6 @@ public interface TokenApi {
* *
* @return the set of endpoints * @return the set of endpoints
*/ */
Set<Endpoint> listEndpointsForToken(String token); Set<? extends Endpoint> listEndpointsForToken(String token);
} }

View File

@ -64,7 +64,7 @@ public interface TokenAsyncApi {
@Path("/tokens/{token}") @Path("/tokens/{token}")
@RequestFilters(AuthenticateRequest.class) @RequestFilters(AuthenticateRequest.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Token> get(@PathParam("token") String token); ListenableFuture<? extends Token> get(@PathParam("token") String token);
/** @see TokenApi#getUserOfToken(String) */ /** @see TokenApi#getUserOfToken(String) */
@GET @GET
@ -73,7 +73,7 @@ public interface TokenAsyncApi {
@Path("/tokens/{token}") @Path("/tokens/{token}")
@RequestFilters(AuthenticateRequest.class) @RequestFilters(AuthenticateRequest.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<User> getUserOfToken(@PathParam("token") String token); ListenableFuture<? extends User> getUserOfToken(@PathParam("token") String token);
/** @see TokenApi#isValid(String) */ /** @see TokenApi#isValid(String) */
@HEAD @HEAD
@ -89,6 +89,6 @@ public interface TokenAsyncApi {
@Path("/tokens/{token}/endpoints") @Path("/tokens/{token}/endpoints")
@RequestFilters(AuthenticateRequest.class) @RequestFilters(AuthenticateRequest.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Endpoint>> listEndpointsForToken(@PathParam("token") String token); ListenableFuture<? extends Set<? extends Endpoint>> listEndpointsForToken(@PathParam("token") String token);
} }

View File

@ -48,7 +48,7 @@ public interface UserApi {
* *
* @return the list of users * @return the list of users
*/ */
Set<User> list(); Set<? extends User> list();
/** /**
* Retrieve information about a user, by user ID * Retrieve information about a user, by user ID
@ -73,13 +73,13 @@ public interface UserApi {
* *
* @return the set of Roles granted to the user * @return the set of Roles granted to the user
*/ */
Set<Role> listRolesOfUser(String userId); Set<? extends Role> listRolesOfUser(String userId);
/** /**
* List the roles a user has been granted on a specific tenant * List the roles a user has been granted on a specific tenant
* *
* @return the set of roles * @return the set of roles
*/ */
Set<Role> listRolesOfUserOnTenant(String userId, String tenantId); Set<? extends Role> listRolesOfUserOnTenant(String userId, String tenantId);
} }

View File

@ -61,7 +61,7 @@ public interface UserAsyncApi {
@Path("/users") @Path("/users")
@RequestFilters(AuthenticateRequest.class) @RequestFilters(AuthenticateRequest.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<User>> list(); ListenableFuture<? extends Set<? extends User>> list();
/** @see UserApi#get(String) */ /** @see UserApi#get(String) */
@GET @GET
@ -70,7 +70,7 @@ public interface UserAsyncApi {
@Path("/users/{userId}") @Path("/users/{userId}")
@RequestFilters(AuthenticateRequest.class) @RequestFilters(AuthenticateRequest.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<User> get(@PathParam("userId") String userId); ListenableFuture<? extends User> get(@PathParam("userId") String userId);
/** @see UserApi#getByName(String) */ /** @see UserApi#getByName(String) */
@GET @GET
@ -79,7 +79,7 @@ public interface UserAsyncApi {
@Path("/users") @Path("/users")
@RequestFilters(AuthenticateRequest.class) @RequestFilters(AuthenticateRequest.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<User> getByName(@QueryParam("name") String userName); ListenableFuture<? extends User> getByName(@QueryParam("name") String userName);
/** @see UserApi#listRolesOfUser(String) */ /** @see UserApi#listRolesOfUser(String) */
@GET @GET
@ -88,7 +88,7 @@ public interface UserAsyncApi {
@Path("/users/{userId}/roles") @Path("/users/{userId}/roles")
@RequestFilters(AuthenticateRequest.class) @RequestFilters(AuthenticateRequest.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Role>> listRolesOfUser(@PathParam("userId") String userId); ListenableFuture<? extends Set<? extends Role>> listRolesOfUser(@PathParam("userId") String userId);
/** @see UserApi#listRolesOfUserOnTenant(String, String) */ /** @see UserApi#listRolesOfUserOnTenant(String, String) */
@GET @GET
@ -97,5 +97,5 @@ public interface UserAsyncApi {
@Path("/tenants/{tenantId}/users/{userId}/roles") @Path("/tenants/{tenantId}/users/{userId}/roles")
@RequestFilters(AuthenticateRequest.class) @RequestFilters(AuthenticateRequest.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Role>> listRolesOfUserOnTenant(@PathParam("userId") String userId, @PathParam("tenantId") String tenantId); ListenableFuture<? extends Set<? extends Role>> listRolesOfUserOnTenant(@PathParam("userId") String userId, @PathParam("tenantId") String tenantId);
} }

View File

@ -50,7 +50,7 @@ public class ServiceApiExpectTest extends BaseKeystoneRestApiExpectTest<Keystone
HttpResponse.builder().statusCode(200) HttpResponse.builder().statusCode(200)
.payload(payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build()) .payload(payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build())
.getServiceApi(); .getServiceApi();
Set<Tenant> tenants = api.listTenants(); Set<? extends Tenant> tenants = api.listTenants();
assertNotNull(tenants); assertNotNull(tenants);
assertFalse(tenants.isEmpty()); assertFalse(tenants.isEmpty());

View File

@ -37,7 +37,7 @@ public class ServiceApiLiveTest extends BaseKeystoneApiLiveTest {
public void testTenants() { public void testTenants() {
ServiceApi api = keystoneContext.getApi().getServiceApi(); ServiceApi api = keystoneContext.getApi().getServiceApi();
Set<Tenant> result = api.listTenants(); Set<? extends Tenant> result = api.listTenants();
assertNotNull(result); assertNotNull(result);
assertFalse(result.isEmpty()); assertFalse(result.isEmpty());

View File

@ -56,7 +56,7 @@ public class TenantApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneA
HttpResponse.builder().statusCode(200).payload( HttpResponse.builder().statusCode(200).payload(
payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build()) payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build())
.getTenantApi().get(); .getTenantApi().get();
Set<Tenant> tenants = api.list(); Set<? extends Tenant> tenants = api.list();
assertNotNull(tenants); assertNotNull(tenants);
assertFalse(tenants.isEmpty()); assertFalse(tenants.isEmpty());
@ -74,7 +74,7 @@ public class TenantApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneA
HttpResponse.builder().statusCode(200).payload( HttpResponse.builder().statusCode(200).payload(
payloadFromResourceWithContentType("/tenant_list_att.json", APPLICATION_JSON)).build()) payloadFromResourceWithContentType("/tenant_list_att.json", APPLICATION_JSON)).build())
.getTenantApi().get(); .getTenantApi().get();
Set<Tenant> tenants = api.list(); Set<? extends Tenant> tenants = api.list();
assertNotNull(tenants); assertNotNull(tenants);
assertFalse(tenants.isEmpty()); assertFalse(tenants.isEmpty());

View File

@ -38,7 +38,7 @@ public class TenantApiLiveTest extends BaseKeystoneApiLiveTest {
public void testTenants() { public void testTenants() {
TenantApi api = keystoneContext.getApi().getTenantApi().get(); TenantApi api = keystoneContext.getApi().getTenantApi().get();
Set<Tenant> result = api.list(); Set<? extends Tenant> result = api.list();
assertNotNull(result); assertNotNull(result);
assertFalse(result.isEmpty()); assertFalse(result.isEmpty());

View File

@ -138,7 +138,7 @@ public class TokenApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneAp
authenticatedGET().endpoint(endpoint + "/v2.0/tokens/XXXXXX/endpoints").build(), authenticatedGET().endpoint(endpoint + "/v2.0/tokens/XXXXXX/endpoints").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_endpoints.json", APPLICATION_JSON)).build()) HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_endpoints.json", APPLICATION_JSON)).build())
.getTokenApi().get(); .getTokenApi().get();
Set<Endpoint> endpoints = api.listEndpointsForToken("XXXXXX"); Set<? extends Endpoint> endpoints = api.listEndpointsForToken("XXXXXX");
assertEquals(endpoints, ImmutableSet.of( assertEquals(endpoints, ImmutableSet.of(
Endpoint.builder().publicURL(URI.create("https://csnode.jclouds.org/v2.0/")) Endpoint.builder().publicURL(URI.create("https://csnode.jclouds.org/v2.0/"))

View File

@ -82,7 +82,7 @@ public class TokenApiLiveTest extends BaseKeystoneApiLiveTest {
public void testTokenEndpoints() { public void testTokenEndpoints() {
TokenApi api = keystoneContext.getApi().getTokenApi().get(); TokenApi api = keystoneContext.getApi().getTokenApi().get();
Set<Endpoint> endpoints = api.listEndpointsForToken(token); Set<? extends Endpoint> endpoints = api.listEndpointsForToken(token);
assertNotNull(endpoints); assertNotNull(endpoints);
assertFalse(endpoints.isEmpty()); assertFalse(endpoints.isEmpty());

View File

@ -56,7 +56,7 @@ public class UserApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneApi
authenticatedGET().endpoint(endpoint + "/v2.0/users").build(), authenticatedGET().endpoint(endpoint + "/v2.0/users").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_list.json", APPLICATION_JSON)).build()) HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_list.json", APPLICATION_JSON)).build())
.getUserApi().get(); .getUserApi().get();
Set<User> users = api.list(); Set<? extends User> users = api.list();
assertNotNull(users); assertNotNull(users);
assertFalse(users.isEmpty()); assertFalse(users.isEmpty());
@ -123,7 +123,7 @@ public class UserApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneApi
authenticatedGET().endpoint(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(), authenticatedGET().endpoint(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_role_list.json", APPLICATION_JSON)).build()) HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_role_list.json", APPLICATION_JSON)).build())
.getUserApi().get(); .getUserApi().get();
Set<Role> roles = api.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f"); Set<? extends Role> roles = api.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f");
assertNotNull(roles); assertNotNull(roles);
assertFalse(roles.isEmpty()); assertFalse(roles.isEmpty());
assertEquals(roles, ImmutableSet.of( assertEquals(roles, ImmutableSet.of(
@ -154,7 +154,7 @@ public class UserApiExpectTest extends BaseKeystoneRestApiExpectTest<KeystoneApi
authenticatedGET().endpoint(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(), authenticatedGET().endpoint(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_tenant_role_list.json", APPLICATION_JSON)).build()) HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/user_tenant_role_list.json", APPLICATION_JSON)).build())
.getUserApi().get(); .getUserApi().get();
Set<Role> roles = api.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f"); Set<? extends Role> roles = api.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f");
assertNotNull(roles); assertNotNull(roles);
assertFalse(roles.isEmpty()); assertFalse(roles.isEmpty());
assertEquals(roles, ImmutableSet.of( assertEquals(roles, ImmutableSet.of(

View File

@ -41,7 +41,7 @@ public class UserApiLiveTest extends BaseKeystoneApiLiveTest {
public void testUsers() { public void testUsers() {
UserApi api = keystoneContext.getApi().getUserApi().get(); UserApi api = keystoneContext.getApi().getUserApi().get();
Set<User> users = api.list(); Set<? extends User> users = api.list();
assertNotNull(users); assertNotNull(users);
assertFalse(users.isEmpty()); assertFalse(users.isEmpty());
for (User user : users) { for (User user : users) {
@ -54,12 +54,12 @@ public class UserApiLiveTest extends BaseKeystoneApiLiveTest {
public void testUserRolesOnTenant() { public void testUserRolesOnTenant() {
UserApi api = keystoneContext.getApi().getUserApi().get(); UserApi api = keystoneContext.getApi().getUserApi().get();
Set<User> users = api.list(); Set<? extends User> users = api.list();
Set<Tenant> tenants = keystoneContext.getApi().getTenantApi().get().list(); Set<? extends Tenant> tenants = keystoneContext.getApi().getTenantApi().get().list();
for (User user : users) { for (User user : users) {
for (Tenant tenant : tenants) { for (Tenant tenant : tenants) {
Set<Role> roles = api.listRolesOfUserOnTenant(user.getId(), tenant.getId()); Set<? extends Role> roles = api.listRolesOfUserOnTenant(user.getId(), tenant.getId());
for (Role role : roles) { for (Role role : roles) {
assertNotNull(role.getId()); assertNotNull(role.getId());
} }
@ -72,7 +72,7 @@ public class UserApiLiveTest extends BaseKeystoneApiLiveTest {
UserApi api = keystoneContext.getApi().getUserApi().get(); UserApi api = keystoneContext.getApi().getUserApi().get();
for (User user : api.list()) { for (User user : api.list()) {
Set<Role> roles = api.listRolesOfUser(user.getId()); Set<? extends Role> roles = api.listRolesOfUser(user.getId());
for (Role role : roles) { for (Role role : roles) {
assertNotNull(role.getId()); assertNotNull(role.getId());
} }