SDK  2.1.4
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
131  std::string name,
132  std::string memberAlias,
133  cbe::Visibility visibility);
134 
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
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
284 
313 
314 #endif // #ifndef CBE_NO_SYNC
315  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
331  void remove(RemoveDelegatePtr delegate);
332 
333 #ifndef CBE_NO_SYNC
352 
381 
382 #endif // #ifndef CBE_NO_SYNC
383  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
397  void rename(std::string newName, RenameDelegatePtr delegate);
398 #ifndef CBE_NO_SYNC
417 
446  std::string newName,
447  RenameError& error);
448 #endif // #ifndef CBE_NO_SYNC
449  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
466 
467 #ifndef CBE_NO_SYNC
485  delegate::ListMembersDelegate::Members listMembers();
486 
515  ListMembersError& error);
516 #endif // #ifndef CBE_NO_SYNC
517  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
531 
532 #ifndef CBE_NO_SYNC
550  std::vector<cbe::Member> listBannedMembers();
551 
580  ListBannedMembersError& error);
581 #endif // #ifndef CBE_NO_SYNC
582  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
596 
597 #ifndef CBE_NO_SYNC
615  delegate::ListRolesDelegate::Roles listRoles();
616 
645  ListRolesError& error);
646 #endif // #ifndef CBE_NO_SYNC
647  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
662  void createRole(std::string name, CreateRoleDelegatePtr delegate);
663 #ifndef CBE_NO_SYNC
681  cbe::Role createRole(std::string name);
682 
711  CreateRoleError& error);
712 #endif // #ifndef CBE_NO_SYNC
713  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
728  void removeRole(RoleId roleId, RemoveRoleDelegatePtr delegate);
729 #ifndef CBE_NO_SYNC
748 
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,...
delegate::group::RemoveSuccess remove()
Synchronous [exception] removes the specified group. Synchronous version of remove(RemoveDelegatePtr)...
cbe::Container groupContainer() const
void listBannedMembers(ListBannedMembersDelegatePtr delegate)
Lists all banned former members, or users.
delegate::ListMembersDelegate::Members listMembers()
Synchronous [exception] list members of the specifed group. Synchronous version of listMembers(ListMe...
cbe::util::Optional< cbe::Group > createGroup(std::string name, std::string memberAlias, cbe::Visibility visibility, CreateGroupError &error)
void listMembers(ListMembersDelegatePtr delegate)
List all members in the group.
delegate::LeaveDelegatePtr LeaveDelegatePtr
Definition: Group.h:256
cbe::util::Optional< delegate::group::RemoveSuccess > remove(RemoveError &error)
Synchronous [non-throwing] removes the specified group. Synchronous version of remove(RemoveDelegateP...
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
cbe::util::Optional< cbe::Group > join(std::string alias, cbe::Visibility memberVisibility, std::string applicationComment, JoinError &error)
Synchronous [non-throwing] Ask to join a group. Synchronous version of join(alias,...
cbe::Group join(std::string alias, cbe::Visibility memberVisibility, std::string applicationComment)
Synchronous [exception] Ask to join a group. Synchronous version of join(std::string,...
delegate::group::RenameSuccess rename(std::string newName)
Synchronous [exception] renames a group Synchronous version of rename(std::string ,...
cbe::Role createRole(std::string name)
Synchronous [exception] creates a new role in the specified group. Synchronous version of createRole(...
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.
cbe::util::Optional< cbe::RoleId > removeRole(RoleId roleId, RemoveRoleError &error)
Synchronous [non-throwing] removes a role in the specified group. Synchronous version of removeRole(r...
cbe::RoleId removeRole(RoleId roleId)
Synchronous [exception] removes a role in the specified group. Synchronous version of removeRole(Role...
delegate::ListRolesDelegate::Roles listRoles()
Synchronous [exception] list roles of a group. Synchronous version of listRoles(ListRolesDelegatePtr)...
cbe::util::Optional< delegate::LeaveSuccess > leave(LeaveError &error)
Synchronous [non-throwing] leaves the specified group. Synchronous version of leave(LeaveDelegatePtr)...
delegate::group::RemoveDelegatePtr RemoveDelegatePtr
Definition: Group.h:322
cbe::util::Optional< delegate::group::RenameSuccess > rename(std::string newName, RenameError &error)
Synchronous [non-throwing] renames a group Synchronous version of rename(newName,RenameDelegatePtr) ,...
bool joined() const
delegate::group::RenameDelegatePtr RenameDelegatePtr
Definition: Group.h:389
void listRoles(ListRolesDelegatePtr delegate)
Lists all roles in the group.
cbe::util::Optional< cbe::Role > createRole(std::string name, CreateRoleError &error)
Synchronous [non-throwing] creates a new role in the specified group. Synchronous version of createRo...
Requests requests() const
Group(cbe::DefaultCtor)
Default constructor.
cbe::util::Optional< delegate::ListRolesDelegate::Roles > listRoles(ListRolesError &error)
Synchronous [non-throwing] list roles of a group. Synchronous version of listRoles(ListRolesDelegateP...
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.
cbe::Group createGroup(std::string name, std::string memberAlias, cbe::Visibility visibility)
Synchronous [exception] creates a new group Synchronous version of createGroup(name,...
void leave(LeaveDelegatePtr delegate)
Leave group.
std::vector< cbe::Member > listBannedMembers()
Synchronous [exception] list the banned members of the specified group. Synchronous version of listBa...
cbe::GroupId id() const
delegate::LeaveSuccess leave()
Synchronous [exception] leaves the specified group. Synchronous version of leave(LeaveDelegatePtr) ,...
cbe::util::Optional< std::vector< cbe::Member > > listBannedMembers(ListBannedMembersError &error)
Synchronous [non-throwing] list the banned members of the specified group. Synchronous version of lis...
delegate::RemoveRoleDelegatePtr RemoveRoleDelegatePtr
Definition: Group.h:719
cbe::util::Optional< delegate::ListMembersDelegate::Members > listMembers(ListMembersError &error)
Synchronous [non-throwing] list members of the specifed group. Synchronous version of listMembers(Lis...
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
exception thrown by cbe::Group::createGroup() if the request fails.
Definition: CreateGroupDelegate.h:52
Definition: CreateRoleDelegate.h:39
exception thrown by cbe::Role::createRole() if the request fails.
Definition: CreateRoleDelegate.h:49
Definition: LeaveDelegate.h:42
exception thrown by cbe::Group::leave() if the if the request fails.
Definition: LeaveDelegate.h:52
Definition: ListMembersDelegate.h:44
exception thrown by cbe::Group::listMembers() if the request fails.
Definition: ListMembersDelegate.h:54
Definition: ListRolesDelegate.h:42
exception thrown by cbe::Group::ListRoles() if the request fails.
Definition: ListRolesDelegate.h:52
Definition: RemoveRoleDelegate.h:39
exception thrown by cbe::Role::removeRole() if the request fails.
Definition: RemoveRoleDelegate.h:49
exception thrown by cbe::Group::join() if the request fails.
Definition: JoinDelegate.h:52
exception thrown by cbe::Group::remove() if the request fails.
Definition: RemoveDelegate.h:55
exception thrown by cbe::Group::rename() if the request fails.
Definition: RenameDelegate.h:51