/
get-user.py
executable file
·48 lines (38 loc) · 1.73 KB
/
get-user.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
"""Outputs details of a random active unlocked user with a given role.
For supplier users, providing additional <framework> and <lot> arguments allows
filtering by suppliers who have published services on the given framewok and lot.
Usage:
get-user.py [options] <role> [<framework>] [<lot>]
--api-url=<api_url> API URL (overrides --stage)
--api-token=<api_token API Token (overrides --stage)
--stage=<stage> Stage to target; automatically derive/decrypt api url and token [default: development]
--brief-status=<status> Status can be one of draft,live,withdrawn,
cancelled,unsuccessful,closed,awarded
Example:
./get-user.py supplier g9 cloud-hosting
./get-user.py buyer dos4 --brief-status=closed # get a buyer user with closed briefs on DOS4
./get-user.py admin
./get-user.py --stage=preview supplier g-cloud-9
./get-user.py --stage=staging supplier dos2 digital-outcomes
"""
import sys
from docopt import docopt
sys.path.insert(0, '.')
from dmscripts.get_user import get_user
if __name__ == "__main__":
arguments = docopt(__doc__)
user = get_user(
api_url=arguments['--api-url'],
api_token=arguments['--api-token'],
stage=arguments['--stage'],
role=arguments['<role>'].lower(),
framework=arguments['<framework>'].lower() if arguments['<framework>'] else None,
lot=arguments['<lot>'].lower() if arguments['<lot>'] else None,
brief_status=arguments['--brief-status'].lower() if arguments['--brief-status'] else None,
)
print("\n".join(": ".join(u) for u in [
('User role', user['role']),
('User name', user['name']),
('User email', user['emailAddress']),
]))