pub struct Client { /* private fields */ }Expand description
Client for managing top-level entities on a VTN, i.e., programs and VENs.
Can be used to implement both, the VEN and the business logic.
If using the VTN of this project with the built-in OAuth authentication provider,
the Client also allows managing the users.
Implementations§
Source§impl Client
impl Client
Sourcepub fn with_url(base_url: Url, auth: Option<ClientCredentials>) -> Self
pub fn with_url(base_url: Url, auth: Option<ClientCredentials>) -> Self
Create a new client for a VTN located at the specified URL.
This assumes that the VTN also works as an OAuth provider
and exposes an API endpoint at <base_url>/auth/token to retrieve a token.
If you want to use another OAuth provider, please use Self::with_details.
Sourcepub fn with_details(
vtn_base_url: Url,
oauth_base_url: Url,
client: Client,
auth: Option<ClientCredentials>,
) -> Self
pub fn with_details( vtn_base_url: Url, oauth_base_url: Url, client: Client, auth: Option<ClientCredentials>, ) -> Self
Create a new client with more details than Self::with_url.
It allows specifying a reqwest::Client instead of the default one.
This allows configuring proxy settings, timeouts, etc.
Additionally, it allows for a separate oauth_base_url,
which is relevant if you don’t want or cannot rely on an OAuth provider at the default URL.
Sourcepub fn with_http_client(
vtn_base_url: Url,
oauth_base_url: Url,
client: Box<dyn HttpClient + Send + Sync>,
auth: Option<ClientCredentials>,
) -> Self
pub fn with_http_client( vtn_base_url: Url, oauth_base_url: Url, client: Box<dyn HttpClient + Send + Sync>, auth: Option<ClientCredentials>, ) -> Self
Create a new client with anything that implements the HttpClient trait.
This is mainly helpful for the integration tests
and should most likely not be used for other purposes.
Please use Client::with_details for detailed HTTP client configuration.
Sourcepub async fn create_program(
&self,
program_content: ProgramContent,
) -> Result<ProgramClient, Error>
pub async fn create_program( &self, program_content: ProgramContent, ) -> Result<ProgramClient, Error>
Create a new program on the VTN.
Sourcepub async fn get_programs(
&self,
filter: Filter<'_, impl AsRef<str>>,
pagination: PaginationOptions,
) -> Result<Vec<ProgramClient>, Error>
pub async fn get_programs( &self, filter: Filter<'_, impl AsRef<str>>, pagination: PaginationOptions, ) -> Result<Vec<ProgramClient>, Error>
Lowlevel operation that gets a list of programs from the VTN with the given query parameters
Sourcepub async fn get_program_list(
&self,
filter: Filter<'_, impl AsRef<str> + Clone>,
) -> Result<Vec<ProgramClient>, Error>
pub async fn get_program_list( &self, filter: Filter<'_, impl AsRef<str> + Clone>, ) -> Result<Vec<ProgramClient>, Error>
Get all programs from the VTN with the given query parameters
It automatically tries to iterate pages where necessary.
Sourcepub async fn get_program_by_id(
&self,
id: &ProgramId,
) -> Result<ProgramClient, Error>
pub async fn get_program_by_id( &self, id: &ProgramId, ) -> Result<ProgramClient, Error>
Get a program by id
Sourcepub async fn get_events(
&self,
program_id: Option<&ProgramId>,
filter: Filter<'_, impl AsRef<str>>,
pagination: PaginationOptions,
) -> Result<Vec<EventClient>, Error>
pub async fn get_events( &self, program_id: Option<&ProgramId>, filter: Filter<'_, impl AsRef<str>>, pagination: PaginationOptions, ) -> Result<Vec<EventClient>, Error>
Low-level operation that gets a list of events from the VTN with the given query parameters
To automatically iterate pages, use [self.get_event_list]
Sourcepub async fn get_event_list(
&self,
program_id: Option<&ProgramId>,
filter: Filter<'_, impl AsRef<str> + Clone>,
) -> Result<Vec<EventClient>, Error>
pub async fn get_event_list( &self, program_id: Option<&ProgramId>, filter: Filter<'_, impl AsRef<str> + Clone>, ) -> Result<Vec<EventClient>, Error>
Get all events from the VTN with the given query parameters.
It automatically tries to iterate pages where necessary.
Sourcepub async fn get_event_by_id(&self, id: &EventId) -> Result<EventClient, Error>
pub async fn get_event_by_id(&self, id: &EventId) -> Result<EventClient, Error>
Get an event by id
Sourcepub async fn create_ven(&self, ven: VenContent) -> Result<VenClient, Error>
pub async fn create_ven(&self, ven: VenContent) -> Result<VenClient, Error>
Create a new VEN entity at the VTN. The content should be created with VenContent::new.
Sourcepub async fn get_ven_list(
&self,
filter: Filter<'_, impl AsRef<str> + Clone>,
) -> Result<Vec<VenClient>, Error>
pub async fn get_ven_list( &self, filter: Filter<'_, impl AsRef<str> + Clone>, ) -> Result<Vec<VenClient>, Error>
Get all VENs from the VTN with the given query parameters.
The client automatically tries to iterate pages where necessary.