pub struct RedmineAsync { /* private fields */ }
Expand description
main API client object (async)
Implementations§
Source§impl RedmineAsync
impl RedmineAsync
Sourcepub fn new(redmine_url: Url, api_key: &str) -> Result<Self, Error>
pub fn new(redmine_url: Url, api_key: &str) -> Result<Self, Error>
create a RedmineAsync object
§Errors
This will return crate::Error::ReqwestError
if initialization of Reqwest client is failed.
Sourcepub fn from_env() -> Result<Self, Error>
pub fn from_env() -> Result<Self, Error>
create a RedmineAsync object from the environment variables
REDMINE_API_KEY REDMINE_URL
§Errors
This will return an error if the environment variables are missing or the URL can not be parsed
Sourcepub fn impersonate_user(&mut self, id: u64)
pub fn impersonate_user(&mut self, id: u64)
Sets the user id of a user to impersonate in all future API calls
this requires Redmine admin privileges
Sourcepub fn issue_url(&self, issue_id: u64) -> Url
pub fn issue_url(&self, issue_id: u64) -> Url
returns the issue URL for a given issue id
this is mostly for convenience since we are already storing the redmine URL and it works entirely on the client
Sourcepub async fn ignore_response_body<E>(&self, endpoint: &E) -> Result<(), Error>where
E: Endpoint,
pub async fn ignore_response_body<E>(&self, endpoint: &E) -> Result<(), Error>where
E: Endpoint,
use this with endpoints that have no response body, e.g. those just deleting a Redmine object
§Errors
This can return an error if the endpoint returns an error when creating the request body or when the web request fails
Sourcepub async fn json_response_body<E, R>(&self, endpoint: &E) -> Result<R, Error>
pub async fn json_response_body<E, R>(&self, endpoint: &E) -> Result<R, Error>
use this with endpoints which return a JSON response but do not support pagination
you can use it with those that support pagination but they will only return the first page
§Errors
This can return an error if the endpoint returns an error when creating the request body, when the web request fails or when the response can not be parsed as a JSON object into the result type
Sourcepub async fn json_response_body_page<E, R>(
&self,
endpoint: &E,
offset: u64,
limit: u64,
) -> Result<ResponsePage<R>, Error>
pub async fn json_response_body_page<E, R>( &self, endpoint: &E, offset: u64, limit: u64, ) -> Result<ResponsePage<R>, Error>
use this to get a single page of a paginated JSON response
§Errors
This can return an error if the endpoint returns an error when creating the request body, when the web request fails, when the response can not be parsed as a JSON object, when any of the pagination keys or the value key are missing in the JSON object or when the values can not be parsed as the result type.
Sourcepub async fn json_response_body_all_pages<E, R>(
&self,
endpoint: &E,
) -> Result<Vec<R>, Error>
pub async fn json_response_body_all_pages<E, R>( &self, endpoint: &E, ) -> Result<Vec<R>, Error>
use this to get the results for all pages of a paginated JSON response
§Errors
This can return an error if the endpoint returns an error when creating the request body, when any of the web requests fails, when the response can not be parsed as a JSON object, when any of the pagination keys or the value key are missing in the JSON object or when the values can not be parsed as the result type.