PrivMX DOCS
API Reference/PrivMX Endpoint Swift/Stores

StoreApi

‘StoreApi’ is a class representing Endpoint’s API for Stores and their files.

Static Methods

create(connection:)

Creates an instance of ‘StoreApi’Gets a list of Stores in given Context.

Params

connection

inout Connection

instance of ’ConnectionID of the Context to get the Stores from

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

Returns

StoreApi · StoreApi struct with list query parameters

Methods

listStores(contextId:pagingQuery:)

struct containing list of Stores

Params

contextId

std.string

Gets a list of Stores in given Context.

pagingQuery

privmx.endpoint.core.PagingQuery

ID of the Context to get the Stores from

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

Returns

privmx.StoreList · struct with list query parameters

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:)

Gets a single Store by given Store ID.

Params

storeId

std.string

ID of the Store to get

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

Returns

privmx.endpoint.store.Store · struct containing information about the Store

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

Creates a new Store in given Context.

Params

contextId

std.string

ID of the Context to create the Store in

users

privmx.UserWithPubKeyVector

vector of UserWithPubKey structs which indicates who will have access to the created Store

managers

privmx.UserWithPubKeyVector

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

publicMeta

privmx.endpoint.core.Buffer

public (unencrypted) metadata

privateMeta

privmx.endpoint.core.Buffer

private (encrypted) metadata

policies

privmx.endpoint.core.ContainerPolicy?

Store’s policies

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 · created Store ID

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

Updates an existing Store.

Params

storeId

std.string

ID of the Store to update

version

Int64

vector of UserWithPubKey structs which indicates who will have access to the created Store

users

privmx.UserWithPubKeyVector

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

managers

privmx.UserWithPubKeyVector

public (unencrypted) metadata

publicMeta

privmx.endpoint.core.Buffer

private (encrypted) metadata

privateMeta

privmx.endpoint.core.Buffer

current version of the updated Store

force

Bool

force update (without checking version)

forceGenerateNewKey

Bool

force to regenerate a key for the Store

policies

privmx.endpoint.core.ContainerPolicy?

Store’s policies

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 Store by given Store ID.

Params

storeId

std.string

ID of the Store to delete

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

getFile(fileId:)

Gets a single file by the given file ID.

Params

fileId

std.string

ID of the file to get

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

Returns

privmx.endpoint.store.File · struct containing information about the file

listFiles(storeId:pagingQuery:)

Gets a list of files in given Store.

Params

storeId

std.string

ID of the Store to get files from

pagingQuery

privmx.endpoint.core.PagingQuery

struct with list query parameters

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

Returns

privmx.FileList · struct containing 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:randomWriteSupport:)

Creates a new file in a Store.

Params

storeId

std.string

ID of the Store to create the file in

publicMeta

privmx.endpoint.core.Buffer

public file metadata

privateMeta

privmx.endpoint.core.Buffer

private file metadata

size

Int64

size of the file

randomWriteSupport

Bool

enable random write support for file

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

Returns

privmx.StoreFileHandle · handle to write data

seekInFile(handle:position:)

Moves read cursor.

Params

handle

privmx.StoreFileHandle

handle to write file data

position

Int64

new cursor position

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

updateFile(fileId:publicMeta:privateMeta:size:)

Update an existing file in a Store.

Params

fileId

std.string

ID of the file to update

publicMeta

privmx.endpoint.core.Buffer

public file metadata

privateMeta

privmx.endpoint.core.Buffer

private file metadata

size

Int64

size of the file

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

Returns

privmx.StoreFileHandle · handle to write file data

updateFileMeta(fileId:publicMeta:privateMeta:)

Update metadata of an existing file in a Store.

Params

fileId

std.string

ID of the file to update

publicMeta

privmx.endpoint.core.Buffer

public file metadata

privateMeta

privmx.endpoint.core.Buffer

private file metadata

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

closeFile(handle:)

Closes the file handle.

Params

handle

privmx.StoreFileHandle

handle to read/write file data

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

Returns

std.string · ID of closed file

openFile(fileId:)

Opens a file to read.

Params

fileId

std.string

ID of the file to read

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

Returns

privmx.StoreFileHandle · handle to read file data

readFromFile(handle:length:)

Reads file data. Single read call moves the files’s cursor position by declared length or set it at the end of the file.

Params

handle

privmx.StoreFileHandle

handle to write file data

length

Int64

size of data to read

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

Returns

privmx.endpoint.core.Buffer · buffer with file data chunk

writeToFile(handle:dataChunk:truncate:)

Writes a file data.

Params

handle

privmx.StoreFileHandle

handle to write file data

dataChunk

privmx.endpoint.core.Buffer

file data chunk

truncate

Bool

truncate the file from: current pos + dataChunk size

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

deleteFile(fileId:)

Deletes a file by given ID.

Params

fileId

std.string

ID of the file to delete

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

syncFile(handle:)

Synchronize file handle data with newest data on serwer.

  • Parameter handle: Store File handle to sync
  • Throws: if the operation fails.

Params

handle

privmx.StoreFileHandle

public func syncFile(
handle: privmx.StoreFileHandle
) throws -> Void

subscribeFor(subscriptionQueries:)

Subscribe for the Store events on the given subscription query.

Params

subscriptionQueries

privmx.SubscriptionQueryVector

list of queries

public func subscribeFor(
subscriptionQueries: privmx.SubscriptionQueryVector
) throws -> privmx.SubscriptionIdVector

Returns

privmx.SubscriptionIdVector · list of subscriptionIds in maching order to subscriptionQueries

unsubscribeFrom(subscriptionIds:)

Unsubscribe from events for the given subscriptionId.

Params

subscriptionIds

privmx.SubscriptionIdVector

list of subscriptionId

public func unsubscribeFrom(
subscriptionIds: privmx.SubscriptionIdVector
) throws -> Void

buildSubscriptionQuery(eventType:selectorType:selectorId:)

Generate subscription Query for the Store events.

Params

eventType

privmx.endpoint.store.EventType

type of event which you listen for

selectorType

privmx.endpoint.store.EventSelectorType

scope on which you listen for events

selectorId

std.string

ID of the selector

public func buildSubscriptionQuery(
eventType: privmx.endpoint.store.EventType,
selectorType: privmx.endpoint.store.EventSelectorType,
selectorId: std.string
) throws -> privmx.SubscriptionQuery

Returns

privmx.SubscriptionQuery · a properly formatted event subscription request.

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.