Skip to content

feat(redfish): expose standard reset action helpers#114

Open
jayzhudev wants to merge 3 commits into
NVIDIA:mainfrom
jayzhudev:feat/common-reset-actions
Open

feat(redfish): expose standard reset action helpers#114
jayzhudev wants to merge 3 commits into
NVIDIA:mainfrom
jayzhudev:feat/common-reset-actions

Conversation

@jayzhudev

Copy link
Copy Markdown
Contributor

Add typed high-level wrappers for DMTF Redfish reset actions on ComputerSystem, Manager, Chassis, and PowerSupply.

Also omit absent optional action parameters from generated request bodies. So reset(None) sends an empty action body rather than ResetType: null, which matches Redfish schemas where ResetType may be omitted.

Spec references:

  • ComputerSystem.Reset: schema/redfish-csdl/csdl/ComputerSystem_v1.xml
  • Manager.Reset: schema/redfish-csdl/csdl/Manager_v1.xml
  • Manager.ResetToDefaults: schema/redfish-csdl/csdl/Manager_v1.xml
  • Chassis.Reset: schema/redfish-csdl/csdl/Chassis_v1.xml
  • PowerSupply.Reset: schema/redfish-csdl/csdl/PowerSupply_v1.xml

Add typed high-level wrappers for DMTF Redfish reset actions on
`ComputerSystem`, `Manager`, `Chassis`, and `PowerSupply`.

Also omit absent optional action parameters from generated request bodies.
This lets reset(None) send an empty action body rather than ResetType: null,
matching Redfish schemas where ResetType may be omitted.

Spec references:
- ComputerSystem.Reset: schema/redfish-csdl/csdl/ComputerSystem_v1.xml
- Manager.Reset: schema/redfish-csdl/csdl/Manager_v1.xml
- Manager.ResetToDefaults: schema/redfish-csdl/csdl/Manager_v1.xml
- Chassis.Reset: schema/redfish-csdl/csdl/Chassis_v1.xml
- PowerSupply.Reset: schema/redfish-csdl/csdl/PowerSupply_v1.xml

Signed-off-by: Jay Zhu <jayzhu@nvidia.com>
@jayzhudev jayzhudev requested review from poroh and yoks June 19, 2026 06:39
)
}
};
let serde = Self::gen_action_parameter_serde_annotation(rename, p.required);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have concerns WRT this function. gen_de_struct_field_type can generate , T, Option<T>, Option<Option<T>, Vec<T>, Option<Vec<T>, Option<Option<Vec<T>. gen_action_parameter_serde_annotation only adds "skip_serializing_if = Option::is_none".

Maybe old generated code was not quite correct in some situations however I don't think that new code can correctly handle "null" fields.

I think we need something like:

    fn gen_ser_struct_field_serde_annot(
        rename: impl ToTokens,
        nullable: IsNullable,
        required: IsRequired,
    ) -> TokenStream {
        if required.into_inner() && nullable.into_inner() {
            quote! { #[serde(rename=#rename, serialize_with="ser_required_nullable")] }
        } else if required.into_inner() {
            quote! { #[serde(rename=#rename)] }
        } else if nullable.into_inner() {
            quote! { #[serde(rename=#rename, default, serialize_with="ser_optional_nullable")] }
        } else {
            quote! { #[serde(rename=#rename, default, skip_serializing_if = "Option::is_none"))] }
        }
    }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. Functionality wise, the gen_de_struct_field_type decides the type such as the ones you mentioned (Option<T>, Option<Option<T>> etc.). So the nullability is "encoded" by it. The gen_action_parameter_serde_annotation controls if the top-level None should be omitted. One concern is to potentially having a Vec<T> field annotated with skip_serializing_if = "Option::is_none".

The key non-obviousness comes from implicitly coordinating two branching logic based on required. In gen_de_struct_field_type, required generates a non-Option, or an Option that can be serialized to JSON null, which matches the branches in this function.

I added this clarification in comments and added tests to catch regression.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can think of some refactoring to make this coordination obvious?

@jayzhudev jayzhudev requested a review from poroh June 20, 2026 19:02
…eration

Signed-off-by: Jay Zhu <jayzhu@nvidia.com>
@jayzhudev jayzhudev self-assigned this Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants