File: mounts.py

package info (click to toggle)
python-aiohasupervisor 0.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 884 kB
  • sloc: python: 4,353; sh: 37; makefile: 3
file content (37 lines) | stat: -rw-r--r-- 1,370 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Mounts client for Supervisor."""

from .client import _SupervisorComponentClient
from .models.mounts import CIFSMountRequest, MountsInfo, MountsOptions, NFSMountRequest


class MountsClient(_SupervisorComponentClient):
    """Handle mounts access in supervisor."""

    async def info(self) -> MountsInfo:
        """Get mounts info."""
        result = await self._client.get("mounts")
        return MountsInfo.from_dict(result.data)

    async def options(self, options: MountsOptions) -> None:
        """Set mounts options."""
        await self._client.post("mounts/options", json=options.to_dict())

    async def create_mount(
        self, name: str, config: CIFSMountRequest | NFSMountRequest
    ) -> None:
        """Create a new mount."""
        await self._client.post("mounts", json={"name": name, **config.to_dict()})

    async def update_mount(
        self, name: str, config: CIFSMountRequest | NFSMountRequest
    ) -> None:
        """Update an existing mount."""
        await self._client.put(f"mounts/{name}", json=config.to_dict())

    async def delete_mount(self, name: str) -> None:
        """Delete an existing mount."""
        await self._client.delete(f"mounts/{name}")

    async def reload_mount(self, name: str) -> None:
        """Reload details of an existing mount."""
        await self._client.post(f"mounts/{name}/reload")