pub struct HttpInventorySource { /* private fields */ }Expand description
Fetches inventory data from an HTTP endpoint.
Perfect for dynamic inventories backed by CMDBs, GraphQL, REST APIs, or
static web-hosted files. The client eagerly fetches the document,
interpolates environment variables, and parses it using the requested
InventoryFormat. Convenience builders make it easy to add headers or
authentication inline—ideal for CI pipelines or tooling that needs to
refresh inventory snapshots periodically.
§Examples
use nornir_rs::{HttpInventorySource, InventoryFormat};
let source = HttpInventorySource::new("https://example.com/inventory", InventoryFormat::Json)?;
// Configure headers or TLS options here.
let _source = source.with_header("Authorization", "Bearer <token>");Implementations§
Source§impl HttpInventorySource
impl HttpInventorySource
Sourcepub fn new(
url: impl Into<String>,
format: InventoryFormat,
) -> Result<Self, InventoryError>
pub fn new( url: impl Into<String>, format: InventoryFormat, ) -> Result<Self, InventoryError>
Creates a source that fetches data from url and parses it using format.
Sourcepub fn with_header(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Adds an HTTP header to the GET request.
Sourcepub fn with_basic_auth(
self,
username: impl Into<String>,
password: impl Into<String>,
) -> Self
pub fn with_basic_auth( self, username: impl Into<String>, password: impl Into<String>, ) -> Self
Configures HTTP basic authentication.
Sourcepub fn with_bearer_token(self, token: impl Into<String>) -> Self
pub fn with_bearer_token(self, token: impl Into<String>) -> Self
Configures bearer token authentication.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HttpInventorySource
impl !RefUnwindSafe for HttpInventorySource
impl Send for HttpInventorySource
impl Sync for HttpInventorySource
impl Unpin for HttpInventorySource
impl UnsafeUnpin for HttpInventorySource
impl !UnwindSafe for HttpInventorySource
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.