Skip to content

Commit 33e04c7

Browse files
committed
Updated
1 parent a1943bb commit 33e04c7

11 files changed

Lines changed: 316 additions & 65 deletions

File tree

‎.gitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.venv
22
.DS_Store
33
.vscode/settings.json
4-
.gitignore
54

65
# API credentials written by setup_env.py - never commit
76
.env

‎.kiro/steering/code-standards.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ if __name__ == '__main__':
5555

5656
- **Auth**: Never hardcode keys. Use env vars or `scripts/utils/credentials.py`.
5757
- **Error handling**: Wrap API calls in try/except. Retry on 408, 429, 503, 504 with backoff.
58-
- **Output**: CSV for tabular, JSON for structured. Print progress on long ops. Store exports in `scripts/script_manager/csv_files/`.
58+
- **Output**: CSV for tabular, JSON for structured. Print progress on long ops. Store exports in `web_apps/script_manager/csv_files/`.
5959
- **Dependencies**: Check `requirements.txt` before adding new ones.
6060
- **Web servers**: Always set `socketserver.TCPServer.allow_reuse_address = True` before creating instance.

‎.kiro/steering/ncm-api-development.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
inclusion: fileMatch
3-
fileMatchPattern: "{scripts/**/*.py,ncm/**/*.py,ncm2/**/*.py,dashboards/**/*.py}"
3+
fileMatchPattern: "{scripts/**/*.py,ncm/**/*.py,ncm2/**/*.py,web_apps/**/*.py}"
44
description: NCM API development — endpoint routing, SDK usage, critical rules. Pull in #reflexion-workflow for the full self-improving docs loop.
55
---
66

‎.kiro/steering/project-setup.md‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,23 @@ If you import a third-party package in new code, confirm it is in
168168

169169
## Running web apps
170170

171-
Web apps live in `web_apps/<name>/`. Each has a `serve.py` and a fixed port
172-
(see `README.md`). Start them in the background, not the foreground, and tell
173-
the user the URL. Ports in use: `lsof -ti:<port> | xargs kill` on macOS/Linux,
174-
`netstat -ano | findstr :<port>` then `taskkill /PID <pid> /F` on Windows.
171+
Web apps live in `web_apps/<name>/` and each has a fixed port. **Do not assume the
172+
entry point is `serve.py`** — five of the twelve apps use a different filename, so
173+
check before launching:
174+
175+
| Entry point | Apps |
176+
|---|---|
177+
| `serve.py` | `inventory_dashboard`, `cellular_health_dashboard`, `alert_dashboard`, `geo_ip_blocker`, `host_identity_copier`, `assign_sdk`, `web_app_template` |
178+
| `config_builder.py` | `config_builder` |
179+
| `script_manager.py` | `script_manager` |
180+
| `ncm_api_key_encryptor.py` | `ncm_api_key_encryptor` |
181+
| `router_lookup.py` | `netcloud_router_lookup` |
182+
| `app.py` | `cisco_to_cradlepoint_zfw_converter` |
183+
184+
`ls web_apps/<name>/` settles it in one call. See `web_apps/README.md` for the port
185+
table.
186+
187+
Start them in the background, not the foreground, and tell the user the URL. Ports
188+
in use: `lsof -ti:<port> | xargs kill` on macOS/Linux, `netstat -ano | findstr
189+
:<port>` then `taskkill /PID <pid> /F` on Windows. Port 8000 is shared by four apps
190+
and 8065 by two, so run those one at a time.

‎.kiro/steering/web-ui-standards.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
inclusion: fileMatch
3-
fileMatchPattern: "{**/*.html,**/*.css,**/web_apps/**,**/dashboards/**}"
3+
fileMatchPattern: "{**/*.html,**/*.css,**/web_apps/**}"
44
description: Web UI standards — template references, dark mode, dashboard requirements.
55
---
66

@@ -38,9 +38,9 @@ Breakpoints at 1024px and 768px. Sidebar collapses on smaller screens.
3838

3939
## Dashboard Pattern
4040

41-
For data-driven dashboards, use `dashboards/cellular_health/` as reference:
42-
- Backend: `dashboards/cellular_health/serve.py` (FastAPI)
43-
- Frontend: `dashboards/cellular_health/index.html`
41+
For data-driven dashboards, use `web_apps/cellular_health_dashboard/` as reference:
42+
- Backend: `web_apps/cellular_health_dashboard/serve.py` (FastAPI)
43+
- Frontend: `web_apps/cellular_health_dashboard/index.html`
4444

4545
### Required Dashboard Features
4646

‎AGENTS.md‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,34 @@ If you import a third-party package in new code, confirm it is in
178178

179179
### Running web apps
180180

181-
Web apps live in `web_apps/<name>/`. Each has a `serve.py` and a fixed port — see
181+
Web apps live in `web_apps/<name>/` and each has a fixed port — see
182182
`web_apps/README.md` for the port table. Start them in the background, not the
183183
foreground, and tell the user the URL.
184184

185+
**Do not assume the entry point is `serve.py`.** Five of the twelve apps use a
186+
different filename:
187+
188+
| Entry point | Apps |
189+
|---|---|
190+
| `serve.py` | `inventory_dashboard`, `cellular_health_dashboard`, `alert_dashboard`, `geo_ip_blocker`, `host_identity_copier`, `assign_sdk`, `web_app_template` |
191+
| `config_builder.py` | `config_builder` |
192+
| `script_manager.py` | `script_manager` |
193+
| `ncm_api_key_encryptor.py` | `ncm_api_key_encryptor` |
194+
| `router_lookup.py` | `netcloud_router_lookup` |
195+
| `app.py` | `cisco_to_cradlepoint_zfw_converter` |
196+
197+
`ls web_apps/<name>/` settles it in one call.
198+
185199
Freeing a port in use:
186200

187201
```bash
188202
lsof -ti:<port> | xargs kill # macOS / Linux
189203
netstat -ano | findstr :<port> && taskkill /PID <pid> /F # Windows
190204
```
191205

192-
Ports 8000 and 8065 are shared by more than one app, so run those one at a time.
206+
Port 8000 is shared by four apps (`script_manager`, `ncm_api_key_encryptor`,
207+
`netcloud_router_lookup`, `web_app_template`) and 8065 by two (`alert_dashboard`,
208+
`geo_ip_blocker`), so run those one at a time.
193209

194210
---
195211

@@ -282,7 +298,7 @@ Available helpers in `scripts/utils/`: `env_check.py`, `env_status.py`,
282298
- **Error handling** — wrap API calls in try/except. Retry on 408, 429, 503, 504 with
283299
exponential backoff.
284300
- **Output** — CSV for tabular data, JSON for structured. Print progress on long
285-
operations. Store exports in `scripts/script_manager/csv_files/`.
301+
operations. Store exports in `web_apps/script_manager/csv_files/`.
286302
- **Dependencies** — check `requirements.txt` before adding new ones.
287303
- **Web servers** — always set `socketserver.TCPServer.allow_reuse_address = True`
288304
before creating the instance.

‎README.md‎

Lines changed: 134 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,55 @@ A collection of Python scripts and web applications for interacting with Ericsso
44

55
## Getting Started
66

7-
Three steps: clone, run setup, start chatting with Kiro.
7+
Fork, clone your fork in Kiro, run setup, then start chatting. If you build
8+
something worth sharing, open a pull request back to this repo.
89

910
### 1. Prerequisites
1011

1112
- Python 3.9 or higher (3.12 recommended) — Windows users, see the [Windows Python Setup Guide](WINDOWS_PYTHON_SETUP.md)
1213
- Git
14+
- A GitHub account
15+
- [Kiro](https://kiro.dev)
1316

14-
### 2. Clone the repository
17+
### 2. Fork the repository
18+
19+
Forking gives you your own copy to experiment in, and it's what lets you
20+
contribute changes back later.
21+
22+
1. Go to [github.com/cradlepoint/api-samples](https://github.com/cradlepoint/api-samples)
23+
2. Click **Fork** (top right), then **Create fork**
24+
25+
You now have `https://github.com/<your-username>/api-samples`.
26+
27+
### 3. Clone your fork in Kiro
28+
29+
In Kiro, open the Command Palette (`Cmd+Shift+P` on macOS, `Ctrl+Shift+P` on
30+
Windows/Linux), run **Git: Clone**, and paste your fork's URL:
31+
32+
```
33+
https://github.com/<your-username>/api-samples.git
34+
```
35+
36+
Pick a local folder, then choose **Open** when Kiro offers to open the cloned
37+
repository.
38+
39+
Prefer the terminal? Same result:
1540

1641
```bash
17-
git clone <repository-url>
42+
git clone https://github.com/<your-username>/api-samples.git
1843
cd api-samples
1944
```
2045

21-
### 3. Run setup
46+
Then add the original repo as `upstream` so you can pull in later changes:
47+
48+
```bash
49+
git remote add upstream https://github.com/cradlepoint/api-samples.git
50+
```
51+
52+
Clone your fork, not this repo directly — you won't have push access here, and
53+
you'd have nowhere to put your branch when it's time to open a pull request.
54+
55+
### 4. Run setup
2256

2357
**macOS / Linux**
2458

@@ -44,16 +78,27 @@ source .venv/bin/activate # macOS / Linux
4478
.venv\Scripts\activate.bat # Windows cmd
4579
```
4680

47-
### 4. Start chatting with Kiro
81+
### 5. Build apps by chatting with Kiro
4882

49-
Open the folder in Kiro and ask for what you want:
83+
Open the Kiro chat panel and describe what you want in plain language:
5084

5185
- "Build me a dashboard showing routers with poor signal"
5286
- "Export all my routers to CSV"
5387
- "Which devices have subscriptions expiring in the next 30 days?"
88+
- "Add a CSV export button to the inventory dashboard"
5489

55-
Kiro reads the API docs in `docs/`, uses the venv, and picks up your credentials
56-
automatically.
90+
Kiro reads the API references in `docs/`, follows the conventions in `.kiro/steering/`,
91+
uses the `.venv` interpreter, and picks up your credentials automatically. New web
92+
apps get scaffolded into `web_apps/` using the shared style template, so they match
93+
the existing dashboards.
94+
95+
A few things that make the results better:
96+
97+
- Point at files with `#File` or `#Folder` when you want Kiro to follow an existing
98+
pattern — for example, "build a dashboard like #Folder web_apps/cellular_health_dashboard"
99+
- Type `#setup-environment` if the environment needs repairing
100+
- Ask for a spec first on anything large: "write a spec for a firmware compliance
101+
dashboard." You review requirements and design before code gets written.
57102

58103
### Setup script options
59104

@@ -118,7 +163,6 @@ api-samples/
118163
├── web_apps/ # Web applications and dashboards
119164
├── scripts/ # Standalone Python scripts and utilities
120165
├── ncm/ # NCM Python SDK source (also pip installable)
121-
├── ncm2/ # NCM Python SDK v2+v3 variant
122166
├── docs/ # API documentation and references
123167
└── postman-collection/ # Postman API collection
124168
```
@@ -127,24 +171,40 @@ api-samples/
127171

128172
All web applications live in `web_apps/`. See [web_apps/README.md](web_apps/README.md) for full details.
129173

130-
| App | Port | Description |
131-
|-----|------|-------------|
132-
| [inventory_dashboard](web_apps/inventory_dashboard/) | 8060 | Device inventory with license status, subscriptions, modem info |
133-
| [cellular_health_dashboard](web_apps/cellular_health_dashboard/) | 8055 | Cellular health scores and signal metrics |
134-
| [script_manager](web_apps/script_manager/) | 8000 | CSV editor and NCM script runner with web UI |
135-
| [config_builder](web_apps/config_builder/) | 8100 | Build JSON configurations from templates |
136-
| [assign_sdk](web_apps/assign_sdk/) | 9000 | Assign SDK app versions to router groups |
137-
| [cisco_to_cradlepoint_zfw_converter](web_apps/cisco_to_cradlepoint_zfw_converter/) | 5001 | Convert Cisco configs to Cradlepoint zone firewall |
138-
| [ncm_api_key_encryptor](web_apps/ncm_api_key_encryptor/) | 8000 | Encrypt API keys for SDK app configs |
139-
| [netcloud_router_lookup](web_apps/netcloud_router_lookup/) | 8000 | Look up router info by serial/MAC |
174+
| App | Port | Entry point | Description |
175+
|-----|------|-------------|-------------|
176+
| [inventory_dashboard](web_apps/inventory_dashboard/) | 8060 | `serve.py` | Device inventory with license status, subscriptions, modem info |
177+
| [cellular_health_dashboard](web_apps/cellular_health_dashboard/) | 8055 | `serve.py` | Cellular health scores and signal metrics — RSRP, SINR, health scores |
178+
| [alert_dashboard](web_apps/alert_dashboard/) | 8065 | `serve.py` | Custom alerts with type/account filters, ACK tracking, auto-refresh, export |
179+
| [geo_ip_blocker](web_apps/geo_ip_blocker/) | 8065 | `serve.py` | Turn country IP ranges into zone firewall deny rules and push to groups |
180+
| [host_identity_copier](web_apps/host_identity_copier/) | 8070 | `serve.py` | Copy host address identities from a master group to many destinations |
181+
| [config_builder](web_apps/config_builder/) | 8100 | `config_builder.py` | Build Cradlepoint JSON configurations from templates with per-site variables |
182+
| [assign_sdk](web_apps/assign_sdk/) | 9000 | `serve.py` | Assign SDK app versions to router groups |
183+
| [script_manager](web_apps/script_manager/) | 8000 | `script_manager.py` | CSV editor and NCM script runner with web UI |
184+
| [ncm_api_key_encryptor](web_apps/ncm_api_key_encryptor/) | 8000 | `ncm_api_key_encryptor.py` | Encrypt API keys for embedding in SDK app configs |
185+
| [netcloud_router_lookup](web_apps/netcloud_router_lookup/) | 8000 | `router_lookup.py` | Search routers across multiple accounts |
186+
| [cisco_to_cradlepoint_zfw_converter](web_apps/cisco_to_cradlepoint_zfw_converter/) | 5001 | `app.py` | Convert Cisco router configs to Cradlepoint zone firewall format |
187+
| [web_app_template](web_apps/web_app_template/) | 8000 | `serve.py` | Style/layout starting point for new apps, not a tool in itself |
188+
189+
Ports 8000 and 8065 are each shared by more than one app, so run those one at a time.
140190

141191
### Running a Web App
142192

193+
Most apps use `serve.py`, but five don't — check the Entry point column above.
194+
143195
```bash
144-
python3 web_apps/inventory_dashboard/serve.py # macOS/Linux
145-
python web_apps/inventory_dashboard/serve.py # Windows
196+
python3 web_apps/inventory_dashboard/serve.py # macOS/Linux
197+
python web_apps/inventory_dashboard/serve.py # Windows
198+
199+
python3 web_apps/config_builder/config_builder.py # non-serve.py example
146200
```
147201

202+
Then open the app's port in your browser, e.g. http://localhost:8060.
203+
204+
These apps bind a local port with no authentication, which is fine on `localhost`.
205+
Don't expose one on a shared network — anyone who can reach the port can read the
206+
credentials stored in its Settings panel.
207+
148208
## Sample Scripts
149209

150210
The `scripts/` folder contains standalone Python scripts demonstrating various API interactions:
@@ -186,6 +246,59 @@ The `docs/` folder contains detailed API references:
186246
- [Known Issues](docs/known-issues.md) — API gotchas and workarounds
187247
- [Common Patterns](docs/common-patterns.md) — reusable code patterns
188248

249+
## Contributing Back
250+
251+
Built something useful in your fork? Open a pull request.
252+
253+
### 1. Work on a branch
254+
255+
```bash
256+
git checkout -b my-new-dashboard
257+
```
258+
259+
### 2. Commit and push to your fork
260+
261+
```bash
262+
git add web_apps/my_new_dashboard/
263+
git commit -m "Add dashboard for firmware compliance"
264+
git push -u origin my-new-dashboard
265+
```
266+
267+
Stage specific paths rather than `git add -A`. This repo keeps local credential and
268+
state files in the working tree, and a couple of them are still tracked from an
269+
earlier commit, so a blanket add can pick up API keys. Check `git status` before you
270+
commit.
271+
272+
### 3. Open the pull request
273+
274+
Either use the GitHub CLI:
275+
276+
```bash
277+
gh pr create --repo cradlepoint/api-samples --web
278+
```
279+
280+
Or visit your fork on GitHub and click **Compare & pull request**. Set the base to
281+
`cradlepoint/api-samples` and describe what you built and how you tested it.
282+
283+
You can ask Kiro to do the whole sequence for you — "commit this on a branch and open
284+
a PR against upstream" — and it will handle the branch, commit, push, and PR.
285+
286+
### Keeping your fork current
287+
288+
```bash
289+
git fetch upstream
290+
git checkout master
291+
git merge upstream/master
292+
git push
293+
```
294+
295+
### Before you submit
296+
297+
- No credentials in the diff — no `.env`, no `profiles.json` or `config.json` with real keys
298+
- A new app includes a short `readme.md` and any extra deps in `requirements.txt`
299+
- New web apps follow the shared style template, including light/dark mode
300+
- The code runs against a real NCM tenant
301+
189302
## Troubleshooting
190303

191304
Start here — it diagnoses most problems in one command:

0 commit comments

Comments
 (0)