pub struct ExpandQuery { /* private fields */ }Expand description
Builder for Redfish $expand query parameters according to DSP0266 specification.
The $expand query parameter allows clients to request that the server expand
navigation properties inline instead of returning just references. This is particularly
useful for reducing the number of HTTP requests needed to retrieve related data.
According to the Redfish specification Table 9, the supported expand options are:
| Option | Description | Example URL |
|---|---|---|
* | Expand all hyperlinks, including payload annotations | ?$expand=* |
. | Expand hyperlinks not in links property instances | ?$expand=. |
~ | Expand hyperlinks in links property instances | ?$expand=~ |
$levels | Number of levels to cascade expansion | ?$expand=.($levels=2) |
§Examples
use nv_redfish_core::query::ExpandQuery;
// Default: expand current resource one level
let default = ExpandQuery::default();
assert_eq!(default.to_query_string(), "$expand=.($levels=1)");
// Expand all hyperlinks
let all = ExpandQuery::all();
assert_eq!(all.to_query_string(), "$expand=*($levels=1)");
// Expand with multiple levels
let deep = ExpandQuery::current().levels(3);
assert_eq!(deep.to_query_string(), "$expand=.($levels=3)");
// Expand specific navigation property
let thermal = ExpandQuery::property("Thermal");
assert_eq!(thermal.to_query_string(), "$expand=Thermal($levels=1)");Implementations§
Source§impl ExpandQuery
impl ExpandQuery
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new expand query with default values.
This is equivalent to ExpandQuery::default() and creates a query
that expands the current resource one level deep: $expand=.($levels=1).
§Examples
use nv_redfish_core::query::ExpandQuery;
let query = ExpandQuery::new();
assert_eq!(query.to_query_string(), "$expand=.($levels=1)");Sourcepub fn no_links() -> Self
pub fn no_links() -> Self
Expand all hyperlinks excluding links.
§Examples
use nv_redfish_core::query::ExpandQuery;
let query = ExpandQuery::no_links();
assert_eq!(query.to_query_string(), "$expand=.");Sourcepub fn all() -> Self
pub fn all() -> Self
Expand all hyperlinks, including those in payload annotations.
This expands all hyperlinks found in the resource, including those in payload
annotations such as @Redfish.Settings, @Redfish.ActionInfo, and
@Redfish.CollectionCapabilities.
Equivalent to: $expand=*
§Examples
use nv_redfish_core::query::ExpandQuery;
let query = ExpandQuery::all();
assert_eq!(query.to_query_string(), "$expand=*($levels=1)");
// With multiple levels
let deep = ExpandQuery::all().levels(3);
assert_eq!(deep.to_query_string(), "$expand=*($levels=3)");Sourcepub fn current() -> Self
pub fn current() -> Self
Expand all hyperlinks not in any links property instances of the resource.
This expands hyperlinks found directly in the resource properties, but not
those in dedicated Links sections. Includes payload annotations.
Equivalent to: $expand=.
§Examples
use nv_redfish_core::query::ExpandQuery;
let query = ExpandQuery::current();
assert_eq!(query.to_query_string(), "$expand=.($levels=1)");Sourcepub fn links() -> Self
pub fn links() -> Self
Expand all hyperlinks found in all links property instances of the resource.
This expands only hyperlinks found in Links sections of the resource,
which typically contain references to related resources.
Equivalent to: $expand=~
§Examples
use nv_redfish_core::query::ExpandQuery;
let query = ExpandQuery::links();
assert_eq!(query.to_query_string(), "$expand=~($levels=1)");Sourcepub fn property<S: Into<String>>(property: S) -> Self
pub fn property<S: Into<String>>(property: S) -> Self
Expand a specific navigation property.
This expands only the specified navigation property, which is useful when you know exactly which related data you need.
§Arguments
property- The name of the navigation property to expand
§Examples
use nv_redfish_core::query::ExpandQuery;
let thermal = ExpandQuery::property("Thermal");
assert_eq!(thermal.to_query_string(), "$expand=Thermal($levels=1)");
let members = ExpandQuery::property("Members");
assert_eq!(members.to_query_string(), "$expand=Members($levels=1)");Sourcepub fn properties(properties: &[&str]) -> Self
pub fn properties(properties: &[&str]) -> Self
Expand multiple specific navigation properties.
This allows expanding several navigation properties in a single request, which is more efficient than making separate requests for each property.
§Arguments
properties- A slice of navigation property names to expand
§Examples
use nv_redfish_core::query::ExpandQuery;
let env = ExpandQuery::properties(&["Thermal", "Power"]);
assert_eq!(env.to_query_string(), "$expand=Thermal,Power($levels=1)");
let system = ExpandQuery::properties(&["Processors", "Memory", "Storage"]);
assert_eq!(system.to_query_string(), "$expand=Processors,Memory,Storage($levels=1)");Sourcepub const fn levels(self, levels: u32) -> Self
pub const fn levels(self, levels: u32) -> Self
Set the number of levels to cascade the expand operation.
The $levels parameter controls how deep the expansion goes:
- Level 1: Expand hyperlinks in the current resource
- Level 2: Also expand hyperlinks in the resources expanded at level 1
- And so on…
§Arguments
levels- Number of levels to expand (typically 1-6 in practice)
§Examples
use nv_redfish_core::query::ExpandQuery;
let shallow = ExpandQuery::current().levels(1);
assert_eq!(shallow.to_query_string(), "$expand=.($levels=1)");
let deep = ExpandQuery::all().levels(3);
assert_eq!(deep.to_query_string(), "$expand=*($levels=3)");Sourcepub fn to_query_string(&self) -> String
pub fn to_query_string(&self) -> String
Convert to the OData query string according to Redfish specification.
This generates the actual query parameter string that will be appended to HTTP requests to Redfish services.
§Returns
A query string in the format $expand=expression($levels=n) or just
$expand=expression if no levels are specified.
§Examples
use nv_redfish_core::query::ExpandQuery;
let query = ExpandQuery::property("Thermal").levels(2);
assert_eq!(query.to_query_string(), "$expand=Thermal($levels=2)");
let query = ExpandQuery::all();
assert_eq!(query.to_query_string(), "$expand=*($levels=1)");Trait Implementations§
Source§impl Clone for ExpandQuery
impl Clone for ExpandQuery
Source§fn clone(&self) -> ExpandQuery
fn clone(&self) -> ExpandQuery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more