mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-06 13:51:36 +00:00
Update calendar ACL commands (#953)
* Update calendar ACL commands Your change was not backwards compatible; sys.argv[4] was previously ignored * Code cleanup
This commit is contained in:
@@ -798,7 +798,7 @@ Specify a collection of Users by directly specifying them or by specifiying item
|
|||||||
<UserBasicAttribute>|
|
<UserBasicAttribute>|
|
||||||
<UserMultiAttribute>
|
<UserMultiAttribute>
|
||||||
|
|
||||||
gam version [check] [simple]
|
gam version [check|checkrc|simple|extended] [location <HostName>]
|
||||||
gam help
|
gam help
|
||||||
|
|
||||||
gam batch <FileName>|- [charset <Charset>]
|
gam batch <FileName>|- [charset <Charset>]
|
||||||
@@ -939,7 +939,9 @@ gam print aliases|nicknames [todrive] [shownoneditable] [nogroups] [nousers] [(q
|
|||||||
gam calendar <CalendarItem> add <CalendarACLRole> ([user] <EmailAddress>)|(group <EmailAddress>)|(domain [<DomainName>])|default [sendnotifications <Boolean>]
|
gam calendar <CalendarItem> add <CalendarACLRole> ([user] <EmailAddress>)|(group <EmailAddress>)|(domain [<DomainName>])|default [sendnotifications <Boolean>]
|
||||||
gam calendar <CalendarItem> update <CalendarACLRole> ([user] <EmailAddress>)|(group <EmailAddress>)|(domain [<DomainName>])|default [sendnotifications <Boolean>]
|
gam calendar <CalendarItem> update <CalendarACLRole> ([user] <EmailAddress>)|(group <EmailAddress>)|(domain [<DomainName>])|default [sendnotifications <Boolean>]
|
||||||
gam calendar <CalendarItem> del|delete <CalendarACLRole> <EmailAddress>|(domain [<DomainName>])|default
|
gam calendar <CalendarItem> del|delete <CalendarACLRole> <EmailAddress>|(domain [<DomainName>])|default
|
||||||
|
gam calendar <CalendarItem> del|delete id <CalendarACLRuleID>
|
||||||
gam calendar <CalendarItem> showacl
|
gam calendar <CalendarItem> showacl
|
||||||
|
gam calendar <CalendarItem> printacl [todrive]
|
||||||
|
|
||||||
<EventNotificationAttribute> ::=
|
<EventNotificationAttribute> ::=
|
||||||
notifyattendees|(sendnotifications <Boolean>)|(sendupdates all|enternalonly|none)
|
notifyattendees|(sendnotifications <Boolean>)|(sendupdates all|enternalonly|none)
|
||||||
|
|||||||
33
src/gam.py
33
src/gam.py
@@ -3705,20 +3705,29 @@ def formatACLRule(rule):
|
|||||||
return '(Scope: {0}:{1}, Role: {2})'.format(rule['scope']['type'], rule['scope']['value'], rule['role'])
|
return '(Scope: {0}:{1}, Role: {2})'.format(rule['scope']['type'], rule['scope']['value'], rule['role'])
|
||||||
return '(Scope: {0}, Role: {1})'.format(rule['scope']['type'], rule['role'])
|
return '(Scope: {0}, Role: {1})'.format(rule['scope']['type'], rule['role'])
|
||||||
|
|
||||||
def doCalendarShowPrintACL(csvOut=False):
|
def doCalendarPrintShowACLs(csvFormat):
|
||||||
calendarId, cal = buildCalendarDataGAPIObject(sys.argv[2])
|
calendarId, cal = buildCalendarDataGAPIObject(sys.argv[2])
|
||||||
if not cal:
|
if not cal:
|
||||||
return
|
return
|
||||||
|
toDrive = False
|
||||||
|
i = 4
|
||||||
|
while i < len(sys.argv):
|
||||||
|
myarg = sys.argv[i].lower().replace('_', '')
|
||||||
|
if csvFormat and myarg == 'todrive':
|
||||||
|
toDrive = True
|
||||||
|
i += 1
|
||||||
|
else:
|
||||||
|
systemErrorExit(2, '%s is not a valid argument for "gam calendar <email> %s"' % (sys.argv[i], ['showacl', 'printacl'][csvFormat]))
|
||||||
acls = callGAPIpages(cal.acl(), 'list', 'items', calendarId=calendarId)
|
acls = callGAPIpages(cal.acl(), 'list', 'items', calendarId=calendarId)
|
||||||
i = 0
|
i = 0
|
||||||
if csvOut:
|
if csvFormat:
|
||||||
titles = []
|
titles = []
|
||||||
rows = []
|
rows = []
|
||||||
else:
|
else:
|
||||||
count = len(acls)
|
count = len(acls)
|
||||||
for rule in acls:
|
for rule in acls:
|
||||||
i += 1
|
i += 1
|
||||||
if csvOut:
|
if csvFormat:
|
||||||
row = flatten_json(rule, None)
|
row = flatten_json(rule, None)
|
||||||
for key in row:
|
for key in row:
|
||||||
if key not in titles:
|
if key not in titles:
|
||||||
@@ -3726,8 +3735,8 @@ def doCalendarShowPrintACL(csvOut=False):
|
|||||||
rows.append(row)
|
rows.append(row)
|
||||||
else:
|
else:
|
||||||
print('Calendar: {0}, ACL: {1}{2}'.format(calendarId, formatACLRule(rule), currentCount(i, count)))
|
print('Calendar: {0}, ACL: {1}{2}'.format(calendarId, formatACLRule(rule), currentCount(i, count)))
|
||||||
if csvOut:
|
if csvFormat:
|
||||||
writeCSVfile(rows, titles, '%s Calendar ACLs' % calendarId, False)
|
writeCSVfile(rows, titles, '%s Calendar ACLs' % calendarId, toDrive)
|
||||||
|
|
||||||
def _getCalendarACLScope(i, body):
|
def _getCalendarACLScope(i, body):
|
||||||
body['scope'] = {}
|
body['scope'] = {}
|
||||||
@@ -3783,15 +3792,15 @@ def doCalendarDelACL():
|
|||||||
calendarId, cal = buildCalendarDataGAPIObject(sys.argv[2])
|
calendarId, cal = buildCalendarDataGAPIObject(sys.argv[2])
|
||||||
if not cal:
|
if not cal:
|
||||||
return
|
return
|
||||||
if sys.argv[4].lower() == 'user':
|
if sys.argv[4].lower() == 'id':
|
||||||
|
ruleId = sys.argv[5]
|
||||||
|
print('Removing rights for %s to %s' % (ruleId, calendarId))
|
||||||
|
callGAPI(cal.acl(), 'delete', calendarId=calendarId, ruleId=ruleId)
|
||||||
|
else:
|
||||||
body = {'role': 'none'}
|
body = {'role': 'none'}
|
||||||
_getCalendarACLScope(5, body)
|
_getCalendarACLScope(5, body)
|
||||||
print('Calendar: {0}, {1} ACL: {2}'.format(calendarId, 'Delete', formatACLScope(body)))
|
print('Calendar: {0}, {1} ACL: {2}'.format(calendarId, 'Delete', formatACLScope(body)))
|
||||||
callGAPI(cal.acl(), 'insert', calendarId=calendarId, body=body, sendNotifications=False)
|
callGAPI(cal.acl(), 'insert', calendarId=calendarId, body=body, sendNotifications=False)
|
||||||
elif sys.argv[4].lower() == 'id':
|
|
||||||
ruleId = sys.argv[5]
|
|
||||||
print('Removing rights for %s to %s' % (ruleId, calendarId))
|
|
||||||
callGAPI(cal.acl(), 'delete', calendarId=calendarId, ruleId=ruleId)
|
|
||||||
|
|
||||||
def doCalendarWipeData():
|
def doCalendarWipeData():
|
||||||
calendarId, cal = buildCalendarDataGAPIObject(sys.argv[2])
|
calendarId, cal = buildCalendarDataGAPIObject(sys.argv[2])
|
||||||
@@ -14061,9 +14070,9 @@ def ProcessGAMCommand(args):
|
|||||||
elif command == 'calendar':
|
elif command == 'calendar':
|
||||||
argument = sys.argv[3].lower()
|
argument = sys.argv[3].lower()
|
||||||
if argument == 'showacl':
|
if argument == 'showacl':
|
||||||
doCalendarShowPrintACL(csvOut=False)
|
doCalendarPrintShowACLs(False)
|
||||||
elif argument == 'printacl':
|
elif argument == 'printacl':
|
||||||
doCalendarShowPrintACL(csvOut=True)
|
doCalendarPrintShowACLs(True)
|
||||||
elif argument == 'add':
|
elif argument == 'add':
|
||||||
doCalendarAddACL('Add')
|
doCalendarAddACL('Add')
|
||||||
elif argument in ['del', 'delete']:
|
elif argument in ['del', 'delete']:
|
||||||
|
|||||||
Reference in New Issue
Block a user