SDK  2.1.4 [async]
CloudBackend Software Development Kit - SDK API for C++
Group.h
1 /*
2  Copyright © CloudBackend AB 2020-2023.
3  */
4 #ifndef INCLUDE_CBE_GROUP_H_
5 #define INCLUDE_CBE_GROUP_H_
6 
7 #include <string>
8 #include "cbe/util/Context.h"
9 #include "cbe/Member.h"
10 #include "cbe/Types.h"
11 
12 #include "cbe/delegate/Error.h"
13 #include "cbe/delegate/CreateGroupDelegate.h"
14 #include "cbe/delegate/CreateRoleDelegate.h"
15 #include "cbe/delegate/LeaveDelegate.h"
16 #include "cbe/delegate/ListMembersDelegate.h"
17 #include "cbe/delegate/ListRolesDelegate.h"
18 #include "cbe/delegate/RemoveRoleDelegate.h"
19 
20 #include "cbe/delegate/group/JoinDelegate.h"
21 #include "cbe/delegate/group/RemoveDelegate.h"
22 #include "cbe/delegate/group/RenameDelegate.h"
23 
24 #include "cbe/delegate/Error.h"
25 #include "cbe/util/ErrorInfo.h"
26 #include "cbe/util/Exception.h"
27 #include "cbe/util/Optional.h"
28 
29 namespace CBI {
30 class Group;
31 using GroupPtr = std::shared_ptr<CBI::Group>;
32 class GroupEventProtocol;
33 using GroupDelegatePtr = std::shared_ptr<GroupEventProtocol>;
34 } // namespace CBI
35 
36 namespace cbe {
37 
42 class Group {
43 public:
47  std::string name() const;
48 
52  cbe::GroupId id() const;
53 
58 
64 
72 
79  bool joined() const;
80 
81  using Requests = std::vector<cbe::Request>;
86  Requests requests() const;
106  std::string memberAlias,
107  cbe::Visibility visibility,
108  CreateGroupDelegatePtr delegate);
109 
110 #ifndef CBE_NO_SYNC
114  using CreateGroupException = delegate::CreateGroupDelegate::Exception;
131  std::string name,
132  std::string memberAlias,
133  cbe::Visibility visibility);
134 
141  using CreateGroupError = delegate::CreateGroupDelegate::ErrorInfo;
162  std::string name,
163  std::string memberAlias,
164  cbe::Visibility visibility,
165  CreateGroupError& error);
166 #endif // #ifndef CBE_NO_SYNC
167  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
189  void join(std::string alias,
190  cbe::Visibility memberVisibility,
191  std::string applicationComment,
192  JoinDelegatePtr delegate);
193 
194 #ifndef CBE_NO_SYNC
198  using JoinException = delegate::group::JoinDelegate::Exception;
213  std::string alias,
214  cbe::Visibility memberVisibility,
215  std::string applicationComment);
216 
245  std::string alias,
246  cbe::Visibility memberVisibility,
247  std::string applicationComment,
248  JoinError& error);
249 #endif // #ifndef CBE_NO_SYNC
250  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
263  void leave(LeaveDelegatePtr delegate);
264 
265 #ifndef CBE_NO_SYNC
269  using LeaveException = delegate::LeaveDelegate::Exception;
284 
291  using LeaveError = delegate::LeaveDelegate::ErrorInfo;
313 
314 #endif // #ifndef CBE_NO_SYNC
315  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
331  void remove(RemoveDelegatePtr delegate);
332 
333 #ifndef CBE_NO_SYNC
337  using RemoveException = delegate::group::RemoveDelegate::Exception;
352 
359  using RemoveError = delegate::group::RemoveDelegate::ErrorInfo;
381 
382 #endif // #ifndef CBE_NO_SYNC
383  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
397  void rename(std::string newName, RenameDelegatePtr delegate);
398 #ifndef CBE_NO_SYNC
402  using RenameException = delegate::group::RenameDelegate::Exception;
416  delegate::group::RenameSuccess rename(std::string newName);
417 
424  using RenameError = delegate::group::RenameDelegate::ErrorInfo;
446  std::string newName,
447  RenameError& error);
448 #endif // #ifndef CBE_NO_SYNC
449  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
466 
467 #ifndef CBE_NO_SYNC
471  using ListMembersException = delegate::ListMembersDelegate::Exception;
485  delegate::ListMembersDelegate::Members listMembers();
486 
493  using ListMembersError = delegate::ListMembersDelegate::ErrorInfo;
515  ListMembersError& error);
516 #endif // #ifndef CBE_NO_SYNC
517  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
531 
532 #ifndef CBE_NO_SYNC
536  using ListBannedMembersException = delegate::ListMembersDelegate::Exception;
550  std::vector<cbe::Member> listBannedMembers();
551 
558  using ListBannedMembersError = delegate::ListMembersDelegate::ErrorInfo;
580  ListBannedMembersError& error);
581 #endif // #ifndef CBE_NO_SYNC
582  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
596 
597 #ifndef CBE_NO_SYNC
601  using ListRolesException = delegate::ListRolesDelegate::Exception;
615  delegate::ListRolesDelegate::Roles listRoles();
616 
623  using ListRolesError = delegate::ListRolesDelegate::ErrorInfo;
645  ListRolesError& error);
646 #endif // #ifndef CBE_NO_SYNC
647  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
662  void createRole(std::string name, CreateRoleDelegatePtr delegate);
663 #ifndef CBE_NO_SYNC
667  using CreateRoleException = delegate::CreateRoleDelegate::Exception;
681  cbe::Role createRole(std::string name);
682 
689  using CreateRoleError = delegate::CreateRoleDelegate::ErrorInfo;
711  CreateRoleError& error);
712 #endif // #ifndef CBE_NO_SYNC
713  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
728  void removeRole(RoleId roleId, RemoveRoleDelegatePtr delegate);
729 #ifndef CBE_NO_SYNC
733  using RemoveRoleException = delegate::RemoveRoleDelegate::Exception;
747  cbe::RoleId removeRole(RoleId roleId);
748 
755  using RemoveRoleError = delegate::RemoveRoleDelegate::ErrorInfo;
777  RemoveRoleError& error);
778 #endif // #ifndef CBE_NO_SYNC
779  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
780 
790  ~Group();
791 
804  explicit operator bool() const;
805 
806 private:
807  struct Impl;
808  std::shared_ptr<Impl> pImpl{};
809  friend class GroupManager;
810  friend class GroupQueryResult;
811  Group(CBI::GroupPtr cbiPeerPtr);
812  CBI::Group& getCbiPeer() const;
813 }; // class Group
814 
815 } // namespace cbe
816 
817 #endif // INCLUDE_CBE_GROUP_H_
A collection of Item, can also represent a table or folder.
Definition: Container.h:63
For managing the groups.
Definition: GroupManager.h:30
Resultset of data retrieved in a search for Group.
Definition: GroupQueryResult.h:27
A group of members.
Definition: Group.h:42
void join(std::string alias, cbe::Visibility memberVisibility, std::string applicationComment, JoinDelegatePtr delegate)
Synchronous [exception] Ask to join a group. In this first version All members will be Public,...
cbe::Container groupContainer() const
void listBannedMembers(ListBannedMembersDelegatePtr delegate)
Lists all banned former members, or users.
void listMembers(ListMembersDelegatePtr delegate)
List all members in the group.
delegate::LeaveDelegatePtr LeaveDelegatePtr
Definition: Group.h:256
std::string name() const
void rename(std::string newName, RenameDelegatePtr delegate)
Rename the Group; group id does not change.
delegate::group::JoinDelegatePtr JoinDelegatePtr
Definition: Group.h:173
void remove(RemoveDelegatePtr delegate)
Remove group.
delegate::ListMembersDelegatePtr ListMembersDelegatePtr
Definition: Group.h:455
delegate::CreateRoleDelegatePtr CreateRoleDelegatePtr
Definition: Group.h:653
cbe::Visibility getVisibility() const
void createRole(std::string name, CreateRoleDelegatePtr delegate)
Creates a new role in the group.
delegate::group::RemoveDelegatePtr RemoveDelegatePtr
Definition: Group.h:322
bool joined() const
delegate::group::RenameDelegatePtr RenameDelegatePtr
Definition: Group.h:389
void listRoles(ListRolesDelegatePtr delegate)
Lists all roles in the group.
Requests requests() const
Group(cbe::DefaultCtor)
Default constructor.
cbe::GroupId parentId() const
void removeRole(RoleId roleId, RemoveRoleDelegatePtr delegate)
delegate::ListRolesDelegatePtr ListRolesDelegatePtr
Definition: Group.h:588
cbe::Group createGroup(std::string name, std::string memberAlias, cbe::Visibility visibility, CreateGroupDelegatePtr delegate)
Create a new Group.
void leave(LeaveDelegatePtr delegate)
Leave group.
cbe::GroupId id() const
delegate::RemoveRoleDelegatePtr RemoveRoleDelegatePtr
Definition: Group.h:719
delegate::CreateGroupDelegatePtr CreateGroupDelegatePtr
Definition: Group.h:91
delegate::ListMembersDelegatePtr ListBannedMembersDelegatePtr
Definition: Group.h:523
User role information.
Definition: Role.h:34
Definition: LeaveDelegate.h:64
Convenience type that bundles all parameters passed to method cbe::delegate::group::RemoveDelegate::o...
Definition: RemoveDelegate.h:76
Convenience type that bundles all parameters passed to method cbe::delegate::group::RenameDelegate::o...
Definition: RenameSuccess.h:17
Class template Optional manages an optional contained value - i.e., a value that is either present or...
Definition: Optional.h:20
std::shared_ptr< RenameDelegate > RenameDelegatePtr
Definition: RenameDelegate.h:63
std::shared_ptr< RemoveDelegate > RemoveDelegatePtr
Definition: RemoveDelegate.h:69
std::shared_ptr< JoinDelegate > JoinDelegatePtr
Definition: JoinDelegate.h:65
std::shared_ptr< CreateGroupDelegate > CreateGroupDelegatePtr
Definition: CreateGroupDelegate.h:63
std::shared_ptr< CreateRoleDelegate > CreateRoleDelegatePtr
Definition: CreateRoleDelegate.h:60
std::shared_ptr< ListRolesDelegate > ListRolesDelegatePtr
Definition: ListRolesDelegate.h:66
std::shared_ptr< ListMembersDelegate > ListMembersDelegatePtr
Definition: ListMembersDelegate.h:68
std::shared_ptr< RemoveRoleDelegate > RemoveRoleDelegatePtr
Definition: RemoveRoleDelegate.h:60
std::shared_ptr< LeaveDelegate > LeaveDelegatePtr
Definition: LeaveDelegate.h:63
Root namespace for the CloudBackend SDK API.
Definition: Account.h:22
std::uint64_t RoleId
Uniquely identifies the Role.
Definition: Types.h:108
Visibility
Definition: Types.h:375
DefaultCtor
Default constructor marker.
Definition: Types.h:204
std::uint64_t GroupId
Uniquely identifies the Group.
Definition: Types.h:84
Definition: CreateGroupDelegate.h:42
Definition: CreateRoleDelegate.h:39
Definition: LeaveDelegate.h:42
Definition: ListMembersDelegate.h:44
Definition: ListRolesDelegate.h:42
Definition: RemoveRoleDelegate.h:39