PrivMX DOCS
API Reference/PrivMX Endpoint/Store

StoreApi

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

Static Methods

create

Creates an instance of StoreApi

Params

connection

core::Connection &

instance of 'Connection'

static StoreApi create(
core::Connection &connection
)

Returns

[StoreApi](/reference/cpp/endpoint/store/store-api) · StoreApi object

Methods

createStore

Creates a new Store in given Context.

Params

contextId

const std::string &

ID of the Context to create the Store in

users

const std::vector<core::UserWithPubKey> &

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

managers

const std::vector<core::UserWithPubKey> &

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

publicMeta

const core::Buffer &

public (unencrypted) metadata

privateMeta

const core::Buffer &

private (encrypted) metadata

policies

const std::optional<core::ContainerPolicy> &

Store policies

std::string createStore(
const std::string &contextId
const std::vector<core::UserWithPubKey> &users
const std::vector<core::UserWithPubKey> &managers
const core::Buffer &publicMeta
const core::Buffer &privateMeta
const std::optional<core::ContainerPolicy> &policies=std::nullopt
)

Returns

std::string · created Store ID

updateStore

Updates an existing Store

Params

storeId

const std::string &

ID of the Store to update

users

const std::vector<core::UserWithPubKey> &

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

managers

const std::vector<core::UserWithPubKey> &

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

publicMeta

const core::Buffer &

public (unencrypted) metadata

privateMeta

const core::Buffer &

private (encrypted) metadata

version

const int64_t

current version of the updated Store

force

const bool

force update (without checking version)

forceGenerateNewKey

const bool

force to regenerate a key for the Store

policies

const std::optional<core::ContainerPolicy> &

Store policies

void updateStore(
const std::string &storeId
const std::vector<core::UserWithPubKey> &users
const std::vector<core::UserWithPubKey> &managers
const core::Buffer &publicMeta
const core::Buffer &privateMeta
const int64_t version
const bool force
const bool forceGenerateNewKey
const std::optional<core::ContainerPolicy> &policies=std::nullopt
)

deleteStore

Deletes a Store by given Store ID.

Params

storeId

const std::string &

ID of the Store to delete

void deleteStore(
const std::string &storeId
)

getStore

Gets a single Store by given Store ID.

Params

storeId

const std::string &

ID of the Store to get

Store getStore(
const std::string &storeId
)

Returns

[Store](/reference/cpp/endpoint/store/types#store) · struct containing information about the Store

listStores

Gets a list of Stores in given Context.

Params

contextId

const std::string &

ID of the Context to get the Stores from

pagingQuery

const core::PagingQuery &

struct with list query parameters

core::PagingList< Store > listStores(
const std::string &contextId
const core::PagingQuery &pagingQuery
)

Returns

[PagingList](/reference/cpp/endpoint/core/types#paginglist)<[Store](/reference/cpp/endpoint/store/types#store)> · struct containing list of Stores

createFile

Creates a new file in a Store

Params

storeId

const std::string &

ID of the Store to create the file in

publicMeta

const core::Buffer &

public file metadata

privateMeta

const core::Buffer &

private file metadata

size

const int64_t

size of the file

int64_t createFile(
const std::string &storeId
const core::Buffer &publicMeta
const core::Buffer &privateMeta
const int64_t size
)

Returns

int64_t · handle to write data

updateFile

Update an existing file in a Store

Params

fileId

const std::string &

ID of the file to update

publicMeta

const core::Buffer &

public file metadata

privateMeta

const core::Buffer &

private file metadata

size

const int64_t

size of the file

int64_t updateFile(
const std::string &fileId
const core::Buffer &publicMeta
const core::Buffer &privateMeta
const int64_t size
)

Returns

int64_t · handle to write file data

updateFileMeta

Update metadata of an existing file in a Store

Params

fileId

const std::string &

ID of the file to update

publicMeta

const core::Buffer &

public file metadata

privateMeta

const core::Buffer &

private file metadata

void updateFileMeta(
const std::string &fileId
const core::Buffer &publicMeta
const core::Buffer &privateMeta
)

writeToFile

Writes a file data.

Params

fileHandle

const int64_t

dataChunk

const core::Buffer &

file data chunk

void writeToFile(
const int64_t fileHandle
const core::Buffer &dataChunk
)

deleteFile

Deletes a file by given ID.

Params

fileId

const std::string &

ID of the file to delete

void deleteFile(
const std::string &fileId
)

getFile

Gets a single file by the given file ID.

Params

fileId

const std::string &

ID of the file to get

File getFile(
const std::string &fileId
)

Returns

[File](/reference/cpp/endpoint/store/types#file) · struct containing information about the file

listFiles

Gets a list of files in given Store

Params

storeId

const std::string &

pagingQuery

const core::PagingQuery &

struct with list query parameters

core::PagingList< File > listFiles(
const std::string &storeId
const core::PagingQuery &pagingQuery
)

Returns

[PagingList](/reference/cpp/endpoint/core/types#paginglist)<[File](/reference/cpp/endpoint/store/types#file)> · struct containing list of files

openFile

Opens a file to read.

Params

fileId

const std::string &

ID of the file to read

int64_t openFile(
const std::string &fileId
)

Returns

int64_t · handle to read file data

readFromFile

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

fileHandle

const int64_t

length

const int64_t

size of data to read

core::Buffer readFromFile(
const int64_t fileHandle
const int64_t length
)

Returns

[Buffer](/reference/cpp/endpoint/core/buffer) · buffer with file data chunk

seekInFile

Moves read cursor.

Params

fileHandle

const int64_t

position

const int64_t

new cursor position

void seekInFile(
const int64_t fileHandle
const int64_t position
)

closeFile

Closes the file handle.

Params

fileHandle

const int64_t

std::string closeFile(
const int64_t fileHandle
)

Returns

std::string · ID of closed file

subscribeForStoreEvents

Subscribes for the Store module main events.

void subscribeForStoreEvents()

unsubscribeFromStoreEvents

Unsubscribes from the Store module main events.

void unsubscribeFromStoreEvents()

subscribeForFileEvents

Subscribes for events in given Store

Params

storeId

const std::string &

void subscribeForFileEvents(
const std::string &storeId
)

unsubscribeFromFileEvents

Unsubscribes from events in given Store

Params

storeId

const std::string &

void unsubscribeFromFileEvents(
const std::string &storeId
)