@@ -38,16 +38,20 @@ class Client(client.HTTPClient):
|
||||
:param string auth_url: Keystone service endpoint for authorization.
|
||||
:param string region_name: Name of a region to select when choosing an
|
||||
endpoint from the service catalog.
|
||||
:param string endpoint: A user-supplied endpoint URL for the keystone service.
|
||||
Lazy-authentication is possible for API service calls
|
||||
if endpoint is set at instantiation.(optional)
|
||||
:param string endpoint: A user-supplied endpoint URL for the keystone
|
||||
service. Lazy-authentication is possible for API
|
||||
service calls if endpoint is set at
|
||||
instantiation.(optional)
|
||||
:param integer timeout: Allows customization of the timeout for client
|
||||
http requests. (optional)
|
||||
|
||||
Example::
|
||||
|
||||
>>> from keystoneclient.v2_0 import client
|
||||
>>> keystone = client.Client(username=USER, password=PASS, project_id=TENANT, auth_url=KEYSTONE_URL)
|
||||
>>> keystone = client.Client(username=USER,
|
||||
password=PASS,
|
||||
project_id=TENANT,
|
||||
auth_url=KEYSTONE_URL)
|
||||
>>> keystone.tenants.list()
|
||||
...
|
||||
>>> user = keystone.users.get(USER_ID)
|
||||
@@ -94,7 +98,8 @@ class Client(client.HTTPClient):
|
||||
raise
|
||||
except Exception, e:
|
||||
_logger.exception("Authorization Failed.")
|
||||
raise exceptions.AuthorizationFailure("Authorization Failed: %s" % e)
|
||||
raise exceptions.AuthorizationFailure("Authorization Failed: "
|
||||
"%s" % e)
|
||||
|
||||
def _extract_service_catalog(self, url, body):
|
||||
""" Set the client's service catalog from the response data. """
|
||||
|
@@ -37,7 +37,7 @@ class UserManager(base.ManagerWithFind):
|
||||
"""
|
||||
# FIXME(ja): why do we have to send id in params and url?
|
||||
params = {"user": {"id": base.getid(user),
|
||||
"email": email }}
|
||||
"email": email}}
|
||||
|
||||
return self._update("/users/%s" % base.getid(user), params, "user")
|
||||
|
||||
@@ -46,7 +46,7 @@ class UserManager(base.ManagerWithFind):
|
||||
Update enabled-ness
|
||||
"""
|
||||
params = {"user": {"id": base.getid(user),
|
||||
"enabled": enabled }}
|
||||
"enabled": enabled}}
|
||||
|
||||
self._update("/users/%s/enabled" % base.getid(user), params, "user")
|
||||
|
||||
@@ -55,26 +55,28 @@ class UserManager(base.ManagerWithFind):
|
||||
Update password
|
||||
"""
|
||||
params = {"user": {"id": base.getid(user),
|
||||
"password": password }}
|
||||
"password": password}}
|
||||
|
||||
return self._update("/users/%s/password" % base.getid(user), params, "user")
|
||||
return self._update("/users/%s/password" % base.getid(user),
|
||||
params, "user")
|
||||
|
||||
def update_tenant(self, user, tenant):
|
||||
"""
|
||||
Update default tenant.
|
||||
"""
|
||||
params = {"user": {"id": base.getid(user),
|
||||
"tenantId": base.getid(tenant) }}
|
||||
"tenantId": base.getid(tenant)}}
|
||||
|
||||
# FIXME(ja): seems like a bad url - default tenant is an attribute
|
||||
# not a subresource!???
|
||||
return self._update("/users/%s/tenant" % base.getid(user), params, "user")
|
||||
return self._update("/users/%s/tenant" % base.getid(user),
|
||||
params, "user")
|
||||
|
||||
def create(self, name, password, email, tenant_id=None, enabled=True):
|
||||
"""
|
||||
Create a user.
|
||||
"""
|
||||
# FIXME(ja): email should be optional but keystone currently requires it
|
||||
# FIXME(ja): email should be optional, keystone currently requires it
|
||||
params = {"user": {"name": name,
|
||||
"password": password,
|
||||
"tenantId": tenant_id,
|
||||
|
Reference in New Issue
Block a user