forked from google/gdata-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
236 lines (177 loc) · 6.92 KB
/
data.py
File metadata and controls
236 lines (177 loc) · 6.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/usr/bin/python
#
# Copyright 2011 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 the Groups Provisioning API."""
__author__ = 'Shraddha gupta <shraddhag@google.com>'
import atom.data
import gdata.apps
import gdata.apps.apps_property_entry
import gdata.apps_property
import gdata.data
# This is required to work around a naming conflict between the Google
# Spreadsheets API and Python's built-in property function
pyproperty = property
# The apps:property groupId of a group entry
GROUP_ID = 'groupId'
# The apps:property groupName of a group entry
GROUP_NAME = 'groupName'
# The apps:property description of a group entry
DESCRIPTION = 'description'
# The apps:property emailPermission of a group entry
EMAIL_PERMISSION = 'emailPermission'
# The apps:property memberId of a group member entry
MEMBER_ID = 'memberId'
# The apps:property memberType of a group member entry
MEMBER_TYPE = 'memberType'
# The apps:property directMember of a group member entry
DIRECT_MEMBER = 'directMember'
class GroupEntry(gdata.apps.apps_property_entry.AppsPropertyEntry):
"""Represents a group entry in object form."""
def GetGroupId(self):
"""Get groupId of the GroupEntry object.
Returns:
The groupId this GroupEntry object as a string or None.
"""
return self._GetProperty(GROUP_ID)
def SetGroupId(self, value):
"""Set the groupId of this GroupEntry object.
Args:
value: string The new groupId to give this object.
"""
self._SetProperty(GROUP_ID, value)
group_id = pyproperty(GetGroupId, SetGroupId)
def GetGroupName(self):
"""Get the groupName of the GroupEntry object.
Returns:
The groupName of this GroupEntry object as a string or None.
"""
return self._GetProperty(GROUP_NAME)
def SetGroupName(self, value):
"""Set the groupName of this GroupEntry object.
Args:
value: string The new groupName to give this object.
"""
self._SetProperty(GROUP_NAME, value)
group_name = pyproperty(GetGroupName, SetGroupName)
def GetDescription(self):
"""Get the description of the GroupEntry object.
Returns:
The description of this GroupEntry object as a string or None.
"""
return self._GetProperty(DESCRIPTION)
def SetDescription(self, value):
"""Set the description of this GroupEntry object.
Args:
value: string The new description to give this object.
"""
self._SetProperty(DESCRIPTION, value)
description = pyproperty(GetDescription, SetDescription)
def GetEmailPermission(self):
"""Get the emailPermission of the GroupEntry object.
Returns:
The emailPermission of this GroupEntry object as a string or None.
"""
return self._GetProperty(EMAIL_PERMISSION)
def SetEmailPermission(self, value):
"""Set the emailPermission of this GroupEntry object.
Args:
value: string The new emailPermission to give this object.
"""
self._SetProperty(EMAIL_PERMISSION, value)
email_permission = pyproperty(GetEmailPermission, SetEmailPermission)
def __init__(self, group_id=None, group_name=None, description=None,
email_permission=None, *args, **kwargs):
"""Constructs a new GroupEntry object with the given arguments.
Args:
group_id: string identifier of the group.
group_name: string name of the group.
description: string (optional) the group description.
email_permisison: string (optional) permission level of the group.
"""
super(GroupEntry, self).__init__(*args, **kwargs)
if group_id:
self.group_id = group_id
if group_name:
self.group_name = group_name
if description:
self.description = description
if email_permission:
self.email_permission = email_permission
class GroupFeed(gdata.data.GDFeed):
"""Represents a feed of GroupEntry objects."""
# Override entry so that this feed knows how to type its list of entries.
entry = [GroupEntry]
class GroupMemberEntry(gdata.apps.apps_property_entry.AppsPropertyEntry):
"""Represents a group member in object form."""
def GetMemberId(self):
"""Get the memberId of the GroupMember object.
Returns:
The memberId of this GroupMember object as a string.
"""
return self._GetProperty(MEMBER_ID)
def SetMemberId(self, value):
"""Set the memberId of this GroupMember object.
Args:
value: string The new memberId to give this object.
"""
self._SetProperty(MEMBER_ID, value)
member_id = pyproperty(GetMemberId, SetMemberId)
def GetMemberType(self):
"""Get the memberType(User, Group) of the GroupMember object.
Returns:
The memberType of this GroupMember object as a string or None.
"""
return self._GetProperty(MEMBER_TYPE)
def SetMemberType(self, value):
"""Set the memberType of this GroupMember object.
Args:
value: string The new memberType to give this object.
"""
self._SetProperty(MEMBER_TYPE, value)
member_type = pyproperty(GetMemberType, SetMemberType)
def GetDirectMember(self):
"""Get the directMember of the GroupMember object.
Returns:
The directMember of this GroupMember object as a bool or None.
"""
return self._GetProperty(DIRECT_MEMBER)
def SetDirectMember(self, value):
"""Set the memberType of this GroupMember object.
Args:
value: string The new memberType to give this object.
"""
self._SetProperty(DIRECT_MEMBER, value)
direct_member = pyproperty(GetDirectMember, SetDirectMember)
def __init__(self, member_id=None, member_type=None,
direct_member=None, *args, **kwargs):
"""Constructs a new GroupMemberEntry object with the given arguments.
Args:
member_id: string identifier of group member object.
member_type: string (optional) member type of group member object.
direct_member: bool (optional) if group member object is direct member.
args: The other parameters to pass to gdata.entry.GDEntry constructor.
kwargs: The other parameters to pass to gdata.entry.GDEntry constructor.
"""
super(GroupMemberEntry, self).__init__(*args, **kwargs)
if member_id:
self.member_id = member_id
if member_type:
self.member_type = member_type
if direct_member:
self.direct_member = direct_member
class GroupMemberFeed(gdata.data.GDFeed):
"""Represents a feed of GroupMemberEntry objects."""
# Override entry so that this feed knows how to type its list of entries.
entry = [GroupMemberEntry]