PrivMX DOCS
API Reference/PrivMX Endpoint Swift Extra/Kvdb

KvdbApi

‘KvdbApi’ is a class representing Endpoint’s API for Kvdbs and their messages.

Methods

createKvdb(in:for:managedBy:withPublicMeta:withPrivateMeta:withPolicies:)

Creates a new KVDB in given Context.

Params

contextId

String

ID of the Context to create the KVDB in

users

[privmx.endpoint.core.UserWithPubKey]

array of UserWithPubKey structs which indicates who will have access to the created KVDB

managers

[privmx.endpoint.core.UserWithPubKey]

array of UserWithPubKey structs which indicates who will have access (and management rights) to the created KVDB

publicMeta

Data

public (unencrypted) metadata

privateMeta

Data

private (encrypted) metadata

policies

privmx.endpoint.core.ContainerPolicy?

KVDB’s policies

public func createKvdb(
in contextId: String,
for users: [privmx.endpoint.core.UserWithPubKey],
managedBy managers: [privmx.endpoint.core.UserWithPubKey],
withPublicMeta publicMeta: Data,
withPrivateMeta privateMeta: Data,
withPolicies policies: privmx.endpoint.core.ContainerPolicy? = nil
) throws -> String

Returns

String · Id of the created KVDB

updateKvdb(_:atVersion:replacingUsers:replacingManagers:replacingPublicMeta:replacingPrivateMeta:force:forceGenerateNewKey:replacingPolicies:)

Updates an existing KVDB.

Params

kvdbId

String

ID of the KVDB to update

version

Int64

current version of the updated KVDB

users

[privmx.endpoint.core.UserWithPubKey]

array of UserWithPubKey structs which indicates who will have access to the created KVDB

managers

[privmx.endpoint.core.UserWithPubKey]

array of UserWithPubKey structs which indicates who will have access (and management rights) to the created KVDB

publicMeta

Data

public (unencrypted) metadata

privateMeta

Data

private (encrypted) metadata

force

Bool

force update (without checking version)

forceGenerateNewKey

Bool

force to regenerate a key for the KVDB

policies

privmx.endpoint.core.ContainerPolicy?

KVDB’s policies

public func updateKvdb(
_ kvdbId: String,
atVersion version: Int64,
replacingUsers users: [privmx.endpoint.core.UserWithPubKey],
replacingManagers managers: [privmx.endpoint.core.UserWithPubKey],
replacingPublicMeta publicMeta: Data,
replacingPrivateMeta privateMeta: Data,
force: Bool,
forceGenerateNewKey:Bool,
replacingPolicies policies: privmx.endpoint.core.ContainerPolicy? = nil
) throws -> Void

deleteKvdb(_:)

Deletes a KVDB by given KVDB ID.

Params

kvdbId

String

ID of the KVDB to delete

public func deleteKvdb(
_ kvdbId: String
) throws -> Void

getKvdb(_:)

Gets a KVDB by given KVDB ID.

Params

kvdbId

String

ID of KVDB to get

public func getKvdb(
_ kvdbId: String
) throws -> privmx.endpoint.kvdb.Kvdb

Returns

privmx.endpoint.kvdb.Kvdb · struct containing info about the KVDB

listKvdbs(from:basedOn:)

Gets a list of Kvdbs in given Context.

Params

contextId

String

ID of the Context to get the Kvdbs from

pagingQuery

privmx.endpoint.core.PagingQuery

with list query parameters

public func listKvdbs(
from contextId: String,
basedOn pagingQuery: privmx.endpoint.core.PagingQuery
) throws -> privmx.KvdbList

Returns

privmx.KvdbList · struct containing a list of Kvdbs

hasEntry(kvdbId:key:)

Check whether the KVDB entry exists.

Params

kvdbId

String

KVDB ID of the KVDB entry to check

key

String

key of the KVDB entry to check

public func hasEntry(
kvdbId: String,
key: String
) throws -> Bool

Returns

Bool · ‘true’ if the KVDB has an entry with given key, ‘false’ otherwise

getEntry(from:for:)

Gets a KVDB entry by given KVDB entry key and KVDB ID.

Params

kvdbId

String

KVDB ID of the KVDB entry to get

key

String

key of the KVDB entry to get

public func getEntry(
from kvdbId: String,
for key: String,
) throws -> privmx.endpoint.kvdb.KvdbEntry

Returns

privmx.endpoint.kvdb.KvdbEntry · struct containing the KVDB entry

listEntriesKeys(from:basedOn:)

Gets a list of KVDB entries keys from a KVDB.

Params

kvdbId

String

ID of the KVDB to list KVDB entries from

pagingQuery

privmx.endpoint.core.PagingQuery

with list query parameters

public func listEntriesKeys(
from kvdbId: String,
basedOn pagingQuery: privmx.endpoint.core.PagingQuery
) throws -> privmx.StringList

Returns

privmx.StringList · struct containing a list of KVDB entries

listEntries(from:basedOn:)

Gets a list of KVDB entries from a KVDB.

Params

kvdbId

String

ID of the KVDB to list KVDB entries from

pagingQuery

privmx.endpoint.core.PagingQuery

with list query parameters

public func listEntries(
from kvdbId: String,
basedOn pagingQuery: privmx.endpoint.core.PagingQuery
) throws -> privmx.KvdbEntryList

Returns

privmx.KvdbEntryList · struct containing a list of KVDB entries

setEntry(in:for:atVersion:withPublicMeta:withPrivateMeta:containing:)

Sets a KVDB entry in the given KVDB.

Params

kvdbId

String

ID of the KVDB to set the entry to

key

String

KVDB entry key

version

Int64

the version of the Entry to set, the default value is 0 for creating a new KVDB Entry

publicMeta

Data

public KVDB entry metadata

privateMeta

Data

private KVDB entry metadata

data

Data

content of the KVDB entry

public func setEntry(
in kvdbId: String,
for key: String,
atVersion version: Int64 = 0,
withPublicMeta publicMeta: Data,
withPrivateMeta privateMeta: Data,
containing data: Data
) throws -> Void

deleteEntry(from:for:)

Deletes a KVDB entry by given KVDB entry ID.

Params

kvdbId

String

KVDB ID of the KVDB entry to delete

key

String

key of the KVDB entry to delete

public func deleteEntry(
from kvdbId: String,
for key: String
) throws -> Void

deleteEntries(from:for:)

Deletes KVDB entries by given KVDB IDs and the list of entry keys.

Params

kvdbId

String

ID of the KVDB database to delete from

keys

[String]

vector of the keys of the KVDB entries to delete

public func deleteEntries(
from kvdbId: String,
for keys: [String]
) throws -> [String:Bool]

Returns

[String : Bool] · map with the statuses of deletion for every key

subscribeForEntryEvents(in:)

Subscribes for events in given KVDB.

Params

kvdbId

String

ID of the KVDB to subscribe

public func subscribeForEntryEvents(
in kvdbId: String
) throws -> Void

unsubscribeFromEntryEvents(in:)

Unsubscribes from events in given KVDB.

Params

kvdbId

String

ID of the KVDB to unsubscribe

public func unsubscribeFromEntryEvents(
in kvdbId: String
) throws -> Void

We use cookies on our website. We use them to ensure the proper functioning of the site and, if you agree, for purposes we set, such as analytics or marketing.