https://github.com/ramnes/sftpgo-client
Python client (sync + async) for the SFTPGo API
https://github.com/ramnes/sftpgo-client
async ftp python python-client sftp sftpgo
Last synced: 9 months ago
JSON representation
Python client (sync + async) for the SFTPGo API
- Host: GitHub
- URL: https://github.com/ramnes/sftpgo-client
- Owner: ramnes
- License: mit
- Created: 2021-03-22T18:33:45.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-18T14:39:31.000Z (about 3 years ago)
- Last Synced: 2025-03-15T15:38:00.420Z (9 months ago)
- Topics: async, ftp, python, python-client, sftp, sftpgo
- Language: Python
- Homepage:
- Size: 337 KB
- Stars: 15
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[SFTPGo]: https://github.com/drakkan/sftpgo
sftpgo-client
=============
[](https://pypi.org/project/sftpgo-client)
[](LICENSE)
[](https://github.com/ambv/black)
Python client for the [SFTPGo][] API
The `sftpgo_client.base` package is automatically generated from the [OpenAPI
specification](generator/openapi.yaml) provided by [SFTPGo][] using
[openapi-python-client](https://github.com/triaxtec/openapi-python-client).
Installation
------------
```
pip install sftpgo-client
```
Examples
--------
* Creating a client:
```python
from sftpgo_client import Client
client = Client(
base_url="http://localhost:8080/api/v2", user="admin", password="password"
)
```
In an asyncio environment, use the asynchronous client instead:
```python
from sftpgo_client import AsyncClient
client = AsyncClient(
base_url="http://localhost:8080/api/v2", user="admin", password="password"
)
```
* Listing users:
```python
users = client.get_users()
for user in users:
print(user.username)
```
or with the asynchronous client:
```python
users = await client.get_users()
for user in users:
print(user.username)
```
All API endpoints are available in both the synchronous and asynchronous clients.
* Adding a new user:
```python
from sftpgo_client import User
user = User.from_dict(
{
"username": "user",
"password": "password",
"permissions": {"/": ["*"]},
}
)
client.add_user(json_body=user)
```
Development
-----------
You can fetch the latest version of the [SFTPGo][] OpenAPI specification and
update `sftpgo_client.base` with:
```
./generator/run.sh
```
You can run the tests with:
```
pip install -r requirements.txt
docker-compose up -d
pytest
```