# example usage:
```python
import plesk
from plesk.definitions.Client import Client
from plesk.definitions.DomainResponse import DomainResponse
from plesk.definitions.DomainRequest import DomainRequest
from plesk.definitions.PlanReference import PlanReference
from plesk.utils import generate_password, generate_guid
panel = plesk.PleskPanel.get_singleton(username='<plesk admin/root username>', password='<plesk password>', fqdn='https://<plesk hostname or ip address>:8443', debug=True)
users: list[Client] = panel.user.fetch_all()
admin_user: Client = panel.user.fetch(customer_id=1)
admin_domains: list[DomainResponse] = admin_user.fetch_domains()
admin_first_domain: DomainResponse = admin_domains[0]
new_domain = DomainRequest(
_name='example.com',
_hosting_type='virtual',
_base_domain=None,
_parent_domain=None,
_owner_client=admin_user.to_owner_reference(),
_description='This is an example subscription made through the api',
_hosting_settings={
'ftp_login': 'example_ftp022',
'ftp_password': generate_password(),
},
_ip_addresses=['<ipv4 address to use>'],
_ipv4=['<ipv4 address to use>'],
_ipv6=[],
_plan=PlanReference(_name='Unlimited'),
)
admin_first_domain.add_domain(domain=new_domain)
new_domain_in_subscription = DomainRequest(
_name='example1.com',
_hosting_type='virtual',
_base_domain=admin_first_domain.to_domain_reference(),
_parent_domain=admin_first_domain.to_domain_reference(),
_owner_client=admin_user.to_owner_reference(),
_description='This is an example domain added to a subscription through the api',
_hosting_settings={
'ftp_login': 'example_ftp212',
'ftp_password': generate_password(),
},
_ip_addresses=['<ipv4 address to use>'],
_ipv4=['<ipv4 address to use>'],
_ipv6=[],
_plan=PlanReference(_name='Unlimited'),
)
admin_first_domain.add_domain(domain=new_domain_in_subscription)
# new_client = ClientRequest(
# _name='John Smith',
# _company='Plesk',
# _login='john-unit-test',
# _status=0,
# _email='john_smith@example.com',
# _locale='en-US',
# _owner_login=admin_user.login,
# _external_id=generate_guid(),
# _description='Nice guy',
# _password=generate_password(),
# _type='customer'
# )
# new_user = panel.user.create(client_request=new_client)
```
Raw data
{
"_id": null,
"home_page": "https://www.github.com/reashetyrr/plesk-api",
"name": "plesk-api",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "plesk",
"author": "Reashetyrr",
"author_email": "webmaster@reashetyr.software",
"download_url": "https://files.pythonhosted.org/packages/18/24/5dd09d78cb3d48569754f3d37941edc542ee1ef2e2bb00d96f23d6cb0c98/plesk_api-0.0.1.tar.gz",
"platform": null,
"description": "# example usage:\r\n```python\r\nimport plesk\r\nfrom plesk.definitions.Client import Client\r\nfrom plesk.definitions.DomainResponse import DomainResponse\r\nfrom plesk.definitions.DomainRequest import DomainRequest\r\nfrom plesk.definitions.PlanReference import PlanReference\r\nfrom plesk.utils import generate_password, generate_guid\r\n\r\npanel = plesk.PleskPanel.get_singleton(username='<plesk admin/root username>', password='<plesk password>', fqdn='https://<plesk hostname or ip address>:8443', debug=True)\r\nusers: list[Client] = panel.user.fetch_all()\r\nadmin_user: Client = panel.user.fetch(customer_id=1)\r\nadmin_domains: list[DomainResponse] = admin_user.fetch_domains()\r\nadmin_first_domain: DomainResponse = admin_domains[0]\r\nnew_domain = DomainRequest(\r\n _name='example.com',\r\n _hosting_type='virtual',\r\n _base_domain=None,\r\n _parent_domain=None,\r\n _owner_client=admin_user.to_owner_reference(),\r\n _description='This is an example subscription made through the api',\r\n _hosting_settings={\r\n 'ftp_login': 'example_ftp022',\r\n 'ftp_password': generate_password(),\r\n },\r\n _ip_addresses=['<ipv4 address to use>'],\r\n _ipv4=['<ipv4 address to use>'],\r\n _ipv6=[],\r\n _plan=PlanReference(_name='Unlimited'),\r\n)\r\nadmin_first_domain.add_domain(domain=new_domain)\r\n\r\nnew_domain_in_subscription = DomainRequest(\r\n _name='example1.com',\r\n _hosting_type='virtual',\r\n _base_domain=admin_first_domain.to_domain_reference(),\r\n _parent_domain=admin_first_domain.to_domain_reference(),\r\n _owner_client=admin_user.to_owner_reference(),\r\n _description='This is an example domain added to a subscription through the api',\r\n _hosting_settings={\r\n 'ftp_login': 'example_ftp212',\r\n 'ftp_password': generate_password(),\r\n },\r\n _ip_addresses=['<ipv4 address to use>'],\r\n _ipv4=['<ipv4 address to use>'],\r\n _ipv6=[],\r\n _plan=PlanReference(_name='Unlimited'),\r\n)\r\nadmin_first_domain.add_domain(domain=new_domain_in_subscription)\r\n# new_client = ClientRequest(\r\n# _name='John Smith',\r\n# _company='Plesk',\r\n# _login='john-unit-test',\r\n# _status=0,\r\n# _email='john_smith@example.com',\r\n# _locale='en-US',\r\n# _owner_login=admin_user.login,\r\n# _external_id=generate_guid(),\r\n# _description='Nice guy',\r\n# _password=generate_password(),\r\n# _type='customer'\r\n# )\r\n# new_user = panel.user.create(client_request=new_client)\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A simple API wrapper for Plesk",
"version": "0.0.1",
"project_urls": {
"Homepage": "https://www.github.com/reashetyrr/plesk-api"
},
"split_keywords": [
"plesk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a2dff2870c58a94b86522ba6fdb3bd3347add0cc9941656161da2fcdd5601bc0",
"md5": "2166c7f4f569a93bd73c674f02655105",
"sha256": "b41dbdc7955bcf7da834a12e1f92e00f871219d312e411642370183dd5c9f1df"
},
"downloads": -1,
"filename": "plesk_api-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2166c7f4f569a93bd73c674f02655105",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 19590,
"upload_time": "2024-07-29T14:26:15",
"upload_time_iso_8601": "2024-07-29T14:26:15.012805Z",
"url": "https://files.pythonhosted.org/packages/a2/df/f2870c58a94b86522ba6fdb3bd3347add0cc9941656161da2fcdd5601bc0/plesk_api-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "18245dd09d78cb3d48569754f3d37941edc542ee1ef2e2bb00d96f23d6cb0c98",
"md5": "1ab70e01b7f5bf3a6cf52f849891469e",
"sha256": "7502988b11ae9106a181c143ee6adaad657a1023c9c7d31e4f3c95a9650bd1ab"
},
"downloads": -1,
"filename": "plesk_api-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "1ab70e01b7f5bf3a6cf52f849891469e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10572,
"upload_time": "2024-07-29T14:26:16",
"upload_time_iso_8601": "2024-07-29T14:26:16.626680Z",
"url": "https://files.pythonhosted.org/packages/18/24/5dd09d78cb3d48569754f3d37941edc542ee1ef2e2bb00d96f23d6cb0c98/plesk_api-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-29 14:26:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "reashetyrr",
"github_project": "plesk-api",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "plesk-api"
}