Skip to content

ramnes/sftpgo-client

Repository files navigation

sftpgo-client

PyPI License Code style

Python client for the SFTPGo API

The sftpgo_client.base package is automatically generated from the OpenAPI specification provided by SFTPGo using openapi-python-client.

Installation

pip install sftpgo-client

Examples

  • Creating a client:
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:

from sftpgo_client import AsyncClient

client = AsyncClient(
    base_url="http://localhost:8080/api/v2", user="admin", password="password"
)
  • Listing users:
users = client.get_users()
for user in users:
    print(user.username)

or with the asynchronous client:

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:
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

About

Python client (sync + async) for the SFTPGo API

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages