MusicBrainz::WebService Class Reference

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

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

List of all members.

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.

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:
host a string containing a host name
port an integer containing a port number
pathPrefix a string prepended to all URLs
username a string containing a MusicBrainz user name
password a string containing the user's password
realm a 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:
ConnectionError couldn't connect to server
RequestError invalid IDs or parameters
AuthenticationError invalid user name and/or password
ResourceNotFoundError resource 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:
ConnectionError couldn't connect to server
RequestError invalid IDs or parameters
AuthenticationError invalid user name and/or password
ResourceNotFoundError resource doesn't exist
See also:
IWebService::post

Implements MusicBrainz::IWebService.

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

Sets the host.

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

Sets the MusicBrainz user password.

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

Sets the path prefix.

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

Sets the port.

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

Sets the proxy host.

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

Sets the proxy password.

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

Sets the proxy port.

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

Sets the proxy user name.

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

Sets the HTTP authentification realm.

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

Sets the MusicBrainz user name.

Parameters:
username a string containing the user name

Generated on 26 May 2010 for libmusicbrainz3 by  doxygen 1.6.1