Sleds/cppcore/client/websvcs.h

130 lines
3.5 KiB
C++

// Copyright (c) 2014, IOnU Security, Inc.
// Copyright (c) 2016, Sequence Logic, Inc. All rights reserved.
#ifndef WEB_SVCS
#define WEB_SVCS
/**
* This is the interface class for communicating with CloudGuard/StorageGuard
*/
#ifdef WIN32
#ifdef SL_CPPCORE_DLLEXPORT
#define SL_CPPCORE_EXPORT __declspec(dllexport)
#else
#define SL_CPPCORE_EXPORT __declspec(dllimport)
#endif
#else
#define SL_CPPCORE_EXPORT
#endif
#include <string>
namespace sequencelogic
{
/**
* @brief Abstract interface for /pubsub/subscribe and related web requests
*
* @details
* SAMD is responsible for file sync in response to pubsub messages.
*/
class SL_CPPCORE_EXPORT WebSvcs
{
public:
WebSvcs() {}
virtual ~WebSvcs() {}
/**
* CLOUDGUARD SERVICE
* Request a list of PubSub messages from the client.
*
* @return Client should return a JSON array, as a string.
*/
virtual std::string getPubSubMessages() = 0;
/**
* CLOUDGUARD SERVICE
* Publish a PubSub message.
*
* @param pMsg A JSON object as a const char *.
* @return The result of the publish, as a JSON string.
*/
virtual std::string sendPubSubMessage(const std::string &msg) = 0;
/**
* CLOUDGUARD SERVICE
* Get the authenticated URN.
*
*/
virtual std::string getAuthenticatedURN() = 0;
/**
* CLOUDGUARD SERVICE
* Remove a PubSub message from the server.
*
* @param pMsg A JSON object as a string.
*/
virtual void disposePubSubMessage(const std::string &msg) = 0;
/**
* STORAGE GUARD SERVICES
* Get the named mount
*
* @param nMount One of the mount types listed.
*/
enum MOUNT_TYPE
{
eMessages,
eOffice,
eSynchronized,
eGroupShared,
eNone
};
virtual std::string getMount (MOUNT_TYPE nMount) = 0;
/**
* STORAGE GUARD SERVICES
* Create a node, based on a SHARE message.
*
* @param JSON string representing the action data from the message.
* @returns The node, as a JSON string
*/
virtual std::string createNode (const std::string &actData) = 0;
/**
* STORAGE GUARD SERVICES
* Synchronize a file in response to a SHARE message
*
* @param JSON string representing the node to sync.
* @returns The number of files synchronized, -1 on error.
*/
virtual int syncNode (const std::string &node) = 0;
/**
* STORAGE GUARD SERVICES
* Given a generic node, as JSON, get the absolute path to it on this device.
*
* @param node The JSON string representation of the node.
*/
virtual std::string getNodeAbsolutePath(const std::string &node) = 0;
/**
* CLOUDGUARD SERVICE
* Get an office from CG.
*
* @param urn of the office to get.
* @returns A JSON string of the office.
*/
virtual std::string getOffice(const std::string &urn) = 0;
/**
* SYNC SERVICE
* Get the mtime of the last sync for the given mount.
*
*/
virtual std::string getLastSyncTime(MOUNT_TYPE mType) = 0;
};
}
#endif