From 39c03a15d54220c40100449bb4377e880568fba1 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Sun, 30 Apr 2023 09:34:22 -0700 Subject: [PATCH] doc update --- docs/parsers/certbot.md | 161 ++++++++++++++++++++++++++++++++++++++++ jc/parsers/certbot.py | 5 ++ man/jc.1 | 2 +- 3 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 docs/parsers/certbot.md diff --git a/docs/parsers/certbot.md b/docs/parsers/certbot.md new file mode 100644 index 00000000..9bfff3b6 --- /dev/null +++ b/docs/parsers/certbot.md @@ -0,0 +1,161 @@ +[Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.certbot + +jc - JSON Convert `certbot` command output parser + +Supports the following `certbot` commands: + +- `certbot show_account` +- `certbot certificates` + +Verbose options are not supported. + +Usage (cli): + + $ certbot show_account | jc --certbot + $ certbot certificates | jc --certbot + +or + + $ jc certbot show_account + $ jc certbot certificates + +Usage (module): + + import jc + result = jc.parse('certbot', certbot_command_output) + +Schema: + + { + "certificates": [ + { + "name": string, + "serial_number": string, + "key_type": string, + "domains": [ + string + ], + "expiration_date": string, + "expiration_date_epoch": integer, + "expiration_date_epoch_utc": integer, + "expiration_date_iso": string, + "validity": string, + "certificate_path": string, + "private_key_path": string + } + ], + "account": { + "server": string, + "url": string, + "email": string + } + } + +Examples: + + $ certbot certificates | jc --certbot -p + { + "certificates": [ + { + "name": "example.com", + "serial_number": "3f7axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "key_type": "RSA", + "domains": [ + "example.com", + "www.example.com" + ], + "expiration_date": "2023-05-11 01:33:10+00:00", + "validity": "63 days", + "certificate_path": "/etc/letsencrypt/live/example.com/chain.pem", + "private_key_path": "/etc/letsencrypt/live/example.com/priv.pem", + "expiration_date_epoch": 1683793990, + "expiration_date_epoch_utc": 1683768790, + "expiration_date_iso": "2023-05-11T01:33:10+00:00" + }, + { + "name": "example.org", + "serial_number": "3bcyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy", + "key_type": "RSA", + "domains": [ + "example.org", + "www.example.org" + ], + "expiration_date": "2023-06-12 01:35:30+00:00", + "validity": "63 days", + "certificate_path": "/etc/letsencrypt/live/example.org/chain.pem", + "private_key_path": "/etc/letsencrypt/live/example.org/key.pem", + "expiration_date_epoch": 1686558930, + "expiration_date_epoch_utc": 1686533730, + "expiration_date_iso": "2023-06-12T01:35:30+00:00" + } + ] + } + + $ certbot certificates | jc --certbot -p -r + { + "certificates": [ + { + "name": "example.com", + "serial_number": "3f7axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "key_type": "RSA", + "domains": [ + "example.com", + "www.example.com" + ], + "expiration_date": "2023-05-11 01:33:10+00:00", + "validity": "63 days", + "certificate_path": "/etc/letsencrypt/live/example.com/chain.pem", + "private_key_path": "/etc/letsencrypt/live/example.com/priv.pem" + }, + { + "name": "example.org", + "serial_number": "3bcyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy", + "key_type": "RSA", + "domains": [ + "example.org", + "www.example.org" + ], + "expiration_date": "2023-06-12 01:35:30+00:00", + "validity": "63 days", + "certificate_path": "/etc/letsencrypt/live/example.org/chain.pem", + "private_key_path": "/etc/letsencrypt/live/example.org/key.pem" + } + ] + } + + $ certbot show_account | jc --certbot -p + { + "account": { + "server": "https://acme-staging-v02.api.letsencrypt.org/directory", + "url": "https://acme-staging-v02.api.letsencrypt.org/acme/acct/123", + "email": "some@example.com" + } + } + + + +### parse + +```python +def parse(data: str, raw: bool = False, quiet: bool = False) -> JSONDictType +``` + +Main text parsing function + +Parameters: + + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True + +Returns: + + Dictionary. Raw or processed structured data. + +### Parser Information +Compatibility: linux, darwin, cygwin, win32, aix, freebsd + +Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/jc/parsers/certbot.py b/jc/parsers/certbot.py index 5c1ee405..d05bd43e 100644 --- a/jc/parsers/certbot.py +++ b/jc/parsers/certbot.py @@ -1,5 +1,10 @@ """jc - JSON Convert `certbot` command output parser +Supports the following `certbot` commands: + +- `certbot show_account` +- `certbot certificates` + Verbose options are not supported. Usage (cli): diff --git a/man/jc.1 b/man/jc.1 index 932dea13..548e52d2 100644 --- a/man/jc.1 +++ b/man/jc.1 @@ -1,4 +1,4 @@ -.TH jc 1 2023-04-29 1.23.2 "JSON Convert" +.TH jc 1 2023-04-30 1.23.2 "JSON Convert" .SH NAME \fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types, and strings