QAlphaCloud  0.0.1
Qt bindings for Alpha Cloud
Classes | Signals | Public Member Functions | List of all members
QAlphaCloud::ApiRequest Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ApiRequest() [1/2]

QAlphaCloud::ApiRequest::ApiRequest ( Connector connector,
QObject *  parent = nullptr 
)
explicit

Create an API request.

Parameters
connectorThe Connector to use, must not be null.
parentThe parent, if wanted.

◆ ApiRequest() [2/2]

QAlphaCloud::ApiRequest::ApiRequest ( Connector connector,
const QString &  endPoint,
QObject *  parent = nullptr 
)

Create an API request.

Parameters
connectorThe Connector to use, must not be null.
endPointThe API endpoint to talk to.
parentThe parent, if wanted.

Member Function Documentation

◆ data()

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.

◆ errorOccurred

void QAlphaCloud::ApiRequest::errorOccurred ( )
signal

Emitted when an error occurred.

This can either be a network error or an error returned by the API.

See also
networkError()
apiError()

◆ errorString()

QString QAlphaCloud::ApiRequest::errorString ( ) const

The error string, if any.

Note
Not every error code has an errorString associated with it.

◆ finished

void QAlphaCloud::ApiRequest::finished ( )
signal

Emitted when the request finished.

This is emitted regardless of whether the request succeeded or failed.

◆ result

void QAlphaCloud::ApiRequest::result ( )
signal

Emitted when an API result received.

This is emitted when the API request completed successfully.

◆ send()

bool QAlphaCloud::ApiRequest::send ( )

Send the event.

Returns
Whether the request was sent.

◆ setAutoDelete()

void QAlphaCloud::ApiRequest::setAutoDelete ( bool  autoDelete)

Set whether to auto-delete the job when finished.

Default is true.

◆ setEndPoint()

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.

◆ setQuery()

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.

◆ setQueryDate()

void QAlphaCloud::ApiRequest::setQueryDate ( const QDate &  date)

Set the query date.

For APIs that return data for a given date.

◆ setSysSn()

void QAlphaCloud::ApiRequest::setSysSn ( const QString &  sysSn)

Set the storage system serial number.

For APIs that apply to a specific storage system.


The documentation for this class was generated from the following files: