lms.cli.courses.groupsets.delete

Delete a group set.

usage: python3 -m lms.cli.courses.groupsets.delete [-h] [--version]
                                                   [--server SERVER]
                                                   [--server-type {blackboard,canvas,moodle}]
                                                   [--auth-user AUTH_USER]
                                                   [--auth-password AUTH_PASSWORD]
                                                   [--auth-token AUTH_TOKEN]
                                                   [--course COURSE]
                                                   [--groupset GROUPSET]
                                                   [--format {json,table,text}]
                                                   [--include-extra-fields]
                                                   [--pretty-headers]
                                                   [--skip-headers]

Delete a group set.

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --course COURSE       The course to target for this operation.
  --groupset GROUPSET   The group set to target for this operation.

server options:
  --server SERVER       The address of the LMS server to connect to.
  --server-type {blackboard,canvas,moodle}
                        The type of LMS being connected to (this can normally
                        be guessed from the server address).

authentication options:
  --auth-user AUTH_USER
                        The user to authenticate with.
  --auth-password AUTH_PASSWORD
                        The password to authenticate with.
  --auth-token AUTH_TOKEN
                        The token to authenticate with.

output formatting options:
  --format {json,table,text}
                        The format to display the output as (default: text).
  --include-extra-fields
                        Include non-common (usually LMS-specific) fields in
                        results (default: False).
  --pretty-headers      When displaying headers, try to make them look
                        "pretty" (default: False).
  --skip-headers        Skip headers when outputting results, will not apply
                        to all formats (default: False).
 1"""
 2Delete a group set.
 3"""
 4
 5import argparse
 6import sys
 7
 8import lms.backend.instance
 9import lms.cli.common
10import lms.cli.parser
11import lms.model.base
12
13def run_cli(args: argparse.Namespace) -> int:
14    """ Run the CLI. """
15
16    config = args._config
17
18    backend = lms.backend.instance.get_backend(**config)
19
20    course_query = lms.cli.common.check_required_course(backend, config)
21    if (course_query is None):
22        return 1
23
24    groupset_query = lms.cli.common.check_required_groupset(backend, config)
25    if (groupset_query is None):
26        return 2
27
28    result = backend.courses_groupsets_resolve_and_delete(course_query, groupset_query)
29
30    if (not result):
31        print(f"ERROR: Could not delete group set: '{groupset_query}'.")
32        return 3
33
34    print(f"Deleted group set: '{groupset_query}'.")
35    return 0
36
37def main() -> int:
38    """ Get a parser, parse the args, and call run. """
39    return run_cli(_get_parser().parse_args())
40
41def _get_parser() -> argparse.ArgumentParser:
42    """ Get the parser. """
43
44    parser = lms.cli.parser.get_parser(__doc__.strip(),
45            include_output_format = True,
46            include_course = True,
47            include_groupset = True,
48    )
49
50    return parser
51
52if (__name__ == '__main__'):
53    sys.exit(main())
def run_cli(args: argparse.Namespace) -> int:
14def run_cli(args: argparse.Namespace) -> int:
15    """ Run the CLI. """
16
17    config = args._config
18
19    backend = lms.backend.instance.get_backend(**config)
20
21    course_query = lms.cli.common.check_required_course(backend, config)
22    if (course_query is None):
23        return 1
24
25    groupset_query = lms.cli.common.check_required_groupset(backend, config)
26    if (groupset_query is None):
27        return 2
28
29    result = backend.courses_groupsets_resolve_and_delete(course_query, groupset_query)
30
31    if (not result):
32        print(f"ERROR: Could not delete group set: '{groupset_query}'.")
33        return 3
34
35    print(f"Deleted group set: '{groupset_query}'.")
36    return 0

Run the CLI.

def main() -> int:
38def main() -> int:
39    """ Get a parser, parse the args, and call run. """
40    return run_cli(_get_parser().parse_args())

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