From 0cb0c9cbe86fca8efd4d258d837f9cd7dff28f05 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Wed, 16 Oct 2024 12:44:27 -0500 Subject: [PATCH] Add Drive.EnvironmentMetrics() accessor (#373) We added EnvironmentMetrics objects, but did not provide a way to fetch them from the links of a Drive. This adds a Drive function to retrieve the EnvironmentMetrics when available. Signed-off-by: Sean McGinnis --- redfish/drive.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/redfish/drive.go b/redfish/drive.go index a90b92a0..f04489a8 100644 --- a/redfish/drive.go +++ b/redfish/drive.go @@ -473,6 +473,17 @@ func (drive *Drive) Endpoints() ([]*Endpoint, error) { return common.GetObjects[Endpoint](drive.GetClient(), drive.endpoints) } +// EnvironmentMetrics gets the environment metrics for this drive. +// If no metrics are available the EnvironmentMetrics reference will be nil but +// no error will be returned unless it was due to a problem fetching the data. +func (drive *Drive) EnvironmentMetrics() (*EnvironmentMetrics, error) { + if drive.environmentMetrics == "" { + return nil, nil + } + + return GetEnvironmentMetrics(drive.GetClient(), drive.environmentMetrics) +} + // Volumes references the Volumes that this drive is associated with. func (drive *Drive) Volumes() ([]*Volume, error) { return common.GetObjects[Volume](drive.GetClient(), drive.volumes)