aboutsummaryrefslogtreecommitdiffstats
path: root/python_moonclient/python_moonclient/cli/parser.py
blob: e71cd6c9b30d4b0eb5f9acbdbc6025584bbaa268 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
class Parser:

    @staticmethod
    def add_common_options(parser):
        parser.add_argument('--consul-host',
                            help='Set the name of the consul server (default: 127.0.0.1)',
                            default="127.0.0.1")
        parser.add_argument('--consul-port',
                            help='Set the port of the consult server (default: 30005)',
                            default="30005")
        parser.add_argument("--verbose", "-v", action='store_true', help="verbose mode")
        parser.add_argument("--debug", "-d", action='store_true', help="debug mode")

    @staticmethod
    def add_filename_argument(parser):
        parser.add_argument('filename', help='configuration filename in json format')

    @staticmethod
    def add_name_argument(parser):
        Parser._add_name_argument(parser)

    @staticmethod
    def add_policy_argument(parser):
        group = parser.add_mutually_exclusive_group(required=True)
        group.add_argument('--policy-name', help='name of the policy')
        group.add_argument('--policy-id', help='id of the policy')

    @staticmethod
    def add_category_argument(parser):
        group = parser.add_mutually_exclusive_group(required=True)
        group.add_argument('--category-name', help='name of the category')
        group.add_argument('--category-id', help='id of the category')

    @staticmethod
    def add_id_or_name_argument(parser):
        group = parser.add_mutually_exclusive_group(required=True)
        Parser._add_id_argument(group)
        Parser._add_name_argument(group)

    @staticmethod
    def _add_id_argument(parser):
        parser.add_argument('--id', help='id of the element')

    @staticmethod
    def _add_name_argument(parser):
        parser.add_argument('--name', help='name of the element')

    @staticmethod
    def add_id_or_name_pdp_argument(parser):
        group = parser.add_mutually_exclusive_group(required=True)
        Parser._add_id_pdp_argument(group)
        Parser._add_name_pdp_argument(group)

    @staticmethod
    def _add_id_pdp_argument(parser):
        parser.add_argument('--id-pdp', help='id of the pdp')

    @staticmethod
    def _add_name_pdp_argument(parser):
        parser.add_argument('--name-pdp', help='name of the pdp')

    @staticmethod
    def add_id_or_name_project_argument(parser):
        group = parser.add_mutually_exclusive_group(required=True)
        Parser._add_id_project_argument(group)
        Parser._add_name_project_argument(group)

    @staticmethod
    def _add_id_project_argument(parser):
        parser.add_argument('--id-project', help='id of the project')

    @staticmethod
    def _add_name_project_argument(parser):
        parser.add_argument('--name-project', help='name of the project')

    @staticmethod
    def add_authz_arguments(parser):
        parser.add_argument("--dry-run", "-n", action='store_true',
                            help="Dry run", dest="dry_run")
        parser.add_argument("--destination",
                            help="Set the type of output needed "
                                 "(default: wrapper, other possible type: "
                                 "interface).",
                            default="wrapper")
        parser.add_argument("--authz-host",
                            help="Set the name of the authz server to test"
                                 "(default: 127.0.0.1).",
                            default="127.0.0.1")
        parser.add_argument("--authz-port",
                            help="Set the port of the authz server to test"
                                 "(default: 31002).",
                            default="31002")
        parser.add_argument("--stress-test", "-s", action='store_true',
                            dest='stress_test',
                            help="Execute stressing tests (warning delta measures "
                                 "will be false, implies -t)")
        parser.add_argument("--write", "-w", help="Write test data to a JSON file",
                            default="/tmp/data.json")