acerdp 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- acerdp-1.1.0/LICENSE +21 -0
- acerdp-1.1.0/PKG-INFO +98 -0
- acerdp-1.1.0/README.md +87 -0
- acerdp-1.1.0/acerdp/__init__.py +687 -0
- acerdp-1.1.0/acerdp.egg-info/PKG-INFO +98 -0
- acerdp-1.1.0/acerdp.egg-info/SOURCES.txt +8 -0
- acerdp-1.1.0/acerdp.egg-info/dependency_links.txt +1 -0
- acerdp-1.1.0/acerdp.egg-info/top_level.txt +1 -0
- acerdp-1.1.0/pyproject.toml +14 -0
- acerdp-1.1.0/setup.cfg +4 -0
acerdp-1.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AceRDP
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
acerdp-1.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: acerdp
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Client for the AceRDP API: Windows RDP and Linux VPS servers.
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Documentation, https://acerdp.io/api-docs
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# AceRDP API client (Python)
|
|
13
|
+
|
|
14
|
+
Order and manage AceRDP Windows RDP and Linux VPS servers from your own code. Every method is one operation of the [API reference](https://acerdp.io/api-docs); it returns the answer's `data` and throws `AceRdpError` (with `code`, `status` and the request id) when the API refuses.
|
|
15
|
+
|
|
16
|
+
Create the key in the panel under Settings > API. Pass `idempotency_key` with anything that charges your balance, so a retry never charges twice.
|
|
17
|
+
|
|
18
|
+
A read, or a change sent with `idempotency_key`, is tried again after `429` or a server error (twice by default, waiting what `Retry-After` says). `wait_until_ready(server_id)` waits until a new or reinstalled server is ready.
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
import os
|
|
22
|
+
from acerdp import AceRdp
|
|
23
|
+
|
|
24
|
+
api = AceRdp(os.environ["ACERDP_API_KEY"])
|
|
25
|
+
servers = api.list_servers()
|
|
26
|
+
api.send_a_power_action(server=servers[0]["id"], action="restart")
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Methods
|
|
30
|
+
|
|
31
|
+
- `add_an_ssh_key`: Add an SSH key
|
|
32
|
+
- `add_extra_ip_addresses`: Add extra IP addresses
|
|
33
|
+
- `add_heavy_use`: Add Heavy use
|
|
34
|
+
- `add_ram`: Add RAM
|
|
35
|
+
- `add_storage`: Add storage
|
|
36
|
+
- `configure_brute_force_protection`: Configure brute-force protection
|
|
37
|
+
- `create_a_server`: Create a server
|
|
38
|
+
- `create_a_webhook`: Create a webhook
|
|
39
|
+
- `delete_a_webhook`: Delete a webhook
|
|
40
|
+
- `delete_an_expired_server`: Delete an expired server
|
|
41
|
+
- `disable_ip_restrictions`: Disable IP restrictions
|
|
42
|
+
- `extend_a_server`: Extend a server
|
|
43
|
+
- `fix_everything`: Fix everything
|
|
44
|
+
- `get_a_plan`: Get a plan
|
|
45
|
+
- `get_a_server`: Get a server
|
|
46
|
+
- `get_a_servers_alerts`: Get a server's alerts
|
|
47
|
+
- `get_a_ticket`: Get a ticket
|
|
48
|
+
- `get_a_top_up`: Get a top-up
|
|
49
|
+
- `get_an_order`: Get an order
|
|
50
|
+
- `get_brute_force_protection`: Get brute-force protection
|
|
51
|
+
- `get_diagnostics_state`: Get diagnostics state
|
|
52
|
+
- `get_ip_restrictions`: Get IP restrictions
|
|
53
|
+
- `get_location_options`: Get location options
|
|
54
|
+
- `get_power_status`: Get power status
|
|
55
|
+
- `get_provisioning_status`: Get provisioning status
|
|
56
|
+
- `get_recovery_status`: Get recovery status
|
|
57
|
+
- `get_server_credentials`: Get server credentials
|
|
58
|
+
- `get_transaction_details`: Get transaction details
|
|
59
|
+
- `get_usage_history`: Get usage history
|
|
60
|
+
- `get_user_balance`: Get user balance
|
|
61
|
+
- `get_user_profile`: Get user profile
|
|
62
|
+
- `list_add_ons`: List add-ons
|
|
63
|
+
- `list_all_transactions`: List all transactions
|
|
64
|
+
- `list_deliveries`: List deliveries
|
|
65
|
+
- `list_events`: List events
|
|
66
|
+
- `list_extra_ip_addresses`: List extra IP addresses
|
|
67
|
+
- `list_invoices`: List invoices
|
|
68
|
+
- `list_locations`: List locations
|
|
69
|
+
- `list_notifications`: List notifications
|
|
70
|
+
- `list_operating_systems`: List operating systems
|
|
71
|
+
- `list_plans`: List plans
|
|
72
|
+
- `list_servers`: List servers
|
|
73
|
+
- `list_ssh_keys`: List SSH keys
|
|
74
|
+
- `list_tickets`: List tickets
|
|
75
|
+
- `list_upgrade_options`: List upgrade options
|
|
76
|
+
- `list_webhooks`: List webhooks
|
|
77
|
+
- `mark_notifications_as_read`: Mark notifications as read
|
|
78
|
+
- `move_a_server`: Move a server
|
|
79
|
+
- `quote_a_new_server`: Quote a new server
|
|
80
|
+
- `quote_a_renewal`: Quote a renewal
|
|
81
|
+
- `reinstall_a_server`: Reinstall a server
|
|
82
|
+
- `remove_an_extra_ip_address`: Remove an extra IP address
|
|
83
|
+
- `remove_an_ssh_key`: Remove an SSH key
|
|
84
|
+
- `remove_heavy_use`: Remove Heavy use
|
|
85
|
+
- `renew_servers`: Renew servers
|
|
86
|
+
- `replace_ip_restrictions`: Replace IP restrictions
|
|
87
|
+
- `resend_a_delivery`: Resend a delivery
|
|
88
|
+
- `reset_the_password`: Reset the password
|
|
89
|
+
- `run_a_repair`: Run a repair
|
|
90
|
+
- `run_diagnostics`: Run diagnostics
|
|
91
|
+
- `send_a_power_action`: Send a power action
|
|
92
|
+
- `send_a_test_event`: Send a test event
|
|
93
|
+
- `servers_due_for_renewal`: Servers due for renewal
|
|
94
|
+
- `start_the_recovery_hour`: Start the recovery hour
|
|
95
|
+
- `top_up_your_balance`: Top up your balance
|
|
96
|
+
- `unblock_an_address`: Unblock an address
|
|
97
|
+
- `update_a_server`: Update a server
|
|
98
|
+
- `upgrade_a_server`: Upgrade a server
|
acerdp-1.1.0/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# AceRDP API client (Python)
|
|
2
|
+
|
|
3
|
+
Order and manage AceRDP Windows RDP and Linux VPS servers from your own code. Every method is one operation of the [API reference](https://acerdp.io/api-docs); it returns the answer's `data` and throws `AceRdpError` (with `code`, `status` and the request id) when the API refuses.
|
|
4
|
+
|
|
5
|
+
Create the key in the panel under Settings > API. Pass `idempotency_key` with anything that charges your balance, so a retry never charges twice.
|
|
6
|
+
|
|
7
|
+
A read, or a change sent with `idempotency_key`, is tried again after `429` or a server error (twice by default, waiting what `Retry-After` says). `wait_until_ready(server_id)` waits until a new or reinstalled server is ready.
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
import os
|
|
11
|
+
from acerdp import AceRdp
|
|
12
|
+
|
|
13
|
+
api = AceRdp(os.environ["ACERDP_API_KEY"])
|
|
14
|
+
servers = api.list_servers()
|
|
15
|
+
api.send_a_power_action(server=servers[0]["id"], action="restart")
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Methods
|
|
19
|
+
|
|
20
|
+
- `add_an_ssh_key`: Add an SSH key
|
|
21
|
+
- `add_extra_ip_addresses`: Add extra IP addresses
|
|
22
|
+
- `add_heavy_use`: Add Heavy use
|
|
23
|
+
- `add_ram`: Add RAM
|
|
24
|
+
- `add_storage`: Add storage
|
|
25
|
+
- `configure_brute_force_protection`: Configure brute-force protection
|
|
26
|
+
- `create_a_server`: Create a server
|
|
27
|
+
- `create_a_webhook`: Create a webhook
|
|
28
|
+
- `delete_a_webhook`: Delete a webhook
|
|
29
|
+
- `delete_an_expired_server`: Delete an expired server
|
|
30
|
+
- `disable_ip_restrictions`: Disable IP restrictions
|
|
31
|
+
- `extend_a_server`: Extend a server
|
|
32
|
+
- `fix_everything`: Fix everything
|
|
33
|
+
- `get_a_plan`: Get a plan
|
|
34
|
+
- `get_a_server`: Get a server
|
|
35
|
+
- `get_a_servers_alerts`: Get a server's alerts
|
|
36
|
+
- `get_a_ticket`: Get a ticket
|
|
37
|
+
- `get_a_top_up`: Get a top-up
|
|
38
|
+
- `get_an_order`: Get an order
|
|
39
|
+
- `get_brute_force_protection`: Get brute-force protection
|
|
40
|
+
- `get_diagnostics_state`: Get diagnostics state
|
|
41
|
+
- `get_ip_restrictions`: Get IP restrictions
|
|
42
|
+
- `get_location_options`: Get location options
|
|
43
|
+
- `get_power_status`: Get power status
|
|
44
|
+
- `get_provisioning_status`: Get provisioning status
|
|
45
|
+
- `get_recovery_status`: Get recovery status
|
|
46
|
+
- `get_server_credentials`: Get server credentials
|
|
47
|
+
- `get_transaction_details`: Get transaction details
|
|
48
|
+
- `get_usage_history`: Get usage history
|
|
49
|
+
- `get_user_balance`: Get user balance
|
|
50
|
+
- `get_user_profile`: Get user profile
|
|
51
|
+
- `list_add_ons`: List add-ons
|
|
52
|
+
- `list_all_transactions`: List all transactions
|
|
53
|
+
- `list_deliveries`: List deliveries
|
|
54
|
+
- `list_events`: List events
|
|
55
|
+
- `list_extra_ip_addresses`: List extra IP addresses
|
|
56
|
+
- `list_invoices`: List invoices
|
|
57
|
+
- `list_locations`: List locations
|
|
58
|
+
- `list_notifications`: List notifications
|
|
59
|
+
- `list_operating_systems`: List operating systems
|
|
60
|
+
- `list_plans`: List plans
|
|
61
|
+
- `list_servers`: List servers
|
|
62
|
+
- `list_ssh_keys`: List SSH keys
|
|
63
|
+
- `list_tickets`: List tickets
|
|
64
|
+
- `list_upgrade_options`: List upgrade options
|
|
65
|
+
- `list_webhooks`: List webhooks
|
|
66
|
+
- `mark_notifications_as_read`: Mark notifications as read
|
|
67
|
+
- `move_a_server`: Move a server
|
|
68
|
+
- `quote_a_new_server`: Quote a new server
|
|
69
|
+
- `quote_a_renewal`: Quote a renewal
|
|
70
|
+
- `reinstall_a_server`: Reinstall a server
|
|
71
|
+
- `remove_an_extra_ip_address`: Remove an extra IP address
|
|
72
|
+
- `remove_an_ssh_key`: Remove an SSH key
|
|
73
|
+
- `remove_heavy_use`: Remove Heavy use
|
|
74
|
+
- `renew_servers`: Renew servers
|
|
75
|
+
- `replace_ip_restrictions`: Replace IP restrictions
|
|
76
|
+
- `resend_a_delivery`: Resend a delivery
|
|
77
|
+
- `reset_the_password`: Reset the password
|
|
78
|
+
- `run_a_repair`: Run a repair
|
|
79
|
+
- `run_diagnostics`: Run diagnostics
|
|
80
|
+
- `send_a_power_action`: Send a power action
|
|
81
|
+
- `send_a_test_event`: Send a test event
|
|
82
|
+
- `servers_due_for_renewal`: Servers due for renewal
|
|
83
|
+
- `start_the_recovery_hour`: Start the recovery hour
|
|
84
|
+
- `top_up_your_balance`: Top up your balance
|
|
85
|
+
- `unblock_an_address`: Unblock an address
|
|
86
|
+
- `update_a_server`: Update a server
|
|
87
|
+
- `upgrade_a_server`: Upgrade a server
|
|
@@ -0,0 +1,687 @@
|
|
|
1
|
+
"""Client for the AceRDP API. Generated by `php artisan api:docs`; do not edit by hand."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import re
|
|
5
|
+
import time
|
|
6
|
+
import urllib.error
|
|
7
|
+
import urllib.parse
|
|
8
|
+
import urllib.request
|
|
9
|
+
|
|
10
|
+
__all__ = ["AceRdp", "AceRdpError", "ERRORS", "Unauthenticated", "ApiAccessDisabled", "ReadOnlyKey", "AgentSpendingLimit", "ServerLimitReached", "ResourceNotFound", "OrderNotFound", "ValidationError", "InsufficientBalance", "AmountTooHigh", "PackageUnavailable", "PackageSoldOut", "LocationSoldOut", "OsUnavailable", "EmailUnconfirmed", "ConfirmationRequired", "ConfirmationMismatch", "UpgradeNotAllowed", "ServerMisconfigured", "AddonRefused", "ExtraIpsRefused", "NoCapacity", "NoAddresses", "ServerNotExtendable", "ExtendBlocked", "AlreadyExtended", "LocationChangeRefused", "RecoveryRefused", "SshKeyRefused", "WebhookRefused", "ActionRefused", "FirewallChangeRefused", "ProtectionChangeRefused", "RepairRefused", "DiagnosticsRefused", "PurchaseFailed", "InvalidIdempotencyKey", "IdempotencyKeyReused", "ServerNotActive", "ServerNotExpired", "ServerNotReady", "ServerBusy", "ServerStopped", "OperationInProgress", "PowerActionInProgress", "IdempotencyInProgress", "Conflict", "DeleteFailed", "UpgradeFailed", "NothingToAlign", "QuoteChanged", "AbuseCaseOpen", "PaymentWaiting", "TransferWaiting", "TransferClosed", "PreconditionFailed", "RateLimited", "TooManyRequests", "TooManyOffers", "ProviderError", "PaymentCreateFailed", "NoAnswer", "StillReading"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class AceRdpError(Exception):
|
|
14
|
+
def __init__(self, message, code=None, status=None, request_id=None, details=None, docs_url=None):
|
|
15
|
+
super().__init__(message)
|
|
16
|
+
self.code = code
|
|
17
|
+
self.status = status
|
|
18
|
+
self.request_id = request_id
|
|
19
|
+
self.details = details
|
|
20
|
+
self.docs_url = docs_url
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Unauthenticated(AceRdpError):
|
|
24
|
+
"""No API key, or one that does not work. Send `Authorization: Bearer <key>`."""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ApiAccessDisabled(AceRdpError):
|
|
28
|
+
"""API access is switched off for this account. Contact support."""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ReadOnlyKey(AceRdpError):
|
|
32
|
+
"""A read-only key asked for a change or a password. Use the full key."""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class AgentSpendingLimit(AceRdpError):
|
|
36
|
+
"""This AI connection spent its daily limit. Ask the account owner, or try again tomorrow."""
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ServerLimitReached(AceRdpError):
|
|
40
|
+
"""The account has as many servers as one account may hold. Ask support for more."""
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ResourceNotFound(AceRdpError):
|
|
44
|
+
"""Nothing of yours has that id, or the address does not exist."""
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class OrderNotFound(AceRdpError):
|
|
48
|
+
"""No order of yours has that id."""
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class ValidationError(AceRdpError):
|
|
52
|
+
"""A field is missing or wrong; `error.details.fields` names each."""
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class InsufficientBalance(AceRdpError):
|
|
56
|
+
"""The balance does not cover it. Top up, or send `pay_with` when ordering."""
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class AmountTooHigh(AceRdpError):
|
|
60
|
+
"""One payment can be at most the amount in the message. Top up in parts."""
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class PackageUnavailable(AceRdpError):
|
|
64
|
+
"""That plan is not sold. List the plans again."""
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class PackageSoldOut(AceRdpError):
|
|
68
|
+
"""That plan is sold out where you asked. Try another location or plan."""
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class LocationSoldOut(AceRdpError):
|
|
72
|
+
"""That location has no free address right now. Choose another location."""
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class OsUnavailable(AceRdpError):
|
|
76
|
+
"""That operating system is not offered. List the systems again."""
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class EmailUnconfirmed(AceRdpError):
|
|
80
|
+
"""Confirm the account's email address before the first order."""
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class ConfirmationRequired(AceRdpError):
|
|
84
|
+
"""A forced action needs `confirm_force: true`."""
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class ConfirmationMismatch(AceRdpError):
|
|
88
|
+
"""`confirm_hostname` does not match the server. Nothing was changed."""
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class UpgradeNotAllowed(AceRdpError):
|
|
92
|
+
"""That plan is not an upgrade of this server (it must have at least as much of everything)."""
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class ServerMisconfigured(AceRdpError):
|
|
96
|
+
"""The server lacks what this needs. Contact support."""
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class AddonRefused(AceRdpError):
|
|
100
|
+
"""The add-on cannot be added now; the message says why."""
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class ExtraIpsRefused(AceRdpError):
|
|
104
|
+
"""Extra addresses cannot be added now; the message says why."""
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class NoCapacity(AceRdpError):
|
|
108
|
+
"""There is no room for that much storage right now."""
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class NoAddresses(AceRdpError):
|
|
112
|
+
"""Not enough free addresses at the server's location. Try fewer."""
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class ServerNotExtendable(AceRdpError):
|
|
116
|
+
"""The server is not active, so it cannot be extended."""
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class ExtendBlocked(AceRdpError):
|
|
120
|
+
"""The server cannot be extended now; the message says why."""
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class AlreadyExtended(AceRdpError):
|
|
124
|
+
"""The server is already paid that far ahead."""
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class LocationChangeRefused(AceRdpError):
|
|
128
|
+
"""The server cannot move now; the message says why."""
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class RecoveryRefused(AceRdpError):
|
|
132
|
+
"""The recovery hour cannot start now; the message says why."""
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class SshKeyRefused(AceRdpError):
|
|
136
|
+
"""The key is not one line of a `.pub` file, or the account has 10 keys."""
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class WebhookRefused(AceRdpError):
|
|
140
|
+
"""The webhook address is not allowed: https, port 443 or 8443, a public host."""
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class ActionRefused(AceRdpError):
|
|
144
|
+
"""The action cannot run now; the message says why."""
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class FirewallChangeRefused(AceRdpError):
|
|
148
|
+
"""The firewall cannot be changed now; the message says why."""
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class ProtectionChangeRefused(AceRdpError):
|
|
152
|
+
"""Brute-force protection cannot be changed now; the message says why."""
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class RepairRefused(AceRdpError):
|
|
156
|
+
"""That repair was not named by a recent diagnostics run. Run diagnostics first."""
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class DiagnosticsRefused(AceRdpError):
|
|
160
|
+
"""Diagnostics cannot run now; the message says why."""
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class PurchaseFailed(AceRdpError):
|
|
164
|
+
"""The order could not be completed. Try again."""
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
class InvalidIdempotencyKey(AceRdpError):
|
|
168
|
+
"""The Idempotency-Key header must be 8 to 64 letters, digits, - or _."""
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class IdempotencyKeyReused(AceRdpError):
|
|
172
|
+
"""That Idempotency-Key was used with a different body. Use a new key."""
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
class ServerNotActive(AceRdpError):
|
|
176
|
+
"""The server is not active (expired, suspended or not set up yet)."""
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class ServerNotExpired(AceRdpError):
|
|
180
|
+
"""Only an expired server can be deleted."""
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class ServerNotReady(AceRdpError):
|
|
184
|
+
"""The server is not active, or busy. Try again once it is done."""
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
class ServerBusy(AceRdpError):
|
|
188
|
+
"""Something else is under way on the server. Try again when it is done."""
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
class ServerStopped(AceRdpError):
|
|
192
|
+
"""Start the server first."""
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class OperationInProgress(AceRdpError):
|
|
196
|
+
"""The server is being set up, reinstalled, moved or upgraded. Wait for it."""
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
class PowerActionInProgress(AceRdpError):
|
|
200
|
+
"""A power action is still running. Poll the power status."""
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class IdempotencyInProgress(AceRdpError):
|
|
204
|
+
"""A request with this Idempotency-Key is still running. Retry with the same key in a moment."""
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
class Conflict(AceRdpError):
|
|
208
|
+
"""Another change to the server is being saved. Try again in a moment."""
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
class DeleteFailed(AceRdpError):
|
|
212
|
+
"""The server could not be deleted now; the message says why."""
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
class UpgradeFailed(AceRdpError):
|
|
216
|
+
"""The upgrade could not be applied; the message says why."""
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
class NothingToAlign(AceRdpError):
|
|
220
|
+
"""Your servers already renew on the same day."""
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class QuoteChanged(AceRdpError):
|
|
224
|
+
"""The price changed since you asked. Quote again."""
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
class AbuseCaseOpen(AceRdpError):
|
|
228
|
+
"""A report about the server is open, so it cannot be handed over."""
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
class PaymentWaiting(AceRdpError):
|
|
232
|
+
"""A payment for the server is still being completed."""
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
class TransferWaiting(AceRdpError):
|
|
236
|
+
"""The server is already offered to someone. Cancel that offer first."""
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
class TransferClosed(AceRdpError):
|
|
240
|
+
"""That offer is no longer open."""
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
class PreconditionFailed(AceRdpError):
|
|
244
|
+
"""The server changed since you read it (`If-Match`). Read it again."""
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
class RateLimited(AceRdpError):
|
|
248
|
+
"""Over the limit: wait `Retry-After` seconds and send it again."""
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
class TooManyRequests(AceRdpError):
|
|
252
|
+
"""This action was tried too often. Wait a few minutes."""
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
class TooManyOffers(AceRdpError):
|
|
256
|
+
"""A server can be offered a few times a day. Try again tomorrow."""
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
class ProviderError(AceRdpError):
|
|
260
|
+
"""We could not carry it out on the server right now. Try again in a minute."""
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
class PaymentCreateFailed(AceRdpError):
|
|
264
|
+
"""The payment could not be started. Try again."""
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
class NoAnswer(AceRdpError):
|
|
268
|
+
"""The server did not answer from inside. If it just started, try again in a few minutes."""
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
class StillReading(AceRdpError):
|
|
272
|
+
"""The last reading may still run inside the server. Try again in ten minutes."""
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
# Each documented error code as its own class; any other code is an AceRdpError.
|
|
276
|
+
ERRORS = {
|
|
277
|
+
"UNAUTHENTICATED": Unauthenticated,
|
|
278
|
+
"API_ACCESS_DISABLED": ApiAccessDisabled,
|
|
279
|
+
"READ_ONLY_KEY": ReadOnlyKey,
|
|
280
|
+
"AGENT_SPENDING_LIMIT": AgentSpendingLimit,
|
|
281
|
+
"SERVER_LIMIT_REACHED": ServerLimitReached,
|
|
282
|
+
"RESOURCE_NOT_FOUND": ResourceNotFound,
|
|
283
|
+
"ORDER_NOT_FOUND": OrderNotFound,
|
|
284
|
+
"VALIDATION_ERROR": ValidationError,
|
|
285
|
+
"INSUFFICIENT_BALANCE": InsufficientBalance,
|
|
286
|
+
"AMOUNT_TOO_HIGH": AmountTooHigh,
|
|
287
|
+
"PACKAGE_UNAVAILABLE": PackageUnavailable,
|
|
288
|
+
"PACKAGE_SOLD_OUT": PackageSoldOut,
|
|
289
|
+
"LOCATION_SOLD_OUT": LocationSoldOut,
|
|
290
|
+
"OS_UNAVAILABLE": OsUnavailable,
|
|
291
|
+
"EMAIL_UNCONFIRMED": EmailUnconfirmed,
|
|
292
|
+
"CONFIRMATION_REQUIRED": ConfirmationRequired,
|
|
293
|
+
"CONFIRMATION_MISMATCH": ConfirmationMismatch,
|
|
294
|
+
"UPGRADE_NOT_ALLOWED": UpgradeNotAllowed,
|
|
295
|
+
"SERVER_MISCONFIGURED": ServerMisconfigured,
|
|
296
|
+
"ADDON_REFUSED": AddonRefused,
|
|
297
|
+
"EXTRA_IPS_REFUSED": ExtraIpsRefused,
|
|
298
|
+
"NO_CAPACITY": NoCapacity,
|
|
299
|
+
"NO_ADDRESSES": NoAddresses,
|
|
300
|
+
"SERVER_NOT_EXTENDABLE": ServerNotExtendable,
|
|
301
|
+
"EXTEND_BLOCKED": ExtendBlocked,
|
|
302
|
+
"ALREADY_EXTENDED": AlreadyExtended,
|
|
303
|
+
"LOCATION_CHANGE_REFUSED": LocationChangeRefused,
|
|
304
|
+
"RECOVERY_REFUSED": RecoveryRefused,
|
|
305
|
+
"SSH_KEY_REFUSED": SshKeyRefused,
|
|
306
|
+
"WEBHOOK_REFUSED": WebhookRefused,
|
|
307
|
+
"ACTION_REFUSED": ActionRefused,
|
|
308
|
+
"FIREWALL_CHANGE_REFUSED": FirewallChangeRefused,
|
|
309
|
+
"PROTECTION_CHANGE_REFUSED": ProtectionChangeRefused,
|
|
310
|
+
"REPAIR_REFUSED": RepairRefused,
|
|
311
|
+
"DIAGNOSTICS_REFUSED": DiagnosticsRefused,
|
|
312
|
+
"PURCHASE_FAILED": PurchaseFailed,
|
|
313
|
+
"INVALID_IDEMPOTENCY_KEY": InvalidIdempotencyKey,
|
|
314
|
+
"IDEMPOTENCY_KEY_REUSED": IdempotencyKeyReused,
|
|
315
|
+
"SERVER_NOT_ACTIVE": ServerNotActive,
|
|
316
|
+
"SERVER_NOT_EXPIRED": ServerNotExpired,
|
|
317
|
+
"SERVER_NOT_READY": ServerNotReady,
|
|
318
|
+
"SERVER_BUSY": ServerBusy,
|
|
319
|
+
"SERVER_STOPPED": ServerStopped,
|
|
320
|
+
"OPERATION_IN_PROGRESS": OperationInProgress,
|
|
321
|
+
"POWER_ACTION_IN_PROGRESS": PowerActionInProgress,
|
|
322
|
+
"IDEMPOTENCY_IN_PROGRESS": IdempotencyInProgress,
|
|
323
|
+
"CONFLICT": Conflict,
|
|
324
|
+
"DELETE_FAILED": DeleteFailed,
|
|
325
|
+
"UPGRADE_FAILED": UpgradeFailed,
|
|
326
|
+
"NOTHING_TO_ALIGN": NothingToAlign,
|
|
327
|
+
"QUOTE_CHANGED": QuoteChanged,
|
|
328
|
+
"ABUSE_CASE_OPEN": AbuseCaseOpen,
|
|
329
|
+
"PAYMENT_WAITING": PaymentWaiting,
|
|
330
|
+
"TRANSFER_WAITING": TransferWaiting,
|
|
331
|
+
"TRANSFER_CLOSED": TransferClosed,
|
|
332
|
+
"PRECONDITION_FAILED": PreconditionFailed,
|
|
333
|
+
"RATE_LIMITED": RateLimited,
|
|
334
|
+
"TOO_MANY_REQUESTS": TooManyRequests,
|
|
335
|
+
"TOO_MANY_OFFERS": TooManyOffers,
|
|
336
|
+
"PROVIDER_ERROR": ProviderError,
|
|
337
|
+
"PAYMENT_CREATE_FAILED": PaymentCreateFailed,
|
|
338
|
+
"NO_ANSWER": NoAnswer,
|
|
339
|
+
"STILL_READING": StillReading,
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
class AceRdp:
|
|
344
|
+
def __init__(self, api_key, base_url="https://acerdp.io", timeout=60, opener=None, retries=2, sleep=None):
|
|
345
|
+
if not api_key:
|
|
346
|
+
raise ValueError("AceRdp needs an api_key (panel: Settings > API).")
|
|
347
|
+
self.api_key = api_key
|
|
348
|
+
self.base_url = base_url.rstrip("/")
|
|
349
|
+
self.timeout = timeout
|
|
350
|
+
self.opener = opener or urllib.request.urlopen
|
|
351
|
+
self.retries = retries
|
|
352
|
+
self.sleep = sleep or time.sleep
|
|
353
|
+
|
|
354
|
+
def wait_until_ready(self, server, interval_seconds=10, timeout_seconds=1800):
|
|
355
|
+
"""Waits until a new or reinstalled server is ready and returns its build status; raises if the build failed."""
|
|
356
|
+
until = time.time() + timeout_seconds
|
|
357
|
+
while True:
|
|
358
|
+
status = self.get_provisioning_status(server=server)
|
|
359
|
+
if status.get("status") == "completed":
|
|
360
|
+
return status
|
|
361
|
+
if status.get("status") == "failed":
|
|
362
|
+
raise AceRdpError("The build failed; the price was refunded.", "BUILD_FAILED")
|
|
363
|
+
if time.time() >= until:
|
|
364
|
+
raise AceRdpError("The server was not ready in time.", "WAIT_TIMED_OUT")
|
|
365
|
+
self.sleep(interval_seconds)
|
|
366
|
+
|
|
367
|
+
def request(self, method, path, params=None):
|
|
368
|
+
rest = dict(params or {})
|
|
369
|
+
|
|
370
|
+
def fill(match):
|
|
371
|
+
name = match.group(1)
|
|
372
|
+
if name not in rest:
|
|
373
|
+
raise ValueError("Missing " + name)
|
|
374
|
+
return urllib.parse.quote(str(rest.pop(name)), safe="")
|
|
375
|
+
|
|
376
|
+
url = self.base_url + re.sub(r"\{(\w+)\}", fill, path)
|
|
377
|
+
headers = {"Authorization": "Bearer " + self.api_key, "Accept": "application/json", "User-Agent": "acerdp-python"}
|
|
378
|
+
if rest.get("idempotency_key"):
|
|
379
|
+
headers["Idempotency-Key"] = str(rest.pop("idempotency_key"))
|
|
380
|
+
data = None
|
|
381
|
+
if method == "GET":
|
|
382
|
+
query = {k: v for k, v in rest.items() if v is not None}
|
|
383
|
+
if query:
|
|
384
|
+
url += "?" + urllib.parse.urlencode(query, doseq=True)
|
|
385
|
+
else:
|
|
386
|
+
headers["Content-Type"] = "application/json"
|
|
387
|
+
data = json.dumps(rest).encode("utf-8")
|
|
388
|
+
# A read, or a change with an Idempotency-Key, is sent again after 429 or a server error: it cannot charge twice.
|
|
389
|
+
safe = method == "GET" or "Idempotency-Key" in headers
|
|
390
|
+
attempt = 0
|
|
391
|
+
while True:
|
|
392
|
+
request = urllib.request.Request(url, data=data, headers=headers, method=method)
|
|
393
|
+
retry_after = None
|
|
394
|
+
try:
|
|
395
|
+
with self.opener(request, timeout=self.timeout) as response:
|
|
396
|
+
status, raw = response.status, response.read()
|
|
397
|
+
except urllib.error.HTTPError as error:
|
|
398
|
+
status, raw = error.code, error.read()
|
|
399
|
+
retry_after = error.headers.get("Retry-After") if error.headers else None
|
|
400
|
+
if not safe or attempt >= self.retries or (status != 429 and status < 500):
|
|
401
|
+
break
|
|
402
|
+
try:
|
|
403
|
+
wait = float(retry_after) if retry_after else 2 ** attempt
|
|
404
|
+
except ValueError:
|
|
405
|
+
wait = 2 ** attempt
|
|
406
|
+
self.sleep(min(max(wait, 0), 60))
|
|
407
|
+
attempt += 1
|
|
408
|
+
try:
|
|
409
|
+
body = json.loads(raw.decode("utf-8") or "{}")
|
|
410
|
+
except ValueError:
|
|
411
|
+
body = {}
|
|
412
|
+
if status >= 400 or body.get("success") is False:
|
|
413
|
+
error = body.get("error") or {}
|
|
414
|
+
raise ERRORS.get(error.get("code"), AceRdpError)(error.get("message") or "HTTP %d" % status, error.get("code"), status, (body.get("meta") or {}).get("request_id"), error.get("details"), error.get("docs_url"))
|
|
415
|
+
return body.get("data")
|
|
416
|
+
|
|
417
|
+
def add_an_ssh_key(self, **params):
|
|
418
|
+
"""Add an SSH key"""
|
|
419
|
+
return self.request("POST", "/api/v1/ssh-keys", params)
|
|
420
|
+
|
|
421
|
+
def add_extra_ip_addresses(self, **params):
|
|
422
|
+
"""Add extra IP addresses"""
|
|
423
|
+
return self.request("POST", "/api/v1/servers/{server}/extra-ips", params)
|
|
424
|
+
|
|
425
|
+
def add_heavy_use(self, **params):
|
|
426
|
+
"""Add Heavy use"""
|
|
427
|
+
return self.request("POST", "/api/v1/servers/{server}/addons/heavy-use", params)
|
|
428
|
+
|
|
429
|
+
def add_ram(self, **params):
|
|
430
|
+
"""Add RAM"""
|
|
431
|
+
return self.request("POST", "/api/v1/servers/{server}/addons/ram", params)
|
|
432
|
+
|
|
433
|
+
def add_storage(self, **params):
|
|
434
|
+
"""Add storage"""
|
|
435
|
+
return self.request("POST", "/api/v1/servers/{server}/addons/storage", params)
|
|
436
|
+
|
|
437
|
+
def configure_brute_force_protection(self, **params):
|
|
438
|
+
"""Configure brute-force protection"""
|
|
439
|
+
return self.request("PUT", "/api/v1/servers/{server}/protection", params)
|
|
440
|
+
|
|
441
|
+
def create_a_server(self, **params):
|
|
442
|
+
"""Create a server"""
|
|
443
|
+
return self.request("POST", "/api/v1/servers", params)
|
|
444
|
+
|
|
445
|
+
def create_a_webhook(self, **params):
|
|
446
|
+
"""Create a webhook"""
|
|
447
|
+
return self.request("POST", "/api/v1/webhooks", params)
|
|
448
|
+
|
|
449
|
+
def delete_a_webhook(self, **params):
|
|
450
|
+
"""Delete a webhook"""
|
|
451
|
+
return self.request("DELETE", "/api/v1/webhooks/{webhook}", params)
|
|
452
|
+
|
|
453
|
+
def delete_an_expired_server(self, **params):
|
|
454
|
+
"""Delete an expired server"""
|
|
455
|
+
return self.request("DELETE", "/api/v1/servers/{server}", params)
|
|
456
|
+
|
|
457
|
+
def disable_ip_restrictions(self, **params):
|
|
458
|
+
"""Disable IP restrictions"""
|
|
459
|
+
return self.request("POST", "/api/v1/servers/{server}/firewall/disable", params)
|
|
460
|
+
|
|
461
|
+
def extend_a_server(self, **params):
|
|
462
|
+
"""Extend a server"""
|
|
463
|
+
return self.request("POST", "/api/v1/servers/{server}/extend", params)
|
|
464
|
+
|
|
465
|
+
def fix_everything(self, **params):
|
|
466
|
+
"""Fix everything"""
|
|
467
|
+
return self.request("POST", "/api/v1/servers/{server}/repairs/auto", params)
|
|
468
|
+
|
|
469
|
+
def get_a_plan(self, **params):
|
|
470
|
+
"""Get a plan"""
|
|
471
|
+
return self.request("GET", "/api/v1/packages/{package}", params)
|
|
472
|
+
|
|
473
|
+
def get_a_server(self, **params):
|
|
474
|
+
"""Get a server"""
|
|
475
|
+
return self.request("GET", "/api/v1/servers/{server}", params)
|
|
476
|
+
|
|
477
|
+
def get_a_servers_alerts(self, **params):
|
|
478
|
+
"""Get a server's alerts"""
|
|
479
|
+
return self.request("GET", "/api/v1/servers/{server}/alerts", params)
|
|
480
|
+
|
|
481
|
+
def get_a_ticket(self, **params):
|
|
482
|
+
"""Get a ticket"""
|
|
483
|
+
return self.request("GET", "/api/v1/tickets/{ticket}", params)
|
|
484
|
+
|
|
485
|
+
def get_a_top_up(self, **params):
|
|
486
|
+
"""Get a top-up"""
|
|
487
|
+
return self.request("GET", "/api/v1/topups/{topup}", params)
|
|
488
|
+
|
|
489
|
+
def get_an_order(self, **params):
|
|
490
|
+
"""Get an order"""
|
|
491
|
+
return self.request("GET", "/api/v1/orders/{intent}", params)
|
|
492
|
+
|
|
493
|
+
def get_brute_force_protection(self, **params):
|
|
494
|
+
"""Get brute-force protection"""
|
|
495
|
+
return self.request("GET", "/api/v1/servers/{server}/protection", params)
|
|
496
|
+
|
|
497
|
+
def get_diagnostics_state(self, **params):
|
|
498
|
+
"""Get diagnostics state"""
|
|
499
|
+
return self.request("GET", "/api/v1/servers/{server}/diagnostics", params)
|
|
500
|
+
|
|
501
|
+
def get_ip_restrictions(self, **params):
|
|
502
|
+
"""Get IP restrictions"""
|
|
503
|
+
return self.request("GET", "/api/v1/servers/{server}/firewall", params)
|
|
504
|
+
|
|
505
|
+
def get_location_options(self, **params):
|
|
506
|
+
"""Get location options"""
|
|
507
|
+
return self.request("GET", "/api/v1/servers/{server}/location", params)
|
|
508
|
+
|
|
509
|
+
def get_power_status(self, **params):
|
|
510
|
+
"""Get power status"""
|
|
511
|
+
return self.request("GET", "/api/v1/servers/{server}/power", params)
|
|
512
|
+
|
|
513
|
+
def get_provisioning_status(self, **params):
|
|
514
|
+
"""Get provisioning status"""
|
|
515
|
+
return self.request("GET", "/api/v1/servers/{server}/provisioning-status", params)
|
|
516
|
+
|
|
517
|
+
def get_recovery_status(self, **params):
|
|
518
|
+
"""Get recovery status"""
|
|
519
|
+
return self.request("GET", "/api/v1/servers/{server}/recovery", params)
|
|
520
|
+
|
|
521
|
+
def get_server_credentials(self, **params):
|
|
522
|
+
"""Get server credentials"""
|
|
523
|
+
return self.request("GET", "/api/v1/servers/{server}/credentials", params)
|
|
524
|
+
|
|
525
|
+
def get_transaction_details(self, **params):
|
|
526
|
+
"""Get transaction details"""
|
|
527
|
+
return self.request("GET", "/api/v1/transactions/{transaction}", params)
|
|
528
|
+
|
|
529
|
+
def get_usage_history(self, **params):
|
|
530
|
+
"""Get usage history"""
|
|
531
|
+
return self.request("GET", "/api/v1/servers/{server}/usage", params)
|
|
532
|
+
|
|
533
|
+
def get_user_balance(self, **params):
|
|
534
|
+
"""Get user balance"""
|
|
535
|
+
return self.request("GET", "/api/v1/user/balance", params)
|
|
536
|
+
|
|
537
|
+
def get_user_profile(self, **params):
|
|
538
|
+
"""Get user profile"""
|
|
539
|
+
return self.request("GET", "/api/v1/user", params)
|
|
540
|
+
|
|
541
|
+
def list_add_ons(self, **params):
|
|
542
|
+
"""List add-ons"""
|
|
543
|
+
return self.request("GET", "/api/v1/servers/{server}/addons", params)
|
|
544
|
+
|
|
545
|
+
def list_all_transactions(self, **params):
|
|
546
|
+
"""List all transactions"""
|
|
547
|
+
return self.request("GET", "/api/v1/transactions", params)
|
|
548
|
+
|
|
549
|
+
def list_deliveries(self, **params):
|
|
550
|
+
"""List deliveries"""
|
|
551
|
+
return self.request("GET", "/api/v1/webhooks/{webhook}/deliveries", params)
|
|
552
|
+
|
|
553
|
+
def list_events(self, **params):
|
|
554
|
+
"""List events"""
|
|
555
|
+
return self.request("GET", "/api/v1/events", params)
|
|
556
|
+
|
|
557
|
+
def list_extra_ip_addresses(self, **params):
|
|
558
|
+
"""List extra IP addresses"""
|
|
559
|
+
return self.request("GET", "/api/v1/servers/{server}/extra-ips", params)
|
|
560
|
+
|
|
561
|
+
def list_invoices(self, **params):
|
|
562
|
+
"""List invoices"""
|
|
563
|
+
return self.request("GET", "/api/v1/invoices", params)
|
|
564
|
+
|
|
565
|
+
def list_locations(self, **params):
|
|
566
|
+
"""List locations"""
|
|
567
|
+
return self.request("GET", "/api/v1/locations", params)
|
|
568
|
+
|
|
569
|
+
def list_notifications(self, **params):
|
|
570
|
+
"""List notifications"""
|
|
571
|
+
return self.request("GET", "/api/v1/notifications", params)
|
|
572
|
+
|
|
573
|
+
def list_operating_systems(self, **params):
|
|
574
|
+
"""List operating systems"""
|
|
575
|
+
return self.request("GET", "/api/v1/operating-systems", params)
|
|
576
|
+
|
|
577
|
+
def list_plans(self, **params):
|
|
578
|
+
"""List plans"""
|
|
579
|
+
return self.request("GET", "/api/v1/packages", params)
|
|
580
|
+
|
|
581
|
+
def list_servers(self, **params):
|
|
582
|
+
"""List servers"""
|
|
583
|
+
return self.request("GET", "/api/v1/servers", params)
|
|
584
|
+
|
|
585
|
+
def list_ssh_keys(self, **params):
|
|
586
|
+
"""List SSH keys"""
|
|
587
|
+
return self.request("GET", "/api/v1/ssh-keys", params)
|
|
588
|
+
|
|
589
|
+
def list_tickets(self, **params):
|
|
590
|
+
"""List tickets"""
|
|
591
|
+
return self.request("GET", "/api/v1/tickets", params)
|
|
592
|
+
|
|
593
|
+
def list_upgrade_options(self, **params):
|
|
594
|
+
"""List upgrade options"""
|
|
595
|
+
return self.request("GET", "/api/v1/servers/{server}/upgrades", params)
|
|
596
|
+
|
|
597
|
+
def list_webhooks(self, **params):
|
|
598
|
+
"""List webhooks"""
|
|
599
|
+
return self.request("GET", "/api/v1/webhooks", params)
|
|
600
|
+
|
|
601
|
+
def mark_notifications_as_read(self, **params):
|
|
602
|
+
"""Mark notifications as read"""
|
|
603
|
+
return self.request("POST", "/api/v1/notifications/read", params)
|
|
604
|
+
|
|
605
|
+
def move_a_server(self, **params):
|
|
606
|
+
"""Move a server"""
|
|
607
|
+
return self.request("POST", "/api/v1/servers/{server}/location", params)
|
|
608
|
+
|
|
609
|
+
def quote_a_new_server(self, **params):
|
|
610
|
+
"""Quote a new server"""
|
|
611
|
+
return self.request("POST", "/api/v1/quotes/server", params)
|
|
612
|
+
|
|
613
|
+
def quote_a_renewal(self, **params):
|
|
614
|
+
"""Quote a renewal"""
|
|
615
|
+
return self.request("GET", "/api/v1/servers/{server}/renewal-quote", params)
|
|
616
|
+
|
|
617
|
+
def reinstall_a_server(self, **params):
|
|
618
|
+
"""Reinstall a server"""
|
|
619
|
+
return self.request("POST", "/api/v1/servers/{server}/reinstall", params)
|
|
620
|
+
|
|
621
|
+
def remove_an_extra_ip_address(self, **params):
|
|
622
|
+
"""Remove an extra IP address"""
|
|
623
|
+
return self.request("DELETE", "/api/v1/servers/{server}/extra-ips/{ip}", params)
|
|
624
|
+
|
|
625
|
+
def remove_an_ssh_key(self, **params):
|
|
626
|
+
"""Remove an SSH key"""
|
|
627
|
+
return self.request("DELETE", "/api/v1/ssh-keys/{sshKey}", params)
|
|
628
|
+
|
|
629
|
+
def remove_heavy_use(self, **params):
|
|
630
|
+
"""Remove Heavy use"""
|
|
631
|
+
return self.request("DELETE", "/api/v1/servers/{server}/addons/heavy-use", params)
|
|
632
|
+
|
|
633
|
+
def renew_servers(self, **params):
|
|
634
|
+
"""Renew servers"""
|
|
635
|
+
return self.request("POST", "/api/v1/renewals", params)
|
|
636
|
+
|
|
637
|
+
def replace_ip_restrictions(self, **params):
|
|
638
|
+
"""Replace IP restrictions"""
|
|
639
|
+
return self.request("PUT", "/api/v1/servers/{server}/firewall", params)
|
|
640
|
+
|
|
641
|
+
def resend_a_delivery(self, **params):
|
|
642
|
+
"""Resend a delivery"""
|
|
643
|
+
return self.request("POST", "/api/v1/webhooks/{webhook}/deliveries/{delivery}/resend", params)
|
|
644
|
+
|
|
645
|
+
def reset_the_password(self, **params):
|
|
646
|
+
"""Reset the password"""
|
|
647
|
+
return self.request("POST", "/api/v1/servers/{server}/reset-password", params)
|
|
648
|
+
|
|
649
|
+
def run_a_repair(self, **params):
|
|
650
|
+
"""Run a repair"""
|
|
651
|
+
return self.request("POST", "/api/v1/servers/{server}/repairs", params)
|
|
652
|
+
|
|
653
|
+
def run_diagnostics(self, **params):
|
|
654
|
+
"""Run diagnostics"""
|
|
655
|
+
return self.request("POST", "/api/v1/servers/{server}/diagnostics", params)
|
|
656
|
+
|
|
657
|
+
def send_a_power_action(self, **params):
|
|
658
|
+
"""Send a power action"""
|
|
659
|
+
return self.request("POST", "/api/v1/servers/{server}/power", params)
|
|
660
|
+
|
|
661
|
+
def send_a_test_event(self, **params):
|
|
662
|
+
"""Send a test event"""
|
|
663
|
+
return self.request("POST", "/api/v1/webhooks/{webhook}/test", params)
|
|
664
|
+
|
|
665
|
+
def servers_due_for_renewal(self, **params):
|
|
666
|
+
"""Servers due for renewal"""
|
|
667
|
+
return self.request("GET", "/api/v1/renewals/due", params)
|
|
668
|
+
|
|
669
|
+
def start_the_recovery_hour(self, **params):
|
|
670
|
+
"""Start the recovery hour"""
|
|
671
|
+
return self.request("POST", "/api/v1/servers/{server}/recovery", params)
|
|
672
|
+
|
|
673
|
+
def top_up_your_balance(self, **params):
|
|
674
|
+
"""Top up your balance"""
|
|
675
|
+
return self.request("POST", "/api/v1/topups", params)
|
|
676
|
+
|
|
677
|
+
def unblock_an_address(self, **params):
|
|
678
|
+
"""Unblock an address"""
|
|
679
|
+
return self.request("POST", "/api/v1/servers/{server}/protection/unblock", params)
|
|
680
|
+
|
|
681
|
+
def update_a_server(self, **params):
|
|
682
|
+
"""Update a server"""
|
|
683
|
+
return self.request("PATCH", "/api/v1/servers/{server}", params)
|
|
684
|
+
|
|
685
|
+
def upgrade_a_server(self, **params):
|
|
686
|
+
"""Upgrade a server"""
|
|
687
|
+
return self.request("POST", "/api/v1/servers/{server}/upgrade", params)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: acerdp
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Client for the AceRDP API: Windows RDP and Linux VPS servers.
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Documentation, https://acerdp.io/api-docs
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# AceRDP API client (Python)
|
|
13
|
+
|
|
14
|
+
Order and manage AceRDP Windows RDP and Linux VPS servers from your own code. Every method is one operation of the [API reference](https://acerdp.io/api-docs); it returns the answer's `data` and throws `AceRdpError` (with `code`, `status` and the request id) when the API refuses.
|
|
15
|
+
|
|
16
|
+
Create the key in the panel under Settings > API. Pass `idempotency_key` with anything that charges your balance, so a retry never charges twice.
|
|
17
|
+
|
|
18
|
+
A read, or a change sent with `idempotency_key`, is tried again after `429` or a server error (twice by default, waiting what `Retry-After` says). `wait_until_ready(server_id)` waits until a new or reinstalled server is ready.
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
import os
|
|
22
|
+
from acerdp import AceRdp
|
|
23
|
+
|
|
24
|
+
api = AceRdp(os.environ["ACERDP_API_KEY"])
|
|
25
|
+
servers = api.list_servers()
|
|
26
|
+
api.send_a_power_action(server=servers[0]["id"], action="restart")
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Methods
|
|
30
|
+
|
|
31
|
+
- `add_an_ssh_key`: Add an SSH key
|
|
32
|
+
- `add_extra_ip_addresses`: Add extra IP addresses
|
|
33
|
+
- `add_heavy_use`: Add Heavy use
|
|
34
|
+
- `add_ram`: Add RAM
|
|
35
|
+
- `add_storage`: Add storage
|
|
36
|
+
- `configure_brute_force_protection`: Configure brute-force protection
|
|
37
|
+
- `create_a_server`: Create a server
|
|
38
|
+
- `create_a_webhook`: Create a webhook
|
|
39
|
+
- `delete_a_webhook`: Delete a webhook
|
|
40
|
+
- `delete_an_expired_server`: Delete an expired server
|
|
41
|
+
- `disable_ip_restrictions`: Disable IP restrictions
|
|
42
|
+
- `extend_a_server`: Extend a server
|
|
43
|
+
- `fix_everything`: Fix everything
|
|
44
|
+
- `get_a_plan`: Get a plan
|
|
45
|
+
- `get_a_server`: Get a server
|
|
46
|
+
- `get_a_servers_alerts`: Get a server's alerts
|
|
47
|
+
- `get_a_ticket`: Get a ticket
|
|
48
|
+
- `get_a_top_up`: Get a top-up
|
|
49
|
+
- `get_an_order`: Get an order
|
|
50
|
+
- `get_brute_force_protection`: Get brute-force protection
|
|
51
|
+
- `get_diagnostics_state`: Get diagnostics state
|
|
52
|
+
- `get_ip_restrictions`: Get IP restrictions
|
|
53
|
+
- `get_location_options`: Get location options
|
|
54
|
+
- `get_power_status`: Get power status
|
|
55
|
+
- `get_provisioning_status`: Get provisioning status
|
|
56
|
+
- `get_recovery_status`: Get recovery status
|
|
57
|
+
- `get_server_credentials`: Get server credentials
|
|
58
|
+
- `get_transaction_details`: Get transaction details
|
|
59
|
+
- `get_usage_history`: Get usage history
|
|
60
|
+
- `get_user_balance`: Get user balance
|
|
61
|
+
- `get_user_profile`: Get user profile
|
|
62
|
+
- `list_add_ons`: List add-ons
|
|
63
|
+
- `list_all_transactions`: List all transactions
|
|
64
|
+
- `list_deliveries`: List deliveries
|
|
65
|
+
- `list_events`: List events
|
|
66
|
+
- `list_extra_ip_addresses`: List extra IP addresses
|
|
67
|
+
- `list_invoices`: List invoices
|
|
68
|
+
- `list_locations`: List locations
|
|
69
|
+
- `list_notifications`: List notifications
|
|
70
|
+
- `list_operating_systems`: List operating systems
|
|
71
|
+
- `list_plans`: List plans
|
|
72
|
+
- `list_servers`: List servers
|
|
73
|
+
- `list_ssh_keys`: List SSH keys
|
|
74
|
+
- `list_tickets`: List tickets
|
|
75
|
+
- `list_upgrade_options`: List upgrade options
|
|
76
|
+
- `list_webhooks`: List webhooks
|
|
77
|
+
- `mark_notifications_as_read`: Mark notifications as read
|
|
78
|
+
- `move_a_server`: Move a server
|
|
79
|
+
- `quote_a_new_server`: Quote a new server
|
|
80
|
+
- `quote_a_renewal`: Quote a renewal
|
|
81
|
+
- `reinstall_a_server`: Reinstall a server
|
|
82
|
+
- `remove_an_extra_ip_address`: Remove an extra IP address
|
|
83
|
+
- `remove_an_ssh_key`: Remove an SSH key
|
|
84
|
+
- `remove_heavy_use`: Remove Heavy use
|
|
85
|
+
- `renew_servers`: Renew servers
|
|
86
|
+
- `replace_ip_restrictions`: Replace IP restrictions
|
|
87
|
+
- `resend_a_delivery`: Resend a delivery
|
|
88
|
+
- `reset_the_password`: Reset the password
|
|
89
|
+
- `run_a_repair`: Run a repair
|
|
90
|
+
- `run_diagnostics`: Run diagnostics
|
|
91
|
+
- `send_a_power_action`: Send a power action
|
|
92
|
+
- `send_a_test_event`: Send a test event
|
|
93
|
+
- `servers_due_for_renewal`: Servers due for renewal
|
|
94
|
+
- `start_the_recovery_hour`: Start the recovery hour
|
|
95
|
+
- `top_up_your_balance`: Top up your balance
|
|
96
|
+
- `unblock_an_address`: Unblock an address
|
|
97
|
+
- `update_a_server`: Update a server
|
|
98
|
+
- `upgrade_a_server`: Upgrade a server
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
acerdp
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "acerdp"
|
|
3
|
+
version = "1.1.0"
|
|
4
|
+
description = "Client for the AceRDP API: Windows RDP and Linux VPS servers."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.8"
|
|
7
|
+
license = { text = "MIT" }
|
|
8
|
+
|
|
9
|
+
[project.urls]
|
|
10
|
+
Documentation = "https://acerdp.io/api-docs"
|
|
11
|
+
|
|
12
|
+
[build-system]
|
|
13
|
+
requires = ["setuptools>=61"]
|
|
14
|
+
build-backend = "setuptools.build_meta"
|
acerdp-1.1.0/setup.cfg
ADDED