![]() |
TSDuck v3.46-4930
MPEG Transport Stream Toolkit
|
#include <tsRestClient.h>


Public Member Functions | |
| RestClient (const RestArgs &args) | |
| RestClient (Report *report, const RestArgs &args) | |
| RestClient (ReporterBase *delegate, const RestArgs &args) | |
| virtual | ~RestClient () override |
| bool | call (const UString &api, const UString &post_data=UString()) |
| bool | getResponseJSON (json::ValuePtr &value) const |
| void | getResponseText (UString &response) const |
| int | httpStatus () const |
| UString | mimeType (bool simple=true, bool lowercase=true) const |
| bool | muteReport (bool mute) |
| virtual Report & | report () const override |
| const ByteBlock & | response () const |
| const UStringToUStringMultiMap & | responseHeaders () const |
| void | setAcceptTypes (const UString &types) |
| Report * | setReport (Report *report) |
| ReporterBase * | setReport (ReporterBase *delegate) |
Static Public Member Functions | |
| static int | SilentLevel (bool silent, int default_severity=Severity::Error) |
Basic helper for REST API clients.
| ts::RestClient::RestClient | ( | const RestArgs & | args | ) |
Constructor.
| [in] | args | Initial REST operation arguments. This instance will keep a copy of it. |
Constructor.
| [in] | report | Where to report errors. The report object must remain valid as long as this object exists or setReport() is used with another Report object. If report is null, log messages are discarded. |
| [in] | args | Initial REST operation arguments. This instance will keep a copy of it. |
| ts::RestClient::RestClient | ( | ReporterBase * | delegate, |
| const RestArgs & | args ) |
Constructor.
| [in] | delegate | Use the report of another ReporterBase. If delegate is null, log messages are discarded. |
| [in] | args | Initial REST operation arguments. This instance will keep a copy of it. |
|
overridevirtual |
Destructor.
|
inline |
Set the accepted MIME types for the response.
| [in] | types | Accepted MIME type or comma-separated types. Typical values are u"*‍/*", u"text/plain", u"application/json", u"application/xml". |
Call a REST API.
| [in] | api | Path of the API call. Concatenated with the RestArgs::api_root it is not empty. |
| [in] | post_data | If not empty, the request is a POST with these data. |
|
inline |
Get the HTTP status code (200, 404, etc). Valid after call().
|
inline |
|
inline |
Get the MIME type in the response headers. Valid after call().
| [in] | simple | If true, simple type name. If false, return the full specification with options. |
| [in] | lowercase | Force lowercase in the result. |
|
inline |
| void ts::RestClient::getResponseText | ( | UString & | response | ) | const |
Get the response in text form (interpreted from UTF-8). Valid after call().
| [out] | response | Response in text form. All CR/LF are turned into simple LF. The last end-of-line, if any, is removed. |
| bool ts::RestClient::getResponseJSON | ( | json::ValuePtr & | value | ) | const |
Get the response in JSON form. Valid after call().
| [out] | value | Response in JSON form. |
|
overridevirtualinherited |
Access the Report which is associated with this object. Can be called from another thread only if the Report object is thread-safe.
Implements ts::ReporterInterface.
Associate this object with another Report to log errors.
| [in] | report | Where to report errors. The report object must remain valid as long as this object exists or setReport() is used with another Report object. If report is null, log messages are discarded. |
|
inherited |
Associate this object with another ReporterBase to log errors.
| [in] | delegate | Use the report of another ReporterBase. If delegate is null, the previous explicit Report is used.. |
|
inherited |
Temporarily mute the associated report.
| [in] | mute | It true, report() will return a null report (log messages are discarded), until muteReport() is invoked again with mute set to false. |
|
inlinestaticinherited |
Compute a log severity level from a "silent" parameter. Some subclass methods have a "silent" parameter to avoid reporting errors which may be insignificant, typically when closing a device after an error, in which case the close operation may produce other errors if the previous error left the device in an inconsistent state. While those errors should not be displayed as errors, we still display them at debug level.
| [in] | silent | If true, do not report errors, report debug messages instead. |
| [in] | default_severity | Default severity, in non-silent mode (error by default). |