mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 12:21:35 +00:00
Make contact delegation consistent with email delegation (#1296)
Add auth to discovery document uid allowed in create/delete as input is converted to primaryemail
This commit is contained in:
@@ -1437,6 +1437,11 @@ gam <UserTypeEntity> delete|del delegate|delegates <EmailAddress>
|
|||||||
gam <UserTypeEntity> show delegates|delegate [csv]
|
gam <UserTypeEntity> show delegates|delegate [csv]
|
||||||
gam <UserTypeEntity> print delegates [todrive]
|
gam <UserTypeEntity> print delegates [todrive]
|
||||||
|
|
||||||
|
gam <UserTypeEntity> create|add contactdelegate <EmailAddress>
|
||||||
|
gam <UserTypeEntity> delete|del contactdelegate <EmailAddress>
|
||||||
|
gam <UserTypeEntity> show contactdelegates [csv]
|
||||||
|
gam <UserTypeEntity> print contactdelegates [todrive]
|
||||||
|
|
||||||
gam <UserTypeEntity> [create|add] filter [from <EmailAddress>] [to <EmailAddress>] [subject <String>] [haswords|query <List>] [nowords|negatedquery <List>] [musthaveattachment|hasattachment] [excludechats] [size larger|smaller <ByteCount>]
|
gam <UserTypeEntity> [create|add] filter [from <EmailAddress>] [to <EmailAddress>] [subject <String>] [haswords|query <List>] [nowords|negatedquery <List>] [musthaveattachment|hasattachment] [excludechats] [size larger|smaller <ByteCount>]
|
||||||
[label <LabelID>] [important|notimportant] [star] [trash] [markread] [archive] [neverspam] [forward <EmailAddress>]
|
[label <LabelID>] [important|notimportant] [star] [trash] [markread] [archive] [neverspam] [forward <EmailAddress>]
|
||||||
gam <UserTypeEntity> delete filters <FilterIDEntity>
|
gam <UserTypeEntity> delete filters <FilterIDEntity>
|
||||||
|
|||||||
@@ -1,4 +1,16 @@
|
|||||||
{
|
{
|
||||||
|
"auth": {
|
||||||
|
"oauth2": {
|
||||||
|
"scopes": {
|
||||||
|
"https://www.googleapis.com/auth/admin.contact.delegation": {
|
||||||
|
"description": "View and manage your Contact Delegation"
|
||||||
|
},
|
||||||
|
"https://www.googleapis.com/auth/admin.contact.delegation.readonly": {
|
||||||
|
"description": "View your Contact Delegation"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"basePath": "",
|
"basePath": "",
|
||||||
"baseUrl": "https://admin.googleapis.com/admin/contacts/v1/",
|
"baseUrl": "https://admin.googleapis.com/admin/contacts/v1/",
|
||||||
"batchPath": "batch",
|
"batchPath": "batch",
|
||||||
|
|||||||
@@ -11602,8 +11602,8 @@ def ProcessGAMCommand(args):
|
|||||||
printShowTeamDrives(users, False)
|
printShowTeamDrives(users, False)
|
||||||
elif showWhat in ['teamdriveinfo']:
|
elif showWhat in ['teamdriveinfo']:
|
||||||
doGetTeamDriveInfo(users)
|
doGetTeamDriveInfo(users)
|
||||||
elif showWhat in ['contactdelegation']:
|
elif showWhat in ['contactdelegate', 'contactdelegates']:
|
||||||
gapi_contactdelegation.print_(users)
|
gapi_contactdelegation.print_(users, False)
|
||||||
else:
|
else:
|
||||||
controlflow.invalid_argument_exit(showWhat, 'gam <users> show')
|
controlflow.invalid_argument_exit(showWhat, 'gam <users> show')
|
||||||
elif command == 'print':
|
elif command == 'print':
|
||||||
@@ -11632,8 +11632,8 @@ def ProcessGAMCommand(args):
|
|||||||
printShowTokens(5, 'users', users, True)
|
printShowTokens(5, 'users', users, True)
|
||||||
elif printWhat in ['teamdrive', 'teamdrives']:
|
elif printWhat in ['teamdrive', 'teamdrives']:
|
||||||
printShowTeamDrives(users, True)
|
printShowTeamDrives(users, True)
|
||||||
elif printWhat in ['contactdelegation']:
|
elif printWhat in ['contactdelegate', 'contactdelegates']:
|
||||||
gapi_contactdelegation.print_(users)
|
gapi_contactdelegation.print_(users, True)
|
||||||
else:
|
else:
|
||||||
controlflow.invalid_argument_exit(printWhat,
|
controlflow.invalid_argument_exit(printWhat,
|
||||||
'gam <users> print')
|
'gam <users> print')
|
||||||
@@ -11748,7 +11748,7 @@ def ProcessGAMCommand(args):
|
|||||||
addSmime(users)
|
addSmime(users)
|
||||||
elif addWhat == 'teamdrive':
|
elif addWhat == 'teamdrive':
|
||||||
doCreateTeamDrive(users)
|
doCreateTeamDrive(users)
|
||||||
elif addWhat == 'contactdelegation':
|
elif addWhat == 'contactdelegate':
|
||||||
gapi_contactdelegation.create(users)
|
gapi_contactdelegation.create(users)
|
||||||
else:
|
else:
|
||||||
controlflow.invalid_argument_exit(addWhat,
|
controlflow.invalid_argument_exit(addWhat,
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
"""Contact Delegation API calls"""
|
"""Contact Delegation API calls"""
|
||||||
|
|
||||||
import csv
|
|
||||||
import os.path
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import gam
|
import gam
|
||||||
@@ -17,7 +15,7 @@ def build():
|
|||||||
|
|
||||||
def create(users):
|
def create(users):
|
||||||
condel = build()
|
condel = build()
|
||||||
delegate = gam.normalizeEmailAddressOrUID(sys.argv[5], noUid=True)
|
delegate = gam.normalizeEmailAddressOrUID(sys.argv[5])
|
||||||
delegate = gapi_directory_users.get_primary(delegate)
|
delegate = gapi_directory_users.get_primary(delegate)
|
||||||
if not delegate:
|
if not delegate:
|
||||||
controlflow.system_error_exit(5,
|
controlflow.system_error_exit(5,
|
||||||
@@ -39,7 +37,7 @@ def create(users):
|
|||||||
|
|
||||||
def delete(users):
|
def delete(users):
|
||||||
condel = build()
|
condel = build()
|
||||||
delegate = gam.normalizeEmailAddressOrUID(sys.argv[5], noUid=True)
|
delegate = gam.normalizeEmailAddressOrUID(sys.argv[5])
|
||||||
delegate = gapi_directory_users.get_primary(delegate)
|
delegate = gapi_directory_users.get_primary(delegate)
|
||||||
if not delegate:
|
if not delegate:
|
||||||
controlflow.system_error_exit(5,
|
controlflow.system_error_exit(5,
|
||||||
@@ -58,20 +56,26 @@ def delete(users):
|
|||||||
delegate=delegate)
|
delegate=delegate)
|
||||||
|
|
||||||
|
|
||||||
def print_(users):
|
def print_(users, csvFormat):
|
||||||
condel = build()
|
condel = build()
|
||||||
titles = ['user', 'delegate']
|
if csvFormat:
|
||||||
csv_rows = []
|
|
||||||
todrive = False
|
todrive = False
|
||||||
|
csv_rows = []
|
||||||
|
titles = ['User', 'delegateAddress']
|
||||||
|
else:
|
||||||
|
csvStyle = False
|
||||||
i = 5
|
i = 5
|
||||||
while i < len(sys.argv):
|
while i < len(sys.argv):
|
||||||
myarg = sys.argv[i].lower().replace('_', '')
|
myarg = sys.argv[i].lower().replace('_', '')
|
||||||
if myarg == 'todrive':
|
if not csvFormat and myarg == 'csv':
|
||||||
|
csvStyle = True
|
||||||
|
i += 1
|
||||||
|
elif csvFormat and myarg == 'todrive':
|
||||||
todrive = True
|
todrive = True
|
||||||
i += 1
|
i += 1
|
||||||
else:
|
else:
|
||||||
controlflow.invalid_argument_exit(sys.argv[i],
|
controlflow.invalid_argument_exit(sys.argv[i],
|
||||||
'gam print browsers')
|
'gam print contactdelegation')
|
||||||
page_message = gapi.got_total_items_msg('Contact Delegates', '...\n')
|
page_message = gapi.got_total_items_msg('Contact Delegates', '...\n')
|
||||||
for user in users:
|
for user in users:
|
||||||
delegates = gapi.get_all_pages(condel.delegates(), 'list',
|
delegates = gapi.get_all_pages(condel.delegates(), 'list',
|
||||||
@@ -79,5 +83,14 @@ def print_(users):
|
|||||||
page_message=page_message,
|
page_message=page_message,
|
||||||
user=user)
|
user=user)
|
||||||
for delegate in delegates:
|
for delegate in delegates:
|
||||||
csv_rows.append({'user': user, 'delegate': delegate.get('email')})
|
if csvFormat:
|
||||||
|
csv_rows.append({'User': user, 'delegateAddress': delegate['email']})
|
||||||
|
else:
|
||||||
|
if csvStyle:
|
||||||
|
print(f'{user},{delegate["email"]}')
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
f'Delegator: {user}\n Delegate Email: {delegate["email"]}\n'
|
||||||
|
)
|
||||||
|
if csvFormat:
|
||||||
display.write_csv_file(csv_rows, titles, 'Contact Delegates', todrive)
|
display.write_csv_file(csv_rows, titles, 'Contact Delegates', todrive)
|
||||||
|
|||||||
Reference in New Issue
Block a user