https://github.com/dovecot/doveadm-http-cli
Python CLI client for Dovecot doveadm HTTP api
https://github.com/dovecot/doveadm-http-cli
Last synced: 6 months ago
JSON representation
Python CLI client for Dovecot doveadm HTTP api
- Host: GitHub
- URL: https://github.com/dovecot/doveadm-http-cli
- Owner: dovecot
- Created: 2021-02-16T12:14:06.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-01-24T18:26:19.000Z (over 1 year ago)
- Last Synced: 2025-01-24T19:27:57.803Z (over 1 year ago)
- Language: Python
- Size: 13.7 KB
- Stars: 5
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python CLI client for Doveadm HTTP API
doveadm-http-cli is a PoC client for Dovecot doveadm HTTP API written in
python.
On startup it will connect to the API and fetch all available commands and
their accepted parameters.
Tab completion is available.
## Usage
First enable
[Doveadm HTTP API](https://doc.dovecot.org/main/core/admin/doveadm.html#http-api).
Next, install the necessary Python requirements (`requirements.txt`). It is
recommended to use [venv](https://docs.python.org/3/library/venv.html) for this
purpose.
```
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
```
Then run the client:
```
./doveadm_cli.py --apikey doveadm_apikey --apiurl http://host:port/doveadm/v1
```
or
```
./doveadm_cli.py --password doveadm_password --apiurl http://host:port/doveadm/v1
```
Use \ to expand commands/parameters.
### Advanced
Use command `debug` to enable printing curl commands for API calls.
### Example
```
$ ./doveadm_cli.py --apikey someapikey --apiurl http://127.0.0.1:8080/doveadm/v1
=== Doveadm HTTP CLI ===
- Array type parameters should be comma separated
- EOF can be specified as a special value for multiline input.
- Command 'debug' can be used to enable debug printing curl command for each command.
- 'commands' can be used to display all available commands.
- Use tab to complete commands/parameters.
(doveadm) debug
Debug set to True
(doveadm) mailboxStatus user=testuser1 mailboxMask=INBOX field=messages
curl -H "Authorization: X-Dovecot-API anV1c3RvNjY2" -H "Content-Type: application/json" -d '[["mailboxStatus", {"field": ["messages"], "mailboxMask": ["INBOX"], "user": "testuser1"}, "c01"]]' http://10.211.55.7:8080/doveadm/v1
[
{
"mailbox": "INBOX",
"messages": "35"
}
]
Results: 1
```