snap_python.components.snaps

class snap_python.components.snaps.SnapsEndpoints(client: AbstractSnapsClient)

Bases: object

async disable_snap(snap: str, wait: bool = False) AsyncResponse | ChangesResponse

Disables a snap package.

Parameters:
  • snap (str) – The name of the snap package to disable.

  • wait (bool, optional) – Whether to wait for the disable operation to complete. Defaults to False.

Returns:

The response from the disable operation.

Return type:

AsyncResponse | ChangesResponse

Raises:

SnapdAPIError – If there is an error during the snap disable operation.

async enable_snap(snap: str, wait: bool = False) AsyncResponse | ChangesResponse

enables a snap package.

Parameters:
  • snap (str) – The name of the snap package to enable.

  • wait (bool, optional) – Whether to wait for the enable operation to complete. Defaults to False.

Returns:

The response from the enable operation.

Return type:

AsyncResponse | ChangesResponse

Raises:

SnapdAPIError – If there is an error during the snap enable operation.

async get_snap_apps(snap: str, services_only: bool = False) AppsResponse

Retrieves the applications associated with a specific snap.

Parameters:
  • snap (str) – The name of the snap to retrieve applications for.

  • services_only (bool) – Whether to retrieve only service applications.

Returns:

The response containing the list of applications for the specified snap.

Return type:

AppsResponse

async get_snap_info(snap: str) SingleInstalledSnapResponse

Retrieves information about a specific snap.

Parameters:

snap (str) – The name of the snap to retrieve information for.

Returns:

The response containing information about the snap.

Return type:

SingleInstalledSnapResponse

Raises:

httpx.HTTPStatusError – If the response status code does not indicate success.

async install_snap(snap: str, channel: str = 'stable', classic: bool = False, dangerous: bool = False, devmode: bool = False, jailmode: bool = False, revision: int = None, filename: str = None, wait: bool = False) AsyncResponse | ChangesResponse

Install or sideload a snap.

To sideload a snap, provide the filename parameter with the path to the snap file.

Parameters:
  • snap (str) – Name of the snap to install.

  • channel (str, optional) – Channel to install, defaults to “stable”.

  • classic (bool, optional) – Install with classic confinement, defaults to False.

  • dangerous (bool, optional) – Install the given snap files even if there are no pre-acknowledged signatures for them, meaning they are not verified and could be dangerous if true (optional, implied by devmode), defaults to False.

  • devmode (bool, optional) – Install with devmode, defaults to False.

  • jailmode (bool, optional) – Install snap with jailmode, defaults to False.

  • revision (int, optional) – Install a specific revision of the snap, defaults to None.

  • filename (str, optional) – Path to snap to sideload, defaults to None.

  • wait (bool, optional) – Whether to wait for snap to install. If not waiting, will return async response with change id, defaults to False.

Raises:
  • FileNotFoundError – If the specified snap file does not exist.

  • ValueError – If attempting to sideload without the dangerous flag set to True.

  • SnapdAPIError – If there is an error during the snap install.

Returns:

If wait is True, will return ChangesResponse. Otherwise, will return AsyncResponse.

Return type:

AsyncResponse | ChangesResponse

async is_snap_installed(snap: str) bool

Check if a snap package is installed.

Parameters:

snap (str) – The name of the snap package to check.

Returns:

True if the snap package is installed, False otherwise.

Return type:

bool

async list_installed_snaps() InstalledSnapListResponse

Asynchronously retrieves a list of installed snaps.

Returns:

The response containing the list of installed snaps.

Return type:

InstalledSnapListResponse

Raises:

httpx.HTTPStatusError – If the response status code does not indicate success.

async refresh_snap(snap: str, channel: str = 'stable', classic: bool = False, dangerous: bool = False, devmode: bool = False, ignore_validation: bool = False, jailmode: bool = False, revision: int = None, filename: str = None, wait: bool = False) AsyncResponse | ChangesResponse

Refreshes a snap package.

Parameters:
  • snap (str) – The name of the snap package to refresh.

  • channel (str, optional) – The channel to refresh the snap from. Defaults to “stable”.

  • classic (bool, optional) – Whether to use classic confinement. Defaults to False.

  • dangerous (bool, optional) – Whether to allow installation of unasserted snaps. Defaults to False.

  • devmode (bool, optional) – Whether to use development mode. Defaults to False.

  • ignore_validation (bool, optional) – Whether to ignore validation. Defaults to False.

  • jailmode (bool, optional) – Whether to use jail mode. Defaults to False.

  • revision (int, optional) – The specific revision to refresh to. Defaults to None.

  • filename (str, optional) – The path to the snap file for sideloading. Defaults to None.

  • wait (bool, optional) – Whether to wait for the refresh operation to complete. Defaults to False.

Returns:

The response from the refresh operation.

Return type:

AsyncResponse | ChangesResponse

Raises:
  • FileNotFoundError – If the specified snap file does not exist.

  • ValueError – If attempting to sideload without the dangerous flag set to True.

  • SnapdAPIError – If there is an error during the snap refresh.

async remove_snap(snap: str, purge: bool = False, terminate: bool = False, wait: bool = False) AsyncResponse | ChangesResponse

Asynchronously removes a snap package.

Parameters:
  • snap (str) – The name of the snap package to remove.

  • purge (bool, optional) – If True, purges the snap package. Defaults to False.

  • terminate (bool, optional) – If True, terminates the snap package. Defaults to False.

  • wait (bool, optional) – If True, waits for the removal process to complete. Defaults to False.

Returns:

The response from the snapd API, either an asynchronous response or a changes response if waiting for completion.

Return type:

AsyncResponse | ChangesResponse

Raises:

SnapdAPIError – If there is an error in the snap removal process.