-
Notifications
You must be signed in to change notification settings - Fork 10
Standard Request Response DTO Pattern
RequestDTO request = new RequestDTO()
.setProperty1(value1)
.setProperty2(value2);
ResponseDTO response = client.EndPoint.Verb(request);This is the pattern you will find yourself using over and over again as you consume the AQTS APIs:
- Create a request DTO object, setting only the properties you care about
- Invoke the appropriate HTTP Verb (GET/POST/DELETE/etc.) on the appropriate public API endpoint (Publish, Provisioning, Acquisition)
- Parse the returned response DTO as needed to get your results.
- If an error occurs, a
WebServiceExceptionwill be thrown. See the Error Handling wiki for details
Every AQTS public REST API follows a Message-Based Web Service pattern. A request DTO (Data Transfer Object) captures all of the request parameters and a corresponding response DTO captures all of the response properties.
The com.aquaticinformatics:aquarius.sdk package and its dependencies handle all the JSON serialization/deserialization work, as well as all the HTTP request composition housekeeping of URL-encoding and path template substitution. As a result, your client code just deals with DTO objects.
All the public properties of DTOs have default values (0 for numeric data types, null for strings or object types). If your code does not need to change a default request property, then there is no need to explicitly set it. This often results in very concise, wrist-friendly code.
The com.aquaticinformatics:aquarius.sdk package includes a request and response DTO service model definition for every operation on every public API endpoint. The names of the DTOs correspond to the names of the DTOs listed on the Metadata Operations page of each endpoint.
To find all the time-series at a location with an identifier of "TheRiver", you would issue a GET http://yourserver/AQUARIUS/Publish/v2/GetTimeSeriesDescriptionList?LocationIdentifier=TheRiver request.
The Publish API Metadata Operations page lists the TimeSeriesDescriptionServiceRequest operation in details.
Expressed in code, this would be:
import com.aquaticinformatics.aquarius.sdk.timeseries.AquariusClient;
import com.aquaticinformatics.aquarius.sdk.timeseries.servicemodels.Publish.*;
import net.servicestack.client.WebServiceException;
...
TimeSeriesDescriptionServiceRequest request = new TimeSeriesDescriptionServiceRequest()
.setLocationIdentifier("The River");
TimeSeriesDescriptionListServiceResponse response = client.Publish.get(request);
System.out.format("There are %d time-series at %s\n", response.TimeSeriesDescriptions.size(), request.LocationIdentifier);Still have questions? Feel free to raise an issue or contact our Support Team
- SDK design philosophy (on the .NET SDK wiki)
- AQTS client concepts
- AQTS code examples
- Troubleshooting tips