{
    "Resources": [
        {
            "Uri": "/cli/v1/_/reset",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Usage": "ipmcset -d reset",
                    "Description": "Reboot {{SoftwareName}} system",
                    "Confirm": {
                        "Condition": true,
                        "Description": "This operation will reboot {{SoftwareName}} system.\nContinue? [Y/N]:"
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "Method",
                            "Path": "/bmc/kepler/MacaService",
                            "Interface": "bmc.kepler.SystemControl",
                            "Name": "GracefulReset",
                            "Params": [
                                0
                            ]
                        }
                    ],
                    "Echoes": [
                        "ipmcset/_reset",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/_/rollback",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Perform a manual rollback",
                    "Usage": "ipmcset -d rollback",
                    "Confirm": {
                        "Condition": true,
                        "Description": "WARNING: The operation may have many adverse effects.\nDo you want to continue?[Y/N]:"
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "Method",
                            "Path": "/bmc/kepler/UpdateService",
                            "Interface": "bmc.kepler.UpdateService",
                            "Name": "Rollback",
                            "Params": [
                                1,
                                "ActiveBMC"
                            ]
                        }
                    ],
                    "Echoes": [
                        "ipmcset/_rollback",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/_/upgrade",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Upgrade component",
                    "Usage": "ipmcset -d upgrade -v <filepath> [activemode] [-s <systemid>]",
                    "ReqHeader": {
                        "SystemId": ["255"]
                    },
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "filepath": {
                                "Required": true,
                                "Type": "string",
                                "Validator": [
                                    {
                                        "Type": "Regex",
                                        "Formula": "^((https|sftp|nfs|cifs|scp)://.{1,1000}|/tmp/.{1,246})$"
                                    }
                                ],
                                "Description": "      e.g.: /tmp/image.hpm"
                            },
                            "activemode": {
                                "Required": false,
                                "Type": "integer",
                                "Validator": [
                                    {
                                        "Type": "Enum",
                                        "Formula": [
                                            0,
                                            1
                                        ]
                                    }
                                ],
                                "Description": "    e.g.: 1\r\n    0: firmware need to reboot manually after {{SoftwareName}} is upgraded.\r\n    1: firmware will reboot after {{SoftwareName}} is upgraded(default).\r\nsystemid:       e.g.: 1\r\nNote:\r\n    1.If OS is power on,the BIOS upgrade file is uploaded to {{SoftwareName}} and take effect when OS is power-off or reseted next time.\r\n    2.If OS is power on,the CPLD or VRD upgrade file is uploaded to {{SoftwareName}} and take effect when OS is power-off.\r\n    3.Length of filepath should not exceed 255 characters.\r\n    4.Systemid indicates the host whose firmware is to be upgraded. The host must be in position. If systemid is not specified, all hosts are upgraded by default."
                            }
                        }
                    },
                    "RspBody": {
                        "GetRealUpgradePath": "${Statements/GetRealUpgradePath()}",
                        "BmcActiveMode": "${Statements/GetExpandParameters()/ActiveMode}",
                        "SoftwareName": "${ProcessingFlow[2]/Destination/SoftwareName}"
                    },
                    "Statements": {
                        "GetRealUpgradePath": {
                            "Steps": [
                                {
                                    "Type": "Plugin",
                                    "Formula": "orchestrator.upgrade.get_update_filepath(ReqBody.filepath)"
                                }
                            ]
                        },
                        "IsFilePermitted": {
                            "Input": "${Statements/GetRealUpgradePath()}",
                            "Steps": [
                                {
                                    "Type": "Plugin",
                                    "Formula": "orchestrator.account.is_permitted(Context, Input[2], 'rw')"
                                }
                            ]
                        },
                        "CheckFilePermitted": {
                            "Input": "${Statements/IsFilePermitted()}",
                            "Steps": [
                                {
                                    "Type": "Script",
                                    "Formula": "return Input or error(custom_messages.NoPrivilegeToOperateSpecifiedFile())"
                                }
                            ]
                        },
                        "GetExpandParameters": {
                            "Steps": [
                                {
                                    "Type": "Plugin",
                                    "Formula": "orchestrator.upgrade.get_expand_parameters(ReqBody.activemode)"
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "Task",
                            "Path": "/bmc/kepler/UpdateService",
                            "Interface": "bmc.kepler.UpdateService",
                            "Name": "StartUpgrade",
                            "Params": [
                                "${Statements/GetRealUpgradePath()[2]}",
                                "${Statements/GetExpandParameters()}"
                            ],
                            "CallIf": {
                                "${Statements/GetRealUpgradePath()[1]}": true,
                                "${Statements/CheckFilePermitted()}": true
                            },
                            "ContextParams": {
                                "SystemId": "${ReqHeader/SystemId[#INDEX]}"
                            }
                        },
                        {
                            "Type": "Property",
                            "Path": "/bmc/kepler/Managers/1/BMC",
                            "Interface": "bmc.kepler.Managers.BMC",
                            "Destination": {
                                "SoftwareName": "SoftwareName"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/_upgrade"
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/_/timezone",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set time zone",
                    "Usage": "ipmcset -d timezone -v <timezone>",
                    "Example": [
                        "ipmcset -d timezone -v UTC+8:00",
                        "ipmcset -d timezone -v Asia/Shanghai"
                    ],
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "timezone": {
                                "Required": true,
                                "Type": "string",
                                "Description": "\n        Time-Offset: -12:00~+14:00            e.g. +08:00,-04:30\n                     UTC-12:00~UTC+14:00      e.g. UTC+08:00,UTC-04:30\n                     GMT-12:00~GMT+14:00      e.g. GMT+08:00,GMT-04:30\n        Timezone   : <City Name>              e.g. Asia/Shanghai,America/New_York"
                            }
                        }
                    },
                    "RspBody": {
                        "MatchTimezoneResult": "${Statements/MatchTimezoneResult()}"
                    },
                    "Statements": {
                        "MatchTimezoneResult": {
                            "Steps": [
                                {
                                    "Type": "Plugin",
                                    "Formula": "orchestrator.time.timezone_check(ReqBody.timezone)"
                                }
                            ]
                        },
                        "CheckTimeZoneConfigurable": {
                            "Steps": [
                                {
                                    "Type": "Plugin",
                                    "Formula": "orchestrator.time.timezone_configurable_check(ReqBody.timezone, ProcessingFlow[2].Destination.TimeZoneConfigurable)"
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "List",
                            "Path": "/bmc/kepler/Managers",
                            "Interface": "bmc.kepler.Managers.Time",
                            "Destination": {
                                "Members": "time_list"
                            }
                        },
                        {
                            "Type": "Property",
                            "Path": "${ProcessingFlow[1]/Destination/time_list[1]}",
                            "Interface": "bmc.kepler.Managers.Time",
                            "Destination": {
                                "TimeZoneConfigurable": "TimeZoneConfigurable"
                            }
                        },
                        {
                            "Type": "Property",
                            "Path": "${ProcessingFlow[1]/Destination/time_list[1]}",
                            "Interface": "bmc.kepler.Managers.Time",
                            "Source": {
                                "TimeZoneName": "${Statements/CheckTimeZoneConfigurable()}"
                            },
                            "CallIf": {
                                "${Statements/MatchTimezoneResult()}": true
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/_timezone",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/_/serialdir",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set serial direction",
                    "Usage": "ipmcset -d serialdir -v <option> [-s <systemid>]",
                    "ReqHeader": {
                        "SystemId": [
                            "0"
                        ]
                    },
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "option": {
                                "Required": false
                            }
                        }
                    },
                    "RspBody": {
                        "connect_table": "${Statements/get_connect_objects()}",
                        "option": "${ReqBody/option}"
                    },
                    "Statements": {
                        "get_save_options": {
                            "Input": "${Statements/set_connect_objects()}",
                            "Steps": [
                                {
                                    "Type": "Script",
                                    "Formula": "for _, obj in pairs(Input) do if tonumber(obj.Id) == tonumber(ReqBody.option) and obj.Source == 'PANEL COM' then return true end end return false"
                                }
                            ]
                        },
                        "set_connect_objects": {
                            "Input": "${ProcessingFlow[1]/Destination/connect_table}",
                            "Steps": [
                                {
                                    "Type": "Expand"
                                }
                            ]
                        },
                        "get_connect_objects": {
                            "Input": "${ProcessingFlow[1]/Destination/connect_table}",
                            "Steps": [
                                {
                                    "Type": "Expand"
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "List",
                            "Path": "/bmc/kepler/Managers/1/SerialManagement",
                            "Destination": {
                                "Members": "connect_table"
                            }
                        },
                        {
                            "Type": "Method",
                            "Path": "${Statements/set_connect_objects()[#INDEX]/Path}",
                            "Interface": "bmc.kepler.Managers.SerialManagement",
                            "Name": "SetConnectStatus",
                            "Params": [
                                "${Statements/get_save_options()}"
                            ],
                            "CallIf": {
                                "${ReqBody/option}": "${Statements/set_connect_objects()[#INDEX]/Id}"
                            },
                            "Foreach": "${Statements/set_connect_objects()}",
                            "ContextParams": {
                                "SystemId": "${ReqHeader/SystemId[1]}"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/_serialdir"
                    ]
                }
            ]
        },
        {
            "Uri": "/bmc/kepler/Managers/1/SerialManagement/:serialmanagement_id",
            "Interfaces": [
                {
                    "Type": "Get",
                    "RspBody": {
                        "Id": "${Statements/Id()}",
                        "Source": "${ProcessingFlow[1]/Destination/Source}",
                        "Destination": "${ProcessingFlow[1]/Destination/Destination}",
                        "Availability": "${ProcessingFlow[1]/Destination/Availability}",
                        "Path": "/bmc/kepler/Managers/1/SerialManagement/${Uri/serialmanagement_id}",
                        "CurrentConnectStatus": "${ProcessingFlow[1]/Destination/CurrentConnectStatus}"
                    },
                    "Statements": {
                        "Id": {
                            "Steps": [
                                {
                                    "Type": "Script",
                                    "Formula": "return tostring(ProcessingFlow[1].Destination.Id)"
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "Property",
                            "Path": "/bmc/kepler/Managers/1/SerialManagement/${Uri/serialmanagement_id}",
                            "Interface": "bmc.kepler.Managers.SerialManagement",
                            "Destination": {
                                "Id": "Id",
                                "Source": "Source",
                                "Destination": "Destination",
                                "Availability": "Availability",
                                "CurrentConnectStatus": "CurrentConnectStatus"
                            }
                        }
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/_/bootdevice",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set boot device",
                    "Usage": "ipmcset -d bootdevice -v <option> [times]",
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "option": {
                                "Required": true,
                                "Type": "integer",
                                "Validator": [
                                    {
                                        "Type": "Enum",
                                        "Formula": [
                                            0,
                                            1,
                                            2,
                                            5,
                                            6,
                                            15
                                        ]
                                    }
                                ],
                                "Description": "\n\t0    No override\n\t1    Force PXE\n\t2    Force boot from default Hard-drive\n\t5    Force boot from default CD/DVD\n\t6    Force boot into BIOS Setup\n\t0xF  Force boot from Floppy/primary removable media"
                            },
                            "times": {
                                "Required": false,
                                "Description": "[once | permanent], default once.",
                                "Validator": [
                                    {
                                        "Type": "Enum",
                                        "Formula": [
                                            "once",
                                            "permanent"
                                        ]
                                    }
                                ]
                            }
                        }
                    },
                    "RspBody": {
                        "OptionResult": "${ProcessingFlow[1]/Destination/OptionResult}",
                        "TimesResultWithout": "${ProcessingFlow[2]/Destination/TimesResult}",
                        "TimesResultWith": "${ProcessingFlow[3]/Destination/TimesResult}"
                    },
                    "Statements": {
                        "BootSourceOverrideTarget": {
                            "Input": "${ReqBody/option}",
                            "Steps": [
                                {
                                    "Type": "Switch",
                                    "Formula": [
                                        {
                                            "Case": 0,
                                            "To": "None"
                                        },
                                        {
                                            "Case": 1,
                                            "To": "Pxe"
                                        },
                                        {
                                            "Case": 2,
                                            "To": "Hdd"
                                        },
                                        {
                                            "Case": 5,
                                            "To": "Cd"
                                        },
                                        {
                                            "Case": 6,
                                            "To": "BiosSetup"
                                        },
                                        {
                                            "Case": 15,
                                            "To": "Floppy"
                                        }
                                    ]
                                }
                            ]
                        },
                        "Times": {
                            "Input": "${ReqBody/times}",
                            "Steps": [
                                {
                                    "Type": "Switch",
                                    "Formula": [
                                        {
                                            "Case": "once",
                                            "To": "Once"
                                        },
                                        {
                                            "Case": "permanent",
                                            "To": "Continuous"
                                        }
                                    ]
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "Method",
                            "Path": "/bmc/kepler/Systems/1/BootOptions",
                            "Interface": "bmc.kepler.Systems.BootOptions",
                            "Name": "SetStartOption",
                            "Params": [
                                "${Statements/BootSourceOverrideTarget()}"
                            ],
                            "Destination": {
                                "Result": "OptionResult"
                            }
                        },
                        {
                            "Type": "Method",
                            "Path": "/bmc/kepler/Systems/1/BootOptions",
                            "Interface": "bmc.kepler.Systems.BootOptions",
                            "Name": "SetStartOptionFlag",
                            "Params": [
                                "Once"
                            ],
                            "Destination": {
                                "Result": "TimesResult"
                            },
                            "CallIf": {
                                "${ReqBody/times}": "#WITHOUT"
                            }
                        },
                        {
                            "Type": "Method",
                            "Path": "/bmc/kepler/Systems/1/BootOptions",
                            "Interface": "bmc.kepler.Systems.BootOptions",
                            "Name": "SetStartOptionFlag",
                            "Params": [
                                "${Statements/Times()}"
                            ],
                            "Destination": {
                                "Result": "TimesResult"
                            },
                            "CallIf": {
                                "${ReqBody/times}": "#WITH"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/_bootdevice",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/_/clearcmos",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Clear CMOS",
                    "ReqHeader": {
                        "SystemId": []
                    },
                    "Usage": "ipmcset -d clearcmos [-s <systemid>]",
                    "Confirm": {
                        "Condition": true,
                        "Description": "WARNING: The operation may have many adverse effects.\nDo you want to continue?[Y/N]:"
                    },
                    "RspBody": {
                        "HostType": "${Statements/GetHostType()}",
                        "ClearCmos": "${Statements/ClearCmos()}"
                    },
                    "Statements": {
                        "ClearCmos": {
                            "Steps": [
                                {
                                    "Type": "Plugin",
                                    "Formula": "orchestrator.clear_cmos.clear_cmos(ReqHeader.SystemId)"
                                }
                            ]
                        },
                        "GetHostType": {
                            "Steps": [
                                {
                                    "Type": "Plugin",
                                    "Formula": "orchestrator.clear_cmos.get_hosttype()"
                                }
                            ]
                        }
                    },
                    "Echoes": [
                        "ipmcset/_clearcmos",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/_/restore",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Restore factory setting",
                    "Usage": "ipmcset -d restore",
                    "Authentication": {
                        "Description": "WARNING: The {{SoftwareName}} will automatically restart and restore factory settings.${Statements/GetFactoryRestorePointTimestamp()}\nInput your password:",
                        "Condition": true
                    },
                    "RspBody": {
                        "TaskId": "${ProcessingFlow[1]/Destination/TaskId}"
                    },
                    "Statements": {
                        "GetFactoryRestorePointTimestamp": {
                            "Steps": [
                                {
                                    "Type": "Plugin",
                                    "Formula": "orchestrator.restore.get_timestamp()"
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "Task",
                            "Path": "/bmc/kepler/Managers/1/Configurations",
                            "Interface": "bmc.kepler.Managers.Configurations",
                            "Name": "RecoverFactoryRestorePoint",
                            "Params": [
                                {}
                            ],
                            "Destination": {
                                "TaskId": "TaskId"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/_restore",
                        ""
                    ]
                }
            ]
        }
    ]
}