Skip to main content
reference

StoreApi

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

Methods

listStores(from:basedOn:)

Lists the Stores that the user has access to within a specified context. This method retrieves a list of all Stores accessible to the user in the given context. The list can be filtered and paginated using the provided query.

public func listStores(
from contextId: String,
basedOn query: privmx.endpoint.core.PagingQuery
) throws -> privmx.StoreList

NameTypeDescription
contextIdStringThe unique identifier of the context from which Stores should be listed.
queryprivmx.endpoint.core.PagingQueryA paging query object to filter and paginate the results.

TypeDescription
privmx.StoreList A `endpoint::core::PagingList<endpoint::store::Store> (`privmx.StoreList`) instance containing the list of Stores.

getStore(_:)

Retrieves detailed information about a specific Store. This method returns the details of a Store, such as its metadata and associated users, identified by its unique store ID.

public func getStore(
_ storeId: String
) throws -> privmx.endpoint.store.Store

NameTypeDescription
storeIdStringThe unique identifier of the Store to retrieve.

TypeDescription
privmx.endpoint.store.Store A `privmx.endpoint.store.Store` instance containing the Store’s metadata and details.

createStore(in:for:managedBy:withPublicMeta:withPrivateMeta:)

Creates a new Store in the specified context, with defined users and managers. This method creates a new Store within a specific context, associating users and managers with it. The Store will also have public and private metadata attached to it.

public func createStore(
in contextId: String,
for users: [privmx.endpoint.core.UserWithPubKey],
managedBy managers: [privmx.endpoint.core.UserWithPubKey],
withPublicMeta publicMeta: Data,
withPrivateMeta privateMeta: Data
) throws -> String

NameTypeDescription
contextIdStringThe unique identifier of the context in which the Store will be created.
users[privmx.endpoint.core.UserWithPubKey]A list of `UserWithPubKey` objects representing users who will have access to the Store.
managers[privmx.endpoint.core.UserWithPubKey]A list of `UserWithPubKey` objects representing managers responsible for the Store.
publicMetaDataThe public metadata associated with the Store, which will not be encrypted.
privateMetaDataThe private metadata associated with the Store, which will be encrypted.

TypeDescription
String A `String` representing the ID of the newly created Store.

updateStore(_:atVersion:replacingUsers:replacingManagers:replacingPublicMeta:replacingPrivateMeta:force:forceGenerateNewKey:)

Updates an existing Store by replacing its users, managers, and metadata. This method updates an existing Store with new values, overriding the previous users, managers, and metadata. The update can be forced, and a new key can be generated if required.

public func updateStore(
_ storeId: 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
) throws -> Void

NameTypeDescription
storeIdStringThe unique identifier of the Store to be updated.
versionInt64The current version of the Store, used to ensure version consistency.
users[privmx.endpoint.core.UserWithPubKey]A new list of `UserWithPubKey` objects representing users who will have access to the Store.
managers[privmx.endpoint.core.UserWithPubKey]A new list of `UserWithPubKey` objects representing managers responsible for the Store.
publicMetaDataThe new public metadata for the Store, which will be unencrypted.
privateMetaDataThe new private metadata for the Store, which will be encrypted.
forceBoolA boolean indicating whether the update should be forced, bypassing version control.
forceGenerateNewKeyBoolA boolean indicating whether a new key should be generated for the Store.

deleteStore(_:)

Deletes a specific Store identified by its unique ID. This method removes the Store along with its associated data from the Bridge.

public func deleteStore(
_ storeId: String
) throws -> Void

NameTypeDescription
storeIdStringThe unique identifier of the Store to be deleted.

getFile(_:)

Retrieves information about a specific File in a Store. This method returns details about a File, such as its metadata, associated with the given file ID.

public func getFile(
_ fileId: String
) throws -> privmx.endpoint.store.File

NameTypeDescription
fileIdStringThe unique identifier of the File to retrieve.

TypeDescription
privmx.endpoint.store.File A `privmx.endpoint.store.File` instance containing the File’s metadata and details.

listFiles(from:basedOn:)

Lists all Files in a specified Store. This method retrieves a list of Files associated with a Store. It only provides metadata and information about the files, not their contents. To download the files themselves, use `openFile()` and `readFromFile()`.

public func listFiles(
from storeId: String,
basedOn query: privmx.endpoint.core.PagingQuery
) throws -> privmx.FileList

NameTypeDescription
storeIdStringThe unique identifier of the Store from which to list Files.
queryprivmx.endpoint.core.PagingQueryA paging query object to filter and paginate the results.

TypeDescription
privmx.FileList A `privmx.endpoint.core.FilesList` instance containing the list of Files.

createFile(in:withPublicMeta:withPrivateMeta:ofSize:)

Creates a new file handle for writing data to a File in a Store. This method creates a new file handle, which can be used to write data to a new File in the Store. Once the file is created, data can be uploaded using `writeToFile()` and finalized with `closeFile()`.

public func createFile(
in storeId: String,
withPublicMeta publicMeta: Data,
withPrivateMeta privateMeta: Data,
ofSize size: Int64
) throws -> privmx.StoreFileHandle

NameTypeDescription
storeIdStringThe unique identifier of the Store in which the File will be created.
publicMetaDataPublic metadata for the File, which will be unencrypted.
privateMetaDataPrivate metadata for the File, which will be encrypted.
sizeInt64The size of the File in bytes.

TypeDescription
privmx.StoreFileHandle A `privmx.StoreFileHandle` used for writing data to the File.

updateFile(_:replacingPublicMeta:replacingPrivateMeta:replacingSize:)

Updates an existing File by overwriting its content and metadata. This method creates a new file handle for updating an existing File, allowing the content and metadata to be replaced. The file can then be written using `writeToFile()` and finalized with `closeFile()`.

public func updateFile(
_ fileId: String,
replacingPublicMeta publicMeta: Data,
replacingPrivateMeta privateMeta: Data,
replacingSize size: Int64
) throws -> privmx.StoreFileHandle

NameTypeDescription
fileIdStringThe unique identifier of the File to be updated.
publicMetaDataNew public metadata for the File, which will be unencrypted.
privateMetaDataNew private metadata for the File, which will be encrypted.
sizeInt64The new size of the File in bytes.

TypeDescription
privmx.StoreFileHandle A `privmx.StoreFileHandle` for writing data to the updated File.

openFile(_:)

Opens a File for reading and returns a file handle (`StoreFileHandle`). This method opens an existing File, identified by its file ID, and returns a handle that can be used to read the file’s content.

public func openFile(
_ fileId: String
) throws -> privmx.StoreFileHandle

NameTypeDescription
fileIdStringThe unique identifier of the File to open.

TypeDescription
privmx.StoreFileHandle A `privmx.StoreFileHandle` for reading the File’s content.

readFromFile(withHandle:length:)

Reads from an opened file.

public func readFromFile(
withHandle handle: privmx.StoreFileHandle,
length: Int64
) throws -> Data

NameTypeDescription
handleprivmx.StoreFileHandlethe handle to an opened File
lengthInt64amount of bytes to be read

TypeDescription
Data `privmx.StoreFileHandle` for reading

writeToFile(withHandle:uploading:)

Writes a chunk of data to an opened file on the Platform.

public func writeToFile(
withHandle handle: privmx.StoreFileHandle,
uploading dataChunk: Data
) throws -> Void

NameTypeDescription
handleprivmx.StoreFileHandlethe handle to an opened file
dataChunkDatathe data to be uploaded

closeFile(withHandle:)

Closes an open File

public func closeFile(
withHandle handle: privmx.StoreFileHandle
) throws -> String

NameTypeDescription
handleprivmx.StoreFileHandlethe handle to an open file

TypeDescription
String The Id of the File

deleteFile(_:)

Deletes the specified File.

public func deleteFile(
_ fileId: String
) throws -> Void

NameTypeDescription
fileIdStringwhich File should be deleted

TypeDescription
True if the file was deleted successfully, false otherwise.

seekInFile(withHandle:toPosition:)

Moves the read/write cursor within an open File. This method repositions the read/write cursor in a file, allowing for random access operations such as reading or writing from a specific position.

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

NameTypeDescription
handleprivmx.StoreFileHandleThe handle of the opened File.
positionInt64The new position for the cursor, in bytes.

unubscribeFromFileEvents(in:)

Unsubscribes from events related to Files in a specific Store. This method stops the client from receiving notifications about file-related events in a specific Store.

public func unubscribeFromFileEvents(
in storeId: String
) throws -> Void

NameTypeDescription
storeIdStringThe unique identifier of the Store for which to unsubscribe from file events.

subscribeForFileEvents(in:)

Subscribes to events related to Files in a specific Store. This method subscribes to file-related events for a specific Store, enabling the client to receive notifications about changes to Files, such as uploads or deletions.

public func subscribeForFileEvents(
in storeId: String
) throws -> Void

NameTypeDescription
storeIdStringThe unique identifier of the Store for which to subscribe to file events.