Skip to content

Commit

Permalink
Merge pull request #14 from splunk-soar-connectors/tapishj/PAPP-34459
Browse files Browse the repository at this point in the history
Zscaler: Feature - New Update User Action
  • Loading branch information
tapishj-splunk authored Aug 12, 2024
2 parents 6b62c2f + 741403e commit bcea011
Show file tree
Hide file tree
Showing 3 changed files with 252 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ VARIABLE | REQUIRED | TYPE | DESCRIPTION
[get groups](#action-get-groups) - Gets a list of groups
[add group user](#action-add-group-user) - Add user to group
[remove group user](#action-remove-group-user) - Remove user from group
[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
Expand Down Expand Up @@ -758,6 +759,41 @@ summary.message | string | |
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 [email protected]
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

Expand Down
189 changes: 189 additions & 0 deletions zscaler.json
Original file line number Diff line number Diff line change
Expand Up @@ -3020,6 +3020,195 @@
},
"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 [email protected]"
],
"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",
Expand Down
27 changes: 27 additions & 0 deletions zscaler_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,30 @@ def _handle_remove_group_user(self, param):

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):
Expand Down Expand Up @@ -1420,6 +1444,9 @@ def handle_action(self, param):
elif action_id == 'remove_group_user':
ret_val = self._handle_remove_group_user(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)

Expand Down

0 comments on commit bcea011

Please sign in to comment.