def get_user_info(self, uid, tenant=None):
        """根据 uin 获取用户信息"""
        tenant = tenant or self.tenant
        if tenant:
            uid = '%s$%s' % (tenant, uid)

        parameters = {'uid': uid}
        response = AWSAuthConnection.make_request(
            self.conn,
            'GET',
            self.admin_endpoint + 'user?' + urllib.parse.urlencode(parameters),
        )
        body = response.read()
        if response.status == 200:
            return json.loads(body)
        elif response.status == 404:
            return None
        else:
            raise StorageResponseError(response.status, response.reason, body)
Exemple #2
0
 def mocked_get_key(key):
     assert '/processed_crash/' in key
     assert '0bba929f-8721-460c-dead-a43c20071027' in key
     raise StorageResponseError(404, 'not found')
 def _handle_response(self, response):
     body = response.read()
     if response.status == 200:
         return json.loads(body) if body else body
     else:
         raise StorageResponseError(response.status, response.reason, body)