Further Team Drive admin work

This commit is contained in:
Jay Lee
2017-11-03 20:07:17 -04:00
parent 0ca083f5e9
commit 6a90a76fb1
2 changed files with 195 additions and 2 deletions

View File

@@ -7293,6 +7293,26 @@ and accept the Terms of Service (ToS). As soon as you've accepted the ToS popup,
raw_input(u'Press Enter when done...')
print u'That\'s it! Your GAM Project is created and ready to use.'
def doGetTeamDriveInfo(users):
teamDriveId = sys.argv[5]
useDomainAdminAccess = False
i = 6
while i < len(sys.argv):
if sys.argv[i].lower().replace(u'_', u'') == u'asadmin':
useDomainAdminAccess = True
i += 1
else:
print u'ERROR: %s is not a valid command for "gam <users> show teamdrive"' % sys.argv[i]
sys.exit(3)
for user in users:
drive = buildGAPIServiceObject(u'drive3', user)
if not drive:
print u'Failed to access Drive as %s' % user
continue
result = callGAPI(drive.teamdrives(), u'get', teamDriveId=teamDriveId,
useDomainAdminAccess=useDomainAdminAccess, fields=u'*')
print_json(None, result)
def doCreateTeamDrive(users):
body = {u'name': sys.argv[5]}
i = 6
@@ -7306,6 +7326,9 @@ def doCreateTeamDrive(users):
sys.exit(3)
for user in users:
drive = buildGAPIServiceObject(u'drive3', user)
if not drive:
print u'Failed to access Drive as %s' % user
continue
requestId = unicode(uuid.uuid4())
result = callGAPI(drive.teamdrives(), u'create', requestId=requestId, body=body, fields=u'id')
print u'Created Team Drive %s with id %s' % (body[u'name'], result[u'id'])
@@ -7321,6 +7344,19 @@ def doUpdateTeamDrive(users):
elif sys.argv[i].lower() == u'theme':
body[u'themeId'] = sys.argv[i+1]
i += 2
elif sys.argv[i].lower() == u'customtheme':
body[u'backgroundImageFile'] = {
u'id': sys.argv[i+1],
u'xCoordinate': float(sys.argv[i+2]),
u'yCoordinate': float(sys.argv[i+3]),
u'width': float(sys.argv[i+4])
}
i += 5
elif sys.argv[i].lower() == u'color':
body[u'colorRgb'] = sys.argv[i+1]
if body[u'colorRgb'] in WEBCOLOR_MAP.keys():
body[u'colorRgb'] = WEBCOLOR_MAP[body[u'colorRgb']]
i += 2
else:
print u'ERROR: %s is not a valid argument for "gam <users> update drivefile"'
sys.exit(3)
@@ -7340,6 +7376,7 @@ def doUpdateTeamDrive(users):
def printShowTeamDrives(users, csvFormat):
todrive = False
useDomainAdminAccess = False
q = None
i = 5
while i < len(sys.argv):
if sys.argv[i].lower() == u'todrive':
@@ -7348,6 +7385,9 @@ def printShowTeamDrives(users, csvFormat):
elif sys.argv[i].lower().replace(u'_', u'') == u'asadmin':
useDomainAdminAccess = True
i += 1
elif sys.argv[i].lower() == u'query':
q = sys.argv[i+1]
i += 2
else:
print u'ERROR: %s is not a valid argument for "gam <users> print|show teamdrives"'
sys.exit(3)
@@ -7358,7 +7398,8 @@ def printShowTeamDrives(users, csvFormat):
if not drive:
continue
results = callGAPIpages(drive.teamdrives(), u'list', u'teamDrives',
useDomainAdminAccess=useDomainAdminAccess, fields=u'*', soft_errors=True)
useDomainAdminAccess=useDomainAdminAccess, fields=u'*',
q=q, soft_errors=True)
if not results:
continue
for td in results:
@@ -12139,6 +12180,8 @@ def ProcessGAMCommand(args):
printShowForwardingAddresses(users, False)
elif showWhat in [u'teamdrive', u'teamdrives']:
printShowTeamDrives(users, False)
elif showWhat in [u'teamdriveinfo']:
doGetTeamDriveInfo(users)
else:
print u'ERROR: %s is not a valid argument for "gam <users> show"' % showWhat
sys.exit(2)
@@ -12243,7 +12286,7 @@ def ProcessGAMCommand(args):
else:
print u'ERROR: %s is not a valid argument for "gam <users> delete"' % delWhat
sys.exit(2)
elif command == u'add':
elif command in [u'add', u'create']:
addWhat = sys.argv[4].lower()
if addWhat == u'calendar':
addCalendar(users)

View File

@@ -788,3 +788,153 @@ USER_RELATION_TYPES = [u'admin_assistant', u'assistant', u'brother', u'child',
USER_WEBSITE_TYPES = [u'app_install_page', u'blog', u'ftp', u'home',
u'home_page', u'other', u'profile', u'reservations',
u'work']
WEBCOLOR_MAP = {
u'aliceblue': u'#f0f8ff',
u'antiquewhite': u'#faebd7',
u'aqua': u'#00ffff',
u'aquamarine': u'#7fffd4',
u'azure': u'#f0ffff',
u'beige': u'#f5f5dc',
u'bisque': u'#ffe4c4',
u'black': u'#000000',
u'blanchedalmond': u'#ffebcd',
u'blue': u'#0000ff',
u'blueviolet': u'#8a2be2',
u'brown': u'#a52a2a',
u'burlywood': u'#deb887',
u'cadetblue': u'#5f9ea0',
u'chartreuse': u'#7fff00',
u'chocolate': u'#d2691e',
u'coral': u'#ff7f50',
u'cornflowerblue': u'#6495ed',
u'cornsilk': u'#fff8dc',
u'crimson': u'#dc143c',
u'cyan': u'#00ffff',
u'darkblue': u'#00008b',
u'darkcyan': u'#008b8b',
u'darkgoldenrod': u'#b8860b',
u'darkgray': u'#a9a9a9',
u'darkgrey': u'#a9a9a9',
u'darkgreen': u'#006400',
u'darkkhaki': u'#bdb76b',
u'darkmagenta': u'#8b008b',
u'darkolivegreen': u'#556b2f',
u'darkorange': u'#ff8c00',
u'darkorchid': u'#9932cc',
u'darkred': u'#8b0000',
u'darksalmon': u'#e9967a',
u'darkseagreen': u'#8fbc8f',
u'darkslateblue': u'#483d8b',
u'darkslategray': u'#2f4f4f',
u'darkslategrey': u'#2f4f4f',
u'darkturquoise': u'#00ced1',
u'darkviolet': u'#9400d3',
u'deeppink': u'#ff1493',
u'deepskyblue': u'#00bfff',
u'dimgray': u'#696969',
u'dimgrey': u'#696969',
u'dodgerblue': u'#1e90ff',
u'firebrick': u'#b22222',
u'floralwhite': u'#fffaf0',
u'forestgreen': u'#228b22',
u'fuchsia': u'#ff00ff',
u'gainsboro': u'#dcdcdc',
u'ghostwhite': u'#f8f8ff',
u'gold': u'#ffd700',
u'goldenrod': u'#daa520',
u'gray': u'#808080',
u'grey': u'#808080',
u'green': u'#008000',
u'greenyellow': u'#adff2f',
u'honeydew': u'#f0fff0',
u'hotpink': u'#ff69b4',
u'indianred': u'#cd5c5c',
u'indigo': u'#4b0082',
u'ivory': u'#fffff0',
u'khaki': u'#f0e68c',
u'lavender': u'#e6e6fa',
u'lavenderblush': u'#fff0f5',
u'lawngreen': u'#7cfc00',
u'lemonchiffon': u'#fffacd',
u'lightblue': u'#add8e6',
u'lightcoral': u'#f08080',
u'lightcyan': u'#e0ffff',
u'lightgoldenrodyellow': u'#fafad2',
u'lightgray': u'#d3d3d3',
u'lightgrey': u'#d3d3d3',
u'lightgreen': u'#90ee90',
u'lightpink': u'#ffb6c1',
u'lightsalmon': u'#ffa07a',
u'lightseagreen': u'#20b2aa',
u'lightskyblue': u'#87cefa',
u'lightslategray': u'#778899',
u'lightslategrey': u'#778899',
u'lightsteelblue': u'#b0c4de',
u'lightyellow': u'#ffffe0',
u'lime': u'#00ff00',
u'limegreen': u'#32cd32',
u'linen': u'#faf0e6',
u'magenta': u'#ff00ff',
u'maroon': u'#800000',
u'mediumaquamarine': u'#66cdaa',
u'mediumblue': u'#0000cd',
u'mediumorchid': u'#ba55d3',
u'mediumpurple': u'#9370db',
u'mediumseagreen': u'#3cb371',
u'mediumslateblue': u'#7b68ee',
u'mediumspringgreen': u'#00fa9a',
u'mediumturquoise': u'#48d1cc',
u'mediumvioletred': u'#c71585',
u'midnightblue': u'#191970',
u'mintcream': u'#f5fffa',
u'mistyrose': u'#ffe4e1',
u'moccasin': u'#ffe4b5',
u'navajowhite': u'#ffdead',
u'navy': u'#000080',
u'oldlace': u'#fdf5e6',
u'olive': u'#808000',
u'olivedrab': u'#6b8e23',
u'orange': u'#ffa500',
u'orangered': u'#ff4500',
u'orchid': u'#da70d6',
u'palegoldenrod': u'#eee8aa',
u'palegreen': u'#98fb98',
u'paleturquoise': u'#afeeee',
u'palevioletred': u'#db7093',
u'papayawhip': u'#ffefd5',
u'peachpuff': u'#ffdab9',
u'peru': u'#cd853f',
u'pink': u'#ffc0cb',
u'plum': u'#dda0dd',
u'powderblue': u'#b0e0e6',
u'purple': u'#800080',
u'red': u'#ff0000',
u'rosybrown': u'#bc8f8f',
u'royalblue': u'#4169e1',
u'saddlebrown': u'#8b4513',
u'salmon': u'#fa8072',
u'sandybrown': u'#f4a460',
u'seagreen': u'#2e8b57',
u'seashell': u'#fff5ee',
u'sienna': u'#a0522d',
u'silver': u'#c0c0c0',
u'skyblue': u'#87ceeb',
u'slateblue': u'#6a5acd',
u'slategray': u'#708090',
u'slategrey': u'#708090',
u'snow': u'#fffafa',
u'springgreen': u'#00ff7f',
u'steelblue': u'#4682b4',
u'tan': u'#d2b48c',
u'teal': u'#008080',
u'thistle': u'#d8bfd8',
u'tomato': u'#ff6347',
u'turquoise': u'#40e0d0',
u'violet': u'#ee82ee',
u'wheat': u'#f5deb3',
u'white': u'#ffffff',
u'whitesmoke': u'#f5f5f5',
u'yellow': u'#ffff00',
u'yellowgreen': u'#9acd32',
}