diff --git a/README.md b/README.md index edebb46..4674e26 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,15 @@ VARIABLE | REQUIRED | TYPE | DESCRIPTION [remove group user](#action-remove-group-user) - Remove user from group [get whitelist](#action-get-whitelist) - get urls on the allow list [get blacklist](#action-get-blacklist) - get urls on the deny list +[update user](#action-update-user) - Update user with given id +[add category url](#action-add-category-url) - Add urls to a cetgory +[add category ip](#action-add-category-ip) - Add IPs to a cetgory +[remove category url](#action-remove-category-url) - Add urls to a cetgory +[remove category ip](#action-remove-category-ip) - Remove IPs to a cetgory +[create destination group](#action-create-destination-group) - Create destination group +[list destination group](#action-list-destination-group) - List destination group +[edit destination group](#action-edit-destination-group) - Edit destination group +[delete destination group](#action-delete-destination-group) - Delete destination group ## action: 'test connectivity' Validate the asset configuration for connectivity using supplied configuration @@ -187,12 +196,15 @@ Type: **investigate** Read only: **True** #### Action Parameters -No parameters are required for this action +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**get_ids_and_names_only** | optional | Whether to retrieve only a list containing URL category IDs and names. Even if displayURL is set to true, URLs will not be returned | boolean | #### Action Output DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES --------- | ---- | -------- | -------------- action_result.status | string | | test success test failed +action_result.parameter.get_ids_and_names_only | string | | RADIO_STATIONS action_result.data.\*.configuredName | string | | test Test-Caution action_result.data.\*.customCategory | boolean | | True False action_result.data.\*.customIpRangesCount | numeric | | 0 @@ -790,4 +802,350 @@ action_result.data.\*.blacklistUrl | string | | action_result.summary.message | string | | Blacklist retrieved action_result.summary.total_blacklist_items | numeric | | 10 summary.total_objects | numeric | | 1 +summary.total_objects_successful | numeric | | 1 + +## action: 'update user' +Update user with given id + +Type: **correct** +Read only: **False** + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**user_id** | required | ZScaler User Id | numeric | `zscaler user id` +**user** | optional | JSON object containing the user details (see https://help.zscaler.com/zia/user-management#/users/{userId}-put) | string | + +#### Action Output +DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES +--------- | ---- | -------- | -------------- +action_result.status | string | | test success test failed +action_result.parameter.user | string | | +action_result.parameter.user_id | numeric | `zscaler user id` | 889814 +action_result.data.\*.adminUser | boolean | | True False +action_result.data.\*.comments | string | | test This is test user +action_result.data.\*.deleted | boolean | | True False +action_result.data.\*.department.id | numeric | | 81896690 +action_result.data.\*.department.name | string | | test IT +action_result.data.\*.email | string | `email` | test first.last@domain.com +action_result.data.\*.groups.\*.id | numeric | `zscaler group id` | 8894813 +action_result.data.\*.groups.\*.name | string | | test Super Admin +action_result.data.\*.id | numeric | `zscaler user id` | 889814 +action_result.data.\*.name | string | | test First Last +action_result.summary | string | | +action_result.summary.message | string | | test User removed from group +action_result.message | string | | test User removed from group +summary.message | string | | +summary.total_objects | numeric | | 1 +summary.total_objects_successful | numeric | | 1 + +## action: 'add category url' +Add urls to a cetgory + +Type: **generic** +Read only: **False** + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**category_id** | required | The ID of the category to add the specified URLs to | string | +**urls** | optional | A comma-separated list of URLs to add to the specified category | string | +**retaining-parent-category-url** | optional | A comma-separated list of URLs to add to the retaining parent category section inside the specified category | string | + +#### Action Output +DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES +--------- | ---- | -------- | -------------- +action_result.status | string | | success failed +action_result.parameter.category_id | string | | RADIO_STATIONS +action_result.parameter.urls | string | | +action_result.parameter.retaining-parent-category-url | string | | +action_result.data.\*.id | string | | +action_result.data.\*.val | numeric | | +action_result.data.\*.type | string | | +action_result.data.\*.urls | string | | +action_result.data.\*.scopes.\*.Type | string | | +action_result.data.\*.editable | boolean | | +action_result.data.\*.keywords | string | | +action_result.data.\*.description | string | | +action_result.data.\*.configuredName | string | | +action_result.data.\*.customCategory | boolean | | +action_result.data.\*.customUrlsCount | numeric | | +action_result.data.\*.dbCategorizedUrls | string | | +action_result.data.\*.customIpRangesCount | numeric | | +action_result.data.\*.keywordsRetainingParentCategory | string | | +action_result.data.\*.urlsRetainingParentCategoryCount | numeric | | +action_result.data.\*.ipRangesRetainingParentCategoryCount | numeric | | +action_result.message | string | | Message: Category urs updated +action_result.summary | string | | +summary.total_objects | numeric | | 1 +summary.total_objects_successful | numeric | | 1 + +## action: 'add category ip' +Add IPs to a cetgory + +Type: **generic** +Read only: **False** + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**category_id** | required | The ID of the category to add the specified URLs to | string | +**ips** | optional | A comma-separated list of IP addresses to add to the specified category | string | +**retaining-parent-category-ip** | optional | A comma-separated list of IPs to add to the retaining parent category section inside the specified category | string | + +#### Action Output +DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES +--------- | ---- | -------- | -------------- +action_result.status | string | | success failed +action_result.parameter.category_id | string | | RADIO_STATIONS +action_result.parameter.ips | string | | +action_result.parameter.retaining-parent-category-ip | string | | +action_result.data.\*.id | string | | +action_result.data.\*.val | numeric | | +action_result.data.\*.type | string | | +action_result.data.\*.urls | string | | +action_result.data.\*.scopes.\*.Type | string | | +action_result.data.\*.editable | boolean | | +action_result.data.\*.keywords | string | | +action_result.data.\*.description | string | | +action_result.data.\*.configuredName | string | | +action_result.data.\*.customCategory | boolean | | +action_result.data.\*.customUrlsCount | numeric | | +action_result.data.\*.dbCategorizedUrls | string | | +action_result.data.\*.customIpRangesCount | numeric | | +action_result.data.\*.keywordsRetainingParentCategory | string | | +action_result.data.\*.urlsRetainingParentCategoryCount | numeric | | +action_result.data.\*.ipRangesRetainingParentCategoryCount | numeric | | +action_result.message | string | | Message: Category ips updated +action_result.summary | string | | +summary.total_objects | numeric | | 1 +summary.total_objects_successful | numeric | | 1 + +## action: 'remove category url' +Add urls to a cetgory + +Type: **generic** +Read only: **False** + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**category_id** | required | The ID of the category to add the specified URLs to | string | +**urls** | optional | A comma-separated list of URLs to remove from the specified category | string | +**retaining-parent-category-url** | optional | A comma-separated list of URLs to remove from the retaining parent category section inside the specified category | string | + +#### Action Output +DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES +--------- | ---- | -------- | -------------- +action_result.status | string | | success failed +action_result.parameter.category_id | string | | RADIO_STATIONS +action_result.parameter.urls | string | | +action_result.parameter.retaining-parent-category-url | string | | +action_result.data.\*.id | string | | +action_result.data.\*.val | numeric | | +action_result.data.\*.type | string | | +action_result.data.\*.urls | string | | +action_result.data.\*.scopes.\*.Type | string | | +action_result.data.\*.editable | boolean | | +action_result.data.\*.keywords | string | | +action_result.data.\*.description | string | | +action_result.data.\*.configuredName | string | | +action_result.data.\*.customCategory | boolean | | +action_result.data.\*.customUrlsCount | numeric | | +action_result.data.\*.dbCategorizedUrls | string | | +action_result.data.\*.customIpRangesCount | numeric | | +action_result.data.\*.keywordsRetainingParentCategory | string | | +action_result.data.\*.urlsRetainingParentCategoryCount | numeric | | +action_result.data.\*.ipRangesRetainingParentCategoryCount | numeric | | +action_result.message | string | | Message: Category urls removed +action_result.summary | string | | +summary.total_objects | numeric | | 1 +summary.total_objects_successful | numeric | | 1 + +## action: 'remove category ip' +Remove IPs to a cetgory + +Type: **generic** +Read only: **False** + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**category_id** | required | The ID of the category to add the specified URLs to | string | +**ips** | optional | A comma-separated list of IP addresses to add to the specified category | string | +**retaining-parent-category-ip** | optional | A comma-separated list of IPs to add to the retaining parent category section inside the specified category | string | + +#### Action Output +DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES +--------- | ---- | -------- | -------------- +action_result.status | string | | success failed +action_result.parameter.category_id | string | | RADIO_STATIONS +action_result.parameter.ips | string | | +action_result.parameter.retaining-parent-category-ip | string | | +action_result.data.\*.id | string | | +action_result.data.\*.val | numeric | | +action_result.data.\*.type | string | | +action_result.data.\*.urls | string | | +action_result.data.\*.scopes.\*.Type | string | | +action_result.data.\*.editable | boolean | | +action_result.data.\*.keywords | string | | +action_result.data.\*.description | string | | +action_result.data.\*.configuredName | string | | +action_result.data.\*.customCategory | boolean | | +action_result.data.\*.customUrlsCount | numeric | | +action_result.data.\*.dbCategorizedUrls | string | | +action_result.data.\*.customIpRangesCount | numeric | | +action_result.data.\*.keywordsRetainingParentCategory | string | | +action_result.data.\*.urlsRetainingParentCategoryCount | numeric | | +action_result.data.\*.ipRangesRetainingParentCategoryCount | numeric | | +action_result.message | string | | Message: Category ips removed +action_result.summary | string | | +summary.total_objects | numeric | | 1 +summary.total_objects_successful | numeric | | 1 + +## action: 'create destination group' +Create destination group + +Type: **generic** +Read only: **False** + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**name** | required | Destination IP group name | string | +**type** | required | Destination IP group type (i.e., the group can contain destination IP addresses, countries, URL categories or FQDNs) | string | +**addresses** | optional | Comma seperated string of destination IP addresses, FQDNs, or wildcard FQDNs added to the group | string | +**description** | optional | Additional information about the destination IP group. | string | +**ip_categories** | optional | Destination IP address URL categories | string | +**countries** | optional | Destination IP address countries. You can identify destinations based on the location of a server. | string | + +#### Action Output +DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES +--------- | ---- | -------- | -------------- +action_result.status | string | | test success test failed +action_result.parameter.countries | string | | +action_result.parameter.ip_categories | string | | +action_result.parameter.description | string | | +action_result.parameter.addresses | string | | +action_result.parameter.type | string | | +action_result.parameter.name | string | | +action_result.data.\*.id | numeric | | +action_result.data.\*.name | string | | +action_result.data.\*.type | string | | DSTN_IP DSTN_FQDN DSTN_DOMAIN DSTN_OTHER +action_result.data.\*.addresses | string | | 192.168.1.1 +action_result.data.\*.countries | string | | +action_result.data.\*.description | string | | +action_result.data.\*.ipCategories | string | | TRADING_BROKARAGE_INSURANCE +action_result.summary | string | | +action_result.summary.message | string | | test User removed from group +action_result.message | string | | test User removed from group +summary.message | string | | +summary.total_objects | numeric | | 1 +summary.total_objects_successful | numeric | | 1 + +## action: 'list destination group' +List destination group + +Type: **investigate** +Read only: **False** + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**ip_group_ids** | optional | A comma-separated list of unique identifiers for the IP destination groups | string | +**exclude_type** | optional | The IP group type to be excluded from the results | string | +**category_type** | optional | Comma seperated list of IP group types to be filtered from results. This argument is only supported when the 'lite' argument is set to True | string | +**include_ipv6** | optional | Retrieve IPv6 destination groups | boolean | +**limit** | optional | Limit of the results to be retrieved | numeric | +**lite** | optional | Whether to retrieve only limited information of IP destination groups. Includes ID, name and type of the IP destination groups | boolean | + +#### Action Output +DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES +--------- | ---- | -------- | -------------- +action_result.status | string | | test success test failed +action_result.parameter.lite | boolean | | +action_result.parameter.limit | numeric | | +action_result.parameter.include_ipv6 | boolean | | +action_result.parameter.category_type | string | | +action_result.parameter.exclude_type | string | | +action_result.parameter.ip_group_id | string | | +action_result.data.\*.id | numeric | | +action_result.data.\*.name | string | | +action_result.data.\*.type | string | | DSTN_IP DSTN_FQDN DSTN_DOMAIN DSTN_OTHER +action_result.data.\*.addresses | string | | 192.168.1.1 +action_result.data.\*.countries | string | | +action_result.data.\*.description | string | | +action_result.data.\*.ipCategories | string | | TRADING_BROKARAGE_INSURANCE +action_result.summary | string | | +action_result.summary.message | string | | Retreived Destination Groups +action_result.message | string | | Retreived Destination Groups +summary.message | string | | +summary.total_objects | numeric | | 1 +summary.total_objects_successful | numeric | | 1 + +## action: 'edit destination group' +Edit destination group + +Type: **generic** +Read only: **False** + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**ip_group_id** | required | The unique identifier for the IP destination group | numeric | +**name** | optional | Destination IP group name | string | +**addresses** | optional | Comma seperated string of destination IP addresses, FQDNs, or wildcard FQDNs added to the group | string | +**description** | optional | Additional information about the destination IP group. | string | +**ip_categories** | optional | Destination IP address URL categories | string | +**countries** | optional | Destination IP address countries. You can identify destinations based on the location of a server. | string | +**is_non_editable** | optional | If set to true, the destination IP address group is non-editable. This field is applicable only to predefined IP address groups, which cannot be modified | boolean | + +#### Action Output +DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES +--------- | ---- | -------- | -------------- +action_result.status | string | | test success test failed +action_result.parameter.is_non_editable | boolean | | +action_result.parameter.countries | string | | +action_result.parameter.ip_categories | string | | +action_result.parameter.description | string | | +action_result.parameter.addresses | string | | +action_result.parameter.name | string | | +action_result.parameter.ip_group_id | numeric | | +action_result.data.\*.id | numeric | | +action_result.data.\*.name | string | | +action_result.data.\*.type | string | | DSTN_IP DSTN_FQDN DSTN_DOMAIN DSTN_OTHER +action_result.data.\*.addresses | string | | 192.168.1.1 +action_result.data.\*.countries | string | | +action_result.data.\*.description | string | | +action_result.data.\*.ipCategories | string | | TRADING_BROKARAGE_INSURANCE +action_result.data.\*.creatorContext | string | | +action_result.summary | string | | +action_result.summary.message | string | | test User removed from group +action_result.message | string | | test User removed from group +summary.message | string | | +summary.total_objects | numeric | | 1 +summary.total_objects_successful | numeric | | 1 + +## action: 'delete destination group' +Delete destination group + +Type: **generic** +Read only: **False** + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**ip_group_ids** | optional | A comma-separated list of unique identifiers for the IP destination groups | string | + +#### Action Output +DATA PATH | TYPE | CONTAINS | EXAMPLE VALUES +--------- | ---- | -------- | -------------- +action_result.status | string | | test success test failed +action_result.parameter.ip_group_ids | string | | +action_result.data.\*.ip_group_ids | string | | +action_result.summary | string | | +action_result.summary.message | string | | test User removed from group +action_result.message | string | | test User removed from group +summary.message | string | | +summary.total_objects | numeric | | 1 summary.total_objects_successful | numeric | | 1 \ No newline at end of file diff --git a/zscaler.json b/zscaler.json index 8326859..f14b789 100644 --- a/zscaler.json +++ b/zscaler.json @@ -316,7 +316,19 @@ "description": "List all URL categories", "type": "investigate", "read_only": true, - "parameters": {}, + "parameters": { + "get_ids_and_names_only": { + "description": "Whether to retrieve only a list containing URL category IDs and names. Even if displayURL is set to true, URLs will not be returned", + "data_type": "boolean", + "order": 0, + "default": false, + "example_values": [ + true, + false + ], + "primary": true + } + }, "output": [ { "data_path": "action_result.status", @@ -326,6 +338,13 @@ "test failed" ] }, + { + "data_path": "action_result.parameter.get_ids_and_names_only", + "data_type": "string", + "example_values": [ + "RADIO_STATIONS" + ] + }, { "data_path": "action_result.data.*.configuredName", "data_type": "string", @@ -3149,6 +3168,1427 @@ "type": "table" }, "versions": "EQ(*)" + }, + { + "action": "update user", + "identifier": "update_user", + "description": "Update user with given id", + "type": "correct", + "read_only": false, + "parameters": { + "user_id": { + "description": "ZScaler User Id", + "data_type": "numeric", + "required": true, + "primary": true, + "contains": [ + "zscaler user id" + ], + "example_values": [ + 889814 + ], + "order": 0 + }, + "user": { + "description": "JSON object containing the user details (see https://help.zscaler.com/zia/user-management#/users/{userId}-put)", + "data_type": "string", + "primary": true, + "order": 1 + } + }, + "output": [ + { + "data_path": "action_result.status", + "data_type": "string", + "column_name": "Status", + "column_order": 2, + "example_values": [ + "test success", + "test failed" + ] + }, + { + "data_path": "action_result.parameter.user", + "data_type": "string", + "column_name": "User", + "column_order": 1 + }, + { + "data_path": "action_result.parameter.user_id", + "data_type": "numeric", + "contains": [ + "zscaler user id" + ], + "column_name": "User ID", + "column_order": 0, + "example_values": [ + 889814 + ] + }, + { + "data_path": "action_result.data.*.adminUser", + "data_type": "boolean", + "example_values": [ + true, + false + ] + }, + { + "data_path": "action_result.data.*.comments", + "data_type": "string", + "example_values": [ + "test This is test user" + ] + }, + { + "data_path": "action_result.data.*.deleted", + "data_type": "boolean", + "example_values": [ + true, + false + ] + }, + { + "data_path": "action_result.data.*.department.id", + "data_type": "numeric", + "example_values": [ + 81896690 + ] + }, + { + "data_path": "action_result.data.*.department.name", + "data_type": "string", + "example_values": [ + "test IT" + ] + }, + { + "data_path": "action_result.data.*.email", + "data_type": "string", + "contains": [ + "email" + ], + "example_values": [ + "test first.last@domain.com" + ], + "column_name": "User Email", + "column_order": 2 + }, + { + "data_path": "action_result.data.*.groups.*.id", + "data_type": "numeric", + "contains": [ + "zscaler group id" + ], + "example_values": [ + 8894813 + ], + "column_name": "Group ID", + "column_order": 3 + }, + { + "data_path": "action_result.data.*.groups.*.name", + "data_type": "string", + "example_values": [ + "test Super Admin" + ], + "column_name": "Group Name", + "column_order": 4 + }, + { + "data_path": "action_result.data.*.id", + "data_type": "numeric", + "contains": [ + "zscaler user id" + ], + "example_values": [ + 889814 + ], + "column_name": "User ID", + "column_order": 0 + }, + { + "data_path": "action_result.data.*.name", + "data_type": "string", + "example_values": [ + "test First Last" + ], + "column_name": "User Name", + "column_order": 1 + }, + { + "data_path": "action_result.summary", + "data_type": "string" + }, + { + "data_path": "action_result.summary.message", + "data_type": "string", + "example_values": [ + "test User removed from group" + ] + }, + { + "data_path": "action_result.message", + "data_type": "string", + "example_values": [ + "test User removed from group" + ] + }, + { + "data_path": "summary.message", + "data_type": "string" + }, + { + "data_path": "summary.total_objects", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "summary.total_objects_successful", + "data_type": "numeric", + "example_values": [ + 1 + ] + } + ], + "render": { + "type": "table" + }, + "versions": "EQ(*)" + }, + { + "action": "add category url", + "description": "Add urls to a cetgory", + "type": "generic", + "identifier": "add_category_url", + "read_only": false, + "parameters": { + "category_id": { + "description": "The ID of the category to add the specified URLs to", + "data_type": "string", + "order": 0, + "example_values": [ + "RADIO_STATIONS" + ], + "primary": true, + "required": true + }, + "urls": { + "description": "A comma-separated list of URLs to add to the specified category", + "data_type": "string", + "order": 1, + "primary": true + }, + "retaining-parent-category-url": { + "description": "A comma-separated list of URLs to add to the retaining parent category section inside the specified category", + "data_type": "string", + "primary": true, + "order": 2 + } + }, + "output": [ + { + "data_path": "action_result.status", + "data_type": "string", + "example_values": [ + "success", + "failed" + ] + }, + { + "data_path": "action_result.parameter.category_id", + "data_type": "string", + "example_values": [ + "RADIO_STATIONS" + ] + }, + { + "data_path": "action_result.parameter.urls", + "data_type": "string" + }, + { + "data_path": "action_result.parameter.retaining-parent-category-url", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.id", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.val", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.type", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.urls", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.scopes.*.Type", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.editable", + "data_type": "boolean" + }, + { + "data_path": "action_result.data.*.keywords", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.description", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.configuredName", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.customCategory", + "data_type": "boolean" + }, + { + "data_path": "action_result.data.*.customUrlsCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.dbCategorizedUrls", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.customIpRangesCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.keywordsRetainingParentCategory", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.urlsRetainingParentCategoryCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.ipRangesRetainingParentCategoryCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.message", + "data_type": "string", + "example_values": [ + "Message: Category urs updated" + ] + }, + { + "data_path": "action_result.summary", + "data_type": "string" + }, + { + "data_path": "summary.total_objects", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "summary.total_objects_successful", + "data_type": "numeric", + "example_values": [ + 1 + ] + } + ], + "render": { + "type": "table" + }, + "versions": "EQ(*)" + }, + { + "action": "add category ip", + "description": "Add IPs to a cetgory", + "type": "generic", + "identifier": "add_category_ip", + "read_only": false, + "parameters": { + "category_id": { + "description": "The ID of the category to add the specified URLs to", + "data_type": "string", + "order": 0, + "example_values": [ + "RADIO_STATIONS" + ], + "primary": true, + "required": true + }, + "ips": { + "description": "A comma-separated list of IP addresses to add to the specified category", + "data_type": "string", + "order": 1, + "primary": true + }, + "retaining-parent-category-ip": { + "description": "A comma-separated list of IPs to add to the retaining parent category section inside the specified category", + "data_type": "string", + "primary": true, + "order": 2 + } + }, + "output": [ + { + "data_path": "action_result.status", + "data_type": "string", + "example_values": [ + "success", + "failed" + ] + }, + { + "data_path": "action_result.parameter.category_id", + "data_type": "string", + "example_values": [ + "RADIO_STATIONS" + ] + }, + { + "data_path": "action_result.parameter.ips", + "data_type": "string" + }, + { + "data_path": "action_result.parameter.retaining-parent-category-ip", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.id", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.val", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.type", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.urls", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.scopes.*.Type", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.editable", + "data_type": "boolean" + }, + { + "data_path": "action_result.data.*.keywords", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.description", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.configuredName", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.customCategory", + "data_type": "boolean" + }, + { + "data_path": "action_result.data.*.customUrlsCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.dbCategorizedUrls", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.customIpRangesCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.keywordsRetainingParentCategory", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.urlsRetainingParentCategoryCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.ipRangesRetainingParentCategoryCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.message", + "data_type": "string", + "example_values": [ + "Message: Category ips updated" + ] + }, + { + "data_path": "action_result.summary", + "data_type": "string" + }, + { + "data_path": "summary.total_objects", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "summary.total_objects_successful", + "data_type": "numeric", + "example_values": [ + 1 + ] + } + ], + "render": { + "type": "table" + }, + "versions": "EQ(*)" + }, + { + "action": "remove category url", + "description": "Add urls to a cetgory", + "type": "generic", + "identifier": "remove_category_url", + "read_only": false, + "parameters": { + "category_id": { + "description": "The ID of the category to add the specified URLs to", + "data_type": "string", + "order": 0, + "example_values": [ + "RADIO_STATIONS" + ], + "primary": true, + "required": true + }, + "urls": { + "description": "A comma-separated list of URLs to remove from the specified category", + "data_type": "string", + "order": 1, + "primary": true + }, + "retaining-parent-category-url": { + "description": "A comma-separated list of URLs to remove from the retaining parent category section inside the specified category", + "data_type": "string", + "primary": true, + "order": 2 + } + }, + "output": [ + { + "data_path": "action_result.status", + "data_type": "string", + "example_values": [ + "success", + "failed" + ] + }, + { + "data_path": "action_result.parameter.category_id", + "data_type": "string", + "example_values": [ + "RADIO_STATIONS" + ] + }, + { + "data_path": "action_result.parameter.urls", + "data_type": "string" + }, + { + "data_path": "action_result.parameter.retaining-parent-category-url", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.id", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.val", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.type", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.urls", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.scopes.*.Type", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.editable", + "data_type": "boolean" + }, + { + "data_path": "action_result.data.*.keywords", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.description", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.configuredName", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.customCategory", + "data_type": "boolean" + }, + { + "data_path": "action_result.data.*.customUrlsCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.dbCategorizedUrls", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.customIpRangesCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.keywordsRetainingParentCategory", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.urlsRetainingParentCategoryCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.ipRangesRetainingParentCategoryCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.message", + "data_type": "string", + "example_values": [ + "Message: Category urls removed" + ] + }, + { + "data_path": "action_result.summary", + "data_type": "string" + }, + { + "data_path": "summary.total_objects", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "summary.total_objects_successful", + "data_type": "numeric", + "example_values": [ + 1 + ] + } + ], + "render": { + "type": "table" + }, + "versions": "EQ(*)" + }, + { + "action": "remove category ip", + "description": "Remove IPs to a cetgory", + "type": "generic", + "identifier": "remove_category_ip", + "read_only": false, + "parameters": { + "category_id": { + "description": "The ID of the category to add the specified URLs to", + "data_type": "string", + "order": 0, + "example_values": [ + "RADIO_STATIONS" + ], + "primary": true, + "required": true + }, + "ips": { + "description": "A comma-separated list of IP addresses to add to the specified category", + "data_type": "string", + "order": 1, + "primary": true + }, + "retaining-parent-category-ip": { + "description": "A comma-separated list of IPs to add to the retaining parent category section inside the specified category", + "data_type": "string", + "primary": true, + "order": 2 + } + }, + "output": [ + { + "data_path": "action_result.status", + "data_type": "string", + "example_values": [ + "success", + "failed" + ] + }, + { + "data_path": "action_result.parameter.category_id", + "data_type": "string", + "example_values": [ + "RADIO_STATIONS" + ] + }, + { + "data_path": "action_result.parameter.ips", + "data_type": "string" + }, + { + "data_path": "action_result.parameter.retaining-parent-category-ip", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.id", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.val", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.type", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.urls", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.scopes.*.Type", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.editable", + "data_type": "boolean" + }, + { + "data_path": "action_result.data.*.keywords", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.description", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.configuredName", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.customCategory", + "data_type": "boolean" + }, + { + "data_path": "action_result.data.*.customUrlsCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.dbCategorizedUrls", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.customIpRangesCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.keywordsRetainingParentCategory", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.urlsRetainingParentCategoryCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.ipRangesRetainingParentCategoryCount", + "data_type": "numeric" + }, + { + "data_path": "action_result.message", + "data_type": "string", + "example_values": [ + "Message: Category ips removed" + ] + }, + { + "data_path": "action_result.summary", + "data_type": "string" + }, + { + "data_path": "summary.total_objects", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "summary.total_objects_successful", + "data_type": "numeric", + "example_values": [ + 1 + ] + } + ], + "render": { + "type": "table" + }, + "versions": "EQ(*)" + }, + { + "action": "create destination group", + "identifier": "create_destination_group", + "description": "Create destination group", + "type": "generic", + "read_only": false, + "parameters": { + "name": { + "description": "Destination IP group name", + "data_type": "string", + "required": true, + "primary": true, + "order": 0 + }, + "type": { + "description": "Destination IP group type (i.e., the group can contain destination IP addresses, countries, URL categories or FQDNs)", + "data_type": "string", + "required": true, + "primary": true, + "example_values": [ + "DSTN_IP", + "DSTN_FQDN", + "DSTN_DOMAIN", + "DSTN_OTHER" + ], + "order": 1 + }, + "addresses": { + "description": "Comma seperated string of destination IP addresses, FQDNs, or wildcard FQDNs added to the group", + "data_type": "string", + "order": 2 + }, + "description": { + "description": "Additional information about the destination IP group.", + "data_type": "string", + "order": 3 + }, + "ip_categories": { + "description": "Destination IP address URL categories", + "data_type": "string", + "order": 4 + }, + "countries": { + "description": "Destination IP address countries. You can identify destinations based on the location of a server.", + "data_type": "string", + "order": 5 + } + }, + "output": [ + { + "data_path": "action_result.status", + "data_type": "string", + "column_name": "Status", + "column_order": 2, + "example_values": [ + "test success", + "test failed" + ] + }, + { + "data_path": "action_result.parameter.countries", + "data_type": "string", + "column_name": "Countries", + "column_order": 5 + }, + { + "data_path": "action_result.parameter.ip_categories", + "data_type": "string", + "column_name": "Ip Categories", + "column_order": 4 + }, + { + "data_path": "action_result.parameter.description", + "data_type": "string", + "column_name": "Description", + "column_order": 3 + }, + { + "data_path": "action_result.parameter.addresses", + "data_type": "string", + "column_name": "Addresses", + "column_order": 2 + }, + { + "data_path": "action_result.parameter.type", + "data_type": "string", + "column_name": "Type", + "column_order": 1 + }, + { + "data_path": "action_result.parameter.name", + "data_type": "string", + "column_name": "Name", + "column_order": 0 + }, + { + "data_path": "action_result.data.*.id", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.name", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.type", + "data_type": "string", + "example_values": [ + "DSTN_IP", + "DSTN_FQDN", + "DSTN_DOMAIN", + "DSTN_OTHER" + ] + }, + { + "data_path": "action_result.data.*.addresses", + "data_type": "string", + "example_values": [ + "192.168.1.1" + ] + }, + { + "data_path": "action_result.data.*.countries", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.description", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.ipCategories", + "data_type": "string", + "example_values": [ + "TRADING_BROKARAGE_INSURANCE" + ] + }, + { + "data_path": "action_result.summary", + "data_type": "string" + }, + { + "data_path": "action_result.summary.message", + "data_type": "string", + "example_values": [ + "test User removed from group" + ] + }, + { + "data_path": "action_result.message", + "data_type": "string", + "example_values": [ + "test User removed from group" + ] + }, + { + "data_path": "summary.message", + "data_type": "string" + }, + { + "data_path": "summary.total_objects", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "summary.total_objects_successful", + "data_type": "numeric", + "example_values": [ + 1 + ] + } + ], + "render": { + "type": "table" + }, + "versions": "EQ(*)" + }, + { + "action": "list destination group", + "identifier": "list_destination_group", + "description": "List destination group", + "type": "investigate", + "read_only": false, + "parameters": { + "ip_group_ids": { + "description": "A comma-separated list of unique identifiers for the IP destination groups", + "data_type": "string", + "primary": true, + "order": 0 + }, + "exclude_type": { + "description": "The IP group type to be excluded from the results", + "data_type": "string", + "primary": true, + "example_values": [ + "DSTN_IP", + "DSTN_FQDN", + "DSTN_DOMAIN", + "DSTN_OTHER" + ], + "order": 1 + }, + "category_type": { + "description": "Comma seperated list of IP group types to be filtered from results. This argument is only supported when the 'lite' argument is set to True", + "data_type": "string", + "example_values": [ + "DSTN_IP", + "DSTN_FQDN", + "DSTN_DOMAIN", + "DSTN_OTHER" + ], + "order": 2 + }, + "include_ipv6": { + "description": "Retrieve IPv6 destination groups", + "data_type": "boolean", + "example_values": [ + true, + false + ], + "default": false, + "order": 3 + }, + "limit": { + "description": "Limit of the results to be retrieved", + "data_type": "numeric", + "default": 50, + "order": 4 + }, + "lite": { + "description": "Whether to retrieve only limited information of IP destination groups. Includes ID, name and type of the IP destination groups", + "data_type": "boolean", + "example_values": [ + true, + false + ], + "default": false, + "order": 5 + } + }, + "output": [ + { + "data_path": "action_result.status", + "data_type": "string", + "column_name": "Status", + "column_order": 2, + "example_values": [ + "test success", + "test failed" + ] + }, + { + "data_path": "action_result.parameter.lite", + "data_type": "boolean", + "column_name": "Lite", + "column_order": 5 + }, + { + "data_path": "action_result.parameter.limit", + "data_type": "numeric", + "column_name": "Limit", + "column_order": 4 + }, + { + "data_path": "action_result.parameter.include_ipv6", + "data_type": "boolean", + "column_name": "Include Ipv6", + "column_order": 3 + }, + { + "data_path": "action_result.parameter.category_type", + "data_type": "string", + "column_name": "Category Type", + "column_order": 2 + }, + { + "data_path": "action_result.parameter.exclude_type", + "data_type": "string", + "column_name": "Exclude Type", + "column_order": 1 + }, + { + "data_path": "action_result.parameter.ip_group_id", + "data_type": "string", + "column_name": "Ip Group ID", + "column_order": 0 + }, + { + "data_path": "action_result.data.*.id", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.name", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.type", + "data_type": "string", + "example_values": [ + "DSTN_IP", + "DSTN_FQDN", + "DSTN_DOMAIN", + "DSTN_OTHER" + ] + }, + { + "data_path": "action_result.data.*.addresses", + "data_type": "string", + "example_values": [ + "192.168.1.1" + ] + }, + { + "data_path": "action_result.data.*.countries", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.description", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.ipCategories", + "data_type": "string", + "example_values": [ + "TRADING_BROKARAGE_INSURANCE" + ] + }, + { + "data_path": "action_result.summary", + "data_type": "string" + }, + { + "data_path": "action_result.summary.message", + "data_type": "string", + "example_values": [ + "Retreived Destination Groups" + ] + }, + { + "data_path": "action_result.message", + "data_type": "string", + "example_values": [ + "Retreived Destination Groups" + ] + }, + { + "data_path": "summary.message", + "data_type": "string" + }, + { + "data_path": "summary.total_objects", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "summary.total_objects_successful", + "data_type": "numeric", + "example_values": [ + 1 + ] + } + ], + "render": { + "type": "table" + }, + "versions": "EQ(*)" + }, + { + "action": "edit destination group", + "identifier": "edit_destination_group", + "description": "Edit destination group", + "type": "generic", + "read_only": false, + "parameters": { + "ip_group_id": { + "description": "The unique identifier for the IP destination group", + "data_type": "numeric", + "required": true, + "primary": true, + "order": 0 + }, + "name": { + "description": "Destination IP group name", + "data_type": "string", + "primary": true, + "order": 1 + }, + "addresses": { + "description": "Comma seperated string of destination IP addresses, FQDNs, or wildcard FQDNs added to the group", + "data_type": "string", + "order": 2 + }, + "description": { + "description": "Additional information about the destination IP group.", + "data_type": "string", + "order": 3 + }, + "ip_categories": { + "description": "Destination IP address URL categories", + "data_type": "string", + "order": 4 + }, + "countries": { + "description": "Destination IP address countries. You can identify destinations based on the location of a server.", + "data_type": "string", + "order": 5 + }, + "is_non_editable": { + "description": "If set to true, the destination IP address group is non-editable. This field is applicable only to predefined IP address groups, which cannot be modified", + "data_type": "boolean", + "default": false, + "example_values": [ + true, + false + ], + "order": 6 + } + }, + "output": [ + { + "data_path": "action_result.status", + "data_type": "string", + "column_name": "Status", + "column_order": 2, + "example_values": [ + "test success", + "test failed" + ] + }, + { + "data_path": "action_result.parameter.is_non_editable", + "data_type": "boolean", + "column_name": "Is Non Editab;e", + "column_order": 6 + }, + { + "data_path": "action_result.parameter.countries", + "data_type": "string", + "column_name": "Countries", + "column_order": 5 + }, + { + "data_path": "action_result.parameter.ip_categories", + "data_type": "string", + "column_name": "Ip Categories", + "column_order": 4 + }, + { + "data_path": "action_result.parameter.description", + "data_type": "string", + "column_name": "Description", + "column_order": 3 + }, + { + "data_path": "action_result.parameter.addresses", + "data_type": "string", + "column_name": "Addresses", + "column_order": 2 + }, + { + "data_path": "action_result.parameter.name", + "data_type": "string", + "column_name": "Name", + "column_order": 1 + }, + { + "data_path": "action_result.parameter.ip_group_id", + "data_type": "numeric", + "column_name": "IP Group Id", + "column_order": 1 + }, + { + "data_path": "action_result.data.*.id", + "data_type": "numeric" + }, + { + "data_path": "action_result.data.*.name", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.type", + "data_type": "string", + "example_values": [ + "DSTN_IP", + "DSTN_FQDN", + "DSTN_DOMAIN", + "DSTN_OTHER" + ] + }, + { + "data_path": "action_result.data.*.addresses", + "data_type": "string", + "example_values": [ + "192.168.1.1" + ] + }, + { + "data_path": "action_result.data.*.countries", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.description", + "data_type": "string" + }, + { + "data_path": "action_result.data.*.ipCategories", + "data_type": "string", + "example_values": [ + "TRADING_BROKARAGE_INSURANCE" + ] + }, + { + "data_path": "action_result.data.*.creatorContext", + "data_type": "string" + }, + { + "data_path": "action_result.summary", + "data_type": "string" + }, + { + "data_path": "action_result.summary.message", + "data_type": "string", + "example_values": [ + "test User removed from group" + ] + }, + { + "data_path": "action_result.message", + "data_type": "string", + "example_values": [ + "test User removed from group" + ] + }, + { + "data_path": "summary.message", + "data_type": "string" + }, + { + "data_path": "summary.total_objects", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "summary.total_objects_successful", + "data_type": "numeric", + "example_values": [ + 1 + ] + } + ], + "render": { + "type": "table" + }, + "versions": "EQ(*)" + }, + { + "action": "delete destination group", + "identifier": "delete_destination_group", + "description": "Delete destination group", + "type": "generic", + "read_only": false, + "parameters": { + "ip_group_ids": { + "description": "A comma-separated list of unique identifiers for the IP destination groups", + "data_type": "string", + "primary": true, + "order": 0 + } + }, + "output": [ + { + "data_path": "action_result.status", + "data_type": "string", + "column_name": "Status", + "column_order": 2, + "example_values": [ + "test success", + "test failed" + ] + }, + { + "data_path": "action_result.parameter.ip_group_ids", + "data_type": "string", + "column_name": "IP Group Ids", + "column_order": 0 + }, + { + "data_path": "action_result.data.*.ip_group_ids", + "data_type": "string" + }, + { + "data_path": "action_result.summary", + "data_type": "string" + }, + { + "data_path": "action_result.summary.message", + "data_type": "string", + "example_values": [ + "test User removed from group" + ] + }, + { + "data_path": "action_result.message", + "data_type": "string", + "example_values": [ + "test User removed from group" + ] + }, + { + "data_path": "summary.message", + "data_type": "string" + }, + { + "data_path": "summary.total_objects", + "data_type": "numeric", + "example_values": [ + 1 + ] + }, + { + "data_path": "summary.total_objects_successful", + "data_type": "numeric", + "example_values": [ + 1 + ] + } + ], + "render": { + "type": "table" + }, + "versions": "EQ(*)" } ], "pip_dependencies": { diff --git a/zscaler_connector.py b/zscaler_connector.py index 269e95c..6a5a4a3 100644 --- a/zscaler_connector.py +++ b/zscaler_connector.py @@ -739,8 +739,17 @@ def _handle_list_url_categories(self, param): if phantom.is_fail(ret_val): return action_result.get_status() + get_ids_and_names_only = param["get_ids_and_names_only"] + for url_category in list_url_categories: - action_result.add_data(url_category) + if get_ids_and_names_only: + category_lite = {} + category_lite["id"] = url_category["id"] + if "configuredName" in url_category: + category_lite["configuredName"] = url_category["configuredName"] + action_result.add_data(category_lite) + else: + action_result.add_data(url_category) summary = action_result.update_summary({}) summary['total_url_categories'] = action_result.get_data_size() @@ -1049,6 +1058,385 @@ def _handle_get_blacklist(self, param): summary['total_blacklist_items'] = action_result.get_data_size() return action_result.set_status(phantom.APP_SUCCESS) + + def _handle_update_user(self, param): + self.save_progress("In action handler for: {0}".format(self.get_action_identifier())) + action_result = self.add_action_result(ActionResult(dict(param))) + user_id = param['user_id'] + + try: + data = json.loads(param["user"]) + except Exception as e: + return action_result.set_status( + phantom.APP_ERROR, + "User object needs to be valid json: {}".format(e) + ) + + ret_val, response = self._make_rest_call_helper(f'/api/v1/users/{user_id}', action_result, data=data, method='put') + + if phantom.is_fail(ret_val): + return action_result.get_status() + + self.debug_print(response) + action_result.add_data(response) + summary = action_result.update_summary({}) + summary['message'] = "User updated" + return action_result.set_status(phantom.APP_SUCCESS) + + def _get_category_details(self, id, action_result): + ret_val, response = self._make_rest_call_helper(f'/api/v1/urlCategories/{id}', action_result) + if phantom.is_fail(ret_val): + return action_result.get_status(), None + return phantom.APP_SUCCESS, response + + def _add_to_category(self, data, parent_data, category_details, category_id, action_result): + new_data = category_details.get("urls", []) + new_data.extend(data) + if new_data: + category_details["urls"] = new_data + + new_parent_data = category_details.get("dbCategorizedUrls", []) + new_parent_data.extend(parent_data) + if new_parent_data: + category_details["dbCategorizedUrls"] = new_parent_data + + ret_val, response = self._make_rest_call_helper(f'/api/v1/urlCategories/{category_id}', action_result, data=category_details, method='put') + return ret_val, response + + def _handle_add_category_url(self, param): + self.save_progress("In action handler for: {0}".format(self.get_action_identifier())) + action_result = self.add_action_result(ActionResult(dict(param))) + category_id = param["category_id"] + + ret_val, category_details = self._get_category_details(category_id, action_result) + if phantom.is_fail(ret_val): + return action_result.get_status() + + is_custom_category = category_details.get("customCategory", False) + + if not is_custom_category: + action_result.set_status(phantom.APP_ERROR, "Category with {0} is a default category, which cannot be modified" + .format(category_id)) + return action_result.get_status() + + urls = param.get("urls", "") + urls_list = [item.strip() for item in urls.split(',') if item.strip()] + retaining_parent_category_url = param.get("retaining-parent-category-url", "") + parent_urls = [item.strip() for item in retaining_parent_category_url.split(',') if item.strip()] + ret_val, response = self._add_to_category(urls_list, parent_urls, category_details, category_id, action_result) + + if phantom.is_fail(ret_val): + return action_result.get_status() + + action_result.add_data(response) + summary = action_result.update_summary({}) + summary['message'] = "Category urls updated" + + return action_result.set_status(phantom.APP_SUCCESS) + + def _handle_add_category_ips(self, param): + self.save_progress("In action handler for: {0}".format(self.get_action_identifier())) + action_result = self.add_action_result(ActionResult(dict(param))) + category_id = param["category_id"] + + ret_val, category_details = self._get_category_details(category_id, action_result) + if phantom.is_fail(ret_val): + return action_result.get_status() + + ips = param.get("ips", "") + ips_list = [item.strip() for item in ips.split(',') if item.strip()] + retaining_parent_category_ip = param.get("retaining-parent-category-ip", "") + parent_ips = [item.strip() for item in retaining_parent_category_ip.split(',') if item.strip()] + ret_val, response = self._add_to_category(ips_list, parent_ips, category_details, category_id, action_result) + + if phantom.is_fail(ret_val): + return action_result.get_status() + + action_result.add_data(response) + summary = action_result.update_summary({}) + summary['message'] = "Category ips updated" + + return action_result.set_status(phantom.APP_SUCCESS) + + def _handle_remove_category_ips(self, param): + self.save_progress("In action handler for: {0}".format(self.get_action_identifier())) + action_result = self.add_action_result(ActionResult(dict(param))) + category_id = param["category_id"] + + ret_val, category_details = self._get_category_details(category_id, action_result) + if phantom.is_fail(ret_val): + return action_result.get_status() + + ips = param.get("ips", "") + ips_to_remove = [item.strip() for item in ips.split(',') if item.strip()] + retaining_parent_category_ips = param.get("retaining-parent-category-ip", "") + parent_ips_to_remove = [item.strip() for item in retaining_parent_category_ips.split(',') if item.strip()] + + ret_val, response = self._remove_from_category(ips_to_remove, parent_ips_to_remove, category_details, category_id, action_result) + + if phantom.is_fail(ret_val): + return action_result.get_status() + + action_result.add_data(response) + summary = action_result.update_summary({}) + summary['message'] = "Category ips removed" + + return action_result.set_status(phantom.APP_SUCCESS) + + def _remove_from_category(self, data, parent_data, category_details, category_id, action_result): + data_set = set(data) + new_data = [] + for point in category_details.get("urls", []): + if point not in data_set: + new_data.append(point) + + parent_data_set = set(parent_data) + new_parent_data = [] + for point in category_details.get("dbCategorizedUrls", []): + if point not in parent_data_set: + new_parent_data.append(point) + + category_details["urls"] = new_data + category_details["dbCategorizedUrls"] = new_parent_data + + ret_val, response = self._make_rest_call_helper(f'/api/v1/urlCategories/{category_id}', action_result, data=category_details, method='put') + return ret_val, response + + def _handle_remove_category_urls(self, param): + self.save_progress("In action handler for: {0}".format(self.get_action_identifier())) + action_result = self.add_action_result(ActionResult(dict(param))) + category_id = param["category_id"] + + ret_val, category_details = self._get_category_details(category_id, action_result) + if phantom.is_fail(ret_val): + return action_result.get_status() + + urls = param.get("urls", "") + urls_to_remove = [item.strip() for item in urls.split(',') if item.strip()] + retaining_parent_category_url = param.get("retaining-parent-category-url", "") + parent_urls_to_remove = [item.strip() for item in retaining_parent_category_url.split(',') if item.strip()] + + ret_val, response = self._remove_from_category(urls_to_remove, parent_urls_to_remove, category_details, category_id, action_result) + + if phantom.is_fail(ret_val): + return action_result.get_status() + + action_result.add_data(response) + summary = action_result.update_summary({}) + summary['message'] = "Category urls removed" + + return action_result.set_status(phantom.APP_SUCCESS) + + def _handle_create_destination_group(self, param): + """ + This action is used to create an IP Destination Group + :param name: IP destination group name + :param type: IP destination group type + :param addresses: Destination IP addresses, FQDNs, or wildcard FQDNs + :param description: Additional information about the destination IP group + :param ip_categories: Destination IP address URL categories + :param countries: Destination IP address countries + :return: status phantom.APP_ERROR/phantom.APP_SUCCESS(along with appropriate message) + """ + self.save_progress("In action handler for: {0}".format(self.get_action_identifier())) + action_result = self.add_action_result(ActionResult(dict(param))) + + addresses = param.get("addresses", "") + ip_categories = param.get("ip_categories", "") + countries = param.get("countries", "") + + data = {} + data["name"] = param["name"] + data["type"] = param["type"] + if addresses: + data["addresses"] = [item.strip() for item in addresses.split(',')] + data["description"] = param.get("description", "") + if ip_categories: + data["ipCategories"] = [item.strip() for item in ip_categories.split(',')] + if countries: + data["countries"] = [item.strip() for item in countries.split(',')] + + ret_val, response = self._make_rest_call_helper('/api/v1/ipDestinationGroups', action_result, data=data, method='post') + if phantom.is_fail(ret_val): + return action_result.get_status() + + action_result.add_data(response) + summary = action_result.update_summary({}) + summary['message'] = "Destination IP added" + + return action_result.set_status(phantom.APP_SUCCESS) + + def _get_destination_group(self, id, action_result, exclude_type=None, category_type=None, lite=False): + + ret_val, response = self._make_rest_call_helper(f'/api/v1/ipDestinationGroups/{id}', action_result) + if phantom.is_fail(ret_val): + return action_result.get_status(), None + + group_type = response["type"] + + if group_type == exclude_type: + return phantom.APP_SUCCESS, None + + if lite: + if category_type and group_type not in category_type: + return phantom.APP_SUCCESS, None + + lite_resp = {"id": response["id"], "name": response["name"], "type": group_type} + return phantom.APP_SUCCESS, lite_resp + + return phantom.APP_SUCCESS, response + + def _get_batched_groups(self, endpoint, params, action_result): + limit = params['pageSize'] + + while True: + params['pageSize'] = min(limit, ZSCALER_MAX_PAGESIZE) + ret_val, get_groups = self._make_rest_call_helper('/api/v1' + endpoint, action_result, params=params) + self.debug_print("get groups is {0}".format(get_groups)) + if phantom.is_fail(ret_val): + return action_result.get_status() + for group in get_groups: + if "extensions" in group: + extensions = group.pop("extensions") + for key in extensions: + group[key] = extensions[key] + action_result.add_data(group) + limit = limit - params['pageSize'] + if limit <= 0 or len(get_groups) == 0: + break + params['page'] += 1 + + return phantom.APP_SUCCESS + + def _handle_list_destination_group(self, param): + """ + This action is used to list IP Destination Groups + :param ip_group_ids: Destination groups to retrieve + :param exclude_type: Group types to exclude from search + :param category_type: Destination types to filter by + :param include_ipv6: Retrieve IPv6 groups + :param limit: Number of groups to retrieve + :param lite: Retrieve limited information for each group + :return: status phantom.APP_ERROR/phantom.APP_SUCCESS(along with appropriate message) + """ + self.save_progress("In action handler for: {0}".format(self.get_action_identifier())) + action_result = self.add_action_result(ActionResult(dict(param))) + + ip_group_ids = param.get("ip_group_ids", "") + ip_ids_lst = [item.strip() for item in ip_group_ids.split(',') if item.strip()] + exclude_type = param.get("exclude_type", "") + category_type = param.get("category_type", "") + category_type_list = [item.strip() for item in category_type.split(',') if item.strip()] + include_ipv6 = param.get("include_ipv6", False) + limit = param.get("limit", 50) + lite = param.get("lite", False) + + params = {} + endpoint = '/ipDestinationGroups' + params['excludeType'] = exclude_type + self.debug_print("ip id list {0}".format(ip_ids_lst)) + if ip_ids_lst: + for ip in ip_ids_lst: + ret_val, response = self._get_destination_group(ip, action_result, exclude_type, category_type, lite) + if phantom.is_fail(ret_val): + return action_result.get_status() + action_result.add_data(response) + + summary = action_result.update_summary({}) + summary['message'] = "Destination groups retrieved" + return action_result.set_status(phantom.APP_SUCCESS) + + elif lite: + endpoint = '/ipDestinationGroups/lite' + params['type'] = category_type_list + + params['page'] = 1 + params['pageSize'] = limit + ret_val = self._get_batched_groups(endpoint, params, action_result) + if phantom.is_fail(ret_val): + return action_result.get_status() + + if include_ipv6: + self.save_progress("Retrieving ipv6 destination groups") + params['page'] = 1 + params['pageSize'] = limit + endpoint = '/ipDestinationGroups/ipv6DestinationGroups/lite' if lite else '/ipDestinationGroups/ipv6DestinationGroups' + ret_val = self._get_batched_groups(endpoint, params, action_result) + if phantom.is_fail(ret_val): + return action_result.get_status() + + # action_result.add_data(destination_groups) + summary = action_result.update_summary({}) + summary['message'] = "Destination groups retrieved" + return action_result.set_status(phantom.APP_SUCCESS) + + def _handle_edit_destination_group(self, param): + """ + This action is used to edit an IP Destination Group + :param ip_group_id: Id of destination group to edit + :param name: IP destination group name + :param addresses: Destination IP addresses, FQDNs, or wildcard FQDNs + :param description: Additional information about the destination IP group + :param ip_categories: Destination IP address URL categories + :param countries: Destination IP address countries + :param is_non_editable: If set to true, the destination IP address group is non-editable + :return: status phantom.APP_ERROR/phantom.APP_SUCCESS(along with appropriate message) + """ + self.save_progress("In action handler for: {0}".format(self.get_action_identifier())) + action_result = self.add_action_result(ActionResult(dict(param))) + + group_id = param['ip_group_id'] + + ret_val, group_resp = self._get_destination_group(group_id, action_result) + if phantom.is_fail(ret_val): + return action_result.get_status() + self.debug_print("handle edit response {0}".format(group_resp)) + if param.get("name"): + group_resp["name"] = param["name"] + if param.get('addresses'): + new_addresses = [item.strip() for item in param["addresses"].split(',') if item.strip()] + group_resp["addresses"] = new_addresses + if param.get("description"): + group_resp["description"] = param["description"] + if param.get("ip_categories"): + new_ip_categories = [item.strip() for item in param["ip_categories"].split(',') if item.strip()] + group_resp["ipCategories"] = new_ip_categories + if param.get("countries"): + new_countries = [item.strip() for item in param["countries"].split(',') if item.strip()] + group_resp["countries"] = new_countries + group_resp["isNonEditable"] = param["is_non_editable"] + + ret_val, response = self._make_rest_call_helper(f'/api/v1/ipDestinationGroups/{group_id}', action_result, data=group_resp, method='put') + if phantom.is_fail(ret_val): + return action_result.get_status() + + action_result.add_data(response) + summary = action_result.update_summary({}) + summary['message'] = "Destination IP edited" + + return action_result.set_status(phantom.APP_SUCCESS) + + def _handle_delete_destination_group(self, param): + """ + This action is used to delete IP Destination Groups + :param ip_group_ids: Ids of destination group to delete + :return: status phantom.APP_ERROR/phantom.APP_SUCCESS(along with appropriate message) + """ + self.save_progress("In action handler for: {0}".format(self.get_action_identifier())) + action_result = self.add_action_result(ActionResult(dict(param))) + + group_ids = param.get("ip_group_ids", "") + list_group_ids = [item.strip() for item in group_ids.split(',') if item.strip()] + + for group_id in list_group_ids: + ret_val, response = self._make_rest_call_helper(f'/api/v1/ipDestinationGroups/{group_id}', action_result, method='delete') + if phantom.is_fail(ret_val): + return action_result.get_status() + action_result.add_data({"ip_group_id": group_id}) + + summary = action_result.update_summary({}) + summary['message'] = "Destination groups deleted" + return action_result.set_status(phantom.APP_SUCCESS) def handle_action(self, param): @@ -1122,6 +1510,33 @@ def handle_action(self, param): elif action_id == 'get_blacklist': ret_val = self._handle_get_blacklist(param) + elif action_id == "update_user": + ret_val = self._handle_update_user(param) + + elif action_id == 'add_category_url': + ret_val = self._handle_add_category_url(param) + + elif action_id == 'add_category_ip': + ret_val = self._handle_add_category_ips(param) + + elif action_id == 'remove_category_url': + ret_val = self._handle_remove_category_urls(param) + + elif action_id == 'remove_category_ip': + ret_val = self._handle_remove_category_ips(param) + + elif action_id == 'create_destination_group': + ret_val = self._handle_create_destination_group(param) + + elif action_id == 'list_destination_group': + ret_val = self._handle_list_destination_group(param) + + elif action_id == 'edit_destination_group': + ret_val = self._handle_edit_destination_group(param) + + elif action_id == 'delete_destination_group': + ret_val = self._handle_delete_destination_group(param) + return ret_val def initialize(self):