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) -> Result<(), String>
pub fn set_credentials(&self, credentials: BmcCredentials) -> Result<(), String>
Replace the credentials used for subsequent requests.
Existing cache and ETag state is preserved.
§Errors
Returns an error if the credentials lock is poisoned.