catocli 1.0.1__tar.gz
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-1.0.1/LICENSE +201 -0
- catocli-1.0.1/MANIFEST.in +4 -0
- catocli-1.0.1/PKG-INFO +22 -0
- catocli-1.0.1/README.md +51 -0
- catocli-1.0.1/catocli/Utils/clidriver.py +103 -0
- catocli-1.0.1/catocli/__init__.py +2 -0
- catocli-1.0.1/catocli/__main__.py +11 -0
- catocli-1.0.1/catocli/parsers/custom/__init__.py +42 -0
- catocli-1.0.1/catocli/parsers/custom/customLib.py +71 -0
- catocli-1.0.1/catocli/parsers/mutation_admin/__init__.py +51 -0
- catocli-1.0.1/catocli/parsers/mutation_container/__init__.py +23 -0
- catocli-1.0.1/catocli/parsers/mutation_policy/__init__.py +357 -0
- catocli-1.0.1/catocli/parsers/mutation_site/__init__.py +219 -0
- catocli-1.0.1/catocli/parsers/mutation_sites/__init__.py +219 -0
- catocli-1.0.1/catocli/parsers/parserApiClient.py +309 -0
- catocli-1.0.1/catocli/parsers/query_accountBySubdomain/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_accountMetrics/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_accountRoles/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_accountSnapshot/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_admin/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_admins/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_appStats/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_appStatsTimeSeries/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_auditFeed/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_container/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_entityLookup/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_events/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_eventsFeed/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_eventsTimeSeries/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_hardwareManagement/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_licensing/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_policy/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_siteLocation/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_subDomains/__init__.py +17 -0
- catocli-1.0.1/catocli/parsers/query_xdr/__init__.py +37 -0
- catocli-1.0.1/catocli/parsers/raw/__init__.py +9 -0
- catocli-1.0.1/catocli.egg-info/PKG-INFO +22 -0
- catocli-1.0.1/catocli.egg-info/SOURCES.txt +95 -0
- catocli-1.0.1/catocli.egg-info/dependency_links.txt +1 -0
- catocli-1.0.1/catocli.egg-info/entry_points.txt +2 -0
- catocli-1.0.1/catocli.egg-info/requires.txt +3 -0
- catocli-1.0.1/catocli.egg-info/top_level.txt +7 -0
- catocli-1.0.1/graphql_client/__init__.py +11 -0
- catocli-1.0.1/graphql_client/api/__init__.py +3 -0
- catocli-1.0.1/graphql_client/api/call_api.py +73 -0
- catocli-1.0.1/graphql_client/api_client.py +192 -0
- catocli-1.0.1/graphql_client/api_client_types.py +404 -0
- catocli-1.0.1/graphql_client/configuration.py +230 -0
- catocli-1.0.1/graphql_client/models/__init__.py +13 -0
- catocli-1.0.1/graphql_client/models/no_schema.py +71 -0
- catocli-1.0.1/schema/catolib.py +1004 -0
- catocli-1.0.1/schema/importSchema.py +60 -0
- catocli-1.0.1/setup.cfg +4 -0
- catocli-1.0.1/setup.py +37 -0
- catocli-1.0.1/vendor/.DS_Store +0 -0
- catocli-1.0.1/vendor/certifi/__init__.py +4 -0
- catocli-1.0.1/vendor/certifi/__main__.py +12 -0
- catocli-1.0.1/vendor/certifi/core.py +114 -0
- catocli-1.0.1/vendor/certifi/py.typed +0 -0
- catocli-1.0.1/vendor/six.py +998 -0
- catocli-1.0.1/vendor/urllib3/__init__.py +211 -0
- catocli-1.0.1/vendor/urllib3/_base_connection.py +172 -0
- catocli-1.0.1/vendor/urllib3/_collections.py +483 -0
- catocli-1.0.1/vendor/urllib3/_request_methods.py +278 -0
- catocli-1.0.1/vendor/urllib3/_version.py +16 -0
- catocli-1.0.1/vendor/urllib3/connection.py +1033 -0
- catocli-1.0.1/vendor/urllib3/connectionpool.py +1182 -0
- catocli-1.0.1/vendor/urllib3/contrib/__init__.py +0 -0
- catocli-1.0.1/vendor/urllib3/contrib/emscripten/__init__.py +18 -0
- catocli-1.0.1/vendor/urllib3/contrib/emscripten/connection.py +254 -0
- catocli-1.0.1/vendor/urllib3/contrib/emscripten/fetch.py +418 -0
- catocli-1.0.1/vendor/urllib3/contrib/emscripten/request.py +22 -0
- catocli-1.0.1/vendor/urllib3/contrib/emscripten/response.py +285 -0
- catocli-1.0.1/vendor/urllib3/contrib/pyopenssl.py +552 -0
- catocli-1.0.1/vendor/urllib3/contrib/socks.py +228 -0
- catocli-1.0.1/vendor/urllib3/exceptions.py +321 -0
- catocli-1.0.1/vendor/urllib3/fields.py +341 -0
- catocli-1.0.1/vendor/urllib3/filepost.py +89 -0
- catocli-1.0.1/vendor/urllib3/http2/__init__.py +53 -0
- catocli-1.0.1/vendor/urllib3/http2/connection.py +356 -0
- catocli-1.0.1/vendor/urllib3/http2/probe.py +87 -0
- catocli-1.0.1/vendor/urllib3/poolmanager.py +637 -0
- catocli-1.0.1/vendor/urllib3/py.typed +2 -0
- catocli-1.0.1/vendor/urllib3/response.py +1265 -0
- catocli-1.0.1/vendor/urllib3/util/__init__.py +42 -0
- catocli-1.0.1/vendor/urllib3/util/connection.py +137 -0
- catocli-1.0.1/vendor/urllib3/util/proxy.py +43 -0
- catocli-1.0.1/vendor/urllib3/util/request.py +256 -0
- catocli-1.0.1/vendor/urllib3/util/response.py +101 -0
- catocli-1.0.1/vendor/urllib3/util/retry.py +533 -0
- catocli-1.0.1/vendor/urllib3/util/ssl_.py +513 -0
- catocli-1.0.1/vendor/urllib3/util/ssl_match_hostname.py +159 -0
- catocli-1.0.1/vendor/urllib3/util/ssltransport.py +276 -0
- catocli-1.0.1/vendor/urllib3/util/timeout.py +275 -0
- catocli-1.0.1/vendor/urllib3/util/url.py +471 -0
- catocli-1.0.1/vendor/urllib3/util/util.py +42 -0
- catocli-1.0.1/vendor/urllib3/util/wait.py +124 -0
catocli-1.0.1/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
catocli-1.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: catocli
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Cato Networks cli wrapper for the GraphQL API.
|
|
5
|
+
Home-page: https://github.com/Cato-Networks/cato-cli
|
|
6
|
+
Author: Cato Networks
|
|
7
|
+
Author-email: [email protected]
|
|
8
|
+
License: Apache-2.0 license
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Requires-Python: >=3.6
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: urllib3
|
|
19
|
+
Requires-Dist: certifi
|
|
20
|
+
Requires-Dist: six
|
|
21
|
+
|
|
22
|
+
The package provides a simple to use CLI that reflects industry standards (such as the AWS cli), and enables customers to manage Cato Networks configurations and processes via the [Cato Networks GraphQL API](https://api.catonetworks.com/api/v1/graphql2) easily integrating into configurations management, orchestration or automation frameworks to support the DevOps model.
|
catocli-1.0.1/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Cato Networks GraphQL API CLI
|
|
2
|
+
|
|
3
|
+
The package provides a simple to use CLI that reflects industry standards (such as the AWS cli), and enables customers to manage Cato Networks configurations and processes via the [Cato Networks GraphQL API](https://api.catonetworks.com/api/v1/graphql2) easily integrating into configurations management, orchestration or automation frameworks to support the DevOps model.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
pip3 install catocli
|
|
7
|
+
|
|
8
|
+
## Authentication - Setting up the required environment variables:
|
|
9
|
+
Set [environment variables](https://en.wikipedia.org/wiki/Environment_variable) to configure a token for authentication, and the specific hub endpoint, example:
|
|
10
|
+
|
|
11
|
+
export CATO_TOKEN="12345-abcde"
|
|
12
|
+
export CATO_HOST="12345-abcde" (defaults to https://api.catonetworks.com/api/v1/graphql2, add this environment variable for developoment purposes to specify alternative cato host)
|
|
13
|
+
export CATO_DEBUG=True (Optional to see cli debug logs in terminal output)
|
|
14
|
+
|
|
15
|
+
[CLICK HERE](https://support.catonetworks.com/hc/en-us/articles/4413280536081-Generating-API-Keys-for-the-Cato-API) to see how create an API key to authenticate.
|
|
16
|
+
|
|
17
|
+
## Running the CLI
|
|
18
|
+
catocli -h
|
|
19
|
+
catocli query -h
|
|
20
|
+
catocli query entityLookup -h
|
|
21
|
+
catocli query entityLookup 10454 '{"type":"country"}`
|
|
22
|
+
|
|
23
|
+
## Check out run locally not as pip package
|
|
24
|
+
git clone git@github.com:Cato-Networks/cato-cli.git
|
|
25
|
+
cd cato-cli
|
|
26
|
+
python3 -m catocli -h
|
|
27
|
+
|
|
28
|
+
This CLI is a Python 3 application and has been tested with Python 3.6 -> 3.8
|
|
29
|
+
## Requirements:
|
|
30
|
+
python 3.6 or higher
|
|
31
|
+
|
|
32
|
+
## Confirm your version of python if installed:
|
|
33
|
+
Open a terminal
|
|
34
|
+
Enter: python -V or python3 -V
|
|
35
|
+
|
|
36
|
+
## Usage:
|
|
37
|
+
usage: catocli <resource> <command> [options]
|
|
38
|
+
|
|
39
|
+
CLI for query, and mutation operations via API.
|
|
40
|
+
|
|
41
|
+
positional arguments:
|
|
42
|
+
{entityLookup}
|
|
43
|
+
entityLookup entityLookup reference.
|
|
44
|
+
|
|
45
|
+
optional arguments:
|
|
46
|
+
-h, --help show this help message and exit
|
|
47
|
+
--version show program's version number and exit
|
|
48
|
+
|
|
49
|
+
## Installing the correct version for environment:
|
|
50
|
+
https://www.python.org/downloads/
|
|
51
|
+
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
import catocli
|
|
6
|
+
from graphql_client import Configuration
|
|
7
|
+
from graphql_client.api_client import ApiException
|
|
8
|
+
from ..parsers.parserApiClient import get_help
|
|
9
|
+
import sys
|
|
10
|
+
sys.path.insert(0, 'vendor')
|
|
11
|
+
import urllib3
|
|
12
|
+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
13
|
+
if "CATO_TOKEN" not in os.environ:
|
|
14
|
+
print("Missing authentication, please set the CATO_TOKEN environment variable with your api key.")
|
|
15
|
+
exit()
|
|
16
|
+
CATO_TOKEN = os.getenv("CATO_TOKEN")
|
|
17
|
+
CATO_DEBUG = bool(os.getenv("CATO_DEBUG", False))
|
|
18
|
+
from ..parsers.raw import raw_parse
|
|
19
|
+
#from ..parsers.custom import custom_parse
|
|
20
|
+
from ..parsers.query_siteLocation import query_siteLocation_parse
|
|
21
|
+
from ..parsers.mutation_admin import mutation_admin_parse
|
|
22
|
+
from ..parsers.mutation_container import mutation_container_parse
|
|
23
|
+
from ..parsers.mutation_policy import mutation_policy_parse
|
|
24
|
+
from ..parsers.mutation_site import mutation_site_parse
|
|
25
|
+
from ..parsers.mutation_sites import mutation_sites_parse
|
|
26
|
+
from ..parsers.query_accountBySubdomain import query_accountBySubdomain_parse
|
|
27
|
+
from ..parsers.query_accountMetrics import query_accountMetrics_parse
|
|
28
|
+
from ..parsers.query_accountRoles import query_accountRoles_parse
|
|
29
|
+
from ..parsers.query_accountSnapshot import query_accountSnapshot_parse
|
|
30
|
+
from ..parsers.query_admin import query_admin_parse
|
|
31
|
+
from ..parsers.query_admins import query_admins_parse
|
|
32
|
+
from ..parsers.query_appStats import query_appStats_parse
|
|
33
|
+
from ..parsers.query_appStatsTimeSeries import query_appStatsTimeSeries_parse
|
|
34
|
+
from ..parsers.query_auditFeed import query_auditFeed_parse
|
|
35
|
+
from ..parsers.query_container import query_container_parse
|
|
36
|
+
from ..parsers.query_entityLookup import query_entityLookup_parse
|
|
37
|
+
from ..parsers.query_events import query_events_parse
|
|
38
|
+
from ..parsers.query_eventsFeed import query_eventsFeed_parse
|
|
39
|
+
from ..parsers.query_eventsTimeSeries import query_eventsTimeSeries_parse
|
|
40
|
+
from ..parsers.query_hardwareManagement import query_hardwareManagement_parse
|
|
41
|
+
from ..parsers.query_licensing import query_licensing_parse
|
|
42
|
+
from ..parsers.query_policy import query_policy_parse
|
|
43
|
+
from ..parsers.query_subDomains import query_subDomains_parse
|
|
44
|
+
from ..parsers.query_xdr import query_xdr_parse
|
|
45
|
+
|
|
46
|
+
configuration = Configuration()
|
|
47
|
+
configuration.verify_ssl = False
|
|
48
|
+
configuration.api_key["x-api-key"] = CATO_TOKEN
|
|
49
|
+
configuration.host = "{}".format(catocli.__cato_host__)
|
|
50
|
+
configuration.debug = CATO_DEBUG
|
|
51
|
+
configuration.version = "{}".format(catocli.__version__)
|
|
52
|
+
|
|
53
|
+
parser = argparse.ArgumentParser(prog='catocli', usage='%(prog)s <operationType> <operationName> [options]', description="CLI for query on CATO via API.")
|
|
54
|
+
parser.add_argument('--version', action='version', version=catocli.__version__)
|
|
55
|
+
subparsers = parser.add_subparsers()
|
|
56
|
+
#custom_parsers = custom_parse(subparsers)
|
|
57
|
+
raw_parsers = subparsers.add_parser('raw', help='Raw GraphQL', usage=get_help("raw"))
|
|
58
|
+
raw_parser = raw_parse(raw_parsers)
|
|
59
|
+
query_parser = subparsers.add_parser('query', help='Query', usage='catocli query <operationName> [options]')
|
|
60
|
+
query_subparsers = query_parser.add_subparsers(description='valid subcommands', help='additional help')
|
|
61
|
+
query_siteLocation_parser = query_siteLocation_parse(query_subparsers)
|
|
62
|
+
mutation_parser = subparsers.add_parser('mutation', help='Mutation', usage='catocli mutation <operationName> [options]')
|
|
63
|
+
mutation_subparsers = mutation_parser.add_subparsers(description='valid subcommands', help='additional help')
|
|
64
|
+
|
|
65
|
+
mutation_admin_parser = mutation_admin_parse(mutation_subparsers)
|
|
66
|
+
mutation_container_parser = mutation_container_parse(mutation_subparsers)
|
|
67
|
+
mutation_policy_parser = mutation_policy_parse(mutation_subparsers)
|
|
68
|
+
mutation_site_parser = mutation_site_parse(mutation_subparsers)
|
|
69
|
+
mutation_sites_parser = mutation_sites_parse(mutation_subparsers)
|
|
70
|
+
query_accountBySubdomain_parser = query_accountBySubdomain_parse(query_subparsers)
|
|
71
|
+
query_accountMetrics_parser = query_accountMetrics_parse(query_subparsers)
|
|
72
|
+
query_accountRoles_parser = query_accountRoles_parse(query_subparsers)
|
|
73
|
+
query_accountSnapshot_parser = query_accountSnapshot_parse(query_subparsers)
|
|
74
|
+
query_admin_parser = query_admin_parse(query_subparsers)
|
|
75
|
+
query_admins_parser = query_admins_parse(query_subparsers)
|
|
76
|
+
query_appStats_parser = query_appStats_parse(query_subparsers)
|
|
77
|
+
query_appStatsTimeSeries_parser = query_appStatsTimeSeries_parse(query_subparsers)
|
|
78
|
+
query_auditFeed_parser = query_auditFeed_parse(query_subparsers)
|
|
79
|
+
query_container_parser = query_container_parse(query_subparsers)
|
|
80
|
+
query_entityLookup_parser = query_entityLookup_parse(query_subparsers)
|
|
81
|
+
query_events_parser = query_events_parse(query_subparsers)
|
|
82
|
+
query_eventsFeed_parser = query_eventsFeed_parse(query_subparsers)
|
|
83
|
+
query_eventsTimeSeries_parser = query_eventsTimeSeries_parse(query_subparsers)
|
|
84
|
+
query_hardwareManagement_parser = query_hardwareManagement_parse(query_subparsers)
|
|
85
|
+
query_licensing_parser = query_licensing_parse(query_subparsers)
|
|
86
|
+
query_policy_parser = query_policy_parse(query_subparsers)
|
|
87
|
+
query_subDomains_parser = query_subDomains_parse(query_subparsers)
|
|
88
|
+
query_xdr_parser = query_xdr_parse(query_subparsers)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def main(args=None):
|
|
92
|
+
args = parser.parse_args(args=args)
|
|
93
|
+
try:
|
|
94
|
+
response = args.func(args, configuration)
|
|
95
|
+
|
|
96
|
+
if type(response) == ApiException:
|
|
97
|
+
print("ERROR! Status code: {}".format(response.status))
|
|
98
|
+
print(response)
|
|
99
|
+
else:
|
|
100
|
+
if response!=None:
|
|
101
|
+
print(json.dumps(response[0], sort_keys=True, indent=4))
|
|
102
|
+
except AttributeError:
|
|
103
|
+
print('Missing arguments. Usage: catocli <operation> -h')
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
import cato.parsers.custom.customLib as customLib
|
|
3
|
+
|
|
4
|
+
def custom_parse(subparsers):
|
|
5
|
+
site_parser = subparsers.add_parser('site', help='Site', usage='cato site <operationName> [options]')
|
|
6
|
+
site_subparsers = site_parser.add_subparsers(description='valid subcommands', help='additional help')
|
|
7
|
+
|
|
8
|
+
site_list_parser = site_subparsers.add_parser('list',
|
|
9
|
+
help='site list',
|
|
10
|
+
usage=get_help_custom("site_list"))
|
|
11
|
+
|
|
12
|
+
site_list_parser.add_argument('accountID', help='The Account ID.')
|
|
13
|
+
site_list_parser.add_argument('-s', help='Search string', default='', nargs='?')
|
|
14
|
+
site_list_parser.add_argument('-f', default="csv", choices=["json","csv"], nargs='?',
|
|
15
|
+
help='Specify format for output')
|
|
16
|
+
site_list_parser.add_argument('-t', const=True, default=False, nargs='?',
|
|
17
|
+
help='Print test request preview without sending api call')
|
|
18
|
+
site_list_parser.add_argument('-v', const=True, default=False, nargs='?',
|
|
19
|
+
help='Verbose output')
|
|
20
|
+
site_list_parser.add_argument('-p', const=True, default=False, nargs='?',
|
|
21
|
+
help='Pretty print')
|
|
22
|
+
|
|
23
|
+
site_list_parser.set_defaults(func=customLib.entityTypeList,operation_name='site')
|
|
24
|
+
|
|
25
|
+
def get_help_custom(path):
|
|
26
|
+
matchCmd = "cato "+path.replace("_"," ")
|
|
27
|
+
import os
|
|
28
|
+
pwd = os.path.dirname(__file__)
|
|
29
|
+
# doc = path+"/README.md"
|
|
30
|
+
abs_path = os.path.join(pwd, "README.md")
|
|
31
|
+
new_line = "\nEXAMPLES:\n"
|
|
32
|
+
lines = open(abs_path, "r").readlines()
|
|
33
|
+
for line in lines:
|
|
34
|
+
if f"{matchCmd}" in line:
|
|
35
|
+
clean_line = line.replace("<br /><br />", "").replace("`","")
|
|
36
|
+
new_line += f"{clean_line}\n"
|
|
37
|
+
# matchArg = path.replace("_",".")
|
|
38
|
+
# for line in lines:
|
|
39
|
+
# if f"`{matchArg}" in line:
|
|
40
|
+
# clean_line = line.replace("<br /><br />", "").replace("`","")
|
|
41
|
+
# new_line += f"{clean_line}\n"
|
|
42
|
+
return new_line
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from graphql_client.api.call_api import ApiClient, CallApi
|
|
3
|
+
from graphql_client.api_client import ApiException
|
|
4
|
+
import logging
|
|
5
|
+
from ..parserApiClient import validateArgs
|
|
6
|
+
|
|
7
|
+
def entityTypeList(args, configuration):
|
|
8
|
+
params = vars(args)
|
|
9
|
+
operation = {
|
|
10
|
+
"operationArgs": {
|
|
11
|
+
"accountID": {
|
|
12
|
+
"name": "accountID",
|
|
13
|
+
"required": True,
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
variablesObj = { "accountID": (params.get("accountID") if params.get("accountID") else params.get("accountId"))}
|
|
18
|
+
|
|
19
|
+
instance = CallApi(ApiClient(configuration))
|
|
20
|
+
operationName = params["operation_name"]
|
|
21
|
+
accountID = params.get("accountID") if params.get("accountID") else params.get("accountId")
|
|
22
|
+
query = '''query entityLookup ( $type:EntityType! $accountID:ID! $search:String ) {
|
|
23
|
+
entityLookup ( accountID:$accountID type:$type search:$search ) {
|
|
24
|
+
'''+params["operation_name"]+'''s: items {
|
|
25
|
+
description
|
|
26
|
+
'''+params["operation_name"]+''': entity {
|
|
27
|
+
id
|
|
28
|
+
name
|
|
29
|
+
type
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}'''
|
|
34
|
+
body = {
|
|
35
|
+
"query": query,
|
|
36
|
+
"operationName": "entityLookup",
|
|
37
|
+
"variables": {
|
|
38
|
+
"accountID": accountID,
|
|
39
|
+
"type": params["operation_name"],
|
|
40
|
+
"search": (params.get("s") if params.get("s")!=None else "")
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
isOk, invalidVars, message = validateArgs(variablesObj,operation)
|
|
45
|
+
if isOk==True:
|
|
46
|
+
if params["t"]==True:
|
|
47
|
+
if params["p"]==True:
|
|
48
|
+
print(json.dumps(body,indent=2,sort_keys=True).replace("\\n", "\n").replace("\\t", " "))
|
|
49
|
+
else:
|
|
50
|
+
print(json.dumps(body).replace("\\n", " ").replace("\\t", " ").replace(" "," ").replace(" "," "))
|
|
51
|
+
return None
|
|
52
|
+
else:
|
|
53
|
+
try:
|
|
54
|
+
response = instance.call_api(body,params)
|
|
55
|
+
if params["f"]=="json":
|
|
56
|
+
if params["p"]==True:
|
|
57
|
+
print(json.dumps(response[0].get("data").get("entityLookup").get(params["operation_name"]+"s"),indent=2,sort_keys=True).replace("\\n", "\n").replace("\\t", " "))
|
|
58
|
+
else:
|
|
59
|
+
print(json.dumps(response[0].get("data").get("entityLookup").get(params["operation_name"]+"s")))
|
|
60
|
+
else:
|
|
61
|
+
if len(response[0].get("data").get("entityLookup").get(params["operation_name"]+"s"))==0:
|
|
62
|
+
print("No results found")
|
|
63
|
+
else:
|
|
64
|
+
print("id,name,type,description")
|
|
65
|
+
for site in response[0].get("data").get("entityLookup").get(params["operation_name"]+"s"):
|
|
66
|
+
print(f"{site.get('site').get('id')},{site.get('site').get('name')},{site.get('site').get('type')},{site.get('description')}")
|
|
67
|
+
except ApiException as e:
|
|
68
|
+
return e
|
|
69
|
+
else:
|
|
70
|
+
print("ERROR: "+message,", ".join(invalidVars))
|
|
71
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
from ..parserApiClient import createRequest, get_help
|
|
3
|
+
|
|
4
|
+
def mutation_admin_parse(mutation_subparsers):
|
|
5
|
+
mutation_admin_parser = mutation_subparsers.add_parser('admin',
|
|
6
|
+
help='admin() mutation operation',
|
|
7
|
+
usage=get_help("mutation_admin"))
|
|
8
|
+
|
|
9
|
+
mutation_admin_subparsers = mutation_admin_parser.add_subparsers()
|
|
10
|
+
|
|
11
|
+
mutation_admin_addAdmin_parser = mutation_admin_subparsers.add_parser('addAdmin',
|
|
12
|
+
help='addAdmin() admin operation',
|
|
13
|
+
usage=get_help("mutation_admin_addAdmin"))
|
|
14
|
+
|
|
15
|
+
mutation_admin_addAdmin_parser.add_argument('accountID', help='The Account ID.')
|
|
16
|
+
mutation_admin_addAdmin_parser.add_argument('json', help='Variables in JSON format.')
|
|
17
|
+
mutation_admin_addAdmin_parser.add_argument('-t', const=True, default=False, nargs='?',
|
|
18
|
+
help='Print test request preview without sending api call')
|
|
19
|
+
mutation_admin_addAdmin_parser.add_argument('-v', const=True, default=False, nargs='?',
|
|
20
|
+
help='Verbose output')
|
|
21
|
+
mutation_admin_addAdmin_parser.add_argument('-p', const=True, default=False, nargs='?',
|
|
22
|
+
help='Pretty print')
|
|
23
|
+
mutation_admin_addAdmin_parser.set_defaults(func=createRequest,operation_name='mutation.admin.addAdmin')
|
|
24
|
+
|
|
25
|
+
mutation_admin_removeAdmin_parser = mutation_admin_subparsers.add_parser('removeAdmin',
|
|
26
|
+
help='removeAdmin() admin operation',
|
|
27
|
+
usage=get_help("mutation_admin_removeAdmin"))
|
|
28
|
+
|
|
29
|
+
mutation_admin_removeAdmin_parser.add_argument('accountID', help='The Account ID.')
|
|
30
|
+
mutation_admin_removeAdmin_parser.add_argument('json', help='Variables in JSON format.')
|
|
31
|
+
mutation_admin_removeAdmin_parser.add_argument('-t', const=True, default=False, nargs='?',
|
|
32
|
+
help='Print test request preview without sending api call')
|
|
33
|
+
mutation_admin_removeAdmin_parser.add_argument('-v', const=True, default=False, nargs='?',
|
|
34
|
+
help='Verbose output')
|
|
35
|
+
mutation_admin_removeAdmin_parser.add_argument('-p', const=True, default=False, nargs='?',
|
|
36
|
+
help='Pretty print')
|
|
37
|
+
mutation_admin_removeAdmin_parser.set_defaults(func=createRequest,operation_name='mutation.admin.removeAdmin')
|
|
38
|
+
|
|
39
|
+
mutation_admin_updateAdmin_parser = mutation_admin_subparsers.add_parser('updateAdmin',
|
|
40
|
+
help='updateAdmin() admin operation',
|
|
41
|
+
usage=get_help("mutation_admin_updateAdmin"))
|
|
42
|
+
|
|
43
|
+
mutation_admin_updateAdmin_parser.add_argument('accountID', help='The Account ID.')
|
|
44
|
+
mutation_admin_updateAdmin_parser.add_argument('json', help='Variables in JSON format.')
|
|
45
|
+
mutation_admin_updateAdmin_parser.add_argument('-t', const=True, default=False, nargs='?',
|
|
46
|
+
help='Print test request preview without sending api call')
|
|
47
|
+
mutation_admin_updateAdmin_parser.add_argument('-v', const=True, default=False, nargs='?',
|
|
48
|
+
help='Verbose output')
|
|
49
|
+
mutation_admin_updateAdmin_parser.add_argument('-p', const=True, default=False, nargs='?',
|
|
50
|
+
help='Pretty print')
|
|
51
|
+
mutation_admin_updateAdmin_parser.set_defaults(func=createRequest,operation_name='mutation.admin.updateAdmin')
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
from ..parserApiClient import createRequest, get_help
|
|
3
|
+
|
|
4
|
+
def mutation_container_parse(mutation_subparsers):
|
|
5
|
+
mutation_container_parser = mutation_subparsers.add_parser('container',
|
|
6
|
+
help='container() mutation operation',
|
|
7
|
+
usage=get_help("mutation_container"))
|
|
8
|
+
|
|
9
|
+
mutation_container_subparsers = mutation_container_parser.add_subparsers()
|
|
10
|
+
|
|
11
|
+
mutation_container_delete_parser = mutation_container_subparsers.add_parser('delete',
|
|
12
|
+
help='delete() container operation',
|
|
13
|
+
usage=get_help("mutation_container_delete"))
|
|
14
|
+
|
|
15
|
+
mutation_container_delete_parser.add_argument('accountID', help='The Account ID.')
|
|
16
|
+
mutation_container_delete_parser.add_argument('json', help='Variables in JSON format.')
|
|
17
|
+
mutation_container_delete_parser.add_argument('-t', const=True, default=False, nargs='?',
|
|
18
|
+
help='Print test request preview without sending api call')
|
|
19
|
+
mutation_container_delete_parser.add_argument('-v', const=True, default=False, nargs='?',
|
|
20
|
+
help='Verbose output')
|
|
21
|
+
mutation_container_delete_parser.add_argument('-p', const=True, default=False, nargs='?',
|
|
22
|
+
help='Pretty print')
|
|
23
|
+
mutation_container_delete_parser.set_defaults(func=createRequest,operation_name='mutation.container.delete')
|