libmusicbrainz3
3.0.2
|
An interface to the MusicBrainz XML web service via HTTP. More...
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. More... | |
virtual | ~WebService () |
Destructor. More... | |
void | setHost (const std::string &host) |
Sets the host. More... | |
std::string | getHost () const |
Returns the host. More... | |
void | setPort (const int port) |
Sets the port. More... | |
int | getPort () const |
Returns the port. More... | |
void | setPathPrefix (const std::string &pathPrefix) |
Sets the path prefix. More... | |
std::string | getPathPrefix () const |
Returns the path prefix. More... | |
void | setUserName (const std::string &username) |
Sets the MusicBrainz user name. More... | |
std::string | getUserName () const |
Returns the MusicBrainz user name. More... | |
void | setPassword (const std::string &password) |
Sets the MusicBrainz user password. More... | |
std::string | getPassword () const |
Returns the MusicBrainz user password. More... | |
void | setRealm (const std::string &realm) |
Sets the HTTP authentification realm. More... | |
std::string | getRealm () const |
Returns the HTTP authentification realm. More... | |
void | setProxyHost (const std::string &host) |
Sets the proxy host. More... | |
std::string | getProxyHost () const |
Returns the proxy host. More... | |
void | setProxyPort (const int port) |
Sets the proxy port. More... | |
int | getProxyPort () const |
Returns the proxy port. More... | |
void | setProxyUserName (const std::string &username) |
Sets the proxy user name. More... | |
std::string | getProxyUserName () const |
Returns the proxy user name. More... | |
void | setProxyPassword (const std::string &password) |
Sets the proxy password. More... | |
std::string | getProxyPassword () const |
Returns the proxy password. More... | |
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. More... | |
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. More... | |
![]() | |
virtual | ~IWebService () |
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.
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.
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 |
Destructor.
|
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.
ConnectionError | couldn't connect to server |
RequestError | invalid IDs or parameters |
AuthenticationError | invalid user name and/or password |
ResourceNotFoundError | resource doesn't exist |
Implements MusicBrainz::IWebService.
std::string MusicBrainz::WebService::getHost | ( | ) | const |
Returns the host.
std::string MusicBrainz::WebService::getPassword | ( | ) | const |
Returns the MusicBrainz user password.
std::string MusicBrainz::WebService::getPathPrefix | ( | ) | const |
Returns the path prefix.
int MusicBrainz::WebService::getPort | ( | ) | const |
Returns the port.
std::string MusicBrainz::WebService::getProxyHost | ( | ) | const |
Returns the proxy host.
std::string MusicBrainz::WebService::getProxyPassword | ( | ) | const |
Returns the proxy password.
int MusicBrainz::WebService::getProxyPort | ( | ) | const |
Returns the proxy port.
std::string MusicBrainz::WebService::getProxyUserName | ( | ) | const |
Returns the proxy user name.
std::string MusicBrainz::WebService::getRealm | ( | ) | const |
Returns the HTTP authentification realm.
std::string MusicBrainz::WebService::getUserName | ( | ) | const |
Returns the MusicBrainz user name.
|
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).
ConnectionError | couldn't connect to server |
RequestError | invalid IDs or parameters |
AuthenticationError | invalid user name and/or password |
ResourceNotFoundError | resource doesn't exist |
Implements MusicBrainz::IWebService.
void MusicBrainz::WebService::setHost | ( | const std::string & | host) |
Sets the host.
host | a string containing the host name |
void MusicBrainz::WebService::setPassword | ( | const std::string & | password) |
Sets the MusicBrainz user password.
password | a string containing the user password |
void MusicBrainz::WebService::setPathPrefix | ( | const std::string & | pathPrefix) |
Sets the path prefix.
pathPrefix | a string containing the path prefix |
void MusicBrainz::WebService::setPort | ( | const int | port) |
Sets the port.
port | an int containing the port number |
void MusicBrainz::WebService::setProxyHost | ( | const std::string & | host) |
Sets the proxy host.
host | a string containing the host name |
void MusicBrainz::WebService::setProxyPassword | ( | const std::string & | password) |
Sets the proxy password.
password | a string containing the password |
void MusicBrainz::WebService::setProxyPort | ( | const int | port) |
Sets the proxy port.
port | an int containing the port number |
void MusicBrainz::WebService::setProxyUserName | ( | const std::string & | username) |
Sets the proxy user name.
username | a string containing the user name |
void MusicBrainz::WebService::setRealm | ( | const std::string & | realm) |
Sets the HTTP authentification realm.
realm | a string containing the realm |
void MusicBrainz::WebService::setUserName | ( | const std::string & | username) |
Sets the MusicBrainz user name.
username | a string containing the user name |