Skip to content

Commit

Permalink
fixup! nethsm: Add support for namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-nitrokey committed May 16, 2024
1 parent 01f7c9c commit d6f64ad
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions pynitrokey/cli/nethsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,47 @@ def delete_user(ctx: Context, user_id: str) -> None:
print(f"User {user_id} deleted on NetHSM {nethsm.host}")


@nethsm.command()
@click.pass_context
def list_namespaces(ctx: Context) -> None:
"""List all namespaces on the NetHSM.
This command requires authentication as a user with the Administrator
role."""
with connect(ctx) as nethsm:
namespaces = nethsm.list_namespaces()

print(f"Namespaces on NetHSM {nethsm.host}:")
for namespace in namespaces:
print(f"- {namespace}")


@nethsm.command()
@click.argument("namespace")
@click.pass_context
def add_namespace(ctx: Context, namespace: str) -> None:
"""Add a new namespace on the NetHSM.
This command requires authentication as a user with the Administrator
role."""
with connect(ctx) as nethsm:
nethsm.add_namespace(namespace)
print(f"Namespace {namespace} added to NetHSM {nethsm.host}")


@nethsm.command()
@click.argument("namespace")
@click.pass_context
def delete_namespace(ctx: Context, namespace: str) -> None:
"""Delete a namespace on the NetHSM.
This command requires authentication as a user with the Administrator
role."""
with connect(ctx) as nethsm:
nethsm.delete_namespace(namespace)
print(f"Namespace {namespace} deleted on NetHSM {nethsm.host}")


@nethsm.command()
@click.option("-u", "--user-id", help="The user ID of the user")
@click.option(
Expand Down

0 comments on commit d6f64ad

Please sign in to comment.