# 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: DBusConnection, item_path: str, session: Session | None = None)

  Represents a secret item.

  delete() → None

    Deletes the item.

  ensure_not_locked() → None

    If collection is locked, raises `LockedException`.

  get_attributes() → dict[str, str]

    Returns item attributes (dictionary).

  get_created() → int

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

    Added in version 1.1.

  get_label() → str

    Returns item label (unicode string).

  get_modified() → int

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

  get_secret() → bytes

    Returns item secret (bytestring).

  get_secret_content_type() → str

    Returns content type of item secret (string).

  is_locked() → bool

    Returns `True` if item is locked, otherwise `False`.

  set_attributes(attributes: dict[str, str]) → None

    Sets item attributes to attributes (dictionary).

  set_label(label: str) → None

    Sets item label to label.

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

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

  unlock(timeout: float | None = None) → bool

    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.

    Raises:

      `TimeoutError` if timeout (in seconds) passed and the prompt was neither accepted nor dismissed.

    Added in version 2.1.2.

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

    Changed in version 3.5: Added `timeout` argument.