pub struct HttpBmc<C>where
C: HttpClient,{ /* private fields */ }Expand description
HTTP-based BMC implementation that wraps an HttpClient.
This struct combines an HTTP client with BMC endpoint information and credentials
to provide a complete Redfish client implementation. It implements the Bmc trait
to provide standardized access to Redfish services.
§Type Parameters
C- The HTTP client implementation to use
Implementations§
Source§impl<C> HttpBmc<C>
impl<C> HttpBmc<C>
Sourcepub fn new(
client: C,
redfish_endpoint: Url,
credentials: BmcCredentials,
cache_settings: CacheSettings,
) -> HttpBmc<C>
pub fn new( client: C, redfish_endpoint: Url, credentials: BmcCredentials, cache_settings: CacheSettings, ) -> HttpBmc<C>
Create a new HTTP-based BMC client with ETag-based caching.
§Arguments
client- The HTTP client implementation to use for requestsredfish_endpoint- The base URL of the Redfish service (e.g.,https://192.168.1.100)credentials- Authentication credentials for the BMC
§Examples
use nv_redfish_bmc_http::HttpBmc;
use nv_redfish_bmc_http::CacheSettings;
use nv_redfish_bmc_http::BmcCredentials;
use nv_redfish_bmc_http::reqwest::Client;
use url::Url;
let credentials = BmcCredentials::username_password("admin".to_string(), Some("password".to_string()));
let http_client = Client::new()?;
let endpoint = Url::parse("https://192.168.1.100")?;
let bmc = HttpBmc::new(http_client, endpoint, credentials, CacheSettings::default());Sourcepub fn with_custom_headers(
client: C,
redfish_endpoint: Url,
credentials: BmcCredentials,
cache_settings: CacheSettings,
custom_headers: HeaderMap,
) -> HttpBmc<C>
pub fn with_custom_headers( client: C, redfish_endpoint: Url, credentials: BmcCredentials, cache_settings: CacheSettings, custom_headers: HeaderMap, ) -> HttpBmc<C>
Create a new HTTP-based BMC client with custom headers and ETag-based caching.
This is an alternative constructor that allows specifying custom HTTP headers that will be included in all requests. Use this when you need vendor-specific headers, custom authentication tokens, or other HTTP headers required by the Redfish service at construction time.
For most use cases, prefer HttpBmc::new which creates a client without
custom headers.
§Arguments
client- The HTTP client implementation to use for requestsredfish_endpoint- The base URL of the Redfish service (e.g.,https://192.168.1.100)credentials- Authentication credentials for the BMCcache_settings- Cache configuration for response cachingcustom_headers- Custom HTTP headers to include in all requests
§Examples
use nv_redfish_bmc_http::HttpBmc;
use nv_redfish_bmc_http::CacheSettings;
use nv_redfish_bmc_http::BmcCredentials;
use nv_redfish_bmc_http::reqwest::Client;
use url::Url;
use http::HeaderMap;
let credentials = BmcCredentials::username_password("admin".to_string(), Some("password".to_string()));
let http_client = Client::new()?;
let endpoint = Url::parse("https://192.168.1.100")?;
// Create custom headers
let mut headers = HeaderMap::new();
headers.insert("X-Auth-Token", "custom-token-value".parse()?);
headers.insert("X-Vendor-Header", "vendor-specific-value".parse()?);
// Create BMC client with custom headers
let bmc = HttpBmc::with_custom_headers(
http_client,
endpoint,
credentials,
CacheSettings::default(),
headers,
);
// All requests will include the custom headersSourcepub fn set_credentials(&self, credentials: BmcCredentials)
pub fn set_credentials(&self, credentials: BmcCredentials)
Replace the credentials used for subsequent requests.
Existing cache and ETag state is preserved.
§Panics
Panics if the internal credentials lock is poisoned. This should not occur in normal operation.
Trait Implementations§
Source§impl<C> Bmc for HttpBmc<C>
impl<C> Bmc for HttpBmc<C>
Source§type Error = <C as HttpClient>::Error
type Error = <C as HttpClient>::Error
Source§async fn get<T>(
&self,
id: &ODataId,
) -> Result<Arc<T>, <HttpBmc<C> as Bmc>::Error>where
T: EntityTypeRef + for<'de> Deserialize<'de> + 'static,
async fn get<T>(
&self,
id: &ODataId,
) -> Result<Arc<T>, <HttpBmc<C> as Bmc>::Error>where
T: EntityTypeRef + for<'de> Deserialize<'de> + 'static,
Source§async fn expand<T>(
&self,
id: &ODataId,
query: ExpandQuery,
) -> Result<Arc<T>, <HttpBmc<C> as Bmc>::Error>where
T: Expandable + 'static,
async fn expand<T>(
&self,
id: &ODataId,
query: ExpandQuery,
) -> Result<Arc<T>, <HttpBmc<C> as Bmc>::Error>where
T: Expandable + 'static,
Source§async fn create<V, R>(
&self,
id: &ODataId,
v: &V,
) -> Result<ModificationResponse<R>, <HttpBmc<C> as Bmc>::Error>
async fn create<V, R>( &self, id: &ODataId, v: &V, ) -> Result<ModificationResponse<R>, <HttpBmc<C> as Bmc>::Error>
Source§async fn create_session<V, R>(
&self,
id: &ODataId,
v: &V,
) -> Result<SessionCreateResponse<R>, <HttpBmc<C> as Bmc>::Error>
async fn create_session<V, R>( &self, id: &ODataId, v: &V, ) -> Result<SessionCreateResponse<R>, <HttpBmc<C> as Bmc>::Error>
Source§async fn update<V, R>(
&self,
id: &ODataId,
etag: Option<&ODataETag>,
v: &V,
) -> Result<ModificationResponse<R>, <HttpBmc<C> as Bmc>::Error>
async fn update<V, R>( &self, id: &ODataId, etag: Option<&ODataETag>, v: &V, ) -> Result<ModificationResponse<R>, <HttpBmc<C> as Bmc>::Error>
Source§async fn delete<T>(
&self,
id: &ODataId,
) -> Result<ModificationResponse<T>, <HttpBmc<C> as Bmc>::Error>
async fn delete<T>( &self, id: &ODataId, ) -> Result<ModificationResponse<T>, <HttpBmc<C> as Bmc>::Error>
Source§async fn action<T, R>(
&self,
action: &Action<T, R>,
params: &T,
) -> Result<ModificationResponse<R>, <HttpBmc<C> as Bmc>::Error>
async fn action<T, R>( &self, action: &Action<T, R>, params: &T, ) -> Result<ModificationResponse<R>, <HttpBmc<C> as Bmc>::Error>
Source§async fn multipart_update<U, V, R>(
&self,
uri: &str,
request: MultipartUpdateRequest<'_, U, V>,
) -> Result<ModificationResponse<R>, <HttpBmc<C> as Bmc>::Error>
async fn multipart_update<U, V, R>( &self, uri: &str, request: MultipartUpdateRequest<'_, U, V>, ) -> Result<ModificationResponse<R>, <HttpBmc<C> as Bmc>::Error>
UpdateService multipart upload using a named stream.Source§async fn http_push_uri_update<U, R>(
&self,
uri: &str,
request: HttpPushUriUpdateRequest<U>,
) -> Result<ModificationResponse<R>, <HttpBmc<C> as Bmc>::Error>
async fn http_push_uri_update<U, R>( &self, uri: &str, request: HttpPushUriUpdateRequest<U>, ) -> Result<ModificationResponse<R>, <HttpBmc<C> as Bmc>::Error>
UpdateService HttpPushUri.