wip
This commit is contained in:
parent
a7e6f2c4e5
commit
eb448597c8
6 changed files with 379 additions and 251 deletions
|
|
@ -55,8 +55,7 @@ def clear() -> Union[Hero, List[Hero]]:
|
|||
"list many heros"
|
||||
heros = Heros.list()
|
||||
for hero in heros.heros:
|
||||
HeroDelete(id=hero.id).delete()
|
||||
|
||||
HeroDelete.delete(id=hero.id)
|
||||
return hero
|
||||
|
||||
|
||||
|
|
@ -81,10 +80,12 @@ def update(
|
|||
@hero_app.command()
|
||||
@engorgio(typer=True)
|
||||
def delete(
|
||||
hero: HeroDelete,
|
||||
hero_id: Optional[int] = typer.Argument(default=None),
|
||||
) -> Hero:
|
||||
"delete a hero by id"
|
||||
hero.delete()
|
||||
hero = HeroDelete.delete(id=hero_id)
|
||||
Console().print(hero)
|
||||
return hero
|
||||
|
||||
|
||||
@hero_app.command()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Optional
|
||||
from typing import Dict, Optional
|
||||
|
||||
import httpx
|
||||
from pydantic import BaseModel
|
||||
|
|
@ -93,9 +93,10 @@ class HeroUpdate(SQLModel):
|
|||
class HeroDelete(BaseModel):
|
||||
id: int
|
||||
|
||||
def delete(self) -> Hero:
|
||||
@classmethod
|
||||
def delete(self, id: int) -> Dict[str, bool]:
|
||||
r = httpx.delete(
|
||||
f"{config.api_client.url}/hero/{self.id}",
|
||||
f"{config.api_client.url}/hero/{id}",
|
||||
)
|
||||
if r.status_code != 200:
|
||||
raise RuntimeError(f"{r.status_code}:\n {r.text}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue