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
Name | Type | Description |
---|---|---|
connection | inout Connection | The connection object used for Store operations. |
Type | Description |
---|---|
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
Name | Type | Description |
---|---|---|
contextId | std.string | The Context from which the Stores should be listed. |
query | privmx.endpoint.core.PagingQuery | A `PagingQuery` object to filter and paginate the results. |
Type | Description |
---|---|
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
Name | Type | Description |
---|---|---|
storeId | std.string | The unique identifier of the Store to retrieve. |
Type | Description |
---|---|
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
Name | Type | Description |
---|---|---|
contextId | std.string | The Context in which the Store should be created. |
users | privmx.UserWithPubKeyVector | A vector of users who will have access to the Store. |
managers | privmx.UserWithPubKeyVector | A vector of managers responsible for the Store. |
publicMeta | privmx.endpoint.core.Buffer | Public metadata for the Store, which will not be encrypted. |
privateMeta | privmx.endpoint.core.Buffer | Private metadata for the Store, which will be encrypted. |
Type | Description |
---|---|
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
Name | Type | Description |
---|---|---|
storeId | std.string | The unique identifier of the Store to be updated. |
version | Int64 | The current version of the Store for consistency checking. |
users | privmx.UserWithPubKeyVector | A vector of users who will have access to the Store. |
managers | privmx.UserWithPubKeyVector | A vector of managers responsible for the Store. |
publicMeta | privmx.endpoint.core.Buffer | New public metadata for the Store, which will not be encrypted. |
privateMeta | privmx.endpoint.core.Buffer | New private metadata for the Store, which will be encrypted. |
force | Bool | Whether to force the update, bypassing version control. |
forceGenerateNewKey | Bool | Whether to generate a new key for the Store. |
deleteStore(storeId:)
Deletes a specified Store.
public func deleteStore(
storeId: std.string
) throws -> Void
Name | Type | Description |
---|---|---|
storeId | std.string | The 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
Name | Type | Description |
---|---|---|
fileId | std.string | The unique identifier of the file to retrieve. |
Type | Description |
---|---|
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
Name | Type | Description |
---|---|---|
storeId | std.string | The Store from which to list files. |
query | privmx.endpoint.core.PagingQuery | A `PagingQuery` object to filter and paginate the results. |
Type | Description |
---|---|
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
Name | Type | Description |
---|---|---|
storeId | std.string | The Store in which the file should be created. |
publicMeta | privmx.endpoint.core.Buffer | Public metadata for the file. |
privateMeta | privmx.endpoint.core.Buffer | Private metadata for the file. |
size | Int64 | The size of the file in bytes. |
Type | Description |
---|---|
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
Name | Type | Description |
---|---|---|
handle | privmx.StoreFileHandle | The handle to the open file. |
position | Int64 | The 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
Name | Type | Description |
---|---|---|
fileId | std.string | The unique identifier of the file to be updated. |
publicMeta | privmx.endpoint.core.Buffer | New public metadata for the file. |
privateMeta | privmx.endpoint.core.Buffer | New private metadata for the file. |
size | Int64 | The size of the updated file in bytes. |
Type | Description |
---|---|
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
Name | Type | Description |
---|---|---|
handle | privmx.StoreFileHandle | The handle to the open file. |
Type | Description |
---|---|
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
Name | Type | Description |
---|---|---|
fileId | std.string | The unique identifier of the file to be opened. |
Type | Description |
---|---|
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
Name | Type | Description |
---|---|---|
handle | privmx.StoreFileHandle | The handle to the open file. |
length | Int64 | The number of bytes to read. |
Type | Description |
---|---|
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
Name | Type | Description |
---|---|---|
handle | privmx.StoreFileHandle | The handle to the open file. |
dataChunk | privmx.endpoint.core.Buffer | The 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
Name | Type | Description |
---|---|---|
fileId | std.string | The 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
Name | Type | Description |
---|---|---|
storeId | std.string | The 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
Name | Type | Description |
---|---|---|
storeId | std.string | The unique identifier of the Store to unsubscribe from file events for. |