forked from unfoldingWord-dev/python-gitea-client
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdates.py
More file actions
234 lines (198 loc) · 7.23 KB
/
Copy pathupdates.py
File metadata and controls
234 lines (198 loc) · 7.23 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
"""
Various classes representing update requests to Gogs
"""
class GogsUserUpdate(object):
"""
An immutable representation of a collection of Gogs user attributes to update.
Instances should be created using the :class:`~GogsUserUpdate.Builder` class.
"""
def __init__(self, source_id, login_name, full_name, email, password, website,
location, active, admin, allow_git_hook, allow_import_local):
self._source_id = source_id
self._login_name = login_name
self._full_name = full_name
self._email = email
self._password = password
self._website = website
self._location = location
self._active = active
self._admin = admin
self._allow_git_hook = allow_git_hook
self._allow_import_local = allow_import_local
def as_dict(self):
fields = {
"source_id": self._source_id,
"login_name": self._login_name,
"full_name": self._full_name,
"email": self._email,
"password": self._password,
"website": self._website,
"location": self._location,
"active": self._active,
"admin": self._admin,
"allow_git_hook": self._allow_git_hook,
"allow_import_local": self._allow_import_local
}
return {k: v for (k, v) in fields.items() if v is not None}
class Builder(object):
def __init__(self, login_name, email):
"""
:param str login_name: login name for authentication source
:param str email: email address of user to update
"""
self._source_id = None
self._login_name = login_name
self._full_name = None
self._email = email
self._password = None
self._website = None
self._location = None
self._active = None
self._admin = None
self._allow_git_hook = None
self._allow_import_local = None
def set_source_id(self, source_id):
"""
:param int source_id: Source id of authentication source
:return: the updated builder
:rtype: GogsUserUpdate.Builder
"""
self._source_id = source_id
return self
def set_full_name(self, full_name):
"""
:param str full_name: Updated full name for user
:return: the updated builder
:rtype: GogsUserUpdate.Builder
"""
self._full_name = full_name
return self
def set_password(self, password):
"""
:param str password: Updated password for user
:return: the updated builder
:rtype: GogsUserUpdate.Builder
"""
self._password = password
return self
def set_website(self, website):
"""
:param str website: Updated personal website for user
:return: the updated builder
:rtype: GogsUserUpdate.Builder
"""
self._website = website
return self
def set_location(self, location):
"""
:param str location: Updated location for user
:return: the updated builder
:rtype: GogsUserUpdate.Builder
"""
self._location = location
return self
def set_active(self, active):
"""
:param bool active: set true/false to signal that the updated user should be
activated/deactivated
:return: the updated builder
:rtype: GogsUserUpdate.Builder
"""
self._active = active
return self
def set_admin(self, admin):
"""
:param bool admin: whether the updated user should be admin
:return: the updated builder
:rtype: GogsUserUpdate.Builder
"""
self._admin = admin
return self
def set_allow_git_hook(self, allow_git_hook):
"""
:param bool allow_git_hook: whether the updated user should be allowed to use Git hooks
:return: the updated builder
:rtype: GogsUserUpdate.Builder
"""
self._allow_git_hook = allow_git_hook
return self
def set_allow_import_local(self, allow_import_local):
"""
:param bool allow_import_local: whether the updated user should be allowed to
import local repositories
:return: the updated builder
:rtype: GogsUserUpdate.Builder
"""
self._allow_import_local = allow_import_local
return self
def build(self):
"""
:return: A :class:`~GogsUserUpdate` instance reflecting the changes added to the builder.
:rtype: GogsUserUpdate
"""
return GogsUserUpdate(
source_id=self._source_id,
login_name=self._login_name,
full_name=self._full_name,
email=self._email,
password=self._password,
website=self._website,
location=self._location,
active=self._active,
admin=self._admin,
allow_git_hook=self._allow_git_hook,
allow_import_local=self._allow_import_local)
class GogsHookUpdate(object):
"""
An immutable representation of a collection of Gogs hook attributes to update.
Instances should be created using the :class:`~GogsHookUpdate.Builder` class.
"""
def __init__(self, events, config, active):
self._events = events
self._config = config
self._active = active
def as_dict(self):
fields = {
"events": self._events,
"config": self._config,
"active": self._active,
}
return {k: v for (k, v) in fields.items() if v is not None}
class Builder(object):
def __init__(self):
self._events = None
self._config = None
self._active = None
def set_events(self, events):
"""
:param List[str] events:
:return: the updated builder
:rtype: GogsHookUpdate.Builder
"""
self._events = events
return self
def set_config(self, config):
"""
:param dict config:
:return: the updated builder
:rtype: GogsHookUpdate.Builder
"""
self._config = config
return self
def set_active(self, active):
"""
:param bool active:
:return: the updated builder
:rtype: GogsHookUpdate.Builder
"""
self._active = active
return self
def build(self):
"""
:return: A :class:`~GogsHookUpdate` instance reflecting the changes added to the builder.
:rtype: GogsHookUpdate
"""
return GogsHookUpdate(
events=self._events,
config=self._config,
active=self._active)