catocli 2.0.3__py3-none-any.whl → 2.0.5__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.
- build/lib/catocli/Utils/clidriver.py +268 -0
- build/lib/catocli/Utils/profile_manager.py +188 -0
- build/lib/catocli/Utils/version_checker.py +192 -0
- build/lib/catocli/__init__.py +2 -0
- build/lib/catocli/__main__.py +12 -0
- build/lib/catocli/parsers/configure/__init__.py +115 -0
- build/lib/catocli/parsers/configure/configure.py +307 -0
- build/lib/catocli/parsers/custom/__init__.py +57 -0
- build/lib/catocli/parsers/custom/customLib.py +561 -0
- build/lib/catocli/parsers/custom/export_rules/__init__.py +42 -0
- build/lib/catocli/parsers/custom/export_rules/export_rules.py +234 -0
- build/lib/catocli/parsers/custom/export_sites/__init__.py +21 -0
- build/lib/catocli/parsers/custom/export_sites/export_sites.py +372 -0
- build/lib/catocli/parsers/custom/import_rules_to_tf/__init__.py +58 -0
- build/lib/catocli/parsers/custom/import_rules_to_tf/import_rules_to_tf.py +451 -0
- build/lib/catocli/parsers/custom/import_sites_to_tf/__init__.py +45 -0
- build/lib/catocli/parsers/custom/import_sites_to_tf/import_sites_to_tf.py +891 -0
- build/lib/catocli/parsers/mutation_accountManagement/__init__.py +48 -0
- build/lib/catocli/parsers/mutation_admin/__init__.py +48 -0
- build/lib/catocli/parsers/mutation_container/__init__.py +138 -0
- build/lib/catocli/parsers/mutation_hardware/__init__.py +22 -0
- build/lib/catocli/parsers/mutation_policy/__init__.py +1305 -0
- build/lib/catocli/parsers/mutation_sandbox/__init__.py +35 -0
- build/lib/catocli/parsers/mutation_site/__init__.py +373 -0
- build/lib/catocli/parsers/mutation_sites/__init__.py +373 -0
- build/lib/catocli/parsers/mutation_xdr/__init__.py +48 -0
- build/lib/catocli/parsers/parserApiClient.py +513 -0
- build/lib/catocli/parsers/query_accountBySubdomain/__init__.py +16 -0
- build/lib/catocli/parsers/query_accountManagement/__init__.py +16 -0
- build/lib/catocli/parsers/query_accountMetrics/__init__.py +16 -0
- build/lib/catocli/parsers/query_accountRoles/__init__.py +16 -0
- build/lib/catocli/parsers/query_accountSnapshot/__init__.py +16 -0
- build/lib/catocli/parsers/query_admin/__init__.py +16 -0
- build/lib/catocli/parsers/query_admins/__init__.py +16 -0
- build/lib/catocli/parsers/query_appStats/__init__.py +16 -0
- build/lib/catocli/parsers/query_appStatsTimeSeries/__init__.py +16 -0
- build/lib/catocli/parsers/query_auditFeed/__init__.py +16 -0
- build/lib/catocli/parsers/query_catalogs/__init__.py +16 -0
- build/lib/catocli/parsers/query_container/__init__.py +16 -0
- build/lib/catocli/parsers/query_devices/__init__.py +16 -0
- build/lib/catocli/parsers/query_entityLookup/__init__.py +16 -0
- build/lib/catocli/parsers/query_events/__init__.py +16 -0
- build/lib/catocli/parsers/query_eventsFeed/__init__.py +16 -0
- build/lib/catocli/parsers/query_eventsTimeSeries/__init__.py +16 -0
- build/lib/catocli/parsers/query_hardware/__init__.py +16 -0
- build/lib/catocli/parsers/query_hardwareManagement/__init__.py +16 -0
- build/lib/catocli/parsers/query_licensing/__init__.py +16 -0
- build/lib/catocli/parsers/query_policy/__init__.py +161 -0
- build/lib/catocli/parsers/query_sandbox/__init__.py +16 -0
- build/lib/catocli/parsers/query_site/__init__.py +100 -0
- build/lib/catocli/parsers/query_siteLocation/__init__.py +13 -0
- build/lib/catocli/parsers/query_subDomains/__init__.py +16 -0
- build/lib/catocli/parsers/query_xdr/__init__.py +35 -0
- build/lib/catocli/parsers/raw/__init__.py +12 -0
- build/lib/graphql_client/__init__.py +11 -0
- build/lib/graphql_client/api/__init__.py +3 -0
- build/lib/graphql_client/api/call_api.py +84 -0
- build/lib/graphql_client/api_client.py +192 -0
- build/lib/graphql_client/api_client_types.py +409 -0
- build/lib/graphql_client/configuration.py +232 -0
- build/lib/graphql_client/models/__init__.py +13 -0
- build/lib/graphql_client/models/no_schema.py +71 -0
- build/lib/schema/catolib.py +1141 -0
- build/lib/schema/importSchema.py +60 -0
- build/lib/schema/remove_policyid.py +89 -0
- build/lib/schema/remove_policyid_mutations.py +89 -0
- build/lib/scripts/catolib.py +62 -0
- build/lib/scripts/export_if_rules_to_json.py +188 -0
- build/lib/scripts/export_wf_rules_to_json.py +111 -0
- build/lib/scripts/import_wf_rules_to_tfstate.py +331 -0
- build/lib/vendor/certifi/__init__.py +4 -0
- build/lib/vendor/certifi/__main__.py +12 -0
- build/lib/vendor/certifi/core.py +114 -0
- build/lib/vendor/certifi/py.typed +0 -0
- build/lib/vendor/six.py +998 -0
- build/lib/vendor/urllib3/__init__.py +211 -0
- build/lib/vendor/urllib3/_base_connection.py +172 -0
- build/lib/vendor/urllib3/_collections.py +483 -0
- build/lib/vendor/urllib3/_request_methods.py +278 -0
- build/lib/vendor/urllib3/_version.py +16 -0
- build/lib/vendor/urllib3/connection.py +1033 -0
- build/lib/vendor/urllib3/connectionpool.py +1182 -0
- build/lib/vendor/urllib3/contrib/__init__.py +0 -0
- build/lib/vendor/urllib3/contrib/emscripten/__init__.py +18 -0
- build/lib/vendor/urllib3/contrib/emscripten/connection.py +254 -0
- build/lib/vendor/urllib3/contrib/emscripten/fetch.py +418 -0
- build/lib/vendor/urllib3/contrib/emscripten/request.py +22 -0
- build/lib/vendor/urllib3/contrib/emscripten/response.py +285 -0
- build/lib/vendor/urllib3/contrib/pyopenssl.py +552 -0
- build/lib/vendor/urllib3/contrib/socks.py +228 -0
- build/lib/vendor/urllib3/exceptions.py +321 -0
- build/lib/vendor/urllib3/fields.py +341 -0
- build/lib/vendor/urllib3/filepost.py +89 -0
- build/lib/vendor/urllib3/http2/__init__.py +53 -0
- build/lib/vendor/urllib3/http2/connection.py +356 -0
- build/lib/vendor/urllib3/http2/probe.py +87 -0
- build/lib/vendor/urllib3/poolmanager.py +637 -0
- build/lib/vendor/urllib3/py.typed +2 -0
- build/lib/vendor/urllib3/response.py +1265 -0
- build/lib/vendor/urllib3/util/__init__.py +42 -0
- build/lib/vendor/urllib3/util/connection.py +137 -0
- build/lib/vendor/urllib3/util/proxy.py +43 -0
- build/lib/vendor/urllib3/util/request.py +256 -0
- build/lib/vendor/urllib3/util/response.py +101 -0
- build/lib/vendor/urllib3/util/retry.py +533 -0
- build/lib/vendor/urllib3/util/ssl_.py +513 -0
- build/lib/vendor/urllib3/util/ssl_match_hostname.py +159 -0
- build/lib/vendor/urllib3/util/ssltransport.py +276 -0
- build/lib/vendor/urllib3/util/timeout.py +275 -0
- build/lib/vendor/urllib3/util/url.py +471 -0
- build/lib/vendor/urllib3/util/util.py +42 -0
- build/lib/vendor/urllib3/util/wait.py +124 -0
- catocli/Utils/clidriver.py +1 -4
- catocli/__init__.py +1 -1
- catocli/parsers/custom/export_rules/__init__.py +2 -0
- catocli/parsers/custom/export_rules/export_rules.py +29 -5
- catocli/parsers/custom/export_sites/__init__.py +1 -0
- catocli/parsers/custom/export_sites/export_sites.py +10 -3
- catocli/parsers/mutation_container/__init__.py +116 -0
- catocli/parsers/mutation_container_fqdn/README.md +7 -0
- catocli/parsers/mutation_container_fqdn_addValues/README.md +17 -0
- catocli/parsers/mutation_container_fqdn_createFromFile/README.md +17 -0
- catocli/parsers/mutation_container_fqdn_removeValues/README.md +17 -0
- catocli/parsers/mutation_container_fqdn_updateFromFile/README.md +17 -0
- catocli/parsers/mutation_container_ipAddressRange/README.md +7 -0
- catocli/parsers/mutation_container_ipAddressRange_addValues/README.md +17 -0
- catocli/parsers/mutation_container_ipAddressRange_createFromFile/README.md +17 -0
- catocli/parsers/mutation_container_ipAddressRange_removeValues/README.md +17 -0
- catocli/parsers/mutation_container_ipAddressRange_updateFromFile/README.md +17 -0
- catocli/parsers/mutation_policy_internetFirewall_addRule/README.md +1 -1
- catocli/parsers/mutation_policy_internetFirewall_updateRule/README.md +1 -1
- catocli/parsers/mutation_policy_wanFirewall_addRule/README.md +1 -1
- catocli/parsers/mutation_policy_wanFirewall_updateRule/README.md +1 -1
- catocli/parsers/parserApiClient.py +183 -7
- catocli/parsers/query_policy/README.md +0 -17
- catocli/parsers/query_policy/__init__.py +153 -8
- catocli/parsers/query_policy_appTenantRestriction/README.md +7 -0
- catocli/parsers/query_policy_appTenantRestriction_policy/README.md +17 -0
- catocli/parsers/query_policy_dynamicIpAllocation/README.md +7 -0
- catocli/parsers/query_policy_dynamicIpAllocation_policy/README.md +17 -0
- catocli/parsers/query_policy_internetFirewall/README.md +7 -0
- catocli/parsers/query_policy_internetFirewall_policy/README.md +17 -0
- catocli/parsers/query_policy_remotePortFwd/README.md +7 -0
- catocli/parsers/query_policy_remotePortFwd_policy/README.md +17 -0
- catocli/parsers/query_policy_socketLan/README.md +7 -0
- catocli/parsers/query_policy_socketLan_policy/README.md +17 -0
- catocli/parsers/query_policy_terminalServer/README.md +7 -0
- catocli/parsers/query_policy_terminalServer_policy/README.md +17 -0
- catocli/parsers/query_policy_wanFirewall/README.md +7 -0
- catocli/parsers/query_policy_wanFirewall_policy/README.md +17 -0
- catocli/parsers/query_policy_wanNetwork/README.md +7 -0
- catocli/parsers/query_policy_wanNetwork_policy/README.md +17 -0
- catocli/parsers/query_site/README.md +0 -16
- catocli/parsers/query_site/__init__.py +92 -8
- catocli/parsers/query_site_availableVersionList/README.md +17 -0
- catocli/parsers/query_site_bgpPeer/README.md +17 -0
- catocli/parsers/query_site_bgpPeerList/README.md +17 -0
- catocli/parsers/query_site_cloudInterconnectConnectionConnectivity/README.md +17 -0
- catocli/parsers/query_site_cloudInterconnectPhysicalConnection/README.md +17 -0
- catocli/parsers/query_site_cloudInterconnectPhysicalConnectionId/README.md +17 -0
- catocli/parsers/query_site_siteBgpStatus/README.md +17 -0
- {catocli-2.0.3.dist-info → catocli-2.0.5.dist-info}/METADATA +1 -1
- {catocli-2.0.3.dist-info → catocli-2.0.5.dist-info}/RECORD +291 -121
- {catocli-2.0.3.dist-info → catocli-2.0.5.dist-info}/top_level.txt +1 -0
- graphql_client/api/call_api.py +4 -3
- models/mutation.container.fqdn.addValues.json +866 -0
- models/mutation.container.fqdn.createFromFile.json +819 -0
- models/mutation.container.fqdn.removeValues.json +866 -0
- models/mutation.container.fqdn.updateFromFile.json +1045 -0
- models/mutation.container.ipAddressRange.addValues.json +1020 -0
- models/mutation.container.ipAddressRange.createFromFile.json +819 -0
- models/mutation.container.ipAddressRange.removeValues.json +1020 -0
- models/mutation.container.ipAddressRange.updateFromFile.json +1045 -0
- models/mutation.policy.appTenantRestriction.addRule.json +8 -8
- models/mutation.policy.appTenantRestriction.addSection.json +1 -1
- models/mutation.policy.appTenantRestriction.createPolicyRevision.json +2 -2
- models/mutation.policy.appTenantRestriction.discardPolicyRevision.json +2 -2
- models/mutation.policy.appTenantRestriction.moveRule.json +2 -2
- models/mutation.policy.appTenantRestriction.moveSection.json +1 -1
- models/mutation.policy.appTenantRestriction.publishPolicyRevision.json +2 -2
- models/mutation.policy.appTenantRestriction.removeRule.json +2 -2
- models/mutation.policy.appTenantRestriction.removeSection.json +1 -1
- models/mutation.policy.appTenantRestriction.updatePolicy.json +2 -2
- models/mutation.policy.appTenantRestriction.updateRule.json +8 -8
- models/mutation.policy.appTenantRestriction.updateSection.json +1 -1
- models/mutation.policy.dynamicIpAllocation.addRule.json +1 -1
- models/mutation.policy.dynamicIpAllocation.addSection.json +1 -1
- models/mutation.policy.dynamicIpAllocation.createPolicyRevision.json +1 -1
- models/mutation.policy.dynamicIpAllocation.discardPolicyRevision.json +1 -1
- models/mutation.policy.dynamicIpAllocation.moveRule.json +1 -1
- models/mutation.policy.dynamicIpAllocation.moveSection.json +1 -1
- models/mutation.policy.dynamicIpAllocation.publishPolicyRevision.json +1 -1
- models/mutation.policy.dynamicIpAllocation.removeRule.json +1 -1
- models/mutation.policy.dynamicIpAllocation.removeSection.json +1 -1
- models/mutation.policy.dynamicIpAllocation.updatePolicy.json +1 -1
- models/mutation.policy.dynamicIpAllocation.updateRule.json +1 -1
- models/mutation.policy.dynamicIpAllocation.updateSection.json +1 -1
- models/mutation.policy.internetFirewall.addRule.json +502 -55
- models/mutation.policy.internetFirewall.addSection.json +1 -1
- models/mutation.policy.internetFirewall.createPolicyRevision.json +127 -10
- models/mutation.policy.internetFirewall.discardPolicyRevision.json +127 -10
- models/mutation.policy.internetFirewall.moveRule.json +127 -10
- models/mutation.policy.internetFirewall.moveSection.json +1 -1
- models/mutation.policy.internetFirewall.publishPolicyRevision.json +127 -10
- models/mutation.policy.internetFirewall.removeRule.json +127 -10
- models/mutation.policy.internetFirewall.removeSection.json +1 -1
- models/mutation.policy.internetFirewall.updatePolicy.json +127 -10
- models/mutation.policy.internetFirewall.updateRule.json +493 -55
- models/mutation.policy.internetFirewall.updateSection.json +1 -1
- models/mutation.policy.remotePortFwd.addRule.json +5 -5
- models/mutation.policy.remotePortFwd.addSection.json +1 -1
- models/mutation.policy.remotePortFwd.createPolicyRevision.json +2 -2
- models/mutation.policy.remotePortFwd.discardPolicyRevision.json +2 -2
- models/mutation.policy.remotePortFwd.moveRule.json +2 -2
- models/mutation.policy.remotePortFwd.moveSection.json +1 -1
- models/mutation.policy.remotePortFwd.publishPolicyRevision.json +2 -2
- models/mutation.policy.remotePortFwd.removeRule.json +2 -2
- models/mutation.policy.remotePortFwd.removeSection.json +1 -1
- models/mutation.policy.remotePortFwd.updatePolicy.json +2 -2
- models/mutation.policy.remotePortFwd.updateRule.json +5 -5
- models/mutation.policy.remotePortFwd.updateSection.json +1 -1
- models/mutation.policy.socketLan.addRule.json +16 -16
- models/mutation.policy.socketLan.addSection.json +1 -1
- models/mutation.policy.socketLan.createPolicyRevision.json +4 -4
- models/mutation.policy.socketLan.discardPolicyRevision.json +4 -4
- models/mutation.policy.socketLan.moveRule.json +4 -4
- models/mutation.policy.socketLan.moveSection.json +1 -1
- models/mutation.policy.socketLan.publishPolicyRevision.json +4 -4
- models/mutation.policy.socketLan.removeRule.json +4 -4
- models/mutation.policy.socketLan.removeSection.json +1 -1
- models/mutation.policy.socketLan.updatePolicy.json +4 -4
- models/mutation.policy.socketLan.updateRule.json +16 -16
- models/mutation.policy.socketLan.updateSection.json +1 -1
- models/mutation.policy.terminalServer.addRule.json +1 -1
- models/mutation.policy.terminalServer.addSection.json +1 -1
- models/mutation.policy.terminalServer.createPolicyRevision.json +1 -1
- models/mutation.policy.terminalServer.discardPolicyRevision.json +1 -1
- models/mutation.policy.terminalServer.moveRule.json +1 -1
- models/mutation.policy.terminalServer.moveSection.json +1 -1
- models/mutation.policy.terminalServer.publishPolicyRevision.json +1 -1
- models/mutation.policy.terminalServer.removeRule.json +1 -1
- models/mutation.policy.terminalServer.removeSection.json +1 -1
- models/mutation.policy.terminalServer.updatePolicy.json +1 -1
- models/mutation.policy.terminalServer.updateRule.json +1 -1
- models/mutation.policy.terminalServer.updateSection.json +1 -1
- models/mutation.policy.wanFirewall.addRule.json +500 -53
- models/mutation.policy.wanFirewall.addSection.json +1 -1
- models/mutation.policy.wanFirewall.createPolicyRevision.json +128 -11
- models/mutation.policy.wanFirewall.discardPolicyRevision.json +128 -11
- models/mutation.policy.wanFirewall.moveRule.json +128 -11
- models/mutation.policy.wanFirewall.moveSection.json +1 -1
- models/mutation.policy.wanFirewall.publishPolicyRevision.json +128 -11
- models/mutation.policy.wanFirewall.removeRule.json +128 -11
- models/mutation.policy.wanFirewall.removeSection.json +1 -1
- models/mutation.policy.wanFirewall.updatePolicy.json +128 -11
- models/mutation.policy.wanFirewall.updateRule.json +491 -53
- models/mutation.policy.wanFirewall.updateSection.json +1 -1
- models/mutation.policy.wanNetwork.addRule.json +13 -13
- models/mutation.policy.wanNetwork.addSection.json +1 -1
- models/mutation.policy.wanNetwork.createPolicyRevision.json +1 -1
- models/mutation.policy.wanNetwork.discardPolicyRevision.json +1 -1
- models/mutation.policy.wanNetwork.moveRule.json +1 -1
- models/mutation.policy.wanNetwork.moveSection.json +1 -1
- models/mutation.policy.wanNetwork.publishPolicyRevision.json +1 -1
- models/mutation.policy.wanNetwork.removeRule.json +1 -1
- models/mutation.policy.wanNetwork.removeSection.json +1 -1
- models/mutation.policy.wanNetwork.updatePolicy.json +1 -1
- models/mutation.policy.wanNetwork.updateRule.json +13 -13
- models/mutation.policy.wanNetwork.updateSection.json +1 -1
- models/query.policy.appTenantRestriction.policy.json +3086 -0
- models/query.policy.dynamicIpAllocation.policy.json +1934 -0
- models/query.policy.internetFirewall.policy.json +7833 -0
- models/query.policy.json +233 -0
- models/query.policy.remotePortFwd.policy.json +2387 -0
- models/query.policy.socketLan.policy.json +7140 -0
- models/query.policy.terminalServer.policy.json +1632 -0
- models/query.policy.wanFirewall.policy.json +9212 -0
- models/query.policy.wanNetwork.policy.json +8010 -0
- models/query.site.availableVersionList.json +365 -0
- models/query.site.bgpPeer.json +1917 -0
- models/query.site.bgpPeerList.json +2076 -0
- models/query.site.cloudInterconnectConnectionConnectivity.json +298 -0
- models/query.site.cloudInterconnectPhysicalConnection.json +728 -0
- models/query.site.cloudInterconnectPhysicalConnectionId.json +660 -0
- models/query.site.siteBgpStatus.json +869 -0
- schema/catolib.py +13 -6
- schema/remove_policyid.py +89 -0
- schema/remove_policyid_mutations.py +89 -0
- {catocli-2.0.3.dist-info → catocli-2.0.5.dist-info}/LICENSE +0 -0
- {catocli-2.0.3.dist-info → catocli-2.0.5.dist-info}/WHEEL +0 -0
- {catocli-2.0.3.dist-info → catocli-2.0.5.dist-info}/entry_points.txt +0 -0
schema/catolib.py
CHANGED
|
@@ -78,6 +78,11 @@ def openFile(fileName, readMode="rt"):
|
|
|
78
78
|
############ parsing schema ############
|
|
79
79
|
|
|
80
80
|
def parseSchema(schema):
|
|
81
|
+
# Load settings to get childOperationParent and childOperationObjects configuration
|
|
82
|
+
settings = loadJSON("../settings.json")
|
|
83
|
+
childOperationParent = settings.get("childOperationParent", {})
|
|
84
|
+
childOperationObjects = settings.get("childOperationObjects", {})
|
|
85
|
+
|
|
81
86
|
mutationOperationsTMP = {}
|
|
82
87
|
queryOperationsTMP = {}
|
|
83
88
|
for i, type in enumerate(schema["data"]["__schema"]["types"]):
|
|
@@ -94,7 +99,7 @@ def parseSchema(schema):
|
|
|
94
99
|
elif type["kind"] == "OBJECT":
|
|
95
100
|
if type["name"] == "Query":
|
|
96
101
|
for field in type["fields"]:
|
|
97
|
-
if field["name"]
|
|
102
|
+
if field["name"] in childOperationParent:
|
|
98
103
|
queryOperationsTMP[field["name"]] = copy.deepcopy(field)
|
|
99
104
|
else:
|
|
100
105
|
catoApiSchema["query"]["query."+field["name"]] = copy.deepcopy(field)
|
|
@@ -107,11 +112,11 @@ def parseSchema(schema):
|
|
|
107
112
|
|
|
108
113
|
for queryType in queryOperationsTMP:
|
|
109
114
|
parentQueryOperationType = copy.deepcopy(queryOperationsTMP[queryType])
|
|
110
|
-
getChildOperations("query", parentQueryOperationType, parentQueryOperationType, "query." + queryType)
|
|
115
|
+
getChildOperations("query", parentQueryOperationType, parentQueryOperationType, "query." + queryType, childOperationObjects)
|
|
111
116
|
|
|
112
117
|
for mutationType in mutationOperationsTMP:
|
|
113
118
|
parentMutationOperationType = copy.deepcopy(mutationOperationsTMP[mutationType])
|
|
114
|
-
getChildOperations("mutation", parentMutationOperationType, parentMutationOperationType, "mutation." + mutationType)
|
|
119
|
+
getChildOperations("mutation", parentMutationOperationType, parentMutationOperationType, "mutation." + mutationType, childOperationObjects)
|
|
115
120
|
|
|
116
121
|
for operationType in catoApiSchema:
|
|
117
122
|
for operationName in catoApiSchema[operationType]:
|
|
@@ -129,7 +134,7 @@ def parseSchema(schema):
|
|
|
129
134
|
payload = generateGraphqlPayload(parsedOperation["variablesPayload"],parsedOperation,operationName)
|
|
130
135
|
writeFile("../queryPayloads/"+operationName+".txt",payload["query"])
|
|
131
136
|
|
|
132
|
-
def getChildOperations(operationType, curType, parentType, parentPath):
|
|
137
|
+
def getChildOperations(operationType, curType, parentType, parentPath, childOperationObjects):
|
|
133
138
|
# Parse fields for nested args to map out all child operations
|
|
134
139
|
# This will separate fields like stories and story for query.xdr,
|
|
135
140
|
# and all fields which are actually sub operations from mutation.internetFirewall, etc
|
|
@@ -154,12 +159,14 @@ def getChildOperations(operationType, curType, parentType, parentPath):
|
|
|
154
159
|
parentFields = []
|
|
155
160
|
for field in curOfType["fields"]:
|
|
156
161
|
curFieldObject = copy.deepcopy(field)
|
|
157
|
-
if "args" in curFieldObject and len(curFieldObject["args"])>0
|
|
162
|
+
if (("args" in curFieldObject and len(curFieldObject["args"])>0) or
|
|
163
|
+
(curFieldObject["name"] in childOperationObjects) or
|
|
164
|
+
(curOfType["name"] in childOperationObjects)):
|
|
158
165
|
hasChildren = True
|
|
159
166
|
curParentType = copy.deepcopy(parentType)
|
|
160
167
|
curFieldObject["args"] = getNestedArgDefinitions(curFieldObject["args"], curFieldObject["name"],None,None)
|
|
161
168
|
curParentType["childOperations"][curFieldObject["name"]] = curFieldObject
|
|
162
|
-
getChildOperations(operationType, curFieldObject, curParentType, parentPath + "." + curFieldObject["name"])
|
|
169
|
+
getChildOperations(operationType, curFieldObject, curParentType, parentPath + "." + curFieldObject["name"], childOperationObjects)
|
|
163
170
|
if not hasChildren:
|
|
164
171
|
catoApiSchema[operationType][parentPath] = parentType
|
|
165
172
|
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import glob
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
def remove_policy_id_from_object(obj, path=""):
|
|
9
|
+
"""
|
|
10
|
+
Recursively remove policyId fields from a JSON object.
|
|
11
|
+
"""
|
|
12
|
+
if isinstance(obj, dict):
|
|
13
|
+
# Remove policyId field if it exists
|
|
14
|
+
if "policyId" in obj:
|
|
15
|
+
print(f"Removing policyId field at path: {path}")
|
|
16
|
+
del obj["policyId"]
|
|
17
|
+
|
|
18
|
+
# Recursively process all other fields
|
|
19
|
+
for key, value in obj.items():
|
|
20
|
+
new_path = f"{path}.{key}" if path else key
|
|
21
|
+
remove_policy_id_from_object(value, new_path)
|
|
22
|
+
|
|
23
|
+
elif isinstance(obj, list):
|
|
24
|
+
# Process each item in the list
|
|
25
|
+
for i, item in enumerate(obj):
|
|
26
|
+
new_path = f"{path}[{i}]" if path else f"[{i}]"
|
|
27
|
+
remove_policy_id_from_object(item, new_path)
|
|
28
|
+
|
|
29
|
+
def process_file(file_path):
|
|
30
|
+
"""
|
|
31
|
+
Process a single JSON file to remove policyId fields.
|
|
32
|
+
"""
|
|
33
|
+
print(f"Processing file: {file_path}")
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
# Read the JSON file
|
|
37
|
+
with open(file_path, 'r') as f:
|
|
38
|
+
data = json.load(f)
|
|
39
|
+
|
|
40
|
+
# Remove policyId fields
|
|
41
|
+
remove_policy_id_from_object(data, os.path.basename(file_path))
|
|
42
|
+
|
|
43
|
+
# Write the modified JSON back to the file
|
|
44
|
+
with open(file_path, 'w') as f:
|
|
45
|
+
json.dump(data, f, indent=4, sort_keys=True)
|
|
46
|
+
|
|
47
|
+
print(f"Successfully processed: {file_path}")
|
|
48
|
+
|
|
49
|
+
except Exception as e:
|
|
50
|
+
print(f"Error processing {file_path}: {e}")
|
|
51
|
+
return False
|
|
52
|
+
|
|
53
|
+
return True
|
|
54
|
+
|
|
55
|
+
def main():
|
|
56
|
+
# Get the directory where this script is located
|
|
57
|
+
script_dir = os.path.dirname(os.path.abspath(__file__))
|
|
58
|
+
base_dir = os.path.dirname(script_dir) # Go up one level to cato-cli directory
|
|
59
|
+
|
|
60
|
+
# Find all query.policy*.json files in the models directory
|
|
61
|
+
models_dir = os.path.join(base_dir, "models")
|
|
62
|
+
pattern = os.path.join(models_dir, "query.policy*.json")
|
|
63
|
+
|
|
64
|
+
files = glob.glob(pattern)
|
|
65
|
+
|
|
66
|
+
if not files:
|
|
67
|
+
print("No query.policy*.json files found!")
|
|
68
|
+
return 1
|
|
69
|
+
|
|
70
|
+
print(f"Found {len(files)} files to process:")
|
|
71
|
+
for file in files:
|
|
72
|
+
print(f" - {os.path.basename(file)}")
|
|
73
|
+
|
|
74
|
+
# Process each file
|
|
75
|
+
success_count = 0
|
|
76
|
+
for file_path in files:
|
|
77
|
+
if process_file(file_path):
|
|
78
|
+
success_count += 1
|
|
79
|
+
|
|
80
|
+
print(f"\nProcessing complete!")
|
|
81
|
+
print(f"Successfully processed: {success_count}/{len(files)} files")
|
|
82
|
+
|
|
83
|
+
if success_count != len(files):
|
|
84
|
+
return 1
|
|
85
|
+
|
|
86
|
+
return 0
|
|
87
|
+
|
|
88
|
+
if __name__ == "__main__":
|
|
89
|
+
sys.exit(main())
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import glob
|
|
6
|
+
|
|
7
|
+
def remove_policy_id_recursive(obj, path=""):
|
|
8
|
+
"""
|
|
9
|
+
Recursively remove all 'policyId' keys from a JSON object.
|
|
10
|
+
Returns the number of removals made.
|
|
11
|
+
"""
|
|
12
|
+
removals = 0
|
|
13
|
+
|
|
14
|
+
if isinstance(obj, dict):
|
|
15
|
+
# Create a list of keys to remove to avoid modifying dict during iteration
|
|
16
|
+
keys_to_remove = []
|
|
17
|
+
for key in obj.keys():
|
|
18
|
+
if key == "policyId":
|
|
19
|
+
keys_to_remove.append(key)
|
|
20
|
+
current_path = f"{path}.{key}" if path else key
|
|
21
|
+
print(f" Removing policyId at: {current_path}")
|
|
22
|
+
removals += 1
|
|
23
|
+
|
|
24
|
+
# Remove the policyId keys
|
|
25
|
+
for key in keys_to_remove:
|
|
26
|
+
del obj[key]
|
|
27
|
+
|
|
28
|
+
# Recursively process remaining values
|
|
29
|
+
for key, value in obj.items():
|
|
30
|
+
current_path = f"{path}.{key}" if path else key
|
|
31
|
+
removals += remove_policy_id_recursive(value, current_path)
|
|
32
|
+
|
|
33
|
+
elif isinstance(obj, list):
|
|
34
|
+
for i, item in enumerate(obj):
|
|
35
|
+
current_path = f"{path}[{i}]" if path else f"[{i}]"
|
|
36
|
+
removals += remove_policy_id_recursive(item, current_path)
|
|
37
|
+
|
|
38
|
+
return removals
|
|
39
|
+
|
|
40
|
+
def process_mutation_policy_files():
|
|
41
|
+
"""
|
|
42
|
+
Find and process all mutation.policy*.json files in the models directory.
|
|
43
|
+
"""
|
|
44
|
+
models_dir = "/Users/briananderson/Documents/Dev/github.com/catonetworks/cato-cli/models"
|
|
45
|
+
pattern = os.path.join(models_dir, "mutation.policy*.json")
|
|
46
|
+
|
|
47
|
+
files = glob.glob(pattern)
|
|
48
|
+
|
|
49
|
+
if not files:
|
|
50
|
+
print("No mutation.policy*.json files found!")
|
|
51
|
+
return
|
|
52
|
+
|
|
53
|
+
print(f"Found {len(files)} mutation.policy*.json files to process:")
|
|
54
|
+
|
|
55
|
+
total_removals = 0
|
|
56
|
+
processed_files = 0
|
|
57
|
+
|
|
58
|
+
for file_path in sorted(files):
|
|
59
|
+
filename = os.path.basename(file_path)
|
|
60
|
+
print(f"\nProcessing: {filename}")
|
|
61
|
+
|
|
62
|
+
try:
|
|
63
|
+
# Read the JSON file
|
|
64
|
+
with open(file_path, 'r', encoding='utf-8') as f:
|
|
65
|
+
data = json.load(f)
|
|
66
|
+
|
|
67
|
+
# Remove policyId fields
|
|
68
|
+
removals = remove_policy_id_recursive(data, filename)
|
|
69
|
+
|
|
70
|
+
if removals > 0:
|
|
71
|
+
# Write back the modified JSON
|
|
72
|
+
with open(file_path, 'w', encoding='utf-8') as f:
|
|
73
|
+
json.dump(data, f, indent=4, ensure_ascii=False)
|
|
74
|
+
|
|
75
|
+
print(f" Removed {removals} policyId field(s)")
|
|
76
|
+
total_removals += removals
|
|
77
|
+
processed_files += 1
|
|
78
|
+
else:
|
|
79
|
+
print(" No policyId fields found")
|
|
80
|
+
|
|
81
|
+
except Exception as e:
|
|
82
|
+
print(f" Error processing {filename}: {e}")
|
|
83
|
+
|
|
84
|
+
print(f"\n=== Summary ===")
|
|
85
|
+
print(f"Files processed: {processed_files}")
|
|
86
|
+
print(f"Total policyId fields removed: {total_removals}")
|
|
87
|
+
|
|
88
|
+
if __name__ == "__main__":
|
|
89
|
+
process_mutation_policy_files()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|