Skip to content

Commit 5f2e150

Browse files
committed
kernelci.legacy.cli: remove old kci user subcommands
Remove the parts of the old `kci user` implementation that have now been implemented again with Click. Signed-off-by: Guillaume Tucker <[email protected]>
1 parent e5e1c61 commit 5f2e150

File tree

1 file changed

+0
-91
lines changed

1 file changed

+0
-91
lines changed

kernelci/legacy/cli/user.py

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,10 @@
66

77
"""Tool to manage KernelCI API users"""
88

9-
import getpass
10-
119
from .base import Args, sub_main
1210
from .base_api import APICommand, AttributesCommand
1311

1412

15-
class cmd_whoami(APICommand): # pylint: disable=invalid-name
16-
"""Use the /whoami entry point to get the current user's data"""
17-
args = APICommand.args + [Args.api_token]
18-
opt_args = APICommand.opt_args + [Args.indent]
19-
20-
def _api_call(self, api, configs, args):
21-
data = api.whoami()
22-
self._print_json(data, args.indent)
23-
return True
24-
25-
26-
class cmd_get_token(APICommand): # pylint: disable=invalid-name
27-
"""Create a new API token for the current user"""
28-
args = APICommand.args + [Args.username]
29-
opt_args = APICommand.opt_args + [
30-
{
31-
'name': '--scopes',
32-
'action': 'append',
33-
'help': "Security scopes",
34-
},
35-
]
36-
37-
def _api_call(self, api, configs, args):
38-
password = getpass.getpass()
39-
token = api.create_token(args.username, password, args.scopes)
40-
self._print_json(token, args.indent)
41-
return True
42-
43-
44-
class cmd_password_hash(APICommand): # pylint: disable=invalid-name
45-
"""Get an encryption hash for an arbitrary password"""
46-
47-
def _api_call(self, api, configs, args):
48-
password = getpass.getpass()
49-
print(api.password_hash(password))
50-
return True
51-
52-
53-
class cmd_change_password(APICommand): # pylint: disable=invalid-name
54-
"""Change a password for a given user"""
55-
args = APICommand.args + [Args.username]
56-
57-
def _api_call(self, api, configs, args):
58-
current = getpass.getpass("Current password: ")
59-
new = getpass.getpass("New password: ")
60-
retyped = getpass.getpass("Retype new password: ")
61-
if new != retyped:
62-
print("Sorry, passwords do not match.")
63-
return False
64-
api.change_password(args.username, current, new)
65-
return True
66-
67-
6813
class cmd_get_group(APICommand): # pylint: disable=invalid-name
6914
"""Get a user group with a given ID"""
7015
args = APICommand.args + [Args.group_id]
@@ -89,42 +34,6 @@ def _api_call(self, api, configs, args):
8934
return True
9035

9136

92-
class cmd_add(APICommand): # pylint: disable=invalid-name
93-
"""Add a new user account"""
94-
args = APICommand.args + [
95-
Args.api_token,
96-
{
97-
'name': 'username',
98-
'help': "Username of the new user",
99-
},
100-
{
101-
'name': 'email',
102-
'help': "Email address of the new user",
103-
},
104-
]
105-
106-
def _api_call(self, api, configs, args):
107-
profile = {
108-
'email': args.email,
109-
}
110-
password = getpass.getpass()
111-
api.create_user(args.username, password, profile)
112-
return True
113-
114-
115-
class cmd_find_users(AttributesCommand): # pylint: disable=invalid-name
116-
"""Find user profiles with arbitrary attributes"""
117-
opt_args = AttributesCommand.opt_args + [
118-
Args.limit, Args.offset
119-
]
120-
121-
def _api_call(self, api, configs, args):
122-
attributes = self._split_attributes(args.attributes)
123-
profiles = api.get_user_profiles(attributes, args.offset, args.limit)
124-
self._print_json(profiles, args.indent)
125-
return True
126-
127-
12837
class cmd_update(APICommand): # pylint: disable=invalid-name
12938
"""Update a new user account"""
13039
args = APICommand.args + [

0 commit comments

Comments
 (0)