PrivMX DOCS
API Reference/PrivMX Endpoint Swift/Stores

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.

Params

connection

inout Connection

The connection object used for Store operations.

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

Returns

StoreApi · A newly created StoreApi instance.

Methods

listStores(contextId:pagingQuery:)

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

Params

contextId

std.string

The Context from which the Stores should be listed.

pagingQuery

privmx.endpoint.core.PagingQuery

A PagingQuery object to filter and paginate the results.

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

Returns

privmx.StoreList · A privmx.StoreList instance containing the list of Stores.

listStores(contextId:query:)

Params

contextId

std.string

query

privmx.endpoint.core.PagingQuery

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

Returns

privmx.StoreList ·

getStore(storeId:)

Retrieves detailed information about a specified Store.

Params

storeId

std.string

The unique identifier of the Store to retrieve.

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

Returns

privmx.endpoint.store.Store · A privmx.endpoint.store.Store instance containing Store details.

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

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. If policies argument is set to nil, the default policies will be applied.

Params

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.

policies

privmx.endpoint.core.ContainerPolicy?

A set of policies for the Container.

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

Returns

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

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

Updates an existing Store. The provided values will override the existing ones. You can also force regeneration of the Store’s key if needed. If policies argument is set to nil, the default policies will be applied.

Params

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.

policies

privmx.endpoint.core.ContainerPolicy?

New set of policies for the Container.

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,
policies: privmx.endpoint.core.ContainerPolicy? = nil
) throws -> Void

deleteStore(storeId:)

Deletes a specified Store.

Params

storeId

std.string

The unique identifier of the Store to delete.

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

getFile(fileId:)

Retrieves detailed information about a specified file.

Params

fileId

std.string

The unique identifier of the file to retrieve.

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

Returns

privmx.endpoint.store.File · A privmx.endpoint.store.File instance representing the file details.

listFiles(storeId:pagingQuery:)

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.

Params

storeId

std.string

The Store from which to list files.

pagingQuery

privmx.endpoint.core.PagingQuery

A PagingQuery object to filter and paginate the results.

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

Returns

privmx.FileList · A privmx.FileList instance containing the list of files.

listFiles(storeId:query:)

Params

storeId

std.string

query

privmx.endpoint.core.PagingQuery

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

Returns

privmx.FileList ·

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.

Params

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.

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

Returns

privmx.StoreFileHandle · A privmx.StoreFileHandle for writing to the file.

seekInFile(handle:position:)

Moves the read cursor within an open file.

Params

handle

privmx.StoreFileHandle

The handle to the open file.

position

Int64

The new position of the read cursor in bytes.

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

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.

Params

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.

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

Returns

privmx.StoreFileHandle · A privmx.StoreFileHandle for writing to the updated file.

updateFileMeta(fileId:publicMeta:privateMeta:)

Updates the metadata of an existing File.

Params

fileId

std.string

id of a File to be updated

publicMeta

privmx.endpoint.core.Buffer

new public metadata

privateMeta

privmx.endpoint.core.Buffer

new private metadata

public func updateFileMeta(
fileId: std.string,
publicMeta:privmx.endpoint.core.Buffer,
privateMeta:privmx.endpoint.core.Buffer
) throws -> Void

closeFile(handle:)

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

Params

handle

privmx.StoreFileHandle

The handle to the open file.

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

Returns

std.string · The ID of the closed file as a std.string.

openFile(fileId:)

Opens a file for reading from the Store.

Params

fileId

std.string

The unique identifier of the file to be opened.

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

Returns

privmx.StoreFileHandle · A privmx.StoreFileHandle for reading the file.

readFromFile(handle:length:)

Reads data from an open file.

Params

handle

privmx.StoreFileHandle

The handle to the open file.

length

Int64

The number of bytes to read.

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

Returns

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.

Params

handle

privmx.StoreFileHandle

The handle to the open file.

dataChunk

privmx.endpoint.core.Buffer

The chunk of data to be written to the file.

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

deleteFile(fileId:)

Deletes a specified file from the Store.

Params

fileId

std.string

The unique identifier of the file to delete.

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

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.

Params

storeId

std.string

The unique identifier of the Store to subscribe to file events for.

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

unsubscribeFromFileEvents(storeId:)

Unsubscribes from file-related events within a specified Store.

Params

storeId

std.string

The unique identifier of the Store to unsubscribe from file events for.

public func unsubscribeFromFileEvents(
storeId: std.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.