files-com 1.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of files-com might be problematic. Click here for more details.
- README.md +682 -0
- _VERSION +1 -0
- files_com-1.5.0.dist-info/METADATA +694 -0
- files_com-1.5.0.dist-info/RECORD +113 -0
- files_com-1.5.0.dist-info/WHEEL +5 -0
- files_com-1.5.0.dist-info/licenses/LICENSE +21 -0
- files_com-1.5.0.dist-info/top_level.txt +1 -0
- files_sdk/__init__.py +270 -0
- files_sdk/api.py +57 -0
- files_sdk/api_client.py +327 -0
- files_sdk/error.py +2891 -0
- files_sdk/list_obj.py +42 -0
- files_sdk/models/__init__.py +104 -0
- files_sdk/models/account_line_item.py +51 -0
- files_sdk/models/action.py +49 -0
- files_sdk/models/action_notification_export.py +147 -0
- files_sdk/models/action_notification_export_result.py +88 -0
- files_sdk/models/api_key.py +322 -0
- files_sdk/models/api_request_log.py +87 -0
- files_sdk/models/app.py +89 -0
- files_sdk/models/as2_incoming_message.py +123 -0
- files_sdk/models/as2_outgoing_message.py +119 -0
- files_sdk/models/as2_partner.py +374 -0
- files_sdk/models/as2_station.py +271 -0
- files_sdk/models/auto.py +36 -0
- files_sdk/models/automation.py +691 -0
- files_sdk/models/automation_log.py +77 -0
- files_sdk/models/automation_run.py +108 -0
- files_sdk/models/bandwidth_snapshot.py +91 -0
- files_sdk/models/behavior.py +334 -0
- files_sdk/models/bundle.py +550 -0
- files_sdk/models/bundle_action.py +86 -0
- files_sdk/models/bundle_download.py +94 -0
- files_sdk/models/bundle_notification.py +217 -0
- files_sdk/models/bundle_path.py +37 -0
- files_sdk/models/bundle_recipient.py +120 -0
- files_sdk/models/bundle_registration.py +79 -0
- files_sdk/models/clickwrap.py +268 -0
- files_sdk/models/dns_record.py +59 -0
- files_sdk/models/email_incoming_message.py +102 -0
- files_sdk/models/email_log.py +74 -0
- files_sdk/models/errors.py +37 -0
- files_sdk/models/exavault_api_request_log.py +85 -0
- files_sdk/models/external_event.py +148 -0
- files_sdk/models/file.py +791 -0
- files_sdk/models/file_action.py +39 -0
- files_sdk/models/file_comment.py +191 -0
- files_sdk/models/file_comment_reaction.py +125 -0
- files_sdk/models/file_migration.py +69 -0
- files_sdk/models/file_migration_log.py +78 -0
- files_sdk/models/file_upload_part.py +54 -0
- files_sdk/models/folder.py +154 -0
- files_sdk/models/form_field.py +43 -0
- files_sdk/models/form_field_set.py +240 -0
- files_sdk/models/ftp_action_log.py +87 -0
- files_sdk/models/gpg_key.py +254 -0
- files_sdk/models/group.py +276 -0
- files_sdk/models/group_user.py +231 -0
- files_sdk/models/history.py +236 -0
- files_sdk/models/history_export.py +238 -0
- files_sdk/models/history_export_result.py +98 -0
- files_sdk/models/image.py +37 -0
- files_sdk/models/inbox_recipient.py +118 -0
- files_sdk/models/inbox_registration.py +79 -0
- files_sdk/models/inbox_upload.py +80 -0
- files_sdk/models/invoice.py +91 -0
- files_sdk/models/invoice_line_item.py +46 -0
- files_sdk/models/ip_address.py +119 -0
- files_sdk/models/lock.py +158 -0
- files_sdk/models/message.py +244 -0
- files_sdk/models/message_comment.py +223 -0
- files_sdk/models/message_comment_reaction.py +181 -0
- files_sdk/models/message_reaction.py +170 -0
- files_sdk/models/notification.py +357 -0
- files_sdk/models/outbound_connection_log.py +88 -0
- files_sdk/models/payment.py +91 -0
- files_sdk/models/payment_line_item.py +42 -0
- files_sdk/models/permission.py +174 -0
- files_sdk/models/preview.py +40 -0
- files_sdk/models/priority.py +63 -0
- files_sdk/models/project.py +205 -0
- files_sdk/models/public_hosting_request_log.py +82 -0
- files_sdk/models/public_ip_address.py +42 -0
- files_sdk/models/public_key.py +212 -0
- files_sdk/models/remote_bandwidth_snapshot.py +91 -0
- files_sdk/models/remote_server.py +1677 -0
- files_sdk/models/remote_server_configuration_file.py +72 -0
- files_sdk/models/request.py +180 -0
- files_sdk/models/restore.py +104 -0
- files_sdk/models/session.py +100 -0
- files_sdk/models/settings_change.py +71 -0
- files_sdk/models/sftp_action_log.py +91 -0
- files_sdk/models/sftp_host_key.py +215 -0
- files_sdk/models/share_group.py +228 -0
- files_sdk/models/share_group_member.py +41 -0
- files_sdk/models/siem_http_destination.py +773 -0
- files_sdk/models/site.py +767 -0
- files_sdk/models/snapshot.py +255 -0
- files_sdk/models/sso_strategy.py +167 -0
- files_sdk/models/status.py +42 -0
- files_sdk/models/style.py +152 -0
- files_sdk/models/sync_log.py +75 -0
- files_sdk/models/usage_by_top_level_dir.py +41 -0
- files_sdk/models/usage_daily_snapshot.py +93 -0
- files_sdk/models/usage_snapshot.py +73 -0
- files_sdk/models/user.py +893 -0
- files_sdk/models/user_cipher_use.py +68 -0
- files_sdk/models/user_request.py +166 -0
- files_sdk/models/user_sftp_client_use.py +68 -0
- files_sdk/models/web_dav_action_log.py +87 -0
- files_sdk/models/webhook_test.py +104 -0
- files_sdk/path_util.py +42 -0
- files_sdk/util.py +34 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import builtins # noqa: F401
|
|
2
|
+
from files_sdk.api import Api # noqa: F401
|
|
3
|
+
from files_sdk.list_obj import ListObj
|
|
4
|
+
from files_sdk.error import ( # noqa: F401
|
|
5
|
+
InvalidParameterError,
|
|
6
|
+
MissingParameterError,
|
|
7
|
+
NotImplementedError,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Group:
|
|
12
|
+
default_attributes = {
|
|
13
|
+
"id": None, # int64 - Group ID
|
|
14
|
+
"name": None, # string - Group name
|
|
15
|
+
"allowed_ips": None, # string - A list of allowed IPs if applicable. Newline delimited
|
|
16
|
+
"admin_ids": None, # string - Comma-delimited list of user IDs who are group administrators (separated by commas)
|
|
17
|
+
"notes": None, # string - Notes about this group
|
|
18
|
+
"user_ids": None, # string - Comma-delimited list of user IDs who belong to this group (separated by commas)
|
|
19
|
+
"usernames": None, # string - Comma-delimited list of usernames who belong to this group (separated by commas)
|
|
20
|
+
"ftp_permission": None, # boolean - If true, users in this group can use FTP to login. This will override a false value of `ftp_permission` on the user level.
|
|
21
|
+
"sftp_permission": None, # boolean - If true, users in this group can use SFTP to login. This will override a false value of `sftp_permission` on the user level.
|
|
22
|
+
"dav_permission": None, # boolean - If true, users in this group can use WebDAV to login. This will override a false value of `dav_permission` on the user level.
|
|
23
|
+
"restapi_permission": None, # boolean - If true, users in this group can use the REST API to login. This will override a false value of `restapi_permission` on the user level.
|
|
24
|
+
"site_id": None, # int64 - Site ID
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
def __init__(self, attributes=None, options=None):
|
|
28
|
+
if not isinstance(attributes, dict):
|
|
29
|
+
attributes = {}
|
|
30
|
+
if not isinstance(options, dict):
|
|
31
|
+
options = {}
|
|
32
|
+
self.set_attributes(attributes)
|
|
33
|
+
self.options = options
|
|
34
|
+
|
|
35
|
+
def set_attributes(self, attributes):
|
|
36
|
+
for attribute, default_value in Group.default_attributes.items():
|
|
37
|
+
setattr(self, attribute, attributes.get(attribute, default_value))
|
|
38
|
+
|
|
39
|
+
def get_attributes(self):
|
|
40
|
+
return {
|
|
41
|
+
k: getattr(self, k, None)
|
|
42
|
+
for k in Group.default_attributes
|
|
43
|
+
if getattr(self, k, None) is not None
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# Parameters:
|
|
47
|
+
# notes - string - Group notes.
|
|
48
|
+
# user_ids - string - A list of user ids. If sent as a string, should be comma-delimited.
|
|
49
|
+
# admin_ids - string - A list of group admin user ids. If sent as a string, should be comma-delimited.
|
|
50
|
+
# ftp_permission - boolean - If true, users in this group can use FTP to login. This will override a false value of `ftp_permission` on the user level.
|
|
51
|
+
# sftp_permission - boolean - If true, users in this group can use SFTP to login. This will override a false value of `sftp_permission` on the user level.
|
|
52
|
+
# dav_permission - boolean - If true, users in this group can use WebDAV to login. This will override a false value of `dav_permission` on the user level.
|
|
53
|
+
# restapi_permission - boolean - If true, users in this group can use the REST API to login. This will override a false value of `restapi_permission` on the user level.
|
|
54
|
+
# allowed_ips - string - A list of allowed IPs if applicable. Newline delimited
|
|
55
|
+
# name - string - Group name.
|
|
56
|
+
def update(self, params=None):
|
|
57
|
+
if not isinstance(params, dict):
|
|
58
|
+
params = {}
|
|
59
|
+
|
|
60
|
+
if hasattr(self, "id") and self.id:
|
|
61
|
+
params["id"] = self.id
|
|
62
|
+
else:
|
|
63
|
+
raise MissingParameterError("Current object doesn't have a id")
|
|
64
|
+
if "id" not in params:
|
|
65
|
+
raise MissingParameterError("Parameter missing: id")
|
|
66
|
+
if "id" in params and not isinstance(params["id"], int):
|
|
67
|
+
raise InvalidParameterError("Bad parameter: id must be an int")
|
|
68
|
+
if "notes" in params and not isinstance(params["notes"], str):
|
|
69
|
+
raise InvalidParameterError("Bad parameter: notes must be an str")
|
|
70
|
+
if "user_ids" in params and not isinstance(params["user_ids"], str):
|
|
71
|
+
raise InvalidParameterError(
|
|
72
|
+
"Bad parameter: user_ids must be an str"
|
|
73
|
+
)
|
|
74
|
+
if "admin_ids" in params and not isinstance(params["admin_ids"], str):
|
|
75
|
+
raise InvalidParameterError(
|
|
76
|
+
"Bad parameter: admin_ids must be an str"
|
|
77
|
+
)
|
|
78
|
+
if "allowed_ips" in params and not isinstance(
|
|
79
|
+
params["allowed_ips"], str
|
|
80
|
+
):
|
|
81
|
+
raise InvalidParameterError(
|
|
82
|
+
"Bad parameter: allowed_ips must be an str"
|
|
83
|
+
)
|
|
84
|
+
if "name" in params and not isinstance(params["name"], str):
|
|
85
|
+
raise InvalidParameterError("Bad parameter: name must be an str")
|
|
86
|
+
response, _options = Api.send_request(
|
|
87
|
+
"PATCH",
|
|
88
|
+
"/groups/{id}".format(id=params["id"]),
|
|
89
|
+
params,
|
|
90
|
+
self.options,
|
|
91
|
+
)
|
|
92
|
+
return response.data
|
|
93
|
+
|
|
94
|
+
def delete(self, params=None):
|
|
95
|
+
if not isinstance(params, dict):
|
|
96
|
+
params = {}
|
|
97
|
+
|
|
98
|
+
if hasattr(self, "id") and self.id:
|
|
99
|
+
params["id"] = self.id
|
|
100
|
+
else:
|
|
101
|
+
raise MissingParameterError("Current object doesn't have a id")
|
|
102
|
+
if "id" not in params:
|
|
103
|
+
raise MissingParameterError("Parameter missing: id")
|
|
104
|
+
if "id" in params and not isinstance(params["id"], int):
|
|
105
|
+
raise InvalidParameterError("Bad parameter: id must be an int")
|
|
106
|
+
Api.send_request(
|
|
107
|
+
"DELETE",
|
|
108
|
+
"/groups/{id}".format(id=params["id"]),
|
|
109
|
+
params,
|
|
110
|
+
self.options,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
def destroy(self, params=None):
|
|
114
|
+
self.delete(params)
|
|
115
|
+
|
|
116
|
+
def save(self):
|
|
117
|
+
if hasattr(self, "id") and self.id:
|
|
118
|
+
new_obj = self.update(self.get_attributes())
|
|
119
|
+
self.set_attributes(new_obj.get_attributes())
|
|
120
|
+
return True
|
|
121
|
+
else:
|
|
122
|
+
new_obj = create(self.get_attributes(), self.options)
|
|
123
|
+
self.set_attributes(new_obj.get_attributes())
|
|
124
|
+
return True
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
# Parameters:
|
|
128
|
+
# cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
|
|
129
|
+
# per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
|
130
|
+
# sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are `site_id` and `name`.
|
|
131
|
+
# filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `name`.
|
|
132
|
+
# filter_prefix - object - If set, return records where the specified field is prefixed by the supplied value. Valid fields are `name`.
|
|
133
|
+
# ids - string - Comma-separated list of group ids to include in results.
|
|
134
|
+
# include_parent_site_groups - boolean - Include groups from the parent site.
|
|
135
|
+
def list(params=None, options=None):
|
|
136
|
+
if not isinstance(params, dict):
|
|
137
|
+
params = {}
|
|
138
|
+
if not isinstance(options, dict):
|
|
139
|
+
options = {}
|
|
140
|
+
if "cursor" in params and not isinstance(params["cursor"], str):
|
|
141
|
+
raise InvalidParameterError("Bad parameter: cursor must be an str")
|
|
142
|
+
if "per_page" in params and not isinstance(params["per_page"], int):
|
|
143
|
+
raise InvalidParameterError("Bad parameter: per_page must be an int")
|
|
144
|
+
if "sort_by" in params and not isinstance(params["sort_by"], dict):
|
|
145
|
+
raise InvalidParameterError("Bad parameter: sort_by must be an dict")
|
|
146
|
+
if "filter" in params and not isinstance(params["filter"], dict):
|
|
147
|
+
raise InvalidParameterError("Bad parameter: filter must be an dict")
|
|
148
|
+
if "filter_prefix" in params and not isinstance(
|
|
149
|
+
params["filter_prefix"], dict
|
|
150
|
+
):
|
|
151
|
+
raise InvalidParameterError(
|
|
152
|
+
"Bad parameter: filter_prefix must be an dict"
|
|
153
|
+
)
|
|
154
|
+
if "ids" in params and not isinstance(params["ids"], str):
|
|
155
|
+
raise InvalidParameterError("Bad parameter: ids must be an str")
|
|
156
|
+
return ListObj(Group, "GET", "/groups", params, options)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def all(params=None, options=None):
|
|
160
|
+
list(params, options)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
# Parameters:
|
|
164
|
+
# id (required) - int64 - Group ID.
|
|
165
|
+
def find(id, params=None, options=None):
|
|
166
|
+
if not isinstance(params, dict):
|
|
167
|
+
params = {}
|
|
168
|
+
if not isinstance(options, dict):
|
|
169
|
+
options = {}
|
|
170
|
+
params["id"] = id
|
|
171
|
+
if "id" in params and not isinstance(params["id"], int):
|
|
172
|
+
raise InvalidParameterError("Bad parameter: id must be an int")
|
|
173
|
+
if "id" not in params:
|
|
174
|
+
raise MissingParameterError("Parameter missing: id")
|
|
175
|
+
response, options = Api.send_request(
|
|
176
|
+
"GET", "/groups/{id}".format(id=params["id"]), params, options
|
|
177
|
+
)
|
|
178
|
+
return Group(response.data, options)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def get(id, params=None, options=None):
|
|
182
|
+
find(id, params, options)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
# Parameters:
|
|
186
|
+
# notes - string - Group notes.
|
|
187
|
+
# user_ids - string - A list of user ids. If sent as a string, should be comma-delimited.
|
|
188
|
+
# admin_ids - string - A list of group admin user ids. If sent as a string, should be comma-delimited.
|
|
189
|
+
# ftp_permission - boolean - If true, users in this group can use FTP to login. This will override a false value of `ftp_permission` on the user level.
|
|
190
|
+
# sftp_permission - boolean - If true, users in this group can use SFTP to login. This will override a false value of `sftp_permission` on the user level.
|
|
191
|
+
# dav_permission - boolean - If true, users in this group can use WebDAV to login. This will override a false value of `dav_permission` on the user level.
|
|
192
|
+
# restapi_permission - boolean - If true, users in this group can use the REST API to login. This will override a false value of `restapi_permission` on the user level.
|
|
193
|
+
# allowed_ips - string - A list of allowed IPs if applicable. Newline delimited
|
|
194
|
+
# name (required) - string - Group name.
|
|
195
|
+
def create(params=None, options=None):
|
|
196
|
+
if not isinstance(params, dict):
|
|
197
|
+
params = {}
|
|
198
|
+
if not isinstance(options, dict):
|
|
199
|
+
options = {}
|
|
200
|
+
if "notes" in params and not isinstance(params["notes"], str):
|
|
201
|
+
raise InvalidParameterError("Bad parameter: notes must be an str")
|
|
202
|
+
if "user_ids" in params and not isinstance(params["user_ids"], str):
|
|
203
|
+
raise InvalidParameterError("Bad parameter: user_ids must be an str")
|
|
204
|
+
if "admin_ids" in params and not isinstance(params["admin_ids"], str):
|
|
205
|
+
raise InvalidParameterError("Bad parameter: admin_ids must be an str")
|
|
206
|
+
if "allowed_ips" in params and not isinstance(params["allowed_ips"], str):
|
|
207
|
+
raise InvalidParameterError(
|
|
208
|
+
"Bad parameter: allowed_ips must be an str"
|
|
209
|
+
)
|
|
210
|
+
if "name" in params and not isinstance(params["name"], str):
|
|
211
|
+
raise InvalidParameterError("Bad parameter: name must be an str")
|
|
212
|
+
if "name" not in params:
|
|
213
|
+
raise MissingParameterError("Parameter missing: name")
|
|
214
|
+
response, options = Api.send_request("POST", "/groups", params, options)
|
|
215
|
+
return Group(response.data, options)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
# Parameters:
|
|
219
|
+
# notes - string - Group notes.
|
|
220
|
+
# user_ids - string - A list of user ids. If sent as a string, should be comma-delimited.
|
|
221
|
+
# admin_ids - string - A list of group admin user ids. If sent as a string, should be comma-delimited.
|
|
222
|
+
# ftp_permission - boolean - If true, users in this group can use FTP to login. This will override a false value of `ftp_permission` on the user level.
|
|
223
|
+
# sftp_permission - boolean - If true, users in this group can use SFTP to login. This will override a false value of `sftp_permission` on the user level.
|
|
224
|
+
# dav_permission - boolean - If true, users in this group can use WebDAV to login. This will override a false value of `dav_permission` on the user level.
|
|
225
|
+
# restapi_permission - boolean - If true, users in this group can use the REST API to login. This will override a false value of `restapi_permission` on the user level.
|
|
226
|
+
# allowed_ips - string - A list of allowed IPs if applicable. Newline delimited
|
|
227
|
+
# name - string - Group name.
|
|
228
|
+
def update(id, params=None, options=None):
|
|
229
|
+
if not isinstance(params, dict):
|
|
230
|
+
params = {}
|
|
231
|
+
if not isinstance(options, dict):
|
|
232
|
+
options = {}
|
|
233
|
+
params["id"] = id
|
|
234
|
+
if "id" in params and not isinstance(params["id"], int):
|
|
235
|
+
raise InvalidParameterError("Bad parameter: id must be an int")
|
|
236
|
+
if "notes" in params and not isinstance(params["notes"], str):
|
|
237
|
+
raise InvalidParameterError("Bad parameter: notes must be an str")
|
|
238
|
+
if "user_ids" in params and not isinstance(params["user_ids"], str):
|
|
239
|
+
raise InvalidParameterError("Bad parameter: user_ids must be an str")
|
|
240
|
+
if "admin_ids" in params and not isinstance(params["admin_ids"], str):
|
|
241
|
+
raise InvalidParameterError("Bad parameter: admin_ids must be an str")
|
|
242
|
+
if "allowed_ips" in params and not isinstance(params["allowed_ips"], str):
|
|
243
|
+
raise InvalidParameterError(
|
|
244
|
+
"Bad parameter: allowed_ips must be an str"
|
|
245
|
+
)
|
|
246
|
+
if "name" in params and not isinstance(params["name"], str):
|
|
247
|
+
raise InvalidParameterError("Bad parameter: name must be an str")
|
|
248
|
+
if "id" not in params:
|
|
249
|
+
raise MissingParameterError("Parameter missing: id")
|
|
250
|
+
response, options = Api.send_request(
|
|
251
|
+
"PATCH", "/groups/{id}".format(id=params["id"]), params, options
|
|
252
|
+
)
|
|
253
|
+
return Group(response.data, options)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def delete(id, params=None, options=None):
|
|
257
|
+
if not isinstance(params, dict):
|
|
258
|
+
params = {}
|
|
259
|
+
if not isinstance(options, dict):
|
|
260
|
+
options = {}
|
|
261
|
+
params["id"] = id
|
|
262
|
+
if "id" in params and not isinstance(params["id"], int):
|
|
263
|
+
raise InvalidParameterError("Bad parameter: id must be an int")
|
|
264
|
+
if "id" not in params:
|
|
265
|
+
raise MissingParameterError("Parameter missing: id")
|
|
266
|
+
Api.send_request(
|
|
267
|
+
"DELETE", "/groups/{id}".format(id=params["id"]), params, options
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def destroy(id, params=None, options=None):
|
|
272
|
+
delete(id, params, options)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def new(*args, **kwargs):
|
|
276
|
+
return Group(*args, **kwargs)
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import builtins # noqa: F401
|
|
2
|
+
from files_sdk.api import Api # noqa: F401
|
|
3
|
+
from files_sdk.list_obj import ListObj
|
|
4
|
+
from files_sdk.error import ( # noqa: F401
|
|
5
|
+
InvalidParameterError,
|
|
6
|
+
MissingParameterError,
|
|
7
|
+
NotImplementedError,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class GroupUser:
|
|
12
|
+
default_attributes = {
|
|
13
|
+
"group_name": None, # string - Group name
|
|
14
|
+
"group_id": None, # int64 - Group ID
|
|
15
|
+
"user_id": None, # int64 - User ID
|
|
16
|
+
"admin": None, # boolean - Is this user an administrator of this group?
|
|
17
|
+
"usernames": None, # string - Comma-delimited list of usernames who belong to this group (separated by commas).
|
|
18
|
+
"id": None, # int64 - Group User ID.
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
def __init__(self, attributes=None, options=None):
|
|
22
|
+
if not isinstance(attributes, dict):
|
|
23
|
+
attributes = {}
|
|
24
|
+
if not isinstance(options, dict):
|
|
25
|
+
options = {}
|
|
26
|
+
self.set_attributes(attributes)
|
|
27
|
+
self.options = options
|
|
28
|
+
|
|
29
|
+
def set_attributes(self, attributes):
|
|
30
|
+
for attribute, default_value in GroupUser.default_attributes.items():
|
|
31
|
+
setattr(self, attribute, attributes.get(attribute, default_value))
|
|
32
|
+
|
|
33
|
+
def get_attributes(self):
|
|
34
|
+
return {
|
|
35
|
+
k: getattr(self, k, None)
|
|
36
|
+
for k in GroupUser.default_attributes
|
|
37
|
+
if getattr(self, k, None) is not None
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# Parameters:
|
|
41
|
+
# group_id (required) - int64 - Group ID to add user to.
|
|
42
|
+
# user_id (required) - int64 - User ID to add to group.
|
|
43
|
+
# admin - boolean - Is the user a group administrator?
|
|
44
|
+
def update(self, params=None):
|
|
45
|
+
if not isinstance(params, dict):
|
|
46
|
+
params = {}
|
|
47
|
+
|
|
48
|
+
if hasattr(self, "id") and self.id:
|
|
49
|
+
params["id"] = self.id
|
|
50
|
+
else:
|
|
51
|
+
raise MissingParameterError("Current object doesn't have a id")
|
|
52
|
+
if "id" not in params:
|
|
53
|
+
raise MissingParameterError("Parameter missing: id")
|
|
54
|
+
if "group_id" not in params:
|
|
55
|
+
raise MissingParameterError("Parameter missing: group_id")
|
|
56
|
+
if "user_id" not in params:
|
|
57
|
+
raise MissingParameterError("Parameter missing: user_id")
|
|
58
|
+
if "id" in params and not isinstance(params["id"], int):
|
|
59
|
+
raise InvalidParameterError("Bad parameter: id must be an int")
|
|
60
|
+
if "group_id" in params and not isinstance(params["group_id"], int):
|
|
61
|
+
raise InvalidParameterError(
|
|
62
|
+
"Bad parameter: group_id must be an int"
|
|
63
|
+
)
|
|
64
|
+
if "user_id" in params and not isinstance(params["user_id"], int):
|
|
65
|
+
raise InvalidParameterError(
|
|
66
|
+
"Bad parameter: user_id must be an int"
|
|
67
|
+
)
|
|
68
|
+
response, _options = Api.send_request(
|
|
69
|
+
"PATCH",
|
|
70
|
+
"/group_users/{id}".format(id=params["id"]),
|
|
71
|
+
params,
|
|
72
|
+
self.options,
|
|
73
|
+
)
|
|
74
|
+
return response.data
|
|
75
|
+
|
|
76
|
+
# Parameters:
|
|
77
|
+
# group_id (required) - int64 - Group ID from which to remove user.
|
|
78
|
+
# user_id (required) - int64 - User ID to remove from group.
|
|
79
|
+
def delete(self, params=None):
|
|
80
|
+
if not isinstance(params, dict):
|
|
81
|
+
params = {}
|
|
82
|
+
|
|
83
|
+
if hasattr(self, "id") and self.id:
|
|
84
|
+
params["id"] = self.id
|
|
85
|
+
else:
|
|
86
|
+
raise MissingParameterError("Current object doesn't have a id")
|
|
87
|
+
if "id" not in params:
|
|
88
|
+
raise MissingParameterError("Parameter missing: id")
|
|
89
|
+
if "group_id" not in params:
|
|
90
|
+
raise MissingParameterError("Parameter missing: group_id")
|
|
91
|
+
if "user_id" not in params:
|
|
92
|
+
raise MissingParameterError("Parameter missing: user_id")
|
|
93
|
+
if "id" in params and not isinstance(params["id"], int):
|
|
94
|
+
raise InvalidParameterError("Bad parameter: id must be an int")
|
|
95
|
+
if "group_id" in params and not isinstance(params["group_id"], int):
|
|
96
|
+
raise InvalidParameterError(
|
|
97
|
+
"Bad parameter: group_id must be an int"
|
|
98
|
+
)
|
|
99
|
+
if "user_id" in params and not isinstance(params["user_id"], int):
|
|
100
|
+
raise InvalidParameterError(
|
|
101
|
+
"Bad parameter: user_id must be an int"
|
|
102
|
+
)
|
|
103
|
+
Api.send_request(
|
|
104
|
+
"DELETE",
|
|
105
|
+
"/group_users/{id}".format(id=params["id"]),
|
|
106
|
+
params,
|
|
107
|
+
self.options,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
def destroy(self, params=None):
|
|
111
|
+
self.delete(params)
|
|
112
|
+
|
|
113
|
+
def save(self):
|
|
114
|
+
if hasattr(self, "id") and self.id:
|
|
115
|
+
new_obj = self.update(self.get_attributes())
|
|
116
|
+
self.set_attributes(new_obj.get_attributes())
|
|
117
|
+
return True
|
|
118
|
+
else:
|
|
119
|
+
new_obj = create(self.get_attributes(), self.options)
|
|
120
|
+
self.set_attributes(new_obj.get_attributes())
|
|
121
|
+
return True
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# Parameters:
|
|
125
|
+
# user_id - int64 - User ID. If provided, will return group_users of this user.
|
|
126
|
+
# cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
|
|
127
|
+
# per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
|
128
|
+
# group_id - int64 - Group ID. If provided, will return group_users of this group.
|
|
129
|
+
def list(params=None, options=None):
|
|
130
|
+
if not isinstance(params, dict):
|
|
131
|
+
params = {}
|
|
132
|
+
if not isinstance(options, dict):
|
|
133
|
+
options = {}
|
|
134
|
+
if "user_id" in params and not isinstance(params["user_id"], int):
|
|
135
|
+
raise InvalidParameterError("Bad parameter: user_id must be an int")
|
|
136
|
+
if "cursor" in params and not isinstance(params["cursor"], str):
|
|
137
|
+
raise InvalidParameterError("Bad parameter: cursor must be an str")
|
|
138
|
+
if "per_page" in params and not isinstance(params["per_page"], int):
|
|
139
|
+
raise InvalidParameterError("Bad parameter: per_page must be an int")
|
|
140
|
+
if "group_id" in params and not isinstance(params["group_id"], int):
|
|
141
|
+
raise InvalidParameterError("Bad parameter: group_id must be an int")
|
|
142
|
+
return ListObj(GroupUser, "GET", "/group_users", params, options)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def all(params=None, options=None):
|
|
146
|
+
list(params, options)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
# Parameters:
|
|
150
|
+
# group_id (required) - int64 - Group ID to add user to.
|
|
151
|
+
# user_id (required) - int64 - User ID to add to group.
|
|
152
|
+
# admin - boolean - Is the user a group administrator?
|
|
153
|
+
def create(params=None, options=None):
|
|
154
|
+
if not isinstance(params, dict):
|
|
155
|
+
params = {}
|
|
156
|
+
if not isinstance(options, dict):
|
|
157
|
+
options = {}
|
|
158
|
+
if "group_id" in params and not isinstance(params["group_id"], int):
|
|
159
|
+
raise InvalidParameterError("Bad parameter: group_id must be an int")
|
|
160
|
+
if "user_id" in params and not isinstance(params["user_id"], int):
|
|
161
|
+
raise InvalidParameterError("Bad parameter: user_id must be an int")
|
|
162
|
+
if "group_id" not in params:
|
|
163
|
+
raise MissingParameterError("Parameter missing: group_id")
|
|
164
|
+
if "user_id" not in params:
|
|
165
|
+
raise MissingParameterError("Parameter missing: user_id")
|
|
166
|
+
response, options = Api.send_request(
|
|
167
|
+
"POST", "/group_users", params, options
|
|
168
|
+
)
|
|
169
|
+
return GroupUser(response.data, options)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
# Parameters:
|
|
173
|
+
# group_id (required) - int64 - Group ID to add user to.
|
|
174
|
+
# user_id (required) - int64 - User ID to add to group.
|
|
175
|
+
# admin - boolean - Is the user a group administrator?
|
|
176
|
+
def update(id, params=None, options=None):
|
|
177
|
+
if not isinstance(params, dict):
|
|
178
|
+
params = {}
|
|
179
|
+
if not isinstance(options, dict):
|
|
180
|
+
options = {}
|
|
181
|
+
params["id"] = id
|
|
182
|
+
if "id" in params and not isinstance(params["id"], int):
|
|
183
|
+
raise InvalidParameterError("Bad parameter: id must be an int")
|
|
184
|
+
if "group_id" in params and not isinstance(params["group_id"], int):
|
|
185
|
+
raise InvalidParameterError("Bad parameter: group_id must be an int")
|
|
186
|
+
if "user_id" in params and not isinstance(params["user_id"], int):
|
|
187
|
+
raise InvalidParameterError("Bad parameter: user_id must be an int")
|
|
188
|
+
if "id" not in params:
|
|
189
|
+
raise MissingParameterError("Parameter missing: id")
|
|
190
|
+
if "group_id" not in params:
|
|
191
|
+
raise MissingParameterError("Parameter missing: group_id")
|
|
192
|
+
if "user_id" not in params:
|
|
193
|
+
raise MissingParameterError("Parameter missing: user_id")
|
|
194
|
+
response, options = Api.send_request(
|
|
195
|
+
"PATCH", "/group_users/{id}".format(id=params["id"]), params, options
|
|
196
|
+
)
|
|
197
|
+
return GroupUser(response.data, options)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
# Parameters:
|
|
201
|
+
# group_id (required) - int64 - Group ID from which to remove user.
|
|
202
|
+
# user_id (required) - int64 - User ID to remove from group.
|
|
203
|
+
def delete(id, params=None, options=None):
|
|
204
|
+
if not isinstance(params, dict):
|
|
205
|
+
params = {}
|
|
206
|
+
if not isinstance(options, dict):
|
|
207
|
+
options = {}
|
|
208
|
+
params["id"] = id
|
|
209
|
+
if "id" in params and not isinstance(params["id"], int):
|
|
210
|
+
raise InvalidParameterError("Bad parameter: id must be an int")
|
|
211
|
+
if "group_id" in params and not isinstance(params["group_id"], int):
|
|
212
|
+
raise InvalidParameterError("Bad parameter: group_id must be an int")
|
|
213
|
+
if "user_id" in params and not isinstance(params["user_id"], int):
|
|
214
|
+
raise InvalidParameterError("Bad parameter: user_id must be an int")
|
|
215
|
+
if "id" not in params:
|
|
216
|
+
raise MissingParameterError("Parameter missing: id")
|
|
217
|
+
if "group_id" not in params:
|
|
218
|
+
raise MissingParameterError("Parameter missing: group_id")
|
|
219
|
+
if "user_id" not in params:
|
|
220
|
+
raise MissingParameterError("Parameter missing: user_id")
|
|
221
|
+
Api.send_request(
|
|
222
|
+
"DELETE", "/group_users/{id}".format(id=params["id"]), params, options
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def destroy(id, params=None, options=None):
|
|
227
|
+
delete(id, params, options)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def new(*args, **kwargs):
|
|
231
|
+
return GroupUser(*args, **kwargs)
|