Metadata-Version: 2.4
Name: cli-anything-npm
Version: 1.0.0
Summary: CLI harness for Nginx Proxy Manager
Author: CLI Anything
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: click>=8.0.0
Requires-Dist: requests>=2.28.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: license
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Nginx Proxy Manager CLI

A stateful CLI harness for managing Nginx Proxy Manager via its REST API.

## Installation

```bash
pip install cli-anything-npm
```

## Quick Start

```bash
# Check NPM health
cli-anything-npm health --url http://npm.example.com:81/api

# Login
cli-anything-npm login --identity admin@example.com --secret password

# List proxy hosts
cli-anything-npm proxy-host list

# Create proxy host
cli-anything-npm proxy-host create \
  --domain example.com \
  --forward-host 10.0.0.1 \
  --forward-port 8080

# Enable/disable hosts
cli-anything-npm proxy-host enable 1
cli-anything-npm proxy-host disable 1

# Get JSON output (for agent consumption)
cli-anything-npm proxy-host list --json
```

## Commands

### Authentication

```bash
cli-anything-npm login --identity <email> --secret <password>
cli-anything-npm login --identity <email> --secret <password> --2fa <code>
cli-anything-npm logout
```

### Proxy Hosts

```bash
cli-anything-npm proxy-host list [--expand] [--query]
cli-anything-npm proxy-host get <id>
cli-anything-npm proxy-host create --domain <domains> --forward-host <host> --forward-port <port>
cli-anything-npm proxy-host update <id> [options]
cli-anything-npm proxy-host delete <id>
cli-anything-npm proxy-host enable <id>
cli-anything-npm proxy-host disable <id>
```

### Certificates

```bash
cli-anything-npm cert list
cli-anything-npm cert get <id>
cli-anything-npm cert renew <id>
cli-anything-npm cert delete <id>
cli-anything-npm cert dns-providers
```

### Streams

```bash
cli-anything-npm stream list
cli-anything-npm stream get <id>
cli-anything-npm stream create --incoming-port <port> --forwarding-host <host> --forwarding-port <port>
cli-anything-npm stream update <id> [options]
cli-anything-npm stream delete <id>
cli-anything-npm stream enable <id>
cli-anything-npm stream disable <id>
```

#### Stream Options

| Option | Description |
|--------|-------------|
| `--incoming-port` | Port to listen on |
| `--forwarding-host` | Target host to forward to |
| `--forwarding-port` | Target port to forward to |
| `--tcp/--no-tcp` | Enable TCP forwarding (default: enabled) |
| `--udp/--no-udp` | Enable UDP forwarding (default: disabled) |
| `--certificate` | SSL certificate ID (0 = no SSL) |
| `--json-input` | Read configuration from JSON file |

#### Stream Examples

```bash
# Create a TCP port proxy (port 3095 -> sais-web-dev:80)
cli-anything-npm stream create \
  --incoming-port 3095 \
  --forwarding-host sais-web-dev \
  --forwarding-port 80

# Create with UDP support
cli-anything-npm stream create \
  --incoming-port 53 \
  --forwarding-host dns-server \
  --forwarding-port 53 \
  --udp

# Update forwarding target
cli-anything-npm stream update 8 --forwarding-host new-backend

# Get stream details
cli-anything-npm stream get 8

# Delete stream
cli-anything-npm stream delete 8
```

### Access Lists

```bash
cli-anything-npm access-list list
```

### Users

```bash
cli-anything-npm user list
cli-anything-npm user get <id>
```

## Global Options

| Option | Description | Default |
|--------|-------------|---------|
| `--url` | NPM API base URL | `http://127.0.0.1:81/api` |
| `--token` | JWT auth token | From session |
| `--json` | Output as JSON | False |

## REPL Mode

```bash
cli-anything-npm repl
npm> health
npm> login --identity admin@example.com --secret password
npm> proxy-host list
npm> proxy-host create --domain test.local --forward-host 10.0.0.1 --forward-port 80
npm> exit
```

## JSON Output

All commands support `--json` for programmatic consumption:

```bash
cli-anything-npm proxy-host list --json
# [{"id": 1, "domain_names": ["example.com"], ...}]
```

## Session Persistence

Session state is saved to `~/.npm-cli/session.json` including:
- API base URL
- JWT token
- User info
- Output preferences

## Python API

```python
from cli_anything.npm import NPMClient, Session

# Create client
client = NPMClient(base_url="http://npm.example.com:81/api")

# Login
result = client.login("admin@example.com", "password")
client.set_token(result["token"])

# List proxy hosts
hosts = client.list_proxy_hosts()

# Create proxy host
host = client.create_proxy_host({
    "domain_names": ["example.com"],
    "forward_host": "10.0.0.1",
    "forward_port": 8080,
    "enabled": True
})

# Enable/disable
client.enable_proxy_host(host["id"])
client.disable_proxy_host(host["id"])
```

## License

MIT
