# python3-cyberfusion-cluster-support
API library for Cluster API.
# Install
## PyPI
Run the following command to install the package from PyPI:
pip3 install python3-cyberfusion-cluster-support
## Generic
Run the following command to create a source distribution:
python3 setup.py sdist
## Debian
Run the following commands to build a Debian package:
mk-build-deps -i -t 'apt -o Debug::pkgProblemResolver=yes --no-install-recommends -y'
dpkg-buildpackage -us -uc
# Configure
## Config file options
* Section `clusterapi`, key `clusterid`. Only objects belonging to the specified cluster are loaded.
* Section `clusterapi`, key `serviceaccountid`. Only objects belonging to a cluster for which a service account to cluster exists for the specified service account are loaded.
## Class options
* `config_file_path`. Non-default config file path.
* `cluster_ids`. Only objects belonging to the specified clusters are loaded.
## Cluster IDs: order of precedence
The `cluster_ids` class option takes precedence over the `clusterid` config file option.
If neither is set, all objects are loaded.
If the `clusterid` config file option is set, but you want to load all objects, setting the `cluster_ids` class option to `None` (default) will not work. Instead, use the sentinel value `cyberfusion.ClusterSupport.ALL_CLUSTERS`.
# Usage
## Basic
```python
from cyberfusion.ClusterSupport import ClusterSupport
s = ClusterSupport()
```
## Read
### API objects without parameters
Some API objects do not require parameters to be retrieved.
These API objects are retrieved from the Cluster API once. They are then cached.
Examples:
```python
print(s.database_users)
print(s.unix_users)
print(s.fpm_pools)
```
### API objects with parameters
Some API objects require parameters to be retrieved.
These API objects are retrieved from the Cluster API on every call.
Example:
```python
print(s.access_logs(virtual_host_id=s.virtual_hosts[0].id, ...))
```
## Update
Example:
```python
d = s.database_users[0]
d.password = "newpassword"
d.update()
```
## Create
Example:
```python
from cyberfusion.ClusterSupport import ClusterSupport
from cyberfusion.ClusterSupport.certificates import Certificate
s = ClusterSupport()
c = Certificate(s)
assert c.id is None
c.create(common_names=["domlimev.nl", "www.domlimev.nl"])
assert c.id is not None
assert c.common_names == common_names=["domlimev.nl", "www.domlimev.nl"]
```
## Delete
Example:
```python
from cyberfusion.ClusterSupport import ClusterSupport
s = ClusterSupport()
c = s.certificates[0]
c.delete()
```
# Tests
Run tests with pytest:
pytest tests/
The config file in `cyberfusion.cfg` (working directory) is used.
Raw data
{
"_id": null,
"home_page": "https://vcs.cyberfusion.nl/core/python3-cyberfusion-cluster-support",
"name": "python3-cyberfusion-cluster-support",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "cyberfusion, cluster, api",
"author": "William Edwards",
"author_email": "wedwards@cyberfusion.nl",
"download_url": "https://files.pythonhosted.org/packages/8f/28/b7767e06dfe6a4c79f0e722617148b444e67f9a320b78ec7511a77129b03/python3-cyberfusion-cluster-support-1.49.4.2.1.tar.gz",
"platform": "linux",
"description": "# python3-cyberfusion-cluster-support\n\nAPI library for Cluster API.\n\n# Install\n\n## PyPI\n\nRun the following command to install the package from PyPI:\n\n pip3 install python3-cyberfusion-cluster-support\n\n## Generic\n\nRun the following command to create a source distribution:\n\n python3 setup.py sdist\n\n## Debian\n\nRun the following commands to build a Debian package:\n\n mk-build-deps -i -t 'apt -o Debug::pkgProblemResolver=yes --no-install-recommends -y'\n dpkg-buildpackage -us -uc\n\n# Configure\n\n## Config file options\n\n* Section `clusterapi`, key `clusterid`. Only objects belonging to the specified cluster are loaded.\n* Section `clusterapi`, key `serviceaccountid`. Only objects belonging to a cluster for which a service account to cluster exists for the specified service account are loaded.\n\n## Class options\n\n* `config_file_path`. Non-default config file path.\n* `cluster_ids`. Only objects belonging to the specified clusters are loaded.\n\n## Cluster IDs: order of precedence\n\nThe `cluster_ids` class option takes precedence over the `clusterid` config file option.\n\nIf neither is set, all objects are loaded.\n\nIf the `clusterid` config file option is set, but you want to load all objects, setting the `cluster_ids` class option to `None` (default) will not work. Instead, use the sentinel value `cyberfusion.ClusterSupport.ALL_CLUSTERS`.\n\n# Usage\n\n## Basic\n\n```python\nfrom cyberfusion.ClusterSupport import ClusterSupport\n\ns = ClusterSupport()\n```\n\n## Read\n\n### API objects without parameters\n\nSome API objects do not require parameters to be retrieved.\n\nThese API objects are retrieved from the Cluster API once. They are then cached.\n\nExamples:\n\n```python\nprint(s.database_users)\nprint(s.unix_users)\nprint(s.fpm_pools)\n```\n\n### API objects with parameters\n\nSome API objects require parameters to be retrieved.\n\nThese API objects are retrieved from the Cluster API on every call.\n\nExample:\n\n```python\nprint(s.access_logs(virtual_host_id=s.virtual_hosts[0].id, ...))\n```\n\n## Update\n\nExample:\n\n```python\nd = s.database_users[0]\nd.password = \"newpassword\"\nd.update()\n```\n\n## Create\n\nExample:\n\n```python\nfrom cyberfusion.ClusterSupport import ClusterSupport\nfrom cyberfusion.ClusterSupport.certificates import Certificate\n\ns = ClusterSupport()\n\nc = Certificate(s)\nassert c.id is None\n\nc.create(common_names=[\"domlimev.nl\", \"www.domlimev.nl\"])\nassert c.id is not None\nassert c.common_names == common_names=[\"domlimev.nl\", \"www.domlimev.nl\"]\n```\n\n## Delete\n\nExample:\n\n```python\nfrom cyberfusion.ClusterSupport import ClusterSupport\n\ns = ClusterSupport()\n\nc = s.certificates[0]\nc.delete()\n```\n\n# Tests\n\nRun tests with pytest:\n\n pytest tests/\n\nThe config file in `cyberfusion.cfg` (working directory) is used.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "API library for Cluster API.",
"version": "1.49.4.2.1",
"project_urls": {
"Homepage": "https://vcs.cyberfusion.nl/core/python3-cyberfusion-cluster-support"
},
"split_keywords": [
"cyberfusion",
" cluster",
" api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8f28b7767e06dfe6a4c79f0e722617148b444e67f9a320b78ec7511a77129b03",
"md5": "50305fd2b95d93df948db1edab1b326b",
"sha256": "52bff4cad581e91f3bc88160089be934644aacc692fac9ab2400e9dd2a06fe59"
},
"downloads": -1,
"filename": "python3-cyberfusion-cluster-support-1.49.4.2.1.tar.gz",
"has_sig": false,
"md5_digest": "50305fd2b95d93df948db1edab1b326b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 66186,
"upload_time": "2024-04-10T07:23:11",
"upload_time_iso_8601": "2024-04-10T07:23:11.749644Z",
"url": "https://files.pythonhosted.org/packages/8f/28/b7767e06dfe6a4c79f0e722617148b444e67f9a320b78ec7511a77129b03/python3-cyberfusion-cluster-support-1.49.4.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-10 07:23:11",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "python3-cyberfusion-cluster-support"
}