{
    "Resources": [
        {
            "Uri": "/cli/v1/ntp",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Operate ntp"
                }
            ]
        },
        {
            "Uri": "/cli/v1/ntp/alternativeserver",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set alternative NTP server address",
                    "Usage": "ipmcset -t ntp -d alternativeserver -v <addr>",
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "addr": {
                                "Type": "string",
                                "Required": true
                            }
                        }
                    },
                    "RspBody": {
                        "addr": "${ReqBody/addr}"
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "List",
                            "Path": "/bmc/kepler/Managers",
                            "Interface": "bmc.kepler.Managers.Ntp",
                            "Destination": {
                                "Members": "ntp_list"
                            }
                        },
                        {
                            "Type": "Property",
                            "Path": "${ProcessingFlow[1]/Destination/ntp_list[1]}",
                            "Interface": "bmc.kepler.Managers.Ntp",
                            "Source": {
                                "AlternateServer": "${ReqBody/addr}"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/ntp_alternativeserver",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/ntp/authstatus",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Enable auth status",
                    "Usage": "ipmcset -t ntp -d authstatus -v <enabled|disabled>",
                    "Example": [
                        "ipmcset -t ntp -d authstatus -v enabled",
                        "ipmcset -t ntp -d authstatus -v disabled"
                    ],
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "status": {
                                "Required": true,
                                "Type": "string",
                                "Validator": [
                                    {
                                        "Type": "Enum",
                                        "Formula": [
                                            "enabled",
                                            "disabled"
                                        ]
                                    }
                                ]
                            }
                        }
                    },
                    "RspBody": {
                        "status": "${ReqBody/status}"
                    },
                    "Statements": {
                        "status_bool": {
                            "Input": "${ReqBody/status}",
                            "Steps": [
                                {
                                    "Type": "Switch",
                                    "Formula": [
                                        {
                                            "Case": "enabled",
                                            "To": true
                                        },
                                        {
                                            "Case": "disabled",
                                            "To": false
                                        }
                                    ]
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "List",
                            "Path": "/bmc/kepler/Managers",
                            "Interface": "bmc.kepler.Managers.Ntp.Auth",
                            "Destination": {
                                "Members": "ntp_list"
                            }
                        },
                        {
                            "Type": "Property",
                            "Path": "${ProcessingFlow[1]/Destination/ntp_list[1]}",
                            "Interface": "bmc.kepler.Managers.Ntp.Auth",
                            "Source": {
                                "AuthEnabled": "${Statements/status_bool()}"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/ntp_authstatus",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/ntp/extraserver",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set extra NTP server address",
                    "Usage": "ipmcset -t ntp -d extraserver -v <addr>",
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "addr": {
                                "Type": "string",
                                "Required": true
                            }
                        }
                    },
                    "RspBody": {
                        "addr": "${ReqBody/addr}",
                        "NTPServerCount": "${ProcessingFlow[2]/Destination/NTPServerCount}",
                        "addr_tab_len": "${Statements/addr_tab_len()}"
                    },
                    "Statements": {
                        "addr_tab_len": {
                            "Steps": [
                                {
                                    "Type": "Script",
                                    "Formula": "separate_addr_with_commas.lua"
                                },
                                {
                                    "Type": "Count"
                                }
                            ]
                        },
                        "addr_tab": {
                            "Steps": [
                                {
                                    "Type": "Script",
                                    "Formula": "separate_addr_with_commas.lua"
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "List",
                            "Path": "/bmc/kepler/Managers",
                            "Interface": "bmc.kepler.Managers.Ntp",
                            "Destination": {
                                "Members": "ntp_list"
                            }
                        },
                        {
                            "Type": "Property",
                            "Path": "${ProcessingFlow[1]/Destination/ntp_list[1]}",
                            "Interface": "bmc.kepler.Managers.Ntp",
                            "Destination": {
                                "NTPServerCount": "NTPServerCount"
                            }
                        },
                        {
                            "Type": "Property",
                            "Path": "${ProcessingFlow[1]/Destination/ntp_list[1]}",
                            "Interface": "bmc.kepler.Managers.Ntp",
                            "Source": {
                                "ExtraServers": "${Statements/addr_tab()}"
                            },
                            "CallIf": {
                                "${Statements/addr_tab_len()}": 1,
                                "${ProcessingFlow[2]/Destination/NTPServerCount}": 3
                            }
                        },
                        {
                            "Type": "Property",
                            "Path": "${ProcessingFlow[1]/Destination/ntp_list[1]}",
                            "Interface": "bmc.kepler.Managers.Ntp",
                            "Source": {
                                "ExtraServers": "${Statements/addr_tab()}"
                            },
                            "CallIf": {
                                "${Statements/addr_tab_len()}": 4,
                                "${ProcessingFlow[2]/Destination/NTPServerCount}": 6
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/ntp_extraserver",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/ntp/mode",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set NTP mode",
                    "Usage": "ipmcset -t ntp -d mode -v <manual|dhcpv4|dhcpv6>",
                    "Example": [
                        "ipmcset -t ntp -d mode -v manual",
                        "ipmcset -t ntp -d mode -v dhcpv4",
                        "ipmcset -t ntp -d mode -v dhcpv6"
                    ],
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "ntp_mode": {
                                "Type": "string",
                                "Required": true,
                                "Validator": [
                                    {
                                        "Type": "Enum",
                                        "Formula": [
                                            "manual",
                                            "dhcpv4",
                                            "dhcpv6"
                                        ]
                                    }
                                ]
                            }
                        }
                    },
                    "RspBody": {
                        "ntp_mode": "${ReqBody/ntp_mode}"
                    },
                    "Statements": {
                        "NTPMode": {
                            "Input": "${ReqBody/ntp_mode}",
                            "Steps": [
                                {
                                    "Type": "Switch",
                                    "Formula": [
                                        {
                                            "Case": "manual",
                                            "To": "Static"
                                        },
                                        {
                                            "Case": "dhcpv4",
                                            "To": "IPv4"
                                        },
                                        {
                                            "Case": "dhcpv6",
                                            "To": "IPv6"
                                        }
                                    ]
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "List",
                            "Path": "/bmc/kepler/Managers",
                            "Interface": "bmc.kepler.Managers.Ntp",
                            "Destination": {
                                "Members": "ntp_list"
                            }
                        },
                        {
                            "Type": "Property",
                            "Path": "${ProcessingFlow[1]/Destination/ntp_list[1]}",
                            "Interface": "bmc.kepler.Managers.Ntp",
                            "Source": {
                                "NTPMode": "${Statements/NTPMode()}"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/ntp_mode",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/ntp/groupkey",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Import NTP group key",
                    "LockdownAllow": false,
                    "Usage": "ipmcset -t ntp -d groupkey -v <filepath>",
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "filepath": {
                                "Type": "string",
                                "Required": true
                            }
                        }
                    },
                    "RspBody": {
                        "IsLocalFile":"${Statements/IsLocalFile()}",
                        "GetFileExist":"${Statements/GetFileExist()}"
                    },
                    "Statements": {
                        "IsLocalFile": {
                            "Steps": [
                                {
                                    "Type": "Script",
                                    "Formula": "return string.sub(ReqBody.filepath, 1, 5) == '/tmp/'"
                                }
                            ]
                        },
                        "GetFileExist": {
                            "Steps": [
                                {
                                    "Type": "Plugin",
                                    "Formula": "orchestrator.ntp.check_file_exist(ReqBody.filepath)"
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "List",
                            "Path": "/bmc/kepler/Managers",
                            "Interface": "bmc.kepler.Managers.Ntp.Auth",
                            "Destination": {
                                "Members": "ntp_list"
                            }
                        },
                        {
                            "Type": "Method",
                            "Path": "${ProcessingFlow[1]/Destination/ntp_list[1]}",
                            "Interface": "bmc.kepler.Managers.Ntp.Auth",
                            "Name": "ImportGroupKey",
                            "Params": [
                                "${ReqBody/filepath}"
                            ],
                            "CallIf": {
                                "${Statements/IsLocalFile()}": true,
                                "${Statements/GetFileExist()}": true
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/ntp_groupkey",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/ntp/preferredserver",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set preferred NTP server address",
                    "Usage": "ipmcset -t ntp -d preferredserver -v <addr>",
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "addr": {
                                "Type": "string",
                                "Required": true
                            }
                        }
                    },
                    "RspBody": {
                        "addr": "${ReqBody/addr}"
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "List",
                            "Path": "/bmc/kepler/Managers",
                            "Interface": "bmc.kepler.Managers.Ntp",
                            "Destination": {
                                "Members": "ntp_list"
                            }
                        },
                        {
                            "Type": "Property",
                            "Path": "${ProcessingFlow[1]/Destination/ntp_list[1]}",
                            "Interface": "bmc.kepler.Managers.Ntp",
                            "Source": {
                                "PreferServer": "${ReqBody/addr}"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/ntp_preferredserver",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/ntp/status",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set NTP enable status",
                    "Usage": "ipmcset -t ntp -d status -v <enabled|disabled>",
                    "Example": [
                        "ipmcset -t ntp -d status -v enabled",
                        "ipmcset -t ntp -d status -v disabled"
                    ],
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "status": {
                                "Type": "string",
                                "Required": true,
                                "Validator": [
                                    {
                                        "Type": "Enum",
                                        "Formula": [
                                            "enabled",
                                            "disabled"
                                        ]
                                    }
                                ]
                            }
                        }
                    },
                    "RspBody": {
                        "status": "${ReqBody/status}"
                    },
                    "Statements": {
                        "status_bool": {
                            "Input": "${ReqBody/status}",
                            "Steps": [
                                {
                                    "Type": "Switch",
                                    "Formula": [
                                        {
                                            "Case": "enabled",
                                            "To": true
                                        },
                                        {
                                            "Case": "disabled",
                                            "To": false
                                        }
                                    ]
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "List",
                            "Path": "/bmc/kepler/Managers",
                            "Interface": "bmc.kepler.Managers.Ntp",
                            "Destination": {
                                "Members": "ntp_list"
                            }
                        },
                        {
                            "Type": "Property",
                            "Path": "${ProcessingFlow[1]/Destination/ntp_list[1]}",
                            "Interface": "bmc.kepler.Managers.Ntp",
                            "Source": {
                                "Enabled": "${Statements/status_bool()}"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/ntp_status",
                        ""
                    ]
                }
            ]
        }
    ]
}