libmusicbrainz3  3.0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
MusicBrainz::WebService Class Reference

An interface to the MusicBrainz XML web service via HTTP. More...

Inheritance diagram for MusicBrainz::WebService:
MusicBrainz::IWebService

Public Member Functions

 WebService (const std::string &host="musicbrainz.org", const int port=80, const std::string &pathPrefix="/ws", const std::string &username=std::string(), const std::string &password=std::string(), const std::string &realm="musicbrainz.org")
 Constructor.
virtual ~WebService ()
 Destructor.
void setHost (const std::string &host)
 Sets the host.
std::string getHost () const
 Returns the host.
void setPort (const int port)
 Sets the port.
int getPort () const
 Returns the port.
void setPathPrefix (const std::string &pathPrefix)
 Sets the path prefix.
std::string getPathPrefix () const
 Returns the path prefix.
void setUserName (const std::string &username)
 Sets the MusicBrainz user name.
std::string getUserName () const
 Returns the MusicBrainz user name.
void setPassword (const std::string &password)
 Sets the MusicBrainz user password.
std::string getPassword () const
 Returns the MusicBrainz user password.
void setRealm (const std::string &realm)
 Sets the HTTP authentification realm.
std::string getRealm () const
 Returns the HTTP authentification realm.
void setProxyHost (const std::string &host)
 Sets the proxy host.
std::string getProxyHost () const
 Returns the proxy host.
void setProxyPort (const int port)
 Sets the proxy port.
int getProxyPort () const
 Returns the proxy port.
void setProxyUserName (const std::string &username)
 Sets the proxy user name.
std::string getProxyUserName () const
 Returns the proxy user name.
void setProxyPassword (const std::string &password)
 Sets the proxy password.
std::string getProxyPassword () const
 Returns the proxy password.
std::string get (const std::string &entity, const std::string &id, const IIncludes::IncludeList &include, const IFilter::ParameterList &filter, const std::string &version="1")
 Query the web service via HTTP-GET.
void post (const std::string &entity, const std::string &id, const std::string &data, const std::string &version="1")
 Send data to the web service via HTTP-POST.
- Public Member Functions inherited from MusicBrainz::IWebService
virtual ~IWebService ()

Detailed Description

An interface to the MusicBrainz XML web service via HTTP.

By default, this class uses the MusicBrainz server but may be configured for accessing other servers as well using the constructor (WebService::WebService). This implements IWebService, so additional documentation on method parameters can be found there.

Constructor & Destructor Documentation

MusicBrainz::WebService::WebService ( const std::string &  host = "musicbrainz.org",
const int  port = 80,
const std::string &  pathPrefix = "/ws",
const std::string &  username = std::string(),
const std::string &  password = std::string(),
const std::string &  realm = "musicbrainz.org" 
)

Constructor.

This can be used without parameters. In this case, the MusicBrainz server will be used.

Parameters
hosta string containing a host name
portan integer containing a port number
pathPrefixa string prepended to all URLs
usernamea string containing a MusicBrainz user name
passworda string containing the user's password
realma string containing the realm used for authentication
virtual MusicBrainz::WebService::~WebService ( )
virtual

Destructor.

Member Function Documentation

std::string MusicBrainz::WebService::get ( const std::string &  entity,
const std::string &  id,
const IIncludes::IncludeList include,
const IFilter::ParameterList filter,
const std::string &  version = "1" 
)
virtual

Query the web service via HTTP-GET.

Returns a string containing the result or raises a WebServiceError. Conditions leading to errors may be invalid entities, IDs, include or filter parameters and unsupported version numbers.

Exceptions
ConnectionErrorcouldn't connect to server
RequestErrorinvalid IDs or parameters
AuthenticationErrorinvalid user name and/or password
ResourceNotFoundErrorresource doesn't exist
See Also
IWebService::get

Implements MusicBrainz::IWebService.

std::string MusicBrainz::WebService::getHost ( ) const

Returns the host.

Returns
a string containing the host name
std::string MusicBrainz::WebService::getPassword ( ) const

Returns the MusicBrainz user password.

Returns
a string containing the user password
std::string MusicBrainz::WebService::getPathPrefix ( ) const

Returns the path prefix.

Returns
a string containing the path prefix
int MusicBrainz::WebService::getPort ( ) const

Returns the port.

Returns
an int containing the port number
std::string MusicBrainz::WebService::getProxyHost ( ) const

Returns the proxy host.

Returns
a string containing the host name
std::string MusicBrainz::WebService::getProxyPassword ( ) const

Returns the proxy password.

Returns
a string containing the password
int MusicBrainz::WebService::getProxyPort ( ) const

Returns the proxy port.

Returns
an int containing the port number
std::string MusicBrainz::WebService::getProxyUserName ( ) const

Returns the proxy user name.

Returns
a string containing the user name
std::string MusicBrainz::WebService::getRealm ( ) const

Returns the HTTP authentification realm.

Returns
a string containing the realm
std::string MusicBrainz::WebService::getUserName ( ) const

Returns the MusicBrainz user name.

Returns
a string containing the user name
void MusicBrainz::WebService::post ( const std::string &  entity,
const std::string &  id,
const std::string &  data,
const std::string &  version = "1" 
)
virtual

Send data to the web service via HTTP-POST.

Note that this may require authentication. You can set user name, password and realm in the constructor (WebService::WebService).

Exceptions
ConnectionErrorcouldn't connect to server
RequestErrorinvalid IDs or parameters
AuthenticationErrorinvalid user name and/or password
ResourceNotFoundErrorresource doesn't exist
See Also
IWebService::post

Implements MusicBrainz::IWebService.

void MusicBrainz::WebService::setHost ( const std::string &  host)

Sets the host.

Parameters
hosta string containing the host name
void MusicBrainz::WebService::setPassword ( const std::string &  password)

Sets the MusicBrainz user password.

Parameters
passworda string containing the user password
void MusicBrainz::WebService::setPathPrefix ( const std::string &  pathPrefix)

Sets the path prefix.

Parameters
pathPrefixa string containing the path prefix
void MusicBrainz::WebService::setPort ( const int  port)

Sets the port.

Parameters
portan int containing the port number
void MusicBrainz::WebService::setProxyHost ( const std::string &  host)

Sets the proxy host.

Parameters
hosta string containing the host name
void MusicBrainz::WebService::setProxyPassword ( const std::string &  password)

Sets the proxy password.

Parameters
passworda string containing the password
void MusicBrainz::WebService::setProxyPort ( const int  port)

Sets the proxy port.

Parameters
portan int containing the port number
void MusicBrainz::WebService::setProxyUserName ( const std::string &  username)

Sets the proxy user name.

Parameters
usernamea string containing the user name
void MusicBrainz::WebService::setRealm ( const std::string &  realm)

Sets the HTTP authentification realm.

Parameters
realma string containing the realm
void MusicBrainz::WebService::setUserName ( const std::string &  username)

Sets the MusicBrainz user name.

Parameters
usernamea string containing the user name