This repository was archived by the owner on Jul 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Group Perms update for argus client #34
Open
snehabas
wants to merge
25
commits into
salesforce:master
Choose a base branch
from
snehabas:grouppermsandperms
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
9cc4512
Updated to support permissions integration
sanjana-sfdc 59c15f7
Removed unnecessary logs
sanjana-sfdc be0c36b
Updated formatting
sanjana-sfdc 14945b0
Removed attributes used for testing
sanjana-sfdc b9405fe
updated api for groups
snehabas 3bad2fe
updates to client for groups API
snehabas ac2757d
Revert "updates to client for groups API"
snehabas f40eaf0
Revert "Revert "updates to client for groups API""
snehabas 9041b5c
update
snehabas ab94bcc
updated
snehabas 63e83f4
updated
snehabas 05a66f1
updated unit tests
snehabas a55dea1
updated formatting
snehabas bc5ed82
updated
snehabas fca2bfa
updated tests and added edge cases
snehabas b4a744b
updated test datat
snehabas 70413aa
deleting group permission works
snehabas f614e36
added integration test
snehabas 98c0830
updated integration tests
snehabas 0db8565
Update README.rst
snehabas f42c3f7
Update argusclient/client.py
snehabas 591392a
updated tests
snehabas 54d1044
new branc to incorporate sanjana's changes
snehabas fe1e70d
added case handling
snehabas 3364ce0
Merge branch 'master' into grouppermsandperms
snehabas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,4 @@ dist | |
| docs/_build | ||
| docs/README.rst | ||
| .idea/ | ||
| venv/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,13 +36,26 @@ | |
| notificationName = "test.notification" | ||
| groupPermissionIdentifier = "group" | ||
| userPermissionIdentifier = "user" | ||
| groupID = "5eb1fc18-c985-47eb-94f9-aebce66e119a" | ||
| permissionNames = ["VIEW", "EDIT", "DELETE"] | ||
| permissionGroupId = '24231-52321-43523-64353-23111' | ||
| username = "testuser" | ||
| permission_ids = [1,2,3] | ||
| group_id = "c8be7819-bf5e-40aa-8535-88694d34280f" | ||
| entity_id = 23590046 | ||
|
|
||
| username = "testuser" | ||
| permission_ids = [1,2,3] | ||
| user_type = "user" | ||
| group_type = "group" | ||
| group_id = "c8be7819-bf5e-40aa-8535-88694d34280f" | ||
| entity_id = 23590046 | ||
|
|
||
| permissionGroup2ID= '24231-52321-43523-64353-23121' | ||
| permissionGroup3ID = '24231-52321-43523-64353-24121' | ||
| permissionGroupIdBad = '2423480-3843hlfw-jf' | ||
|
|
||
|
|
||
| compAlertID = 6000 | ||
| childAlertID_1 = 6003 | ||
| childAlertID_2 = 6009 | ||
|
|
@@ -121,10 +134,29 @@ | |
| } | ||
|
|
||
| groupPermission_D = { | ||
| "type": groupPermissionIdentifier, | ||
| "permissionNames": permissionNames, | ||
| "groupId": permissionGroupId | ||
| "type": "group", | ||
| "groupId": permissionGroupId, | ||
| "permissionIds": [0,1,2] | ||
| } | ||
| groupPermission_E = { | ||
| "type": "group", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could use the variable groupPermissionIdentifier here |
||
| "groupId": permissionGroup2ID, | ||
| "permissionIds": [0,1] | ||
| } | ||
|
|
||
| groupPermission_F = { | ||
| "type": "group", | ||
| "groupId": permissionGroup3ID, | ||
| "permissionIds": [0,1,2] | ||
| } | ||
|
|
||
|
|
||
| groupBadPermission_D = { | ||
| "groupId": groupID, | ||
| "permissionIds": [0,3] | ||
| } | ||
|
|
||
|
|
||
|
|
||
| userPermission_D = { | ||
| "type": userPermissionIdentifier, | ||
|
|
@@ -372,7 +404,7 @@ | |
| 'id': triggerID_1, | ||
| 'threshold': 1.0, | ||
| 'type': 'GREATER_THAN', | ||
| 'inertia': 0L, | ||
| 'inertia': 0, | ||
| 'name': 'CompAlertTest/trigger1' | ||
| } | ||
|
|
||
|
|
@@ -383,7 +415,7 @@ | |
| 'subscriptions': ['jdoe@example.com'], | ||
| 'notifierName': 'com.salesforce.dva.argus.service.alert.notifier.EmailNotifier', | ||
| 'metricsToAnnotate': [], | ||
| 'cooldownPeriod': 0L, | ||
| 'cooldownPeriod': 0, | ||
| 'sractionable': False, | ||
| 'customText': 'None' | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| # | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need to check this file in |
||
| # Copyright (c) 2016, salesforce.com, inc. | ||
| # All rights reserved. | ||
| # Licensed under the BSD 3-Clause license. | ||
| # For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
| # | ||
| # Use the package in this repo (argusclient directory) | ||
|
|
||
| from argusclient import * | ||
| from argusclient.model import Permission | ||
|
|
||
| """ | ||
| LOGGING IN!~ | ||
| """ | ||
| username = "s.basu" | ||
| password = "" | ||
| argus = ArgusServiceClient(user="s.basu", | ||
| password=password, | ||
| endpoint="http://shared1-argusws1-1-prd.eng.sfdc.net:8080/argusws/") | ||
| # endpoint = "https://argus-ws.data.sfdc.net/argusws/") | ||
| print ('logging in...') | ||
| argus.login() | ||
| print ('logged in!') | ||
| """ | ||
| Set endpoint and params | ||
| """ | ||
| argus.grouppermissions = GroupPermissionsServiceClient(argus, get_all_req_opts= dict(groupID="234-567-891-667-001", type="group", | ||
| permissionsID=[0,1,2])) | ||
|
|
||
| print(argus.grouppermissions) | ||
| print(type(argus.grouppermissions)) | ||
|
|
||
| # argus.alerts = AlertsServiceClient(argus, get_all_req_opts={REQ_PARAMS: dict(shared=False, | ||
| # alertNameContains='TestAlert', | ||
| # limit=1), | ||
| # REQ_PATH: "allinfo"}) | ||
| # permission_group_D = { | ||
| # "id": 10, | ||
| # "createdById": 6906380, | ||
| # "createdDate": 1616098911000, | ||
| # "modifiedById": 6906380, | ||
| # "modifiedDate": 1616098911000, | ||
| # "type": "group", | ||
| # "groupId": "c8be7819-bf5e-40aa-8535-88694d34280f", | ||
| # "username": '', | ||
| # "permissionIds": [], | ||
| # "entityId": 23590046 | ||
| # } | ||
|
|
||
| GroupPermission_D = { | ||
| "type": "group", | ||
| "groupId": "ebd7db70-290b-4d85-b366-b4be9d5967e4", | ||
| "permissionIds": [0,1,2], | ||
| "permissionNames": [] | ||
| } | ||
| GroupPermission_R ={ | ||
| "type": "group", | ||
| "groupId": "ebd7db70-290b-4d85-b366-b4be9d5967e4", | ||
| "permissionIds": [1], | ||
| "permissionNames": [] | ||
| } | ||
| groupID1 = "ebd7db70-290b-4d85-b366-b4be9d5967e4" | ||
| grouppermission = GroupPermission.from_dict(GroupPermission_D) | ||
| perm = Permission.from_dict(GroupPermission_R) | ||
| #groupPerm = argus.grouppermissions.get_permissions_for_group(groupID1) | ||
| #print("groupPerms are "+ str(groupPerm)) | ||
| #grouppermission = GroupPermission(GroupPermission_D.get("groupId"),[0,1,2]) | ||
| groupPerm1 = argus.grouppermissions.add_permissions_for_group(grouppermission) | ||
| print("groupPerms are "+ str(groupPerm1)) | ||
|
|
||
| deletedPerm = argus.grouppermissions.delete_permissions_for_group(perm) #this is not working as adding group_permission returns a permission object instead of groupPermission object ? | ||
| print("removed groupPerms are "+ str(deletedPerm)) | ||
|
|
||
| #argus.permissions = PermissionsServiceClient(argus) | ||
| #group_perm = Permission.from_dict(permission_group_D) | ||
| # delattr(group_perm, "id") | ||
| # deleted_perm = argus.permissions.delete(23590046, group_perm) | ||
| # | ||
| # print "updating perm" | ||
| # updated_perm = argus.permissions.add(23590046, group_perm) | ||
| # print "updated permission is "+ str(updated_perm) | ||
| #print ("making call to get perms for entities") | ||
| #all_perms = argus.permissions.get_permissions_for_entities([26947204]) | ||
| #print (all_perms) | ||
| #print (type(group_perm)) | ||
| #for id, val group_perm.items(): | ||
| #print (id) | ||
| # print (type(val)) | ||
| # for perm in val: | ||
| # perm_type = perm.type | ||
| # if perm_type == 'group': | ||
| ## print (perm.groupId) | ||
| # else: | ||
| # print (perm.username) | ||
| # argus.permissions = PermissionsServiceClient(argus, get_all_req_opts={REQ_PARAMS: dict(shared=False), | ||
| # # REQ_PATH: "entityIds", | ||
| # # REQ_METHOD: "post", | ||
| # # REQ_BODY: [14796957, 14796958]}) | ||
| # argus.dashboards = DashboardsServiceClient(argus, get_all_req_opts=dict(REQ_PARAMS=dict(username="j.ma", shared=False, limit=3))) # note - limit does not work | ||
| """ | ||
| Making the call | ||
| """ | ||
| if __name__ == '__main__': | ||
|
|
||
| # print 'calling items()' | ||
| # res = argus.alerts.items() | ||
| # res = argus.permissions.items() | ||
| # res = argus.dashboards.items() | ||
| print ("calling groupPerms") | ||
| # res1 = groupPerm1 | ||
|
|
||
| #print ('size of result: ', len()) | ||
| #res = argus.permissions.get(16348603) | ||
| # Get notif | ||
| # alert = res[0][1] | ||
| # print 'notifs:', alert.notifications.items() | ||
| # notifs = alert.notifications.items() | ||
| # notif = notifs[0][1] | ||
| # print '\nresult: ', res | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this required? Looks incomplete