Files.com 1.4.112__tar.gz → 1.4.113__tar.gz
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.
- {Files.com-1.4.112 → Files.com-1.4.113}/Files.com.egg-info/PKG-INFO +1 -1
- {Files.com-1.4.112 → Files.com-1.4.113}/PKG-INFO +1 -1
- Files.com-1.4.113/README.md +576 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/__init__.py +1 -1
- Files.com-1.4.112/README.md +0 -228
- {Files.com-1.4.112 → Files.com-1.4.113}/Files.com.egg-info/SOURCES.txt +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/Files.com.egg-info/dependency_links.txt +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/Files.com.egg-info/requires.txt +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/Files.com.egg-info/top_level.txt +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/api.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/api_client.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/error.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/list_obj.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/__init__.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/account_line_item.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/action.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/action_notification_export.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/action_notification_export_result.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/action_webhook_failure.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/api_key.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/api_request_log.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/app.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/as2_incoming_message.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/as2_outgoing_message.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/as2_partner.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/as2_station.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/auto.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/automation.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/automation_log.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/automation_run.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/bandwidth_snapshot.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/behavior.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/bundle.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/bundle_action.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/bundle_download.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/bundle_notification.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/bundle_path.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/bundle_recipient.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/bundle_registration.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/clickwrap.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/dns_record.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/email_incoming_message.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/email_log.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/errors.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/exavault_api_request_log.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/external_event.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/file.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/file_action.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/file_comment.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/file_comment_reaction.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/file_migration.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/file_migration_log.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/file_upload_part.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/folder.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/form_field.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/form_field_set.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/ftp_action_log.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/gpg_key.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/group.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/group_user.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/history.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/history_export.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/history_export_result.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/image.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/inbox_recipient.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/inbox_registration.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/inbox_upload.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/invoice.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/invoice_line_item.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/ip_address.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/lock.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/message.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/message_comment.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/message_comment_reaction.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/message_reaction.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/notification.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/outbound_connection_log.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/payment.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/payment_line_item.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/permission.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/preview.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/priority.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/project.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/public_hosting_request_log.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/public_ip_address.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/public_key.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/remote_bandwidth_snapshot.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/remote_server.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/remote_server_configuration_file.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/request.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/session.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/settings_change.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/sftp_action_log.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/sftp_host_key.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/share_group.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/share_group_member.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/site.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/snapshot.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/sso_strategy.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/status.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/style.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/sync_log.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/usage_daily_snapshot.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/usage_snapshot.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/user.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/user_cipher_use.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/user_request.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/web_dav_action_log.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/webhook_test.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/path_util.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/util.py +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/pyproject.toml +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/setup.cfg +0 -0
- {Files.com-1.4.112 → Files.com-1.4.113}/setup.py +0 -0
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
# Files.com Python Client
|
|
2
|
+
|
|
3
|
+
The content included here should be enough to get started, but please visit our
|
|
4
|
+
[Developer Documentation Website](https://developers.files.com/python/) for the complete documentation.
|
|
5
|
+
|
|
6
|
+
## Introduction
|
|
7
|
+
|
|
8
|
+
The Files.com Python client library provides convenient access to the Files.com API from applications written in the Python language.
|
|
9
|
+
|
|
10
|
+
### Installation
|
|
11
|
+
|
|
12
|
+
To install the package:
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
pip3 install Files.com
|
|
16
|
+
````
|
|
17
|
+
|
|
18
|
+
#### Requirements
|
|
19
|
+
|
|
20
|
+
* Python 3.5+
|
|
21
|
+
* requests
|
|
22
|
+
|
|
23
|
+
### Usage
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
import files_sdk
|
|
27
|
+
````
|
|
28
|
+
|
|
29
|
+
<Note title="Repository">
|
|
30
|
+
Explore the [files-sdk-python](https://github.com/Files-com/files-sdk-python) code on GitHub.
|
|
31
|
+
</Note>
|
|
32
|
+
|
|
33
|
+
### Getting Support
|
|
34
|
+
|
|
35
|
+
The Files.com team is happy to help with any SDK Integration challenges you
|
|
36
|
+
may face.
|
|
37
|
+
|
|
38
|
+
Just email support@files.com and we'll get the process started.
|
|
39
|
+
|
|
40
|
+
## Authentication
|
|
41
|
+
|
|
42
|
+
### Authenticate with an API Key
|
|
43
|
+
|
|
44
|
+
Authenticating with an API key is the recommended authentication method for most scenarios, and is
|
|
45
|
+
the method used in the examples on this site.
|
|
46
|
+
|
|
47
|
+
To use the API or SDKs with an API Key, first generate an API key from the [web
|
|
48
|
+
interface](https://www.files.com/docs/sdk-and-apis/api-keys) or [via the API or an
|
|
49
|
+
SDK](/python/resources/developers/api-keys).
|
|
50
|
+
|
|
51
|
+
Note that when using a user-specific API key, if the user is an administrator, you will have full
|
|
52
|
+
access to the entire API. If the user is not an administrator, you will only be able to access files
|
|
53
|
+
that user can access, and no access will be granted to site administration functions in the API.
|
|
54
|
+
|
|
55
|
+
```python title="Example Request"
|
|
56
|
+
files_sdk.set_api_key("YOUR_API_KEY")
|
|
57
|
+
|
|
58
|
+
## Alternatively, you can specify the API key on a per-request basis in the final parameter to any method or initializer.
|
|
59
|
+
files_sdk.user.list(params, {"api_key": "YOUR_API_KEY"})
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
<Note>
|
|
63
|
+
Don't forget to replace the placeholder, `YOUR_API_KEY`, with your actual API key.
|
|
64
|
+
</Note>
|
|
65
|
+
|
|
66
|
+
### Authenticate with a Session
|
|
67
|
+
|
|
68
|
+
You can also authenticate to the REST API or SDKs by creating a user session using the username and
|
|
69
|
+
password of an active user. If the user is an administrator, the session will have full access to
|
|
70
|
+
the entire API. Sessions created from regular user accounts will only be able to access files that
|
|
71
|
+
user can access, and no access will be granted to site administration functions.
|
|
72
|
+
|
|
73
|
+
API sessions use the exact same session timeout settings as web interface sessions. When an API
|
|
74
|
+
session times out, simply create a new session and resume where you left off. This process is not
|
|
75
|
+
automatically handled by SDKs because we do not want to store password information in memory without
|
|
76
|
+
your explicit consent.
|
|
77
|
+
|
|
78
|
+
#### Logging in
|
|
79
|
+
|
|
80
|
+
To create a session, the `create` method is called on the `files_sdk` object with the user's username and
|
|
81
|
+
password.
|
|
82
|
+
|
|
83
|
+
This returns a session object that can be used to authenticate SDK method calls.
|
|
84
|
+
|
|
85
|
+
```python title="Example Request"
|
|
86
|
+
session = files_sdk.session.create({ "username": "motor", "password": "vroom" })
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Using a session
|
|
90
|
+
|
|
91
|
+
Once a session has been created, you can store the session globally, use the session per object, or use the session per request to authenticate SDK operations.
|
|
92
|
+
|
|
93
|
+
```python title="Example Request"
|
|
94
|
+
## You may set the returned session to be used by default for subsequent requests.
|
|
95
|
+
files_sdk.set_session(session)
|
|
96
|
+
|
|
97
|
+
## Alternatively, you can specify the session ID on a per-object basis in the second parameter to a model constructor.
|
|
98
|
+
user = files_sdk.user.User(params, {"session_id": session.id})
|
|
99
|
+
|
|
100
|
+
## You may also specify the session ID on a per-request basis in the final parameter to static methods.
|
|
101
|
+
files_sdk.user.find(id, params, {"session_id": session.id})
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Logging out
|
|
105
|
+
|
|
106
|
+
User sessions can be ended calling the `destroy` method on the `session` object.
|
|
107
|
+
|
|
108
|
+
```python title="Example Request"
|
|
109
|
+
session.destroy()
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Configuration
|
|
113
|
+
|
|
114
|
+
### Configuration options
|
|
115
|
+
|
|
116
|
+
#### Base URL
|
|
117
|
+
|
|
118
|
+
Setting the base URL for the API is required if your site is configured to disable global acceleration.
|
|
119
|
+
This can also be set to use a mock server in development or CI.
|
|
120
|
+
|
|
121
|
+
```python title="Example setting"
|
|
122
|
+
files_sdk.base_url = "https://SUBDOMAIN.files.com"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### Log level
|
|
126
|
+
|
|
127
|
+
This SDK utilizes the standard Python logging framework. It will respect the global log level
|
|
128
|
+
and you can set the module specific log level and other logging settings by getting the logger
|
|
129
|
+
object in the standard manner as shown below:
|
|
130
|
+
|
|
131
|
+
```python title="Example setting"
|
|
132
|
+
import logging
|
|
133
|
+
logging.getLogger("files_sdk")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### Console log level
|
|
137
|
+
|
|
138
|
+
Enables printing of messages to stderr in addition to normal logging.
|
|
139
|
+
|
|
140
|
+
Allowed values are:
|
|
141
|
+
|
|
142
|
+
* `None`
|
|
143
|
+
* "info"
|
|
144
|
+
* "debug"
|
|
145
|
+
|
|
146
|
+
```python title="Example setting"
|
|
147
|
+
files_sdk.console_log_level = "info"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### Open timeout
|
|
151
|
+
|
|
152
|
+
Open timeout in seconds. The default value is 30.
|
|
153
|
+
|
|
154
|
+
```python title="Example setting"
|
|
155
|
+
files_sdk.open_timeout = 60
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
#### Read timeout
|
|
159
|
+
|
|
160
|
+
Read timeout in seconds. The default value is 80.
|
|
161
|
+
|
|
162
|
+
```python title="Example setting"
|
|
163
|
+
files_sdk.read_timeout = 90
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
#### Initial network retry delay
|
|
167
|
+
|
|
168
|
+
Initial retry delay in seconds. The default value is 0.5.
|
|
169
|
+
|
|
170
|
+
```python title="Example setting"
|
|
171
|
+
files_sdk.initial_network_retry_delay = 1
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### Maximum retry delay
|
|
175
|
+
|
|
176
|
+
Maximum network retry delay in seconds. The default value is 2.
|
|
177
|
+
|
|
178
|
+
```python title="Example setting"
|
|
179
|
+
files_sdk.max_network_retry_delay = 5
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### Maximum network retries
|
|
183
|
+
|
|
184
|
+
Maximum number of retries. The default value is 3.
|
|
185
|
+
|
|
186
|
+
```python title="Example setting"
|
|
187
|
+
files_sdk.max_network_retries = 5
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
#### Source IP
|
|
191
|
+
|
|
192
|
+
Configure the local IP address from which to send requests.
|
|
193
|
+
|
|
194
|
+
```python title="Example setting"
|
|
195
|
+
files_sdk.source_ip = '10.1.2.3'
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Logging
|
|
199
|
+
|
|
200
|
+
The Files.com SDK is compatible with the standard log4j logging scheme.
|
|
201
|
+
|
|
202
|
+
Add `com.files` logger to your `Loggers` root in the `log4j2.xml` file.
|
|
203
|
+
|
|
204
|
+
```xml title="log4j2.xml"
|
|
205
|
+
<Loggers>
|
|
206
|
+
<!-- set preferred level -->
|
|
207
|
+
<Logger name="com.files" level="TRACE" />
|
|
208
|
+
<!-- to enable network request -->
|
|
209
|
+
<Logger name="okhttp3.logging.wire" level="INFO"/>
|
|
210
|
+
</Loggers>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Create a `resources/log4j2.xml` file.
|
|
214
|
+
|
|
215
|
+
```xml title="resources/log4j2.xml"
|
|
216
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
217
|
+
<Configuration>
|
|
218
|
+
<Appenders>
|
|
219
|
+
<Console name="Console" target="SYSTEM_OUT">
|
|
220
|
+
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
|
221
|
+
</Console>
|
|
222
|
+
</Appenders>
|
|
223
|
+
<Loggers>
|
|
224
|
+
<!-- set preferred level -->
|
|
225
|
+
<Logger name="com.files" level="TRACE"/>
|
|
226
|
+
<!-- to enable network request -->
|
|
227
|
+
<Logger name="okhttp3.logging.wire" level="INFO"/>
|
|
228
|
+
</Loggers>
|
|
229
|
+
</Configuration>
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
You can read more about [log4j2 configuration](https://logging.apache.org/log4j/2.x/manual/configuration.html).
|
|
233
|
+
|
|
234
|
+
## Errors
|
|
235
|
+
|
|
236
|
+
The Files.com Python SDK will return errors by raising exceptions. There are many exception classes defined in the Files SDK that correspond
|
|
237
|
+
to specific errors.
|
|
238
|
+
|
|
239
|
+
The raised exceptions come from two categories:
|
|
240
|
+
|
|
241
|
+
1. SDK Exceptions - errors that originate within the SDK
|
|
242
|
+
2. API Exceptions - errors that occur due to the response from the Files.com API. These errors are grouped into common error types.
|
|
243
|
+
|
|
244
|
+
There are several types of exceptions within each category. Exception classes indicate different types of errors and are named in a
|
|
245
|
+
fashion that describe the general premise of the originating error. More details can be found in the err object message.
|
|
246
|
+
|
|
247
|
+
Use standard Python exception handling to detect and deal with errors. It is generally recommended to handle specific errors first, then
|
|
248
|
+
handle the general `files_sdk.error.Error` exception as a catch-all.
|
|
249
|
+
|
|
250
|
+
```python title="Example Error Handling"
|
|
251
|
+
try:
|
|
252
|
+
session = files_sdk.session.create({ "username": "USERNAME", "password": "BADPASSWORD" })
|
|
253
|
+
except files_sdk.error.NotAuthenticatedError as err:
|
|
254
|
+
print(f"Authentication Error Occured ({type(err).__name__}):", err)
|
|
255
|
+
except files_sdk.error.Error as err:
|
|
256
|
+
print(f"Unknown Error Occured ({type(err).__name__}):", err)
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Error Types
|
|
260
|
+
|
|
261
|
+
#### SDK Errors
|
|
262
|
+
|
|
263
|
+
SDK errors are general errors that occure within the SDK code. Each exception class inherits from a standard `Error` base class.
|
|
264
|
+
|
|
265
|
+
```python title="Example SDK Exception Class Inheritance Structure"
|
|
266
|
+
files_sdk.error.APIConnectionError -> files_sdk.error.Error -> Exception
|
|
267
|
+
```
|
|
268
|
+
##### SDK Exception Classes
|
|
269
|
+
|
|
270
|
+
| Error Class Name| Description |
|
|
271
|
+
| --------------- | ------------ |
|
|
272
|
+
| `APIConnectionError`| The Files.com API cannot be reached |
|
|
273
|
+
| `AuthenticationError`| Not enough authentication information has been provided |
|
|
274
|
+
| `InvalidParameterError`| A passed in parameter is invalid |
|
|
275
|
+
| `MissingParameterError`| A method parameter is missing |
|
|
276
|
+
| `NotImplementedError`| The called method has not be implemented by the SDK |
|
|
277
|
+
|
|
278
|
+
#### API Errors
|
|
279
|
+
|
|
280
|
+
API errors are errors returned by the Files.com API. Each exception class inherits from an error group base class.
|
|
281
|
+
The error group base class indicates a particular type of error.
|
|
282
|
+
|
|
283
|
+
```python title="Example API Exception Class Inheritance Structure"
|
|
284
|
+
files_sdk.error.FolderAdminPermissionRequiredError -> files_sdk.error.NotAuthorizedError -> files_sdk.error.APIError -> files_sdk.error.Error -> Exception
|
|
285
|
+
```
|
|
286
|
+
##### API Exception Classes
|
|
287
|
+
|
|
288
|
+
| Error Class Name | Error Group |
|
|
289
|
+
| --------- | --------- |
|
|
290
|
+
|`AgentUpgradeRequiredError`| `BadRequestError` |
|
|
291
|
+
|`AttachmentTooLargeError`| `BadRequestError` |
|
|
292
|
+
|`CannotDownloadDirectoryError`| `BadRequestError` |
|
|
293
|
+
|`CantMoveWithMultipleLocationsError`| `BadRequestError` |
|
|
294
|
+
|`DatetimeParseError`| `BadRequestError` |
|
|
295
|
+
|`DestinationSameError`| `BadRequestError` |
|
|
296
|
+
|`FolderMustNotBeAFileError`| `BadRequestError` |
|
|
297
|
+
|`InvalidBodyError`| `BadRequestError` |
|
|
298
|
+
|`InvalidCursorError`| `BadRequestError` |
|
|
299
|
+
|`InvalidCursorTypeForSortError`| `BadRequestError` |
|
|
300
|
+
|`InvalidEtagsError`| `BadRequestError` |
|
|
301
|
+
|`InvalidFilterAliasCombinationError`| `BadRequestError` |
|
|
302
|
+
|`InvalidFilterCombinationError`| `BadRequestError` |
|
|
303
|
+
|`InvalidFilterFieldError`| `BadRequestError` |
|
|
304
|
+
|`InvalidFilterParamError`| `BadRequestError` |
|
|
305
|
+
|`InvalidFilterParamValueError`| `BadRequestError` |
|
|
306
|
+
|`InvalidInputEncodingError`| `BadRequestError` |
|
|
307
|
+
|`InvalidInterfaceError`| `BadRequestError` |
|
|
308
|
+
|`InvalidOauthProviderError`| `BadRequestError` |
|
|
309
|
+
|`InvalidPathError`| `BadRequestError` |
|
|
310
|
+
|`InvalidReturnToUrlError`| `BadRequestError` |
|
|
311
|
+
|`InvalidUploadOffsetError`| `BadRequestError` |
|
|
312
|
+
|`InvalidUploadPartGapError`| `BadRequestError` |
|
|
313
|
+
|`InvalidUploadPartSizeError`| `BadRequestError` |
|
|
314
|
+
|`MethodNotAllowedError`| `BadRequestError` |
|
|
315
|
+
|`NoValidInputParamsError`| `BadRequestError` |
|
|
316
|
+
|`PartNumberTooLargeError`| `BadRequestError` |
|
|
317
|
+
|`PathCannotHaveTrailingWhitespaceError`| `BadRequestError` |
|
|
318
|
+
|`ReauthenticationNeededFieldsError`| `BadRequestError` |
|
|
319
|
+
|`RequestParamsContainInvalidCharacterError`| `BadRequestError` |
|
|
320
|
+
|`RequestParamsInvalidError`| `BadRequestError` |
|
|
321
|
+
|`RequestParamsRequiredError`| `BadRequestError` |
|
|
322
|
+
|`SearchAllOnChildPathError`| `BadRequestError` |
|
|
323
|
+
|`UnsupportedCurrencyError`| `BadRequestError` |
|
|
324
|
+
|`UnsupportedHttpResponseFormatError`| `BadRequestError` |
|
|
325
|
+
|`UnsupportedMediaTypeError`| `BadRequestError` |
|
|
326
|
+
|`UserIdInvalidError`| `BadRequestError` |
|
|
327
|
+
|`UserIdOnUserEndpointError`| `BadRequestError` |
|
|
328
|
+
|`UserRequiredError`| `BadRequestError` |
|
|
329
|
+
|`AdditionalAuthenticationRequiredError`| `NotAuthenticatedError` |
|
|
330
|
+
|`AuthenticationRequiredError`| `NotAuthenticatedError` |
|
|
331
|
+
|`BundleRegistrationCodeFailedError`| `NotAuthenticatedError` |
|
|
332
|
+
|`FilesAgentTokenFailedError`| `NotAuthenticatedError` |
|
|
333
|
+
|`InboxRegistrationCodeFailedError`| `NotAuthenticatedError` |
|
|
334
|
+
|`InvalidCredentialsError`| `NotAuthenticatedError` |
|
|
335
|
+
|`InvalidOauthError`| `NotAuthenticatedError` |
|
|
336
|
+
|`InvalidOrExpiredCodeError`| `NotAuthenticatedError` |
|
|
337
|
+
|`InvalidSessionError`| `NotAuthenticatedError` |
|
|
338
|
+
|`InvalidUsernameOrPasswordError`| `NotAuthenticatedError` |
|
|
339
|
+
|`LockedOutError`| `NotAuthenticatedError` |
|
|
340
|
+
|`LockoutRegionMismatchError`| `NotAuthenticatedError` |
|
|
341
|
+
|`OneTimePasswordIncorrectError`| `NotAuthenticatedError` |
|
|
342
|
+
|`TwoFactorAuthenticationErrorError`| `NotAuthenticatedError` |
|
|
343
|
+
|`TwoFactorAuthenticationSetupExpiredError`| `NotAuthenticatedError` |
|
|
344
|
+
|`ApiKeyIsDisabledError`| `NotAuthorizedError` |
|
|
345
|
+
|`ApiKeyIsPathRestrictedError`| `NotAuthorizedError` |
|
|
346
|
+
|`ApiKeyOnlyForDesktopAppError`| `NotAuthorizedError` |
|
|
347
|
+
|`ApiKeyOnlyForMobileAppError`| `NotAuthorizedError` |
|
|
348
|
+
|`ApiKeyOnlyForOfficeIntegrationError`| `NotAuthorizedError` |
|
|
349
|
+
|`BillingPermissionRequiredError`| `NotAuthorizedError` |
|
|
350
|
+
|`BundleMaximumUsesReachedError`| `NotAuthorizedError` |
|
|
351
|
+
|`CannotLoginWhileUsingKeyError`| `NotAuthorizedError` |
|
|
352
|
+
|`CantActForOtherUserError`| `NotAuthorizedError` |
|
|
353
|
+
|`ContactAdminForPasswordChangeHelpError`| `NotAuthorizedError` |
|
|
354
|
+
|`FilesAgentFailedAuthorizationError`| `NotAuthorizedError` |
|
|
355
|
+
|`FolderAdminOrBillingPermissionRequiredError`| `NotAuthorizedError` |
|
|
356
|
+
|`FolderAdminPermissionRequiredError`| `NotAuthorizedError` |
|
|
357
|
+
|`FullPermissionRequiredError`| `NotAuthorizedError` |
|
|
358
|
+
|`HistoryPermissionRequiredError`| `NotAuthorizedError` |
|
|
359
|
+
|`InsufficientPermissionForParamsError`| `NotAuthorizedError` |
|
|
360
|
+
|`InsufficientPermissionForSiteError`| `NotAuthorizedError` |
|
|
361
|
+
|`MustAuthenticateWithApiKeyError`| `NotAuthorizedError` |
|
|
362
|
+
|`NeedAdminPermissionForInboxError`| `NotAuthorizedError` |
|
|
363
|
+
|`NonAdminsMustQueryByFolderOrPathError`| `NotAuthorizedError` |
|
|
364
|
+
|`NotAllowedToCreateBundleError`| `NotAuthorizedError` |
|
|
365
|
+
|`PasswordChangeNotRequiredError`| `NotAuthorizedError` |
|
|
366
|
+
|`PasswordChangeRequiredError`| `NotAuthorizedError` |
|
|
367
|
+
|`ReadOnlySessionError`| `NotAuthorizedError` |
|
|
368
|
+
|`ReadPermissionRequiredError`| `NotAuthorizedError` |
|
|
369
|
+
|`ReauthenticationFailedError`| `NotAuthorizedError` |
|
|
370
|
+
|`ReauthenticationFailedFinalError`| `NotAuthorizedError` |
|
|
371
|
+
|`ReauthenticationNeededActionError`| `NotAuthorizedError` |
|
|
372
|
+
|`RecaptchaFailedError`| `NotAuthorizedError` |
|
|
373
|
+
|`SelfManagedRequiredError`| `NotAuthorizedError` |
|
|
374
|
+
|`SiteAdminRequiredError`| `NotAuthorizedError` |
|
|
375
|
+
|`SiteFilesAreImmutableError`| `NotAuthorizedError` |
|
|
376
|
+
|`TwoFactorAuthenticationRequiredError`| `NotAuthorizedError` |
|
|
377
|
+
|`UserIdWithoutSiteAdminError`| `NotAuthorizedError` |
|
|
378
|
+
|`WriteAndBundlePermissionRequiredError`| `NotAuthorizedError` |
|
|
379
|
+
|`WritePermissionRequiredError`| `NotAuthorizedError` |
|
|
380
|
+
|`ZipDownloadIpMismatchError`| `NotAuthorizedError` |
|
|
381
|
+
|`ApiKeyNotFoundError`| `NotFoundError` |
|
|
382
|
+
|`BundlePathNotFoundError`| `NotFoundError` |
|
|
383
|
+
|`BundleRegistrationNotFoundError`| `NotFoundError` |
|
|
384
|
+
|`CodeNotFoundError`| `NotFoundError` |
|
|
385
|
+
|`FileNotFoundError`| `NotFoundError` |
|
|
386
|
+
|`FileUploadNotFoundError`| `NotFoundError` |
|
|
387
|
+
|`FolderNotFoundError`| `NotFoundError` |
|
|
388
|
+
|`GroupNotFoundError`| `NotFoundError` |
|
|
389
|
+
|`InboxNotFoundError`| `NotFoundError` |
|
|
390
|
+
|`NestedNotFoundError`| `NotFoundError` |
|
|
391
|
+
|`PlanNotFoundError`| `NotFoundError` |
|
|
392
|
+
|`SiteNotFoundError`| `NotFoundError` |
|
|
393
|
+
|`UserNotFoundError`| `NotFoundError` |
|
|
394
|
+
|`AlreadyCompletedError`| `ProcessingFailureError` |
|
|
395
|
+
|`AutomationCannotBeRunManuallyError`| `ProcessingFailureError` |
|
|
396
|
+
|`BehaviorNotAllowedOnRemoteServerError`| `ProcessingFailureError` |
|
|
397
|
+
|`BundleOnlyAllowsPreviewsError`| `ProcessingFailureError` |
|
|
398
|
+
|`BundleOperationRequiresSubfolderError`| `ProcessingFailureError` |
|
|
399
|
+
|`CouldNotCreateParentError`| `ProcessingFailureError` |
|
|
400
|
+
|`DestinationExistsError`| `ProcessingFailureError` |
|
|
401
|
+
|`DestinationFolderLimitedError`| `ProcessingFailureError` |
|
|
402
|
+
|`DestinationParentConflictError`| `ProcessingFailureError` |
|
|
403
|
+
|`DestinationParentDoesNotExistError`| `ProcessingFailureError` |
|
|
404
|
+
|`ExpiredPrivateKeyError`| `ProcessingFailureError` |
|
|
405
|
+
|`ExpiredPublicKeyError`| `ProcessingFailureError` |
|
|
406
|
+
|`ExportFailureError`| `ProcessingFailureError` |
|
|
407
|
+
|`ExportNotReadyError`| `ProcessingFailureError` |
|
|
408
|
+
|`FailedToChangePasswordError`| `ProcessingFailureError` |
|
|
409
|
+
|`FileLockedError`| `ProcessingFailureError` |
|
|
410
|
+
|`FileNotUploadedError`| `ProcessingFailureError` |
|
|
411
|
+
|`FilePendingProcessingError`| `ProcessingFailureError` |
|
|
412
|
+
|`FileProcessingErrorError`| `ProcessingFailureError` |
|
|
413
|
+
|`FileTooBigToDecryptError`| `ProcessingFailureError` |
|
|
414
|
+
|`FileTooBigToEncryptError`| `ProcessingFailureError` |
|
|
415
|
+
|`FileUploadedToWrongRegionError`| `ProcessingFailureError` |
|
|
416
|
+
|`FilenameTooLongError`| `ProcessingFailureError` |
|
|
417
|
+
|`FolderLockedError`| `ProcessingFailureError` |
|
|
418
|
+
|`FolderNotEmptyError`| `ProcessingFailureError` |
|
|
419
|
+
|`HistoryUnavailableError`| `ProcessingFailureError` |
|
|
420
|
+
|`InvalidBundleCodeError`| `ProcessingFailureError` |
|
|
421
|
+
|`InvalidFileTypeError`| `ProcessingFailureError` |
|
|
422
|
+
|`InvalidFilenameError`| `ProcessingFailureError` |
|
|
423
|
+
|`InvalidPriorityColorError`| `ProcessingFailureError` |
|
|
424
|
+
|`InvalidRangeError`| `ProcessingFailureError` |
|
|
425
|
+
|`ModelSaveErrorError`| `ProcessingFailureError` |
|
|
426
|
+
|`MultipleProcessingErrorsError`| `ProcessingFailureError` |
|
|
427
|
+
|`PathTooLongError`| `ProcessingFailureError` |
|
|
428
|
+
|`RecipientAlreadySharedError`| `ProcessingFailureError` |
|
|
429
|
+
|`RemoteServerErrorError`| `ProcessingFailureError` |
|
|
430
|
+
|`ResourceLockedError`| `ProcessingFailureError` |
|
|
431
|
+
|`SubfolderLockedError`| `ProcessingFailureError` |
|
|
432
|
+
|`TwoFactorAuthenticationCodeAlreadySentError`| `ProcessingFailureError` |
|
|
433
|
+
|`TwoFactorAuthenticationCountryBlacklistedError`| `ProcessingFailureError` |
|
|
434
|
+
|`TwoFactorAuthenticationGeneralErrorError`| `ProcessingFailureError` |
|
|
435
|
+
|`TwoFactorAuthenticationUnsubscribedRecipientError`| `ProcessingFailureError` |
|
|
436
|
+
|`UpdatesNotAllowedForRemotesError`| `ProcessingFailureError` |
|
|
437
|
+
|`DuplicateShareRecipientError`| `RateLimitedError` |
|
|
438
|
+
|`ReauthenticationRateLimitedError`| `RateLimitedError` |
|
|
439
|
+
|`TooManyConcurrentLoginsError`| `RateLimitedError` |
|
|
440
|
+
|`TooManyConcurrentRequestsError`| `RateLimitedError` |
|
|
441
|
+
|`TooManyLoginAttemptsError`| `RateLimitedError` |
|
|
442
|
+
|`TooManyRequestsError`| `RateLimitedError` |
|
|
443
|
+
|`TooManySharesError`| `RateLimitedError` |
|
|
444
|
+
|`AgentUnavailableError`| `ServiceUnavailableError` |
|
|
445
|
+
|`AutomationsUnavailableError`| `ServiceUnavailableError` |
|
|
446
|
+
|`MigrationInProgressError`| `ServiceUnavailableError` |
|
|
447
|
+
|`SiteDisabledError`| `ServiceUnavailableError` |
|
|
448
|
+
|`UploadsUnavailableError`| `ServiceUnavailableError` |
|
|
449
|
+
|`AccountAlreadyExistsError`| `SiteConfigurationError` |
|
|
450
|
+
|`AccountOverdueError`| `SiteConfigurationError` |
|
|
451
|
+
|`NoAccountForSiteError`| `SiteConfigurationError` |
|
|
452
|
+
|`SiteWasRemovedError`| `SiteConfigurationError` |
|
|
453
|
+
|`TrialExpiredError`| `SiteConfigurationError` |
|
|
454
|
+
|`TrialLockedError`| `SiteConfigurationError` |
|
|
455
|
+
|`UserRequestsEnabledRequiredError`| `SiteConfigurationError` |
|
|
456
|
+
|
|
457
|
+
## Examples
|
|
458
|
+
|
|
459
|
+
### File Operations
|
|
460
|
+
|
|
461
|
+
This SDK allows both file based transfer and data based transfer. Please see the examples below.
|
|
462
|
+
|
|
463
|
+
#### File Download
|
|
464
|
+
|
|
465
|
+
The second parameter is optional and will simply use the remote filename by default.
|
|
466
|
+
|
|
467
|
+
```python
|
|
468
|
+
files_sdk.file.download_file("/remote.txt", "local.txt")
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
#### File Upload
|
|
472
|
+
|
|
473
|
+
The second parameter is optional and will simply use the local filename by default.
|
|
474
|
+
|
|
475
|
+
```python
|
|
476
|
+
files_sdk.file.upload_file("local.txt", "/remote.txt")
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
If the parent directories do not already exist, they can be automatically created by passing
|
|
480
|
+
`mkdir_parents` in the `params`.
|
|
481
|
+
|
|
482
|
+
```python
|
|
483
|
+
files_sdk.file.upload_file("local.txt", "/uploads/remote.txt", params={"mkdir_parents": True})
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
#### List root folder
|
|
487
|
+
|
|
488
|
+
```python
|
|
489
|
+
for f in files_sdk.folder.list_for("/").auto_paging_iter():
|
|
490
|
+
print(f.type, f.path)
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
#### Writing a file example (string)
|
|
494
|
+
|
|
495
|
+
```python
|
|
496
|
+
with files_sdk.file.open("foo.txt", 'w') as f:
|
|
497
|
+
f.write("contents")
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
#### Writing a file example (binary)
|
|
501
|
+
|
|
502
|
+
```python
|
|
503
|
+
with files_sdk.file.open("foo.txt", 'wb') as f:
|
|
504
|
+
f.write(b"contents")
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
#### Reading a file example (string)
|
|
508
|
+
|
|
509
|
+
```python
|
|
510
|
+
with files_sdk.open("foo.txt", 'r') as f:
|
|
511
|
+
print(f.read())
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
#### Reading a file example (binary)
|
|
515
|
+
|
|
516
|
+
```python
|
|
517
|
+
with files_sdk.open("foo.txt", 'rb') as f:
|
|
518
|
+
print(f.read())
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
### List Responses and Cursor Paging
|
|
522
|
+
|
|
523
|
+
List responses for APIs with cursor support will return an iterable object
|
|
524
|
+
which contains a single page of records. It has a built-in `auto_paging_iter`
|
|
525
|
+
method to iterate through the pages, making the additional API calls
|
|
526
|
+
as needed.
|
|
527
|
+
|
|
528
|
+
#### Iterating with with auto_paging_iter
|
|
529
|
+
|
|
530
|
+
```python
|
|
531
|
+
list_obj = files_sdk.folder.list_for('/')
|
|
532
|
+
|
|
533
|
+
for f in list_obj.auto_paging_iter():
|
|
534
|
+
print(f.type, f.path)
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
#### Iterating manually
|
|
538
|
+
|
|
539
|
+
```python
|
|
540
|
+
list_obj = files_sdk.folder.list_for('/')
|
|
541
|
+
|
|
542
|
+
for f in list_obj:
|
|
543
|
+
print(f.type, f.path)
|
|
544
|
+
|
|
545
|
+
while list_obj.has_next_page:
|
|
546
|
+
list_obj.load_next_page()
|
|
547
|
+
for f in list_obj:
|
|
548
|
+
print(f.type, f.path)
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
### Comparing Case insensitive files and paths
|
|
552
|
+
|
|
553
|
+
For related documentation see [Case Sensitivity Documentation](https://www.files.com/docs/files-and-folders/file-system-semantics/case-sensitivity).
|
|
554
|
+
|
|
555
|
+
```python
|
|
556
|
+
if files_sdk.path_util.is_same("Fïłèńämê.Txt", "filename.txt"):
|
|
557
|
+
print("Paths are the same")
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
## Mock Server
|
|
561
|
+
|
|
562
|
+
Files.com publishes a Files.com API server, which is useful for testing your use of the Files.com
|
|
563
|
+
SDKs and other direct integrations against the Files.com API in an integration test environment.
|
|
564
|
+
|
|
565
|
+
It is a Ruby app that operates as a minimal server for the purpose of testing basic network
|
|
566
|
+
operations and JSON encoding for your SDK or API client. It does not maintain state and it does not
|
|
567
|
+
deeply inspect your submissions for correctness.
|
|
568
|
+
|
|
569
|
+
Eventually we will add more features intended for integration testing, such as the ability to
|
|
570
|
+
intentionally provoke errors.
|
|
571
|
+
|
|
572
|
+
Download the server as a Docker image via [Docker Hub](https://hub.docker.com/r/filescom/files-mock-server).
|
|
573
|
+
|
|
574
|
+
The Source Code is also available on [GitHub](https://github.com/Files-com/files-mock-server).
|
|
575
|
+
|
|
576
|
+
A README is available on the GitHub link.
|
Files.com-1.4.112/README.md
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
# Files.com Python Client
|
|
2
|
-
|
|
3
|
-
The Files.com Python client library provides convenient access to the Files.com API from applications written in the Python language.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
## Installation
|
|
7
|
-
|
|
8
|
-
To install the package:
|
|
9
|
-
|
|
10
|
-
pip3 install Files.com
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
### Requirements
|
|
14
|
-
|
|
15
|
-
* Python 3.5+
|
|
16
|
-
* requests
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## Usage
|
|
20
|
-
|
|
21
|
-
import files_sdk
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
### Authentication
|
|
25
|
-
|
|
26
|
-
There are multiple ways to authenticate to the API.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
#### Global API Key
|
|
30
|
-
|
|
31
|
-
You can set an API key globally, like this:
|
|
32
|
-
|
|
33
|
-
files_sdk.set_api_key("my-key")
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
#### Per-Request API Key
|
|
37
|
-
|
|
38
|
-
Or, you can pass an API key per-request, in the Options dictionary at the end
|
|
39
|
-
of every method. Like this:
|
|
40
|
-
|
|
41
|
-
files_sdk.group.list({}, {"api_key": "my-key"})
|
|
42
|
-
|
|
43
|
-
That key will automatically be used for any followup actions that occur
|
|
44
|
-
on models returned from the API.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
#### User Session
|
|
48
|
-
|
|
49
|
-
Or, you can open a user session by calling `files_sdk.session.create`
|
|
50
|
-
|
|
51
|
-
session = files_sdk.session.create({"username": "uname", "password": "pwd"})
|
|
52
|
-
|
|
53
|
-
Then use it as follows:
|
|
54
|
-
|
|
55
|
-
files_sdk.group.list({}, {"session": session})
|
|
56
|
-
|
|
57
|
-
Or use if for all subsequent API calls globally like this:
|
|
58
|
-
|
|
59
|
-
session = files_sdk.session.create({"username": "uname", "password": "pwd"})
|
|
60
|
-
files_sdk.set_session(session)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
### Setting Global Options
|
|
64
|
-
|
|
65
|
-
You can set the following global options directly on the `files_sdk` module:
|
|
66
|
-
|
|
67
|
-
* `files_sdk.source_ip` - the source IP from which to send requests from (local bind)
|
|
68
|
-
* `files_sdk.open_timeout` - open timeout in seconds (default: 30)
|
|
69
|
-
* `files_sdk.read_timeout` - read timeout in seconds (default: 80)
|
|
70
|
-
* `files_sdk.initial_network_retry_delay` - initial retry delay in seconds (default: 0.5)
|
|
71
|
-
* `files_sdk.max_network_retries` - max retries (default: 3)
|
|
72
|
-
* `files_sdk.max_network_retry_delay` - max retry delay in seconds (default: 2)
|
|
73
|
-
* `files_sdk.base_url` - set this to your site subdomain if your site is configured to disable global acceleration.
|
|
74
|
-
Otherwise, don't change this setting for production.
|
|
75
|
-
For dev/CI, you can point this to the mock server.
|
|
76
|
-
* `files_sdk.console_log_level` - set to `None`, `info`, or `debug`, this enables printing
|
|
77
|
-
of messages to stderr in addition to normal logging
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
#### Log Level
|
|
81
|
-
|
|
82
|
-
This SDK utilizes the standard Python logging framework. It will respect the global log level
|
|
83
|
-
and you can set the module specific log level and other logging settings by getting the logger
|
|
84
|
-
object in the standard manner as shown below:
|
|
85
|
-
|
|
86
|
-
import logging
|
|
87
|
-
|
|
88
|
-
logging.getLogger("files_sdk")
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
### Error Handling
|
|
92
|
-
|
|
93
|
-
Unexpected errors when attempting to connect to the API inherit from the base level `Error` class. They all contain a `__str__()`
|
|
94
|
-
implementation to describe what went wrong.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
#### Unable to connect to the API
|
|
98
|
-
|
|
99
|
-
```python
|
|
100
|
-
try:
|
|
101
|
-
for f in files_sdk.folder.list_for("/").auto_paging_iter():
|
|
102
|
-
print(f.type, f.path)
|
|
103
|
-
except files_sdk.error.APIConnectionError as e:
|
|
104
|
-
print("Unable to list root folder: " + str(e))
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Errors from the API inherit from `ApiError`. They all contain more properties to describe the error such as `code`, `headers`, etc.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
#### Path does not exist
|
|
111
|
-
|
|
112
|
-
```python
|
|
113
|
-
try:
|
|
114
|
-
for f in files_sdk.folder.list_for("/missing").auto_paging_iter():
|
|
115
|
-
print(f.type, f.path)
|
|
116
|
-
except files_sdk.error.FolderNotFoundError as e:
|
|
117
|
-
print(f"Unable to list folder: {e.code}")
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
### File Operations
|
|
122
|
-
|
|
123
|
-
This SDK allows both file based transfer and data based transfer. Please see the examples below.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
#### File Download
|
|
127
|
-
|
|
128
|
-
The second parameter is optional and will simply use the remote filename by default.
|
|
129
|
-
|
|
130
|
-
files_sdk.file.download_file("/remote.txt", "local.txt")
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
#### File Upload
|
|
134
|
-
|
|
135
|
-
The second parameter is optional and will simply use the local filename by default.
|
|
136
|
-
|
|
137
|
-
files_sdk.file.upload_file("local.txt", "/remote.txt")
|
|
138
|
-
|
|
139
|
-
If the parent directories do not already exist, they can be automatically created by passing
|
|
140
|
-
`mkdir_parents` in the `params`.
|
|
141
|
-
|
|
142
|
-
files_sdk.file.upload_file("local.txt", "/uploads/remote.txt", params={"mkdir_parents": True})
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
#### List root folder
|
|
146
|
-
|
|
147
|
-
for f in files_sdk.folder.list_for("/").auto_paging_iter():
|
|
148
|
-
print(f.type, f.path)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
#### Writing a file example (string)
|
|
152
|
-
|
|
153
|
-
with files_sdk.file.open("foo.txt", 'w') as f:
|
|
154
|
-
f.write("contents")
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
#### Writing a file example (binary)
|
|
158
|
-
|
|
159
|
-
with files_sdk.file.open("foo.txt", 'wb') as f:
|
|
160
|
-
f.write(b"contents")
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
#### Reading a file example (string)
|
|
164
|
-
|
|
165
|
-
with files_sdk.open("foo.txt", 'r') as f:
|
|
166
|
-
print(f.read())
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
#### Reading a file example (binary)
|
|
170
|
-
|
|
171
|
-
with files_sdk.open("foo.txt", 'rb') as f:
|
|
172
|
-
print(f.read())
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
### List Responses and Cursor Paging
|
|
176
|
-
|
|
177
|
-
List responses for APIs with cursor support will return an iterable object
|
|
178
|
-
which contains a single page of records. It has a built-in `auto_paging_iter`
|
|
179
|
-
method to iterate through the pages, making the additional API calls
|
|
180
|
-
as needed.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
#### Iterating with with auto_paging_iter
|
|
184
|
-
|
|
185
|
-
list_obj = files_sdk.folder.list_for('/')
|
|
186
|
-
|
|
187
|
-
for f in list_obj.auto_paging_iter():
|
|
188
|
-
print(f.type, f.path)
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
#### Iterating manually
|
|
192
|
-
|
|
193
|
-
list_obj = files_sdk.folder.list_for('/')
|
|
194
|
-
|
|
195
|
-
for f in list_obj:
|
|
196
|
-
print(f.type, f.path)
|
|
197
|
-
|
|
198
|
-
while list_obj.has_next_page:
|
|
199
|
-
list_obj.load_next_page()
|
|
200
|
-
for f in list_obj:
|
|
201
|
-
print(f.type, f.path)
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
### Comparing Case insensitive files and paths
|
|
205
|
-
|
|
206
|
-
For related documentation see [Case Sensitivity Documentation](https://www.files.com/docs/files-and-folders/file-system-semantics/case-sensitivity).
|
|
207
|
-
|
|
208
|
-
if files_sdk.path_util.is_same("Fïłèńämê.Txt", "filename.txt"):
|
|
209
|
-
print("Paths are the same")
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
### Additional Object Documentation
|
|
213
|
-
|
|
214
|
-
Additional docs are available at https://developers.files.com/ and also
|
|
215
|
-
in the `docs/` subdirectory of this directory.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
### Pydoc Generated Documentation coming in the future
|
|
219
|
-
|
|
220
|
-
We hope to add Pydoc documentation to a future release.
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
## Getting Support
|
|
224
|
-
|
|
225
|
-
The Files.com team is happy to help with any SDK Integration challenges you
|
|
226
|
-
may face.
|
|
227
|
-
|
|
228
|
-
Just email support@files.com and we'll get the process started.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/action_notification_export_result.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{Files.com-1.4.112 → Files.com-1.4.113}/files_sdk/models/remote_server_configuration_file.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|