autograder.cli.users.tokens.create

Create a new token.

usage: python3 -m autograder.cli.users.tokens.create [-h] [--version]
                                                     [--server SERVER]
                                                     [--user USER]
                                                     [--pass PASS]
                                                     [--target-user TARGET_USER]
                                                     [--name NAME]
                                                     [--testing-mode]

Create a new token.

options:
    -h, --help          show this help message and exit
    --version           show program's version number and exit

command-specific options:
    --server SERVER     The URL of the autograder server to communicate with.
    --user USER         The email of the user making this request.
    --pass PASS         The password of the user making this request.
    --target-user TARGET_USER
                        The user that is the target of this request (defaults
                        to you). (default: None)
    --name NAME         An optional name to use. (default: None)

testing options:
    --testing-mode      Run as if a test is being run (default: False).
 1"""
 2Create a new token.
 3"""
 4
 5import argparse
 6import sys
 7
 8import autograder.api.users.tokens.create
 9import autograder.cli.parser
10
11def run_cli(args: argparse.Namespace) -> int:
12    """ Run the CLI. """
13
14    config = args._config_info.application_config
15
16    result = autograder.api.users.tokens.create.send(config, exit_on_error = True)
17
18    print("Token ID: " + result['token-info']['id'])
19    print("Token Text: " + result['token-cleartext'])
20    print("")
21    print("Copy down the token text and keep it safe, this will be the only time it is ever shown.")
22
23    return 0
24
25def main() -> int:
26    """ Get a parser, parse the args, and call run. """
27
28    return run_cli(_get_parser().parse_args())
29
30def _get_parser() -> argparse.ArgumentParser:
31    """ Get a parser for this operation. """
32
33    parser = autograder.cli.parser.get_parser(
34        __doc__.strip(),
35        autograder.api.users.tokens.create.API_PARAMS)
36
37    return parser
38
39if (__name__ == '__main__'):
40    sys.exit(main())
def run_cli(args: argparse.Namespace) -> int:
12def run_cli(args: argparse.Namespace) -> int:
13    """ Run the CLI. """
14
15    config = args._config_info.application_config
16
17    result = autograder.api.users.tokens.create.send(config, exit_on_error = True)
18
19    print("Token ID: " + result['token-info']['id'])
20    print("Token Text: " + result['token-cleartext'])
21    print("")
22    print("Copy down the token text and keep it safe, this will be the only time it is ever shown.")
23
24    return 0

Run the CLI.

def main() -> int:
26def main() -> int:
27    """ Get a parser, parse the args, and call run. """
28
29    return run_cli(_get_parser().parse_args())

Get a parser, parse the args, and call run.