Skip to content

Fuseki commands

kurra.cli.commands.db.fuseki

CLI commands for administering a Fuseki database.

ping_command

ping_command(fuseki_url: str = typer.Argument(..., help='Fuseki base URL. E.g. http://localhost:3030'), username: str = None, password: str = None, timeout: int = 60) -> None

Check if the Fuseki server is alive.

Parameters:

Name Type Description Default
fuseki_url str

Fuseki base URL. E.g. http://localhost:3030

Argument(..., help='Fuseki base URL. E.g. http://localhost:3030')
username str

Fuseki username, if the server requires authentication.

None
password str

Fuseki password, if the server requires authentication.

None
timeout int

Timeout per request, in seconds.

60

Raises:

Type Description
Exception

If the request to the Fuseki server fails.

Source code in kurra/cli/commands/db/fuseki.py
@app.command(name="ping", help="Check if the server is alive")
def ping_command(
    fuseki_url: str = typer.Argument(
        ..., help="Fuseki base URL. E.g. http://localhost:3030"
    ),
    username: Annotated[
        str, typer.Option("--username", "-u", help="Fuseki username.")
    ] = None,
    password: Annotated[
        str, typer.Option("--password", "-p", help="Fuseki password.")
    ] = None,
    timeout: Annotated[
        int, typer.Option("--timeout", "-t", help="Timeout per request")
    ] = 60,
) -> None:
    """Check if the Fuseki server is alive.

    Args:
        fuseki_url: Fuseki base URL. E.g. http://localhost:3030
        username: Fuseki username, if the server requires authentication.
        password: Fuseki password, if the server requires authentication.
        timeout: Timeout per request, in seconds.

    Raises:
        Exception: If the request to the Fuseki server fails.
    """
    auth = (
        (username, password) if username is not None and password is not None else None
    )

    with httpx.Client(auth=auth, timeout=timeout) as http_client:
        try:
            console.print(describe(fuseki_url, http_client=http_client))
        except Exception as err:
            console.print(
                f"[bold red]ERROR[/bold red] Failed to describe datasets at {fuseki_url}."
            )
            raise err

server_command

server_command(fuseki_url: str = typer.Argument(..., help='Fuseki base URL. E.g. http://localhost:3030'), username: str = None, password: str = None, timeout: int = 60) -> None

Get basic Fuseki server info.

Parameters:

Name Type Description Default
fuseki_url str

Fuseki base URL. E.g. http://localhost:3030

Argument(..., help='Fuseki base URL. E.g. http://localhost:3030')
username str

Fuseki username, if the server requires authentication.

None
password str

Fuseki password, if the server requires authentication.

None
timeout int

Timeout per request, in seconds.

60

Raises:

Type Description
Exception

If the request to the Fuseki server fails.

Source code in kurra/cli/commands/db/fuseki.py
@app.command(name="server", help="Get basic server info")
def server_command(
    fuseki_url: str = typer.Argument(
        ..., help="Fuseki base URL. E.g. http://localhost:3030"
    ),
    username: Annotated[
        str, typer.Option("--username", "-u", help="Fuseki username.")
    ] = None,
    password: Annotated[
        str, typer.Option("--password", "-p", help="Fuseki password.")
    ] = None,
    timeout: Annotated[
        int, typer.Option("--timeout", "-t", help="Timeout per request")
    ] = 60,
) -> None:
    """Get basic Fuseki server info.

    Args:
        fuseki_url: Fuseki base URL. E.g. http://localhost:3030
        username: Fuseki username, if the server requires authentication.
        password: Fuseki password, if the server requires authentication.
        timeout: Timeout per request, in seconds.

    Raises:
        Exception: If the request to the Fuseki server fails.
    """
    auth = (
        (username, password) if username is not None and password is not None else None
    )

    with httpx.Client(auth=auth, timeout=timeout) as http_client:
        try:
            console.print(describe(fuseki_url, http_client=http_client))
        except Exception as err:
            console.print(
                f"[bold red]ERROR[/bold red] Failed to describe datasets at {fuseki_url}."
            )
            raise err

stats_command

stats_command(fuseki_url: str = typer.Argument(..., help='Fuseki base URL. E.g. http://localhost:3030'), username: str = None, password: str = None, timeout: int = 60) -> None

Request statistics for all datasets on the Fuseki server.

Parameters:

Name Type Description Default
fuseki_url str

Fuseki base URL. E.g. http://localhost:3030

Argument(..., help='Fuseki base URL. E.g. http://localhost:3030')
username str

Fuseki username, if the server requires authentication.

None
password str

Fuseki password, if the server requires authentication.

None
timeout int

Timeout per request, in seconds.

60

Raises:

Type Description
Exception

If the request to the Fuseki server fails.

Source code in kurra/cli/commands/db/fuseki.py
@app.command(name="stats", help="Request statistics for all datasets")
def stats_command(
    fuseki_url: str = typer.Argument(
        ..., help="Fuseki base URL. E.g. http://localhost:3030"
    ),
    username: Annotated[
        str, typer.Option("--username", "-u", help="Fuseki username.")
    ] = None,
    password: Annotated[
        str, typer.Option("--password", "-p", help="Fuseki password.")
    ] = None,
    timeout: Annotated[
        int, typer.Option("--timeout", "-t", help="Timeout per request")
    ] = 60,
) -> None:
    """Request statistics for all datasets on the Fuseki server.

    Args:
        fuseki_url: Fuseki base URL. E.g. http://localhost:3030
        username: Fuseki username, if the server requires authentication.
        password: Fuseki password, if the server requires authentication.
        timeout: Timeout per request, in seconds.

    Raises:
        Exception: If the request to the Fuseki server fails.
    """
    auth = (
        (username, password) if username is not None and password is not None else None
    )

    with httpx.Client(auth=auth, timeout=timeout) as http_client:
        try:
            console.print(describe(fuseki_url, http_client=http_client))
        except Exception as err:
            console.print(
                f"[bold red]ERROR[/bold red] Failed to describe datasets at {fuseki_url}."
            )
            raise err

backup_command

backup_command(fuseki_url: str = typer.Argument(..., help='Fuseki base URL. E.g. http://localhost:3030'), username: str = None, password: str = None, timeout: int = 60) -> None

Ask the Fuseki server to create a backup of a dataset.

Parameters:

Name Type Description Default
fuseki_url str

Fuseki base URL. E.g. http://localhost:3030

Argument(..., help='Fuseki base URL. E.g. http://localhost:3030')
username str

Fuseki username, if the server requires authentication.

None
password str

Fuseki password, if the server requires authentication.

None
timeout int

Timeout per request, in seconds.

60

Raises:

Type Description
Exception

If the request to the Fuseki server fails.

Source code in kurra/cli/commands/db/fuseki.py
@app.command(name="backup", help="Ask the server to create a backup")
def backup_command(
    fuseki_url: str = typer.Argument(
        ..., help="Fuseki base URL. E.g. http://localhost:3030"
    ),
    username: Annotated[
        str, typer.Option("--username", "-u", help="Fuseki username.")
    ] = None,
    password: Annotated[
        str, typer.Option("--password", "-p", help="Fuseki password.")
    ] = None,
    timeout: Annotated[
        int, typer.Option("--timeout", "-t", help="Timeout per request")
    ] = 60,
) -> None:
    """Ask the Fuseki server to create a backup of a dataset.

    Args:
        fuseki_url: Fuseki base URL. E.g. http://localhost:3030
        username: Fuseki username, if the server requires authentication.
        password: Fuseki password, if the server requires authentication.
        timeout: Timeout per request, in seconds.

    Raises:
        Exception: If the request to the Fuseki server fails.
    """
    auth = (
        (username, password) if username is not None and password is not None else None
    )

    with httpx.Client(auth=auth, timeout=timeout) as http_client:
        try:
            console.print(describe(fuseki_url, http_client=http_client))
        except Exception as err:
            console.print(
                f"[bold red]ERROR[/bold red] Failed to describe datasets at {fuseki_url}."
            )
            raise err

backups_list_command

backups_list_command(fuseki_url: str = typer.Argument(..., help='Fuseki base URL. E.g. http://localhost:3030'), username: str = None, password: str = None, timeout: int = 60) -> None

List all existing backups on the Fuseki server.

Parameters:

Name Type Description Default
fuseki_url str

Fuseki base URL. E.g. http://localhost:3030

Argument(..., help='Fuseki base URL. E.g. http://localhost:3030')
username str

Fuseki username, if the server requires authentication.

None
password str

Fuseki password, if the server requires authentication.

None
timeout int

Timeout per request, in seconds.

60

Raises:

Type Description
Exception

If the request to the Fuseki server fails.

Source code in kurra/cli/commands/db/fuseki.py
@app.command(name="backups_list", help="List all existing backups")
def backups_list_command(
    fuseki_url: str = typer.Argument(
        ..., help="Fuseki base URL. E.g. http://localhost:3030"
    ),
    username: Annotated[
        str, typer.Option("--username", "-u", help="Fuseki username.")
    ] = None,
    password: Annotated[
        str, typer.Option("--password", "-p", help="Fuseki password.")
    ] = None,
    timeout: Annotated[
        int, typer.Option("--timeout", "-t", help="Timeout per request")
    ] = 60,
) -> None:
    """List all existing backups on the Fuseki server.

    Args:
        fuseki_url: Fuseki base URL. E.g. http://localhost:3030
        username: Fuseki username, if the server requires authentication.
        password: Fuseki password, if the server requires authentication.
        timeout: Timeout per request, in seconds.

    Raises:
        Exception: If the request to the Fuseki server fails.
    """
    auth = (
        (username, password) if username is not None and password is not None else None
    )

    with httpx.Client(auth=auth, timeout=timeout) as http_client:
        try:
            console.print(describe(fuseki_url, http_client=http_client))
        except Exception as err:
            console.print(
                f"[bold red]ERROR[/bold red] Failed to describe datasets at {fuseki_url}."
            )
            raise err

sleep_command

sleep_command(fuseki_url: str = typer.Argument(..., help='Fuseki base URL. E.g. http://localhost:3030'), username: str = None, password: str = None, timeout: int = 60) -> None

Tell the Fuseki server to sleep.

Parameters:

Name Type Description Default
fuseki_url str

Fuseki base URL. E.g. http://localhost:3030

Argument(..., help='Fuseki base URL. E.g. http://localhost:3030')
username str

Fuseki username, if the server requires authentication.

None
password str

Fuseki password, if the server requires authentication.

None
timeout int

Timeout per request, in seconds.

60

Raises:

Type Description
Exception

If the request to the Fuseki server fails.

Source code in kurra/cli/commands/db/fuseki.py
@app.command(name="sleep", help="Tell the server to sleep")
def sleep_command(
    fuseki_url: str = typer.Argument(
        ..., help="Fuseki base URL. E.g. http://localhost:3030"
    ),
    username: Annotated[
        str, typer.Option("--username", "-u", help="Fuseki username.")
    ] = None,
    password: Annotated[
        str, typer.Option("--password", "-p", help="Fuseki password.")
    ] = None,
    timeout: Annotated[
        int, typer.Option("--timeout", "-t", help="Timeout per request")
    ] = 60,
) -> None:
    """Tell the Fuseki server to sleep.

    Args:
        fuseki_url: Fuseki base URL. E.g. http://localhost:3030
        username: Fuseki username, if the server requires authentication.
        password: Fuseki password, if the server requires authentication.
        timeout: Timeout per request, in seconds.

    Raises:
        Exception: If the request to the Fuseki server fails.
    """
    auth = (
        (username, password) if username is not None and password is not None else None
    )

    with httpx.Client(auth=auth, timeout=timeout) as http_client:
        try:
            console.print(describe(fuseki_url, http_client=http_client))
        except Exception as err:
            console.print(
                f"[bold red]ERROR[/bold red] Failed to describe datasets at {fuseki_url}."
            )
            raise err

tasks_command

tasks_command(fuseki_url: str = typer.Argument(..., help='Fuseki base URL. E.g. http://localhost:3030'), username: str = None, password: str = None, timeout: int = 60) -> None

List tasks currently running on the Fuseki server.

Parameters:

Name Type Description Default
fuseki_url str

Fuseki base URL. E.g. http://localhost:3030

Argument(..., help='Fuseki base URL. E.g. http://localhost:3030')
username str

Fuseki username, if the server requires authentication.

None
password str

Fuseki password, if the server requires authentication.

None
timeout int

Timeout per request, in seconds.

60

Raises:

Type Description
Exception

If the request to the Fuseki server fails.

Source code in kurra/cli/commands/db/fuseki.py
@app.command(name="tasks", help="List running tasks")
def tasks_command(
    fuseki_url: str = typer.Argument(
        ..., help="Fuseki base URL. E.g. http://localhost:3030"
    ),
    username: Annotated[
        str, typer.Option("--username", "-u", help="Fuseki username.")
    ] = None,
    password: Annotated[
        str, typer.Option("--password", "-p", help="Fuseki password.")
    ] = None,
    timeout: Annotated[
        int, typer.Option("--timeout", "-t", help="Timeout per request")
    ] = 60,
) -> None:
    """List tasks currently running on the Fuseki server.

    Args:
        fuseki_url: Fuseki base URL. E.g. http://localhost:3030
        username: Fuseki username, if the server requires authentication.
        password: Fuseki password, if the server requires authentication.
        timeout: Timeout per request, in seconds.

    Raises:
        Exception: If the request to the Fuseki server fails.
    """
    auth = (
        (username, password) if username is not None and password is not None else None
    )

    with httpx.Client(auth=auth, timeout=timeout) as http_client:
        try:
            console.print(describe(fuseki_url, http_client=http_client))
        except Exception as err:
            console.print(
                f"[bold red]ERROR[/bold red] Failed to describe datasets at {fuseki_url}."
            )
            raise err

metrics_command

metrics_command(fuseki_url: str = typer.Argument(..., help='Fuseki base URL. E.g. http://localhost:3030'), username: str = None, password: str = None, timeout: int = 60) -> None

Get metrics for the Fuseki server.

Parameters:

Name Type Description Default
fuseki_url str

Fuseki base URL. E.g. http://localhost:3030

Argument(..., help='Fuseki base URL. E.g. http://localhost:3030')
username str

Fuseki username, if the server requires authentication.

None
password str

Fuseki password, if the server requires authentication.

None
timeout int

Timeout per request, in seconds.

60

Raises:

Type Description
Exception

If the request to the Fuseki server fails.

Source code in kurra/cli/commands/db/fuseki.py
@app.command(name="metrics", help="Get server metrics")
def metrics_command(
    fuseki_url: str = typer.Argument(
        ..., help="Fuseki base URL. E.g. http://localhost:3030"
    ),
    username: Annotated[
        str, typer.Option("--username", "-u", help="Fuseki username.")
    ] = None,
    password: Annotated[
        str, typer.Option("--password", "-p", help="Fuseki password.")
    ] = None,
    timeout: Annotated[
        int, typer.Option("--timeout", "-t", help="Timeout per request")
    ] = 60,
) -> None:
    """Get metrics for the Fuseki server.

    Args:
        fuseki_url: Fuseki base URL. E.g. http://localhost:3030
        username: Fuseki username, if the server requires authentication.
        password: Fuseki password, if the server requires authentication.
        timeout: Timeout per request, in seconds.

    Raises:
        Exception: If the request to the Fuseki server fails.
    """
    auth = (
        (username, password) if username is not None and password is not None else None
    )

    with httpx.Client(auth=auth, timeout=timeout) as http_client:
        try:
            console.print(describe(fuseki_url, http_client=http_client))
        except Exception as err:
            console.print(
                f"[bold red]ERROR[/bold red] Failed to describe datasets at {fuseki_url}."
            )
            raise err

describe_command

describe_command(fuseki_url: str = typer.Argument(..., help='Fuseki base URL. E.g. http://localhost:3030'), username: str = None, password: str = None, timeout: int = 60) -> None

Get the list of datasets on the Fuseki server, or describe one.

Parameters:

Name Type Description Default
fuseki_url str

Fuseki base URL. E.g. http://localhost:3030

Argument(..., help='Fuseki base URL. E.g. http://localhost:3030')
username str

Fuseki username, if the server requires authentication.

None
password str

Fuseki password, if the server requires authentication.

None
timeout int

Timeout per request, in seconds.

60

Raises:

Type Description
Exception

If the request to the Fuseki server fails.

Source code in kurra/cli/commands/db/fuseki.py
@app.command(name="describe", help="Get the list of datasets or describe one")
def describe_command(
    fuseki_url: str = typer.Argument(
        ..., help="Fuseki base URL. E.g. http://localhost:3030"
    ),
    username: Annotated[
        str, typer.Option("--username", "-u", help="Fuseki username.")
    ] = None,
    password: Annotated[
        str, typer.Option("--password", "-p", help="Fuseki password.")
    ] = None,
    timeout: Annotated[
        int, typer.Option("--timeout", "-t", help="Timeout per request")
    ] = 60,
) -> None:
    """Get the list of datasets on the Fuseki server, or describe one.

    Args:
        fuseki_url: Fuseki base URL. E.g. http://localhost:3030
        username: Fuseki username, if the server requires authentication.
        password: Fuseki password, if the server requires authentication.
        timeout: Timeout per request, in seconds.

    Raises:
        Exception: If the request to the Fuseki server fails.
    """
    auth = (
        (username, password) if username is not None and password is not None else None
    )

    with httpx.Client(auth=auth, timeout=timeout) as http_client:
        try:
            console.print(describe(fuseki_url, http_client=http_client))
        except Exception as err:
            console.print(
                f"[bold red]ERROR[/bold red] Failed to describe datasets at {fuseki_url}."
            )
            raise err

create_command

create_command(fuseki_url: str = typer.Argument(..., help='Fuseki base URL. E.g. http://localhost:3030'), dataset_name: str | None = typer.Argument(None, help='repository name'), dataset_type: str = typer.Option('tdb2', help=f'dataset type. Options: {dataset_type_options}'), config: Path | None = typer.Option(None, help='assembler file'), username: str = None, password: str = None, timeout: int = 60) -> None

Create a new dataset on the Fuseki server.

Either dataset_name or config must be given, not both.

Parameters:

Name Type Description Default
fuseki_url str

Fuseki base URL. E.g. http://localhost:3030

Argument(..., help='Fuseki base URL. E.g. http://localhost:3030')
dataset_name str | None

The name of the dataset to create, using dataset_type.

Argument(None, help='repository name')
dataset_type str

The dataset type to create, when dataset_name is given. Options: mem, tdb, tdb1, tdb2.

Option('tdb2', help=f'dataset type. Options: {dataset_type_options}')
config Path | None

An assembler file describing the dataset to create, as an alternative to dataset_name.

Option(None, help='assembler file')
username str

Fuseki username, if the server requires authentication.

None
password str

Fuseki password, if the server requires authentication.

None
timeout int

Timeout per request, in seconds.

60

Raises:

Type Description
BadParameter

If both dataset_name and config are given, if neither is given, or if dataset_type is not a valid option.

Exception

If the request to the Fuseki server fails.

Source code in kurra/cli/commands/db/fuseki.py
@app.command(name="create", help="Create a new dataset")
def create_command(
    fuseki_url: str = typer.Argument(
        ..., help="Fuseki base URL. E.g. http://localhost:3030"
    ),
    dataset_name: str | None = typer.Argument(None, help="repository name"),
    dataset_type: str = typer.Option(
        "tdb2", help=f"dataset type. Options: {dataset_type_options}"
    ),
    config: Path | None = typer.Option(None, help="assembler file"),
    username: Annotated[
        str, typer.Option("--username", "-u", help="Fuseki username.")
    ] = None,
    password: Annotated[
        str, typer.Option("--password", "-p", help="Fuseki password.")
    ] = None,
    timeout: Annotated[
        int, typer.Option("--timeout", "-t", help="Timeout per request")
    ] = 60,
) -> None:
    """Create a new dataset on the Fuseki server.

    Either `dataset_name` or `config` must be given, not both.

    Args:
        fuseki_url: Fuseki base URL. E.g. http://localhost:3030
        dataset_name: The name of the dataset to create, using `dataset_type`.
        dataset_type: The dataset type to create, when `dataset_name` is given. Options: `mem`, `tdb`, `tdb1`, `tdb2`.
        config: An assembler file describing the dataset to create, as an alternative to `dataset_name`.
        username: Fuseki username, if the server requires authentication.
        password: Fuseki password, if the server requires authentication.
        timeout: Timeout per request, in seconds.

    Raises:
        typer.BadParameter: If both `dataset_name` and `config` are given, if neither is given, or if `dataset_type` is not a valid option.
        Exception: If the request to the Fuseki server fails.
    """
    auth = (
        (username, password) if username is not None and password is not None else None
    )

    if dataset_name and config:
        raise typer.BadParameter("Only dataset name or --config is allowed, not both.")

    if dataset_name and dataset_type not in dataset_type_options:
        raise typer.BadParameter(
            f"Invalid dataset type '{dataset_type}'. Options: {dataset_type_options}"
        )

    if dataset_name:
        with httpx.Client(auth=auth, timeout=timeout) as http_client:
            try:
                console.print(
                    create(
                        fuseki_url, dataset_name, dataset_type, http_client=http_client
                    )
                )
            except Exception as err:
                console.print(
                    f"[bold red]ERROR[/bold red] Failed to create dataset {dataset_name} at {fuseki_url}."
                )
                raise err
    else:
        if config is None:
            raise typer.BadParameter(
                "Either dataset name or assembler config file must be provided."
            )
        with httpx.Client(auth=auth, timeout=timeout) as http_client:
            try:
                console.print(create(fuseki_url, config, http_client=http_client))
            except Exception as err:
                console.print(
                    f"[bold red]ERROR[/bold red] Failed to create dataset {dataset_name} at {fuseki_url}."
                )
                raise err

delete_command

delete_command(fuseki_url: str = typer.Argument(..., help='Fuseki base URL. E.g. http://localhost:3030'), dataset_name: str = typer.Argument(..., help='The name of the dataset to delete.'), username: str = None, password: str = None, timeout: int = 60)

Delete a dataset from the Fuseki server.

Parameters:

Name Type Description Default
fuseki_url str

Fuseki base URL. E.g. http://localhost:3030

Argument(..., help='Fuseki base URL. E.g. http://localhost:3030')
dataset_name str

The name of the dataset to delete.

Argument(..., help='The name of the dataset to delete.')
username str

Fuseki username, if the server requires authentication.

None
password str

Fuseki password, if the server requires authentication.

None
timeout int

Timeout per request, in seconds.

60

Raises:

Type Description
FusekiError

If the dataset fails to delete.

Source code in kurra/cli/commands/db/fuseki.py
@app.command(name="delete", help="Delete a dataset")
def delete_command(
    fuseki_url: str = typer.Argument(
        ..., help="Fuseki base URL. E.g. http://localhost:3030"
    ),
    dataset_name: str = typer.Argument(..., help="The name of the dataset to delete."),
    username: Annotated[
        str, typer.Option("--username", "-u", help="Fuseki username.")
    ] = None,
    password: Annotated[
        str, typer.Option("--password", "-p", help="Fuseki password.")
    ] = None,
    timeout: Annotated[
        int, typer.Option("--timeout", "-t", help="Timeout per request")
    ] = 60,
):
    """Delete a dataset from the Fuseki server.

    Args:
        fuseki_url: Fuseki base URL. E.g. http://localhost:3030
        dataset_name: The name of the dataset to delete.
        username: Fuseki username, if the server requires authentication.
        password: Fuseki password, if the server requires authentication.
        timeout: Timeout per request, in seconds.

    Raises:
        FusekiError: If the dataset fails to delete.
    """
    auth = (
        (username, password) if username is not None and password is not None else None
    )

    with httpx.Client(auth=auth, timeout=timeout) as http_client:
        try:
            console.print(delete(fuseki_url, dataset_name, http_client=http_client))
        except FusekiError as err:
            console.print(
                f"[bold red]ERROR[/bold red] Failed to delete dataset {dataset_name} at {fuseki_url}."
            )
            raise err