Metadata-Version: 2.4
Name: pyrest-model-client
Version: 0.0.4
Summary: A simple, flexible Python HTTP client and API modeling toolkit built on httpx and pydantic.
Author: Avi Zaguri
License: MIT
Project-URL: Homepage, https://github.com/aviz92/pyrest-model-client
Project-URL: Repository, https://github.com/aviz92/pyrest-model-client
Project-URL: Issues, https://github.com/aviz92/pyrest-model-client/issues
Keywords: rest,development
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.11
Classifier: Operating System :: OS Independent
Classifier: Topic :: System :: Logging
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: colorlog>=6.10.1
Requires-Dist: custom-python-logger>=2.0.10
Requires-Dist: email-validator>=2.3.0
Requires-Dist: httpx>=0.28.1
Requires-Dist: pathlib>=1.0.1
Requires-Dist: pre-commit>=4.5.0
Requires-Dist: pydantic>=2.12.4
Requires-Dist: pytest>=9.0.1
Requires-Dist: pytest-mock>=3.15.1
Requires-Dist: pytest-plugins>=1.0.9
Requires-Dist: python-dotenv>=1.2.1
Requires-Dist: python-simple-email-sender>=1.0.6
Requires-Dist: python-vault>=0.0.3
Requires-Dist: pyyaml>=6.0.3
Requires-Dist: setuptools>=80.9.0
Requires-Dist: wheel>=0.45.1
Dynamic: license-file

# python-requests-client

A simple, flexible Python HTTP client and API modeling toolkit built on top of [httpx](https://www.python-httpx.org/) and [pydantic](https://docs.pydantic.dev/). Easily integrate robust API requests and resource models into your Python projects.

---

## 🚀 Features
- **Model-driven**: Define and interact with API resources as Python classes.
- **Easy HTTP Requests**: Simple `RequestClient` for GET, POST, PUT, DELETE with automatic header and base URL management.
- **Pydantic API Models**: Define resource models with CRUD helpers (`save`, `delete`, `load`, `find`).
- **Global Client Setup**: Set a global API client for all models with `set_client()`.
- **Type Safety**: All models use Pydantic for validation and serialization.
- **Extensible**: Easily create new models for any RESTful resource.

---

## 📦 Installation
```bash
pip install python-requests-client
```

---

## 🔧 Usage

### 1. Define Your Models

```python
from pyrest_model_client.base import BaseAPIModel
from typing import ClassVar


class User(BaseAPIModel):
  name: str
  email: str
  _resource_path: ClassVar[str] = "user"


class Environment(BaseAPIModel):
  name: str
  _resource_path: ClassVar[str] = "environment"
```

### 2. Initialize the Client

```python
from pyrest_model_client import RequestClient, build_header, set_client
from example_usage.models.user import User
from example_usage.models.environment import Environment

set_client(
  new_client=RequestClient(
    base_url="http://localhost:8000",
    header=build_header(token="YOUR_API_TOKEN")
  )
)

# Create and save a new user
e = User(name="Alice", email="alice@example.com")
e.save()

# Update and save
e.name = "Alice Smith"
e.save()

# Find all environments
environments = Environment.find()
print(environments)

# Load a specific user by ID
user = User.load(resource_id="123")

# Delete a user
user.delete()
```

---

## 🤝 Contributing
Contributions are welcome! Please fork the repo, create a branch, and submit a pull request.

---

## 📄 License
MIT License — see [LICENSE](LICENSE) for details.
