Skip to content

Commit d777111

Browse files
committed
feat:getQueueMigrations, getQueueFunctions, getQueueMessaging, getQueueMails
1 parent beae4f9 commit d777111

File tree

11 files changed

+190
-6
lines changed

11 files changed

+190
-6
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ getQueueUsageWebhooks: $(SRCS) $(EXAMPLES_DIR)/health/params/getQueueUsageWebhoo
170170
$(CXX) $(CXXFLAGS) -o tests/health/params/getQueueUsageWebhooks $(SRCS) $(EXAMPLES_DIR)/health/params/getQueueUsageWebhooks.cpp $(LDFLAGS)
171171
getQueueUsageDump: $(SRCS) $(EXAMPLES_DIR)/health/params/getQueueUsageDump.cpp
172172
$(CXX) $(CXXFLAGS) -o tests/health/params/getQueueUsageDump $(SRCS) $(EXAMPLES_DIR)/health/params/getQueueUsageDump.cpp $(LDFLAGS)
173+
getQueueFunctions: $(SRCS) $(EXAMPLES_DIR)/health/params/getQueueFunctions.cpp
174+
$(CXX) $(CXXFLAGS) -o tests/health/params/getQueueFunctions $(SRCS) $(EXAMPLES_DIR)/health/params/getQueueFunctions.cpp $(LDFLAGS)
175+
getQueueMails: $(SRCS) $(EXAMPLES_DIR)/health/params/getQueueMails.cpp
176+
$(CXX) $(CXXFLAGS) -o tests/health/params/getQueueMails $(SRCS) $(EXAMPLES_DIR)/health/params/getQueueMails.cpp $(LDFLAGS)
177+
getQueueMessaging: $(SRCS) $(EXAMPLES_DIR)/health/params/getQueueMessaging.cpp
178+
$(CXX) $(CXXFLAGS) -o tests/health/params/getQueueMessaging $(SRCS) $(EXAMPLES_DIR)/health/params/getQueueMessaging.cpp $(LDFLAGS)
179+
getQueueMigrations: $(SRCS) $(EXAMPLES_DIR)/health/params/getQueueMigrations.cpp
180+
$(CXX) $(CXXFLAGS) -o tests/health/params/getQueueMigrations $(SRCS) $(EXAMPLES_DIR)/health/params/getQueueMigrations.cpp $(LDFLAGS)
173181

174182
clean:
175183
rm -f tests/*
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "Appwrite.hpp"
2+
#include <iostream>
3+
4+
int main() {
5+
std::string projectId = "66fbb5a100070a3a1d19";
6+
std::string apiKey = "";
7+
std::string threshold = "5";
8+
9+
Appwrite appwrite(projectId);
10+
Health& health = appwrite.getHealth();
11+
12+
health.setup(apiKey, projectId);
13+
14+
try {
15+
std::string response = health.getQueueFunctions(threshold);
16+
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
17+
} catch (const AppwriteException& ex) {
18+
std::cerr << "Exception: " << ex.what() << std::endl;
19+
}
20+
21+
return 0;
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "Appwrite.hpp"
2+
#include <iostream>
3+
4+
int main() {
5+
std::string projectId = "66fbb5a100070a3a1d19";
6+
std::string apiKey = "";
7+
std::string threshold = "5";
8+
9+
Appwrite appwrite(projectId);
10+
Health& health = appwrite.getHealth();
11+
12+
health.setup(apiKey, projectId);
13+
14+
try {
15+
std::string response = health.getQueueMails(threshold);
16+
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
17+
} catch (const AppwriteException& ex) {
18+
std::cerr << "Exception: " << ex.what() << std::endl;
19+
}
20+
21+
return 0;
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "Appwrite.hpp"
2+
#include <iostream>
3+
4+
int main() {
5+
std::string projectId = "66fbb5a100070a3a1d19";
6+
std::string apiKey = "";
7+
std::string threshold = "5";
8+
9+
Appwrite appwrite(projectId);
10+
Health& health = appwrite.getHealth();
11+
12+
health.setup(apiKey, projectId);
13+
14+
try {
15+
std::string response = health.getQueueMessaging(threshold);
16+
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
17+
} catch (const AppwriteException& ex) {
18+
std::cerr << "Exception: " << ex.what() << std::endl;
19+
}
20+
21+
return 0;
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "Appwrite.hpp"
2+
#include <iostream>
3+
4+
int main() {
5+
std::string projectId = "66fbb5a100070a3a1d19";
6+
std::string apiKey = "";
7+
std::string threshold = "5";
8+
9+
Appwrite appwrite(projectId);
10+
Health& health = appwrite.getHealth();
11+
12+
health.setup(apiKey, projectId);
13+
14+
try {
15+
std::string response = health.getQueueMigrations(threshold);
16+
std::cout << "Health Check Done! \nResponse: " << response << std::endl;
17+
} catch (const AppwriteException& ex) {
18+
std::cerr << "Exception: " << ex.what() << std::endl;
19+
}
20+
21+
return 0;
22+
}

include/classes/Health.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ class Health {
2121
std::string getTime();
2222
std::string getQueue();
2323
std::string getCertificate(const std::string& domain = "");
24+
std::string getQueueMails(const std::string& domain = "");
2425
std::string getQueueCertificates(const std::string& threshold = "");
2526
std::string getQueueBuilds(const std::string& threshold = "");
27+
std::string getQueueMessaging(const std::string& threshold = "");
28+
std::string getQueueMigrations(const std::string& threshold = "");
29+
std::string getQueueFunctions(const std::string& threshold = "");
2630
std::string getQueueUsageWebhooks(const std::string& threshold = "");
2731
std::string getQueueUsageDump(const std::string& threshold = "");
2832

src/services/Health.cpp

Lines changed: 90 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ std::string Health::getQueue(){
171171
return response;
172172
}
173173
else {
174-
throw AppwriteException("Error fetching time. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
174+
throw AppwriteException("Error fetching queue. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
175175
}
176176
}
177177

@@ -192,7 +192,7 @@ std::string Health::getCertificate(const std::string& domain){
192192
return response;
193193
}
194194
else {
195-
throw AppwriteException("Error fetching time. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
195+
throw AppwriteException("Error fetching certificates. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
196196
}
197197
}
198198

@@ -213,7 +213,7 @@ std::string Health::getQueueBuilds(const std::string& threshold){
213213
return response;
214214
}
215215
else {
216-
throw AppwriteException("Error fetching time. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
216+
throw AppwriteException("Error fetching queue builds. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
217217
}
218218
}
219219

@@ -234,7 +234,7 @@ std::string Health::getQueueCertificates(const std::string& threshold){
234234
return response;
235235
}
236236
else {
237-
throw AppwriteException("Error fetching time. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
237+
throw AppwriteException("Error fetching queue certificate. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
238238
}
239239
}
240240

@@ -255,7 +255,7 @@ std::string Health::getQueueUsageWebhooks(const std::string& threshold){
255255
return response;
256256
}
257257
else {
258-
throw AppwriteException("Error fetching time. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
258+
throw AppwriteException("Error fetching webhook usage. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
259259
}
260260
}
261261

@@ -276,7 +276,91 @@ std::string Health::getQueueUsageDump(const std::string& threshold){
276276
return response;
277277
}
278278
else {
279-
throw AppwriteException("Error fetching time. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
279+
throw AppwriteException("Error fetching usage-dump. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
280+
}
281+
}
282+
283+
std::string Health::getQueueMails(const std::string& threshold){
284+
std::string url = Config::API_BASE_URL + "/health/queue/mails";
285+
286+
std::string queryString = "threshold=" + Utils::urlEncode(threshold);
287+
url += "?" + queryString;
288+
289+
std::vector<std::string> headers = Config::getHeaders(projectId);
290+
headers.push_back("X-Appwrite-Key: " + apiKey);
291+
292+
std::string response;
293+
294+
int statusCode = Utils::getRequest(url, headers, response);
295+
296+
if (statusCode == HttpStatus::OK) {
297+
return response;
298+
}
299+
else {
300+
throw AppwriteException("Error fetching mails. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
301+
}
302+
}
303+
304+
std::string Health::getQueueMessaging(const std::string& threshold){
305+
std::string url = Config::API_BASE_URL + "/health/queue/messaging";
306+
307+
std::string queryString = "threshold=" + Utils::urlEncode(threshold);
308+
url += "?" + queryString;
309+
310+
std::vector<std::string> headers = Config::getHeaders(projectId);
311+
headers.push_back("X-Appwrite-Key: " + apiKey);
312+
313+
std::string response;
314+
315+
int statusCode = Utils::getRequest(url, headers, response);
316+
317+
if (statusCode == HttpStatus::OK) {
318+
return response;
319+
}
320+
else {
321+
throw AppwriteException("Error fetching messages from queues. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
322+
}
323+
}
324+
325+
std::string Health::getQueueMigrations(const std::string& threshold){
326+
std::string url = Config::API_BASE_URL + "/health/queue/migrations";
327+
328+
std::string queryString = "threshold=" + Utils::urlEncode(threshold);
329+
url += "?" + queryString;
330+
331+
std::vector<std::string> headers = Config::getHeaders(projectId);
332+
headers.push_back("X-Appwrite-Key: " + apiKey);
333+
334+
std::string response;
335+
336+
int statusCode = Utils::getRequest(url, headers, response);
337+
338+
if (statusCode == HttpStatus::OK) {
339+
return response;
340+
}
341+
else {
342+
throw AppwriteException("Error fetching migration queues. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
343+
}
344+
}
345+
346+
std::string Health::getQueueFunctions(const std::string& threshold){
347+
std::string url = Config::API_BASE_URL + "/health/queue/functions";
348+
349+
std::string queryString = "threshold=" + Utils::urlEncode(threshold);
350+
url += "?" + queryString;
351+
352+
std::vector<std::string> headers = Config::getHeaders(projectId);
353+
headers.push_back("X-Appwrite-Key: " + apiKey);
354+
355+
std::string response;
356+
357+
int statusCode = Utils::getRequest(url, headers, response);
358+
359+
if (statusCode == HttpStatus::OK) {
360+
return response;
361+
}
362+
else {
363+
throw AppwriteException("Error fetching function queues. Status code: " + std::to_string(statusCode) + "\n\nResponse: " + response);
280364
}
281365
}
282366

tests/health/params/getQueueFunctions

1.27 MB
Binary file not shown.

tests/health/params/getQueueMails

1.27 MB
Binary file not shown.

tests/health/params/getQueueMessaging

1.27 MB
Binary file not shown.

0 commit comments

Comments
 (0)