OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
MongoGroupFunctions.h
Go to the documentation of this file.
1#pragma once
2
3
4#include <iostream>
5#include <cstdint>
6#include <vector>
7#include <bsoncxx/json.hpp>
8#include <bsoncxx/types.hpp>
9#include <mongocxx/client.hpp>
10#include <mongocxx/stdx.hpp>
11#include <mongocxx/uri.hpp>
12#include <mongocxx/instance.hpp>
13#include <bsoncxx/builder/stream/helpers.hpp>
14#include <bsoncxx/builder/stream/document.hpp>
15#include <bsoncxx/builder/stream/array.hpp>
16
17#include "User.h"
18#include "Group.h"
19
20using bsoncxx::builder::stream::close_array;
21using bsoncxx::builder::stream::close_document;
22using bsoncxx::builder::stream::document;
23using bsoncxx::builder::stream::finalize;
24using bsoncxx::builder::stream::open_array;
25using bsoncxx::builder::stream::open_document;
26using bsoncxx::document::value;
27using bsoncxx::document::view;
28using bsoncxx::document::element;
29
30
31/*
32 1) Create Group
33 2) Get All User Groups
34 3) Get Group Data
35 4) Edit group Data
36 5) Add User to group
37 6) Remove User from group
38 7) Remove group
39*/
41{
42 void createGroup(std::string groupName, User& creatingUser, mongocxx::client& adminClient);
43
44
45 std::vector<Group> getAllUserGroups(User& loggedInUser, mongocxx::client& userClient);
46
47 std::vector<Group> getAllGroups(User& loggedInUser, mongocxx::client& userClient);
48 size_t getAllGroupCount(User& loggedInUser, mongocxx::client& userClient);
49
50 Group getGroupDataByName(std::string groupName, mongocxx::client& userClient);
51
52 Group getGroupDataById(std::string groupId, mongocxx::client& userClient);
53
54
55 bool changeGroupName(std::string oldName, std::string newName, mongocxx::client& adminClient);
56
57 bool changeGroupOwner(Group& group, User& oldUser, User& newUser, mongocxx::client& adminClient);
58
59 bool addUserToGroup(User& loggedInUser, std::string groupName, mongocxx::client& adminClient);
60
61
62 bool removeUserFromGroup(User& loggedInUser, std::string groupName, mongocxx::client& adminClient);
63
64 bool removeGroup(Group& groupToBeRemoved, mongocxx::client& adminClient);
65
66 std::string groupToJson(Group& grp);
67
68 std::string groupsToJson(std::vector<Group>& groups);
69 std::string generateUniqueGroupName(mongocxx::client& adminClient);
70
71}
Definition Group.h:20
Definition User.h:20
Definition MongoGroupFunctions.h:41
std::string groupsToJson(std::vector< Group > &groups)
Definition MongoGroupFunctions.cpp:453
Group getGroupDataById(std::string groupId, mongocxx::client &userClient)
Definition MongoGroupFunctions.cpp:202
bool changeGroupName(std::string oldName, std::string newName, mongocxx::client &adminClient)
Definition MongoGroupFunctions.cpp:244
void createGroup(std::string groupName, User &creatingUser, mongocxx::client &adminClient)
Definition MongoGroupFunctions.cpp:22
std::string generateUniqueGroupName(mongocxx::client &adminClient)
Definition MongoGroupFunctions.cpp:70
bool removeGroup(Group &groupToBeRemoved, mongocxx::client &adminClient)
Definition MongoGroupFunctions.cpp:421
bool changeGroupOwner(Group &group, User &oldUser, User &newUser, mongocxx::client &adminClient)
Definition MongoGroupFunctions.cpp:276
bool removeUserFromGroup(User &loggedInUser, std::string groupName, mongocxx::client &adminClient)
Definition MongoGroupFunctions.cpp:380
std::vector< Group > getAllGroups(User &loggedInUser, mongocxx::client &userClient)
Definition MongoGroupFunctions.cpp:129
bool addUserToGroup(User &loggedInUser, std::string groupName, mongocxx::client &adminClient)
Definition MongoGroupFunctions.cpp:334
std::string groupToJson(Group &grp)
Definition MongoGroupFunctions.cpp:442
size_t getAllGroupCount(User &loggedInUser, mongocxx::client &userClient)
Definition MongoGroupFunctions.cpp:149
Group getGroupDataByName(std::string groupName, mongocxx::client &userClient)
Definition MongoGroupFunctions.cpp:160
std::vector< Group > getAllUserGroups(User &loggedInUser, mongocxx::client &userClient)
Definition MongoGroupFunctions.cpp:107