QAlphaCloud
0.0.1
Qt bindings for Alpha Cloud
|
API request job. More...
#include <apirequest.h>
Inherits QObject.
Classes | |
struct | EndPoint |
The API endpoints. More... | |
Signals | |
void | finished () |
Emitted when the request finished. More... | |
void | result () |
Emitted when an API result received. More... | |
void | errorOccurred () |
Emitted when an error occurred. More... | |
Public Member Functions | |
ApiRequest (Connector *connector, QObject *parent=nullptr) | |
Create an API request. More... | |
ApiRequest (Connector *connector, const QString &endPoint, QObject *parent=nullptr) | |
Create an API request. More... | |
~ApiRequest () override | |
Destroys the API request. | |
QString | endPoint () const |
The API endpoint to use. | |
void | setEndPoint (const QString &endPoint) |
Set the API endpoint to use. More... | |
QString | sysSn () const |
The storage system serial number. | |
void | setSysSn (const QString &sysSn) |
Set the storage system serial number. More... | |
QDate | queryDate () const |
The query date. | |
void | setQueryDate (const QDate &date) |
Set the query date. More... | |
QUrlQuery | query () const |
Custom query arguments. | |
void | setQuery (const QUrlQuery &query) |
Set custom query arguments. More... | |
bool | autoDelete () const |
Whether the job auto-deletes when finished. | |
void | setAutoDelete (bool autoDelete) |
Set whether to auto-delete the job when finished. More... | |
QAlphaCloud::ErrorCode | error () const |
The error, if any. | |
QString | errorString () const |
The error string, if any. More... | |
QJsonValue | data () const |
The data the API returned. More... | |
Q_INVOKABLE bool | send () |
Send the event. More... | |
Q_INVOKABLE void | abort () |
Abort the event. | |
API request job.
This class handles all network communication to the API. It implements a job which will self-delete when finished.
Normally, you don't need to use this class directly but it can be handy to issue API requests for which this library provides no wrapper class.
|
explicit |
Create an API request.
connector | The Connector to use, must not be null. |
parent | The parent, if wanted. |
QAlphaCloud::ApiRequest::ApiRequest | ( | Connector * | connector, |
const QString & | endPoint, | ||
QObject * | parent = nullptr |
||
) |
Create an API request.
connector | The Connector to use, must not be null. |
endPoint | The API endpoint to talk to. |
parent | The parent, if wanted. |
QJsonValue QAlphaCloud::ApiRequest::data | ( | ) | const |
The data the API returned.
This can be either a JSON object or JSON array (or null) depending on the API.
|
signal |
Emitted when an error occurred.
This can either be a network error or an error returned by the API.
QString QAlphaCloud::ApiRequest::errorString | ( | ) | const |
The error string, if any.
|
signal |
Emitted when the request finished.
This is emitted regardless of whether the request succeeded or failed.
|
signal |
Emitted when an API result received.
This is emitted when the API request completed successfully.
bool QAlphaCloud::ApiRequest::send | ( | ) |
Send the event.
void QAlphaCloud::ApiRequest::setAutoDelete | ( | bool | autoDelete | ) |
Set whether to auto-delete the job when finished.
Default is true.
void QAlphaCloud::ApiRequest::setEndPoint | ( | const QString & | endPoint | ) |
Set the API endpoint to use.
This can be any one of EndPoint or any string. A trailing slash is not required.
void QAlphaCloud::ApiRequest::setQuery | ( | const QUrlQuery & | query | ) |
Set custom query arguments.
In case sysSn and queryDate are not sufficient for a given API call, arbitrary query parameters can be provided.
void QAlphaCloud::ApiRequest::setQueryDate | ( | const QDate & | date | ) |
Set the query date.
For APIs that return data for a given date.
void QAlphaCloud::ApiRequest::setSysSn | ( | const QString & | sysSn | ) |
Set the storage system serial number.
For APIs that apply to a specific storage system.