pub struct Client { /* private fields */ }Expand description
The pdns api client for a single pdns webserver. It should be created with the Client::new or Client::new_with_client function.
Implementations§
Source§impl Client
impl Client
Sourcepub fn list_servers(&self) -> Result<Vec<Server>>
pub fn list_servers(&self) -> Result<Vec<Server>>
list the servers
§Errors
super::Error::Urlif the api endpoint url could not be formedsuper::Error::Httpif errors in making requestsuper::Error::Httpif errors in decoding response JSON on a successful requestsuper::Error::APIErrorif api returned an error (not 200 OK status)
Sourcepub fn list_server(&self, server_id: &str) -> Result<Server>
pub fn list_server(&self, server_id: &str) -> Result<Server>
lists information on a specific server
§Errors
super::Error::Urlif the api endpoint url could not be formedsuper::Error::Httpif errors in making requestsuper::Error::Httpif errors in decoding response JSON on a successful requestsuper::Error::APIErrorif api returned an error (not 200 OK status)
Source§impl Client
impl Client
Sourcepub fn new(base_url: impl AsRef<str>, api_key: &str) -> Result<Self>
pub fn new(base_url: impl AsRef<str>, api_key: &str) -> Result<Self>
creates a new Client.
api_key is the value for the X-API-Key header
base_url should be a valid base url with no path (it will be joined with /api/v1 which will clear its path)
The underlying client uses the defaults of a reqwest::blocking::Client
Use Client::new_with_client instead to specify the internal client
§Errors
Error::InvalidBaseUrlifbase_urlis not a valid base urlError::InvalidBaseUrlif scheme is nothttp,httpsError::BadApiKeyifapi_keyis not a valid header valueError::Httpif the internal client could not be madeError::Urlifbase_urlcould not be parsed
Sourcepub fn new_with_client(
base_url: impl AsRef<str>,
client: Client,
) -> Result<Self>
pub fn new_with_client( base_url: impl AsRef<str>, client: Client, ) -> Result<Self>
creates a new Client.
client is the underlying client to use
base_url should be a valid base url with no path (it will be joined with /api/v1 which will clear its path)
It is assumed that client has a default header for (“X-API-Key”, “api key”) for authentication
§Errors
Error::Urlifbase_urlcould not be parsedError::InvalidBaseUrlifbase_urlis not a valid base urlError::InvalidBaseUrlif scheme is nothttp,https