7.3.0: Fix sporestack server topup with recent API changes
This commit is contained in:
parent
5728118ec1
commit
92fbddc9e5
|
@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [7.3.0 - 2022-11-28]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed broken `sporestack server topup` after API changes.
|
||||
|
||||
## [7.2.1 - 2022-11-01]
|
||||
|
||||
### Changed
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
__all__ = ["api", "api_client", "exceptions"]
|
||||
|
||||
__version__ = "7.2.1"
|
||||
__version__ = "7.3.0"
|
||||
|
|
|
@ -51,7 +51,6 @@ class ServerLaunch:
|
|||
"""Token to draw from when launching the server."""
|
||||
quote: bool = False
|
||||
"""Don't launch, get a quote on how much it would cost"""
|
||||
affiliate_token: Optional[str] = None
|
||||
hostname: str = ""
|
||||
"""Hostname to refer to your server by."""
|
||||
autorenew: bool = False
|
||||
|
@ -65,17 +64,11 @@ class ServerLaunch:
|
|||
"""Deprecated, not needed when paying with token. Only used for quote."""
|
||||
expiration: int
|
||||
machine_id: str
|
||||
network_interfaces: List[NetworkInterface] = []
|
||||
"""Deprecated, use ipv4/ipv6 from ServerInfo instead."""
|
||||
created_at: int = 0
|
||||
region: Optional[str] = None
|
||||
"""Deprecated, use ServerInfo instead."""
|
||||
created: bool = False
|
||||
paid: bool = False
|
||||
"""Deprecated, not needed when paying with token."""
|
||||
warning: Optional[str] = None
|
||||
flavor: str = ""
|
||||
"""Deprecated, use ServerInfo instead."""
|
||||
|
||||
|
||||
class ServerTopup:
|
||||
|
@ -85,15 +78,11 @@ class ServerTopup:
|
|||
class Request(BaseModel):
|
||||
days: int
|
||||
token: str
|
||||
quote: bool = False
|
||||
affiliate_token: Optional[str] = None
|
||||
|
||||
class Response(BaseModel):
|
||||
machine_id: str
|
||||
payment: Payment
|
||||
"""Deprecated, not needed when paying with token."""
|
||||
expiration: int
|
||||
paid: bool = False
|
||||
paid: bool = True
|
||||
"""Deprecated, not needed when paying with token."""
|
||||
warning: Optional[str] = None
|
||||
|
||||
|
|
|
@ -140,7 +140,6 @@ def launch(
|
|||
api_endpoint: str = API_ENDPOINT,
|
||||
region: Optional[str] = None,
|
||||
retry: bool = False,
|
||||
affiliate_token: Optional[str] = None,
|
||||
quote: bool = False,
|
||||
hostname: str = "",
|
||||
autorenew: bool = False,
|
||||
|
@ -148,7 +147,6 @@ def launch(
|
|||
request = api.ServerLaunch.Request(
|
||||
days=days,
|
||||
token=token,
|
||||
affiliate_token=affiliate_token,
|
||||
flavor=flavor,
|
||||
region=region,
|
||||
operating_system=operating_system,
|
||||
|
@ -170,18 +168,11 @@ def topup(
|
|||
token: str,
|
||||
api_endpoint: str = API_ENDPOINT,
|
||||
retry: bool = False,
|
||||
affiliate_token: Optional[str] = None,
|
||||
quote: bool = False,
|
||||
) -> api.ServerTopup.Response:
|
||||
"""
|
||||
Topup a server.
|
||||
"""
|
||||
request = api.ServerTopup.Request(
|
||||
days=days,
|
||||
token=token,
|
||||
affiliate_token=affiliate_token,
|
||||
quote=quote,
|
||||
)
|
||||
request = api.ServerTopup.Request(days=days, token=token)
|
||||
url = api_endpoint + api.ServerTopup.url.format(machine_id=machine_id)
|
||||
response = _api_request(url=url, json_params=request.dict(), retry=retry)
|
||||
response_object = api.ServerTopup.Response.parse_obj(response)
|
||||
|
|
|
@ -223,7 +223,6 @@ def topup(
|
|||
token=_token,
|
||||
retry=True,
|
||||
)
|
||||
assert response.payment.paid is True
|
||||
|
||||
typer.echo(response.expiration)
|
||||
|
||||
|
|
Loading…
Reference in New Issue