Fledge
An open source edge computing platform for industrial users
StorageClient Class Reference

Client for accessing the storage service. More...

#include <storage_client.h>

Public Member Functions

 StorageClient (HttpClient *client)
 Storage Client constructor stores the provided HttpClient into the map.
 
 StorageClient (const std::string &hostname, const unsigned short port)
 
 ~StorageClient ()
 Destructor for storage client.
 
ResultSetqueryTable (const std::string &schema, const std::string &tablename, const Query &query)
 Query a table. More...
 
ResultSetqueryTable (const std::string &tablename, const Query &query)
 Query a table. More...
 
ReadingSetqueryTableToReadings (const std::string &tableName, const Query &query)
 Query a table and return a ReadingSet pointer. More...
 
int insertTable (const std::string &schema, const std::string &tableName, const InsertValues &values)
 
int insertTable (const std::string &schema, const std::string &tableName, const std::vector< InsertValues > &values)
 
int insertTable (const std::string &tableName, const std::vector< InsertValues > &values)
 
int updateTable (const std::string &schema, const std::string &tableName, const InsertValues &values, const Where &where, const UpdateModifier *modifier=NULL)
 
int updateTable (const std::string &schema, const std::string &tableName, const JSONProperties &json, const Where &where, const UpdateModifier *modifier=NULL)
 
int updateTable (const std::string &schema, const std::string &tableName, const InsertValues &values, const JSONProperties &json, const Where &where, const UpdateModifier *modifier=NULL)
 
int updateTable (const std::string &schema, const std::string &tableName, const ExpressionValues &values, const Where &where, const UpdateModifier *modifier=NULL)
 
int updateTable (const std::string &schema, const std::string &tableName, std::vector< std::pair< ExpressionValues *, Where *>> &updates, const UpdateModifier *modifier=NULL)
 
int updateTable (const std::string &schema, const std::string &tableName, const InsertValues &values, const ExpressionValues &expressoins, const Where &where, const UpdateModifier *modifier=NULL)
 
int deleteTable (const std::string &schema, const std::string &tableName, const Query &query)
 Delete from a table. More...
 
int insertTable (const std::string &tableName, const InsertValues &values)
 
int updateTable (const std::string &tableName, const InsertValues &values, const Where &where, const UpdateModifier *modifier=NULL)
 
int updateTable (const std::string &tableName, const JSONProperties &json, const Where &where, const UpdateModifier *modifier=NULL)
 
int updateTable (const std::string &tableName, const InsertValues &values, const JSONProperties &json, const Where &where, const UpdateModifier *modifier=NULL)
 
int updateTable (const std::string &tableName, const ExpressionValues &values, const Where &where, const UpdateModifier *modifier=NULL)
 
int updateTable (const std::string &tableName, std::vector< std::pair< ExpressionValues *, Where *>> &updates, const UpdateModifier *modifier=NULL)
 
int updateTable (const std::string &tableName, const InsertValues &values, const ExpressionValues &expressions, const Where &where, const UpdateModifier *modifier=NULL)
 
int updateTable (const std::string &schema, const std::string &tableName, std::vector< std::pair< InsertValue *, Where * > > &updates, const UpdateModifier *modifier)
 
int updateTable (const std::string &tableName, std::vector< std::pair< InsertValue *, Where *> > &updates, const UpdateModifier *modifier=NULL)
 
int deleteTable (const std::string &tableName, const Query &query)
 Delete from a table. More...
 
bool readingAppend (Reading &reading)
 Append a single reading.
 
bool readingAppend (const std::vector< Reading *> &readings)
 Append multiple readings. More...
 
ResultSetreadingQuery (const Query &query)
 Perform a generic query against the readings data. More...
 
ReadingSetreadingQueryToReadings (const Query &query)
 Perform a generic query against the readings data, returning ReadingSet object. More...
 
ReadingSetreadingFetch (const unsigned long readingId, const unsigned long count)
 Retrieve a set of readings for sending on the northbound interface of Fledge. More...
 
PurgeResult readingPurgeByAge (unsigned long age, unsigned long sent, bool purgeUnsent)
 Purge the readings by age. More...
 
PurgeResult readingPurgeBySize (unsigned long size, unsigned long sent, bool purgeUnsent)
 Purge the readings by size. More...
 
PurgeResult readingPurgeByAsset (const std::string &asset)
 Purge the readings by asset name. More...
 
bool registerAssetNotification (const std::string &assetName, const std::string &callbackUrl)
 Register interest for a Reading asset name. More...
 
bool unregisterAssetNotification (const std::string &assetName, const std::string &callbackUrl)
 Unregister interest for a Reading asset name. More...
 
bool registerTableNotification (const std::string &tableName, const std::string &key, std::vector< std::string > keyValues, const std::string &operation, const std::string &callbackUrl)
 Register interest for a table. More...
 
bool unregisterTableNotification (const std::string &tableName, const std::string &key, std::vector< std::string > keyValues, const std::string &operation, const std::string &callbackUrl)
 Unregister interest for a table name. More...
 
void registerManagement (ManagementClient *mgmnt)
 
bool createSchema (const std::string &)
 Function to create Storage Schema.
 
bool deleteHttpClient ()
 Delete HttpClient object for current thread.
 

Detailed Description

Client for accessing the storage service.

Member Function Documentation

◆ deleteTable() [1/2]

int StorageClient::deleteTable ( const std::string &  schema,
const std::string &  tableName,
const Query query 
)

Delete from a table.

Parameters
schemaThe name of the schema to delete from
tablenameThe name of the table to delete from
queryThe query payload to match rows to delete
Returns
int The number of rows deleted

◆ deleteTable() [2/2]

int StorageClient::deleteTable ( const std::string &  tableName,
const Query query 
)

Delete from a table.

Parameters
tablenameThe name of the table to delete from
queryThe query payload to match rows to delete
Returns
int The number of rows deleted

◆ queryTable() [1/2]

ResultSet * StorageClient::queryTable ( const std::string &  schema,
const std::string &  tableName,
const Query query 
)

Query a table.

Parameters
schemaThe name of the schema to query
tablenameThe name of the table to query
queryThe query payload
Returns
ResultSet* The resultset of the query

◆ queryTable() [2/2]

ResultSet * StorageClient::queryTable ( const std::string &  tableName,
const Query query 
)

Query a table.

Parameters
tablenameThe name of the table to query
queryThe query payload
Returns
ResultSet* The resultset of the query

◆ queryTableToReadings()

ReadingSet * StorageClient::queryTableToReadings ( const std::string &  tableName,
const Query query 
)

Query a table and return a ReadingSet pointer.

Parameters
tablenameThe name of the table to query
queryThe query payload
Returns
ReadingSet* The resultset of the query as ReadingSet class pointer

◆ readingAppend()

bool StorageClient::readingAppend ( const std::vector< Reading *> &  readings)

Append multiple readings.

TODO implement a mechanism to force streamed or non-streamed mode

◆ readingFetch()

ReadingSet * StorageClient::readingFetch ( const unsigned long  readingId,
const unsigned long  count 
)

Retrieve a set of readings for sending on the northbound interface of Fledge.

Parameters
readingIdThe ID of the reading which should be the first one to send
countMaximum number if readings to return
Returns
ReadingSet The set of readings

◆ readingPurgeByAge()

PurgeResult StorageClient::readingPurgeByAge ( unsigned long  age,
unsigned long  sent,
bool  purgeUnsent 
)

Purge the readings by age.

Parameters
ageNumber of hours old a reading has to be to be considered for purging
sentThe ID of the last reading that was sent
purgeUnsentFlag to control if unsent readings should be purged
Returns
PurgeResult Data on the readings hat were purged

◆ readingPurgeByAsset()

PurgeResult StorageClient::readingPurgeByAsset ( const std::string &  asset)

Purge the readings by asset name.

Parameters
assetThe name of the asset to purge
Returns
PurgeResult Data on the readings that were purged

◆ readingPurgeBySize()

PurgeResult StorageClient::readingPurgeBySize ( unsigned long  size,
unsigned long  sent,
bool  purgeUnsent 
)

Purge the readings by size.

Parameters
sizeDesired maximum size of readings table
sentThe ID of the last reading that was sent
purgeUnsentFlag to control if unsent readings should be purged
Returns
PurgeResult Data on the readings hat were purged

◆ readingQuery()

ResultSet * StorageClient::readingQuery ( const Query query)

Perform a generic query against the readings data.

Parameters
queryThe query to execute
Returns
ResultSet The result of the query

◆ readingQueryToReadings()

ReadingSet * StorageClient::readingQueryToReadings ( const Query query)

Perform a generic query against the readings data, returning ReadingSet object.

Parameters
queryThe query to execute
Returns
ReadingSet The result of the query

◆ registerAssetNotification()

bool StorageClient::registerAssetNotification ( const std::string &  assetName,
const std::string &  callbackUrl 
)

Register interest for a Reading asset name.

Parameters
assetNameThe asset name to register for readings data notification
callbackUrlThe callback URL to send readings data.
Returns
True on success, false otherwise.

◆ registerTableNotification()

bool StorageClient::registerTableNotification ( const std::string &  tableName,
const std::string &  key,
std::vector< std::string >  keyValues,
const std::string &  operation,
const std::string &  callbackUrl 
)

Register interest for a table.

Parameters
tableNameThe table name to register for notification
tableKeyThe key of interest in the table
tableKeyValuesThe key values of interest
tableOperationThe table operation of interest (insert/update/delete)
callbackUrlThe callback URL to send change data
Returns
True on success, false otherwise.

◆ unregisterAssetNotification()

bool StorageClient::unregisterAssetNotification ( const std::string &  assetName,
const std::string &  callbackUrl 
)

Unregister interest for a Reading asset name.

Parameters
assetNameThe asset name to unregister for readings data notification
callbackUrlThe callback URL provided in registration.
Returns
True on success, false otherwise.

◆ unregisterTableNotification()

bool StorageClient::unregisterTableNotification ( const std::string &  tableName,
const std::string &  key,
std::vector< std::string >  keyValues,
const std::string &  operation,
const std::string &  callbackUrl 
)

Unregister interest for a table name.

Parameters
tableNameThe table name to unregister interest in
tableKeyThe key of interest in the table
tableKeyValuesThe key values of interest
tableOperationThe table operation of interest (insert/update/delete)
callbackUrlThe callback URL to send change data
Returns
True on success, false otherwise.

The documentation for this class was generated from the following files: