Skip to content

Commit 3d43718

Browse files
authored
Add status constants (#30)
1 parent 35d09de commit 3d43718

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

hcloud/servers/domain.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ class Server(BaseDomain):
4040
:param volumes: List[:class:`BoundVolume <hcloud.volumes.client.BoundVolume>`]
4141
Volumes assigned to this server.
4242
"""
43+
STATUS_RUNNING = "running"
44+
"""Server Status running"""
45+
STATUS_INIT = "initializing"
46+
"""Server Status initializing"""
47+
STATUS_STARTING = "starting"
48+
"""Server Status starting"""
49+
STATUS_STOPPING = "stopping"
50+
"""Server Status stopping"""
51+
STATUS_OFF = "off"
52+
"""Server Status off"""
53+
STATUS_DELETING = "deleting"
54+
"""Server Status deleting"""
55+
STATUS_MIGRATING = "migrating"
56+
"""Server Status migrating"""
57+
STATUS_REBUILDING = "rebuilding"
58+
"""Server Status rebuilding"""
59+
STATUS_UNKNOWN = "unknown"
60+
"""Server Status unknown"""
4361
__slots__ = (
4462
"id",
4563
"name",
@@ -62,7 +80,7 @@ class Server(BaseDomain):
6280

6381
created = ISODateTime()
6482

65-
supported_fields = ("created", )
83+
supported_fields = ("created",)
6684

6785
def __init__(
6886
self,

hcloud/volumes/domain.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class Volume(BaseDomain, DomainIdentityMixin):
2929
:param format: str, None
3030
Filesystem of the volume if formatted on creation, None if not formatted on creation.
3131
"""
32+
STATUS_CREATING = "creating"
33+
"""Volume Status creating"""
34+
STATUS_AVAILABLE = "available"
35+
"""Volume Status available"""
36+
3237
created = ISODateTime()
3338

3439
__slots__ = (
@@ -44,7 +49,7 @@ class Volume(BaseDomain, DomainIdentityMixin):
4449
"status"
4550
)
4651

47-
supported_fields = ("created", )
52+
supported_fields = ("created",)
4853

4954
def __init__(
5055
self,

tests/unit/servers/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_bound_server_init(self, response_full_server):
8585
@pytest.mark.parametrize(
8686
"params",
8787
[
88-
{"status": ["running"],
88+
{"status": [Server.STATUS_RUNNING],
8989
"sort": "status",
9090
"page": 1,
9191
"per_page": 10},
@@ -109,7 +109,7 @@ def test_get_actions_list(self, hetzner_client, bound_server, response_get_actio
109109
@pytest.mark.parametrize(
110110
"params",
111111
[
112-
{"status": ["running"],
112+
{"status": [Server.STATUS_RUNNING],
113113
"sort": "status"},
114114
{}
115115

0 commit comments

Comments
 (0)