55#include " APIRequest.h"
66#include " APIResponse.h"
77#include " DataModels/Observation.h"
8+ #include " Query/ObservationsQuery.h"
9+ #include " Query/ObservationsOfDataStreamQuery.h"
810
911namespace ConnectedSystemsAPI {
1012 class ObservationsAPI {
@@ -18,28 +20,61 @@ namespace ConnectedSystemsAPI {
1820 : apiRoot(apiRoot), authHeader(authHeader) {
1921 }
2022
21- APIResponse<DataModels::Observation> getObservations () {
23+ // / <summary>
24+ // / List or search all observations available from this server endpoint.
25+ // / </summary>
26+ // / <param name="query">The query string parameters.</param>
27+ // / <returns>A response object containing a list of observations.</returns>
28+ APIResponse<DataModels::Observation> getObservations (const Query::ObservationsQuery& query) {
29+ return getObservations (query.toString ());
30+ }
31+
32+ // / <summary>
33+ // / List or search all observations available from this server endpoint.
34+ // / </summary>
35+ // / <param name="query">The query string.</param>
36+ // / <returns>A response object containing a list of observations.</returns>
37+ APIResponse<DataModels::Observation> getObservations (std::string queryString = " " ) {
2238 auto response = APIRequest::Builder ()
2339 .setApiRoot (apiRoot)
2440 .setMethod (" GET" )
2541 .setAuthHeader (authHeader)
26- .setResourcePath (" /observations" )
42+ .setResourcePath (" /observations" + queryString )
2743 .build ()
2844 .execute <DataModels::Observation>();
2945 return response;
3046 }
3147
32- APIResponse<DataModels::Observation> getObservationsOfDataStream (const std::string& dataStreamId) {
48+ // / <summary>
49+ // / List or search all observations available from a datastream.
50+ // / </summary>
51+ // / <param name="query">The query string parameters.</param>
52+ // / <returns>A response object containing a list of observations.</returns>
53+ APIResponse<DataModels::Observation> getObservationsOfDataStream (const std::string& dataStreamId, const Query::ObservationsOfDataStreamQuery& query) {
54+ return getObservationsOfDataStream (dataStreamId, query.toString ());
55+ }
56+
57+ // / <summary>
58+ // / List or search all observations available from a datastream.
59+ // / </summary>
60+ // / <param name="query">The query string.</param>
61+ // / <returns>A response object containing a list of observations.</returns>
62+ APIResponse<DataModels::Observation> getObservationsOfDataStream (const std::string& dataStreamId, std::string queryString = " " ) {
3363 auto response = APIRequest::Builder ()
3464 .setApiRoot (apiRoot)
3565 .setMethod (" GET" )
3666 .setAuthHeader (authHeader)
37- .setResourcePath (" /datastreams/" + dataStreamId + " /observations" )
67+ .setResourcePath (" /datastreams/" + dataStreamId + " /observations" + queryString )
3868 .build ()
3969 .execute <DataModels::Observation>();
4070 return response;
4171 }
4272
73+ // / <summary>
74+ // / Get a specific observation by its ID.
75+ // / </summary>
76+ // / <param name="observationId">The ID of the observation to retrieve.</param>
77+ // / <returns>A response object containing the requested observation.</returns>
4378 APIResponse<DataModels::Observation> getObservationById (const std::string& observationId) {
4479 auto response = APIRequest::Builder ()
4580 .setApiRoot (apiRoot)
@@ -51,6 +86,12 @@ namespace ConnectedSystemsAPI {
5186 return response;
5287 }
5388
89+ // / <summary>
90+ // / Add a new observation to an existing data stream.
91+ // / </summary>
92+ // / <param name="dataStreamId">The local identifier of the data stream.</param>
93+ // / <param name="observation">The observation to create.</param>
94+ // / <returns>A response object indicating success or failure.</returns>
5495 APIResponse<void > createObservation (const std::string& dataStreamId, const DataModels::Observation& observation) {
5596 nlohmann::ordered_json j;
5697 ConnectedSystemsAPI::DataModels::to_json (j, observation);
@@ -66,6 +107,12 @@ namespace ConnectedSystemsAPI {
66107 return response;
67108 }
68109
110+ // / <summary>
111+ // / Update an existing observation.
112+ // / </summary>
113+ // / <param name="observationId">The ID of the observation to update.</param>
114+ // / <param name="observation">The updated observation.</param>
115+ // / <returns>A response object indicating success or failure.</returns>
69116 APIResponse<void > updateObservation (const std::string& observationId, const DataModels::Observation& observation) {
70117 nlohmann::ordered_json j;
71118 ConnectedSystemsAPI::DataModels::to_json (j, observation);
@@ -81,6 +128,11 @@ namespace ConnectedSystemsAPI {
81128 return response;
82129 }
83130
131+ // / <summary>
132+ // / Delete an observation by its ID.
133+ // / </summary>
134+ // / <param name="observationId">The ID of the observation to delete.</param>
135+ // / <returns>A response object indicating success or failure.</returns>
84136 APIResponse<void > deleteObservation (const std::string& observationId) {
85137 auto response = APIRequest::Builder ()
86138 .setApiRoot (apiRoot)
0 commit comments