Example #1
0
 def update_user(self, uid, **kwargs):
     """Update an existing user.
     :param str uid: the user id
     :param str display_name: the display name
     :param str email: the user email
     :param str key_type: the key_type 's3' or 'swift'. Default: 's3'
     :param str access_key: the access key
     :param str secret_key: the secret key
     :param bool generate_key: True to auto generate a new key pair. Default: True
     :param str user_caps: the user caps. i.e. "user=read; usage=read,write"
     :param int max_buckets: max bucket for the user. Default: 1000
     :param bool suspended: to suspend a user
     :return radosgw.user.UserInfo: the updated user
     :see: http://docs.ceph.com/docs/master/radosgw/adminops/#modify-user
     """
     params = {'uid': uid}
     # optional query parameters
     _kwargs_get('display_name', kwargs, params)
     _kwargs_get('email', kwargs, params)
     _kwargs_get('key_type', kwargs, params)
     _kwargs_get('access_key', kwargs, params)
     _kwargs_get('secret_key', kwargs, params)
     _kwargs_get('user_caps', kwargs, params)
     _kwargs_get('generate_key', kwargs, params, False)
     _kwargs_get('max_buckets', kwargs, params)
     _kwargs_get('suspended', kwargs, params)
     _kwargs_get('format', kwargs, params, 'json')
     response = self.make_request('POST', path='/user', query_params=params)
     body = self._process_response(response)
     user_dict = json.loads(body)
     user = UserInfo(self, user_dict)
     return user
 def create_user(self, uid, display_name, **kwargs):
     """Creates a new user.
     :param str uid: the user id
     :param str tenant: the user tenant
     :param str display_name: the display name
     :param str email: the user email
     :param str key_type: the key_type 's3' or 'swift'. Default: 's3'
     :param str access_key: the access key
     :param str secret_key: the secret key
     :param bool generate_key: True to auto generate a new key pair. Default: True
     :param str user_caps: the user caps. i.e. "user=read; usage=read,write"
     :param int max_buckets: max bucket for the user. Default: 1000
     :param bool suspended: to suspend a user
     :return radosgw.user.UserInfo: the created user
     :see: http://ceph.com/docs/next/radosgw/adminops/#create-user
     """
     # mandatory query parameters
     if 'tenant' in kwargs:
         uid = kwargs['tenant'] + "$" + uid
     params = {'uid': uid, 'display-name': display_name}
     # optional query parameters
     _kwargs_get('email', kwargs, params)
     _kwargs_get('key_type', kwargs, params, 's3')
     _kwargs_get('access_key', kwargs, params)
     _kwargs_get('secret_key', kwargs, params)
     _kwargs_get('user_caps', kwargs, params)
     _kwargs_get('generate_key', kwargs, params, True)
     _kwargs_get('max_buckets', kwargs, params)
     _kwargs_get('suspended', kwargs, params)
     _kwargs_get('format', kwargs, params, 'json')
     response = self.make_request('PUT', path='/user', query_params=params)
     body = self._process_response(response)
     user_dict = json.loads(body)
     user = UserInfo(self, user_dict)
     return user
 def get_user(self, uid, **kwargs):
     """Get the user information.
     :param str uid: the user id
     :returns radosgw.user.UserInfo: the user info
     :throws radosgw.exception.RadosGWAdminError: if an error occurs
     :see: http://ceph.com/docs/next/radosgw/adminops/#get-user-info
     """
     # mandatory query parameters
     params = {'uid': uid}
     # optional query parameters
     _kwargs_get('format', kwargs, params, 'json')
     response = self.make_request('GET', path='/user', query_params=params)
     body = self._process_response(response)
     user_dict = json.loads(body)
     user = UserInfo(self, user_dict)
     return user