PrivMXStore
Protocol declaring methods of StoreApi using Swift types, enabling interaction with PrivMX Stores and Files. Do not conform to this protocol
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.
Params
contextId
String
The unique identifier of the context from which Stores should be listed.
query
privmx.endpoint.core.PagingQuery
A paging query object to filter and paginate the results.
Returns
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.
Params
storeId
String
The unique identifier of the Store to retrieve.
Returns
privmx.endpoint.store.Store
·
A privmx.endpoint.store.Store
instance containing the Store’s metadata and details.
createStore(in:for:managedBy:withPublicMeta:withPrivateMeta:withPolicies:)
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. Note: when no policies are supplied, the default ones inherited from the context will be used instead.
Params
contextId
String
The 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.
publicMeta
Data
The public metadata associated with the Store, which will not be encrypted.
privateMeta
Data
The private metadata associated with the Store, which will be encrypted.
policies
privmx.endpoint.core.ContainerPolicy?
The policies governing the Container, as well as the items within.
Returns
String
·
A String
representing the ID of the newly created Store.
deleteStore(_:)
Deletes a specific Store identified by its unique ID. This method removes the Store along with its associated data from the Bridge.
Params
storeId
String
The unique identifier of the Store to be deleted.
updateStore(_:atVersion:replacingUsers:replacingManagers:replacingPublicMeta:replacingPrivateMeta:force:forceGenerateNewKey:replacingPolicies:)
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.
Params
storeId
String
The unique identifier of the Store to be updated.
version
Int64
The 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.
publicMeta
Data
The new public metadata for the Store, which will be unencrypted.
privateMeta
Data
The new private metadata for the Store, which will be encrypted.
force
Bool
A boolean indicating whether the update should be forced, bypassing version control.
forceGenerateNewKey
Bool
A boolean indicating whether a new key should be generated for the Store.
policies
privmx.endpoint.core.ContainerPolicy?
The new policies for the Container.
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.
Params
fileId
String
The unique identifier of the File to retrieve.
Returns
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()
.
Params
storeId
String
The unique identifier of the Store from which to list Files.
query
privmx.endpoint.core.PagingQuery
A paging query object to filter and paginate the results.
Returns
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()
.
Params
storeId
String
The unique identifier of the Store in which the File will be created.
publicMeta
Data
Public metadata for the File, which will be unencrypted.
privateMeta
Data
Private metadata for the File, which will be encrypted.
size
Int64
The size of the File in bytes.
Returns
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()
.
Params
fileId
String
The unique identifier of the File to be updated.
publicMeta
Data
New public metadata for the File, which will be unencrypted.
privateMeta
Data
New private metadata for the File, which will be encrypted.
size
Int64
The new size of the File in bytes.
Returns
privmx.StoreFileHandle
·
A privmx.StoreFileHandle
for writing data to the updated File.
updateFileMeta(of:replacingPublicMeta:replacingPrivateMeta:)
Updates an existing File by overwriting its metadata.
Params
fileId
String
The unique identifier of the File to be updated.
publicMeta
Data
New public metadata for the File, which will be unencrypted.
privateMeta
Data
New private metadata for the File, which will be encrypted.
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.
Params
fileId
String
The unique identifier of the File to open.
Returns
privmx.StoreFileHandle
·
A privmx.StoreFileHandle
for reading the File’s content.
readFromFile(withHandle:length:)
Reads a specified number of bytes from an open File. This method reads a defined amount of data from a file that has been opened using a StoreFileHandle.
Params
handle
privmx.StoreFileHandle
The StoreFileHandle of the opened File.
length
Int64
The number of bytes to read from the File.
Returns
Data
·
A Data
object containing the bytes read from the File.
writeToFile(withHandle:uploading:)
Writes a chunk of data to an open File. This method uploads a chunk of data to a file that has been opened for writing using a file handle.
Params
handle
privmx.StoreFileHandle
The handle of the opened File.
dataChunk
Data
The data to write to the File.
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.
Params
handle
privmx.StoreFileHandle
The handle of the opened File.
position
Int64
The new position for the cursor, in bytes.
closeFile(withHandle:)
Closes an open File and finalizes any pending operations.
This method closes a file that was opened using openFile()
or created with createFile()
. It ensures that all pending write operations are completed and releases the file handle.
Params
handle
privmx.StoreFileHandle
The handle of the opened File to close.
Returns
String
·
A String
representing the ID of the closed File.
deleteFile(_:)
Permanently deletes a File from the platform. This method removes a file, identified by its file ID, and all its associated data from the platform.
Params
fileId
String
The unique identifier of the File to delete.
subscribeForStoreEvents()
Subscribes to events related to Stores. This method allows the client to receive notifications about changes to Stores, such as updates or new Stores being created, by subscribing to Store-related 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.
Params
storeId
String
The unique identifier of the Store for which to subscribe to file events.
unsubscribeFromStoreEvents()
Unsubscribes from events related to Stores. This method stops the client from receiving notifications about Store-related events.
unsubscribeFromFileEvents(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.
Params
storeId
String
The unique identifier of the Store for which to unsubscribe from file events.
unubscribeFromFileEvents(in:)
Params
storeId
String
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.
PrivMX Endpoint Swift v2.3