Browse Source

Add pep8-naming

master
/dev/null 1 week ago
parent
commit
066b4ce6de
  1. 1
      Pipfile
  2. 41
      Pipfile.lock
  3. 18
      src/sporestack/api.py
  4. 50
      src/sporestack/api_client.py
  5. 4
      src/sporestack/cli.py

1
Pipfile

@ -11,6 +11,7 @@ sporestack = {editable = true, path = "."}
black = "==21.10b0"
flake8 = "~=4.0"
flake8-noqa = "~=1.2"
pep8-naming = "~=0.12.1"
mypy = "~=0.910"
pytest = "~=6.2"
pytest-cov = "~=2.11"

41
Pipfile.lock

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "d419cf47d62f4f77a0d585c9200720d8c4dd65c459f5e800f4af65bf6e58d596"
"sha256": "312468a9937e6726d47437bf8efbc7d1036aad78021b88660668e0bc195d57ca"
},
"pipfile-spec": 6,
"requires": {},
@ -272,10 +272,17 @@
},
"flake8-noqa": {
"hashes": [
"sha256:05e272280834c0aa6f50abe38a93f6b6a6d57ab2189c1fdcbb842fd23f0e8771"
"sha256:629b87b542f9b4cbd7ee6de10b2c669e460a200145a7577b98092b7e94373153"
],
"index": "pypi",
"version": "==1.2.0"
"version": "==1.2.1"
},
"flake8-polyfill": {
"hashes": [
"sha256:12be6a34ee3ab795b19ca73505e7b55826d5f6ad7230d31b18e106400169b9e9",
"sha256:e44b087597f6da52ec6393a709e7108b2905317d0c0b744cdca6208e670d8eda"
],
"version": "==1.0.2"
},
"idna": {
"hashes": [
@ -361,11 +368,11 @@
},
"packaging": {
"hashes": [
"sha256:096d689d78ca690e4cd8a89568ba06d07ca097e3306a4381635073ca91479966",
"sha256:14317396d1e8cdb122989b916fa2c7e9ca8e2be9e8060a6eff75b6b7b4d8a7e0"
"sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb",
"sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"
],
"markers": "python_version >= '3.6'",
"version": "==21.2"
"version": "==21.3"
},
"pathspec": {
"hashes": [
@ -381,6 +388,14 @@
],
"version": "==0.12.0"
},
"pep8-naming": {
"hashes": [
"sha256:4a8daeaeb33cfcde779309fc0c9c0a68a3bbe2ad8a8308b763c5068f86eb9f37",
"sha256:bb2455947757d162aa4cad55dba4ce029005cd1692f2899a21d51d8630ca7841"
],
"index": "pypi",
"version": "==0.12.1"
},
"pkginfo": {
"hashes": [
"sha256:37ecd857b47e5f55949c41ed061eb51a0bee97a87c969219d144c0e023982779",
@ -438,11 +453,11 @@
},
"pyparsing": {
"hashes": [
"sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1",
"sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"
"sha256:04ff808a5b90911829c55c4e26f75fa5ca8a2f5f36aa3a51f68e27033341d3e4",
"sha256:d9bdec0013ef1eb5a84ab39a3b3868911598afa494f5faa038647101504e2b81"
],
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.4.7"
"markers": "python_version >= '3.6'",
"version": "==3.0.6"
},
"pytest": {
"hashes": [
@ -548,11 +563,11 @@
},
"setuptools": {
"hashes": [
"sha256:899d27ec8104a68d4ba813b1afd66708a1a10e9391e79be92c8c60f9c77d05e5",
"sha256:dedb38ba61844d9df36072dad313cb79426fd50497aaac9c0da4cd50dbeeb110"
"sha256:94ee891f4759150cded601a6beb6b08400413aefd0267b692f3f8c6e0bb238e7",
"sha256:fb537610c2dfe77b5896e3ee53dd53fbdd9adc48076c8f28cee3a30fb59a5038"
],
"markers": "python_version >= '3.6'",
"version": "==59.0.1"
"version": "==59.1.1"
},
"six": {
"hashes": [

18
src/sporestack/api.py

@ -12,7 +12,7 @@ from pydantic import BaseModel
from .models import NetworkInterface, Payment
class token_enable(object):
class TokenEnable(object):
url = "/token/{token}/enable"
method = "POST"
@ -25,7 +25,7 @@ class token_enable(object):
payment: Payment
class token_add(object):
class TokenAdd(object):
url = "/token/{token}/add"
method = "POST"
@ -38,7 +38,7 @@ class token_add(object):
payment: Payment
class token_balance(object):
class TokenBalance(object):
url = "/token/{token}/balance"
method = "GET"
@ -48,7 +48,7 @@ class token_balance(object):
usd: str
class server_launch(object):
class ServerLaunch(object):
url = "/server/{machine_id}/launch"
method = "POST"
@ -81,7 +81,7 @@ class server_launch(object):
flavor: str
class server_topup(object):
class ServerTopup(object):
url = "/server/{machine_id}/topup"
method = "POST"
@ -103,7 +103,7 @@ class server_topup(object):
latest_api_version: int
class server_info(object):
class ServerInfo(object):
url = "/server/{machine_id}/info"
method = "GET"
@ -116,16 +116,16 @@ class server_info(object):
region: str
class server_start(object):
class ServerStart(object):
url = "/server/{machine_id}/start"
method = "POST"
class server_stop(object):
class ServerStop(object):
url = "/server/{machine_id}/stop"
method = "POST"
class server_delete(object):
class ServerDelete(object):
url = "/server/{machine_id}/delete"
method = "POST"

50
src/sporestack/api_client.py

@ -141,8 +141,8 @@ def launch(
retry: bool = False,
affiliate_amount: Optional[int] = None,
affiliate_token: Optional[str] = None,
) -> api.server_launch.Response:
request = api.server_launch.Request(
) -> api.ServerLaunch.Response:
request = api.ServerLaunch.Request(
machine_id=machine_id,
days=days,
currency=currency,
@ -154,9 +154,9 @@ def launch(
operating_system=operating_system,
ssh_key=ssh_key,
)
url = api_endpoint + api.server_launch.url.format(machine_id=machine_id)
url = api_endpoint + api.ServerLaunch.url.format(machine_id=machine_id)
response = api_request(url=url, json_params=request.dict(), retry=retry)
response_object = api.server_launch.Response.parse_obj(response)
response_object = api.ServerLaunch.Response.parse_obj(response)
assert response_object.machine_id == machine_id
return response_object
@ -170,11 +170,11 @@ def topup(
retry: bool = False,
affiliate_amount: Optional[int] = None,
affiliate_token: Optional[str] = None,
) -> api.server_topup.Response:
) -> api.ServerTopup.Response:
"""
Topup a server.
"""
request = api.server_topup.Request(
request = api.ServerTopup.Request(
machine_id=machine_id,
days=days,
currency=currency,
@ -182,9 +182,9 @@ def topup(
affiliate_amount=affiliate_amount,
affiliate_token=affiliate_token,
)
url = api_endpoint + api.server_topup.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_object = api.server_topup.Response.parse_obj(response)
response_object = api.ServerTopup.Response.parse_obj(response)
assert response_object.machine_id == machine_id
return response_object
@ -193,7 +193,7 @@ def start(machine_id: str, api_endpoint: str = API_ENDPOINT) -> None:
"""
Boots the server.
"""
url = api_endpoint + api.server_start.url.format(machine_id=machine_id)
url = api_endpoint + api.ServerStart.url.format(machine_id=machine_id)
api_request(url, empty_post=True)
@ -201,7 +201,7 @@ def stop(machine_id: str, api_endpoint: str = API_ENDPOINT) -> None:
"""
Powers off the server.
"""
url = api_endpoint + api.server_stop.url.format(machine_id=machine_id)
url = api_endpoint + api.ServerStop.url.format(machine_id=machine_id)
api_request(url, empty_post=True)
@ -209,17 +209,17 @@ def delete(machine_id: str, api_endpoint: str = API_ENDPOINT) -> None:
"""
Deletes the server.
"""
url = api_endpoint + api.server_delete.url.format(machine_id=machine_id)
url = api_endpoint + api.ServerDelete.url.format(machine_id=machine_id)
api_request(url, empty_post=True)
def info(machine_id: str, api_endpoint: str = API_ENDPOINT) -> api.server_info.Response:
def info(machine_id: str, api_endpoint: str = API_ENDPOINT) -> api.ServerInfo.Response:
"""
Returns info about the server.
"""
url = api_endpoint + api.server_info.url.format(machine_id=machine_id)
url = api_endpoint + api.ServerInfo.url.format(machine_id=machine_id)
response = api_request(url)
response_object = api.server_info.Response.parse_obj(response)
response_object = api.ServerInfo.Response.parse_obj(response)
assert response_object.machine_id == machine_id
return response_object
@ -230,11 +230,11 @@ def token_enable(
currency: str,
api_endpoint: str = API_ENDPOINT,
retry: bool = False,
) -> api.token_enable.Response:
request = api.token_enable.Request(dollars=dollars, currency=currency)
url = api_endpoint + api.token_enable.url.format(token=token)
) -> api.TokenEnable.Response:
request = api.TokenEnable.Request(dollars=dollars, currency=currency)
url = api_endpoint + api.TokenEnable.url.format(token=token)
response = api_request(url=url, json_params=request.dict(), retry=retry)
response_object = api.token_enable.Response.parse_obj(response)
response_object = api.TokenEnable.Response.parse_obj(response)
assert response_object.token == token
return response_object
@ -245,20 +245,20 @@ def token_add(
currency: str,
api_endpoint: str = API_ENDPOINT,
retry: bool = False,
) -> api.token_add.Response:
request = api.token_add.Request(dollars=dollars, currency=currency)
url = api_endpoint + api.token_add.url.format(token=token)
) -> api.TokenAdd.Response:
request = api.TokenAdd.Request(dollars=dollars, currency=currency)
url = api_endpoint + api.TokenAdd.url.format(token=token)
response = api_request(url=url, json_params=request.dict(), retry=retry)
response_object = api.token_add.Response.parse_obj(response)
response_object = api.TokenAdd.Response.parse_obj(response)
assert response_object.token == token
return response_object
def token_balance(
token: str, api_endpoint: str = API_ENDPOINT
) -> api.token_balance.Response:
url = api_endpoint + api.token_balance.url.format(token=token)
) -> api.TokenBalance.Response:
url = api_endpoint + api.TokenBalance.url.format(token=token)
response = api_request(url=url)
response_object = api.token_balance.Response.parse_obj(response)
response_object = api.TokenBalance.Response.parse_obj(response)
assert response_object.token == token
return response_object

4
src/sporestack/cli.py

@ -1,3 +1,7 @@
"""
SporeStack CLI: `sporestack`
"""
import json
import logging
import os

Loading…
Cancel
Save