From 1a8367b5cf4432a3dadbb49f01e4de45c5ff4667 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 23 Mar 2019 14:23:05 +0200 Subject: Refactor: add Session.allow_scopes --- effitool | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/effitool b/effitool index 9caf322..1954581 100755 --- a/effitool +++ b/effitool @@ -222,6 +222,12 @@ class Session: def get_client(self, client_id): return self._api.get_json(self._token, '/clients/{}'.format(client_id)) + def allow_scopes(self, client_id, scopes): + path = '/clients/{}'.format(client_id) + client = self._api.get_json(self._token, path) + client['allowed_scopes'] = uniq(client.get('allowed_scopes', []) + scopes) + self._api.put_json(self._token, path, client) + def fetch_member(self, rid): headers = { 'Muck-Id': rid, @@ -323,15 +329,8 @@ class Tool: print(scope) def allow_scope(self, args): - name = args['client-name'] - scopes = args['scope'] - server = self.get_chosen_server(args) - token = self.get_admin_token(server) - api = HTTPAPI(server['url']) - path = '/clients/{}'.format(name) - client = api.get_json(token, path) - client['allowed_scopes'] = uniq(client.get('allowed_scopes', []) + scopes) - api.put_json(token, path, client) + session = self.get_session(args) + session.allow_scopes(args['client-name'], args['scope']) def deny_scope(self, args): name = args['client-name'] -- cgit v1.2.1