catocli 2.1.4__py3-none-any.whl → 2.1.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of catocli might be problematic. Click here for more details.
- catocli/Utils/clidriver.py +10 -8
- catocli/Utils/cliutils.py +48 -5
- catocli/__init__.py +2 -2
- catocli/clisettings.json +35 -0
- catocli/parsers/custom/export_sites/__init__.py +14 -3
- catocli/parsers/custom/export_sites/export_sites.py +644 -12
- catocli/parsers/custom/import_sites_to_tf/__init__.py +44 -16
- catocli/parsers/custom/import_sites_to_tf/import_sites_to_tf.py +732 -395
- catocli/parsers/customParserApiClient.py +14 -7
- catocli/parsers/mutation_licensing/__init__.py +24 -0
- catocli/parsers/mutation_licensing_updateCommercialLicense/README.md +19 -0
- catocli/parsers/mutation_policy/__init__.py +509 -509
- catocli/parsers/query_devices/README.md +1 -1
- catocli/parsers/query_eventsFeed/README.md +1 -1
- catocli/parsers/query_policy/__init__.py +55 -55
- {catocli-2.1.4.dist-info → catocli-2.1.8.dist-info}/METADATA +1 -1
- {catocli-2.1.4.dist-info → catocli-2.1.8.dist-info}/RECORD +27 -23
- models/mutation.licensing.updateCommercialLicense.json +931 -0
- models/query.devices.json +199 -60
- models/query.events.json +216 -0
- models/query.eventsFeed.json +48 -0
- models/query.eventsTimeSeries.json +144 -0
- schema/catolib.py +3 -3
- {catocli-2.1.4.dist-info → catocli-2.1.8.dist-info}/WHEEL +0 -0
- {catocli-2.1.4.dist-info → catocli-2.1.8.dist-info}/entry_points.txt +0 -0
- {catocli-2.1.4.dist-info → catocli-2.1.8.dist-info}/licenses/LICENSE +0 -0
- {catocli-2.1.4.dist-info → catocli-2.1.8.dist-info}/top_level.txt +0 -0
catocli/Utils/clidriver.py
CHANGED
|
@@ -47,21 +47,22 @@ from ..parsers.query_hardware import query_hardware_parse
|
|
|
47
47
|
from ..parsers.query_enterpriseDirectory import query_enterpriseDirectory_parse
|
|
48
48
|
from ..parsers.query_devices import query_devices_parse
|
|
49
49
|
from ..parsers.query_catalogs import query_catalogs_parse
|
|
50
|
-
from ..parsers.query_site import query_site_parse
|
|
51
50
|
from ..parsers.query_xdr import query_xdr_parse
|
|
51
|
+
from ..parsers.query_site import query_site_parse
|
|
52
52
|
from ..parsers.query_groups import query_groups_parse
|
|
53
53
|
from ..parsers.query_policy import query_policy_parse
|
|
54
54
|
from ..parsers.mutation_xdr import mutation_xdr_parse
|
|
55
|
-
from ..parsers.mutation_sites import mutation_sites_parse
|
|
56
55
|
from ..parsers.mutation_site import mutation_site_parse
|
|
56
|
+
from ..parsers.mutation_sites import mutation_sites_parse
|
|
57
|
+
from ..parsers.mutation_policy import mutation_policy_parse
|
|
57
58
|
from ..parsers.mutation_container import mutation_container_parse
|
|
58
59
|
from ..parsers.mutation_admin import mutation_admin_parse
|
|
59
60
|
from ..parsers.mutation_accountManagement import mutation_accountManagement_parse
|
|
60
61
|
from ..parsers.mutation_sandbox import mutation_sandbox_parse
|
|
61
|
-
from ..parsers.
|
|
62
|
+
from ..parsers.mutation_licensing import mutation_licensing_parse
|
|
62
63
|
from ..parsers.mutation_groups import mutation_groups_parse
|
|
63
|
-
from ..parsers.mutation_policy import mutation_policy_parse
|
|
64
64
|
from ..parsers.mutation_enterpriseDirectory import mutation_enterpriseDirectory_parse
|
|
65
|
+
from ..parsers.mutation_hardware import mutation_hardware_parse
|
|
65
66
|
|
|
66
67
|
def show_version_info(args, configuration=None):
|
|
67
68
|
print(f"catocli version {catocli.__version__}")
|
|
@@ -181,21 +182,22 @@ query_hardware_parser = query_hardware_parse(query_subparsers)
|
|
|
181
182
|
query_enterpriseDirectory_parser = query_enterpriseDirectory_parse(query_subparsers)
|
|
182
183
|
query_devices_parser = query_devices_parse(query_subparsers)
|
|
183
184
|
query_catalogs_parser = query_catalogs_parse(query_subparsers)
|
|
184
|
-
query_site_parser = query_site_parse(query_subparsers)
|
|
185
185
|
query_xdr_parser = query_xdr_parse(query_subparsers)
|
|
186
|
+
query_site_parser = query_site_parse(query_subparsers)
|
|
186
187
|
query_groups_parser = query_groups_parse(query_subparsers)
|
|
187
188
|
query_policy_parser = query_policy_parse(query_subparsers)
|
|
188
189
|
mutation_xdr_parser = mutation_xdr_parse(mutation_subparsers)
|
|
189
|
-
mutation_sites_parser = mutation_sites_parse(mutation_subparsers)
|
|
190
190
|
mutation_site_parser = mutation_site_parse(mutation_subparsers)
|
|
191
|
+
mutation_sites_parser = mutation_sites_parse(mutation_subparsers)
|
|
192
|
+
mutation_policy_parser = mutation_policy_parse(mutation_subparsers)
|
|
191
193
|
mutation_container_parser = mutation_container_parse(mutation_subparsers)
|
|
192
194
|
mutation_admin_parser = mutation_admin_parse(mutation_subparsers)
|
|
193
195
|
mutation_accountManagement_parser = mutation_accountManagement_parse(mutation_subparsers)
|
|
194
196
|
mutation_sandbox_parser = mutation_sandbox_parse(mutation_subparsers)
|
|
195
|
-
|
|
197
|
+
mutation_licensing_parser = mutation_licensing_parse(mutation_subparsers)
|
|
196
198
|
mutation_groups_parser = mutation_groups_parse(mutation_subparsers)
|
|
197
|
-
mutation_policy_parser = mutation_policy_parse(mutation_subparsers)
|
|
198
199
|
mutation_enterpriseDirectory_parser = mutation_enterpriseDirectory_parse(mutation_subparsers)
|
|
200
|
+
mutation_hardware_parser = mutation_hardware_parse(mutation_subparsers)
|
|
199
201
|
|
|
200
202
|
|
|
201
203
|
def parse_headers(header_strings):
|
catocli/Utils/cliutils.py
CHANGED
|
@@ -39,14 +39,55 @@ def load_cli_settings():
|
|
|
39
39
|
Load clisettings.json from multiple possible locations:
|
|
40
40
|
1. Package resource (for installed packages)
|
|
41
41
|
2. Repository location (for development)
|
|
42
|
+
3. Adjacent file location (for development)
|
|
43
|
+
4. Embedded defaults as final fallback
|
|
42
44
|
|
|
43
45
|
Returns:
|
|
44
|
-
dict: The loaded settings or default settings if loading fails
|
|
46
|
+
dict: The loaded settings or embedded default settings if all loading fails
|
|
45
47
|
"""
|
|
48
|
+
# Embedded default settings as final fallback
|
|
49
|
+
default_settings = {
|
|
50
|
+
"export_by_socket_type": {
|
|
51
|
+
"SOCKET_X1500": True,
|
|
52
|
+
"SOCKET_X1600": True,
|
|
53
|
+
"SOCKET_X1600_LTE": True,
|
|
54
|
+
"SOCKET_X1700": True
|
|
55
|
+
},
|
|
56
|
+
"default_socket_interface_map": {
|
|
57
|
+
"SOCKET_X1500": "LAN1",
|
|
58
|
+
"SOCKET_X1600": "INT_5",
|
|
59
|
+
"SOCKET_X1600_LTE": "INT_5",
|
|
60
|
+
"SOCKET_X1700": "INT_3"
|
|
61
|
+
},
|
|
62
|
+
"childOperationParent": {
|
|
63
|
+
"xdr": True,
|
|
64
|
+
"policy": True,
|
|
65
|
+
"groups": True,
|
|
66
|
+
"newGroups": True,
|
|
67
|
+
"site": True
|
|
68
|
+
},
|
|
69
|
+
"childOperationObjects": {
|
|
70
|
+
"ipAddressRange": True,
|
|
71
|
+
"fqdn": True,
|
|
72
|
+
"PolicyQueries": True,
|
|
73
|
+
"GroupsQueries": True,
|
|
74
|
+
"ContainerQueries": True,
|
|
75
|
+
"SiteQueries": True
|
|
76
|
+
},
|
|
77
|
+
"queryOperationCsvOutput": {
|
|
78
|
+
"query.appStats": "format_app_stats_to_csv",
|
|
79
|
+
"query.appStatsTimeSeries": "format_app_stats_timeseries_to_csv",
|
|
80
|
+
"query.accountMetrics": "format_account_metrics_to_csv",
|
|
81
|
+
"query.socketPortMetricsTimeSeries": "format_socket_port_metrics_timeseries_to_csv"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
46
85
|
settings_locations = [
|
|
47
86
|
# Try package resource first (for installed packages)
|
|
48
87
|
lambda: json.loads(get_package_resource('catocli', 'clisettings.json')),
|
|
49
|
-
# Try
|
|
88
|
+
# Try adjacent file location (for development - new location)
|
|
89
|
+
lambda: json.load(open(os.path.join(os.path.dirname(__file__), '../clisettings.json'), 'r', encoding='utf-8')),
|
|
90
|
+
# Try repository location (for development - fallback)
|
|
50
91
|
lambda: json.load(open(os.path.join(os.path.dirname(__file__), '../../clisettings.json'), 'r', encoding='utf-8'))
|
|
51
92
|
]
|
|
52
93
|
|
|
@@ -59,8 +100,8 @@ def load_cli_settings():
|
|
|
59
100
|
# Continue to next location
|
|
60
101
|
continue
|
|
61
102
|
|
|
62
|
-
# If all locations fail, return default settings
|
|
63
|
-
return
|
|
103
|
+
# If all locations fail, return embedded default settings
|
|
104
|
+
return default_settings
|
|
64
105
|
|
|
65
106
|
|
|
66
107
|
def get_cli_settings_path():
|
|
@@ -71,7 +112,9 @@ def get_cli_settings_path():
|
|
|
71
112
|
str or None: Path to the settings file if found, None otherwise
|
|
72
113
|
"""
|
|
73
114
|
possible_paths = [
|
|
74
|
-
#
|
|
115
|
+
# Adjacent file location (for development - new location)
|
|
116
|
+
os.path.join(os.path.dirname(__file__), '../clisettings.json'),
|
|
117
|
+
# Repository location (for development - fallback)
|
|
75
118
|
os.path.join(os.path.dirname(__file__), '../../clisettings.json'),
|
|
76
119
|
# Current directory
|
|
77
120
|
os.path.join(os.getcwd(), 'clisettings.json'),
|
catocli/__init__.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "2.1.
|
|
2
|
-
__cato_host__ = "https://api.catonetworks.com/api/v1/graphql2"
|
|
1
|
+
__version__ = "2.1.8"
|
|
2
|
+
__cato_host__ = "https://api.catonetworks.com/api/v1/graphql2"
|
catocli/clisettings.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"export_by_socket_type": {
|
|
3
|
+
"SOCKET_X1500":true,
|
|
4
|
+
"SOCKET_X1600":true,
|
|
5
|
+
"SOCKET_X1600_LTE":true,
|
|
6
|
+
"SOCKET_X1700":true
|
|
7
|
+
},
|
|
8
|
+
"default_socket_interface_map": {
|
|
9
|
+
"SOCKET_X1500":"LAN1",
|
|
10
|
+
"SOCKET_X1600":"INT_5",
|
|
11
|
+
"SOCKET_X1600_LTE":"INT_5",
|
|
12
|
+
"SOCKET_X1700":"INT_3"
|
|
13
|
+
},
|
|
14
|
+
"childOperationParent": {
|
|
15
|
+
"xdr": true,
|
|
16
|
+
"policy": true,
|
|
17
|
+
"groups": true,
|
|
18
|
+
"newGroups": true,
|
|
19
|
+
"site": true
|
|
20
|
+
},
|
|
21
|
+
"childOperationObjects": {
|
|
22
|
+
"ipAddressRange": true,
|
|
23
|
+
"fqdn": true,
|
|
24
|
+
"PolicyQueries": true,
|
|
25
|
+
"GroupsQueries": true,
|
|
26
|
+
"ContainerQueries": true,
|
|
27
|
+
"SiteQueries": true
|
|
28
|
+
},
|
|
29
|
+
"queryOperationCsvOutput": {
|
|
30
|
+
"query.appStats": "format_app_stats_to_csv",
|
|
31
|
+
"query.appStatsTimeSeries": "format_app_stats_timeseries_to_csv",
|
|
32
|
+
"query.accountMetrics": "format_account_metrics_to_csv",
|
|
33
|
+
"query.socketPortMetricsTimeSeries": "format_socket_port_metrics_timeseries_to_csv"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -6,17 +6,28 @@ def export_sites_parse(subparsers):
|
|
|
6
6
|
# Create the socket_sites parser (direct command, no subparsers)
|
|
7
7
|
socket_sites_parser = subparsers.add_parser(
|
|
8
8
|
'socket_sites',
|
|
9
|
-
help='Export consolidated site and socket data to JSON format',
|
|
9
|
+
help='Export consolidated site and socket data to JSON or CSV format',
|
|
10
10
|
usage='catocli export socket_sites [-accountID <account_id>] [options]'
|
|
11
11
|
)
|
|
12
12
|
|
|
13
13
|
socket_sites_parser.add_argument('-accountID', help='Account ID to export data from (uses CATO_ACCOUNT_ID environment variable if not specified)', required=False)
|
|
14
14
|
socket_sites_parser.add_argument('--site-ids', '-siteIDs', dest='siteIDs', help='Comma-separated list of site IDs to filter and export (e.g., "1234,1235,1236"). If not specified, exports all sites.', required=False)
|
|
15
15
|
socket_sites_parser.add_argument('-clip', '--calculate-local-ip', action='store_true', help='Calculate local IP addresses from subnet ranges (first usable IP)')
|
|
16
|
+
|
|
17
|
+
# Format selection
|
|
18
|
+
socket_sites_parser.add_argument('-f', '--format', dest='export_format', choices=['json', 'csv'], default='json',
|
|
19
|
+
help='Export format: json (default) or csv')
|
|
20
|
+
|
|
21
|
+
# Filename arguments (updated for both formats)
|
|
16
22
|
socket_sites_parser.add_argument('--json-filename', dest='json_filename', help='Override JSON file name (default: socket_sites_{account_id}.json)')
|
|
17
|
-
socket_sites_parser.add_argument('--
|
|
23
|
+
socket_sites_parser.add_argument('--csv-filename', dest='csv_filename', help='Override CSV file name (default: socket_sites_{account_id}.csv)')
|
|
24
|
+
socket_sites_parser.add_argument('--append-timestamp', dest='append_timestamp', action='store_true', help='Append timestamp to file names')
|
|
25
|
+
socket_sites_parser.add_argument('--output-directory', dest='output_directory', help='Output directory for exported files (default: config_data)')
|
|
26
|
+
|
|
18
27
|
socket_sites_parser.add_argument('-v', '--verbose', action='store_true', help='Verbose output')
|
|
19
28
|
|
|
20
|
-
socket_sites_parser.set_defaults(func=export_sites.
|
|
29
|
+
socket_sites_parser.set_defaults(func=export_sites.export_socket_sites_dispatcher)
|
|
21
30
|
|
|
22
31
|
return socket_sites_parser
|
|
32
|
+
|
|
33
|
+
|