Skip to main content
reference

StoreApi

Swift wrapper for privmx.NativeStoreApiWrapper, providing functionality to manage Stores and files within PrivMX platform.

Static Methods

create(connection:)

Creates a new instance of `StoreApi` from a connection object. This method initializes the `StoreApi` instance, enabling Store-related operations over the specified connection.

public static func create(
connection: inout Connection
) throws -> StoreApi

NameTypeDescription
connectioninout ConnectionThe connection object used for Store operations.

TypeDescription
StoreApi A newly created `StoreApi` instance.

Methods

listStores(contextId:query:)

Lists all Stores the user has access to within a specified Context.

public func listStores(
contextId: std.string,
query: privmx.endpoint.core.PagingQuery
) throws -> privmx.StoreList

NameTypeDescription
contextIdstd.stringThe Context from which the Stores should be listed.
queryprivmx.endpoint.core.PagingQueryA `PagingQuery` object to filter and paginate the results.

TypeDescription
privmx.StoreList A `privmx.StoreList` instance containing the list of Stores.

getStore(storeId:)

Retrieves detailed information about a specified Store.

public func getStore(
storeId: std.string
) throws -> privmx.endpoint.store.Store

NameTypeDescription
storeIdstd.stringThe unique identifier of the Store to retrieve.

TypeDescription
privmx.endpoint.store.Store A `privmx.endpoint.store.Store` instance containing Store details.

createStore(contextId:users:managers:publicMeta:privateMeta:)

Creates a new Store within a specified Context. This method creates a new Store with specified users and managers. Note that managers must be added as users to gain access to the Store.

public func createStore(
contextId: std.string,
users: privmx.UserWithPubKeyVector,
managers: privmx.UserWithPubKeyVector,
publicMeta: privmx.endpoint.core.Buffer,
privateMeta: privmx.endpoint.core.Buffer
) throws -> std.string

NameTypeDescription
contextIdstd.stringThe Context in which the Store should be created.
usersprivmx.UserWithPubKeyVectorA vector of users who will have access to the Store.
managersprivmx.UserWithPubKeyVectorA vector of managers responsible for the Store.
publicMetaprivmx.endpoint.core.BufferPublic metadata for the Store, which will not be encrypted.
privateMetaprivmx.endpoint.core.BufferPrivate metadata for the Store, which will be encrypted.

TypeDescription
std.string The ID of the newly created Store as a `std.string`.

updateStore(storeId:version:users:managers:publicMeta:privateMeta:force:forceGenerateNewKey:)

Updates an existing Store. The provided values will override the existing ones. You can also force regeneration of the Store’s key if needed.

public func updateStore(
storeId: std.string,
version: Int64,
users: privmx.UserWithPubKeyVector,
managers: privmx.UserWithPubKeyVector,
publicMeta: privmx.endpoint.core.Buffer,
privateMeta: privmx.endpoint.core.Buffer,
force: Bool,
forceGenerateNewKey: Bool
) throws -> Void

NameTypeDescription
storeIdstd.stringThe unique identifier of the Store to be updated.
versionInt64The current version of the Store for consistency checking.
usersprivmx.UserWithPubKeyVectorA vector of users who will have access to the Store.
managersprivmx.UserWithPubKeyVectorA vector of managers responsible for the Store.
publicMetaprivmx.endpoint.core.BufferNew public metadata for the Store, which will not be encrypted.
privateMetaprivmx.endpoint.core.BufferNew private metadata for the Store, which will be encrypted.
forceBoolWhether to force the update, bypassing version control.
forceGenerateNewKeyBoolWhether to generate a new key for the Store.

deleteStore(storeId:)

Deletes a specified Store.

public func deleteStore(
storeId: std.string
) throws -> Void

NameTypeDescription
storeIdstd.stringThe unique identifier of the Store to delete.

getFile(fileId:)

Retrieves detailed information about a specified file.

public func getFile(
fileId: std.string
) throws -> privmx.endpoint.store.File

NameTypeDescription
fileIdstd.stringThe unique identifier of the file to retrieve.

TypeDescription
privmx.endpoint.store.File A `privmx.endpoint.store.File` instance representing the file details.

listFiles(storeId:query:)

Lists all files in a specified Store. This method retrieves metadata about files in the Store. To download files, use the `openFile()` and `readFile()` methods.

public func listFiles(
storeId: std.string,
query: privmx.endpoint.core.PagingQuery
) throws -> privmx.FileList

NameTypeDescription
storeIdstd.stringThe Store from which to list files.
queryprivmx.endpoint.core.PagingQueryA `PagingQuery` object to filter and paginate the results.

TypeDescription
privmx.FileList A `privmx.FileList` instance containing the list of files.

createFile(storeId:publicMeta:privateMeta:size:)

Creates a new file handle for writing in a Store. Use `writeToFile()` to upload data to this handle and `closeFile()` to finalize the process.

public func createFile(
storeId: std.string,
publicMeta:privmx.endpoint.core.Buffer,
privateMeta:privmx.endpoint.core.Buffer,
size: Int64
) throws -> privmx.StoreFileHandle

NameTypeDescription
storeIdstd.stringThe Store in which the file should be created.
publicMetaprivmx.endpoint.core.BufferPublic metadata for the file.
privateMetaprivmx.endpoint.core.BufferPrivate metadata for the file.
sizeInt64The size of the file in bytes.

TypeDescription
privmx.StoreFileHandle A `privmx.StoreFileHandle` for writing to the file.

seekInFile(handle:position:)

Moves the read cursor within an open file.

public func seekInFile(
handle: privmx.StoreFileHandle,
position: Int64
) throws -> Void

NameTypeDescription
handleprivmx.StoreFileHandleThe handle to the open file.
positionInt64The new position of the read cursor in bytes.

updateFile(fileId:publicMeta:privateMeta:size:)

Updates an existing file within a Store. This method creates a new handle for updating the file’s content and metadata. Use `writeToFile()` to upload data and `closeFile()` to finalize the update.

public func updateFile(
fileId: std.string,
publicMeta:privmx.endpoint.core.Buffer,
privateMeta:privmx.endpoint.core.Buffer,
size: Int64
) throws -> privmx.StoreFileHandle

NameTypeDescription
fileIdstd.stringThe unique identifier of the file to be updated.
publicMetaprivmx.endpoint.core.BufferNew public metadata for the file.
privateMetaprivmx.endpoint.core.BufferNew private metadata for the file.
sizeInt64The size of the updated file in bytes.

TypeDescription
privmx.StoreFileHandle A `privmx.StoreFileHandle` for writing to the updated file.

closeFile(handle:)

Closes an open file handle. This method finalizes a file operation, such as writing or updating.

public func closeFile(
handle: privmx.StoreFileHandle
) throws -> std.string

NameTypeDescription
handleprivmx.StoreFileHandleThe handle to the open file.

TypeDescription
std.string The ID of the closed file as a `std.string`.

openFile(fileId:)

Opens a file for reading from the Store.

public func openFile(
fileId: std.string
) throws -> privmx.StoreFileHandle

NameTypeDescription
fileIdstd.stringThe unique identifier of the file to be opened.

TypeDescription
privmx.StoreFileHandle A `privmx.StoreFileHandle` for reading the file.

readFromFile(handle:length:)

Reads data from an open file.

public func readFromFile(
handle: privmx.StoreFileHandle,
length: Int64
) throws -> privmx.endpoint.core.Buffer

NameTypeDescription
handleprivmx.StoreFileHandleThe handle to the open file.
lengthInt64The number of bytes to read.

TypeDescription
privmx.endpoint.core.Buffer A buffer containing the read data.

writeToFile(handle:dataChunk:)

Writes a chunk of data to an open file on the platform.

public func writeToFile(
handle: privmx.StoreFileHandle,
dataChunk: privmx.endpoint.core.Buffer
) throws -> Void

NameTypeDescription
handleprivmx.StoreFileHandleThe handle to the open file.
dataChunkprivmx.endpoint.core.BufferThe chunk of data to be written to the file.

deleteFile(fileId:)

Deletes a specified file from the Store.

public func deleteFile(
fileId: std.string
) throws -> Void

NameTypeDescription
fileIdstd.stringThe unique identifier of the file to delete.

subscribeForStoreEvents()

Subscribes to Store-related events.

public func subscribeForStoreEvents(
) throws -> Void

unsubscribeFromStoreEvents()

Unsubscribes from Store-related events.

public func unsubscribeFromStoreEvents(
) throws -> Void

subscribeForFileEvents(storeId:)

Subscribes to file-related events within a specified Store.

public func subscribeForFileEvents(
storeId: std.string
) throws -> Void

NameTypeDescription
storeIdstd.stringThe unique identifier of the Store to subscribe to file events for.

unsubscribeFromFileEvents(storeId:)

Unsubscribes from file-related events within a specified Store.

public func unsubscribeFromFileEvents(
storeId: std.string
) throws -> Void

NameTypeDescription
storeIdstd.stringThe unique identifier of the Store to unsubscribe from file events for.