-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Group Perms update for argus client #34
base: master
Are you sure you want to change the base?
Changes from all commits
9cc4512
59c15f7
be0c36b
14945b0
b9405fe
3bad2fe
ac2757d
f40eaf0
9041b5c
ab94bcc
63e83f4
05a66f1
a55dea1
bc5ed82
fca2bfa
b4a744b
70413aa
f614e36
98c0830
0db8565
f42c3f7
591392a
54d1044
fe1e70d
3364ce0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ dist | |
docs/_build | ||
docs/README.rst | ||
.idea/ | ||
venv/ |
Large diffs are not rendered by default.
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", | ||
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': ['[email protected]'], | ||
'notifierName': 'com.salesforce.dva.argus.service.alert.notifier.EmailNotifier', | ||
'metricsToAnnotate': [], | ||
'cooldownPeriod': 0L, | ||
'cooldownPeriod': 0, | ||
'sractionable': False, | ||
'customText': 'None' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# | ||
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 |
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