catocli 2.1.0__py3-none-any.whl → 2.1.2__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 +217 -194
- catocli/Utils/version_checker.py +1 -1
- catocli/__init__.py +1 -1
- catocli/parsers/custom/customLib.py +1 -1
- catocli/parsers/custom/export_sites/export_sites.py +118 -130
- catocli/parsers/custom/import_rules_to_tf/import_rules_to_tf.py +13 -2
- catocli/parsers/custom/import_sites_to_tf/import_sites_to_tf.py +8 -1
- catocli/parsers/customParserApiClient.py +1195 -0
- catocli/parsers/custom_private/__init__.py +134 -0
- catocli/parsers/mutation_accountManagement/__init__.py +45 -58
- catocli/parsers/mutation_accountManagement_addAccount/README.md +7 -5
- catocli/parsers/mutation_accountManagement_removeAccount/README.md +4 -5
- catocli/parsers/mutation_accountManagement_updateAccount/README.md +7 -5
- catocli/parsers/mutation_admin/__init__.py +84 -45
- catocli/parsers/mutation_admin_addAdmin/README.md +7 -5
- catocli/parsers/mutation_admin_addServicePrincipalAdmin/README.md +19 -0
- catocli/parsers/mutation_admin_removeAdmin/README.md +7 -5
- catocli/parsers/mutation_admin_removeServicePrincipalAdmin/README.md +19 -0
- catocli/parsers/mutation_admin_updateAdmin/README.md +8 -6
- catocli/parsers/mutation_admin_updateServicePrincipalAdmin/README.md +20 -0
- catocli/parsers/mutation_container/__init__.py +135 -135
- catocli/parsers/mutation_container_delete/README.md +7 -5
- catocli/parsers/mutation_container_fqdn_addValues/README.md +7 -5
- catocli/parsers/mutation_container_fqdn_createFromFile/README.md +7 -5
- catocli/parsers/mutation_container_fqdn_removeValues/README.md +7 -5
- catocli/parsers/mutation_container_fqdn_updateFromFile/README.md +7 -5
- catocli/parsers/mutation_container_ipAddressRange_addValues/README.md +7 -5
- catocli/parsers/mutation_container_ipAddressRange_createFromFile/README.md +7 -5
- catocli/parsers/mutation_container_ipAddressRange_removeValues/README.md +7 -5
- catocli/parsers/mutation_container_ipAddressRange_updateFromFile/README.md +7 -5
- catocli/parsers/mutation_enterpriseDirectory/README.md +7 -0
- catocli/parsers/mutation_enterpriseDirectory/__init__.py +61 -0
- catocli/parsers/mutation_enterpriseDirectory_archiveLocation/README.md +19 -0
- catocli/parsers/mutation_enterpriseDirectory_createLocation/README.md +19 -0
- catocli/parsers/mutation_enterpriseDirectory_restoreLocation/README.md +19 -0
- catocli/parsers/mutation_enterpriseDirectory_updateLocation/README.md +19 -0
- catocli/parsers/mutation_groups/__init__.py +45 -45
- catocli/parsers/mutation_groups_createGroup/README.md +8 -6
- catocli/parsers/mutation_groups_deleteGroup/README.md +8 -6
- catocli/parsers/mutation_groups_updateGroup/README.md +8 -6
- catocli/parsers/mutation_hardware/__init__.py +16 -16
- catocli/parsers/mutation_hardware_updateHardwareShipping/README.md +7 -5
- catocli/parsers/mutation_policy/__init__.py +1302 -1302
- catocli/parsers/mutation_policy_appTenantRestriction_addRule/README.md +8 -6
- catocli/parsers/mutation_policy_appTenantRestriction_addSection/README.md +8 -6
- catocli/parsers/mutation_policy_appTenantRestriction_createPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_appTenantRestriction_discardPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_appTenantRestriction_moveRule/README.md +8 -6
- catocli/parsers/mutation_policy_appTenantRestriction_moveSection/README.md +8 -6
- catocli/parsers/mutation_policy_appTenantRestriction_publishPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_appTenantRestriction_removeRule/README.md +8 -6
- catocli/parsers/mutation_policy_appTenantRestriction_removeSection/README.md +8 -6
- catocli/parsers/mutation_policy_appTenantRestriction_updatePolicy/README.md +8 -6
- catocli/parsers/mutation_policy_appTenantRestriction_updateRule/README.md +8 -6
- catocli/parsers/mutation_policy_appTenantRestriction_updateSection/README.md +8 -6
- catocli/parsers/mutation_policy_dynamicIpAllocation_addRule/README.md +8 -6
- catocli/parsers/mutation_policy_dynamicIpAllocation_addSection/README.md +8 -6
- catocli/parsers/mutation_policy_dynamicIpAllocation_createPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_dynamicIpAllocation_discardPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_dynamicIpAllocation_moveRule/README.md +8 -6
- catocli/parsers/mutation_policy_dynamicIpAllocation_moveSection/README.md +8 -6
- catocli/parsers/mutation_policy_dynamicIpAllocation_publishPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_dynamicIpAllocation_removeRule/README.md +8 -6
- catocli/parsers/mutation_policy_dynamicIpAllocation_removeSection/README.md +8 -6
- catocli/parsers/mutation_policy_dynamicIpAllocation_updatePolicy/README.md +8 -6
- catocli/parsers/mutation_policy_dynamicIpAllocation_updateRule/README.md +8 -6
- catocli/parsers/mutation_policy_dynamicIpAllocation_updateSection/README.md +8 -6
- catocli/parsers/mutation_policy_internetFirewall_addRule/README.md +8 -6
- catocli/parsers/mutation_policy_internetFirewall_addSection/README.md +8 -6
- catocli/parsers/mutation_policy_internetFirewall_createPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_internetFirewall_discardPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_internetFirewall_moveRule/README.md +8 -6
- catocli/parsers/mutation_policy_internetFirewall_moveSection/README.md +8 -6
- catocli/parsers/mutation_policy_internetFirewall_publishPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_internetFirewall_removeRule/README.md +8 -6
- catocli/parsers/mutation_policy_internetFirewall_removeSection/README.md +8 -6
- catocli/parsers/mutation_policy_internetFirewall_updatePolicy/README.md +8 -6
- catocli/parsers/mutation_policy_internetFirewall_updateRule/README.md +8 -6
- catocli/parsers/mutation_policy_internetFirewall_updateSection/README.md +8 -6
- catocli/parsers/mutation_policy_remotePortFwd_addRule/README.md +8 -6
- catocli/parsers/mutation_policy_remotePortFwd_addSection/README.md +8 -6
- catocli/parsers/mutation_policy_remotePortFwd_createPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_remotePortFwd_discardPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_remotePortFwd_moveRule/README.md +8 -6
- catocli/parsers/mutation_policy_remotePortFwd_moveSection/README.md +8 -6
- catocli/parsers/mutation_policy_remotePortFwd_publishPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_remotePortFwd_removeRule/README.md +8 -6
- catocli/parsers/mutation_policy_remotePortFwd_removeSection/README.md +8 -6
- catocli/parsers/mutation_policy_remotePortFwd_updatePolicy/README.md +8 -6
- catocli/parsers/mutation_policy_remotePortFwd_updateRule/README.md +8 -6
- catocli/parsers/mutation_policy_remotePortFwd_updateSection/README.md +8 -6
- catocli/parsers/mutation_policy_socketLan_addRule/README.md +8 -6
- catocli/parsers/mutation_policy_socketLan_addSection/README.md +8 -6
- catocli/parsers/mutation_policy_socketLan_createPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_socketLan_discardPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_socketLan_moveRule/README.md +8 -6
- catocli/parsers/mutation_policy_socketLan_moveSection/README.md +8 -6
- catocli/parsers/mutation_policy_socketLan_publishPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_socketLan_removeRule/README.md +8 -6
- catocli/parsers/mutation_policy_socketLan_removeSection/README.md +8 -6
- catocli/parsers/mutation_policy_socketLan_updatePolicy/README.md +8 -6
- catocli/parsers/mutation_policy_socketLan_updateRule/README.md +8 -6
- catocli/parsers/mutation_policy_socketLan_updateSection/README.md +8 -6
- catocli/parsers/mutation_policy_terminalServer_addRule/README.md +8 -6
- catocli/parsers/mutation_policy_terminalServer_addSection/README.md +8 -6
- catocli/parsers/mutation_policy_terminalServer_createPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_terminalServer_discardPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_terminalServer_moveRule/README.md +8 -6
- catocli/parsers/mutation_policy_terminalServer_moveSection/README.md +8 -6
- catocli/parsers/mutation_policy_terminalServer_publishPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_terminalServer_removeRule/README.md +8 -6
- catocli/parsers/mutation_policy_terminalServer_removeSection/README.md +8 -6
- catocli/parsers/mutation_policy_terminalServer_updatePolicy/README.md +8 -6
- catocli/parsers/mutation_policy_terminalServer_updateRule/README.md +8 -6
- catocli/parsers/mutation_policy_terminalServer_updateSection/README.md +8 -6
- catocli/parsers/mutation_policy_wanFirewall_addRule/README.md +8 -6
- catocli/parsers/mutation_policy_wanFirewall_addSection/README.md +8 -6
- catocli/parsers/mutation_policy_wanFirewall_createPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_wanFirewall_discardPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_wanFirewall_moveRule/README.md +8 -6
- catocli/parsers/mutation_policy_wanFirewall_moveSection/README.md +8 -6
- catocli/parsers/mutation_policy_wanFirewall_publishPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_wanFirewall_removeRule/README.md +8 -6
- catocli/parsers/mutation_policy_wanFirewall_removeSection/README.md +8 -6
- catocli/parsers/mutation_policy_wanFirewall_updatePolicy/README.md +8 -6
- catocli/parsers/mutation_policy_wanFirewall_updateRule/README.md +8 -6
- catocli/parsers/mutation_policy_wanFirewall_updateSection/README.md +8 -6
- catocli/parsers/mutation_policy_wanNetwork_addRule/README.md +8 -6
- catocli/parsers/mutation_policy_wanNetwork_addSection/README.md +8 -6
- catocli/parsers/mutation_policy_wanNetwork_createPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_wanNetwork_discardPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_wanNetwork_moveRule/README.md +8 -6
- catocli/parsers/mutation_policy_wanNetwork_moveSection/README.md +8 -6
- catocli/parsers/mutation_policy_wanNetwork_publishPolicyRevision/README.md +8 -6
- catocli/parsers/mutation_policy_wanNetwork_removeRule/README.md +8 -6
- catocli/parsers/mutation_policy_wanNetwork_removeSection/README.md +8 -6
- catocli/parsers/mutation_policy_wanNetwork_updatePolicy/README.md +8 -6
- catocli/parsers/mutation_policy_wanNetwork_updateRule/README.md +8 -6
- catocli/parsers/mutation_policy_wanNetwork_updateSection/README.md +8 -6
- catocli/parsers/mutation_sandbox/__init__.py +27 -27
- catocli/parsers/mutation_sandbox_deleteReport/README.md +7 -5
- catocli/parsers/mutation_sandbox_uploadFile/README.md +7 -5
- catocli/parsers/mutation_site/__init__.py +474 -474
- catocli/parsers/mutation_site_addBgpPeer/README.md +7 -5
- catocli/parsers/mutation_site_addCloudInterconnectPhysicalConnection/README.md +7 -5
- catocli/parsers/mutation_site_addCloudInterconnectSite/README.md +7 -5
- catocli/parsers/mutation_site_addIpsecIkeV2Site/README.md +7 -5
- catocli/parsers/mutation_site_addIpsecIkeV2SiteTunnels/README.md +8 -6
- catocli/parsers/mutation_site_addNetworkRange/README.md +8 -6
- catocli/parsers/mutation_site_addSecondaryAwsVSocket/README.md +7 -5
- catocli/parsers/mutation_site_addSecondaryAzureVSocket/README.md +7 -5
- catocli/parsers/mutation_site_addSocketAddOnCard/README.md +7 -5
- catocli/parsers/mutation_site_addSocketSite/README.md +7 -5
- catocli/parsers/mutation_site_addStaticHost/README.md +8 -6
- catocli/parsers/mutation_site_assignSiteBwLicense/README.md +7 -5
- catocli/parsers/mutation_site_removeBgpPeer/README.md +7 -5
- catocli/parsers/mutation_site_removeCloudInterconnectPhysicalConnection/README.md +7 -5
- catocli/parsers/mutation_site_removeIpsecIkeV2SiteTunnels/README.md +8 -6
- catocli/parsers/mutation_site_removeNetworkRange/README.md +7 -5
- catocli/parsers/mutation_site_removeSecondaryAwsVSocket/README.md +7 -5
- catocli/parsers/mutation_site_removeSecondaryAzureVSocket/README.md +7 -5
- catocli/parsers/mutation_site_removeSite/README.md +7 -5
- catocli/parsers/mutation_site_removeSiteBwLicense/README.md +7 -5
- catocli/parsers/mutation_site_removeSocketAddOnCard/README.md +7 -5
- catocli/parsers/mutation_site_removeStaticHost/README.md +7 -5
- catocli/parsers/mutation_site_replaceSiteBwLicense/README.md +7 -5
- catocli/parsers/mutation_site_startSiteUpgrade/README.md +7 -5
- catocli/parsers/mutation_site_updateBgpPeer/README.md +7 -5
- catocli/parsers/mutation_site_updateCloudInterconnectPhysicalConnection/README.md +7 -5
- catocli/parsers/mutation_site_updateHa/README.md +8 -6
- catocli/parsers/mutation_site_updateIpsecIkeV2SiteGeneralDetails/README.md +8 -6
- catocli/parsers/mutation_site_updateIpsecIkeV2SiteTunnels/README.md +8 -6
- catocli/parsers/mutation_site_updateNetworkRange/README.md +8 -6
- catocli/parsers/mutation_site_updateSecondaryAwsVSocket/README.md +7 -5
- catocli/parsers/mutation_site_updateSecondaryAzureVSocket/README.md +7 -5
- catocli/parsers/mutation_site_updateSiteBwLicense/README.md +7 -5
- catocli/parsers/mutation_site_updateSiteGeneralDetails/README.md +8 -6
- catocli/parsers/mutation_site_updateSocketInterface/README.md +9 -7
- catocli/parsers/mutation_site_updateStaticHost/README.md +8 -6
- catocli/parsers/mutation_sites/__init__.py +474 -474
- catocli/parsers/mutation_sites_addBgpPeer/README.md +7 -5
- catocli/parsers/mutation_sites_addCloudInterconnectPhysicalConnection/README.md +7 -5
- catocli/parsers/mutation_sites_addCloudInterconnectSite/README.md +7 -5
- catocli/parsers/mutation_sites_addIpsecIkeV2Site/README.md +7 -5
- catocli/parsers/mutation_sites_addIpsecIkeV2SiteTunnels/README.md +8 -6
- catocli/parsers/mutation_sites_addNetworkRange/README.md +8 -6
- catocli/parsers/mutation_sites_addSecondaryAwsVSocket/README.md +7 -5
- catocli/parsers/mutation_sites_addSecondaryAzureVSocket/README.md +7 -5
- catocli/parsers/mutation_sites_addSocketAddOnCard/README.md +7 -5
- catocli/parsers/mutation_sites_addSocketSite/README.md +7 -5
- catocli/parsers/mutation_sites_addStaticHost/README.md +8 -6
- catocli/parsers/mutation_sites_assignSiteBwLicense/README.md +7 -5
- catocli/parsers/mutation_sites_removeBgpPeer/README.md +7 -5
- catocli/parsers/mutation_sites_removeCloudInterconnectPhysicalConnection/README.md +7 -5
- catocli/parsers/mutation_sites_removeIpsecIkeV2SiteTunnels/README.md +8 -6
- catocli/parsers/mutation_sites_removeNetworkRange/README.md +7 -5
- catocli/parsers/mutation_sites_removeSecondaryAwsVSocket/README.md +7 -5
- catocli/parsers/mutation_sites_removeSecondaryAzureVSocket/README.md +7 -5
- catocli/parsers/mutation_sites_removeSite/README.md +7 -5
- catocli/parsers/mutation_sites_removeSiteBwLicense/README.md +7 -5
- catocli/parsers/mutation_sites_removeSocketAddOnCard/README.md +7 -5
- catocli/parsers/mutation_sites_removeStaticHost/README.md +7 -5
- catocli/parsers/mutation_sites_replaceSiteBwLicense/README.md +7 -5
- catocli/parsers/mutation_sites_startSiteUpgrade/README.md +7 -5
- catocli/parsers/mutation_sites_updateBgpPeer/README.md +7 -5
- catocli/parsers/mutation_sites_updateCloudInterconnectPhysicalConnection/README.md +7 -5
- catocli/parsers/mutation_sites_updateHa/README.md +8 -6
- catocli/parsers/mutation_sites_updateIpsecIkeV2SiteGeneralDetails/README.md +8 -6
- catocli/parsers/mutation_sites_updateIpsecIkeV2SiteTunnels/README.md +8 -6
- catocli/parsers/mutation_sites_updateNetworkRange/README.md +8 -6
- catocli/parsers/mutation_sites_updateSecondaryAwsVSocket/README.md +7 -5
- catocli/parsers/mutation_sites_updateSecondaryAzureVSocket/README.md +7 -5
- catocli/parsers/mutation_sites_updateSiteBwLicense/README.md +7 -5
- catocli/parsers/mutation_sites_updateSiteGeneralDetails/README.md +8 -6
- catocli/parsers/mutation_sites_updateSocketInterface/README.md +9 -7
- catocli/parsers/mutation_sites_updateStaticHost/README.md +8 -6
- catocli/parsers/mutation_xdr/__init__.py +45 -45
- catocli/parsers/mutation_xdr_addStoryComment/README.md +7 -5
- catocli/parsers/mutation_xdr_analystFeedback/README.md +7 -6
- catocli/parsers/mutation_xdr_deleteStoryComment/README.md +7 -5
- catocli/parsers/query_accountBySubdomain/README.md +7 -5
- catocli/parsers/query_accountBySubdomain/__init__.py +12 -12
- catocli/parsers/query_accountManagement/README.md +4 -5
- catocli/parsers/query_accountManagement/__init__.py +12 -12
- catocli/parsers/query_accountMetrics/README.md +20 -18
- catocli/parsers/query_accountMetrics/__init__.py +12 -12
- catocli/parsers/query_accountRoles/README.md +7 -5
- catocli/parsers/query_accountRoles/__init__.py +12 -12
- catocli/parsers/query_accountSnapshot/README.md +8 -6
- catocli/parsers/query_accountSnapshot/__init__.py +12 -12
- catocli/parsers/query_admin/README.md +7 -5
- catocli/parsers/query_admin/__init__.py +12 -12
- catocli/parsers/query_admins/README.md +11 -9
- catocli/parsers/query_admins/__init__.py +12 -12
- catocli/parsers/query_appStats/README.md +20 -11
- catocli/parsers/query_appStats/__init__.py +12 -12
- catocli/parsers/query_appStatsTimeSeries/README.md +21 -12
- catocli/parsers/query_appStatsTimeSeries/__init__.py +12 -12
- catocli/parsers/query_auditFeed/README.md +10 -8
- catocli/parsers/query_auditFeed/__init__.py +12 -12
- catocli/parsers/query_catalogs/README.md +9 -7
- catocli/parsers/query_catalogs/__init__.py +12 -12
- catocli/parsers/query_container/README.md +13 -11
- catocli/parsers/query_container/__init__.py +12 -12
- catocli/parsers/query_devices/README.md +10 -8
- catocli/parsers/query_devices/__init__.py +12 -12
- catocli/parsers/query_enterpriseDirectory/README.md +19 -0
- catocli/parsers/query_enterpriseDirectory/__init__.py +16 -0
- catocli/parsers/query_entityLookup/README.md +19 -17
- catocli/parsers/query_entityLookup/__init__.py +12 -12
- catocli/parsers/query_events/README.md +13 -11
- catocli/parsers/query_events/__init__.py +12 -12
- catocli/parsers/query_eventsFeed/README.md +9 -7
- catocli/parsers/query_eventsFeed/__init__.py +12 -12
- catocli/parsers/query_eventsTimeSeries/README.md +14 -12
- catocli/parsers/query_eventsTimeSeries/__init__.py +12 -12
- catocli/parsers/query_groups/__init__.py +51 -51
- catocli/parsers/query_groups_groupList/README.md +8 -6
- catocli/parsers/query_groups_group_members/README.md +8 -6
- catocli/parsers/query_groups_whereUsed/README.md +7 -5
- catocli/parsers/query_hardware/README.md +7 -5
- catocli/parsers/query_hardware/__init__.py +12 -12
- catocli/parsers/query_hardwareManagement/README.md +7 -5
- catocli/parsers/query_hardwareManagement/__init__.py +12 -12
- catocli/parsers/query_licensing/README.md +4 -5
- catocli/parsers/query_licensing/__init__.py +12 -12
- catocli/parsers/query_policy/__init__.py +158 -158
- catocli/parsers/query_policy_appTenantRestriction_policy/README.md +7 -5
- catocli/parsers/query_policy_dynamicIpAllocation_policy/README.md +7 -5
- catocli/parsers/query_policy_internetFirewall_policy/README.md +7 -5
- catocli/parsers/query_policy_remotePortFwd_policy/README.md +7 -5
- catocli/parsers/query_policy_socketLan_policy/README.md +7 -5
- catocli/parsers/query_policy_terminalServer_policy/README.md +7 -5
- catocli/parsers/query_policy_wanFirewall_policy/README.md +7 -5
- catocli/parsers/query_policy_wanNetwork_policy/README.md +7 -5
- catocli/parsers/query_popLocations/README.md +7 -5
- catocli/parsers/query_popLocations/__init__.py +12 -12
- catocli/parsers/query_sandbox/README.md +7 -5
- catocli/parsers/query_sandbox/__init__.py +12 -12
- catocli/parsers/query_servicePrincipalAdmin/README.md +19 -0
- catocli/parsers/query_servicePrincipalAdmin/__init__.py +16 -0
- catocli/parsers/query_site/__init__.py +123 -123
- catocli/parsers/query_siteLocation/__init__.py +10 -10
- catocli/parsers/query_site_availableVersionList/README.md +7 -5
- catocli/parsers/query_site_bgpPeer/README.md +7 -5
- catocli/parsers/query_site_bgpPeerList/README.md +7 -5
- catocli/parsers/query_site_cloudInterconnectConnectionConnectivity/README.md +7 -5
- catocli/parsers/query_site_cloudInterconnectPhysicalConnection/README.md +7 -5
- catocli/parsers/query_site_cloudInterconnectPhysicalConnectionId/README.md +7 -5
- catocli/parsers/query_site_secondaryAwsVSocket/README.md +7 -5
- catocli/parsers/query_site_secondaryAzureVSocket/README.md +7 -5
- catocli/parsers/query_site_siteBgpStatus/README.md +7 -5
- catocli/parsers/query_socketPortMetrics/README.md +13 -11
- catocli/parsers/query_socketPortMetrics/__init__.py +12 -12
- catocli/parsers/query_socketPortMetricsTimeSeries/README.md +14 -12
- catocli/parsers/query_socketPortMetricsTimeSeries/__init__.py +12 -12
- catocli/parsers/query_subDomains/README.md +7 -5
- catocli/parsers/query_subDomains/__init__.py +12 -12
- catocli/parsers/query_xdr/__init__.py +27 -27
- catocli/parsers/query_xdr_stories/README.md +7 -6
- catocli/parsers/query_xdr_story/README.md +9 -8
- catocli/parsers/raw/__init__.py +9 -9
- {catocli-2.1.0.dist-info → catocli-2.1.2.dist-info}/METADATA +1 -1
- catocli-2.1.2.dist-info/RECORD +659 -0
- graphql_client/api/call_api.py +20 -2
- models/mutation.accountManagement.addAccount.json +5 -15
- models/mutation.accountManagement.updateAccount.json +1 -3
- models/mutation.admin.addAdmin.json +14 -35
- models/mutation.admin.addServicePrincipalAdmin.json +2554 -0
- models/mutation.admin.removeAdmin.json +1 -1
- models/mutation.admin.removeServicePrincipalAdmin.json +201 -0
- models/mutation.admin.updateAdmin.json +13 -30
- models/mutation.admin.updateServicePrincipalAdmin.json +2554 -0
- models/mutation.container.delete.json +9 -435
- models/mutation.container.fqdn.addValues.json +6 -11
- models/mutation.container.fqdn.createFromFile.json +4 -12
- models/mutation.container.fqdn.removeValues.json +6 -11
- models/mutation.container.fqdn.updateFromFile.json +5 -15
- models/mutation.container.ipAddressRange.addValues.json +4 -12
- models/mutation.container.ipAddressRange.createFromFile.json +4 -12
- models/mutation.container.ipAddressRange.removeValues.json +4 -12
- models/mutation.container.ipAddressRange.updateFromFile.json +5 -15
- models/mutation.enterpriseDirectory.archiveLocation.json +1046 -0
- models/mutation.enterpriseDirectory.createLocation.json +2521 -0
- models/mutation.enterpriseDirectory.restoreLocation.json +1046 -0
- models/mutation.enterpriseDirectory.updateLocation.json +2567 -0
- models/mutation.groups.createGroup.json +39 -171
- models/mutation.groups.deleteGroup.json +36 -162
- models/mutation.groups.updateGroup.json +41 -177
- models/mutation.hardware.updateHardwareShipping.json +18 -47
- models/mutation.policy.appTenantRestriction.addRule.json +50 -136
- models/mutation.policy.appTenantRestriction.addSection.json +4 -12
- models/mutation.policy.appTenantRestriction.createPolicyRevision.json +3 -9
- models/mutation.policy.appTenantRestriction.discardPolicyRevision.json +2 -6
- models/mutation.policy.appTenantRestriction.moveRule.json +4 -12
- models/mutation.policy.appTenantRestriction.moveSection.json +4 -12
- models/mutation.policy.appTenantRestriction.publishPolicyRevision.json +3 -9
- models/mutation.policy.appTenantRestriction.removeRule.json +2 -6
- models/mutation.policy.appTenantRestriction.removeSection.json +2 -6
- models/mutation.policy.appTenantRestriction.updatePolicy.json +2 -6
- models/mutation.policy.appTenantRestriction.updateRule.json +49 -133
- models/mutation.policy.appTenantRestriction.updateSection.json +3 -9
- models/mutation.policy.dynamicIpAllocation.addRule.json +15 -45
- models/mutation.policy.dynamicIpAllocation.addSection.json +4 -12
- models/mutation.policy.dynamicIpAllocation.createPolicyRevision.json +3 -9
- models/mutation.policy.dynamicIpAllocation.discardPolicyRevision.json +2 -6
- models/mutation.policy.dynamicIpAllocation.moveRule.json +4 -12
- models/mutation.policy.dynamicIpAllocation.moveSection.json +4 -12
- models/mutation.policy.dynamicIpAllocation.publishPolicyRevision.json +3 -9
- models/mutation.policy.dynamicIpAllocation.removeRule.json +2 -6
- models/mutation.policy.dynamicIpAllocation.removeSection.json +2 -6
- models/mutation.policy.dynamicIpAllocation.updatePolicy.json +2 -6
- models/mutation.policy.dynamicIpAllocation.updateRule.json +14 -42
- models/mutation.policy.dynamicIpAllocation.updateSection.json +3 -9
- models/mutation.policy.internetFirewall.addRule.json +248 -542
- models/mutation.policy.internetFirewall.addSection.json +4 -12
- models/mutation.policy.internetFirewall.createPolicyRevision.json +3 -9
- models/mutation.policy.internetFirewall.discardPolicyRevision.json +2 -6
- models/mutation.policy.internetFirewall.moveRule.json +4 -12
- models/mutation.policy.internetFirewall.moveSection.json +4 -12
- models/mutation.policy.internetFirewall.publishPolicyRevision.json +3 -9
- models/mutation.policy.internetFirewall.removeRule.json +2 -6
- models/mutation.policy.internetFirewall.removeSection.json +2 -6
- models/mutation.policy.internetFirewall.updatePolicy.json +2 -6
- models/mutation.policy.internetFirewall.updateRule.json +247 -539
- models/mutation.policy.internetFirewall.updateSection.json +3 -9
- models/mutation.policy.remotePortFwd.addRule.json +35 -91
- models/mutation.policy.remotePortFwd.addSection.json +4 -12
- models/mutation.policy.remotePortFwd.createPolicyRevision.json +3 -9
- models/mutation.policy.remotePortFwd.discardPolicyRevision.json +2 -6
- models/mutation.policy.remotePortFwd.moveRule.json +4 -12
- models/mutation.policy.remotePortFwd.moveSection.json +4 -12
- models/mutation.policy.remotePortFwd.publishPolicyRevision.json +3 -9
- models/mutation.policy.remotePortFwd.removeRule.json +2 -6
- models/mutation.policy.remotePortFwd.removeSection.json +2 -6
- models/mutation.policy.remotePortFwd.updatePolicy.json +2 -6
- models/mutation.policy.remotePortFwd.updateRule.json +34 -88
- models/mutation.policy.remotePortFwd.updateSection.json +3 -9
- models/mutation.policy.socketLan.addRule.json +78 -185
- models/mutation.policy.socketLan.addSection.json +4 -12
- models/mutation.policy.socketLan.createPolicyRevision.json +3 -9
- models/mutation.policy.socketLan.discardPolicyRevision.json +2 -6
- models/mutation.policy.socketLan.moveRule.json +4 -12
- models/mutation.policy.socketLan.moveSection.json +4 -12
- models/mutation.policy.socketLan.publishPolicyRevision.json +3 -9
- models/mutation.policy.socketLan.removeRule.json +2 -6
- models/mutation.policy.socketLan.removeSection.json +2 -6
- models/mutation.policy.socketLan.updatePolicy.json +2 -6
- models/mutation.policy.socketLan.updateRule.json +77 -182
- models/mutation.policy.socketLan.updateSection.json +3 -9
- models/mutation.policy.terminalServer.addRule.json +10 -30
- models/mutation.policy.terminalServer.addSection.json +4 -12
- models/mutation.policy.terminalServer.createPolicyRevision.json +3 -9
- models/mutation.policy.terminalServer.discardPolicyRevision.json +2 -6
- models/mutation.policy.terminalServer.moveRule.json +4 -12
- models/mutation.policy.terminalServer.moveSection.json +4 -12
- models/mutation.policy.terminalServer.publishPolicyRevision.json +3 -9
- models/mutation.policy.terminalServer.removeRule.json +2 -6
- models/mutation.policy.terminalServer.removeSection.json +2 -6
- models/mutation.policy.terminalServer.updatePolicy.json +2 -6
- models/mutation.policy.terminalServer.updateRule.json +9 -27
- models/mutation.policy.terminalServer.updateSection.json +3 -9
- models/mutation.policy.wanFirewall.addRule.json +290 -654
- models/mutation.policy.wanFirewall.addSection.json +4 -12
- models/mutation.policy.wanFirewall.createPolicyRevision.json +3 -9
- models/mutation.policy.wanFirewall.discardPolicyRevision.json +2 -6
- models/mutation.policy.wanFirewall.moveRule.json +4 -12
- models/mutation.policy.wanFirewall.moveSection.json +4 -12
- models/mutation.policy.wanFirewall.publishPolicyRevision.json +3 -9
- models/mutation.policy.wanFirewall.removeRule.json +2 -6
- models/mutation.policy.wanFirewall.removeSection.json +2 -6
- models/mutation.policy.wanFirewall.updatePolicy.json +2 -6
- models/mutation.policy.wanFirewall.updateRule.json +289 -651
- models/mutation.policy.wanFirewall.updateSection.json +3 -9
- models/mutation.policy.wanNetwork.addRule.json +204 -514
- models/mutation.policy.wanNetwork.addSection.json +4 -12
- models/mutation.policy.wanNetwork.createPolicyRevision.json +3 -9
- models/mutation.policy.wanNetwork.discardPolicyRevision.json +2 -6
- models/mutation.policy.wanNetwork.moveRule.json +4 -12
- models/mutation.policy.wanNetwork.moveSection.json +4 -12
- models/mutation.policy.wanNetwork.publishPolicyRevision.json +3 -9
- models/mutation.policy.wanNetwork.removeRule.json +2 -6
- models/mutation.policy.wanNetwork.removeSection.json +2 -6
- models/mutation.policy.wanNetwork.updatePolicy.json +2 -6
- models/mutation.policy.wanNetwork.updateRule.json +203 -511
- models/mutation.policy.wanNetwork.updateSection.json +3 -9
- models/mutation.sandbox.deleteReport.json +1 -3
- models/mutation.sandbox.uploadFile.json +1 -3
- models/mutation.site.addBgpPeer.json +48 -123
- models/mutation.site.addCloudInterconnectPhysicalConnection.json +12 -36
- models/mutation.site.addCloudInterconnectSite.json +8 -24
- models/mutation.site.addIpsecIkeV2Site.json +10 -30
- models/mutation.site.addIpsecIkeV2SiteTunnels.json +14 -40
- models/mutation.site.addNetworkRange.json +15 -43
- models/mutation.site.addSecondaryAwsVSocket.json +5 -15
- models/mutation.site.addSecondaryAzureVSocket.json +4 -12
- models/mutation.site.addSocketAddOnCard.json +4 -12
- models/mutation.site.addSocketSite.json +12 -36
- models/mutation.site.addStaticHost.json +4 -10
- models/mutation.site.assignSiteBwLicense.json +120 -11782
- models/mutation.site.removeBgpPeer.json +1 -3
- models/mutation.site.removeCloudInterconnectPhysicalConnection.json +1 -3
- models/mutation.site.removeIpsecIkeV2SiteTunnels.json +2 -4
- models/mutation.site.removeNetworkRange.json +1 -1
- models/mutation.site.removeSecondaryAwsVSocket.json +1 -1
- models/mutation.site.removeSecondaryAzureVSocket.json +1 -1
- models/mutation.site.removeSite.json +1 -1
- models/mutation.site.removeSiteBwLicense.json +119 -11779
- models/mutation.site.removeSocketAddOnCard.json +3 -9
- models/mutation.site.removeStaticHost.json +1 -1
- models/mutation.site.replaceSiteBwLicense.json +121 -11785
- models/mutation.site.startSiteUpgrade.json +3 -9
- models/mutation.site.updateBgpPeer.json +47 -120
- models/mutation.site.updateCloudInterconnectPhysicalConnection.json +10 -30
- models/mutation.site.updateHa.json +4 -10
- models/mutation.site.updateIpsecIkeV2SiteGeneralDetails.json +11 -24
- models/mutation.site.updateIpsecIkeV2SiteTunnels.json +15 -43
- models/mutation.site.updateNetworkRange.json +15 -43
- models/mutation.site.updateSecondaryAwsVSocket.json +4 -12
- models/mutation.site.updateSecondaryAzureVSocket.json +3 -9
- models/mutation.site.updateSiteBwLicense.json +120 -11782
- models/mutation.site.updateSiteGeneralDetails.json +14 -40
- models/mutation.site.updateSocketInterface.json +26 -74
- models/mutation.site.updateStaticHost.json +4 -10
- models/mutation.sites.addBgpPeer.json +48 -123
- models/mutation.sites.addCloudInterconnectPhysicalConnection.json +12 -36
- models/mutation.sites.addCloudInterconnectSite.json +8 -24
- models/mutation.sites.addIpsecIkeV2Site.json +10 -30
- models/mutation.sites.addIpsecIkeV2SiteTunnels.json +14 -40
- models/mutation.sites.addNetworkRange.json +15 -43
- models/mutation.sites.addSecondaryAwsVSocket.json +5 -15
- models/mutation.sites.addSecondaryAzureVSocket.json +4 -12
- models/mutation.sites.addSocketAddOnCard.json +4 -12
- models/mutation.sites.addSocketSite.json +12 -36
- models/mutation.sites.addStaticHost.json +4 -10
- models/mutation.sites.assignSiteBwLicense.json +120 -11782
- models/mutation.sites.removeBgpPeer.json +1 -3
- models/mutation.sites.removeCloudInterconnectPhysicalConnection.json +1 -3
- models/mutation.sites.removeIpsecIkeV2SiteTunnels.json +2 -4
- models/mutation.sites.removeNetworkRange.json +1 -1
- models/mutation.sites.removeSecondaryAwsVSocket.json +1 -1
- models/mutation.sites.removeSecondaryAzureVSocket.json +1 -1
- models/mutation.sites.removeSite.json +1 -1
- models/mutation.sites.removeSiteBwLicense.json +119 -11779
- models/mutation.sites.removeSocketAddOnCard.json +3 -9
- models/mutation.sites.removeStaticHost.json +1 -1
- models/mutation.sites.replaceSiteBwLicense.json +121 -11785
- models/mutation.sites.startSiteUpgrade.json +3 -9
- models/mutation.sites.updateBgpPeer.json +47 -120
- models/mutation.sites.updateCloudInterconnectPhysicalConnection.json +10 -30
- models/mutation.sites.updateHa.json +4 -10
- models/mutation.sites.updateIpsecIkeV2SiteGeneralDetails.json +11 -24
- models/mutation.sites.updateIpsecIkeV2SiteTunnels.json +15 -43
- models/mutation.sites.updateNetworkRange.json +15 -43
- models/mutation.sites.updateSecondaryAwsVSocket.json +4 -12
- models/mutation.sites.updateSecondaryAzureVSocket.json +3 -9
- models/mutation.sites.updateSiteBwLicense.json +120 -11782
- models/mutation.sites.updateSiteGeneralDetails.json +14 -40
- models/mutation.sites.updateSocketInterface.json +26 -74
- models/mutation.sites.updateStaticHost.json +4 -10
- models/mutation.xdr.addStoryComment.json +15 -113
- models/mutation.xdr.analystFeedback.json +229 -26307
- models/mutation.xdr.deleteStoryComment.json +15 -113
- models/query.accountBySubdomain.json +2 -1
- models/query.accountMetrics.json +15 -12
- models/query.accountRoles.json +1 -1
- models/query.accountSnapshot.json +4 -2
- models/query.admin.json +1 -1
- models/query.admins.json +7 -10
- models/query.appStats.json +633 -33
- models/query.appStatsTimeSeries.json +15 -28
- models/query.auditFeed.json +225 -16
- models/query.catalogs.json +106 -215
- models/query.container.json +21 -471
- models/query.devices.json +333 -620
- models/query.enterpriseDirectory.json +3596 -0
- models/query.entityLookup.json +15 -27
- models/query.events.json +1875 -33
- models/query.eventsFeed.json +30 -14
- models/query.eventsTimeSeries.json +15 -28
- models/query.groups.group.members.json +23 -55
- models/query.groups.groupList.json +87 -266
- models/query.groups.whereUsed.json +2 -6
- models/query.hardware.json +92 -192
- models/query.hardwareManagement.json +21 -63
- models/query.licensing.json +76 -11721
- models/query.policy.appTenantRestriction.policy.json +2 -6
- models/query.policy.dynamicIpAllocation.policy.json +2 -6
- models/query.policy.internetFirewall.policy.json +2 -6
- models/query.policy.remotePortFwd.policy.json +2 -6
- models/query.policy.socketLan.policy.json +2 -6
- models/query.policy.terminalServer.policy.json +2 -6
- models/query.policy.wanFirewall.policy.json +2 -6
- models/query.policy.wanNetwork.policy.json +2 -6
- models/query.popLocations.json +34 -74
- models/query.sandbox.json +44 -83
- models/query.servicePrincipalAdmin.json +1098 -0
- models/query.site.availableVersionList.json +4 -5
- models/query.site.bgpPeer.json +2 -6
- models/query.site.bgpPeerList.json +2 -6
- models/query.site.cloudInterconnectConnectionConnectivity.json +1 -3
- models/query.site.cloudInterconnectPhysicalConnection.json +1 -3
- models/query.site.cloudInterconnectPhysicalConnectionId.json +3 -9
- models/query.site.secondaryAwsVSocket.json +1 -1
- models/query.site.secondaryAzureVSocket.json +1 -1
- models/query.site.siteBgpStatus.json +2 -6
- models/query.socketPortMetrics.json +465 -33
- models/query.socketPortMetricsTimeSeries.json +15 -28
- models/query.subDomains.json +1 -1
- models/query.xdr.stories.json +306 -26440
- models/query.xdr.story.json +40 -26100
- schema/catolib.py +1266 -956
- schema/importSchema.py +53 -48
- catocli/parsers/mutation/README.md +0 -4
- catocli/parsers/mutation_accountManagement_disableAccount/README.md +0 -16
- catocli/parsers/parserApiClient.py +0 -522
- catocli/parsers/query/README.md +0 -3
- catocli-2.1.0.dist-info/RECORD +0 -644
- models/mutation.accountManagement.disableAccount.json +0 -545
- models/query.policy.json +0 -40899
- models/query.site.json +0 -5688
- schema/remove_policyid.py +0 -89
- schema/remove_policyid_mutations.py +0 -89
- {catocli-2.1.0.dist-info → catocli-2.1.2.dist-info}/WHEEL +0 -0
- {catocli-2.1.0.dist-info → catocli-2.1.2.dist-info}/entry_points.txt +0 -0
- {catocli-2.1.0.dist-info → catocli-2.1.2.dist-info}/licenses/LICENSE +0 -0
- {catocli-2.1.0.dist-info → catocli-2.1.2.dist-info}/top_level.txt +0 -0
schema/importSchema.py
CHANGED
|
@@ -2,59 +2,64 @@
|
|
|
2
2
|
import catolib
|
|
3
3
|
import logging
|
|
4
4
|
import json
|
|
5
|
+
import concurrent.futures
|
|
6
|
+
import threading
|
|
7
|
+
import sys
|
|
5
8
|
|
|
6
9
|
############ ENV Settings ############
|
|
7
10
|
logging.basicConfig(filename="download-schema.log", filemode='w', format='%(name)s - %(levelname)s - %(message)s')
|
|
8
11
|
options = catolib.initParser()
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
# ## Uncomment this secion to build cli as one continuous job
|
|
13
|
-
# ##################################################################
|
|
14
|
-
# query = {
|
|
15
|
-
# 'query':'query IntrospectionQuery { __schema { description } }',
|
|
16
|
-
# 'operationName':'IntrospectionQuery'
|
|
17
|
-
# }
|
|
18
|
-
# success,introspection = catolib.send(options.api_key,query)
|
|
19
|
-
# catolib.parseSchema(introspection)
|
|
20
|
-
# catolib.writeCliDriver(catolib.catoApiSchema)
|
|
21
|
-
# catolib.writeOperationParsers(catolib.catoApiSchema)
|
|
22
|
-
# catolib.writeReadmes(catolib.catoApiSchema)
|
|
23
|
-
# ##################################################################
|
|
24
|
-
|
|
25
|
-
######################### OPTION 2 ##############################
|
|
26
|
-
## Uncomment to manually run each step manually writing files locally
|
|
27
|
-
######################### Step 1 ################################
|
|
28
|
-
## Run intrpsection to pull down schema and write locally
|
|
29
|
-
#################################################################
|
|
30
|
-
query = {
|
|
31
|
-
'query':'query IntrospectionQuery { __schema { description } }',
|
|
32
|
-
'operationName':'IntrospectionQuery'
|
|
33
|
-
}
|
|
34
|
-
success,resp = catolib.send(options.api_key,query)
|
|
35
|
-
catolib.writeFile("introspection.json",json.dumps(resp, indent=4, sort_keys=True))
|
|
36
|
-
# #################################################################
|
|
37
|
-
|
|
38
|
-
######################### Step 2 ################################
|
|
39
|
-
## Load from introsspeection from local file, and
|
|
40
|
-
## use catolib to parse the schema, write locally
|
|
41
|
-
## to catoApiIntrospection.json and catoApiSchema.json
|
|
42
|
-
#################################################################
|
|
43
|
-
introspection = catolib.loadJSON("introspection.json")
|
|
44
|
-
catolib.parseSchema(introspection)
|
|
45
|
-
catolib.writeFile("catoApiIntrospection.json",json.dumps(catolib.catoApiIntrospection, indent=4, sort_keys=True))
|
|
46
|
-
catolib.writeFile("catoApiSchema.json",json.dumps(catolib.catoApiSchema, indent=4, sort_keys=True))
|
|
47
|
-
#################################################################
|
|
13
|
+
# Increase recursion limit for complex schemas
|
|
14
|
+
sys.setrecursionlimit(5000)
|
|
48
15
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
16
|
+
def run():
|
|
17
|
+
print("Starting continuous multi-threaded schema processing...")
|
|
18
|
+
|
|
19
|
+
######################### CONTINUOUS BUILD PROCESS ##############################
|
|
20
|
+
## Single continuous process - download, parse, and generate all in one flow
|
|
21
|
+
print("Downloading and processing GraphQL schema...")
|
|
22
|
+
|
|
23
|
+
# Step 1: Download schema with introspection query
|
|
24
|
+
query = {
|
|
25
|
+
'query': 'query IntrospectionQuery { __schema { description } }',
|
|
26
|
+
'operationName': 'IntrospectionQuery'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
success, introspection = catolib.send(options.api_key, query)
|
|
30
|
+
if not success:
|
|
31
|
+
print("ERROR: Failed to download schema")
|
|
32
|
+
return
|
|
33
|
+
|
|
34
|
+
print("• Schema downloaded successfully")
|
|
35
|
+
|
|
36
|
+
# Step 2: Parse schema using multi-threading
|
|
37
|
+
print("• Parsing schema with multi-threading...")
|
|
38
|
+
catolib.parseSchema(introspection)
|
|
39
|
+
print("• Schema parsed successfully")
|
|
40
|
+
|
|
41
|
+
# Step 3: Generate all CLI components
|
|
42
|
+
print("• Generating CLI components...")
|
|
43
|
+
catolib.writeCliDriver(catolib.catoApiSchema)
|
|
44
|
+
print("• CLI driver generated")
|
|
45
|
+
|
|
46
|
+
catolib.writeOperationParsers(catolib.catoApiSchema)
|
|
47
|
+
print("• Operation parsers generated")
|
|
48
|
+
|
|
49
|
+
catolib.writeReadmes(catolib.catoApiSchema)
|
|
50
|
+
print("• README files generated")
|
|
51
|
+
|
|
52
|
+
# Save the processed schema files for reference
|
|
53
|
+
catolib.writeFile("catoApiIntrospection.json", json.dumps(catolib.catoApiIntrospection, indent=4, sort_keys=True))
|
|
54
|
+
catolib.writeFile("catoApiSchema.json", json.dumps(catolib.catoApiSchema, indent=4, sort_keys=True))
|
|
55
|
+
catolib.writeFile("introspection.json", json.dumps(introspection, indent=4, sort_keys=True))
|
|
56
|
+
print("• Schema files saved")
|
|
57
|
+
|
|
58
|
+
total_operations = len(catolib.catoApiSchema["query"]) + len(catolib.catoApiSchema["mutation"])
|
|
59
|
+
print(f"\n- Continuous build completed successfully!")
|
|
60
|
+
print(f" - Total operations generated: {total_operations}")
|
|
61
|
+
print(f" - Query operations: {len(catolib.catoApiSchema['query'])}")
|
|
62
|
+
print(f" - Mutation operations: {len(catolib.catoApiSchema['mutation'])}")
|
|
58
63
|
|
|
59
64
|
if __name__ == '__main__':
|
|
60
|
-
|
|
65
|
+
run()
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
## CATO-CLI - mutation.accountManagement.disableAccount:
|
|
3
|
-
[Click here](https://api.catonetworks.com/documentation/#mutation-disableAccount) for documentation on this operation.
|
|
4
|
-
|
|
5
|
-
### Usage for mutation.accountManagement.disableAccount:
|
|
6
|
-
|
|
7
|
-
`catocli mutation accountManagement disableAccount -h`
|
|
8
|
-
|
|
9
|
-
`catocli mutation accountManagement disableAccount <json>`
|
|
10
|
-
|
|
11
|
-
`catocli mutation accountManagement disableAccount "$(cat < disableAccount.json)"`
|
|
12
|
-
|
|
13
|
-
`catocli mutation accountManagement disableAccount '{}'`
|
|
14
|
-
|
|
15
|
-
#### Operation Arguments for mutation.accountManagement.disableAccount ####
|
|
16
|
-
`accountId` [ID] - (required) N/A
|
|
@@ -1,522 +0,0 @@
|
|
|
1
|
-
import codecs
|
|
2
|
-
import json
|
|
3
|
-
import os
|
|
4
|
-
import sys
|
|
5
|
-
from graphql_client import ApiClient, CallApi
|
|
6
|
-
from graphql_client.api_client import ApiException
|
|
7
|
-
import logging
|
|
8
|
-
import pprint
|
|
9
|
-
import uuid
|
|
10
|
-
from urllib3.filepost import encode_multipart_formdata
|
|
11
|
-
|
|
12
|
-
def createRequest(args, configuration):
|
|
13
|
-
params = vars(args)
|
|
14
|
-
instance = CallApi(ApiClient(configuration))
|
|
15
|
-
operationName = params["operation_name"]
|
|
16
|
-
operation = loadJSON("models/"+operationName+".json")
|
|
17
|
-
variablesObj = {}
|
|
18
|
-
if params["json"] and not params["t"]:
|
|
19
|
-
try:
|
|
20
|
-
variablesObj = json.loads(params["json"])
|
|
21
|
-
except ValueError as e:
|
|
22
|
-
print("ERROR: Query argument must be valid json in quotes. ",e,'\n\nExample: \'{"yourKey":"yourValue"}\'')
|
|
23
|
-
exit()
|
|
24
|
-
elif not params["t"] and params["json"] is None:
|
|
25
|
-
# Default to empty object if no json provided and not using -t flag
|
|
26
|
-
variablesObj = {}
|
|
27
|
-
if "accountId" in operation["args"]:
|
|
28
|
-
variablesObj["accountId"] = configuration.accountID
|
|
29
|
-
else:
|
|
30
|
-
variablesObj["accountID"] = configuration.accountID
|
|
31
|
-
if params["t"]==True:
|
|
32
|
-
# Skip validation when using -t flag
|
|
33
|
-
isOk = True
|
|
34
|
-
else:
|
|
35
|
-
isOk, invalidVars, message = validateArgs(variablesObj,operation)
|
|
36
|
-
if isOk==True:
|
|
37
|
-
body = generateGraphqlPayload(variablesObj,operation,operationName)
|
|
38
|
-
if params["t"]==True:
|
|
39
|
-
# Load query from queryPayloads file
|
|
40
|
-
try:
|
|
41
|
-
queryPayloadFile = "queryPayloads/" + operationName + ".json"
|
|
42
|
-
queryPayload = loadJSON(queryPayloadFile)
|
|
43
|
-
if queryPayload and "query" in queryPayload:
|
|
44
|
-
print(queryPayload["query"])
|
|
45
|
-
else:
|
|
46
|
-
print("ERROR: Query not found in " + queryPayloadFile)
|
|
47
|
-
except Exception as e:
|
|
48
|
-
print("ERROR: Could not load query from " + queryPayloadFile + ": " + str(e))
|
|
49
|
-
return None
|
|
50
|
-
else:
|
|
51
|
-
try:
|
|
52
|
-
return instance.call_api(body,params)
|
|
53
|
-
except ApiException as e:
|
|
54
|
-
return e
|
|
55
|
-
else:
|
|
56
|
-
print("ERROR: "+message,", ".join(invalidVars))
|
|
57
|
-
try:
|
|
58
|
-
queryPayloadFile = "queryPayloads/" + operationName + ".json"
|
|
59
|
-
queryPayload = loadJSON(queryPayloadFile)
|
|
60
|
-
print("\nExample: catocli "+operationName.replace(".", " "), json.dumps(queryPayload['variables']))
|
|
61
|
-
except Exception as e:
|
|
62
|
-
print("ERROR: Could not load query from " + queryPayloadFile + ": " + str(e))
|
|
63
|
-
|
|
64
|
-
def querySiteLocation(args, configuration):
|
|
65
|
-
params = vars(args)
|
|
66
|
-
operationName = params["operation_name"]
|
|
67
|
-
operation = loadJSON("models/"+operationName+".json")
|
|
68
|
-
try:
|
|
69
|
-
variablesObj = json.loads(params["json"])
|
|
70
|
-
except ValueError as e:
|
|
71
|
-
print("ERROR: Query argument must be valid json in quotes. ",e,'\n\nExample: \'{"filters":[{"search": "Your city here","field":"city","opeation":"exact"}}\'')
|
|
72
|
-
exit()
|
|
73
|
-
if not variablesObj.get("filters"):
|
|
74
|
-
print("ERROR: Missing argument, must include filters array. ",e,'\n\nExample: \'{"filters":[{"search": "Your city here","field":"city","opeation":"exact"}}\'')
|
|
75
|
-
exit()
|
|
76
|
-
if not isinstance(variablesObj.get("filters"), list):
|
|
77
|
-
print("ERROR: Invalid argument, must include filters array. ",e,'\n\nExample: \'{"filters":[{"search": "Your city here","field":"city","opeation":"exact"}}\'')
|
|
78
|
-
exit()
|
|
79
|
-
requiredFields = ["search","field","operation"]
|
|
80
|
-
for filter in variablesObj["filters"]:
|
|
81
|
-
if not isinstance(filter, dict):
|
|
82
|
-
print("ERROR: Invalid filter '"+str(filter)+"', filters must be valid json and include 'search', 'field', and 'operation'. ",'\n\nExample: \'{"filters":[{"search": "Your city here","field":"city","opeation":"exact"}}\'',type(filter))
|
|
83
|
-
exit()
|
|
84
|
-
for param in filter:
|
|
85
|
-
if param not in requiredFields:
|
|
86
|
-
print("ERROR: Invalid field '"+param+"', filters must include 'search', 'field', and 'operation'. ",'\n\nExample: \'{"filters":[{"search": "Your city here","field":"city","opeation":"exact"}}\'')
|
|
87
|
-
exit()
|
|
88
|
-
for filter in variablesObj["filters"]:
|
|
89
|
-
for param in filter:
|
|
90
|
-
val = filter.get(param)
|
|
91
|
-
if param=="search" and (not isinstance(val, str) or len(val)<3):
|
|
92
|
-
print("ERROR: Invalid search '"+val+"', must be a string value and at least 3 characters in lengh. ",'\n\nExample: \'{"filters":[{"search": "Your city here","field":"city","opeation":"exact"}}\'')
|
|
93
|
-
exit()
|
|
94
|
-
if param=="field" and (not isinstance(val, str) or val not in [ 'countryName', 'stateName', 'city']):
|
|
95
|
-
print("ERROR: Invalid field '"+val+"', must be one of the following: 'countryName', 'stateName', or 'city'.",'\n\nExample: \'{"search":"your query here","field":"city"}\'')
|
|
96
|
-
exit()
|
|
97
|
-
if param=="operation" and (not isinstance(val, str) or val not in [ 'startsWith', 'endsWith', 'exact', 'contains' ]):
|
|
98
|
-
print("ERROR: Invalid operation '"+val+"', must be one of the following: 'startsWith', 'endsWith', 'exact', 'contains'.",'\n\nExample: \'{"search": "Your search here","field":"city","operation":"exact"}\'')
|
|
99
|
-
exit()
|
|
100
|
-
response = {"data":[]}
|
|
101
|
-
for key, siteObj in operation.items():
|
|
102
|
-
isOk = True
|
|
103
|
-
for filter in variablesObj["filters"]:
|
|
104
|
-
search = filter.get("search")
|
|
105
|
-
field = filter.get("field")
|
|
106
|
-
operation = filter.get("operation")
|
|
107
|
-
if field in siteObj:
|
|
108
|
-
if operation=="startsWith" and not siteObj[field].startswith(search):
|
|
109
|
-
isOk = False
|
|
110
|
-
break
|
|
111
|
-
elif operation=="endsWith" and not siteObj[field].endswith(search):
|
|
112
|
-
isOk = False
|
|
113
|
-
break
|
|
114
|
-
elif operation=="exact" and not siteObj[field]==search:
|
|
115
|
-
isOk = False
|
|
116
|
-
break
|
|
117
|
-
elif operation=="contains" and not search in siteObj[field]:
|
|
118
|
-
isOk = False
|
|
119
|
-
break
|
|
120
|
-
else:
|
|
121
|
-
isOk = False
|
|
122
|
-
break
|
|
123
|
-
if isOk==False:
|
|
124
|
-
break
|
|
125
|
-
if isOk==True:
|
|
126
|
-
response["data"].append(siteObj)
|
|
127
|
-
if params["p"]==True:
|
|
128
|
-
responseStr = json.dumps(response,indent=2,sort_keys=True,ensure_ascii=False).encode('utf8')
|
|
129
|
-
print(responseStr.decode())
|
|
130
|
-
else:
|
|
131
|
-
responseStr = json.dumps(response,ensure_ascii=False).encode('utf8')
|
|
132
|
-
print(responseStr.decode())
|
|
133
|
-
|
|
134
|
-
def createRawRequest(args, configuration):
|
|
135
|
-
params = vars(args)
|
|
136
|
-
# Handle endpoint override
|
|
137
|
-
if hasattr(args, 'endpoint') and args.endpoint:
|
|
138
|
-
configuration.host = args.endpoint
|
|
139
|
-
|
|
140
|
-
# Check if binary/multipart mode is enabled
|
|
141
|
-
if hasattr(args, 'binary') and args.binary:
|
|
142
|
-
return createRawBinaryRequest(args, configuration)
|
|
143
|
-
|
|
144
|
-
instance = CallApi(ApiClient(configuration))
|
|
145
|
-
isOk = False
|
|
146
|
-
try:
|
|
147
|
-
body = json.loads(params["json"])
|
|
148
|
-
isOk = True
|
|
149
|
-
except ValueError as e:
|
|
150
|
-
print("ERROR: Argument must be valid json. ",e)
|
|
151
|
-
isOk=False
|
|
152
|
-
except Exception as e:
|
|
153
|
-
isOk=False
|
|
154
|
-
print("ERROR: ",e)
|
|
155
|
-
if isOk==True:
|
|
156
|
-
if params["t"]==True:
|
|
157
|
-
if params["p"]==True:
|
|
158
|
-
print(json.dumps(body,indent=2,sort_keys=True).replace("\\n", "\n").replace("\\t", "\t"))
|
|
159
|
-
else:
|
|
160
|
-
print(json.dumps(body).replace("\\n", " ").replace("\\t", " ").replace(" "," ").replace(" "," "))
|
|
161
|
-
return None
|
|
162
|
-
else:
|
|
163
|
-
try:
|
|
164
|
-
return instance.call_api(body,params)
|
|
165
|
-
except ApiException as e:
|
|
166
|
-
print(e)
|
|
167
|
-
exit()
|
|
168
|
-
|
|
169
|
-
def generateGraphqlPayload(variablesObj,operation,operationName):
|
|
170
|
-
indent = " "
|
|
171
|
-
queryStr = ""
|
|
172
|
-
variableStr = ""
|
|
173
|
-
for varName in variablesObj:
|
|
174
|
-
if (varName in operation["operationArgs"]):
|
|
175
|
-
variableStr += operation["operationArgs"][varName]["requestStr"]
|
|
176
|
-
operationAry = operationName.split(".")
|
|
177
|
-
operationType = operationAry.pop(0)
|
|
178
|
-
queryStr = operationType + " "
|
|
179
|
-
queryStr += renderCamelCase(".".join(operationAry))
|
|
180
|
-
queryStr += " ( " + variableStr + ") {\n"
|
|
181
|
-
queryStr += indent + operation["name"] + " ( "
|
|
182
|
-
for argName in operation["args"]:
|
|
183
|
-
arg = operation["args"][argName]
|
|
184
|
-
if arg["varName"] in variablesObj:
|
|
185
|
-
queryStr += arg["responseStr"]
|
|
186
|
-
queryStr += ") {\n" + renderArgsAndFields("", variablesObj, operation, operation["type"]["definition"], " ") + " }"
|
|
187
|
-
queryStr += indent + "\n}";
|
|
188
|
-
body = {
|
|
189
|
-
"query":queryStr,
|
|
190
|
-
"variables":variablesObj,
|
|
191
|
-
"operationName":renderCamelCase(".".join(operationAry)),
|
|
192
|
-
}
|
|
193
|
-
return body
|
|
194
|
-
|
|
195
|
-
def get_help(path):
|
|
196
|
-
matchCmd = "catocli "+path.replace("_"," ")
|
|
197
|
-
import os
|
|
198
|
-
pwd = os.path.dirname(__file__)
|
|
199
|
-
doc = path+"/README.md"
|
|
200
|
-
abs_path = os.path.join(pwd, doc)
|
|
201
|
-
new_line = "\nEXAMPLES:\n"
|
|
202
|
-
lines = open(abs_path, "r").readlines()
|
|
203
|
-
for line in lines:
|
|
204
|
-
if f"{matchCmd}" in line:
|
|
205
|
-
clean_line = line.replace("<br /><br />", "").replace("`","")
|
|
206
|
-
new_line += f"{clean_line}\n"
|
|
207
|
-
# matchArg = path.replace("_",".")
|
|
208
|
-
# for line in lines:
|
|
209
|
-
# if f"`{matchArg}" in line:
|
|
210
|
-
# clean_line = line.replace("<br /><br />", "").replace("`","")
|
|
211
|
-
# new_line += f"{clean_line}\n"
|
|
212
|
-
return new_line
|
|
213
|
-
|
|
214
|
-
def validateArgs(variablesObj,operation):
|
|
215
|
-
isOk = True
|
|
216
|
-
invalidVars = []
|
|
217
|
-
message = "Arguments are missing or have invalid values: "
|
|
218
|
-
for varName in variablesObj:
|
|
219
|
-
if varName not in operation["operationArgs"]:
|
|
220
|
-
isOk = False
|
|
221
|
-
invalidVars.append('"'+varName+'"')
|
|
222
|
-
message = "Invalid argument names. Looking for: "+", ".join(list(operation["operationArgs"].keys()))
|
|
223
|
-
|
|
224
|
-
if isOk==True:
|
|
225
|
-
for varName in operation["operationArgs"]:
|
|
226
|
-
if operation["operationArgs"][varName]["required"] and varName not in variablesObj:
|
|
227
|
-
isOk = False
|
|
228
|
-
invalidVars.append('"'+varName+'"')
|
|
229
|
-
else:
|
|
230
|
-
if varName in variablesObj:
|
|
231
|
-
value = variablesObj[varName]
|
|
232
|
-
if operation["operationArgs"][varName]["required"] and value=="":
|
|
233
|
-
isOk = False
|
|
234
|
-
invalidVars.append('"'+varName+'":"'+str(value)+'"')
|
|
235
|
-
return isOk, invalidVars, message
|
|
236
|
-
|
|
237
|
-
def loadJSON(file):
|
|
238
|
-
CONFIG = {}
|
|
239
|
-
module_dir = os.path.dirname(__file__)
|
|
240
|
-
# Navigate up two directory levels (from parsers/ to catocli/ to root)
|
|
241
|
-
module_dir = os.path.dirname(module_dir) # Go up from parsers/
|
|
242
|
-
module_dir = os.path.dirname(module_dir) # Go up from catocli/
|
|
243
|
-
try:
|
|
244
|
-
file_path = os.path.join(module_dir, file)
|
|
245
|
-
with open(file_path, 'r') as data:
|
|
246
|
-
CONFIG = json.load(data)
|
|
247
|
-
return CONFIG
|
|
248
|
-
except:
|
|
249
|
-
logging.warning(f"File \"{os.path.join(module_dir, file)}\" not found.")
|
|
250
|
-
exit()
|
|
251
|
-
|
|
252
|
-
def renderCamelCase(pathStr):
|
|
253
|
-
str = ""
|
|
254
|
-
pathAry = pathStr.split(".")
|
|
255
|
-
for i, path in enumerate(pathAry):
|
|
256
|
-
if i == 0:
|
|
257
|
-
str += path[0].lower() + path[1:]
|
|
258
|
-
else:
|
|
259
|
-
str += path[0].upper() + path[1:]
|
|
260
|
-
return str
|
|
261
|
-
|
|
262
|
-
def renderArgsAndFields(responseArgStr, variablesObj, curOperation, definition, indent):
|
|
263
|
-
for fieldName in definition['fields']:
|
|
264
|
-
field = definition['fields'][fieldName]
|
|
265
|
-
field_name = field['alias'] if 'alias' in field else field['name']
|
|
266
|
-
|
|
267
|
-
# Check if field has arguments and whether they are present in variables
|
|
268
|
-
should_include_field = True
|
|
269
|
-
argsPresent = False
|
|
270
|
-
argStr = ""
|
|
271
|
-
|
|
272
|
-
if field.get("args") and not isinstance(field['args'], list):
|
|
273
|
-
if (len(list(field['args'].keys()))>0):
|
|
274
|
-
# Field has arguments - only include if arguments are present in variables
|
|
275
|
-
argStr = " ( "
|
|
276
|
-
for argName in field['args']:
|
|
277
|
-
arg = field['args'][argName]
|
|
278
|
-
if arg["varName"] in variablesObj:
|
|
279
|
-
argStr += arg['responseStr'] + " "
|
|
280
|
-
argsPresent = True
|
|
281
|
-
argStr += ") "
|
|
282
|
-
# Only include fields with arguments if the arguments are present
|
|
283
|
-
should_include_field = argsPresent
|
|
284
|
-
|
|
285
|
-
# Only process field if we should include it
|
|
286
|
-
if should_include_field:
|
|
287
|
-
responseArgStr += indent + field_name
|
|
288
|
-
if argsPresent:
|
|
289
|
-
responseArgStr += argStr
|
|
290
|
-
|
|
291
|
-
if should_include_field and field.get("type") and field['type'].get('definition') and field['type']['definition']['fields'] is not None:
|
|
292
|
-
responseArgStr += " {\n"
|
|
293
|
-
for subfieldIndex in field['type']['definition']['fields']:
|
|
294
|
-
subfield = field['type']['definition']['fields'][subfieldIndex]
|
|
295
|
-
# Use the alias if it exists, otherwise use the field name
|
|
296
|
-
subfield_name = subfield['alias'] if 'alias' in subfield else subfield['name']
|
|
297
|
-
responseArgStr += indent + " " + subfield_name
|
|
298
|
-
if subfield.get("args") and len(list(subfield["args"].keys()))>0:
|
|
299
|
-
argsPresent = False
|
|
300
|
-
subArgStr = " ( "
|
|
301
|
-
for argName in subfield['args']:
|
|
302
|
-
arg = subfield['args'][argName]
|
|
303
|
-
if arg["varName"] in variablesObj:
|
|
304
|
-
argsPresent = True
|
|
305
|
-
subArgStr += arg['responseStr'] + " "
|
|
306
|
-
subArgStr += " )"
|
|
307
|
-
if argsPresent==True:
|
|
308
|
-
responseArgStr += subArgStr
|
|
309
|
-
if subfield.get("type") and subfield['type'].get("definition") and (subfield['type']['definition'].get("fields") or subfield['type']['definition'].get('inputFields')):
|
|
310
|
-
responseArgStr += " {\n"
|
|
311
|
-
responseArgStr = renderArgsAndFields(responseArgStr, variablesObj, curOperation, subfield['type']['definition'], indent + " ")
|
|
312
|
-
if subfield['type']['definition'].get('possibleTypes'):
|
|
313
|
-
for possibleTypeName in subfield['type']['definition']['possibleTypes']:
|
|
314
|
-
possibleType = subfield['type']['definition']['possibleTypes'][possibleTypeName]
|
|
315
|
-
responseArgStr += indent + " ... on " + possibleType['name'] + " {\n"
|
|
316
|
-
if possibleType.get('fields') or possibleType.get('inputFields'):
|
|
317
|
-
responseArgStr = renderArgsAndFields(responseArgStr, variablesObj, curOperation, possibleType, indent + " ")
|
|
318
|
-
responseArgStr += indent + " }\n"
|
|
319
|
-
responseArgStr += indent + " }"
|
|
320
|
-
elif subfield.get('type') and subfield['type'].get('definition') and subfield['type']['definition'].get('possibleTypes'):
|
|
321
|
-
responseArgStr += " {\n"
|
|
322
|
-
responseArgStr += indent + " __typename\n"
|
|
323
|
-
for possibleTypeName in subfield['type']['definition']['possibleTypes']:
|
|
324
|
-
possibleType = subfield['type']['definition']['possibleTypes'][possibleTypeName]
|
|
325
|
-
responseArgStr += indent + " ... on " + possibleType['name'] + " {\n"
|
|
326
|
-
if possibleType.get('fields') or possibleType.get('inputFields'):
|
|
327
|
-
responseArgStr = renderArgsAndFields(responseArgStr, variablesObj, curOperation, possibleType, indent + " ")
|
|
328
|
-
responseArgStr += indent + " }\n"
|
|
329
|
-
responseArgStr += indent + " }\n"
|
|
330
|
-
responseArgStr += "\n"
|
|
331
|
-
if field['type']['definition'].get('possibleTypes'):
|
|
332
|
-
for possibleTypeName in field['type']['definition']['possibleTypes']:
|
|
333
|
-
possibleType = field['type']['definition']['possibleTypes'][possibleTypeName]
|
|
334
|
-
responseArgStr += indent + " ... on " + possibleType['name'] + " {\n"
|
|
335
|
-
if possibleType.get('fields') or possibleType.get('inputFields'):
|
|
336
|
-
responseArgStr = renderArgsAndFields(responseArgStr, variablesObj, curOperation, possibleType, indent + " ")
|
|
337
|
-
responseArgStr += indent + " }\n"
|
|
338
|
-
responseArgStr += indent + "}\n"
|
|
339
|
-
if should_include_field and field.get('type') and field['type'].get('definition') and field['type']['definition'].get('inputFields'):
|
|
340
|
-
responseArgStr += " {\n"
|
|
341
|
-
for subfieldName in field['type']['definition'].get('inputFields'):
|
|
342
|
-
subfield = field['type']['definition']['inputFields'][subfieldName]
|
|
343
|
-
# Updated aliasing logic for inputFields
|
|
344
|
-
if (subfield.get('type') and subfield['type'].get('name') and
|
|
345
|
-
curOperation.get('fieldTypes', {}).get(subfield['type']['name']) and
|
|
346
|
-
subfield.get('type', {}).get('kind') and
|
|
347
|
-
'SCALAR' not in str(subfield['type']['kind'])):
|
|
348
|
-
subfield_name = f"{subfield['name']}{field['type']['definition']['name']}: {subfield['name']}"
|
|
349
|
-
else:
|
|
350
|
-
subfield_name = subfield['name'] # Always use the raw field name, not incorrect aliases
|
|
351
|
-
responseArgStr += indent + " " + subfield_name
|
|
352
|
-
if subfield.get('type') and subfield['type'].get('definition') and (subfield['type']['definition'].get('fields') or subfield['type']['definition'].get('inputFields')):
|
|
353
|
-
responseArgStr += " {\n"
|
|
354
|
-
responseArgStr = renderArgsAndFields(responseArgStr, variablesObj, curOperation, subfield['type']['definition'], indent + " ")
|
|
355
|
-
responseArgStr += indent + " }\n"
|
|
356
|
-
if field['type']['definition'].get('possibleTypes'):
|
|
357
|
-
for possibleTypeName in field['type']['definition']['possibleTypes']:
|
|
358
|
-
possibleType = field['type']['definition']['possibleTypes'][possibleTypeName]
|
|
359
|
-
responseArgStr += indent + "... on " + possibleType['name'] + " {\n"
|
|
360
|
-
if possibleType.get('fields') or possibleType.get('inputFields'):
|
|
361
|
-
responseArgStr = renderArgsAndFields(responseArgStr, variablesObj, curOperation, possibleType, indent + " ")
|
|
362
|
-
responseArgStr += indent + " }\n"
|
|
363
|
-
responseArgStr += indent + "}\n"
|
|
364
|
-
if should_include_field:
|
|
365
|
-
responseArgStr += "\n"
|
|
366
|
-
return responseArgStr
|
|
367
|
-
|
|
368
|
-
def createRawBinaryRequest(args, configuration):
|
|
369
|
-
"""Handle multipart/form-data requests for file uploads and binary content"""
|
|
370
|
-
params = vars(args)
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
# Parse the JSON body
|
|
374
|
-
try:
|
|
375
|
-
body = json.loads(params["json"])
|
|
376
|
-
except ValueError as e:
|
|
377
|
-
print("ERROR: JSON argument must be valid json. ", e)
|
|
378
|
-
return
|
|
379
|
-
except Exception as e:
|
|
380
|
-
print("ERROR: ", e)
|
|
381
|
-
return
|
|
382
|
-
|
|
383
|
-
# Build form data
|
|
384
|
-
form_fields = {}
|
|
385
|
-
files = []
|
|
386
|
-
|
|
387
|
-
# Add the operations field containing the GraphQL payload
|
|
388
|
-
form_fields['operations'] = json.dumps(body)
|
|
389
|
-
|
|
390
|
-
# Handle file mappings if files are specified
|
|
391
|
-
if hasattr(args, 'files') and args.files:
|
|
392
|
-
# Build the map object for file uploads
|
|
393
|
-
file_map = {}
|
|
394
|
-
for i, (field_name, file_path) in enumerate(args.files):
|
|
395
|
-
file_index = str(i + 1)
|
|
396
|
-
file_map[file_index] = [field_name]
|
|
397
|
-
|
|
398
|
-
# Read file content
|
|
399
|
-
try:
|
|
400
|
-
with open(file_path, 'rb') as f:
|
|
401
|
-
file_content = f.read()
|
|
402
|
-
files.append((file_index, (os.path.basename(file_path), file_content, 'application/octet-stream')))
|
|
403
|
-
except IOError as e:
|
|
404
|
-
print(f"ERROR: Could not read file {file_path}: {e}")
|
|
405
|
-
return
|
|
406
|
-
|
|
407
|
-
# Add the map field
|
|
408
|
-
form_fields['map'] = json.dumps(file_map)
|
|
409
|
-
|
|
410
|
-
# Test mode - just print the request structure
|
|
411
|
-
if params.get("t") == True:
|
|
412
|
-
print("Multipart form data request:")
|
|
413
|
-
if params.get("p") == True:
|
|
414
|
-
print(f"Operations: {json.dumps(json.loads(form_fields.get('operations')), indent=2)}")
|
|
415
|
-
else:
|
|
416
|
-
print(f"Operations: {form_fields.get('operations')}")
|
|
417
|
-
if 'map' in form_fields:
|
|
418
|
-
print(f"Map: {form_fields.get('map')}")
|
|
419
|
-
if files:
|
|
420
|
-
print(f"Files: {[f[0] + ': ' + f[1][0] for f in files]}")
|
|
421
|
-
return None
|
|
422
|
-
|
|
423
|
-
# Perform the multipart request
|
|
424
|
-
try:
|
|
425
|
-
return sendMultipartRequest(configuration, form_fields, files, params)
|
|
426
|
-
except Exception as e:
|
|
427
|
-
# Safely handle exception string conversion
|
|
428
|
-
try:
|
|
429
|
-
error_str = str(e)
|
|
430
|
-
except Exception:
|
|
431
|
-
error_str = f"Exception of type {type(e).__name__}"
|
|
432
|
-
|
|
433
|
-
if params.get("v") == True:
|
|
434
|
-
import traceback
|
|
435
|
-
print(f"ERROR: Failed to send multipart request: {error_str}")
|
|
436
|
-
traceback.print_exc()
|
|
437
|
-
else:
|
|
438
|
-
print(f"ERROR: Failed to send multipart request: {error_str}")
|
|
439
|
-
return None
|
|
440
|
-
|
|
441
|
-
def sendMultipartRequest(configuration, form_fields, files, params):
|
|
442
|
-
"""Send a multipart/form-data request directly using urllib3"""
|
|
443
|
-
import urllib3
|
|
444
|
-
|
|
445
|
-
# Create pool manager
|
|
446
|
-
pool_manager = urllib3.PoolManager(
|
|
447
|
-
cert_reqs='CERT_NONE' if not getattr(configuration, 'verify_ssl', False) else 'CERT_REQUIRED'
|
|
448
|
-
)
|
|
449
|
-
|
|
450
|
-
# Prepare form data
|
|
451
|
-
fields = []
|
|
452
|
-
for key, value in form_fields.items():
|
|
453
|
-
fields.append((key, value))
|
|
454
|
-
|
|
455
|
-
for file_key, (filename, content, content_type) in files:
|
|
456
|
-
fields.append((file_key, (filename, content, content_type)))
|
|
457
|
-
|
|
458
|
-
# Encode multipart data
|
|
459
|
-
body_data, content_type = encode_multipart_formdata(fields)
|
|
460
|
-
|
|
461
|
-
# Prepare headers
|
|
462
|
-
headers = {
|
|
463
|
-
'Content-Type': content_type,
|
|
464
|
-
'User-Agent': f"Cato-CLI-v{getattr(configuration, 'version', 'unknown')}"
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
# Add API key if not using headers file or custom headers
|
|
468
|
-
using_custom_headers = hasattr(configuration, 'custom_headers') and configuration.custom_headers
|
|
469
|
-
if not using_custom_headers and hasattr(configuration, 'api_key') and hasattr(configuration, 'api_key') and configuration.api_key and 'x-api-key' in configuration.api_key:
|
|
470
|
-
headers['x-api-key'] = configuration.api_key['x-api-key']
|
|
471
|
-
|
|
472
|
-
# Add custom headers
|
|
473
|
-
if using_custom_headers:
|
|
474
|
-
headers.update(configuration.custom_headers)
|
|
475
|
-
|
|
476
|
-
# Verbose output
|
|
477
|
-
if params.get("v") == True:
|
|
478
|
-
print(f"Host: {getattr(configuration, 'host', 'unknown')}")
|
|
479
|
-
masked_headers = headers.copy()
|
|
480
|
-
if 'x-api-key' in masked_headers:
|
|
481
|
-
masked_headers['x-api-key'] = '***MASKED***'
|
|
482
|
-
print(f"Request Headers: {json.dumps(masked_headers, indent=4, sort_keys=True)}")
|
|
483
|
-
print(f"Content-Type: {content_type}")
|
|
484
|
-
print(f"Form fields: {list(form_fields.keys())}")
|
|
485
|
-
print(f"Files: {[f[0] for f in files]}\n")
|
|
486
|
-
|
|
487
|
-
try:
|
|
488
|
-
# Make the request
|
|
489
|
-
resp = pool_manager.request(
|
|
490
|
-
'POST',
|
|
491
|
-
getattr(configuration, 'host', 'https://api.catonetworks.com/api/v1/graphql'),
|
|
492
|
-
body=body_data,
|
|
493
|
-
headers=headers
|
|
494
|
-
)
|
|
495
|
-
|
|
496
|
-
# Parse response
|
|
497
|
-
if resp.status < 200 or resp.status >= 300:
|
|
498
|
-
reason = resp.reason if resp.reason is not None else "Unknown Error"
|
|
499
|
-
error_msg = f"HTTP {resp.status}: {reason}"
|
|
500
|
-
if resp.data:
|
|
501
|
-
try:
|
|
502
|
-
error_msg += f"\n{resp.data.decode('utf-8')}"
|
|
503
|
-
except Exception:
|
|
504
|
-
error_msg += f"\n{resp.data}"
|
|
505
|
-
print(f"ERROR: {error_msg}")
|
|
506
|
-
return None
|
|
507
|
-
|
|
508
|
-
try:
|
|
509
|
-
response_data = json.loads(resp.data.decode('utf-8'))
|
|
510
|
-
except json.JSONDecodeError:
|
|
511
|
-
response_data = resp.data.decode('utf-8')
|
|
512
|
-
|
|
513
|
-
return [response_data]
|
|
514
|
-
|
|
515
|
-
except Exception as e:
|
|
516
|
-
# Safely handle exception string conversion
|
|
517
|
-
try:
|
|
518
|
-
error_str = str(e)
|
|
519
|
-
except Exception:
|
|
520
|
-
error_str = f"Exception of type {type(e).__name__}"
|
|
521
|
-
print(f"ERROR: Network/request error: {error_str}")
|
|
522
|
-
return None
|
catocli/parsers/query/README.md
DELETED