A Python CLI interface for the Postmark DMARC monitoring API
Project description
py-postdmarc
A Python interface for the Postmark DMARC monitoring API.
Table of Contents
Example
set POSTMARK_API_KEY="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
postdmarc get_record
postdmarc export_all_reports --from_date 2020-01-01 --to_date 2020-01-08 --filepath reports.json
Installation
pip install py-postdmarc
Clone
Clone this repo to your local machine using https://github.com/scuriosity/py-postdmarc
, then install locally with pip:
git clone https://github.com/scuriosity/py-postdmarc
pip install .
Features
Implements the 10 API methods provided by the API Documentation:
- Create a record
- Get a record
- Update a record
- Get DNS snippet
- Verify DNS
- Delete a record
- List DMARC reports
- Get a specific DMARC report by ID
- Recover API token
- Rotate API token
As well as
- Export all forensic reports within a given timeframe to a JSON file.
Usage
API Key
For most commands, your Postmark API key is required. The py-postdmarc package can load your API key either from the POSTMARK_API_KEY
environment variable or the file PM_API.key
in the package root. The API key should be a hexadecimal string like this:
aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
py-postdmarc/
+-- postdmarc/
| +-- __init__.py
| +-- pdm_exceptions.py
| â””-- postdmarc.py
|
+-- tests/
| +-- __init__.py
| +-- test_meta.py
| â””-- test_postdmarc.py
|
+-- license.txt
+-- PM_API.key
+-- readme.md
+-- requirements.txt
+-- setup.py
If the key isn't set in one of these two locations, an APIKeyMissingError will be raised.
Syntax
Create a record
postdmarc create_record --email EMAIL@domain.com --domain domain.com
Get a record
postdmarc get_record
Update a record
postdmarc update_record --email EMAIL@domeng.com
Get DNS snippet
postdmarc get_dns_snippet
Verify DNS
postdmarc verify_dns
Delete a record
postdmarc delete_record
List DMARC reports
postdmarc list_reports --from_date 01-01-2020 --to_date 01-02-2020
Optional flags for "after", "before" and "reverse" are provided.
Get a specific DMARC report by ID
postdmarc get_report --id 1234567
postdmarc get_report --id 1234567 --fmt xml
Recover API token
postdmarc recover_token --owner domain.com
Rotate API token
postdmarc rotate_token
Export all forensic reports
postdmarc export_all_reports --from_date 2020-01-01 --to_date 2020-01-08 --filepath reports.json
Contributing
Issues and pull requests are welcome. Create a new pull request using https://github.com/scuriosity/py-postdmarc/compare
License
- MIT license
- Copyright 2020 © Scuriosity.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file py-postdmarc-0.0.2.tar.gz
.
File metadata
- Download URL: py-postdmarc-0.0.2.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200325 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96471e18ff34dfec7f429ab7b440fa3abb21193219241c7ebac3c9125a9a3923 |
|
MD5 | 8e93142c2ca622df3e0673d039b185c7 |
|
BLAKE2b-256 | 7b0377418820aff119e381a6a676c4f1a899728f736ec7de4be0942f8258eb40 |