dqx-network 0.1.0
Network validation checks for DQX data quality framework
Requires Python: >=3.11

# DQX Network

A Python package that extends the DQX data quality framework with comprehensive network validation checks.

## Features

- **14 Network Check Functions**: Validate IP addresses, URLs, domains, MAC addresses, ports, and more
- **DQX Integration**: Standardized interface for integrating with DQX framework
- **Command Line Interface**: Easy testing and validation from the command line
- **Batch Processing**: Run multiple checks from JSON configuration files
- **Comprehensive Validation**: Support for IPv4, IPv6, CIDR, private/public IPs, and network protocols

## Available Network Checks

| Check Function | Description |
|---------------|-------------|
| `is_valid_ipv4` | Validate IPv4 addresses |
| `is_valid_ipv6` | Validate IPv6 addresses |
| `is_valid_ip` | Validate any IP address (IPv4 or IPv6) |
| `is_valid_cidr` | Validate CIDR notation |
| `is_private_ip` | Check if IP is in private range |
| `is_reserved_ip` | Check if IP is in reserved range |
| `is_valid_mac_address` | Validate MAC addresses (multiple formats) |
| `is_valid_url` | Validate URLs |
| `is_valid_domain` | Validate domain names |
| `is_valid_port` | Validate port numbers (1-65535) |
| `is_well_known_port` | Check if port is well-known (1-1023) |
| `is_valid_hostname` | Validate hostnames |
| `is_valid_email` | Validate email addresses |
| `is_in_subnet` | Check if IP is within a subnet |

## Installation

### Development Installation

For development, install the package in editable mode:

```bash
pip install -e .
```

### Production Installation

```bash
pip install .
```

## Usage

### As a Python Module

```python
from dqx_network import is_valid_ipv4, is_valid_url, dqx_check

# Direct function calls
result = is_valid_ipv4("192.168.1.1")
print(result.passed)  # True
print(result.message)  # "'192.168.1.1' is a valid IPv4 address"

# DQX-compatible format
dqx_result = dqx_check("is_valid_url", "https://example.com")
print(dqx_result["passed"])  # True
```

### As a Command Line Tool

After installation, you can use the CLI for testing and validation:

```bash
# List all available checks
dqx-network-cli list

# Run a single check
dqx-network-cli check is_valid_ipv4 192.168.1.1

# Check URL validity
dqx-network-cli check is_valid_url https://example.com

# Show check information
dqx-network-cli info is_valid_mac_address

# Run batch checks from JSON file
dqx-network-cli batch examples/checks.json

# Run DQX plugin demo
dqx-network-cli demo
```

### DQX Framework Integration

```python
from dqx_network import dqx_plugin, DQXNetworkChecker

# Using the plugin interface
checker = DQXNetworkChecker()

# Single check
result = checker.check("is_valid_ipv4", "192.168.1.1")

# Multiple checks
checks = [
    {"check_name": "is_valid_ipv4", "value": "192.168.1.1"},
    {"check_name": "is_valid_url", "value": "https://example.com"},
    {"check_name": "is_private_ip", "value": "10.0.0.1"}
]
results = checker.check_multiple(checks)

# Using the global plugin instance
plugin_info = dqx_plugin.get_plugin_info()
print(f"Plugin: {plugin_info['plugin_name']} v{plugin_info['plugin_version']}")
```

### Direct Execution

You can also run the main module directly:

```bash
python -m dqx_network.main
```

## Project Structure

This project uses the standard Python src layout:

```
dqx-network/
├── src/
│   └── dqx_network/
│       ├── __init__.py          # Package initialization and exports
│       ├── main.py              # Main entry point
│       ├── checks.py            # Core network check functions
│       ├── dqx_integration.py   # DQX framework integration
│       └── cli.py               # Command-line interface
├── examples/
│   └── checks.json              # Sample check configurations
├── pyproject.toml               # Project configuration
└── README.md                    # This file
```

## API Reference

### Core Check Functions

All check functions return a `NetworkCheckResult` object with:
- `passed`: Boolean indicating if the check passed
- `message`: Human-readable result message
- `details`: Additional details about the check

### DQX Integration

The package provides several integration points:

- `DQXNetworkChecker`: Main checker class for DQX integration
- `DQXNetworkPlugin`: Plugin interface for DQX frameworks
- `dqx_check()`: Convenience function for single checks
- `dqx_check_batch()`: Convenience function for multiple checks

### Command Line Interface

The CLI supports several commands:
- `list`: Show all available checks
- `check <check_name> <value>`: Run a single check
- `info <check_name>`: Show detailed check information
- `batch <file>`: Run checks from JSON file
- `demo`: Run DQX plugin demonstration

## Examples

### Batch Check Configuration

Create a JSON file with check configurations:

```json
[
  {
    "check_name": "is_valid_ipv4",
    "value": "192.168.1.1",
    "kwargs": {}
  },
  {
    "check_name": "is_in_subnet",
    "value": "192.168.1.100",
    "kwargs": {"subnet": "192.168.1.0/24"}
  }
]
```

Run with: `dqx-network-cli batch checks.json`

### Custom Check Integration

```python
from dqx_network import run_check, get_available_checks

# Get all available checks
checks = get_available_checks()

# Run a check by name
result = run_check("is_valid_mac_address", "00:11:22:33:44:55")
if result.passed:
    print("Valid MAC address")
else:
    print(f"Invalid: {result.message}")
```

## Contributing

1. Fork the repository
2. Create a feature branch
3. Add your network check functions to `checks.py`
4. Update the `NETWORK_CHECKS` registry
5. Add tests and documentation
6. Submit a pull request

## License

[Add your license here]