Add gs_get_before_update to create group (#872)

Appease pylint
This commit is contained in:
Ross Scroggs
2019-04-01 07:38:49 -07:00
committed by Jay Lee
parent 9f988bb464
commit b3ad45f2cc

View File

@@ -963,14 +963,13 @@ def callGAPIpages(service, function, items=u'items',
page_token = None
total_items = 0
while True:
page = callGAPI(
service,
function,
soft_errors=soft_errors,
throw_reasons=throw_reasons,
retry_reasons=retry_reasons,
pageToken=page_token,
**kwargs)
page = callGAPI(service,
function,
soft_errors=soft_errors,
throw_reasons=throw_reasons,
retry_reasons=retry_reasons,
pageToken=page_token,
**kwargs)
if page:
page_token = page.get(u'nextPageToken')
page_items = page.get(items, [])
@@ -988,10 +987,8 @@ def callGAPIpages(service, function, items=u'items',
if message_attribute:
first_item = page_items[0] if num_page_items > 0 else {}
last_item = page_items[-1] if num_page_items > 1 else first_item
show_message = show_message.replace(
u'%%first_item%%', str(first_item.get(message_attribute, u'')))
show_message = show_message.replace(
u'%%last_item%%', str(last_item.get(message_attribute, u'')))
show_message = show_message.replace(u'%%first_item%%', str(first_item.get(message_attribute, u'')))
show_message = show_message.replace(u'%%last_item%%', str(last_item.get(message_attribute, u'')))
sys.stderr.write(u'\r')
sys.stderr.flush()
sys.stderr.write(show_message)
@@ -1024,12 +1021,11 @@ def callGAPIitems(service, function, items=u'items',
Returns:
The list of items in the first page of a response.
"""
results = callGAPI(
service,
function,
throw_reasons=throw_reasons,
retry_reasons=retry_reasons,
**kwargs)
results = callGAPI(service,
function,
throw_reasons=throw_reasons,
retry_reasons=retry_reasons,
**kwargs)
if results:
return results.get(items, [])
return []
@@ -8406,7 +8402,7 @@ def getGroupAttrValue(myarg, value, gs_object, gs_body, function):
def doCreateGroup():
cd = buildGAPIObject(u'directory')
body = {u'email': normalizeEmailAddressOrUID(sys.argv[3], noUid=True)}
got_name = False
gs_get_before_update = got_name = False
i = 4
gs_body = {}
gs = None
@@ -8430,6 +8426,9 @@ def doCreateGroup():
else:
body[u'description'] = description
i += 2
elif myarg == u'getbeforeupdate':
gs_get_before_update = True
i += 1
else:
if not gs:
gs = buildGAPIObject(u'groupssettings')
@@ -8441,12 +8440,14 @@ def doCreateGroup():
print u"Creating group %s" % body[u'email']
callGAPI(cd.groups(), u'insert', body=body, fields=u'email')
if gs and not GroupIsAbuseOrPostmaster(body[u'email']):
settings = callGAPI(gs.groups(), u'get',
retry_reasons=[u'serviceLimit'],
groupUniqueId=body[u'email'], fields=u'*')
if settings is not None:
settings.update(gs_body)
callGAPI(gs.groups(), u'update', retry_reasons=[u'serviceLimit'], groupUniqueId=body[u'email'], body=settings)
if gs_get_before_update:
current_settings = callGAPI(gs.groups(), u'get',
retry_reasons=[u'serviceLimit'],
groupUniqueId=body[u'email'], fields=u'*')
if current_settings is not None:
gs_body = dict(current_settings.items() + gs_body.items())
if gs_body:
callGAPI(gs.groups(), u'update', retry_reasons=[u'serviceLimit'], groupUniqueId=body[u'email'], body=gs_body)
def doCreateAlias():
cd = buildGAPIObject(u'directory')
@@ -9042,8 +9043,8 @@ def doUpdateGroup():
if not GroupIsAbuseOrPostmaster(group):
if gs_get_before_update:
current_settings = callGAPI(gs.groups(), u'get',
retry_reasons=[u'serviceLimit'],
groupUniqueId=group, fields=u'*')
retry_reasons=[u'serviceLimit'],
groupUniqueId=group, fields=u'*')
if current_settings is not None:
gs_body = dict(current_settings.items() + gs_body.items())
if gs_body:
@@ -10918,7 +10919,7 @@ def doPrintShowAlerts():
titles.append(field)
csv_rows.append(aj)
writeCSVfile(csv_rows, titles, u'Alerts', False)
def doPrintShowAlertFeedback():
_, ac = buildAlertCenterGAPIObject(_getValueFromOAuth(u'email'))
feedback = callGAPIpages(ac.alerts().feedback(), u'list', u'feedback', alertId=u'-')
@@ -10926,7 +10927,7 @@ def doPrintShowAlertFeedback():
print feedbac
def _getValidAlertFeedbackTypes(ac):
return [type for type in ac._rootDesc[u'schemas'][u'AlertFeedback'][u'properties'][u'type'][u'enum'] if type != u'ALERT_FEEDBACK_TYPE_UNSPECIFIED']
return [aftype for aftype in ac._rootDesc[u'schemas'][u'AlertFeedback'][u'properties'][u'type'][u'enum'] if aftype != u'ALERT_FEEDBACK_TYPE_UNSPECIFIED']
def doCreateAlertFeedback():
_, ac = buildAlertCenterGAPIObject(_getValueFromOAuth(u'email'))