pyonepassword 3.6.0: now with multiple item deletion

Options
zcutlip
zcutlip
Community Member
edited March 2023 in CLI

Hey there fellow CLI users. Apologies for the crosspost. I wanted to share the release of pyonepassword 3.6.0.

In response to a question posted here, I've added the ability to delete multiple items from a vault in one method call. It's much faster than looping over a list of items, deleting one at a time.

In addition to a mandatory vault argument, you may optionally select items for deletion by tags, item category, and/or a name-matching glob pattern. (the glob pattern follows the same rules as fnmatch())

Under the hood this method deletes items in batches defaulting to 25 items. So a request to delete 100 items, would, behind the scenes, delete those items in four passes. This is tunable by a kwarg in case users see performance benefits with smaller or larger batches.

Here are some examples:

from pyonepassword import OP

op = OP()

vault = "Test Data"

# delete all items from vault "Test Data"
op.item_delete_multiple(vault)


# delete all items tagged 'tag_1' or 'tag_2'
op.item_delete_multiple(vault, tags=["tag_1", "tag_2"])


# delete all items of category "server"
# server arguments may be any argument accepted by 'op item list --categories'
op.item_delete_multiple(vault, categories=["server"])


# Delete all items matching glob pattern "My*Login", including:
# - My New Login
# - My Old Login
# - My Spiffy Login
op.item_delete_multiple(vault, title_glob="My*Login")


# Delete all items from the vault, including previouly archived items:
op.item_delete_multiple(vault, include_archive=True)


# Delete all items from the vault, moving them to the archive
# rather than permanently deleting
op.item_delete_multiple(vault, archive=True)


# Delete items in batches of 40, rather than the default of 25
op.item_delete_multiple(vault, batch_size=40)

Hope people find this useful! Let me know if you have any questions, and don't hesitate to file GitHub issues on any problems or feature requests.

Cheers,
Zach


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Browser:_ Not Provided

This discussion has been closed.