SDK  2.1.4 [async]
CloudBackend Software Development Kit - SDK API for C++
CloudBackend.h
1 /*
2  Copyright © CloudBackend AB 2020-2023.
3 */
4 
5 #ifndef INCLUDE_CBE_CLOUDBACKEND_H_
6 #define INCLUDE_CBE_CLOUDBACKEND_H_
7 
8 #include "cbe/Types.h"
9 #include "cbe/delegate/CreateAccountDelegate.h"
10 #include "cbe/delegate/Error.h"
11 #include "cbe/delegate/CloudBackendListenerDelegate.h"
12 #include "cbe/delegate/LogInDelegate.h"
13 #include "cbe/delegate/QueryJoinDelegate.h"
14 #include "cbe/delegate/QueryDelegate.h"
15 
16 #include "cbe/util/Context.h"
17 #include "cbe/util/ErrorInfo.h"
18 #include "cbe/util/Exception.h"
19 #include "cbe/util/Optional.h"
20 
21 #include <iosfwd>
22 #include <string>
23 
24 namespace CBI {
25 class CloudBackend;
26 using CloudBackendPtr = std::shared_ptr<CBI::CloudBackend>;
27 class AccountEventProtocol;
28 using AccountDelegatePtr = std::shared_ptr<AccountEventProtocol>;
29 } // namespace CBI
30 
31 namespace cbe
32 {
33 class QueryChainExt;
34 class QueryChainSync;
35 
36 class Filter;
37 class GroupManager;
38 class PublishManager;
39 class ShareManager;
40 class SubscribeManager;
41 
47 class CloudBackend {
48 public:
90  static cbe::CloudBackend logIn(const std::string& username,
91  const std::string& password,
92  const std::string& tenant,
93  const std::string& client,
94  LogInDelegatePtr delegate);
95 
96 #ifndef DOXYGEN_SHOULD_SKIP_THIS
107  static cbe::CloudBackend logIn(const std::string& username,
108  const std::string& password,
109  const std::string& tenant,
110  LogInDelegatePtr delegate);
111 
112  // Internal test
127  static cbe::CloudBackend logIn(const std::string& username,
128  const std::string& password,
129  const std::string& tenant,
130  const std::string& client,
131  bool useEdgeNodes,
132  LogInDelegatePtr delegate);
133  // Internal test
148  static cbe::CloudBackend logIn(const std::string& username,
149  const std::string& password,
150  const std::string& tenant,
151  const std::string& client,
152  const std::string& host,
153  LogInDelegatePtr delegate);
154 #endif // DOXYGEN_SHOULD_SKIP_THIS
155 
156 #ifndef CBE_NO_SYNC
160  using LogInException = delegate::LogInDelegate::Exception;
179  static cbe::CloudBackend logIn(const std::string& username,
180  const std::string& password,
181  const std::string& tenant,
182  const std::string& client);
183  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
184 #ifndef DOXYGEN_SHOULD_SKIP_THIS
198  static cbe::CloudBackend logIn(const std::string& username,
199  const std::string& password,
200  const std::string& tenant);
201  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
202 
203  // Internal test
220  static cbe::CloudBackend logIn(const std::string& username,
221  const std::string& password,
222  const std::string& tenant,
223  const std::string& client,
224  bool useEdgeNodes);
225  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
242  static cbe::CloudBackend logIn(const std::string& username,
243  const std::string& password,
244  const std::string& tenant,
245  const std::string& client,
246  const std::string& host);
247 #endif // DOXYGEN_SHOULD_SKIP_THIS
248  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
256  using LogInError = delegate::LogInDelegate::ErrorInfo;
283  static cbe::CloudBackend logIn(const std::string& username,
284  const std::string& password,
285  const std::string& tenant,
286  const std::string& client,
287  LogInError& error);
288  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
289 #ifndef DOXYGEN_SHOULD_SKIP_THIS
313  static cbe::CloudBackend logIn(const std::string& username,
314  const std::string& password,
315  const std::string& tenant,
316  LogInError& error);
317  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
318  // Internal test
343  static cbe::CloudBackend logIn(const std::string& username,
344  const std::string& password,
345  const std::string& tenant,
346  const std::string& client,
347  bool useEdgeNodes,
348  LogInError& error);
349  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
374  static cbe::CloudBackend logIn(const std::string& username,
375  const std::string& password,
376  const std::string& tenant,
377  const std::string& client,
378  const std::string& host,
379  LogInError& error);
380 #endif // DOXYGEN_SHOULD_SKIP_THIS
381 #endif // #ifndef CBE_NO_SYNC
382 
409  static cbe::UserId createAccount(const std::string& username,
410  const std::string& password,
411  const std::string& email,
412  const std::string& firstName,
413  const std::string& lastName,
414  const std::string& tenant,
415  const std::string& client,
416  CreateAccountDelegatePtr delegate);
417 #ifndef CBE_NO_SYNC
421  using CreateAccountException = delegate::CreateAccountDelegate::Exception;
439  static cbe::UserId createAccount(const std::string& username,
440  const std::string& password,
441  const std::string& email,
442  const std::string& firstName,
443  const std::string& lastName,
444  const std::string& tenant,
445  const std::string& client);
446 
453  using CreateAccountError = delegate::CreateAccountDelegate::ErrorInfo;
471  static cbe::util::Optional<cbe::UserId> createAccount(const std::string& username,
472  const std::string& password,
473  const std::string& email,
474  const std::string& firstName,
475  const std::string& lastName,
476  const std::string& tenant,
477  const std::string& client,
478  CreateAccountError& error);
479 #endif // #ifndef CBE_NO_SYNC
480 
481 
489  std::shared_ptr<delegate::CloudBackendListenerDelegate>;
493  using ListenerHandle = std::uint64_t;
508 
517 
532  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
597  QueryDelegatePtr queryDelegate);
607  Filter filter,
608  QueryDelegatePtr queryDelegate);
609 
640  QueryJoinDelegatePtr queryJoinDelegate);
650  Filter filter,
651  QueryJoinDelegatePtr queryJoinDelegate);
652 
653 #ifndef CBE_NO_SYNC
654  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
656  using QueryException = delegate::QueryDelegate::Exception;
679  cbe::QueryChainSync query(ContainerId containerId);
680 
689  cbe::QueryChainSync query(ContainerId containerId,
690  Filter filter);
691  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
693  using QueryJoinError = delegate::QueryJoinDelegate::ErrorInfo;
722  cbe::QueryChainSync query(ContainerId containerId,
723  QueryJoinError& error);
724 
739  cbe::QueryChainSync query(ContainerId containerId,
740  Filter filter,
741  QueryJoinError& error);
742 
743  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
745  using QueryError = delegate::QueryDelegate::ErrorInfo;
746  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
747 #endif // #ifndef CBE_NO_SYNC
748 
766  cbe::QueryChain queryWithPath(std::string relativePath,
767  cbe::ContainerId queryRoot,
768  QueryDelegatePtr delegate);
777  cbe::QueryChain queryWithPath(std::string relativePath,
778  QueryDelegatePtr delegate);
779 
802  cbe::QueryResult search(std::string tags,
803  cbe::ContainerId containerId,
804  QueryDelegatePtr delegate);
805 
812 #ifndef CBE_NO_SYNC
816  using SearchException = delegate::QueryDelegate::Exception;
830  cbe::QueryResult search(std::string tags,
831  cbe::ContainerId containerId);
832 
839  using SearchError = delegate::QueryDelegate::ErrorInfo;
861  std::string tags,
862  cbe::ContainerId containerId,
863  SearchError& error);
864 #endif // #ifndef CBE_NO_SYNC
865  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
866 
893  cbe::ContainerId containerId,
894  QueryDelegatePtr delegate);
895 
896 
903 #ifndef CBE_NO_SYNC
921  cbe::ContainerId containerId);
922 
950  cbe::ContainerId containerId,
951  SearchError& error);
952 #endif // #ifndef CBE_NO_SYNC
953  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
954 
955 
956 #ifndef DOXYGEN_SHOULD_SKIP_THIS
968  // void restRequest(std::string uri,
969  // cbe::http_t requestType,
970  // std::string contentType,
971  // cbe::APIDelegatePtr delegate);
972 
985  // void soapRequest(std::string body,
986  // std::string soapAction,
987  // cbe::APIDelegatePtr delegate);
988 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
989 
997 
1005 
1014  bool clearCache();
1015 
1022 
1023 
1029  std::string version() const;
1030 
1037 
1044 
1050  cbe::PublishManager publishManager(); // Publish (web shares)
1051 
1052 
1059  void terminate();
1060 
1066  cbe::SubscribeManager subscribeManager(); // Subscribe (following)
1067 
1077  ~CloudBackend();
1078 
1091  explicit operator bool() const;
1092 private:
1093  struct Impl;
1094  std::shared_ptr<Impl> pImpl{};
1095 
1096  CloudBackend(CBI::CloudBackendPtr cbiPeerPtr);
1100  CBI::CloudBackend& getCbiPeer() const;
1101 
1102 }; // class CloudBackend
1103 
1104 } // namespace cbe
1105 // namespace cbe
1106 
1107 #endif // INCLUDE_CBE_CLOUDBACKEND_H_
Login account information.
Definition: Account.h:26
The session that holds the connection with the cloud.
Definition: CloudBackend.h:47
delegate::LogInDelegatePtr LogInDelegatePtr
Definition: CloudBackend.h:55
static cbe::CloudBackend logIn(const std::string &username, const std::string &password, const std::string &tenant, const std::string &client, LogInDelegatePtr delegate)
Logs in to the CloudBackend service.
delegate::QueryJoinDelegatePtr QueryJoinDelegatePtr
Definition: CloudBackend.h:619
cbe::QueryChainExt query(ContainerId containerId, Filter filter, QueryJoinDelegatePtr queryJoinDelegate)
Join multiple tables using filter (where).
static cbe::Container castContainer(cbe::Item item)
Casts an item to a container.
cbe::PublishManager publishManager()
Gets the publish manager.
delegate::CreateAccountDelegatePtr CreateAccountDelegatePtr
Definition: CloudBackend.h:389
void terminate()
Terminates the CloudBackend service.
cbe::QueryChain queryWithPath(std::string relativePath, cbe::ContainerId queryRoot, QueryDelegatePtr delegate)
Queries items of a container with a given path.
cbe::SubscribeManager subscribeManager()
Gets the subscribe manager.
void removeListener(ListenerHandle handle)
Delete a specific listener.
cbe::ShareManager shareManager()
Gets the share manager.
cbe::GroupManager groupManager()
Gets the group manager.
cbe::QueryChain query(ContainerId containerId, Filter filter, QueryDelegatePtr queryDelegate)
Select Item's of a container (table) with a filter (where).
cbe::QueryChain queryWithPath(std::string relativePath, QueryDelegatePtr delegate)
Queries items of a container with a given path relative the home root container.
bool clearCache()
Clear the local cache.
ListenerHandle addListener(CloudBackendListenerDelegatePtr listener)
Listen for changes to specific items.
static cbe::UserId createAccount(const std::string &username, const std::string &password, const std::string &email, const std::string &firstName, const std::string &lastName, const std::string &tenant, const std::string &client, CreateAccountDelegatePtr delegate)
Creates a user account.
std::shared_ptr< delegate::CloudBackendListenerDelegate > CloudBackendListenerDelegatePtr
Definition: CloudBackend.h:489
static cbe::Object castObject(cbe::Item item)
Casts an item to an object.
std::uint64_t ListenerHandle
Handle identifying a registered Listener.
Definition: CloudBackend.h:493
cbe::Account account()
Returns an account object with information on the user.
cbe::QueryResult search(std::string tags, cbe::ContainerId containerId, QueryDelegatePtr delegate)
Select Object's with specified key/values.
delegate::QueryDelegatePtr QueryDelegatePtr
Definition: CloudBackend.h:531
cbe::QueryChain query(ContainerId containerId, QueryDelegatePtr queryDelegate)
Select Item's of a container (table).
cbe::QueryResult search(cbe::Filter filter, cbe::ContainerId containerId, QueryDelegatePtr delegate)
Select Object's with specified key/values using filter.
CloudBackend(cbe::DefaultCtor)
Default constructor.
std::string version() const
Returns the version number of the SDK.
cbe::QueryChainExt query(ContainerId containerId, QueryJoinDelegatePtr queryJoinDelegate)
Join multiple tables.
A collection of Item, can also represent a table or folder.
Definition: Container.h:63
Use to select Item that meets specific criterias when doing a query.
Definition: Filter.h:40
For managing the groups.
Definition: GroupManager.h:30
A set made up of Container and Object.
Definition: Item.h:36
Holder of a set of data, can represent a table row.
Definition: Object.h:64
Managing the list of web shares.
Definition: PublishManager.h:21
Extension of class QueryChain.
Definition: QueryChain.h:150
To do a search for Object combining more than one Container table.
Definition: QueryChain.h:32
resultset of data retrieved.
Definition: QueryResult.h:51
Managing Shares.
Definition: ShareManager.h:27
For managing subscriptions.
Definition: SubscribeManager.h:30
QueryDelegate::ErrorInfo ErrorInfo
Definition: QueryJoinDelegate.h:47
Class template Optional manages an optional contained value - i.e., a value that is either present or...
Definition: Optional.h:20
std::shared_ptr< LogInDelegate > LogInDelegatePtr
Definition: LogInDelegate.h:76
std::shared_ptr< QueryJoinDelegate > QueryJoinDelegatePtr
Definition: QueryJoinDelegate.h:76
std::shared_ptr< QueryDelegate > QueryDelegatePtr
Definition: QueryDelegate.h:100
std::shared_ptr< CreateAccountDelegate > CreateAccountDelegatePtr
Definition: CreateAccountDelegate.h:66
Root namespace for the CloudBackend SDK API.
Definition: Account.h:22
std::uint64_t UserId
Uniquely identifies the CBE user number.
Definition: Types.h:126
std::uint64_t ContainerId
Unique Id of a cbe::Container.
Definition: Types.h:60
DefaultCtor
Default constructor marker.
Definition: Types.h:204
Definition: CreateAccountDelegate.h:44
Definition: LogInDelegate.h:45
Definition: QueryDelegate.h:61