> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jakan.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Package Operations

> Operations for managing Stash packages.

Operations for managing Stash packages.

Bases: `StashClientProtocol`

Mixin for package-related client methods.

## Functions

### install\_packages

```python theme={null}
install_packages(
    package_type: PackageType | str,
    packages: list[PackageSpecInput] | list[dict[str, Any]],
) -> str
```

Install packages.

Parameters:

| Name           | Type                                             | Description                                                                                                                                 | Default    |
| -------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| `package_type` | `PackageType \| str`                             | Type of packages to install (PackageType.SCRAPER or PackageType.PLUGIN)                                                                     | *required* |
| `packages`     | `list[PackageSpecInput] \| list[dict[str, Any]]` | List of PackageSpecInput objects or dictionaries containing: - id: Package ID (required) - sourceURL: Source URL for the package (required) | *required* |

Returns:

| Type  | Description                      |
| ----- | -------------------------------- |
| `str` | Job ID for the installation task |

Raises:

| Type             | Description                  |
| ---------------- | ---------------------------- |
| `ValueError`     | If the input data is invalid |
| `TransportError` | If the request fails         |

Examples:

Install a scraper package:

```python theme={null}
from stash_graphql_client.types import PackageType, PackageSpecInput

packages = [
    PackageSpecInput(id="package-id", source_url="https://example.com/package.yml")
]
job_id = await client.install_packages(PackageType.SCRAPER, packages)
print(f"Installation job started: {job_id}")
```

Install multiple plugin packages using dictionaries:

```python theme={null}
packages = [
    {"id": "plugin-1", "sourceURL": "https://example.com/plugin1.yml"},
    {"id": "plugin-2", "sourceURL": "https://example.com/plugin2.yml"}
]
job_id = await client.install_packages("Plugin", packages)
```

### update\_packages

```python theme={null}
update_packages(
    package_type: PackageType | str,
    packages: list[PackageSpecInput]
    | list[dict[str, Any]]
    | None = None,
) -> str
```

Update packages.

Parameters:

| Name           | Type                                                     | Description                                                                                                                                                                                                   | Default    |
| -------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| `package_type` | `PackageType \| str`                                     | Type of packages to update (PackageType.SCRAPER or PackageType.PLUGIN)                                                                                                                                        | *required* |
| `packages`     | `list[PackageSpecInput] \| list[dict[str, Any]] \| None` | Optional list of PackageSpecInput objects or dictionaries containing: - id: Package ID (required) - sourceURL: Source URL for the package (required) If None, all packages of the given type will be updated. | `None`     |

Returns:

| Type  | Description                |
| ----- | -------------------------- |
| `str` | Job ID for the update task |

Raises:

| Type             | Description                  |
| ---------------- | ---------------------------- |
| `ValueError`     | If the input data is invalid |
| `TransportError` | If the request fails         |

Examples:

Update all scraper packages:

```python theme={null}
from stash_graphql_client.types import PackageType

job_id = await client.update_packages(PackageType.SCRAPER)
print(f"Update job started: {job_id}")
```

Update specific plugin packages:

```python theme={null}
from stash_graphql_client.types import PackageType, PackageSpecInput

packages = [
    PackageSpecInput(id="plugin-id", source_url="https://example.com/plugin.yml")
]
job_id = await client.update_packages(PackageType.PLUGIN, packages)
```

Update using dictionaries:

```python theme={null}
packages = [
    {"id": "scraper-1", "sourceURL": "https://example.com/scraper1.yml"}
]
job_id = await client.update_packages("Scraper", packages)
```

### uninstall\_packages

```python theme={null}
uninstall_packages(
    package_type: PackageType | str,
    packages: list[PackageSpecInput] | list[dict[str, Any]],
) -> str
```

Uninstall packages.

Parameters:

| Name           | Type                                             | Description                                                                                                                                 | Default    |
| -------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| `package_type` | `PackageType \| str`                             | Type of packages to uninstall (PackageType.SCRAPER or PackageType.PLUGIN)                                                                   | *required* |
| `packages`     | `list[PackageSpecInput] \| list[dict[str, Any]]` | List of PackageSpecInput objects or dictionaries containing: - id: Package ID (required) - sourceURL: Source URL for the package (required) | *required* |

Returns:

| Type  | Description                        |
| ----- | ---------------------------------- |
| `str` | Job ID for the uninstallation task |

Raises:

| Type             | Description                  |
| ---------------- | ---------------------------- |
| `ValueError`     | If the input data is invalid |
| `TransportError` | If the request fails         |

Examples:

Uninstall a scraper package:

```python theme={null}
from stash_graphql_client.types import PackageType, PackageSpecInput

packages = [
    PackageSpecInput(id="package-id", source_url="https://example.com/package.yml")
]
job_id = await client.uninstall_packages(PackageType.SCRAPER, packages)
print(f"Uninstallation job started: {job_id}")
```

Uninstall multiple plugin packages using dictionaries:

```python theme={null}
packages = [
    {"id": "plugin-1", "sourceURL": "https://example.com/plugin1.yml"},
    {"id": "plugin-2", "sourceURL": "https://example.com/plugin2.yml"}
]
job_id = await client.uninstall_packages("Plugin", packages)
```

### installed\_packages

```python theme={null}
installed_packages(
    package_type: PackageType | str,
) -> list[Package]
```

List installed packages.

Parameters:

| Name           | Type                 | Description                                                          | Default    |
| -------------- | -------------------- | -------------------------------------------------------------------- | ---------- |
| `package_type` | `PackageType \| str` | Type of packages to list (PackageType.SCRAPER or PackageType.PLUGIN) | *required* |

Returns:

| Type            | Description                                             |
| --------------- | ------------------------------------------------------- |
| `list[Package]` | List of Package objects representing installed packages |

Raises:

| Type             | Description          |
| ---------------- | -------------------- |
| `TransportError` | If the request fails |

Examples:

List all installed scrapers:

```python theme={null}
from stash_graphql_client.types import PackageType

packages = await client.installed_packages(PackageType.SCRAPER)
for pkg in packages:
    print(f"{pkg.name} v{pkg.version} - {pkg.package_id}")
```

List all installed plugins:

```python theme={null}
packages = await client.installed_packages("Plugin")
print(f"Found {len(packages)} installed plugins")
```

### available\_packages

```python theme={null}
available_packages(
    package_type: PackageType | str, source: str
) -> list[Package]
```

List available packages from a source.

Parameters:

| Name           | Type                 | Description                                                          | Default    |
| -------------- | -------------------- | -------------------------------------------------------------------- | ---------- |
| `package_type` | `PackageType \| str` | Type of packages to list (PackageType.SCRAPER or PackageType.PLUGIN) | *required* |
| `source`       | `str`                | Source URL to query for available packages                           | *required* |

Returns:

| Type            | Description                                             |
| --------------- | ------------------------------------------------------- |
| `list[Package]` | List of Package objects representing available packages |

Raises:

| Type             | Description          |
| ---------------- | -------------------- |
| `TransportError` | If the request fails |

Examples:

List available scrapers from official source:

```python theme={null}
from stash_graphql_client.types import PackageType

packages = await client.available_packages(
    PackageType.SCRAPER,
    "https://stashapp.github.io/scrapers"
)
for pkg in packages:
    print(f"{pkg.name} v{pkg.version} - {pkg.package_id}")
```

List available plugins:

```python theme={null}
packages = await client.available_packages(
    "Plugin",
    "https://stashapp.github.io/plugins"
)
print(f"Found {len(packages)} available plugins")
```
