wp-engine-api-python


Namewp-engine-api-python JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/jpollock/wp-engine-api-python
SummaryWP Engine API SDK for Python
upload_time2024-12-15 22:05:45
maintainerNone
docs_urlNone
authorJeremy Pollock
requires_python>=3.8
licenseMIT
keywords wpengine wordpress api sdk
VCS
bugtrack_url
requirements requests python-dateutil urllib3 pydantic typing-extensions python-dotenv pytest pytest-cov black isort mypy flake8 openapi-generator-cli
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # WP Engine API Python SDK

A Python SDK for interacting with the WP Engine API, enabling Python developers to programmatically interact with WP Engine services.

> **Note**: This SDK is maintained by Jeremy Pollock (jeremy.pollock@wpengine.com) and is not affiliated with or supported by WP Engine.

## Installation

```bash
pip install wp-engine-api
```

## Authentication

The SDK supports two methods of authentication:

### 1. Direct Username/Password

```python
from wp_engine_api import WPEngineAPI

# Initialize with credentials directly
client = WPEngineAPI(
    username="your-username",
    password="your-password"
)
```

### 2. Environment Variables

Create a `.env` file in your project root:
```bash
WP_ENGINE_API_USERNAME=your-username
WP_ENGINE_API_PASSWORD=your-password
```

Or set environment variables directly:
```bash
export WP_ENGINE_API_USERNAME=your-username
export WP_ENGINE_API_PASSWORD=your-password
```

Then initialize the client:
```python
from wp_engine_api import WPEngineAPI

# Initialize using environment variables
client = WPEngineAPI()
```

## Quick Start

```python
from wp_engine_api import WPEngineAPI

# Initialize the client
client = WPEngineAPI(
    username="your-username",
    password="your-password"
)

# List all sites
sites = client.sites.list()
for site in sites:
    print(f"Site: {site.name} ({site.id})")

# Get a specific site
site = client.sites.get("site_id")

# Create a backup
backup = client.backups.create(
    "site_id",
    {
        "description": "Pre-deployment backup",
        "notification_emails": ["admin@example.com"]
    }
)
```

## Features

- Full coverage of the WP Engine API
- Type hints for better IDE support
- Automatic rate limiting
- Request validation
- Comprehensive error handling
- Environment variable support
- .env file support

## Examples

### Site Management

```python
# List all sites
sites = client.sites.list()

# Get a specific site
site = client.sites.get("site_id")

# Update a site
updated_site = client.sites.update(
    "site_id",
    {"name": "New Site Name"}
)
```

### Backup Management

```python
# Create a backup
backup = client.backups.create(
    "site_id",
    {
        "description": "Pre-deployment backup",
        "notification_emails": ["admin@example.com"]
    }
)

# List backups
backups = client.backups.list("site_id")

# Get backup status
backup_status = client.backups.get("site_id", "backup_id")
```

### Error Handling

```python
from wp_engine_api.exceptions import (
    AuthenticationError,
    ValidationError,
    ResourceNotFoundError,
    RateLimitError
)

try:
    sites = client.sites.list()
except AuthenticationError:
    print("Invalid credentials")
except ResourceNotFoundError:
    print("Resource not found")
except RateLimitError as e:
    print(f"Rate limit exceeded. Retry after {e.retry_after} seconds")
except ValidationError as e:
    print(f"Invalid request: {e}")
```

## Rate Limiting

The SDK includes automatic rate limiting to help you stay within the API's limits. You can configure the rate limiting behavior:

```python
client = WPEngineAPI(
    username="your-username",
    password="your-password",
    max_retries=3,
    retry_delay=1.0
)
```

## Development

### Setup Development Environment

1. Clone the repository:
```bash
git clone https://github.com/wpengine/wp-engine-api-python.git
cd wp-engine-api-python
```

2. Create a virtual environment:
```bash
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
```

3. Install development dependencies:
```bash
pip install -r requirements.txt
```

### Running Tests

```bash
pytest
```

### Generating API Client

The SDK uses OpenAPI Generator to generate the base API client code. To regenerate the client:

```bash
python scripts/generate_client.py
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Maintainer

This SDK is maintained by Jeremy Pollock (jeremy.pollock@wpengine.com). For any questions, issues, or contributions, please reach out directly.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jpollock/wp-engine-api-python",
    "name": "wp-engine-api-python",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "wpengine, wordpress, api, sdk",
    "author": "Jeremy Pollock",
    "author_email": "Jeremy Pollock <jeremy.pollock@wpengine.com>",
    "download_url": "https://files.pythonhosted.org/packages/b9/25/579e546cc697ae997fc3b2dd70a167893e7353a790aebe6ed03f35695c67/wp_engine_api_python-0.0.2.tar.gz",
    "platform": null,
    "description": "# WP Engine API Python SDK\n\nA Python SDK for interacting with the WP Engine API, enabling Python developers to programmatically interact with WP Engine services.\n\n> **Note**: This SDK is maintained by Jeremy Pollock (jeremy.pollock@wpengine.com) and is not affiliated with or supported by WP Engine.\n\n## Installation\n\n```bash\npip install wp-engine-api\n```\n\n## Authentication\n\nThe SDK supports two methods of authentication:\n\n### 1. Direct Username/Password\n\n```python\nfrom wp_engine_api import WPEngineAPI\n\n# Initialize with credentials directly\nclient = WPEngineAPI(\n    username=\"your-username\",\n    password=\"your-password\"\n)\n```\n\n### 2. Environment Variables\n\nCreate a `.env` file in your project root:\n```bash\nWP_ENGINE_API_USERNAME=your-username\nWP_ENGINE_API_PASSWORD=your-password\n```\n\nOr set environment variables directly:\n```bash\nexport WP_ENGINE_API_USERNAME=your-username\nexport WP_ENGINE_API_PASSWORD=your-password\n```\n\nThen initialize the client:\n```python\nfrom wp_engine_api import WPEngineAPI\n\n# Initialize using environment variables\nclient = WPEngineAPI()\n```\n\n## Quick Start\n\n```python\nfrom wp_engine_api import WPEngineAPI\n\n# Initialize the client\nclient = WPEngineAPI(\n    username=\"your-username\",\n    password=\"your-password\"\n)\n\n# List all sites\nsites = client.sites.list()\nfor site in sites:\n    print(f\"Site: {site.name} ({site.id})\")\n\n# Get a specific site\nsite = client.sites.get(\"site_id\")\n\n# Create a backup\nbackup = client.backups.create(\n    \"site_id\",\n    {\n        \"description\": \"Pre-deployment backup\",\n        \"notification_emails\": [\"admin@example.com\"]\n    }\n)\n```\n\n## Features\n\n- Full coverage of the WP Engine API\n- Type hints for better IDE support\n- Automatic rate limiting\n- Request validation\n- Comprehensive error handling\n- Environment variable support\n- .env file support\n\n## Examples\n\n### Site Management\n\n```python\n# List all sites\nsites = client.sites.list()\n\n# Get a specific site\nsite = client.sites.get(\"site_id\")\n\n# Update a site\nupdated_site = client.sites.update(\n    \"site_id\",\n    {\"name\": \"New Site Name\"}\n)\n```\n\n### Backup Management\n\n```python\n# Create a backup\nbackup = client.backups.create(\n    \"site_id\",\n    {\n        \"description\": \"Pre-deployment backup\",\n        \"notification_emails\": [\"admin@example.com\"]\n    }\n)\n\n# List backups\nbackups = client.backups.list(\"site_id\")\n\n# Get backup status\nbackup_status = client.backups.get(\"site_id\", \"backup_id\")\n```\n\n### Error Handling\n\n```python\nfrom wp_engine_api.exceptions import (\n    AuthenticationError,\n    ValidationError,\n    ResourceNotFoundError,\n    RateLimitError\n)\n\ntry:\n    sites = client.sites.list()\nexcept AuthenticationError:\n    print(\"Invalid credentials\")\nexcept ResourceNotFoundError:\n    print(\"Resource not found\")\nexcept RateLimitError as e:\n    print(f\"Rate limit exceeded. Retry after {e.retry_after} seconds\")\nexcept ValidationError as e:\n    print(f\"Invalid request: {e}\")\n```\n\n## Rate Limiting\n\nThe SDK includes automatic rate limiting to help you stay within the API's limits. You can configure the rate limiting behavior:\n\n```python\nclient = WPEngineAPI(\n    username=\"your-username\",\n    password=\"your-password\",\n    max_retries=3,\n    retry_delay=1.0\n)\n```\n\n## Development\n\n### Setup Development Environment\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/wpengine/wp-engine-api-python.git\ncd wp-engine-api-python\n```\n\n2. Create a virtual environment:\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n```\n\n3. Install development dependencies:\n```bash\npip install -r requirements.txt\n```\n\n### Running Tests\n\n```bash\npytest\n```\n\n### Generating API Client\n\nThe SDK uses OpenAPI Generator to generate the base API client code. To regenerate the client:\n\n```bash\npython scripts/generate_client.py\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Maintainer\n\nThis SDK is maintained by Jeremy Pollock (jeremy.pollock@wpengine.com). For any questions, issues, or contributions, please reach out directly.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "WP Engine API SDK for Python",
    "version": "0.0.2",
    "project_urls": {
        "Bug Reports": "https://github.com/jpollock/wp-engine-api-python/issues",
        "Documentation": "https://wpengineapi.com/docs",
        "Homepage": "https://github.com/jpollock/wp-engine-api-python",
        "Source": "https://github.com/jpollock/wp-engine-api-python"
    },
    "split_keywords": [
        "wpengine",
        " wordpress",
        " api",
        " sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6e5e774c23a056fec3c23820ac6002c62f5ddc2ef0a859279ede2100ce89dfa4",
                "md5": "583968edc59fa89c6db3ba67e5f557da",
                "sha256": "e16938ec0d1ac8546c7d54976f1998ebc58f22022ecbdadf631a902a6822a47f"
            },
            "downloads": -1,
            "filename": "wp_engine_api_python-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "583968edc59fa89c6db3ba67e5f557da",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 126820,
            "upload_time": "2024-12-15T22:05:42",
            "upload_time_iso_8601": "2024-12-15T22:05:42.407616Z",
            "url": "https://files.pythonhosted.org/packages/6e/5e/774c23a056fec3c23820ac6002c62f5ddc2ef0a859279ede2100ce89dfa4/wp_engine_api_python-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b925579e546cc697ae997fc3b2dd70a167893e7353a790aebe6ed03f35695c67",
                "md5": "929b2d4683bf8587f271bafa6204bc39",
                "sha256": "4541990a166b1cac456be5610460e52ec09a58b6bbe0bbeb80afa274fe86d7cb"
            },
            "downloads": -1,
            "filename": "wp_engine_api_python-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "929b2d4683bf8587f271bafa6204bc39",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 53207,
            "upload_time": "2024-12-15T22:05:45",
            "upload_time_iso_8601": "2024-12-15T22:05:45.038645Z",
            "url": "https://files.pythonhosted.org/packages/b9/25/579e546cc697ae997fc3b2dd70a167893e7353a790aebe6ed03f35695c67/wp_engine_api_python-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-15 22:05:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jpollock",
    "github_project": "wp-engine-api-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.25.0"
                ]
            ]
        },
        {
            "name": "python-dateutil",
            "specs": [
                [
                    ">=",
                    "2.8.0"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    ">=",
                    "1.26.0"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    ">=",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "typing-extensions",
            "specs": [
                [
                    ">=",
                    "4.0.0"
                ]
            ]
        },
        {
            "name": "python-dotenv",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    ">=",
                    "7.0.0"
                ]
            ]
        },
        {
            "name": "pytest-cov",
            "specs": [
                [
                    ">=",
                    "4.0.0"
                ]
            ]
        },
        {
            "name": "black",
            "specs": [
                [
                    ">=",
                    "22.0.0"
                ]
            ]
        },
        {
            "name": "isort",
            "specs": [
                [
                    ">=",
                    "5.0.0"
                ]
            ]
        },
        {
            "name": "mypy",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "flake8",
            "specs": [
                [
                    ">=",
                    "6.0.0"
                ]
            ]
        },
        {
            "name": "openapi-generator-cli",
            "specs": [
                [
                    ">=",
                    "6.0.0"
                ]
            ]
        }
    ],
    "lcname": "wp-engine-api-python"
}
        
Elapsed time: 9.86322s