def update_key(self, id, **kwargs): data = { 'scopes': kwargs.get('scopes'), 'text': kwargs.get('text'), 'expireTime': kwargs.get('expireTime'), 'customer': kwargs.get('customer') } r = self.http.put('/key/{}'.format(id), data) return ApiKey.parse(r['key'])
def create_key(self, username, scopes=None, expires=None, text='', customer=None): data = { 'user': username, 'scopes': scopes or list(), 'text': text, 'customer': customer } if expires: data['expireTime'] = DateTime.iso8601(expires) r = self.http.post('/key', data) return ApiKey.parse(r['data'])
def get_keys(self, query=None): r = self.http.get('/keys', query) return [ApiKey.parse(k) for k in r['keys']]
def get_key(self): return ApiKey.parse(self.http.get('/key/%s' % id)['key'])