The secretstorage.item module

SecretStorage item contains a secret, some attributes and a label visible to user. Editing all these properties and reading the secret is possible only when the collection storing the item is unlocked. The collection can be unlocked using collection’s unlock() method.

class secretstorage.item.Item(connection: jeepney.integrate.blocking.DBusConnection, item_path: str, session: Union[secretstorage.dhcrypto.Session, NoneType] = None)[source]

Represents a secret item.

delete() → None[source]

Deletes the item.

ensure_not_locked() → None[source]

If collection is locked, raises LockedException.

get_attributes() → Dict[str, str][source]

Returns item attributes (dictionary).

get_created() → int[source]

Returns UNIX timestamp (integer) representing the time when the item was created.

New in version 1.1.

get_label() → str[source]

Returns item label (unicode string).

get_modified() → int[source]

Returns UNIX timestamp (integer) representing the time when the item was last modified.

get_secret() → bytes[source]

Returns item secret (bytestring).

get_secret_content_type() → str[source]

Returns content type of item secret (string).

is_locked() → bool[source]

Returns True if item is locked, otherwise False.

set_attributes(attributes: Dict[str, str]) → None[source]

Sets item attributes to attributes (dictionary).

set_label(label: str) → None[source]

Sets item label to label.

set_secret(secret: bytes, content_type: str = 'text/plain') → None[source]

Sets item secret to secret. If content_type is given, also sets the content type of the secret (text/plain by default).

unlock() → bool[source]

Requests unlocking the item. Usually, this means that the whole collection containing this item will be unlocked.

Returns a boolean representing whether the prompt has been dismissed; that means False on successful unlocking and True if it has been dismissed.

New in version 2.1.2.

Changed in version 3.0: No longer accepts the callback argument.