7.3.0: Fix sporestack server topup with recent API changes
ci/woodpecker/push/woodpecker Pipeline failed Details
ci/woodpecker/tag/woodpecker Pipeline failed Details

This commit is contained in:
Administrator 2022-11-28 16:28:43 +00:00
parent 5728118ec1
commit 92fbddc9e5
5 changed files with 9 additions and 24 deletions

View File

@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [7.3.0 - 2022-11-28]
### Fixed
- Fixed broken `sporestack server topup` after API changes.
## [7.2.1 - 2022-11-01] ## [7.2.1 - 2022-11-01]
### Changed ### Changed

View File

@ -2,4 +2,4 @@
__all__ = ["api", "api_client", "exceptions"] __all__ = ["api", "api_client", "exceptions"]
__version__ = "7.2.1" __version__ = "7.3.0"

View File

@ -51,7 +51,6 @@ class ServerLaunch:
"""Token to draw from when launching the server.""" """Token to draw from when launching the server."""
quote: bool = False quote: bool = False
"""Don't launch, get a quote on how much it would cost""" """Don't launch, get a quote on how much it would cost"""
affiliate_token: Optional[str] = None
hostname: str = "" hostname: str = ""
"""Hostname to refer to your server by.""" """Hostname to refer to your server by."""
autorenew: bool = False autorenew: bool = False
@ -65,17 +64,11 @@ class ServerLaunch:
"""Deprecated, not needed when paying with token. Only used for quote.""" """Deprecated, not needed when paying with token. Only used for quote."""
expiration: int expiration: int
machine_id: str machine_id: str
network_interfaces: List[NetworkInterface] = []
"""Deprecated, use ipv4/ipv6 from ServerInfo instead."""
created_at: int = 0 created_at: int = 0
region: Optional[str] = None
"""Deprecated, use ServerInfo instead."""
created: bool = False created: bool = False
paid: bool = False paid: bool = False
"""Deprecated, not needed when paying with token.""" """Deprecated, not needed when paying with token."""
warning: Optional[str] = None warning: Optional[str] = None
flavor: str = ""
"""Deprecated, use ServerInfo instead."""
class ServerTopup: class ServerTopup:
@ -85,15 +78,11 @@ class ServerTopup:
class Request(BaseModel): class Request(BaseModel):
days: int days: int
token: str token: str
quote: bool = False
affiliate_token: Optional[str] = None
class Response(BaseModel): class Response(BaseModel):
machine_id: str machine_id: str
payment: Payment
"""Deprecated, not needed when paying with token."""
expiration: int expiration: int
paid: bool = False paid: bool = True
"""Deprecated, not needed when paying with token.""" """Deprecated, not needed when paying with token."""
warning: Optional[str] = None warning: Optional[str] = None

View File

@ -140,7 +140,6 @@ def launch(
api_endpoint: str = API_ENDPOINT, api_endpoint: str = API_ENDPOINT,
region: Optional[str] = None, region: Optional[str] = None,
retry: bool = False, retry: bool = False,
affiliate_token: Optional[str] = None,
quote: bool = False, quote: bool = False,
hostname: str = "", hostname: str = "",
autorenew: bool = False, autorenew: bool = False,
@ -148,7 +147,6 @@ def launch(
request = api.ServerLaunch.Request( request = api.ServerLaunch.Request(
days=days, days=days,
token=token, token=token,
affiliate_token=affiliate_token,
flavor=flavor, flavor=flavor,
region=region, region=region,
operating_system=operating_system, operating_system=operating_system,
@ -170,18 +168,11 @@ def topup(
token: str, token: str,
api_endpoint: str = API_ENDPOINT, api_endpoint: str = API_ENDPOINT,
retry: bool = False, retry: bool = False,
affiliate_token: Optional[str] = None,
quote: bool = False,
) -> api.ServerTopup.Response: ) -> api.ServerTopup.Response:
""" """
Topup a server. Topup a server.
""" """
request = api.ServerTopup.Request( request = api.ServerTopup.Request(days=days, token=token)
days=days,
token=token,
affiliate_token=affiliate_token,
quote=quote,
)
url = api_endpoint + api.ServerTopup.url.format(machine_id=machine_id) url = api_endpoint + api.ServerTopup.url.format(machine_id=machine_id)
response = _api_request(url=url, json_params=request.dict(), retry=retry) response = _api_request(url=url, json_params=request.dict(), retry=retry)
response_object = api.ServerTopup.Response.parse_obj(response) response_object = api.ServerTopup.Response.parse_obj(response)

View File

@ -223,7 +223,6 @@ def topup(
token=_token, token=_token,
retry=True, retry=True,
) )
assert response.payment.paid is True
typer.echo(response.expiration) typer.echo(response.expiration)