pub struct Client<K> { /* 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<VirtualEndNode>
impl Client<VirtualEndNode>
Sourcepub async fn create_ven(
&self,
ven: VenVenRequest,
) -> Result<VenClient<VirtualEndNode>, Error>
pub async fn create_ven( &self, ven: VenVenRequest, ) -> Result<VenClient<VirtualEndNode>, Error>
Create a new VEN entity at the VTN.
Source§impl Client<BusinessLogic>
impl Client<BusinessLogic>
Sourcepub async fn create_ven(
&self,
ven: BlVenRequest,
) -> Result<VenClient<BusinessLogic>, Error>
pub async fn create_ven( &self, ven: BlVenRequest, ) -> Result<VenClient<BusinessLogic>, Error>
Create a new VEN entity at the VTN.
Source§impl<K: ClientKind> Client<K>
impl<K: ClientKind> Client<K>
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: ProgramRequest,
) -> Result<ProgramClient<K>, Error>
pub async fn create_program( &self, program_content: ProgramRequest, ) -> Result<ProgramClient<K>, Error>
Create a new program on the VTN.
Sourcepub async fn get_programs(
&self,
filter: Filter<'_, impl AsRef<str>>,
pagination: PaginationOptions,
) -> Result<Vec<ProgramClient<K>>, Error>
pub async fn get_programs( &self, filter: Filter<'_, impl AsRef<str>>, pagination: PaginationOptions, ) -> Result<Vec<ProgramClient<K>>, 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<K>>, Error>
pub async fn get_program_list( &self, filter: Filter<'_, impl AsRef<str> + Clone>, ) -> Result<Vec<ProgramClient<K>>, 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<K>, Error>
pub async fn get_program_by_id( &self, id: &ProgramId, ) -> Result<ProgramClient<K>, 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<K>>, Error>
pub async fn get_events( &self, program_id: Option<&ProgramId>, filter: Filter<'_, impl AsRef<str>>, pagination: PaginationOptions, ) -> Result<Vec<EventClient<K>>, 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<K>>, Error>
pub async fn get_event_list( &self, program_id: Option<&ProgramId>, filter: Filter<'_, impl AsRef<str> + Clone>, ) -> Result<Vec<EventClient<K>>, 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<K>, Error>
pub async fn get_event_by_id( &self, id: &EventId, ) -> Result<EventClient<K>, Error>
Get an event by id
Sourcepub async fn get_ven_list(
&self,
filter: Filter<'_, impl AsRef<str> + Clone>,
) -> Result<Vec<VenClient<K>>, Error>
pub async fn get_ven_list( &self, filter: Filter<'_, impl AsRef<str> + Clone>, ) -> Result<Vec<VenClient<K>>, Error>
Get all VENs from the VTN with the given query parameters.
The client automatically tries to iterate pages where necessary.
Trait Implementations§
Auto Trait Implementations§
impl<K> !RefUnwindSafe for Client<K>
impl<K> !UnwindSafe for Client<K>
impl<K> Freeze for Client<K>
impl<K> Send for Client<K>
impl<K> Sync for Client<K>
impl<K> Unpin for Client<K>
impl<K> UnsafeUnpin for Client<K>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more