Skip to content

Commit e79b4c6

Browse files
committed
refactoring duplicacy as mentioned in #24
1 parent a31866a commit e79b4c6

23 files changed

+48
-121
lines changed

examples/health/getAntivirus.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
66
std::string apiKey = "";
7-
8-
Appwrite appwrite(projectId);
9-
Health& health = appwrite.getHealth();
10-
11-
health.setup(apiKey, projectId);
12-
7+
Appwrite appwrite(projectId, apiKey);
8+
139
try {
14-
std::string response = health.getAntivirus();
10+
std::string response = appwrite.getHealth().getAntivirus();
1511
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1612
} catch (const AppwriteException& ex) {
1713
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/getCache.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
66
std::string apiKey = "";
7-
8-
Appwrite appwrite(projectId);
9-
Health& health = appwrite.getHealth();
7+
Appwrite appwrite(projectId, apiKey);
108

11-
health.setup(apiKey, projectId);
12-
139
try {
14-
std::string response = health.getCache();
10+
std::string response = appwrite.getHealth().getCache();
1511
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1612
} catch (const AppwriteException& ex) {
1713
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/getDB.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
66
std::string apiKey = "";
7-
8-
Appwrite appwrite(projectId);
9-
Health& health = appwrite.getHealth();
7+
Appwrite appwrite(projectId, apiKey);
108

11-
health.setup(apiKey, projectId);
12-
139
try {
14-
std::string response = health.getDB();
10+
std::string response = appwrite.getHealth().getDB();
1511
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1612
} catch (const AppwriteException& ex) {
1713
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/getHealth.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
66
std::string apiKey = "";
7-
8-
Appwrite appwrite(projectId);
9-
Health& health = appwrite.getHealth();
7+
Appwrite appwrite(projectId, apiKey);
108

11-
health.setup(apiKey, projectId);
12-
139
try {
14-
std::string response = health.getHealth();
10+
std::string response = appwrite.getHealth().getHealthStatus();
1511
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1612
} catch (const AppwriteException& ex) {
1713
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/getPubSub.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
66
std::string apiKey = "";
7-
8-
Appwrite appwrite(projectId);
9-
Health& health = appwrite.getHealth();
7+
Appwrite appwrite(projectId, apiKey);
108

11-
health.setup(apiKey, projectId);
12-
139
try {
14-
std::string response = health.getPubSub();
10+
std::string response = appwrite.getHealth().getPubSub();
1511
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1612
} catch (const AppwriteException& ex) {
1713
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/getQueue.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
66
std::string apiKey = "";
7-
8-
Appwrite appwrite(projectId);
9-
Health& health = appwrite.getHealth();
7+
Appwrite appwrite(projectId, apiKey);
108

11-
health.setup(apiKey, projectId);
12-
139
try {
14-
std::string response = health.getQueue();
10+
std::string response = appwrite.getHealth().getQueue();
1511
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1612
} catch (const AppwriteException& ex) {
1713
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/getStorage.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
66
std::string apiKey = "";
7-
8-
Appwrite appwrite(projectId);
9-
Health& health = appwrite.getHealth();
7+
Appwrite appwrite(projectId, apiKey);
108

11-
health.setup(apiKey, projectId);
12-
139
try {
14-
std::string response = health.getStorage();
10+
std::string response = appwrite.getHealth().getStorage();
1511
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1612
} catch (const AppwriteException& ex) {
1713
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/getStorageLocal.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
66
std::string apiKey = "";
7-
8-
Appwrite appwrite(projectId);
9-
Health& health = appwrite.getHealth();
7+
Appwrite appwrite(projectId, apiKey);
108

11-
health.setup(apiKey, projectId);
12-
139
try {
14-
std::string response = health.getStorageLocal();
10+
std::string response = appwrite.getHealth().getStorageLocal();
1511
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1612
} catch (const AppwriteException& ex) {
1713
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/getTime.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@
33

44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
6-
std::string apiKey = "";
7-
86
Appwrite appwrite(projectId);
9-
Health& health = appwrite.getHealth();
10-
11-
health.setup(apiKey, projectId);
12-
7+
138
try {
14-
std::string response = health.getTime();
9+
std::string response = appwrite.getHealth().getTime();
1510
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1611
} catch (const AppwriteException& ex) {
1712
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/params/getCertificate.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33

44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
6-
std::string apiKey = "";
76
std::string domain = "pooranjoyb.tech";
8-
9-
Appwrite appwrite(projectId);
10-
Health& health = appwrite.getHealth();
11-
12-
health.setup(apiKey, projectId);
7+
std::string apiKey = "";
8+
Appwrite appwrite(projectId, apiKey);
139

1410
try {
15-
std::string response = health.getCertificate(domain);
11+
std::string response = appwrite.getHealth().getCertificate(domain);
1612
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1713
} catch (const AppwriteException& ex) {
1814
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/params/getQueueBuilds.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33

44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
6-
std::string apiKey = "";
76
std::string threshold = "5";
8-
9-
Appwrite appwrite(projectId);
10-
Health& health = appwrite.getHealth();
7+
std::string apiKey = "";
8+
Appwrite appwrite(projectId, apiKey);
119

12-
health.setup(apiKey, projectId);
13-
1410
try {
15-
std::string response = health.getQueueBuilds(threshold);
11+
std::string response = appwrite.getHealth().getQueueBuilds(threshold);
1612
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1713
} catch (const AppwriteException& ex) {
1814
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/params/getQueueCertificates.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33

44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
6-
std::string apiKey = "";
76
std::string threshold = "5";
8-
9-
Appwrite appwrite(projectId);
10-
Health& health = appwrite.getHealth();
7+
std::string apiKey = "";
8+
Appwrite appwrite(projectId, apiKey);
119

12-
health.setup(apiKey, projectId);
13-
1410
try {
15-
std::string response = health.getQueueCertificates(threshold);
11+
std::string response = appwrite.getHealth().getQueueCertificates(threshold);
1612
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1713
} catch (const AppwriteException& ex) {
1814
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/params/getQueueFunctions.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33

44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
6-
std::string apiKey = "";
76
std::string threshold = "5";
8-
9-
Appwrite appwrite(projectId);
10-
Health& health = appwrite.getHealth();
7+
std::string apiKey = "";
8+
Appwrite appwrite(projectId, apiKey);
119

12-
health.setup(apiKey, projectId);
13-
1410
try {
15-
std::string response = health.getQueueFunctions(threshold);
11+
std::string response = appwrite.getHealth().getQueueFunctions(threshold);
1612
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1713
} catch (const AppwriteException& ex) {
1814
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/params/getQueueMails.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33

44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
6-
std::string apiKey = "";
76
std::string threshold = "5";
8-
9-
Appwrite appwrite(projectId);
10-
Health& health = appwrite.getHealth();
7+
std::string apiKey = "";
8+
Appwrite appwrite(projectId, apiKey);
119

12-
health.setup(apiKey, projectId);
13-
1410
try {
15-
std::string response = health.getQueueMails(threshold);
11+
std::string response = appwrite.getHealth().getQueueMails(threshold);
1612
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1713
} catch (const AppwriteException& ex) {
1814
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/params/getQueueMessaging.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33

44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
6-
std::string apiKey = "";
76
std::string threshold = "5";
8-
9-
Appwrite appwrite(projectId);
10-
Health& health = appwrite.getHealth();
7+
std::string apiKey = "";
8+
Appwrite appwrite(projectId, apiKey);
119

12-
health.setup(apiKey, projectId);
13-
1410
try {
15-
std::string response = health.getQueueMessaging(threshold);
11+
std::string response = appwrite.getHealth().getQueueMessaging(threshold);
1612
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1713
} catch (const AppwriteException& ex) {
1814
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/params/getQueueMigrations.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33

44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
6-
std::string apiKey = "";
76
std::string threshold = "5";
8-
9-
Appwrite appwrite(projectId);
10-
Health& health = appwrite.getHealth();
11-
12-
health.setup(apiKey, projectId);
7+
std::string apiKey = "";
8+
Appwrite appwrite(projectId, apiKey);
139

1410
try {
15-
std::string response = health.getQueueMigrations(threshold);
11+
std::string response = appwrite.getHealth().getQueueMigrations(threshold);
1612
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1713
} catch (const AppwriteException& ex) {
1814
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/params/getQueueUsageDump.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33

44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
6-
std::string apiKey = "";
76
std::string threshold = "5";
8-
9-
Appwrite appwrite(projectId);
10-
Health& health = appwrite.getHealth();
7+
std::string apiKey = "";
8+
Appwrite appwrite(projectId, apiKey);
119

12-
health.setup(apiKey, projectId);
13-
1410
try {
15-
std::string response = health.getQueueUsageDump(threshold);
11+
std::string response = appwrite.getHealth().getQueueUsageDump(threshold);
1612
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1713
} catch (const AppwriteException& ex) {
1814
std::cerr << "Exception: " << ex.what() << std::endl;

examples/health/params/getQueueUsageWebhooks.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33

44
int main() {
55
std::string projectId = "66fbb5a100070a3a1d19";
6-
std::string apiKey = "";
76
std::string threshold = "5";
8-
9-
Appwrite appwrite(projectId);
10-
Health& health = appwrite.getHealth();
7+
std::string apiKey = "";
8+
Appwrite appwrite(projectId, apiKey);
119

12-
health.setup(apiKey, projectId);
13-
1410
try {
15-
std::string response = health.getQueueUsageWebhooks(threshold);
11+
std::string response = appwrite.getHealth().getQueueUsageWebhooks(threshold);
1612
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
1713
} catch (const AppwriteException& ex) {
1814
std::cerr << "Exception: " << ex.what() << std::endl;

include/classes/Health.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Health {
1111
Health(const std::string& projectId, const std::string& apiKey);
1212

1313
// core
14-
std::string getHealth();
14+
std::string getHealthStatus();
1515
std::string getAntivirus();
1616
std::string getCache();
1717
std::string getDB();

src/services/Health.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Health::Health(const std::string& projectId, const std::string& apiKey)
1111
: projectId(projectId), apiKey(apiKey) {}
1212

13-
std::string Health::getHealth(){
13+
std::string Health::getHealthStatus(){
1414

1515
std::string url = Config::API_BASE_URL + "/health";
1616

tests/health/getDB

109 KB
Binary file not shown.

tests/health/getHealth

63.6 KB
Binary file not shown.

tests/health/getPubSub

63.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)