You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2014/03/14 10:03:38 UTC
[3/3] git commit: JCLOUDS-453. Add OpenStack Keystone v2.0 OS-KSADM
Admin Extension support for Keystone.
JCLOUDS-453. Add OpenStack Keystone v2.0 OS-KSADM Admin Extension support for Keystone.
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/b68f1b6e
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/b68f1b6e
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/b68f1b6e
Branch: refs/heads/master
Commit: b68f1b6e1a4ff60540a85210fe811be82f6d3b77
Parents: e7fccd6
Author: Pedro Navarro PĂ©rez <pe...@gmail.com>
Authored: Thu Jan 30 11:12:05 2014 +0100
Committer: Ignasi Barrera <na...@apache.org>
Committed: Fri Mar 14 09:54:38 2014 +0100
----------------------------------------------------------------------
.../openstack/keystone/v2_0/KeystoneApi.java | 28 ++
.../keystone/v2_0/KeystoneAsyncApi.java | 28 ++
.../v2_0/config/KeystoneRestClientModule.java | 12 +
.../openstack/keystone/v2_0/domain/Service.java | 60 +++-
.../openstack/keystone/v2_0/domain/Tenant.java | 65 +++--
.../openstack/keystone/v2_0/domain/User.java | 110 +++++--
.../v2_0/extensions/ExtensionNamespaces.java | 30 ++
.../keystone/v2_0/extensions/RoleAdminApi.java | 65 +++++
.../v2_0/extensions/RoleAdminAsyncApi.java | 111 +++++++
.../v2_0/extensions/ServiceAdminApi.java | 70 +++++
.../v2_0/extensions/ServiceAdminAsyncApi.java | 127 ++++++++
.../v2_0/extensions/TenantAdminApi.java | 80 +++++
.../v2_0/extensions/TenantAdminAsyncApi.java | 138 +++++++++
.../keystone/v2_0/extensions/UserAdminApi.java | 66 +++++
.../v2_0/extensions/UserAdminAsyncApi.java | 114 ++++++++
.../v2_0/functions/internal/ParseServices.java | 95 ++++++
.../v2_0/options/CreateTenantOptions.java | 144 +++++++++
.../v2_0/options/CreateUserOptions.java | 180 ++++++++++++
.../v2_0/options/UpdateTenantOptions.java | 159 ++++++++++
.../v2_0/options/UpdateUserOptions.java | 193 ++++++++++++
.../v2_0/extensions/RoleAdminApiLiveTest.java | 105 +++++++
.../v2_0/extensions/RoleAdminApiMockTest.java | 249 ++++++++++++++++
.../extensions/ServiceAdminApiLiveTest.java | 106 +++++++
.../extensions/ServiceAdminApiMockTest.java | 285 ++++++++++++++++++
.../v2_0/extensions/TenantAdminApiLiveTest.java | 101 +++++++
.../v2_0/extensions/TenantAdminApiMockTest.java | 292 +++++++++++++++++++
.../v2_0/extensions/UserAdminApiLiveTest.java | 102 +++++++
.../v2_0/extensions/UserAdminApiMockTest.java | 200 +++++++++++++
.../v2_0/features/ServiceApiExpectTest.java | 3 +-
.../v2_0/features/TenantApiExpectTest.java | 9 +-
.../v2_0/features/TokenApiExpectTest.java | 2 +-
.../v2_0/features/UserApiExpectTest.java | 19 +-
.../v2_0/functions/internal/ParseUsersTest.java | 12 +-
.../v2_0/parse/ParseAdminAccessTest.java | 3 +-
.../ParseRandomEndpointVersionAccessTest.java | 2 +-
.../v2_0/internal/BaseOpenStackMockTest.java | 12 +
.../src/test/resources/admin_extensions.json | 1 +
.../test/resources/role_create_response.json | 1 +
.../src/test/resources/role_list_response.json | 1 +
.../test/resources/service_create_response.json | 1 +
.../test/resources/service_list_response.json | 1 +
.../test/resources/tenant_create_response.json | 1 +
.../test/resources/tenant_update_response.json | 1 +
.../test/resources/user_create_response.json | 1 +
.../test/resources/user_update_response.json | 1 +
45 files changed, 3310 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApi.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApi.java
index 394fdb3..2a67c0c 100644
--- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApi.java
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApi.java
@@ -19,6 +19,10 @@ package org.jclouds.openstack.keystone.v2_0;
import java.io.Closeable;
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;
+import org.jclouds.openstack.keystone.v2_0.extensions.TenantAdminApi;
+import org.jclouds.openstack.keystone.v2_0.extensions.UserAdminApi;
import org.jclouds.openstack.keystone.v2_0.features.ServiceApi;
import org.jclouds.openstack.keystone.v2_0.features.TenantApi;
import org.jclouds.openstack.keystone.v2_0.features.TokenApi;
@@ -74,4 +78,28 @@ public interface KeystoneApi extends Closeable {
*/
@Delegate
Optional<? extends TenantApi> getTenantApi();
+
+ /**
+ * Provides synchronous access to Admin user features
+ */
+ @Delegate
+ Optional<? extends UserAdminApi> getUserAdminApi();
+
+ /**
+ * Provides synchronous access to Admin tenant features
+ */
+ @Delegate
+ Optional<? extends TenantAdminApi> getTenantAdminApi();
+
+ /**
+ * Provides synchronous access to Admin role features
+ */
+ @Delegate
+ Optional<? extends RoleAdminApi> getRoleAdminApi();
+
+ /**
+ * Provides synchronous access to Admin service features
+ */
+ @Delegate
+ Optional<? extends ServiceAdminApi> getServiceAdminApi();
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/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
index b5f044c..e0a0b1d 100644
--- 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
@@ -24,6 +24,10 @@ 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;
@@ -87,4 +91,28 @@ public interface KeystoneAsyncApi extends Closeable {
*/
@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/b68f1b6e/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
index ff17044..9006d23 100644
--- 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
@@ -34,6 +34,14 @@ 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;
@@ -85,6 +93,10 @@ public class KeystoneRestClientModule<S extends KeystoneApi, A extends KeystoneA
.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")
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Service.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Service.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Service.java
index 0480c45..b4836ff 100644
--- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Service.java
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Service.java
@@ -21,6 +21,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Set;
+import org.jclouds.javax.annotation.Nullable;
+
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ForwardingSet;
@@ -48,9 +50,19 @@ public class Service extends ForwardingSet<Endpoint> {
public abstract static class Builder<T extends Builder<T>> {
protected abstract T self();
+ protected String id;
protected String type;
protected String name;
+ protected String description;
protected ImmutableSet.Builder<Endpoint> endpoints = ImmutableSet.<Endpoint>builder();
+
+ /**
+ * @see Service#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
/**
* @see Service#getType()
@@ -67,6 +79,14 @@ public class Service extends ForwardingSet<Endpoint> {
this.name = name;
return self();
}
+
+ /**
+ * @see Service#getDescription()
+ */
+ public T description(String description) {
+ this.description = description;
+ return self();
+ }
/**
* @see Service#delegate()
@@ -85,13 +105,15 @@ public class Service extends ForwardingSet<Endpoint> {
}
public Service build() {
- return new Service(type, name, endpoints.build());
+ return new Service(id, type, name, description, endpoints.build());
}
public T fromService(Service in) {
return this
+ .id(in.getId())
.type(in.getType())
.name(in.getName())
+ .description(in.getDescription())
.endpoints(in);
}
}
@@ -102,17 +124,31 @@ public class Service extends ForwardingSet<Endpoint> {
}
}
+ private final String id;
private final String type;
private final String name;
+ private final String description;
private final Set<Endpoint> endpoints;
@ConstructorProperties({
- "type", "name", "endpoints"
+ "id", "type", "name", "description", "endpoints"
})
- protected Service(String type, String name, Set<Endpoint> endpoints) {
+ protected Service(@Nullable String id, String type, String name, @Nullable String description, @Nullable Set<Endpoint> endpoints) {
+ this.id = id;
this.type = checkNotNull(type, "type");
this.name = checkNotNull(name, "name");
- this.endpoints = ImmutableSet.copyOf(checkNotNull(endpoints, "endpoints"));
+ this.description = description;
+ this.endpoints = endpoints == null ? ImmutableSet.<Endpoint>of() : ImmutableSet.copyOf(endpoints);
+ }
+
+ /**
+ * When providing an ID, it is assumed that the service exists in the current OpenStack deployment
+ *
+ * @return the id of the service in the current OpenStack deployment
+ */
+ @Nullable
+ public String getId() {
+ return this.id;
}
/**
@@ -130,10 +166,17 @@ public class Service extends ForwardingSet<Endpoint> {
public String getName() {
return this.name;
}
+
+ /**
+ * @return the description of the service
+ */
+ public String getDescription() {
+ return this.description;
+ }
@Override
public int hashCode() {
- return Objects.hashCode(type, name, endpoints);
+ return Objects.hashCode(id, type, name, description, endpoints);
}
@Override
@@ -141,14 +184,17 @@ public class Service extends ForwardingSet<Endpoint> {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
Service that = Service.class.cast(obj);
- return Objects.equal(this.type, that.type)
+ return Objects.equal(this.id, that.id)
+ && Objects.equal(this.type, that.type)
&& Objects.equal(this.name, that.name)
+ && Objects.equal(this.description, that.description)
&& Objects.equal(this.endpoints, that.endpoints);
}
protected ToStringHelper string() {
return Objects.toStringHelper(this).omitNullValues()
- .add("type", type).add("name", name).add("endpoints", endpoints);
+ .add("id", id).add("type", type).add("name", name)
+ .add("description", description).add("endpoints", endpoints);
}
@Override
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Tenant.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Tenant.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Tenant.java
index 418a464..6293184 100644
--- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Tenant.java
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Tenant.java
@@ -26,12 +26,14 @@ import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
/**
- * A container used to group or isolate resources and/or identity objects. Depending on the service
- * operator, a tenant may map to a customer, account, organization, or project.
- *
+ * A container used to group or isolate resources and/or identity objects.
+ * Depending on the service operator, a tenant may map to a customer, account,
+ * organization, or project.
+ *
* @author Adrian Cole
- * @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-Service-Concepts-e1362.html"
-/>
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-Service-Concepts-e1362.html"
+ * />
*/
public class Tenant {
@@ -43,12 +45,13 @@ public class Tenant {
return new ConcreteBuilder().fromTenant(this);
}
- public abstract static class Builder<T extends Builder<T>> {
+ public abstract static class Builder<T extends Builder<T>> {
protected abstract T self();
protected String id;
protected String name;
protected String description;
+ protected Boolean enabled;
/**
* @see Tenant#getId()
@@ -59,6 +62,14 @@ public class Tenant {
}
/**
+ * @see Tenant#isEnabled()
+ */
+ public T enabled(Boolean enabled) {
+ this.enabled = enabled;
+ return self();
+ }
+
+ /**
* @see Tenant#getName()
*/
public T name(String name) {
@@ -75,14 +86,11 @@ public class Tenant {
}
public Tenant build() {
- return new Tenant(id, name, description);
+ return new Tenant(id, name, description, enabled);
}
public T fromTenant(Tenant in) {
- return this
- .id(in.getId())
- .name(in.getName())
- .description(in.getDescription());
+ return this.id(in.getId()).name(in.getName()).description(in.getDescription());
}
}
@@ -96,19 +104,20 @@ public class Tenant {
private final String id;
private final String name;
private final String description;
+ private final Boolean enabled;
- @ConstructorProperties({
- "id", "name", "description"
- })
- protected Tenant(String id, String name, @Nullable String description) {
+ @ConstructorProperties({ "id", "name", "description", "enabled" })
+ protected Tenant(String id, String name, @Nullable String description, @Nullable Boolean enabled) {
this.id = checkNotNull(id, "id");
this.name = checkNotNull(name, "name");
this.description = description;
+ this.enabled = enabled;
}
/**
- * When providing an ID, it is assumed that the tenant exists in the current OpenStack deployment
- *
+ * When providing an ID, it is assumed that the tenant exists in the current
+ * OpenStack deployment
+ *
* @return the id of the tenant in the current OpenStack deployment
*/
public String getId() {
@@ -130,6 +139,13 @@ public class Tenant {
return this.description;
}
+ /**
+ * @return if the tenant is enabled
+ */
+ public boolean isEnabled() {
+ return this.enabled;
+ }
+
@Override
public int hashCode() {
return Objects.hashCode(id, name, description);
@@ -137,17 +153,18 @@ public class Tenant {
@Override
public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
Tenant that = Tenant.class.cast(obj);
- return Objects.equal(this.id, that.id)
- && Objects.equal(this.name, that.name)
- && Objects.equal(this.description, that.description);
+ return Objects.equal(this.id, that.id) && Objects.equal(this.name, that.name)
+ && Objects.equal(this.description, that.description) && Objects.equal(this.enabled, that.enabled);
}
protected ToStringHelper string() {
- return Objects.toStringHelper(this).omitNullValues()
- .add("id", id).add("name", name).add("description", description);
+ return Objects.toStringHelper(this).omitNullValues().add("id", id).add("name", name)
+ .add("description", description).add("enabled", enabled);
}
@Override
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/User.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/User.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/User.java
index 47eaf06..fd3127d 100644
--- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/User.java
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/User.java
@@ -29,14 +29,16 @@ import com.google.common.collect.ForwardingSet;
import com.google.common.collect.ImmutableSet;
/**
- * A digital representation of a person, system, or service who uses OpenStack cloud services.
- * Keystone authentication services will validate that incoming request are being made by the user
- * who claims to be making the call. Users have a login and may be assigned tokens to access users.
- * Users may be directly assigned to a particular tenant and behave as if they are contained in that
- * tenant.
- *
+ * A digital representation of a person, system, or service who uses OpenStack
+ * cloud services. Keystone authentication services will validate that incoming
+ * request are being made by the user who claims to be making the call. Users
+ * have a login and may be assigned tokens to access users. Users may be
+ * directly assigned to a particular tenant and behave as if they are contained
+ * in that tenant.
+ *
* @author Adrian Cole
- * @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-User-Concepts-e1362.html"
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-User-Concepts-e1362.html"
* />
*/
public class User extends ForwardingSet<Role> {
@@ -54,6 +56,9 @@ public class User extends ForwardingSet<Role> {
protected String id;
protected String name;
+ protected String email;
+ protected Boolean enabled;
+ protected String tenantId;
protected ImmutableSet.Builder<Role> roles = ImmutableSet.<Role> builder();
/**
@@ -73,6 +78,30 @@ public class User extends ForwardingSet<Role> {
}
/**
+ * @see User#getEmail()
+ */
+ public T email(String email) {
+ this.email = email;
+ return self();
+ }
+
+ /**
+ * @see User#isEnabled()
+ */
+ public T enabled(Boolean enabled) {
+ this.enabled = enabled;
+ return self();
+ }
+
+ /**
+ * @see User#getTenantId
+ */
+ public T tenantId(String tenantId) {
+ this.tenantId = tenantId;
+ return self();
+ }
+
+ /**
* @see User#delegate()
*/
public T role(Role role) {
@@ -89,14 +118,12 @@ public class User extends ForwardingSet<Role> {
}
public User build() {
- return new User(id, name, roles.build());
+ return new User(id, name, email, enabled, tenantId, roles.build());
}
public T fromUser(User in) {
- return this
- .id(in.getId())
- .name(in.getName())
- .roles(in);
+ return this.id(in.getId()).name(in.getName()).email(in.getEmail()).enabled(in.isEnabled())
+ .tenantId(in.getTenantId()).roles(in);
}
}
@@ -109,20 +136,26 @@ public class User extends ForwardingSet<Role> {
private final String id;
private final String name;
+ private final String email;
+ private final Boolean enabled;
+ private final String tenantId;
private final Set<Role> roles;
- @ConstructorProperties({
- "id", "name", "roles"
- })
- protected User(String id, String name, @Nullable Set<Role> roles) {
+ @ConstructorProperties({ "id", "name", "email", "enabled", "tenantId", "roles" })
+ protected User(String id, String name, @Nullable String email, @Nullable Boolean enabled, @Nullable String tenantId,
+ @Nullable Set<Role> roles) {
this.id = checkNotNull(id, "id");
this.name = checkNotNull(name, "name");
- this.roles = roles == null ? ImmutableSet.<Role>of() : ImmutableSet.copyOf(roles);
+ this.email = email;
+ this.enabled = enabled;
+ this.tenantId = tenantId;
+ this.roles = roles == null ? ImmutableSet.<Role> of() : ImmutableSet.copyOf(roles);
}
/**
- * When providing an ID, it is assumed that the user exists in the current OpenStack deployment
- *
+ * When providing an ID, it is assumed that the user exists in the current
+ * OpenStack deployment
+ *
* @return the id of the user in the current OpenStack deployment
*/
public String getId() {
@@ -136,24 +169,47 @@ public class User extends ForwardingSet<Role> {
return this.name;
}
+ /**
+ * @return the e-mail
+ */
+ public String getEmail() {
+ return this.email;
+ }
+
+ /**
+ * @return if the user is enabled
+ */
+ public boolean isEnabled() {
+ return this.enabled;
+ }
+
+ /**
+ * @return the user tenant
+ */
+ public String getTenantId() {
+ return this.tenantId;
+ }
+
@Override
public int hashCode() {
- return Objects.hashCode(id, name, roles);
+ return Objects.hashCode(id, name, email, enabled, tenantId, roles);
}
@Override
public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
User that = User.class.cast(obj);
- return Objects.equal(this.id, that.id)
- && Objects.equal(this.name, that.name)
- && Objects.equal(this.roles, that.roles);
+ return Objects.equal(this.id, that.id) && Objects.equal(this.name, that.name)
+ && Objects.equal(this.roles, that.roles) && Objects.equal(this.enabled, that.enabled)
+ && Objects.equal(this.tenantId, that.tenantId) && Objects.equal(this.email, that.email);
}
protected ToStringHelper string() {
- return Objects.toStringHelper(this).omitNullValues()
- .add("id", id).add("name", name).add("roles", roles);
+ return Objects.toStringHelper(this).omitNullValues().add("id", id).add("name", name).add("email", email)
+ .add("enabled", enabled).add("roles", roles).add("tenanId", tenantId);
}
@Override
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ExtensionNamespaces.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ExtensionNamespaces.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ExtensionNamespaces.java
new file mode 100644
index 0000000..7ec238d
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ExtensionNamespaces.java
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/**
+ * Extension namespaces
+ *
+ * @author Pedro Navarro
+ * @see <a href= "http://docs.openstack.org/developer/keystone/extension_development.html" />
+ */
+public interface ExtensionNamespaces {
+ /**
+ * OpenStack Keystone Admin Support
+ */
+ public static final String OS_KSADM = "http://docs.openstack.org/identity/api/ext/OS-KSADM/v1.0";
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminApi.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminApi.java
new file mode 100644
index 0000000..f0d7536
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminApi.java
@@ -0,0 +1,65 @@
+/*
+ * 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 org.jclouds.openstack.keystone.v2_0.domain.Role;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+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
+ * @author Pedro Navarro
+ */
+@Beta
+@Extension(of = ServiceType.IDENTITY, namespace = ExtensionNamespaces.OS_KSADM)
+public interface RoleAdminApi {
+
+ /**
+ * Returns a summary list of roles.
+ *
+ * @return The list of roles
+ */
+ FluentIterable<? extends Role> list();
+
+ /**
+ * Creates a new Role
+ *
+ * @return the new Role
+ */
+ Role create(String name);
+
+ /**
+ * Gets the role
+ *
+ * @return the role
+ */
+ Role get(String roleId);
+
+ /**
+ * Deletes a role
+ *
+ * @return true if successful
+ */
+ boolean delete(String roleId);
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/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
new file mode 100644
index 0000000..71ad4f0
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/RoleAdminAsyncApi.java
@@ -0,0 +1,111 @@
+/*
+ * 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
+ * @author Pedro Navarro
+ */
+@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/b68f1b6e/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminApi.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminApi.java
new file mode 100644
index 0000000..c476abb
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminApi.java
@@ -0,0 +1,70 @@
+/*
+ * 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 org.jclouds.collect.PagedIterable;
+import org.jclouds.openstack.keystone.v2_0.domain.Service;
+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 com.google.common.annotations.Beta;
+
+/**
+ * Provides synchronous access to Service Administration actions.
+ * <p/>
+ *
+ * @see org.jclouds.openstack.keystone.v2_0.extensions.ServiceAdminAsyncApi
+ * @author Pedro Navarro
+ */
+@Beta
+@Extension(of = ServiceType.IDENTITY, namespace = ExtensionNamespaces.OS_KSADM)
+public interface ServiceAdminApi {
+
+ /**
+ * Retrieve the list of services
+ * <p/>
+ *
+ * @return the list of services
+ */
+ PagedIterable<? extends Service> list();
+
+ PaginatedCollection<? extends Service> list(PaginationOptions options);
+
+ /**
+ * Creates a new Service
+ *
+ * @return the new Service
+ */
+ Service create(String name, String type, String description);
+
+ /**
+ * Gets the service
+ *
+ * @return the service
+ */
+ Service get(String serviceId);
+
+ /**
+ * Deletes a service
+ *
+ * @return true if successful
+ */
+ boolean delete(String serviceId);
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/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
new file mode 100644
index 0000000..142bbae
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/ServiceAdminAsyncApi.java
@@ -0,0 +1,127 @@
+/*
+ * 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
+ * @author Pedro Navarro
+ */
+@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/b68f1b6e/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminApi.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminApi.java
new file mode 100644
index 0000000..ce455d3
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminApi.java
@@ -0,0 +1,80 @@
+/*
+ * 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 org.jclouds.openstack.keystone.v2_0.domain.Tenant;
+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 com.google.common.annotations.Beta;
+
+/**
+ * Provides synchronous access to Tenant Administration actions.
+ * <p/>
+ *
+ * @see org.jclouds.openstack.keystone.v2_0.extensions.TenantAdminAsyncApi
+ * @author Pedro Navarro
+ */
+@Beta
+@Extension(of = ServiceType.IDENTITY, namespace = ExtensionNamespaces.OS_KSADM)
+public interface TenantAdminApi {
+
+ /**
+ * Creates a new tenant
+ *
+ * @return the new tenant
+ */
+ Tenant create(String name);
+
+ /**
+ * Creates a new tenant
+ *
+ * @return the new tenant
+ */
+ Tenant create(String name, CreateTenantOptions options);
+
+ /**
+ * Deletes a tenant
+ *
+ * @return true if successful
+ */
+ boolean delete(String userId);
+
+ /**
+ * Updates a tenant
+ *
+ * @return the updated tenant
+ */
+ Tenant update(String id, UpdateTenantOptions options);
+
+ /**
+ * Adds role to a user on a tenant
+ *
+ * @return true if successful
+ */
+ boolean addRoleOnTenant(String tenantId, String userId, String roleId);
+
+ /**
+ * Deletes role to a user on tenant
+ *
+ * @return true if successful
+ */
+ boolean deleteRoleOnTenant(String tenantId, String userId, String roleId);
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/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
new file mode 100644
index 0000000..63f5eab
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/TenantAdminAsyncApi.java
@@ -0,0 +1,138 @@
+/*
+ * 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
+ * @author Pedro Navarro
+ */
+@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/b68f1b6e/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminApi.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminApi.java
new file mode 100644
index 0000000..9fe8dcf
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminApi.java
@@ -0,0 +1,66 @@
+/*
+ * 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 org.jclouds.openstack.keystone.v2_0.domain.User;
+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 com.google.common.annotations.Beta;
+
+/**
+ * Provides synchronous access to User Administration actions.
+ * <p/>
+ *
+ * @see org.jclouds.openstack.keystone.v2_0.extensions.UserAdminAsyncApi
+ * @author Pedro Navarro
+ */
+@Beta
+@Extension(of = ServiceType.IDENTITY, namespace = ExtensionNamespaces.OS_KSADM)
+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);
+
+ /**
+ * Deletes an user
+ *
+ * @return true if successful
+ */
+ boolean delete(String userId);
+
+ /**
+ * Updates an user
+ *
+ * @return the updated user
+ */
+ User update(String id, UpdateUserOptions options);
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/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
new file mode 100644
index 0000000..254e8af
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/extensions/UserAdminAsyncApi.java
@@ -0,0 +1,114 @@
+/*
+ * 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
+ * @author Pedro Navarro
+ */
+@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/b68f1b6e/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/internal/ParseServices.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/internal/ParseServices.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/internal/ParseServices.java
new file mode 100644
index 0000000..a40ffc8
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/internal/ParseServices.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.keystone.v2_0.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
+import org.jclouds.openstack.keystone.v2_0.domain.Service;
+import org.jclouds.openstack.keystone.v2_0.extensions.ServiceAdminApi;
+import org.jclouds.openstack.keystone.v2_0.functions.internal.ParseServices.Services;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.inject.TypeLiteral;
+
+/**
+ * boiler plate until we determine a better way
+ *
+ * @author Pedro Navarro
+ */
+@Beta
+@Singleton
+public class ParseServices extends ParseJson<Services> {
+ static class Services extends PaginatedCollection<Service> {
+
+ @ConstructorProperties({ "OS-KSADM:services", "services_links" })
+ protected Services(Iterable<Service> services, Iterable<Link> services_links) {
+ super(services, services_links);
+ }
+
+ }
+
+ @Inject
+ public ParseServices(Json json) {
+ super(json, TypeLiteral.get(Services.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Service, ToPagedIterable> {
+
+ private final KeystoneApi api;
+
+ @Inject
+ protected ToPagedIterable(KeystoneApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Service>> markerToNextForArg0(Optional<Object> ignored) {
+ final ServiceAdminApi serviceApi = api.getServiceAdminApi().get();
+ return new Function<Object, IterableWithMarker<Service>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Service> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(serviceApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listServices()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/CreateTenantOptions.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/CreateTenantOptions.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/CreateTenantOptions.java
new file mode 100644
index 0000000..6ad805b
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/CreateTenantOptions.java
@@ -0,0 +1,144 @@
+/*
+ * 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.options;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * @author Pedro Navarro
+ */
+public class CreateTenantOptions implements MapBinder {
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ private String description;
+ private boolean enabled;
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof CreateTenantOptions) {
+ final CreateTenantOptions other = CreateTenantOptions.class.cast(object);
+ return equal(description, other.description) && equal(enabled, other.enabled);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(description, enabled);
+ }
+
+ protected ToStringHelper string() {
+ ToStringHelper toString = Objects.toStringHelper("").omitNullValues();
+ toString.add("description", description);
+ toString.add("enabled", Boolean.valueOf(enabled));
+ return toString;
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ static class ServerRequest {
+ final String name;
+ String description;
+ boolean enabled;
+
+ private ServerRequest(String name) {
+ this.name = name;
+ }
+
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ ServerRequest tenant = new ServerRequest(checkNotNull(postParams.get("name"), "name parameter not present")
+ .toString());
+ if (description != null)
+ tenant.description = description;
+ tenant.enabled = enabled;
+
+ return bindToRequest(request, ImmutableMap.of("tenant", tenant));
+ }
+
+ /**
+ * Gets the default tenant description
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * A description can be defined when creating a tenant.
+ */
+ public CreateTenantOptions description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public boolean isEnabled() {
+ return this.enabled;
+ }
+
+ public CreateTenantOptions enabled(boolean enabled) {
+ this.enabled = enabled;
+ return this;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see CreateTenantOptions#description(String)
+ */
+ public static CreateTenantOptions description(String description) {
+ CreateTenantOptions options = new CreateTenantOptions();
+ return options.description(description);
+ }
+
+ /**
+ * @see CreateTenantOptions#enabled(boolean)
+ */
+ public static CreateTenantOptions enabled(boolean enabled) {
+ CreateTenantOptions options = new CreateTenantOptions();
+ return options.enabled(enabled);
+ }
+
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/CreateUserOptions.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/CreateUserOptions.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/CreateUserOptions.java
new file mode 100644
index 0000000..a63291b
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/CreateUserOptions.java
@@ -0,0 +1,180 @@
+/*
+ * 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.options;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * @author Pedro Navarro
+ */
+public class CreateUserOptions implements MapBinder{
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ private String tenant;
+ private String password;
+ private String email;
+ private boolean enabled;
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof CreateUserOptions) {
+ final CreateUserOptions other = CreateUserOptions.class.cast(object);
+ return equal(tenant, other.tenant) && equal(password, other.password) && equal(email, other.email)
+ && equal(enabled, other.enabled);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(tenant, password, email, enabled);
+ }
+
+ protected ToStringHelper string() {
+ ToStringHelper toString = Objects.toStringHelper("").omitNullValues();
+ toString.add("tenant", tenant);
+ toString.add("password", password);
+ toString.add("email", email);
+ toString.add("enabled", Boolean.valueOf(enabled));
+ return toString;
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ static class ServerRequest {
+ final String name;
+ String tenant;
+ String password;
+ String email;
+ boolean enabled;
+
+ private ServerRequest(String name, String password) {
+ this.name = name;
+ this.password = password;
+ }
+
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ ServerRequest user = new ServerRequest(checkNotNull(postParams.get("name"), "name parameter not present")
+ .toString(), checkNotNull(postParams.get("password"), "password parameter not present")
+ .toString());
+ if (email != null)
+ user.email = email;
+ if (password != null)
+ user.password = password;
+ if (tenant != null)
+ user.tenant = tenant;
+ user.enabled = enabled;
+
+ return bindToRequest(request, ImmutableMap.of("user", user));
+ }
+
+ /**
+ * Gets the default user tenant
+ */
+ public String getTenant() {
+ return this.tenant;
+ }
+
+ /**
+ * A default tenant can be defined when creating an user.
+ */
+ public CreateUserOptions tenant(String tenant) {
+ this.tenant = tenant;
+ return this;
+ }
+
+ /**
+ * Gets the user e-mail
+ */
+ public String getEmail() {
+ return this.email;
+ }
+
+ /**
+ * @see #getEmail()
+ */
+ public CreateUserOptions email(String email) {
+ this.email = email;
+ return this;
+ }
+
+ public boolean isEnabled() {
+ return this.enabled;
+ }
+
+ public CreateUserOptions enabled(boolean enabled) {
+ this.enabled = enabled;
+ return this;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see CreateUserOptions#tenant(String)
+ */
+ public static CreateUserOptions tenant(String tenant) {
+ CreateUserOptions options = new CreateUserOptions();
+ return options.tenant(tenant);
+ }
+
+ /**
+ * @see CreateUserOptions#email(String)
+ */
+ public static CreateUserOptions email(String email) {
+ CreateUserOptions options = new CreateUserOptions();
+ return options.email(email);
+ }
+
+ /**
+ * @see CreateUserOptions#enabled(boolean)
+ */
+ public static CreateUserOptions enabled(boolean enabled) {
+ CreateUserOptions options = new CreateUserOptions();
+ return options.enabled(enabled);
+ }
+
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/UpdateTenantOptions.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/UpdateTenantOptions.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/UpdateTenantOptions.java
new file mode 100644
index 0000000..0f7c12a
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/UpdateTenantOptions.java
@@ -0,0 +1,159 @@
+/*
+ * 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.options;
+
+import static com.google.common.base.Objects.equal;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * @author Pedro Navarro
+ */
+public class UpdateTenantOptions implements MapBinder {
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ private String name;
+ private String description;
+ private boolean enabled;
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof UpdateTenantOptions) {
+ final UpdateTenantOptions other = UpdateTenantOptions.class.cast(object);
+ return equal(description, other.description) && equal(enabled, other.enabled) && equal(name, other.name);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, description, enabled);
+ }
+
+ protected ToStringHelper string() {
+ ToStringHelper toString = Objects.toStringHelper("").omitNullValues();
+ toString.add("name", name);
+ toString.add("description", description);
+ toString.add("enabled", Boolean.valueOf(enabled));
+ return toString;
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ static class ServerRequest {
+ String name;
+ String description;
+ boolean enabled;
+
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ ServerRequest tenant = new ServerRequest();
+ if (description != null)
+ tenant.description = description;
+ if (name != null)
+ tenant.name = name;
+ tenant.enabled = enabled;
+
+ return bindToRequest(request, ImmutableMap.of("tenant", tenant));
+ }
+
+ /**
+ * Gets the default tenant description
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * A description can be defined when creating a tenant.
+ */
+ public UpdateTenantOptions description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public boolean isEnabled() {
+ return this.enabled;
+ }
+
+ public UpdateTenantOptions enabled(boolean enabled) {
+ this.enabled = enabled;
+ return this;
+ }
+
+ public UpdateTenantOptions name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see UpdateTenantOptions#name(String)
+ */
+ public static UpdateTenantOptions name(String name) {
+ UpdateTenantOptions options = new UpdateTenantOptions();
+ return options.name(name);
+ }
+
+ /**
+ * @see UpdateTenantOptions#description(String)
+ */
+ public static UpdateTenantOptions description(String description) {
+ UpdateTenantOptions options = new UpdateTenantOptions();
+ return options.description(description);
+ }
+
+ /**
+ * @see UpdateTenantOptions#enabled(boolean)
+ */
+ public static UpdateTenantOptions enabled(boolean enabled) {
+ UpdateTenantOptions options = new UpdateTenantOptions();
+ return options.enabled(enabled);
+ }
+
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/b68f1b6e/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/UpdateUserOptions.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/UpdateUserOptions.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/UpdateUserOptions.java
new file mode 100644
index 0000000..8e64f36
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/options/UpdateUserOptions.java
@@ -0,0 +1,193 @@
+/*
+ * 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.options;
+
+import static com.google.common.base.Objects.equal;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * @author Pedro Navarro
+ */
+public class UpdateUserOptions implements MapBinder{
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ private String name;
+ private String email;
+ private String password;
+ private boolean enabled;
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof UpdateUserOptions) {
+ final UpdateUserOptions other = UpdateUserOptions.class.cast(object);
+ return equal(name, other.name) && equal(email, other.email)
+ && equal(enabled, other.enabled) && equal(password, other.password);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, email, enabled, password);
+ }
+
+ protected ToStringHelper string() {
+ ToStringHelper toString = Objects.toStringHelper("").omitNullValues();
+ toString.add("name", name);
+ toString.add("email", email);
+ toString.add("password", password);
+ toString.add("enabled", Boolean.valueOf(enabled));
+ return toString;
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ static class ServerRequest {
+
+ String name;
+ String email;
+ String password;
+ boolean enabled;
+
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ ServerRequest user = new ServerRequest();
+ if (email != null)
+ user.email = email;
+ if (name != null)
+ user.name = name;
+ if (password != null)
+ user.password = password;
+ user.enabled = enabled;
+
+ return bindToRequest(request, ImmutableMap.of("user", user));
+ }
+
+ /**
+ * Gets the default user name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * A name can be defined when updating an user.
+ */
+ public UpdateUserOptions name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * Gets the default password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ public UpdateUserOptions password(String password) {
+ this.password = password;
+ return this;
+ }
+
+ /**
+ * Gets the user e-mail
+ */
+ public String getEmail() {
+ return this.email;
+ }
+
+ /**
+ * @see #getEmail()
+ */
+ public UpdateUserOptions email(String email) {
+ this.email = email;
+ return this;
+ }
+
+ public boolean isEnabled() {
+ return this.enabled;
+ }
+
+ public UpdateUserOptions enabled(boolean enabled) {
+ this.enabled = enabled;
+ return this;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see UpdateUserOptions#name(String)
+ */
+ public static UpdateUserOptions name(String name) {
+ UpdateUserOptions options = new UpdateUserOptions();
+ return options.name(name);
+ }
+
+ /**
+ * @see UpdateUserOptions#email(String)
+ */
+ public static UpdateUserOptions email(String email) {
+ UpdateUserOptions options = new UpdateUserOptions();
+ return options.email(email);
+ }
+
+ /**
+ * @see UpdateUserOptions#enabled(boolean)
+ */
+ public static UpdateUserOptions enabled(boolean enabled) {
+ UpdateUserOptions options = new UpdateUserOptions();
+ return options.enabled(enabled);
+ }
+
+ /**
+ * @see UpdateUserOptions#password(String)
+ */
+ public static UpdateUserOptions password(String password) {
+ UpdateUserOptions options = new UpdateUserOptions();
+ return options.password(password);
+ }
+
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+
+}