neon-api


Nameneon-api JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/neondatabase/neon-api-python
SummaryAn API Client for the Neon API.
upload_time2025-01-14 18:14:01
maintainerNone
docs_urlNone
authorKenneth Reitz
requires_python>=3.9.0
licenseApache 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# `neon_api`: Python API wrapper for the [Neon API](https://api-docs.neon.tech/reference/getting-started-with-neon-api).

`neon_api` is a Python wrapper designed to simplify interactions with the [Neon API](https://api-docs.neon.tech/reference/getting-started-with-neon-api). It provides a convenient way for developers to integrate their Python applications with the Neon platform, offering methods to manage API keys, projects, branches, databases, endpoints, roles, and operations programmatically.

With `neon_api`, you can automate tasks, streamline workflows, and build powerful integrations with ease.


## Installation

Installation of `neon_api` is easy, with pip:

```bash
$ pip install neon-api
```

## Usage

```python
from neon_api import NeonAPI

# Initialize the client.
neon = NeonAPI(api_key='your_api_key')
```

**[Documentation is available on ReadTheDocs](https://neon-api-python.readthedocs.io/)**.


Remember that you should never expose your api_key and handle it carefully since it gives access to sensitive data. It's better to set it as an environment variable (e.g. `NEON_API_KEY` + accompanying `neon_api.from_environ()`).


-------

### Methods of the `NeonAPI` class:

- `me()`: Returns the current user.

**Manage API keys**:

- `api_keys()`: Returns a list of API keys.
- `api_key_create(**json)`: Creates an API key.
- `api_key_delete(key_id)`: Deletes a given API key.

**Manage projects**:

- `projects()`: Returns a list of projects.
- `project(project_id)`: Returns a specific project.
- `project_create(project_id, **json)`: Creates a new project. 
- `project_update(project_id, **json)`: Updates a given project.
- `project_delete(project_id)`: Deletes a given project.
- `project_permissions(project_id)`: Returns a list of permissions for a given project.
- `project_permissions_grant(project_id, **json)`: Grant permissions to a given project.
- `project_permissions_revoke(project_id, **json)`: Revoke permissions from a given project.
- `connection_uri(project_id, database_name, role_name)`: Returns the connection string for a given project.

**Manage branches**:

- `branches(project_id)`: Returns a list of branches for a given project.
- `branch(project_id, branch_id)`: Returns a specific branch.
- `branch_create(project_id, **json)`: Creates a new branch.
- `branch_update(project_id, branch_id, **json)`: Updates a given branch.
- `branch_delete(project_id, branch_id)`: Deletes a given branch.
- `branch_set_as_primary(project_id, branch_id)`: Sets a given branch as primary.

**Manage databases**:

- `databases(project_id, branch_id)`: Returns a list of databases for a given project and branch.
- `database(project_id, branch_id, database_id)`: Returns a specific database.
- `database_create(project_id, branch_id, **json)`: Creates a new database.
- `database_update(project_id, branch_id, **json)`: Updates a given database.
- `database_delete(project_id, branch_id, database_id)`: Deletes a given database.

**Manage endpoints**:

- `endpoints(project_id, branch_id)`: Returns a list of endpoints for a given project and branch.
- `endpoint_create(project_id, branch_id, **json)`: Creates a new endpoint.
- `endpoint_update(project_id, branch_id, endpoint_id, **json)`: Updates a given endpoint.
- `endpoint_delete(project_id, branch_id, endpoint_id)`: Deletes a given endpoint.
- `endpoint_start(project_id, branch_id, endpoint_id)`: Starts a given endpoint.
- `endpoint_suspend(project_id, branch_id, endpoint_id)`: Suspends a given endpoint.

**Manage roles**:

- `roles(project_id, branch_id)`: Returns a list of roles for a given project and branch.
- `role(project_id, branch_id, role_name)`: Returns a specific role.
- `role_create(project_id, branch_id, role_name)`: Creates a new role.
- `role_delete(project_id, branch_id, role_name)`: Deletes a given role.
- `role_password_reveal(project_id, branch_id, role_name)`: Reveals the password for a given role.
- `role_password_reset(project_id, branch_id, role_name)`: Resets the password for a given role.

**Manage operations**:

- `operations(project_id)`: Returns a list of operations for a given project.
- `operation(project_id, operation_id)`: Returns a specific operation.

**Experimental**:

- `consumption()`: Returns a list of project consumption metrics.


View the [Neon API documentation](https://api-docs.neon.tech/reference/getting-started-with-neon-api) for more information on the available endpoints and their parameters.


## Development

First, create a virtual environment, then install the dependencies of the library with `pip`:

```bash
$ pip install -r requirements.txt
```

This will install all the necessary dependencies for development.

To run the tests, use the following command:

```bash
# set up a .env file with your API key as per `.env.example`
$ make test
```

The tests don't require an internet connection, as they are mocked using the `pytest-vcr` library. To record new cassettes, use the following command:

```bash
$ make record
```

This will record new cassettes for the tests. Make sure to commit these cassettes along with your changes.

## License & Copyright

[Apache 2.0 Licensed](./LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/neondatabase/neon-api-python",
    "name": "neon-api",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9.0",
    "maintainer_email": null,
    "keywords": null,
    "author": "Kenneth Reitz",
    "author_email": "me@kennethreitz.org",
    "download_url": "https://files.pythonhosted.org/packages/3d/f6/31e508a8c3e3e71ba766f815e66b9efd418f83681f04fcf32ccb649ecbd7/neon_api-0.2.0.tar.gz",
    "platform": null,
    "description": "\n# `neon_api`: Python API wrapper for the [Neon API](https://api-docs.neon.tech/reference/getting-started-with-neon-api).\n\n`neon_api` is a Python wrapper designed to simplify interactions with the [Neon API](https://api-docs.neon.tech/reference/getting-started-with-neon-api). It provides a convenient way for developers to integrate their Python applications with the Neon platform, offering methods to manage API keys, projects, branches, databases, endpoints, roles, and operations programmatically.\n\nWith `neon_api`, you can automate tasks, streamline workflows, and build powerful integrations with ease.\n\n\n## Installation\n\nInstallation of `neon_api` is easy, with pip:\n\n```bash\n$ pip install neon-api\n```\n\n## Usage\n\n```python\nfrom neon_api import NeonAPI\n\n# Initialize the client.\nneon = NeonAPI(api_key='your_api_key')\n```\n\n**[Documentation is available on ReadTheDocs](https://neon-api-python.readthedocs.io/)**.\n\n\nRemember that you should never expose your api_key and handle it carefully since it gives access to sensitive data. It's better to set it as an environment variable (e.g. `NEON_API_KEY` + accompanying `neon_api.from_environ()`).\n\n\n-------\n\n### Methods of the `NeonAPI` class:\n\n- `me()`: Returns the current user.\n\n**Manage API keys**:\n\n- `api_keys()`: Returns a list of API keys.\n- `api_key_create(**json)`: Creates an API key.\n- `api_key_delete(key_id)`: Deletes a given API key.\n\n**Manage projects**:\n\n- `projects()`: Returns a list of projects.\n- `project(project_id)`: Returns a specific project.\n- `project_create(project_id, **json)`: Creates a new project. \n- `project_update(project_id, **json)`: Updates a given project.\n- `project_delete(project_id)`: Deletes a given project.\n- `project_permissions(project_id)`: Returns a list of permissions for a given project.\n- `project_permissions_grant(project_id, **json)`: Grant permissions to a given project.\n- `project_permissions_revoke(project_id, **json)`: Revoke permissions from a given project.\n- `connection_uri(project_id, database_name, role_name)`: Returns the connection string for a given project.\n\n**Manage branches**:\n\n- `branches(project_id)`: Returns a list of branches for a given project.\n- `branch(project_id, branch_id)`: Returns a specific branch.\n- `branch_create(project_id, **json)`: Creates a new branch.\n- `branch_update(project_id, branch_id, **json)`: Updates a given branch.\n- `branch_delete(project_id, branch_id)`: Deletes a given branch.\n- `branch_set_as_primary(project_id, branch_id)`: Sets a given branch as primary.\n\n**Manage databases**:\n\n- `databases(project_id, branch_id)`: Returns a list of databases for a given project and branch.\n- `database(project_id, branch_id, database_id)`: Returns a specific database.\n- `database_create(project_id, branch_id, **json)`: Creates a new database.\n- `database_update(project_id, branch_id, **json)`: Updates a given database.\n- `database_delete(project_id, branch_id, database_id)`: Deletes a given database.\n\n**Manage endpoints**:\n\n- `endpoints(project_id, branch_id)`: Returns a list of endpoints for a given project and branch.\n- `endpoint_create(project_id, branch_id, **json)`: Creates a new endpoint.\n- `endpoint_update(project_id, branch_id, endpoint_id, **json)`: Updates a given endpoint.\n- `endpoint_delete(project_id, branch_id, endpoint_id)`: Deletes a given endpoint.\n- `endpoint_start(project_id, branch_id, endpoint_id)`: Starts a given endpoint.\n- `endpoint_suspend(project_id, branch_id, endpoint_id)`: Suspends a given endpoint.\n\n**Manage roles**:\n\n- `roles(project_id, branch_id)`: Returns a list of roles for a given project and branch.\n- `role(project_id, branch_id, role_name)`: Returns a specific role.\n- `role_create(project_id, branch_id, role_name)`: Creates a new role.\n- `role_delete(project_id, branch_id, role_name)`: Deletes a given role.\n- `role_password_reveal(project_id, branch_id, role_name)`: Reveals the password for a given role.\n- `role_password_reset(project_id, branch_id, role_name)`: Resets the password for a given role.\n\n**Manage operations**:\n\n- `operations(project_id)`: Returns a list of operations for a given project.\n- `operation(project_id, operation_id)`: Returns a specific operation.\n\n**Experimental**:\n\n- `consumption()`: Returns a list of project consumption metrics.\n\n\nView the [Neon API documentation](https://api-docs.neon.tech/reference/getting-started-with-neon-api) for more information on the available endpoints and their parameters.\n\n\n## Development\n\nFirst, create a virtual environment, then install the dependencies of the library with `pip`:\n\n```bash\n$ pip install -r requirements.txt\n```\n\nThis will install all the necessary dependencies for development.\n\nTo run the tests, use the following command:\n\n```bash\n# set up a .env file with your API key as per `.env.example`\n$ make test\n```\n\nThe tests don't require an internet connection, as they are mocked using the `pytest-vcr` library. To record new cassettes, use the following command:\n\n```bash\n$ make record\n```\n\nThis will record new cassettes for the tests. Make sure to commit these cassettes along with your changes.\n\n## License & Copyright\n\n[Apache 2.0 Licensed](./LICENSE).\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "An API Client for the Neon API.",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/neondatabase/neon-api-python"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f366b2529c00a48d2633dae91b88e8b83f976b973fa1764a728e7c1b8638bc74",
                "md5": "58e39bedb86c8b1ecb20ba338a04636a",
                "sha256": "60164320387721d009f54e151e3a7c4bedb66b24acab8e6659c93f2976ac0007"
            },
            "downloads": -1,
            "filename": "neon_api-0.2.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "58e39bedb86c8b1ecb20ba338a04636a",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.9.0",
            "size": 15179,
            "upload_time": "2025-01-14T18:13:59",
            "upload_time_iso_8601": "2025-01-14T18:13:59.206618Z",
            "url": "https://files.pythonhosted.org/packages/f3/66/b2529c00a48d2633dae91b88e8b83f976b973fa1764a728e7c1b8638bc74/neon_api-0.2.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3df631e508a8c3e3e71ba766f815e66b9efd418f83681f04fcf32ccb649ecbd7",
                "md5": "49cc7b0eaa6774c30a7a47b204d9828e",
                "sha256": "645925f35a5298e321d6fe133b586ee23dcfaf0413e1dd3c88a580001a1e901f"
            },
            "downloads": -1,
            "filename": "neon_api-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "49cc7b0eaa6774c30a7a47b204d9828e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9.0",
            "size": 18340,
            "upload_time": "2025-01-14T18:14:01",
            "upload_time_iso_8601": "2025-01-14T18:14:01.531202Z",
            "url": "https://files.pythonhosted.org/packages/3d/f6/31e508a8c3e3e71ba766f815e66b9efd418f83681f04fcf32ccb649ecbd7/neon_api-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-14 18:14:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "neondatabase",
    "github_project": "neon-api-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "neon-api"
}
        
Elapsed time: 0.39188s