Secret.Item¶
- Subclasses:
None
Methods¶
- Inherited:
Gio.DBusProxy (25), GObject.Object (37), Gio.AsyncInitable (4), Gio.DBusInterface (3), Gio.Initable (2), Secret.Retrievable (7)
- Structs:
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
Item flags |
||
r |
Item locked |
||
r/w/co |
Secret Service |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Secret.Item(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A secret item
Secret.Item
represents a secret item stored in the Secret Service.Each item has a value, represented by a [struct`Value`], which can be retrieved by [method`Item`.get_secret] or set by [method`Item`.set_secret]. The item is only available when the item is not locked.
Items can be locked or unlocked using the [method`Service`.lock] or [method`Service`.unlock] functions. The Secret Service may not be able to unlock individual items, and may unlock an entire collection when a single item is unlocked.
Each item has a set of attributes, which are used to locate the item later. These are not stored or transferred in a secure manner. Each attribute has a string name and a string value. Use [method`Service`.search] to search for items based on their attributes, and [method`Item`.set_attributes] to change the attributes associated with an item.
Items can be created with [func`Item`.create] or [method`Service`.store].
- classmethod create(collection, schema, attributes, label, value, flags, cancellable, callback, *user_data)¶
- Parameters:
collection (
Secret.Collection
) – a secret collection to create this item inschema (
Secret.Schema
orNone
) – the schema for the attributeslabel (
str
) – label for the new itemvalue (
Secret.Value
) – secret value for the new itemflags (
Secret.ItemCreateFlags
) – flags for the creation of the new itemcancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completes
Create a new item in the secret service.
If the flags contains
Secret.ItemCreateFlags.REPLACE
, then the secret service will search for an item matching the attributes, and update that item instead of creating a new one.This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. [method`Service`.prompt] will be used to handle any prompts that are required.
- classmethod create_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – the asynchronous result passed to the callback- Raises:
- Returns:
the new item, which should be unreferenced with [method`GObject`.Object.unref]
- Return type:
Finish operation to create a new item in the secret service.
- classmethod create_sync(collection, schema, attributes, label, value, flags, cancellable)¶
- Parameters:
collection (
Secret.Collection
) – a secret collection to create this item inschema (
Secret.Schema
orNone
) – the schema for the attributeslabel (
str
) – label for the new itemvalue (
Secret.Value
) – secret value for the new itemflags (
Secret.ItemCreateFlags
) – flags for the creation of the new itemcancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
the new item, which should be unreferenced with [method`GObject`.Object.unref]
- Return type:
Create a new item in the secret service.
If the flags contains
Secret.ItemCreateFlags.REPLACE
, then the secret service will search for an item matching the attributes, and update that item instead of creating a new one.This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. [method`Service`.prompt] will be used to handle any prompts that are required.
- classmethod load_secrets(items, cancellable, callback, *user_data)¶
- Parameters:
items ([
Secret.Item
]) – the items to retrieve secrets forcancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completes
Load the secret values for a secret item stored in the service.
The items must all have the same [property`Item`:py:data::service<Secret.Item.props.service>] property.
This function returns immediately and completes asynchronously.
- classmethod load_secrets_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – asynchronous result passed to callback- Raises:
- Returns:
whether the operation succeeded or not
- Return type:
Complete asynchronous operation to load the secret values for secret items stored in the service.
Items that are locked will not have their secrets loaded.
- classmethod load_secrets_sync(items, cancellable)¶
- Parameters:
items ([
Secret.Item
]) – the items to retrieve secrets forcancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
whether the operation succeeded or not
- Return type:
Load the secret values for a secret item stored in the service.
The items must all have the same [property`Item`:py:data::service<Secret.Item.props.service>] property.
This method may block indefinitely and should not be used in user interface threads.
Items that are locked will not have their secrets loaded.
- delete(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completes
Delete this item.
This method returns immediately and completes asynchronously. The secret service may prompt the user. [method`Service`.prompt] will be used to handle any prompts that show up.
- delete_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – asynchronous result passed to the callback- Raises:
- Returns:
whether the item was successfully deleted or not
- Return type:
Complete asynchronous operation to delete the secret item.
- delete_sync(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optional cancellation object- Raises:
- Returns:
whether the item was successfully deleted or not
- Return type:
Delete this secret item.
This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. [method`Service`.prompt] will be used to handle any prompts that show up.
- get_attributes()¶
- Returns:
a new reference to the attributes, which should not be modified, and released with [func`GLib`.HashTable.unref]
- Return type:
Set the attributes of this item.
The attributes are a mapping of string keys to string values. Attributes are used to search for items. Attributes are not stored or transferred securely by the secret service.
Do not modify the attributes returned by this method. Use [method`Item`.set_attributes] instead.
- get_created()¶
- Returns:
the created date and time
- Return type:
Get the created date and time of the item.
The return value is the number of seconds since the unix epoch, January 1st 1970.
- get_flags()¶
- Returns:
the flags for features initialized
- Return type:
Get the flags representing what features of the
Secret.Item
proxy have been initialized.Use [method`Item`.load_secret] to initialize further features and change the flags.
- get_label()¶
- Returns:
the label, which should be freed with [func`GLib`.free]
- Return type:
Get the label of this item.
- get_locked()¶
- Returns:
whether the item is locked or not
- Return type:
Get whether the item is locked or not.
Depending on the secret service an item may not be able to be locked independently from the collection that it is in.
- get_modified()¶
- Returns:
the modified date and time
- Return type:
Get the modified date and time of the item.
The return value is the number of seconds since the unix epoch, January 1st 1970.
- get_schema_name()¶
-
Gets the name of the schema that this item was stored with. This is also available at the
xdg:schema
attribute.
- get_secret()¶
- Returns:
the secret value which should be released with [method`Value`.unref], or
None
- Return type:
Secret.Value
orNone
Get the secret value of this item.
If this item is locked or the secret has not yet been loaded then this will return
None
.To load the secret call the [method`Item`.load_secret] method.
- get_service()¶
- Returns:
the Secret Service object
- Return type:
Get the Secret Service object that this item was created with.
- load_secret(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completes
Load the secret value of this item.
Each item has a single secret which might be a password or some other secret binary value.
This function will fail if the secret item is locked.
This function returns immediately and completes asynchronously.
- load_secret_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – asynchronous result passed to callback- Raises:
- Returns:
whether the secret item successfully loaded or not
- Return type:
Complete asynchronous operation to load the secret value of this item.
The newly loaded secret value can be accessed by calling [method`Item`.get_secret].
- load_secret_sync(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optional cancellation object- Raises:
- Returns:
whether the secret item successfully loaded or not
- Return type:
Load the secret value of this item.
Each item has a single secret which might be a password or some other secret binary value.
This function may block indefinitely. Use the asynchronous version in user interface threads.
- refresh()¶
Refresh the properties on this item.
This fires off a request to refresh, and the properties will be updated later.
Calling this method is not normally necessary, as the secret service will notify the client when properties change.
- set_attributes(schema, attributes, cancellable, callback, *user_data)¶
- Parameters:
schema (
Secret.Schema
orNone
) – the schema for the attributescancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the asynchronous operation completes
Set the attributes of this item.
The attributes are a mapping of string keys to string values. Attributes are used to search for items. Attributes are not stored or transferred securely by the secret service.
This function returns immediately and completes asynchronously.
- set_attributes_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – asynchronous result passed to the callback- Raises:
- Returns:
whether the change was successful or not
- Return type:
Complete operation to set the attributes of this item.
- set_attributes_sync(schema, attributes, cancellable)¶
- Parameters:
schema (
Secret.Schema
orNone
) – the schema for the attributescancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
whether the change was successful or not
- Return type:
Set the attributes of this item.
The attributes are a mapping of string keys to string values. Attributes are used to search for items. Attributes are not stored or transferred securely by the secret service.
This function may block indefinitely. Use the asynchronous version in user interface threads.
- set_label(label, cancellable, callback, *user_data)¶
- Parameters:
label (
str
) – a new labelcancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completes
Set the label of this item.
This function returns immediately and completes asynchronously.
- set_label_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – asynchronous result passed to callback- Raises:
- Returns:
whether the change was successful or not
- Return type:
Complete asynchronous operation to set the label of this collection.
- set_label_sync(label, cancellable)¶
- Parameters:
label (
str
) – a new labelcancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
whether the change was successful or not
- Return type:
Set the label of this item.
This function may block indefinitely. Use the asynchronous version in user interface threads.
- set_secret(value, cancellable, callback, *user_data)¶
- Parameters:
value (
Secret.Value
) – a new secret valuecancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completes
Set the secret value of this item.
Each item has a single secret which might be a password or some other secret binary value.
This function returns immediately and completes asynchronously.
- set_secret_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – asynchronous result passed to callback- Raises:
- Returns:
whether the change was successful or not
- Return type:
Complete asynchronous operation to set the secret value of this item.
- set_secret_sync(value, cancellable)¶
- Parameters:
value (
Secret.Value
) – a new secret valuecancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
whether the change was successful or not
- Return type:
Set the secret value of this item.
Each item has a single secret which might be a password or some other secret binary value.
This function may block indefinitely. Use the asynchronous version in user interface threads.
Property Details¶
- Secret.Item.props.flags¶
- Name:
flags
- Type:
- Default Value:
- Flags:
A set of flags describing which parts of the secret item have been initialized.
- Secret.Item.props.locked¶
-
Whether the item is locked or not.
An item may not be independently lockable separate from other items in its collection.
To lock or unlock a item use the [method`Service`.lock] or [method`Service`.unlock] functions.
- Secret.Item.props.service¶
- Name:
service
- Type:
- Default Value:
- Flags:
The [class`Service`] object that this item is associated with and uses to interact with the actual D-Bus Secret Service.