Helix Web Services Client  1
Helix Web Services Client SDK for Qt Applications
Classes | Public Types | Public Slots | Signals | Public Member Functions | List of all members
hws::Client Class Reference

Front end to making requests against the Phoenix web services API. More...

#include <Client.h>

Inheritance diagram for hws::Client:

Classes

class  ExecuteMethodFinished
 
class  Impl
 
class  LogInFinished
 

Public Types

typedef QList< QVariantMap > QVariantMapList
 
typedef QHash< QString, QString > QStringHash
 

Public Slots

void validateSession ()
 
void logIn (const QString &user, const QString &password)
 
void executeMethod (const QString &method, const QString &path, const QSharedPointer< QStringHash > params=QSharedPointer< QStringHash >(), const QSharedPointer< QByteArray > body=QSharedPointer< QByteArray >())
 
void executeMethod (const QString &method, const QString &path, const QSharedPointer< QStringHash > params, const QVariantMap &body)
 
void executeMethod (const QString &method, const QString &path, const QSharedPointer< QStringHash > params, const QVariantMapList &body)
 

Signals

void validateSessionDone (RequestErrorPtr error)
 
void logInDone (RequestErrorPtr error, SessionPtr session)
 
void executeMethodDone (RequestErrorPtr error, const QString &method, const QString &path, const QSharedPointer< QVariantMapList > body)
 

Public Member Functions

 Client (QObject *parent, QUrl url)
 
 Client (QObject *parent)
 A basic empty client that should be updated.
 
 ~Client ()
 
const QUrl & url () const
 The Helix Web Services URL.
 
void setUrl (const QUrl &url)
 The Helix Web Services URL.
 
bool hasSession () const
 
const Sessionsession () const
 The session instance is required before making any remote call.
 
void setSession (const Session &session)
 
const QString & hwsPrefixPath () const
 
void setHWSPrefixPath (const QString &path)
 
const QString & settingsKey () const
 
const QSharedPointer< QSettings > settings () const
 
void setSettings (QSharedPointer< QSettings > settings)
 The current settings handle for the client.
 
void addRequestConfig (QString key, QString value)
 
void ignoreSslErrors (bool ignore)
 

Detailed Description

Front end to making requests against the Phoenix web services API.

Constructor & Destructor Documentation

hws::Client::~Client ( )

Destroy the client. Any open connections for updates will get automatically disconnected.

Member Function Documentation

void hws::Client::addRequestConfig ( QString  key,
QString  value 
)

Creates a per-request configuration setting.

See the documentation for details, but this will apply the correct prefix to the key, and leave the value untouched.

Parameters
keyThe configuration key, e.g., P4PORT
valueThe 'raw' header value
void hws::Client::executeMethod ( const QString &  method,
const QString &  path,
const QSharedPointer< QStringHash >  params = QSharedPointer<QStringHash>(),
const QSharedPointer< QByteArray >  body = QSharedPointer<QByteArray>() 
)
slot

Execute a method of Helix Web Services.

Parameters
methodAn HTTP verb, e.g., "POST"
pathThe method path to use, e.g., '/helix_versioning_engine/v78/changes'
paramsOptional URL parameters to set
bodyOptional request body to use
void hws::Client::executeMethod ( const QString &  method,
const QString &  path,
const QSharedPointer< QStringHash >  params,
const QVariantMap &  body 
)
slot

Execute a method of Helix Web Services.

Parameters
methodAn HTTP verb, e.g., "POST"
pathThe method path to use, e.g., '/helix_versioning_engine/v78/changes'
paramsURL parameters to set (for no parameters, set to empty pointer)
bodyRequest body set as a QVariantMap, will be serialized as JSON
void hws::Client::executeMethod ( const QString &  method,
const QString &  path,
const QSharedPointer< QStringHash >  params,
const QVariantMapList &  body 
)
slot

Execute a method of Helix Web Services.

Parameters
methodAn HTTP verb, e.g., "POST"
pathThe method path to use, e.g., '/helix_versioning_engine/v78/changes'
paramsURL parameters to set (for no parameters, set to empty pointer)
bodyRequest body set as a list of QVariantMaps, will be serialized as JSON
void hws::Client::executeMethodDone ( RequestErrorPtr  error,
const QString &  method,
const QString &  path,
const QSharedPointer< QVariantMapList >  body 
)
signal

Main callback for most method calls to Helix Web Services.

If the error is set, the body is definitely null.

If no error occurred, you may have one or more values, depending on the method called.

Parameters
errorIf set, details on the problem.
methodHTTP verb of the method run
pathSubpath (without the prefix) of the method
bodyIf the response included a body, we convert it from JSON to a list of hashes.
bool hws::Client::hasSession ( ) const

When true, this should have a session instance that was known to work at some point.

const QString & hws::Client::hwsPrefixPath ( ) const

This is a leading path to almost every request in the system. It's configurable since some development environment setups don't have a nice way to handle creating DNS entries, which leads to services sometimes getting mounted locally under subpaths.

void hws::Client::ignoreSslErrors ( bool  ignore)

Ignore SSL certificate errors in the connection.

This is required in situations where your certificate is self-signed or otherwise not valid.

void hws::Client::logIn ( const QString &  user,
const QString &  password 
)
slot

This should attempt a login as the user and password to the url that's been configured on this client.

IMPORTANT: this will attempt to resolve the hostname of the client itself, which we'll use to generate a host locked ticket.

void hws::Client::logInDone ( RequestErrorPtr  error,
SessionPtr  session 
)
signal

When the login request has resolved this is called.

Authentication errors will result in no session being created.

void hws::Client::setHWSPrefixPath ( const QString &  path)

This is a leading path to almost every request in the system. It's configurable since some development environment setups don't have a nice way to handle creating DNS entries, which leads to services sometimes getting mounted locally under subpaths.

void hws::Client::setSession ( const Session session)

If you have stored a previously used session, you can just assign it to this client instance.

const QSharedPointer<QSettings> hws::Client::settings ( ) const

Returns the current settings handle for the client. If it exists, The settings will store the session data by URL under a particular key.

const QString& hws::Client::settingsKey ( ) const

All stored sessions are saved as a JSON object under this settings key, which is defaulted to "HelixWebServicesSettings".

This should be set on construction only.

void hws::Client::validateSession ( )
slot

Trigger a remote call to the web services instance to validate that the session (and ticket) is still valid.

Even if this client has no session, we'll still double check that we can call back to the server.

void hws::Client::validateSessionDone ( RequestErrorPtr  error)
signal

Callback after validating a session.

The error value indicates a networking or remote system problem.

If the session is invalid, the error will not be set. Instead, you should double check the output of client.hasSession(). If that is false, you'll need to sign in again.

At this point, if the session is invalid, it will be cleared from any QSettings cachce as well, if the client was initialized with a settings handle.


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