Merge pull request 'api/clan: rename 'show_clan_meta' -> 'get_clan_details'' (#4236) from api-cleanup into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/4236
This commit is contained in:
hsjobeki
2025-07-07 10:00:10 +00:00
17 changed files with 109 additions and 102 deletions

View File

@@ -122,11 +122,12 @@ def blk_from_dict(data: dict) -> BlkInfo:
@API.register
def show_block_devices() -> Blockdevices:
def list_block_devices() -> Blockdevices:
"""
Api method to show local block devices.
List local block devices by running `lsblk`.
It must return a list of block devices.
Returns:
A list of detected block devices with metadata like size, path, type, etc.
"""
cmd = nix_shell(

View File

@@ -88,7 +88,7 @@ def parse_avahi_output(output: str) -> DNSInfo:
@API.register
def show_mdns() -> DNSInfo:
def list_mdns_services() -> DNSInfo:
cmd = nix_shell(
["avahi"],
[
@@ -107,7 +107,7 @@ def show_mdns() -> DNSInfo:
def mdns_command(args: argparse.Namespace) -> None:
dns_info = show_mdns()
dns_info = list_mdns_services()
for name, info in dns_info.services.items():
print(f"Hostname: {name} - ip: {info.ip}")

View File

@@ -1,12 +1,12 @@
from clan_lib.api import API
from clan_lib.errors import ClanError
from clan_lib.flake import Flake
from clan_lib.nix_models.clan import InventoryMeta as Meta
from clan_lib.nix_models.clan import InventoryMeta
from clan_lib.persist.inventory_store import InventoryStore
@API.register
def show_clan_meta(flake: Flake) -> Meta:
def get_clan_details(flake: Flake) -> InventoryMeta:
if flake.is_local and not flake.path.exists():
msg = f"Path {flake} does not exist"
raise ClanError(msg, description="clan directory does not exist")