Skip to content

Commit

Permalink
PAPP-34459: Update user action working
Browse files Browse the repository at this point in the history
  • Loading branch information
tapishj-splunk committed Aug 5, 2024
1 parent ca06a69 commit ce2fd3f
Show file tree
Hide file tree
Showing 2 changed files with 216 additions and 0 deletions.
189 changes: 189 additions & 0 deletions zscaler.json
Original file line number Diff line number Diff line change
Expand Up @@ -3000,6 +3000,195 @@
"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 [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(*)"
}
],
"pip_dependencies": {
Expand Down
27 changes: 27 additions & 0 deletions zscaler_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,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 handle_action(self, param):

ret_val = phantom.APP_SUCCESS
Expand Down Expand Up @@ -1056,6 +1080,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)

return ret_val

def initialize(self):
Expand Down

0 comments on commit ce2fd3f

Please sign in to comment.