mirror of
https://github.com/GAM-team/GAM.git
synced 2026-06-07 15:51:38 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d9e35d013 | ||
|
|
af43db44ed | ||
|
|
8e3f30e901 | ||
|
|
cccbddcf45 | ||
|
|
a70bbf08ed | ||
|
|
57e1625246 | ||
|
|
24bd99386b |
@@ -3997,13 +3997,14 @@ gam print cigroups [todrive <ToDriveAttribute>*]
|
||||
|
||||
<CIGroupMembersFieldName> ::=
|
||||
createtime
|
||||
email|useremail|
|
||||
expiretime|
|
||||
memberkey|
|
||||
name|
|
||||
role|
|
||||
type|
|
||||
updatetime|
|
||||
useremail
|
||||
updatetime
|
||||
|
||||
<CIGroupMembersFieldNameList> ::= "<CIGroupMembersFieldName>(,<CIGroupMembersFieldName>)*"
|
||||
|
||||
gam <UserTypeEntity> info cimember <GroupEntity>
|
||||
@@ -4017,16 +4018,19 @@ gam print cigroup-members [todrive <ToDriveAttribute>*]
|
||||
[types <CIGroupMemberTypeList>]
|
||||
[memberemaildisplaypattern|memberemailskippattern <RegularExpression>]
|
||||
<CIGroupMembersFieldName>* [fields <CIGroupMembersFieldNameList>]
|
||||
[(recursive [noduplicates])includederivedmembership] [nogroupeemail]
|
||||
[minimal|basic|full]
|
||||
[(recursive [noduplicates]) | includederivedmembership] [nogroupemail]
|
||||
[formatjson [quotechar <Character>]]
|
||||
gam show cigroup-members
|
||||
[(cimember|ciowner <UserItem>)|(cigroup <GroupItem>)|(select <GroupEntity>)]
|
||||
[showownedby <UserItem>]
|
||||
[emailmatchpattern [not] <RegularExpression>] [namematchpattern [not] <RegularExpression>]
|
||||
[descriptionmatchpattern [not] <RegularExpression>]
|
||||
[roles <GroupRoleList>] [members] [managers] [owners] [depth <Number>]
|
||||
[roles <GroupRoleList>] [members] [managers] [owners]
|
||||
[types <CIGroupMemberTypeList>]
|
||||
[memberemaildisplaypattern|memberemailskippattern <RegularExpression>]
|
||||
[minimal|basic|full]
|
||||
[(depth <Number>) | includederivedmembership]
|
||||
|
||||
# Cloud Identity Devices
|
||||
|
||||
|
||||
@@ -1,3 +1,44 @@
|
||||
7.04.04
|
||||
|
||||
Updated `gam print group-members|cigroup-members` to include the `email` column
|
||||
when `fields <MembersFieldNameList>` did not include `email`.
|
||||
|
||||
7.04.03
|
||||
|
||||
Added option `minimal|basic|full` to `gam print cigroup-members`:
|
||||
* `minimal` - Fields displayed: group, id, role, email
|
||||
* `basic` - Fields displayed: group, type, id, role, email
|
||||
* `full` - Fields displayed: group, type, id, role, email, createTime, updateTime; this is the default
|
||||
|
||||
Added option `minimal|basic|full` to `gam show cigroup-members`:
|
||||
* `minimal` - Fields displayed: role, email
|
||||
* `basic` - Fields displayed: type, role, email
|
||||
* `full` - Fields displayed: type, role, email, createTime, updateTime; this is the default
|
||||
|
||||
Upgraded `gam print cigroup-members ... recursive` to display sub-group email addresses rather than IDs.
|
||||
|
||||
7.04.02
|
||||
|
||||
Improved output formatting for the following commands:
|
||||
```
|
||||
gam info peoplecontact
|
||||
gam show peoplecontacts
|
||||
gam info peopleprofile
|
||||
gam show peopleprofile
|
||||
gam <UserTypeEntity> info contacts
|
||||
gam <UserTypeEntity> show contacts
|
||||
gam <UserTypeEntity> show peopleprofile
|
||||
```
|
||||
|
||||
7.04.01
|
||||
|
||||
Fixed bug where multiple `querytime<String>` values in a query were not properly processed;
|
||||
only the last `querytime<String>` was processed.
|
||||
```
|
||||
Command line: query "sync:#querytime1#..#querytime2# status:provisioned" querytime1 -2y querytime2 -40w
|
||||
Query: (sync:#querytime1#..2024-05-09T00:00:00 status:provisioned) Invalid
|
||||
```
|
||||
|
||||
7.04.00
|
||||
|
||||
The Classic Sites API no longer functions, the following commands are deprecated:
|
||||
|
||||
@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
|
||||
"""
|
||||
|
||||
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
|
||||
__version__ = '7.04.00'
|
||||
__version__ = '7.04.04'
|
||||
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
||||
|
||||
#pylint: disable=wrong-import-position
|
||||
@@ -667,8 +667,10 @@ def accessErrorExitNonDirectory(api, errMsg):
|
||||
Ent.API, api])+[errMsg],
|
||||
''))
|
||||
|
||||
def ClientAPIAccessDeniedExit():
|
||||
def ClientAPIAccessDeniedExit(errMsg=None):
|
||||
stderrErrorMsg(Msg.API_ACCESS_DENIED)
|
||||
if errMsg:
|
||||
stderrErrorMsg(errMsg)
|
||||
missingScopes = API.getClientScopesSet(GM.Globals[GM.CURRENT_CLIENT_API])-GM.Globals[GM.CURRENT_CLIENT_API_SCOPES]
|
||||
if missingScopes:
|
||||
writeStderr(Msg.API_CHECK_CLIENT_AUTHORIZATION.format(GM.Globals[GM.OAUTH2_CLIENT_ID],
|
||||
@@ -5979,6 +5981,8 @@ def getCIGroupTransitiveMemberRoleFixType(groupName, tmember):
|
||||
member['type'] = Ent.TYPE_USER if not tid.endswith('.iam.gserviceaccount.com') else Ent.TYPE_SERVICE_ACCOUNT
|
||||
elif ttype == 'groups':
|
||||
member['type'] = Ent.TYPE_GROUP
|
||||
elif tid.startswith('cbcm-browser.'):
|
||||
member['type'] = Ent.TYPE_CBCM_BROWSER
|
||||
else:
|
||||
member['type'] = Ent.TYPE_OTHER
|
||||
else:
|
||||
@@ -7320,12 +7324,6 @@ def _getRawFields(requiredField=None):
|
||||
return rawFields
|
||||
return f'{requiredField},{rawFields}'
|
||||
|
||||
def _addInitialField(fieldsList, initialField):
|
||||
if isinstance(initialField, list):
|
||||
fieldsList.extend(initialField)
|
||||
else:
|
||||
fieldsList.append(initialField)
|
||||
|
||||
def CheckInputRowFilterHeaders(titlesList, rowFilter, rowDropFilter):
|
||||
status = True
|
||||
for filterVal in rowFilter:
|
||||
@@ -7740,6 +7738,12 @@ def RowFilterMatch(row, titlesList, rowFilter, rowFilterModeAll, rowDropFilter,
|
||||
# }
|
||||
# fieldsList is the list of API fields
|
||||
def getFieldsList(myarg, fieldsChoiceMap, fieldsList, initialField=None, fieldsArg='fields', onlyFieldsArg=False):
|
||||
def addInitialField():
|
||||
if isinstance(initialField, list):
|
||||
fieldsList.extend(initialField)
|
||||
else:
|
||||
fieldsList.append(initialField)
|
||||
|
||||
def addMappedFields(mappedFields):
|
||||
if isinstance(mappedFields, list):
|
||||
fieldsList.extend(mappedFields)
|
||||
@@ -7748,11 +7752,11 @@ def getFieldsList(myarg, fieldsChoiceMap, fieldsList, initialField=None, fieldsA
|
||||
|
||||
if not onlyFieldsArg and myarg in fieldsChoiceMap:
|
||||
if not fieldsList and initialField is not None:
|
||||
_addInitialField(fieldsList, initialField)
|
||||
addInitialField()
|
||||
addMappedFields(fieldsChoiceMap[myarg])
|
||||
elif myarg == fieldsArg:
|
||||
if not fieldsList and initialField is not None:
|
||||
_addInitialField(fieldsList, initialField)
|
||||
addInitialField()
|
||||
for field in _getFieldsList():
|
||||
if field in fieldsChoiceMap:
|
||||
addMappedFields(fieldsChoiceMap[field])
|
||||
@@ -7929,14 +7933,21 @@ class CSVPrintFile():
|
||||
fieldsList.append(fields)
|
||||
self.AddTitles(fields.replace('.', GC.Values[GC.CSV_OUTPUT_SUBFIELD_DELIMITER]))
|
||||
|
||||
def addInitialField(self, initialField, fieldsChoiceMap, fieldsList):
|
||||
if isinstance(initialField, list):
|
||||
for field in initialField:
|
||||
self.AddField(field, fieldsChoiceMap, fieldsList)
|
||||
else:
|
||||
self.AddField(initialField, fieldsChoiceMap, fieldsList)
|
||||
|
||||
def GetFieldsListTitles(self, fieldName, fieldsChoiceMap, fieldsList, initialField=None):
|
||||
if fieldName in fieldsChoiceMap:
|
||||
if not fieldsList and initialField is not None:
|
||||
_addInitialField(fieldsList, initialField)
|
||||
self.addInitialField(initialField, fieldsChoiceMap, fieldsList)
|
||||
self.AddField(fieldName, fieldsChoiceMap, fieldsList)
|
||||
elif fieldName == 'fields':
|
||||
if not fieldsList and initialField is not None:
|
||||
_addInitialField(fieldsList, initialField)
|
||||
self.addInitialField(initialField, fieldsChoiceMap, fieldsList)
|
||||
for field in _getFieldsList():
|
||||
if field in fieldsChoiceMap:
|
||||
self.AddField(field, fieldsChoiceMap, fieldsList)
|
||||
@@ -21225,6 +21236,8 @@ def _getPeopleOtherContacts(people, entityType, user, i=0, count=0):
|
||||
resourceName = contact.pop('resourceName')
|
||||
otherContacts[resourceName] = contact
|
||||
return otherContacts
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
entityUnknownWarning(entityType, user, i, count)
|
||||
return None
|
||||
@@ -21281,6 +21294,8 @@ def queryPeopleContacts(people, contactQuery, fields, sortOrder, entityType, use
|
||||
showMessage = pageMessage.replace(TOTAL_ITEMS_MARKER, str(totalItems))
|
||||
writeGotMessage(showMessage.replace('{0}', str(Ent.Choose(Ent.PEOPLE_CONTACT, totalItems))))
|
||||
return entityList
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
entityUnknownWarning(entityType, user, i, count)
|
||||
return None
|
||||
@@ -21307,6 +21322,8 @@ def queryPeopleOtherContacts(people, contactQuery, fields, entityType, user, i=0
|
||||
showMessage = pageMessage.replace(TOTAL_ITEMS_MARKER, str(totalItems))
|
||||
writeGotMessage(showMessage.replace('{0}', str(Ent.Choose(Ent.OTHER_CONTACT, totalItems))))
|
||||
return entityList
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
entityUnknownWarning(entityType, user, i, count)
|
||||
return None
|
||||
@@ -21327,6 +21344,8 @@ def getPeopleContactGroupsInfo(people, entityType, entityName, i, count):
|
||||
if group['formattedName'] != group['name']:
|
||||
contactGroupNames.setdefault(group['name'], [])
|
||||
contactGroupNames[group['name']].append(group['resourceName'])
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except GAPI.forbidden:
|
||||
userPeopleServiceNotEnabledWarning(entityName, i, count)
|
||||
return (contactGroupIDs, False)
|
||||
@@ -21425,6 +21444,8 @@ def createUserPeopleContact(users):
|
||||
csvPF.WriteRow(row)
|
||||
except GAPI.invalidArgument as e:
|
||||
entityActionFailedWarning([entityType, user, peopleEntityType, None], str(e), i, count)
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
ClientAPIAccessDeniedExit()
|
||||
if csvPF:
|
||||
@@ -21588,6 +21609,8 @@ def _clearUpdatePeopleContacts(users, updateContacts):
|
||||
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], str(e), j, jcount)
|
||||
except (GAPI.notFound, GAPI.internalError):
|
||||
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], Msg.DOES_NOT_EXIST, j, jcount)
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
ClientAPIAccessDeniedExit()
|
||||
Ind.Decrement()
|
||||
@@ -21736,6 +21759,8 @@ def dedupReplaceDomainUserPeopleContacts(users):
|
||||
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], str(e), j, jcount)
|
||||
except (GAPI.notFound, GAPI.internalError):
|
||||
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], Msg.DOES_NOT_EXIST, j, jcount)
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
ClientAPIAccessDeniedExit()
|
||||
Ind.Decrement()
|
||||
@@ -21789,6 +21814,8 @@ def deleteUserPeopleContacts(users):
|
||||
entityActionPerformed([entityType, user, peopleEntityType, resourceName], j, jcount)
|
||||
except (GAPI.notFound, GAPI.internalError):
|
||||
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], Msg.DOES_NOT_EXIST, j, jcount)
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
ClientAPIAccessDeniedExit()
|
||||
Ind.Decrement()
|
||||
@@ -21846,12 +21873,29 @@ def _printPerson(entityTypeName, user, person, csvPF, FJQC, parameters):
|
||||
'JSON': json.dumps(cleanJSON(person),
|
||||
ensure_ascii=False, sort_keys=True)})
|
||||
|
||||
PEOPLE_CONTACT_OBJECT_KEYS = {
|
||||
'addresses': 'type',
|
||||
'calendarUrls': 'type',
|
||||
'emailAddresses': 'type',
|
||||
'events': 'type',
|
||||
'externalIds': 'type',
|
||||
'genders': 'value',
|
||||
'imClients': 'type',
|
||||
'locations': 'type',
|
||||
'miscKeywords': 'type',
|
||||
'nicknames': 'type',
|
||||
'organizations': 'type',
|
||||
'relations': 'type',
|
||||
'urls': 'type',
|
||||
'userDefined': 'key',
|
||||
}
|
||||
|
||||
def _showPerson(userEntityType, user, entityType, person, i, count, FJQC, parameters):
|
||||
_processPersonMetadata(person, parameters)
|
||||
if not FJQC.formatJSON:
|
||||
printEntity([userEntityType, user, entityType, person['resourceName']], i, count)
|
||||
Ind.Increment()
|
||||
showJSON(None, person)
|
||||
showJSON(None, person, dictObjectsKey=PEOPLE_CONTACT_OBJECT_KEYS)
|
||||
Ind.Decrement()
|
||||
else:
|
||||
printLine(json.dumps(cleanJSON(person), ensure_ascii=False, sort_keys=True))
|
||||
@@ -22067,6 +22111,8 @@ def _infoPeople(users, entityType, source):
|
||||
except GAPI.invalidArgument as e:
|
||||
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], str(e), j, jcount)
|
||||
continue
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
ClientAPIAccessDeniedExit()
|
||||
if showContactGroups and contactGroupIDs:
|
||||
@@ -22245,6 +22291,8 @@ def copyUserPeopleOtherContacts(users):
|
||||
except (GAPI.notFound, GAPI.internalError):
|
||||
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], Msg.DOES_NOT_EXIST, j, jcount)
|
||||
continue
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
ClientAPIAccessDeniedExit()
|
||||
Ind.Decrement()
|
||||
@@ -22359,7 +22407,9 @@ def processUserPeopleOtherContacts(users):
|
||||
except (GAPI.notFound, GAPI.internalError):
|
||||
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName], Msg.DOES_NOT_EXIST, j, jcount)
|
||||
continue
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied):
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
ClientAPIAccessDeniedExit()
|
||||
Ind.Decrement()
|
||||
|
||||
@@ -22476,6 +22526,8 @@ def _printShowPeople(source):
|
||||
pageSize=GC.Values[GC.PEOPLE_MAX_RESULTS],
|
||||
sources=sources, mergeSources=mergeSources,
|
||||
readMask=fields, fields='nextPageToken,people', **kwargs)
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
ClientAPIAccessDeniedExit()
|
||||
if not countsOnly:
|
||||
@@ -22596,6 +22648,8 @@ def printShowUserPeopleProfiles(users):
|
||||
except GAPI.notFound:
|
||||
entityUnknownWarning(Ent.PEOPLE_PROFILE, user, i, count)
|
||||
continue
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
ClientAPIAccessDeniedExit()
|
||||
if not csvPF:
|
||||
@@ -22750,6 +22804,8 @@ def _processPeopleContactPhotos(users, function):
|
||||
entityDoesNotHaveItemWarning([entityType, user, peopleEntityType, resourceName, Ent.PHOTO, filename], j, jcount)
|
||||
except (GAPI.invalidArgument, OSError, IOError) as e:
|
||||
entityActionFailedWarning([entityType, user, peopleEntityType, resourceName, Ent.PHOTO, filename], str(e), j, jcount)
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
ClientAPIAccessDeniedExit()
|
||||
break
|
||||
@@ -22824,7 +22880,7 @@ def createUserPeopleContactGroup(users):
|
||||
if addCSVData:
|
||||
row.update(addCSVData)
|
||||
csvPF.WriteRow(row)
|
||||
except GAPI.forbidden:
|
||||
except (GAPI.forbidden, GAPI.permissionDenied):
|
||||
userPeopleServiceNotEnabledWarning(user, i, count)
|
||||
except GAPI.serviceNotAvailable:
|
||||
entityUnknownWarning(entityType, user, i, count)
|
||||
@@ -22878,7 +22934,7 @@ def updateUserPeopleContactGroup(users):
|
||||
entityActionPerformed([entityType, user, Ent.CONTACT_GROUP, contactGroup], j, jcount)
|
||||
except (GAPI.notFound, GAPI.internalError) as e:
|
||||
entityActionFailedWarning([entityType, user, Ent.CONTACT_GROUP, contactGroup], str(e), j, jcount)
|
||||
except GAPI.forbidden:
|
||||
except (GAPI.forbidden, GAPI.permissionDenied):
|
||||
userPeopleServiceNotEnabledWarning(user, i, count)
|
||||
break
|
||||
except GAPI.serviceNotAvailable:
|
||||
@@ -22923,7 +22979,7 @@ def deleteUserPeopleContactGroups(users):
|
||||
entityActionPerformed([entityType, user, Ent.CONTACT_GROUP, contactGroup], j, jcount)
|
||||
except GAPI.notFound as e:
|
||||
entityActionFailedWarning([entityType, user, Ent.CONTACT_GROUP, contactGroup], str(e), j, jcount)
|
||||
except GAPI.forbidden:
|
||||
except (GAPI.forbidden, GAPI.permissionDenied):
|
||||
userPeopleServiceNotEnabledWarning(user, i, count)
|
||||
break
|
||||
except GAPI.serviceNotAvailable:
|
||||
@@ -23024,7 +23080,7 @@ def infoUserPeopleContactGroups(users):
|
||||
_showContactGroup(entityType, user, Ent.CONTACT_GROUP, group, j, jcount, FJQC)
|
||||
except GAPI.notFound as e:
|
||||
entityActionFailedWarning([entityType, user, Ent.CONTACT_GROUP, contactGroup], str(e), j, jcount)
|
||||
except GAPI.forbidden:
|
||||
except (GAPI.forbidden, GAPI.permissionDenied):
|
||||
userPeopleServiceNotEnabledWarning(user, i, count)
|
||||
break
|
||||
except GAPI.serviceNotAvailable:
|
||||
@@ -23073,6 +23129,8 @@ def printShowUserPeopleContactGroups(users):
|
||||
throwReasons=GAPI.PEOPLE_ACCESS_THROW_REASONS,
|
||||
pageSize=GC.Values[GC.PEOPLE_MAX_RESULTS],
|
||||
groupFields=fields, fields='nextPageToken,contactGroups')
|
||||
except GAPI.permissionDenied as e:
|
||||
ClientAPIAccessDeniedExit(str(e))
|
||||
except (GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
ClientAPIAccessDeniedExit()
|
||||
_printPersonEntityList(Ent.PEOPLE_CONTACT_GROUP, entityList, entityType, user, i, count, csvPF, FJQC, parameters, None)
|
||||
@@ -24143,7 +24201,8 @@ def substituteQueryTimes(queries, queryTimes):
|
||||
for i, query in enumerate(queries):
|
||||
if query is not None:
|
||||
for queryTimeName, queryTimeValue in iter(queryTimes.items()):
|
||||
queries[i] = query.replace(f'#{queryTimeName}#', queryTimeValue)
|
||||
query = query.replace(f'#{queryTimeName}#', queryTimeValue)
|
||||
queries[i] = query
|
||||
|
||||
# Get CrOS devices from gam.cfg print_cros_ous and print_cros_ous_and_children
|
||||
def getCfgCrOSEntities():
|
||||
@@ -33909,6 +33968,8 @@ def infoGroupMembers(entityList, ciGroupsAPI=False):
|
||||
printKeyValueList(['type', result['type']])
|
||||
for field in ['createTime', 'updateTime']:
|
||||
printKeyValueList([field, formatLocalTime(result[field])])
|
||||
if 'deliverySetting' in result:
|
||||
printKeyValueList(['deliverySetting', result['deliverySetting']])
|
||||
Ind.Decrement()
|
||||
except (GAPI.groupNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis, GAPI.invalid, GAPI.forbidden) as e:
|
||||
entityActionFailedWarning([entityType, groupKey], str(e), j, jcount)
|
||||
@@ -34095,7 +34156,7 @@ def doPrintGroupMembers():
|
||||
for name in info['names']:
|
||||
if name['metadata']['source']['type'] == sourceType:
|
||||
return name['displayName']
|
||||
except (GAPI.notFound, GAPI.serviceNotAvailable, GAPI.forbidden):
|
||||
except (GAPI.notFound, GAPI.serviceNotAvailable, GAPI.forbidden, GAPI.permissionDenied):
|
||||
pass
|
||||
return unknownName
|
||||
|
||||
@@ -34152,7 +34213,7 @@ def doPrintGroupMembers():
|
||||
pass
|
||||
elif getMemberMatchOptions(myarg, memberOptions):
|
||||
pass
|
||||
elif csvPF.GetFieldsListTitles(myarg, GROUPMEMBERS_FIELDS_CHOICE_MAP, fieldsList):
|
||||
elif csvPF.GetFieldsListTitles(myarg, GROUPMEMBERS_FIELDS_CHOICE_MAP, fieldsList, initialField='email'):
|
||||
pass
|
||||
elif myarg == 'membernames':
|
||||
memberOptions[MEMBEROPTION_MEMBERNAMES] = True
|
||||
@@ -36071,8 +36132,9 @@ def getCIGroupTransitiveMembers(ci, groupName, membersList, i, count):
|
||||
return True
|
||||
|
||||
def getCIGroupMembers(ci, groupName, memberRoles, membersList, membersSet, i, count,
|
||||
memberOptions, memberDisplayOptions, level, typesSet):
|
||||
printGettingAllEntityItemsForWhom(memberRoles if memberRoles else Ent.ROLE_MANAGER_MEMBER_OWNER, groupName, i, count)
|
||||
memberOptions, memberDisplayOptions, level, typesSet, groupEmail, kwargs):
|
||||
nameToPrint = groupEmail if groupEmail else groupName
|
||||
printGettingAllEntityItemsForWhom(memberRoles if memberRoles else Ent.ROLE_MANAGER_MEMBER_OWNER, nameToPrint, i, count)
|
||||
validRoles = _getCIRoleVerification(memberRoles)
|
||||
if memberOptions[MEMBEROPTION_INCLUDEDERIVEDMEMBERSHIP]:
|
||||
groupMembers = []
|
||||
@@ -36087,12 +36149,11 @@ def getCIGroupMembers(ci, groupName, memberRoles, membersList, membersSet, i, co
|
||||
groupMembers = callGAPIpages(ci.groups().memberships(), 'list', 'memberships',
|
||||
pageMessage=getPageMessageForWhom(),
|
||||
throwReasons=GAPI.CIGROUP_LIST_THROW_REASONS, retryReasons=GAPI.CIGROUP_RETRY_REASONS,
|
||||
parent=groupName, view='FULL',
|
||||
fields='nextPageToken,memberships(*)', pageSize=GC.Values[GC.MEMBER_MAX_RESULTS])
|
||||
parent=groupName, **kwargs)
|
||||
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis,
|
||||
GAPI.forbidden, GAPI.badRequest, GAPI.invalid, GAPI.invalidArgument, GAPI.systemError,
|
||||
GAPI.permissionDenied, GAPI.serviceNotAvailable):
|
||||
entityUnknownWarning(Ent.CLOUD_IDENTITY_GROUP, groupName, i, count)
|
||||
entityUnknownWarning(Ent.CLOUD_IDENTITY_GROUP, nameToPrint, i, count)
|
||||
return
|
||||
checkCategory = memberDisplayOptions['showCategory']
|
||||
if not memberOptions[MEMBEROPTION_RECURSIVE]:
|
||||
@@ -36126,7 +36187,7 @@ def getCIGroupMembers(ci, groupName, memberRoles, membersList, membersSet, i, co
|
||||
memberName not in membersSet):
|
||||
membersSet.add(memberName)
|
||||
member['level'] = level
|
||||
member['subgroup'] = groupName
|
||||
member['subgroup'] = nameToPrint
|
||||
membersList.append(member)
|
||||
else:
|
||||
if memberName not in membersSet:
|
||||
@@ -36135,37 +36196,41 @@ def getCIGroupMembers(ci, groupName, memberRoles, membersList, membersSet, i, co
|
||||
checkCIMemberMatch(member, memberOptions) and
|
||||
(not checkCategory or _checkCIMemberCategory(member, memberDisplayOptions))):
|
||||
member['level'] = level
|
||||
member['subgroup'] = groupName
|
||||
member['subgroup'] = nameToPrint
|
||||
membersList.append(member)
|
||||
_, gname = member['name'].rsplit('/', 1)
|
||||
groupMemberList.append(f'groups/{gname}')
|
||||
groupMemberList.append((f'groups/{gname}', memberName))
|
||||
for member in groupMemberList:
|
||||
getCIGroupMembers(ci, member, memberRoles, membersList, membersSet, i, count,
|
||||
memberOptions, memberDisplayOptions, level+1, typesSet)
|
||||
getCIGroupMembers(ci, member[0], memberRoles, membersList, membersSet, i, count,
|
||||
memberOptions, memberDisplayOptions, level+1, typesSet, member[1], kwargs)
|
||||
else:
|
||||
for member in groupMembers:
|
||||
getCIGroupMemberRoleFixType(member)
|
||||
memberName = member.get('preferredMemberKey', {}).get('id', '')
|
||||
if member['type'] != Ent.TYPE_GROUP:
|
||||
if (member['type'] in typesSet and
|
||||
checkCIMemberMatch(member, memberOptions) and
|
||||
_checkMemberRole(member, validRoles) and
|
||||
(not checkCategory or _checkCIMemberCategory(member, memberDisplayOptions))):
|
||||
member['level'] = level
|
||||
member['subgroup'] = groupName
|
||||
member['subgroup'] = nameToPrint
|
||||
membersList.append(member)
|
||||
else:
|
||||
if (member['type'] in typesSet and
|
||||
checkCIMemberMatch(member, memberOptions) and
|
||||
(not checkCategory or _checkCIMemberCategory(member, memberDisplayOptions))):
|
||||
member['level'] = level
|
||||
member['subgroup'] = groupName
|
||||
member['subgroup'] = nameToPrint
|
||||
membersList.append(member)
|
||||
_, gname = member['name'].rsplit('/', 1)
|
||||
getCIGroupMembers(ci, f'groups/{gname}', memberRoles, membersList, membersSet, i, count,
|
||||
memberOptions, memberDisplayOptions, level+1, typesSet)
|
||||
memberOptions, memberDisplayOptions, level+1, typesSet, memberName, kwargs)
|
||||
|
||||
CIGROUPMEMBERS_FIELDS_CHOICE_MAP = {
|
||||
'createtime': 'createTime',
|
||||
'delivery': 'deliverySetting',
|
||||
'deliverysettings': 'deliverySetting',
|
||||
'email': 'preferredMemberKey',
|
||||
'expiretime': 'expireTime',
|
||||
'id': 'name',
|
||||
'memberkey': 'preferredMemberKey',
|
||||
@@ -36186,6 +36251,16 @@ CIGROUPMEMBERS_SORT_FIELDS = [
|
||||
]
|
||||
CIGROUPMEMBERS_TIME_OBJECTS = {'createTime', 'updateTime', 'expireTime'}
|
||||
|
||||
def _getCIListGroupMembersArgs(listView):
|
||||
if listView == 'full':
|
||||
return {'view': 'FULL', 'pageSize': GC.Values[GC.MEMBER_MAX_RESULTS_CI_FULL],
|
||||
'fields': 'nextPageToken,memberships(*)'}
|
||||
if listView == 'basic':
|
||||
return {'view': 'FULL', 'pageSize': GC.Values[GC.MEMBER_MAX_RESULTS_CI_FULL],
|
||||
'fields': 'nextPageToken,memberships(name,preferredMemberKey,roles,type)'}
|
||||
return {'view': 'BASIC', 'pageSize': GC.Values[GC.MEMBER_MAX_RESULTS_CI_BASIC],
|
||||
'fields': 'nextPageToken,memberships(*)'}
|
||||
|
||||
# gam print cigroup-members [todrive <ToDriveAttribute>*]
|
||||
# [(cimember|ciowner <UserItem>)|(cigroup <GroupItem>)|(select <GroupEntity>)]
|
||||
# [showownedby <UserItem>]
|
||||
@@ -36195,6 +36270,7 @@ CIGROUPMEMBERS_TIME_OBJECTS = {'createTime', 'updateTime', 'expireTime'}
|
||||
# [types <CIGroupMemberTypeList>]
|
||||
# [memberemaildisplaypattern|memberemailskippattern <RegularExpression>]
|
||||
# <CIGroupMembersFieldName>* [fields <CIGroupMembersFieldNameList>]
|
||||
# [minimal|basic|full]
|
||||
# [(recursive [noduplicates])|includederivedmembership] [nogroupeemail]
|
||||
# [formatjson [quotechar <Character>]]
|
||||
def doPrintCIGroupMembers():
|
||||
@@ -36212,6 +36288,7 @@ def doPrintCIGroupMembers():
|
||||
rolesSet = set()
|
||||
typesSet = set()
|
||||
matchPatterns = {}
|
||||
listView = 'full'
|
||||
while Cmd.ArgumentsRemaining():
|
||||
myarg = getArgument()
|
||||
if myarg == 'todrive':
|
||||
@@ -36240,7 +36317,7 @@ def doPrintCIGroupMembers():
|
||||
pass
|
||||
elif getMemberMatchOptions(myarg, memberOptions):
|
||||
pass
|
||||
elif getFieldsList(myarg, CIGROUPMEMBERS_FIELDS_CHOICE_MAP, fieldsList):
|
||||
elif getFieldsList(myarg, CIGROUPMEMBERS_FIELDS_CHOICE_MAP, fieldsList, initialField='preferredMemberKey'):
|
||||
pass
|
||||
elif myarg == 'noduplicates':
|
||||
memberOptions[MEMBEROPTION_NODUPLICATES] = True
|
||||
@@ -36252,8 +36329,12 @@ def doPrintCIGroupMembers():
|
||||
memberOptions[MEMBEROPTION_RECURSIVE] = False
|
||||
elif myarg == 'nogroupemail':
|
||||
groupColumn = False
|
||||
elif myarg in {'minimal', 'basic', 'full'}:
|
||||
listView = myarg
|
||||
else:
|
||||
FJQC.GetFormatJSONQuoteChar(myarg, False)
|
||||
if listView == 'minimal' and memberOptions[MEMBEROPTION_RECURSIVE]:
|
||||
usageErrorExit(Msg.ARE_MUTUALLY_EXCLUSIVE.format('minimal', 'recursive'))
|
||||
if not typesSet:
|
||||
typesSet = {Ent.TYPE_USER} if memberOptions[MEMBEROPTION_RECURSIVE] else ALL_CIGROUP_MEMBER_TYPES
|
||||
fields = ','.join(set(groupFieldsLists['ci']))
|
||||
@@ -36280,6 +36361,7 @@ def doPrintCIGroupMembers():
|
||||
if showOwnedBy:
|
||||
getRolesSet.add(Ent.ROLE_OWNER)
|
||||
getRoles = ','.join(sorted(getRolesSet))
|
||||
kwargs = _getCIListGroupMembersArgs(listView)
|
||||
level = 0
|
||||
i = 0
|
||||
count = len(entityList)
|
||||
@@ -36306,7 +36388,7 @@ def doPrintCIGroupMembers():
|
||||
membersList = []
|
||||
membersSet = set()
|
||||
getCIGroupMembers(ci, groupEntity['name'], getRoles, membersList, membersSet, i, count,
|
||||
memberOptions, memberDisplayOptions, level, typesSet)
|
||||
memberOptions, memberDisplayOptions, level, typesSet, groupEmail, kwargs)
|
||||
if showOwnedBy and not checkCIGroupShowOwnedBy(showOwnedBy, membersList):
|
||||
continue
|
||||
for member in membersList:
|
||||
@@ -36324,6 +36406,8 @@ def doPrintCIGroupMembers():
|
||||
row['subgroup'] = member['subgroup']
|
||||
if memberDisplayOptions['showCategory']:
|
||||
row['category'] = member['category']
|
||||
if listView == 'minimal':
|
||||
dmember.pop('type', None)
|
||||
mapCIGroupMemberFieldNames(dmember)
|
||||
if not FJQC.formatJSON:
|
||||
csvPF.WriteRowTitles(flattenJSON(dmember, flattened=row, timeObjects=CIGROUPMEMBERS_TIME_OBJECTS))
|
||||
@@ -36353,17 +36437,19 @@ def doPrintCIGroupMembers():
|
||||
# [showownedby <UserItem>]
|
||||
# [emailmatchpattern [not] <RegularExpression>] [namematchpattern [not] <RegularExpression>]
|
||||
# [descriptionmatchpattern [not] <RegularExpression>]
|
||||
# [roles <GroupRoleList>] [members] [managers] [owners] [depth <Number>]
|
||||
# [roles <GroupRoleList>] [members] [managers] [owners]
|
||||
# [internal] [internaldomains <DomainList>] [external]
|
||||
# [types <CIGroupMemberTypeList>]
|
||||
# [memberemaildisplaypattern|memberemailskippattern <RegularExpression>]
|
||||
# [includederivedmembership]
|
||||
# [minimal|basic|full]
|
||||
# [(depth <Number>) | includederivedmembership]
|
||||
def doShowCIGroupMembers():
|
||||
def _roleOrder(key):
|
||||
return {Ent.ROLE_OWNER: 0, Ent.ROLE_MANAGER: 1, Ent.ROLE_MEMBER: 2}.get(key, 3)
|
||||
|
||||
def _typeOrder(key):
|
||||
return {Ent.TYPE_CUSTOMER: 0, Ent.TYPE_USER: 1, Ent.TYPE_GROUP: 2, Ent.TYPE_EXTERNAL: 3}.get(key, 4)
|
||||
return {Ent.TYPE_CUSTOMER: 0, Ent.TYPE_USER: 1, Ent.TYPE_GROUP: 2,
|
||||
Ent.TYPE_CBCM_BROWSER: 3, Ent.TYPE_OTHER: 4, Ent.TYPE_EXTERNAL: 5}.get(key, 6)
|
||||
|
||||
def _showGroup(groupName, groupEmail, depth):
|
||||
if includeDerivedMembership:
|
||||
@@ -36374,8 +36460,7 @@ def doShowCIGroupMembers():
|
||||
try:
|
||||
membersList = callGAPIpages(ci.groups().memberships(), 'list', 'memberships',
|
||||
throwReasons=GAPI.CIGROUP_LIST_THROW_REASONS, retryReasons=GAPI.CIGROUP_RETRY_REASONS,
|
||||
parent=groupName, view='FULL',
|
||||
fields='nextPageToken,memberships(*)', pageSize=GC.Values[GC.MEMBER_MAX_RESULTS])
|
||||
parent=groupName, **kwargs)
|
||||
for member in membersList:
|
||||
getCIGroupMemberRoleFixType(member)
|
||||
except (GAPI.resourceNotFound, GAPI.domainNotFound, GAPI.domainCannotUseApis,
|
||||
@@ -36396,7 +36481,10 @@ def doShowCIGroupMembers():
|
||||
if (_checkMemberRole(member, rolesSet) and
|
||||
member['type'] in typesSet and
|
||||
checkCIMemberMatch(member, memberOptions)):
|
||||
memberDetails = f'{member.get("role", Ent.ROLE_MEMBER)}, {member["type"]}, {member["preferredMemberKey"]["id"]}'
|
||||
if listView != 'minimal':
|
||||
memberDetails = f'{member.get("role", Ent.ROLE_MEMBER)}, {member["type"]}, {member["preferredMemberKey"]["id"]}'
|
||||
else:
|
||||
memberDetails = f'{member.get("role", Ent.ROLE_MEMBER)}, {member["preferredMemberKey"]["id"]}'
|
||||
if checkCategory:
|
||||
memberDetails += f', {member["category"]}'
|
||||
for field in ['createTime', 'updateTime', 'expireTime']:
|
||||
@@ -36421,6 +36509,7 @@ def doShowCIGroupMembers():
|
||||
matchPatterns = {}
|
||||
maxdepth = -1
|
||||
includeDerivedMembership = False
|
||||
listView = 'full'
|
||||
while Cmd.ArgumentsRemaining():
|
||||
myarg = getArgument()
|
||||
if myarg == 'showownedby':
|
||||
@@ -36451,6 +36540,8 @@ def doShowCIGroupMembers():
|
||||
maxdepth = getInteger(minVal=-1)
|
||||
elif myarg == 'includederivedmembership':
|
||||
includeDerivedMembership = True
|
||||
elif myarg in {'minimal', 'basic', 'full'}:
|
||||
listView = myarg
|
||||
else:
|
||||
unknownArgumentExit()
|
||||
if not rolesSet:
|
||||
@@ -36460,6 +36551,7 @@ def doShowCIGroupMembers():
|
||||
checkCategory = memberDisplayOptions['showCategory']
|
||||
fields = ','.join(set(groupFieldsLists['ci']))
|
||||
entityList = getCIGroupMembersEntityList(ci, entityList, query, subTitle, matchPatterns, groupFieldsLists['ci'], None)
|
||||
kwargs = _getCIListGroupMembersArgs(listView)
|
||||
i = 0
|
||||
count = len(entityList)
|
||||
for group in entityList:
|
||||
|
||||
@@ -179,6 +179,10 @@ LICENSE_MAX_RESULTS = 'license_max_results'
|
||||
LICENSE_SKUS = 'license_skus'
|
||||
# When retrieving lists of Google Group members from API, how many should be retrieved in each chunk
|
||||
MEMBER_MAX_RESULTS = 'member_max_results'
|
||||
# CI API Group members max page size when view=BASIC
|
||||
MEMBER_MAX_RESULTS_CI_BASIC = 'member_max_results_ci_basic'
|
||||
# CI API Group members max page size when view=FULL
|
||||
MEMBER_MAX_RESULTS_CI_FULL = 'member_max_results_ci_full'
|
||||
# When deleting or modifying Gmail messages, how many should be processed in each batch
|
||||
MESSAGE_BATCH_SIZE = 'message_batch_size'
|
||||
# When retrieving lists of Gmail messages from API, how many should be retrieved in each chunk
|
||||
@@ -385,6 +389,8 @@ Defaults = {
|
||||
LICENSE_MAX_RESULTS: '100',
|
||||
LICENSE_SKUS: '',
|
||||
MEMBER_MAX_RESULTS: '200',
|
||||
MEMBER_MAX_RESULTS_CI_BASIC: '1000',
|
||||
MEMBER_MAX_RESULTS_CI_FULL: '500',
|
||||
MESSAGE_BATCH_SIZE: '50',
|
||||
MESSAGE_MAX_RESULTS: '500',
|
||||
MOBILE_MAX_RESULTS: '100',
|
||||
@@ -550,6 +556,8 @@ VAR_INFO = {
|
||||
LICENSE_MAX_RESULTS: {VAR_TYPE: TYPE_INTEGER, VAR_LIMITS: (10, 1000)},
|
||||
LICENSE_SKUS: {VAR_TYPE: TYPE_STRING, VAR_LIMITS: (0, None)},
|
||||
MEMBER_MAX_RESULTS: {VAR_TYPE: TYPE_INTEGER, VAR_LIMITS: (1, 200)},
|
||||
MEMBER_MAX_RESULTS_CI_BASIC: {VAR_TYPE: TYPE_INTEGER, VAR_LIMITS: (1, 1000)},
|
||||
MEMBER_MAX_RESULTS_CI_FULL: {VAR_TYPE: TYPE_INTEGER, VAR_LIMITS: (1, 500)},
|
||||
MESSAGE_BATCH_SIZE: {VAR_TYPE: TYPE_INTEGER, VAR_LIMITS: (1, 1000)},
|
||||
MESSAGE_MAX_RESULTS: {VAR_TYPE: TYPE_INTEGER, VAR_LIMITS: (1, 10000)},
|
||||
MOBILE_MAX_RESULTS: {VAR_TYPE: TYPE_INTEGER, VAR_LIMITS: (1, 100)},
|
||||
|
||||
@@ -1,283 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2009 Google Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Data model classes for parsing and generating XML for the Sites Data API."""
|
||||
|
||||
import atom
|
||||
import gdata
|
||||
|
||||
# XML Namespaces used in Google Sites entities.
|
||||
SITES_NAMESPACE = 'http://schemas.google.com/sites/2008'
|
||||
SITES_TEMPLATE = '{http://schemas.google.com/sites/2008}%s'
|
||||
SPREADSHEETS_NAMESPACE = 'http://schemas.google.com/spreadsheets/2006'
|
||||
SPREADSHEETS_TEMPLATE = '{http://schemas.google.com/spreadsheets/2006}%s'
|
||||
GACL_NAMESPACE = 'http://schemas.google.com/acl/2007'
|
||||
GACL_TEMPLATE = '{http://schemas.google.com/acl/2007}%s'
|
||||
DC_TERMS_TEMPLATE = '{http://purl.org/dc/terms}%s'
|
||||
THR_TERMS_TEMPLATE = '{http://purl.org/syndication/thread/1.0}%s'
|
||||
XHTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'
|
||||
XHTML_TEMPLATE = '{http://www.w3.org/1999/xhtml}%s'
|
||||
|
||||
SITES_INVITE_LINK_REL = SITES_NAMESPACE + '#invite'
|
||||
SITES_PARENT_LINK_REL = SITES_NAMESPACE + '#parent'
|
||||
SITES_REVISION_LINK_REL = SITES_NAMESPACE + '#revision'
|
||||
SITES_SOURCE_LINK_REL = SITES_NAMESPACE + '#source'
|
||||
SITES_TEMPLATE_LINK_REL = SITES_NAMESPACE + '#template'
|
||||
|
||||
ALTERNATE_REL = 'alternate'
|
||||
WEB_ADDRESS_MAPPING_REL = 'webAddressMapping'
|
||||
|
||||
SITES_KIND_SCHEME = 'http://schemas.google.com/g/2005#kind'
|
||||
ANNOUNCEMENT_KIND_TERM = SITES_NAMESPACE + '#announcement'
|
||||
ANNOUNCEMENT_PAGE_KIND_TERM = SITES_NAMESPACE + '#announcementspage'
|
||||
ATTACHMENT_KIND_TERM = SITES_NAMESPACE + '#attachment'
|
||||
COMMENT_KIND_TERM = SITES_NAMESPACE + '#comment'
|
||||
FILECABINET_KIND_TERM = SITES_NAMESPACE + '#filecabinet'
|
||||
LISTITEM_KIND_TERM = SITES_NAMESPACE + '#listitem'
|
||||
LISTPAGE_KIND_TERM = SITES_NAMESPACE + '#listpage'
|
||||
WEBPAGE_KIND_TERM = SITES_NAMESPACE + '#webpage'
|
||||
WEBATTACHMENT_KIND_TERM = SITES_NAMESPACE + '#webattachment'
|
||||
FOLDER_KIND_TERM = SITES_NAMESPACE + '#folder'
|
||||
TAG_KIND_TERM = SITES_NAMESPACE + '#tag'
|
||||
|
||||
SUPPORT_KINDS = [
|
||||
'announcement', 'announcementspage', 'attachment', 'comment', 'filecabinet',
|
||||
'listitem', 'listpage', 'webpage', 'webattachment', 'tag'
|
||||
]
|
||||
|
||||
|
||||
class GDataBase(atom.AtomBase):
|
||||
"""The Google Sites intermediate class from atom.AtomBase."""
|
||||
_namespace = gdata.GDATA_NAMESPACE
|
||||
_children = atom.AtomBase._children.copy()
|
||||
_attributes = atom.AtomBase._attributes.copy()
|
||||
|
||||
def __init__(self, text=None):
|
||||
atom.AtomBase.__init__(self, text=text)
|
||||
|
||||
class SitesBase(GDataBase):
|
||||
_namespace = SITES_NAMESPACE
|
||||
|
||||
class SiteName(SitesBase):
|
||||
"""Google Sites <sites:siteName>."""
|
||||
_tag = 'siteName'
|
||||
|
||||
class Theme(SitesBase):
|
||||
"""Google Sites <sites:theme>."""
|
||||
_tag = 'theme'
|
||||
|
||||
class SiteEntry(gdata.BatchEntry):
|
||||
"""Google Sites Site Feed Entry."""
|
||||
_tag = 'entry'
|
||||
_namespace = atom.ATOM_NAMESPACE
|
||||
_children = gdata.BatchEntry._children.copy()
|
||||
|
||||
_children['{%s}siteName' % SITES_NAMESPACE] = ('siteName', SiteName)
|
||||
_children['{%s}theme' % SITES_NAMESPACE] = ('theme', Theme)
|
||||
_attributes = gdata.BatchEntry._attributes.copy()
|
||||
_attributes['{%s}etag' % gdata.GDATA_NAMESPACE] = 'etag'
|
||||
|
||||
def __init__(self, siteName=None, title=None, summary=None, theme=None, sourceSite=None, category=None, etag=None):
|
||||
gdata.BatchEntry.__init__(self, category=category)
|
||||
self.siteName = siteName
|
||||
self.title = title
|
||||
self.summary = summary
|
||||
self.theme = theme
|
||||
if sourceSite is not None:
|
||||
sourceLink = atom.Link(href=sourceSite, rel=SITES_SOURCE_LINK_REL, link_type='application/atom+xml')
|
||||
self.link.append(sourceLink)
|
||||
self.etag = etag
|
||||
|
||||
def find_alternate_link(self):
|
||||
for link in self.link:
|
||||
if link.rel == ALTERNATE_REL and link.href:
|
||||
return link.href
|
||||
return None
|
||||
|
||||
FindAlternateLink = find_alternate_link
|
||||
|
||||
def find_source_link(self):
|
||||
for link in self.link:
|
||||
if link.rel == SITES_SOURCE_LINK_REL and link.href:
|
||||
return link.href
|
||||
return None
|
||||
|
||||
FindSourceLink = find_source_link
|
||||
|
||||
def find_webaddress_mappings(self):
|
||||
mappingLinks = []
|
||||
for link in self.link:
|
||||
if link.rel == WEB_ADDRESS_MAPPING_REL and link.href:
|
||||
mappingLinks.append(link.href)
|
||||
return mappingLinks
|
||||
|
||||
FindWebAddressMappings = find_webaddress_mappings
|
||||
|
||||
def SiteEntryFromString(xml_string):
|
||||
return atom.CreateClassFromXMLString(SiteEntry, xml_string)
|
||||
|
||||
class SiteFeed(gdata.BatchFeed, gdata.LinkFinder):
|
||||
"""A Google Sites feed flavor of an Atom Feed."""
|
||||
_tag = 'feed'
|
||||
_namespace = atom.ATOM_NAMESPACE
|
||||
_children = gdata.BatchFeed._children.copy()
|
||||
_children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [SiteEntry])
|
||||
|
||||
def __init__(self):
|
||||
gdata.BatchFeed.__init__(self)
|
||||
|
||||
def SiteFeedFromString(xml_string):
|
||||
return atom.CreateClassFromXMLString(SiteFeed, xml_string)
|
||||
|
||||
class AclBase(GDataBase):
|
||||
_namespace = GACL_NAMESPACE
|
||||
|
||||
class AclRole(AclBase):
|
||||
"""Describes the role of an entry in an access control list."""
|
||||
_tag = 'role'
|
||||
_children = AclBase._children.copy()
|
||||
_attributes = AclBase._attributes.copy()
|
||||
_attributes['value'] = 'value'
|
||||
|
||||
def __init__(self, value=None):
|
||||
AclBase.__init__(self)
|
||||
self.value = value
|
||||
|
||||
class AclAdditionalRole(AclBase):
|
||||
"""Describes an additionalRole element."""
|
||||
_tag = 'additionalRole'
|
||||
_children = AclBase._children.copy()
|
||||
_attributes = AclBase._attributes.copy()
|
||||
_attributes['value'] = 'value'
|
||||
|
||||
def __init__(self, value=None):
|
||||
AclBase.__init__(self)
|
||||
self.value = value
|
||||
|
||||
class AclScope(AclBase):
|
||||
"""Describes the scope of an entry in an access control list."""
|
||||
_tag = 'scope'
|
||||
_children = AclBase._children.copy()
|
||||
_attributes = AclBase._attributes.copy()
|
||||
_attributes['type'] = 'type'
|
||||
_attributes['value'] = 'value'
|
||||
|
||||
def __init__(self, stype=None, value=None):
|
||||
AclBase.__init__(self)
|
||||
self.type = stype
|
||||
self.value = value
|
||||
|
||||
|
||||
class AclWithKey(AclBase):
|
||||
"""Describes a key that can be used to access a document."""
|
||||
_tag = 'withKey'
|
||||
_children = AclBase._children.copy()
|
||||
_children['{%s}role' % GACL_NAMESPACE] = ('role', AclRole)
|
||||
_children['{%s}additionalRole' % GACL_NAMESPACE] = ('additionalRole', AclAdditionalRole)
|
||||
_attributes = AclBase._attributes.copy()
|
||||
_attributes['key'] = 'key'
|
||||
|
||||
def __init__(self, key=None, role=None, additionalRole=None):
|
||||
AclBase.__init__(self)
|
||||
self.key = key
|
||||
self.role = role
|
||||
self.additionalRole = additionalRole
|
||||
|
||||
class AclEntry(gdata.BatchEntry):
|
||||
"""Describes an entry in a feed of an access control list (ACL)."""
|
||||
_tag = 'entry'
|
||||
_namespace = atom.ATOM_NAMESPACE
|
||||
_children = gdata.BatchEntry._children.copy()
|
||||
|
||||
_children['{%s}role' % GACL_NAMESPACE] = ('role', AclRole)
|
||||
_children['{%s}additionalRole' % GACL_NAMESPACE] = ('additionalRole', AclAdditionalRole)
|
||||
_children['{%s}scope' % GACL_NAMESPACE] = ('scope', AclScope)
|
||||
_children['{%s}withKey' % GACL_NAMESPACE] = ('withKey', AclWithKey)
|
||||
_attributes = gdata.BatchEntry._attributes.copy()
|
||||
_attributes['{%s}etag' % gdata.GDATA_NAMESPACE] = 'etag'
|
||||
|
||||
def __init__(self, role=None, additionalRole=None, scope=None, withKey=None, etag=None):
|
||||
gdata.BatchEntry.__init__(self)
|
||||
self.role = role
|
||||
self.additionalRole = additionalRole
|
||||
self.scope = scope
|
||||
self.withKey = withKey
|
||||
self.etag = etag
|
||||
|
||||
def find_invite_link(self):
|
||||
for link in self.link:
|
||||
if link.rel == SITES_INVITE_LINK_REL and link.href:
|
||||
return link.href
|
||||
return None
|
||||
|
||||
FindInviteLink = find_invite_link
|
||||
|
||||
def AclEntryFromString(xml_string):
|
||||
return atom.CreateClassFromXMLString(AclEntry, xml_string)
|
||||
|
||||
class AclFeed(gdata.BatchFeed, gdata.LinkFinder):
|
||||
"""Describes a feed of an access control list (ACL)."""
|
||||
_tag = 'feed'
|
||||
_namespace = atom.ATOM_NAMESPACE
|
||||
_children = gdata.BatchFeed._children.copy()
|
||||
_children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [AclEntry])
|
||||
|
||||
def __init__(self):
|
||||
gdata.BatchFeed.__init__(self)
|
||||
|
||||
def AclFeedFromString(xml_string):
|
||||
return atom.CreateClassFromXMLString(AclFeed, xml_string)
|
||||
|
||||
class ActivityEntry(gdata.BatchEntry):
|
||||
"""Describes an entry in a feed of site activity (changes)."""
|
||||
_tag = 'entry'
|
||||
_namespace = atom.ATOM_NAMESPACE
|
||||
_children = gdata.BatchEntry._children.copy()
|
||||
_attributes = gdata.BatchEntry._attributes.copy()
|
||||
|
||||
def __init__(self):
|
||||
gdata.BatchEntry.__init__(self)
|
||||
|
||||
def __find_category_scheme(self, scheme):
|
||||
for category in self.category:
|
||||
if category.scheme == scheme:
|
||||
return category
|
||||
return None
|
||||
|
||||
def kind(self):
|
||||
kind = self.__find_category_scheme(SITES_KIND_SCHEME)
|
||||
if kind is not None:
|
||||
return kind.term[len(SITES_NAMESPACE) + 1:]
|
||||
else:
|
||||
return None
|
||||
|
||||
Kind = kind
|
||||
|
||||
def ActivityEntryFromString(xml_string):
|
||||
return atom.CreateClassFromXMLString(ActivityEntry, xml_string)
|
||||
|
||||
class ActivityFeed(gdata.BatchFeed, gdata.LinkFinder):
|
||||
"""Describes a feed of site activity (changes)."""
|
||||
_tag = 'feed'
|
||||
_namespace = atom.ATOM_NAMESPACE
|
||||
_children = gdata.BatchFeed._children.copy()
|
||||
_children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [ActivityEntry])
|
||||
|
||||
def __init__(self):
|
||||
gdata.BatchFeed.__init__(self)
|
||||
|
||||
def ActivityFeedFromString(xml_string):
|
||||
return atom.CreateClassFromXMLString(ActivityFeed, xml_string)
|
||||
@@ -1,246 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright 2009 Google Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""SitesService extends the GDataService for Google Sites API calls."""
|
||||
|
||||
import gdata.apps
|
||||
import gdata.apps.service
|
||||
import gdata.service
|
||||
|
||||
|
||||
# Feed URI templates
|
||||
CONTENT_FEED_TEMPLATE = '/feeds/content/%s/%s/'
|
||||
REVISION_FEED_TEMPLATE = '/feeds/revision/%s/%s/'
|
||||
ACTIVITY_FEED_TEMPLATE = '/feeds/activity/%s/%s/'
|
||||
ACTIVITY_ENTRY_TEMPLATE = '/feeds/activity/%s/%s/%s'
|
||||
SITE_FEED_TEMPLATE = '/feeds/site/%s/'
|
||||
ACL_FEED_TEMPLATE = '/feeds/acl/site/%s/%s'
|
||||
ACL_ENTRY_TEMPLATE = '/feeds/acl/site/%s/%s/%s'
|
||||
|
||||
|
||||
class SitesService(gdata.service.GDataService):
|
||||
"""Client extension for the Google Sites API service."""
|
||||
|
||||
def __init__(self,
|
||||
source=None, server='sites.google.com', additional_headers=None,
|
||||
**kwargs):
|
||||
"""Constructs a new client for the Sites API.
|
||||
|
||||
Args:
|
||||
site: string (optional) Name (webspace) of the Google Site
|
||||
domain: string (optional) Domain of the (Google Apps hosted) Site.
|
||||
If no domain is given, the Site is assumed to be a consumer Google
|
||||
Site, in which case the value 'site' is used.
|
||||
source: string (optional) The name of the user's application.
|
||||
server: string (optional) The name of the server to which a connection
|
||||
will be opened. Default value: 'sites..google.com'.
|
||||
**kwargs: The other parameters to pass to gdata.service.GDataService
|
||||
constructor.
|
||||
"""
|
||||
if additional_headers == None:
|
||||
additional_headers = {}
|
||||
additional_headers['GData-Version'] = '1.4'
|
||||
gdata.service.GDataService.__init__(self,
|
||||
source=source, server=server, additional_headers=additional_headers,
|
||||
**kwargs)
|
||||
self.ssl = True
|
||||
self.port = 443
|
||||
|
||||
def make_site_feed_uri(self, domain=None, site=None):
|
||||
if not domain:
|
||||
domain = 'site'
|
||||
if not site:
|
||||
return SITE_FEED_TEMPLATE % domain
|
||||
return (SITE_FEED_TEMPLATE % domain) + site
|
||||
|
||||
MakeSiteFeedUri = make_site_feed_uri
|
||||
|
||||
def get_site_feed(self, uri=None, domain=None, site=None,
|
||||
extra_headers=None, url_params=None, escape_params=True):
|
||||
|
||||
uri = uri or self.make_site_feed_uri(domain=domain, site=site)
|
||||
try:
|
||||
return self.Get(uri,
|
||||
url_params=url_params, extra_headers=extra_headers, escape_params=escape_params,
|
||||
converter=gdata.apps.sites.SiteFeedFromString)
|
||||
except gdata.service.RequestError as e:
|
||||
raise gdata.apps.service.AppsForYourDomainException(e.args[0])
|
||||
|
||||
GetSiteFeed = get_site_feed
|
||||
|
||||
def create_site(self, siteentry=None, uri=None, domain=None, site=None,
|
||||
extra_headers=None, url_params=None, escape_params=True):
|
||||
|
||||
if uri is None:
|
||||
uri = self.make_site_feed_uri(domain=domain, site=site)
|
||||
try:
|
||||
return self.Post(siteentry, uri,
|
||||
url_params=url_params, extra_headers=extra_headers, escape_params=escape_params,
|
||||
converter=gdata.apps.sites.SiteEntryFromString)
|
||||
except gdata.service.RequestError as e:
|
||||
raise gdata.apps.service.AppsForYourDomainException(e.args[0])
|
||||
|
||||
CreateSite = create_site
|
||||
|
||||
def get_site(self, uri=None, domain=None, site=None,
|
||||
extra_headers=None, url_params=None, escape_params=True):
|
||||
|
||||
uri = uri or self.make_site_feed_uri(domain=domain, site=site)
|
||||
try:
|
||||
return self.Get(uri,
|
||||
url_params=url_params, extra_headers=extra_headers, escape_params=escape_params,
|
||||
converter=gdata.apps.sites.SiteEntryFromString)
|
||||
except gdata.service.RequestError as e:
|
||||
raise gdata.apps.service.AppsForYourDomainException(e.args[0])
|
||||
|
||||
GetSite = get_site
|
||||
|
||||
def update_site(self, siteentry=None, uri=None, domain=None, site=None,
|
||||
extra_headers=None, url_params=None, escape_params=True):
|
||||
|
||||
uri = uri or self.make_site_feed_uri(domain=domain, site=site)
|
||||
try:
|
||||
return self.Put(siteentry, uri,
|
||||
url_params=url_params, extra_headers=extra_headers, escape_params=escape_params,
|
||||
converter=gdata.apps.sites.SiteEntryFromString)
|
||||
except gdata.service.RequestError as e:
|
||||
raise gdata.apps.service.AppsForYourDomainException(e.args[0])
|
||||
|
||||
UpdateSite = update_site
|
||||
|
||||
def make_acl_feed_uri(self, domain=None, site=None):
|
||||
return ACL_FEED_TEMPLATE % (domain, site)
|
||||
|
||||
MakeAclFeedUri = make_acl_feed_uri
|
||||
|
||||
def get_acl_feed(self, uri=None, domain=None, site=None,
|
||||
extra_headers=None, url_params=None, escape_params=True):
|
||||
|
||||
uri = uri or self.make_acl_feed_uri(domain=domain, site=site)
|
||||
try:
|
||||
return self.Get(uri,
|
||||
url_params=url_params, extra_headers=extra_headers, escape_params=escape_params,
|
||||
converter=gdata.apps.sites.AclFeedFromString)
|
||||
except gdata.service.RequestError as e:
|
||||
raise gdata.apps.service.AppsForYourDomainException(e.args[0])
|
||||
|
||||
GetAclFeed = get_acl_feed
|
||||
|
||||
def make_acl_entry_uri(self, domain=None, site=None, ruleId=None):
|
||||
return ACL_ENTRY_TEMPLATE % (domain, site, ruleId)
|
||||
|
||||
MakeAclEntryUri = make_acl_entry_uri
|
||||
|
||||
def create_acl_entry(self, aclentry=None, uri=None, domain=None, site=None,
|
||||
extra_headers=None, url_params=None, escape_params=True):
|
||||
|
||||
uri = uri or self.make_acl_feed_uri(domain=domain, site=site)
|
||||
try:
|
||||
return self.Post(aclentry, uri,
|
||||
url_params=url_params, extra_headers=extra_headers, escape_params=escape_params,
|
||||
converter=gdata.apps.sites.AclEntryFromString)
|
||||
except gdata.service.RequestError as e:
|
||||
raise gdata.apps.service.AppsForYourDomainException(e.args[0])
|
||||
|
||||
CreateAclEntry = create_acl_entry
|
||||
|
||||
def get_acl_entry(self, uri=None, domain=None, site=None, ruleId=None,
|
||||
extra_headers=None, url_params=None, escape_params=True):
|
||||
|
||||
uri = uri or self.make_acl_entry_uri(domain=domain, site=site, ruleId=ruleId)
|
||||
try:
|
||||
return self.Get(uri,
|
||||
url_params=url_params, extra_headers=extra_headers, escape_params=escape_params,
|
||||
converter=gdata.apps.sites.AclEntryFromString)
|
||||
except gdata.service.RequestError as e:
|
||||
raise gdata.apps.service.AppsForYourDomainException(e.args[0])
|
||||
|
||||
GetAclEntry = get_acl_entry
|
||||
|
||||
def update_acl_entry(self, aclentry=None, uri=None, domain=None, site=None, ruleId=None,
|
||||
extra_headers=None, url_params=None, escape_params=True):
|
||||
|
||||
uri = uri or self.make_acl_entry_uri(domain=domain, site=site, ruleId=ruleId)
|
||||
try:
|
||||
return self.Put(aclentry, uri,
|
||||
url_params=url_params, extra_headers=extra_headers, escape_params=escape_params,
|
||||
converter=gdata.apps.sites.AclEntryFromString)
|
||||
except gdata.service.RequestError as e:
|
||||
raise gdata.apps.service.AppsForYourDomainException(e.args[0])
|
||||
|
||||
UpdateAclEntry = update_acl_entry
|
||||
|
||||
def delete_acl_entry(self, uri=None, domain=None, site=None, ruleId=None,
|
||||
extra_headers=None, url_params=None, escape_params=True):
|
||||
|
||||
uri = uri or self.make_acl_entry_uri(domain=domain, site=site, ruleId=ruleId)
|
||||
try:
|
||||
return self.Delete(uri,
|
||||
url_params=url_params, escape_params=escape_params, extra_headers=extra_headers)
|
||||
except gdata.service.RequestError as e:
|
||||
raise gdata.apps.service.AppsForYourDomainException(e.args[0])
|
||||
|
||||
DeleteAclEntry = delete_acl_entry
|
||||
|
||||
def make_activity_feed_uri(self, domain=None, site=None):
|
||||
return ACTIVITY_FEED_TEMPLATE % (domain, site)
|
||||
|
||||
MakeActivityFeedUri = make_activity_feed_uri
|
||||
|
||||
def get_activity_feed(self, uri=None, domain=None, site=None,
|
||||
extra_headers=None, url_params=None, escape_params=True):
|
||||
|
||||
uri = uri or self.make_activity_feed_uri(domain=domain, site=site)
|
||||
try:
|
||||
return self.Get(uri,
|
||||
url_params=url_params, extra_headers=extra_headers, escape_params=escape_params,
|
||||
converter=gdata.apps.sites.ActivityFeedFromString)
|
||||
except gdata.service.RequestError as e:
|
||||
raise gdata.apps.service.AppsForYourDomainException(e.args[0])
|
||||
|
||||
GetActivityFeed = get_activity_feed
|
||||
|
||||
def make_activity_entry_uri(self, domain=None, site=None, activityId=None):
|
||||
return ACTIVITY_ENTRY_TEMPLATE % (domain, site, activityId)
|
||||
|
||||
MakeActivityEntryUri = make_activity_entry_uri
|
||||
|
||||
def get_activity_entry(self, uri=None, domain=None, site=None, activityId=None,
|
||||
extra_headers=None, url_params=None, escape_params=True):
|
||||
|
||||
uri = uri or self.make_activity_entry_uri(domain=domain, site=site, activityId=activityId)
|
||||
try:
|
||||
return self.Get(uri,
|
||||
url_params=url_params, extra_headers=extra_headers, escape_params=escape_params,
|
||||
converter=gdata.apps.sites.ActivityEntryFromString)
|
||||
except gdata.service.RequestError as e:
|
||||
raise gdata.apps.service.AppsForYourDomainException(e.args[0])
|
||||
|
||||
GetActivityEntry = get_activity_entry
|
||||
|
||||
class SitesQuery(gdata.service.Query):
|
||||
|
||||
def make_site_feed_uri(self, domain=None, site=None):
|
||||
if not domain:
|
||||
domain = 'site'
|
||||
if not site:
|
||||
return SITE_FEED_TEMPLATE % domain
|
||||
return (SITE_FEED_TEMPLATE % domain) + site
|
||||
|
||||
def __init__(self, feed=None, domain=None, site=None, params=None):
|
||||
self.feed = feed or self.make_site_feed_uri(domain=domain, site=site)
|
||||
gdata.service.Query.__init__(self, feed=self.feed, params=params)
|
||||
|
||||
Reference in New Issue
Block a user