|
9 | 9 |
|
10 | 10 |
|
11 | 11 | class Files: |
12 | | - """ Interface for PythonAnywhere files API. |
13 | | -
|
14 | | - Uses `pythonanywhere_core.base` :method: `get_api_endpoint` to |
15 | | - create url, which is stored in a class variable `Files.base_url`, |
16 | | - then calls `call_api` with appropriate arguments to execute files |
17 | | - action. |
18 | | -
|
19 | | - Covers: |
20 | | - - GET, POST and DELETE for files path endpoint |
21 | | - - POST, GET and DELETE for files sharing endpoint |
22 | | - - GET for tree endpoint |
23 | | -
|
24 | | - "path" methods: |
25 | | - - use :method: `Files.path_get` to get contents of file or |
26 | | - directory from `path` |
27 | | - - use :method: `Files.path_post` to upload or update file at given |
28 | | - `dest_path` using contents from `source` |
29 | | - - use :method: `Files.path_delete` to delete file/directory on on |
30 | | - given `path` |
31 | | -
|
32 | | - "sharing" methods: |
33 | | - - use :method: `Files.sharing_post` to enable sharing a file from |
34 | | - `path` (if not shared before) and get a link to it |
35 | | - - use :method: `Files.sharing_get` to get sharing url for `path` |
36 | | - - use :method: `Files.sharing_delete` to disable sharing for |
37 | | - `path` |
38 | | -
|
39 | | - "tree" method: |
40 | | - - use :method: `Files.tree_get` to get list of regular files and |
41 | | - subdirectories of a directory at `path` (limited to 1000 results) |
42 | 12 | """ |
| 13 | + Interface for the PythonAnywhere Files API. |
| 14 | +
|
| 15 | + This class uses the `get_api_endpoint` function from ``pythonanywhere_core.base`` |
| 16 | + to construct the API URL, which is stored in the class variable ``base_url``. |
| 17 | + It then calls the ``call_api`` method with the appropriate arguments to |
| 18 | + perform file-related actions. |
| 19 | +
|
| 20 | + Supported Endpoints: |
| 21 | + - `GET`, `POST`, and `DELETE` for the files path endpoint. |
| 22 | + - `POST`, `GET`, and `DELETE` for the file sharing endpoint. |
| 23 | + - `GET` for the tree endpoint. |
| 24 | +
|
| 25 | + Path Methods: |
| 26 | + - :meth:`Files.path_get`: Retrieve the contents of a file or directory from a specified `path`. |
| 27 | + - :meth:`Files.path_post`: Upload or update a file at the given `dest_path` using contents from `source`. |
| 28 | + - :meth:`Files.path_delete`: Delete a file or directory at the specified `path`. |
| 29 | +
|
| 30 | + Sharing Methods: |
| 31 | + - :meth:`Files.sharing_post`: Enable sharing of a file from the given `path` (if not already shared) and get a link to it. |
| 32 | + - :meth:`Files.sharing_get`: Retrieve the sharing URL for a specified `path`. |
| 33 | + - :meth:`Files.sharing_delete`: Disable sharing for a specified `path`. |
| 34 | +
|
| 35 | + Tree Method: |
| 36 | + - :meth:`Files.tree_get`: Retrieve a list of regular files and subdirectories of a directory at the specified `path` |
| 37 | + (limited to 1000 results). |
| 38 | + """ |
| 39 | + |
43 | 40 |
|
44 | 41 | base_url = get_api_endpoint(username=getpass.getuser(), flavor="files") |
45 | 42 | path_endpoint = urljoin(base_url, "path") |
|
0 commit comments