Skip to content

Commit 0b21c4e

Browse files
committed
docs: add DynamoDB CLI, API, GUI, and man command documentation
- README.md: add zday dynamo CLI reference (7 commands + env vars + workflow) - README.md: add zday man CLI reference - README.md: add DynamoDB API endpoints table (9 endpoints + curl examples) - README.md: add DynamoDB GUI features section (backend switch, template import) - README.md: update AWS section with concrete DynamoDB details - zebra_day_ui_guide.md: add DynamoDB backend controls + template import sections - programatic_guide.md: add DynamoDB backend usage examples - AWS_DYNAMO_CONFIG_PLAN.md: update status from DRAFT to IMPLEMENTED
1 parent 7ac0834 commit 0b21c4e

File tree

4 files changed

+199
-3
lines changed

4 files changed

+199
-3
lines changed

AWS_DYNAMO_CONFIG_PLAN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AWS DynamoDB Shared Configuration Plan
22

3-
> **Status**: DRAFTpending approval before implementation
3+
> **Status**: IMPLEMENTEDall 5 phases complete, merged to main (PRs #24#29, #31, #32)
44
> **Author**: Forge
55
> **Date**: 2026-02-06
66
> **Scope**: `zebra_day` — shared printer config + ZPL templates via DynamoDB, with S3 backups

README.md

Lines changed: 121 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,76 @@ zday env reset # Show command to reset (deactivate + reactiv
167167
# Cognito authentication (requires pip install -e ".[auth]")
168168
zday cognito status # Show auth configuration
169169
zday cognito info # Setup instructions
170+
171+
# DynamoDB shared configuration (opt-in)
172+
zday dynamo init # Create DynamoDB table + S3 bucket
173+
zday dynamo status # Show table/bucket status
174+
zday dynamo bootstrap # Push local config & templates to DynamoDB
175+
zday dynamo export # Pull DynamoDB config & templates to local files
176+
zday dynamo backup # Trigger immediate S3 backup snapshot
177+
zday dynamo restore # Restore DynamoDB from S3 backup
178+
zday dynamo destroy # Delete DynamoDB table (preserves S3 backups)
179+
180+
# Interactive documentation browser
181+
zday man # Interactive topic menu
182+
zday man quickstart # View specific topic
183+
zday man --list # List all topics
184+
zday man --search "dynamo" # Search docs for a term
185+
```
186+
187+
#### DynamoDB CLI Reference (`zday dynamo`)
188+
189+
Opt-in shared configuration via AWS DynamoDB with S3 backup snapshots. Local-file mode remains the default.
190+
191+
| Command | Description | Key Options |
192+
|---------|-------------|-------------|
193+
| `zday dynamo init` | Create DynamoDB table and S3 bucket | `--table-name`, `--region`, `--s3-bucket`, `--profile`, `--cost-center`, `--project`, `--skip-checks` |
194+
| `zday dynamo status` | Show table and S3 backup status | `--json`, `--create-s3-if-missing` |
195+
| `zday dynamo bootstrap` | Push local config + templates to DynamoDB | `--config-file`, `--templates-dir`, `--include-package/--no-include-package`, `--create-s3-if-missing` |
196+
| `zday dynamo export` | Pull DynamoDB config + templates to local files | `--output-dir`, `--format json|yaml` |
197+
| `zday dynamo backup` | Trigger immediate S3 backup snapshot | `--create-s3-if-missing` |
198+
| `zday dynamo restore` | Restore DynamoDB from an S3 backup | `--s3-key`, `--list`, `--yes` |
199+
| `zday dynamo destroy` | Delete DynamoDB table (preserves S3) | `--yes` (required safety gate) |
200+
201+
##### DynamoDB Environment Variables
202+
203+
| Variable | Description | Default |
204+
|----------|-------------|---------|
205+
| `ZEBRA_DAY_CONFIG_BACKEND` | Set to `dynamodb` to enable DynamoDB mode | `local` |
206+
| `ZEBRA_DAY_DYNAMO_TABLE` | DynamoDB table name | `zebra-day-config` |
207+
| `ZEBRA_DAY_DYNAMO_REGION` | AWS region | `us-west-2` |
208+
| `ZEBRA_DAY_S3_BACKUP_BUCKET` | S3 bucket for config backups | _(none — prompted interactively)_ |
209+
| `ZEBRA_DAY_S3_BACKUP_PREFIX` | S3 key prefix | `zebra-day/` |
210+
| `AWS_PROFILE` | AWS profile name (must **not** be `default`) | _(none)_ |
211+
212+
##### Quick DynamoDB Workflow
213+
214+
```bash
215+
# 1. Create table + bucket
216+
export AWS_PROFILE=my-profile
217+
zday dynamo init --region us-west-2 --s3-bucket zebra-day-cfg-us-west-2
218+
219+
# 2. Push local config & templates
220+
zday dynamo bootstrap --create-s3-if-missing
221+
222+
# 3. Confirm status
223+
zday dynamo status
224+
225+
# 4. Switch a running GUI to DynamoDB (session-only, via web UI Config page)
226+
# or set env vars and restart:
227+
export ZEBRA_DAY_CONFIG_BACKEND=dynamodb
228+
zday gui restart
229+
```
230+
231+
#### Documentation Browser (`zday man`)
232+
233+
Browse built-in documentation topics from the terminal using Rich-rendered Markdown.
234+
235+
```bash
236+
zday man # Interactive topic picker
237+
zday man quickstart # Jump to a topic by slug
238+
zday man --list # List all topics with descriptions
239+
zday man --search "template" # Full-text search across all docs
170240
```
171241

172242
#### Migration from 0.5.x
@@ -411,8 +481,11 @@ Use `zday info` to see the exact paths on your system.
411481

412482

413483
## Hardware Config
414-
### AWS Headsup
415-
- New functionality, best engaged for now via the GUI, allows for a shared dynamodb config resource so multiple clients can query it and share the same config across varios points of code execution.
484+
### AWS DynamoDB Shared Config (opt-in)
485+
- Multiple clients can share a single DynamoDB table as the config backend (printer fleet + ZPL templates).
486+
- Enable via `ZEBRA_DAY_CONFIG_BACKEND=dynamodb` env var or the GUI's Switch Backend form.
487+
- Every DynamoDB write triggers an automatic S3 backup snapshot (JSON).
488+
- See `zday dynamo --help` and the [DynamoDB Plan](AWS_DYNAMO_CONFIG_PLAN.md) for details.
416489
417490
### Quick
418491
* Connect all zebra printers to the same network as the machine you'll be running `zebra_day` is connected to. Load labels, power on printers , confirm status lights are green, etc.
@@ -694,6 +767,52 @@ http://YOUR.HOST.IP.ADDR:8118/_print_label?lab=default&printer=192.168.1.7&label
694767
695768
### [Web UI Guide](zebra_day/docs/zebra_day_ui_guide.md)
696769
770+
### DynamoDB GUI Features (v2.2.0+)
771+
772+
The **Config** page includes controls for the DynamoDB shared backend:
773+
774+
- **Backend Status Card** — shows current backend type (`local` or `dynamodb`), table name, region, S3 bucket, AWS profile
775+
- **Switch Backend Form** — swap between `local` and `dynamodb` backends for the running session (does not persist to env vars)
776+
- Auto-detects existing DynamoDB tables in the selected region
777+
- Auto-suggests S3 bucket name based on region
778+
- Validates AWS profile (rejects `default`)
779+
- "Create Bucket" button if the target S3 bucket doesn't exist
780+
- **Refresh Config** — reload config from the active backend
781+
782+
The **Templates** page includes:
783+
784+
- **Import to DynamoDB** — when a DynamoDB backend is active, local templates (user + package) appear with checkboxes for selective import into DynamoDB
785+
786+
### DynamoDB API Endpoints
787+
788+
All prefixed with `/api/v1/`. Available when the web server is running.
789+
790+
| Method | Endpoint | Description |
791+
|--------|----------|-------------|
792+
| `GET` | `/config/backend-status` | Current backend type and AWS details |
793+
| `POST` | `/config/refresh` | Reload config from active backend |
794+
| `GET` | `/config/detect-tables` | List DynamoDB tables in a region (`?region=&profile=`) |
795+
| `POST` | `/config/check-s3-bucket` | Check if an S3 bucket exists |
796+
| `POST` | `/config/create-s3-bucket` | Create S3 bucket with `lsmc` cost tags |
797+
| `POST` | `/config/switch-backend` | Switch live backend (session-only) |
798+
| `POST` | `/templates/import-to-dynamo` | Import local templates into DynamoDB |
799+
| `POST` | `/templates` | Save/create a ZPL template |
800+
| `DELETE` | `/templates/{name}` | Delete a template |
801+
802+
```bash
803+
# Example: check backend status
804+
curl https://localhost:8118/api/v1/config/backend-status
805+
806+
# Example: switch to DynamoDB (session-only)
807+
curl -X POST https://localhost:8118/api/v1/config/switch-backend \
808+
-H "Content-Type: application/json" \
809+
-d '{"backend_type":"dynamodb","table_name":"zebra-day-config","region":"us-west-2","s3_bucket":"zebra-day-cfg-us-west-2","profile":"my-profile"}'
810+
811+
# Example: import local templates to DynamoDB
812+
curl -X POST https://localhost:8118/api/v1/templates/import-to-dynamo \
813+
-H "Content-Type: application/json" \
814+
-d '{"template_names":["tube_2inX1in","plate_1inX0.25in"]}'
815+
```
697816
698817
<br><br>
699818

zebra_day/docs/programatic_guide.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,49 @@ zlab.replace_printer_json_from_template()
6161
When clearing or writing a new config, the existing one is saved to a backup location. Users can open these and effectively rollback if errors are made. Replace from template means overwriting the active one with the template file which accompanies the repo.
6262

6363

64+
### Using DynamoDB Backend (v2.2.0+)
65+
66+
By default `zpl()` uses local files. To use a shared DynamoDB backend, pass `backend="dynamodb"`:
67+
68+
```python
69+
import zebra_day.print_mgr as zdpm
70+
71+
# Local backend (default)
72+
zlab = zdpm.zpl()
73+
74+
# DynamoDB backend — requires table + S3 bucket to exist (see `zday dynamo init`)
75+
zlab = zdpm.zpl(
76+
backend="dynamodb",
77+
table_name="zebra-day-config",
78+
region="us-west-2",
79+
s3_bucket="zebra-day-cfg-us-west-2",
80+
s3_prefix="zebra-day/",
81+
profile="my-aws-profile",
82+
)
83+
84+
# All operations (print, scan, template management) work identically
85+
# regardless of backend. Config and templates are read/written to DynamoDB
86+
# instead of local files, and every write triggers an automatic S3 backup.
87+
```
88+
89+
Alternatively, set environment variables and omit explicit parameters:
90+
91+
```bash
92+
export ZEBRA_DAY_CONFIG_BACKEND=dynamodb
93+
export ZEBRA_DAY_DYNAMO_TABLE=zebra-day-config
94+
export ZEBRA_DAY_DYNAMO_REGION=us-west-2
95+
export ZEBRA_DAY_S3_BACKUP_BUCKET=zebra-day-cfg-us-west-2
96+
export AWS_PROFILE=my-aws-profile
97+
```
98+
99+
```python
100+
import zebra_day.print_mgr as zdpm
101+
102+
# Picks up DynamoDB settings from env vars automatically
103+
zlab = zdpm.zpl()
104+
```
105+
106+
64107
### Scan Local Network For Zebra Printers
65108
> def probe_zebra_printers_add_to_printers_json(self, ip_stub="192.168.1", scan_wait="0.25",lab="scan-results"):
66109

zebra_day/docs/zebra_day_ui_guide.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,40 @@ The **State** column shows additional details when errors are detected:
9191

9292
---
9393

94+
## DynamoDB Backend Controls (v2.2.0+)
95+
96+
The **Config** page includes a DynamoDB section when the feature is enabled:
97+
98+
### Backend Status Card
99+
Displays the active backend (`local` or `dynamodb`) along with AWS details (table name, region, S3 bucket, profile).
100+
101+
### Switch Backend Form
102+
Swap between `local` and `dynamodb` backends for the running server session:
103+
- Select backend type from dropdown
104+
- DynamoDB fields appear when `dynamodb` is selected: table, region, S3 bucket, S3 prefix, AWS profile
105+
- Auto-detects existing DynamoDB tables in the chosen region
106+
- Auto-suggests S3 bucket name (`zebra-day-cfg-<region>`)
107+
- "Create Bucket" button appears if the bucket doesn't exist
108+
- Validates that AWS profile is not set to `default`
109+
- **Session-only**: switching does not change environment variables or persist across restarts
110+
111+
### Refresh Config
112+
Reloads the printer configuration from the active backend (useful after external changes to DynamoDB).
113+
114+
---
115+
116+
## Template Import to DynamoDB (v2.3.0+)
117+
118+
When a DynamoDB backend is active, the **Templates** page shows an additional section:
119+
120+
### Import Local Templates
121+
- Lists all local templates (user-created and package-shipped) with checkboxes
122+
- Select one or more templates and click **Import Selected to DynamoDB**
123+
- Templates already present in DynamoDB are skipped
124+
- Imported templates become the active set for all clients sharing the DynamoDB table
125+
126+
---
127+
94128
## API Reference (curl examples)
95129

96130
All API endpoints are documented at `/docs` (Swagger UI) and `/redoc`. Here are common operations:

0 commit comments

Comments
 (0)