Skip to content

Commit

Permalink
Add status constants (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
LKaemmerling authored Feb 27, 2019
1 parent 35d09de commit 3d43718
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
20 changes: 19 additions & 1 deletion hcloud/servers/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ class Server(BaseDomain):
:param volumes: List[:class:`BoundVolume <hcloud.volumes.client.BoundVolume>`]
Volumes assigned to this server.
"""
STATUS_RUNNING = "running"
"""Server Status running"""
STATUS_INIT = "initializing"
"""Server Status initializing"""
STATUS_STARTING = "starting"
"""Server Status starting"""
STATUS_STOPPING = "stopping"
"""Server Status stopping"""
STATUS_OFF = "off"
"""Server Status off"""
STATUS_DELETING = "deleting"
"""Server Status deleting"""
STATUS_MIGRATING = "migrating"
"""Server Status migrating"""
STATUS_REBUILDING = "rebuilding"
"""Server Status rebuilding"""
STATUS_UNKNOWN = "unknown"
"""Server Status unknown"""
__slots__ = (
"id",
"name",
Expand All @@ -62,7 +80,7 @@ class Server(BaseDomain):

created = ISODateTime()

supported_fields = ("created", )
supported_fields = ("created",)

def __init__(
self,
Expand Down
7 changes: 6 additions & 1 deletion hcloud/volumes/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class Volume(BaseDomain, DomainIdentityMixin):
:param format: str, None
Filesystem of the volume if formatted on creation, None if not formatted on creation.
"""
STATUS_CREATING = "creating"
"""Volume Status creating"""
STATUS_AVAILABLE = "available"
"""Volume Status available"""

created = ISODateTime()

__slots__ = (
Expand All @@ -44,7 +49,7 @@ class Volume(BaseDomain, DomainIdentityMixin):
"status"
)

supported_fields = ("created", )
supported_fields = ("created",)

def __init__(
self,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/servers/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_bound_server_init(self, response_full_server):
@pytest.mark.parametrize(
"params",
[
{"status": ["running"],
{"status": [Server.STATUS_RUNNING],
"sort": "status",
"page": 1,
"per_page": 10},
Expand All @@ -109,7 +109,7 @@ def test_get_actions_list(self, hetzner_client, bound_server, response_get_actio
@pytest.mark.parametrize(
"params",
[
{"status": ["running"],
{"status": [Server.STATUS_RUNNING],
"sort": "status"},
{}
Expand Down

0 comments on commit 3d43718

Please sign in to comment.