{
    "Resources": [
        {
            "Uri": "/cli/v1/trap",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Operate SNMP trap"
                }
            ]
        },
        {
            "Uri": "/cli/v1/trap/address",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set trap address",
                    "Usage": "ipmcset -t trap -d address -v <destination> <ipaddr>",
                    "Brief": "destination : The destination index that will be set. The values can be 1, 2, 3 or 4.\nipaddr      : The IP address that will be set. The value \"\" means clearing the address.",
                    "Example": [
                        "ipmcset -t trap -d address -v 1 192.168.1.1",
                        "ipmcset -t trap -d address -v 4 \"\""
                    ],
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "destination": {
                                "Type": "integer",
                                "Validator": [
                                    {
                                        "Type": "Enum",
                                        "Formula": [
                                            1,
                                            2,
                                            3,
                                            4
                                        ]
                                    }
                                ],
                                "Required": true
                            },
                            "ipaddr": {
                                "Type": "string",
                                "Required": true
                            }
                        }
                    },
                    "RspBody": {
                        "Destination": "${ReqBody/destination}"
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "Property",
                            "Path": "/bmc/kepler/EventService/Subscriptions/Snmp/Nmses/${ReqBody/destination}",
                            "Interface": "bmc.kepler.EventService.Subscriptions.Snmp.Nms",
                            "Source": {
                                "Address": "${ReqBody/ipaddr}"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/trap_address",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/trap/port",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set trap port",
                    "Usage": "ipmcset -t trap -d port -v <destination> <portvalue>  ",
                    "Brief": "destination : The destination index that will be set. The values can be 1, 2, 3 or 4.\nportvalue   : The port value that will be set. The value can be from 1 to 65535.",
                    "Example": [
                        "ipmcset -t trap -d port -v 1 1",
                        "ipmcset -t trap -d port -v 4 65535"
                    ],
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "destination": {
                                "Type": "integer",
                                "Validator": [
                                    {
                                        "Type": "Enum",
                                        "Formula": [
                                            1,
                                            2,
                                            3,
                                            4
                                        ]
                                    }
                                ],
                                "Required": true
                            },
                            "portvalue": {
                                "Type": "integer",
                                "Required": true,
                                "Validator": [
                                    {
                                        "Type": "Range",
                                        "Formula": [
                                            1,
                                            65535
                                        ]
                                    }
                                ]
                            }
                        }
                    },
                    "RspBody": {
                        "Destination": "${ReqBody/destination}"
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "Property",
                            "Path": "/bmc/kepler/EventService/Subscriptions/Snmp/Nmses/${ReqBody/destination}",
                            "Interface": "bmc.kepler.EventService.Subscriptions.Snmp.Nms",
                            "Source": {
                                "Port": "${ReqBody/portvalue}"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/trap_port",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/trap/severity",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set trap send severity",
                    "Usage": "ipmcset -t trap -d severity -v <level>",
                    "Brief": "Level contains at least one of the following severity levels : none,all,normal,minor,major,critical.\n    e.g.: none\n    e.g.: normal minor",
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "value1": {
                                "Type": "string",
                                "Required": true
                            },
                            "value2": {
                                "Type": "string",
                                "Required": false
                            },
                            "value3": {
                                "Type": "string",
                                "Required": false
                            },
                            "value4": {
                                "Type": "string",
                                "Required": false
                            }
                        }
                    },
                    "RspBody": {
                        "CheckSeverityResult": "${Statements/CheckSeverity()}"
                    },
                    "Statements": {
                        "SeverityFilter": {
                            "Steps": [
                                {
                                    "Type": "Plugin",
                                    "Formula": "orchestrator.trap.get_severity_filter(ReqBody)"
                                }
                            ]
                        },
                        "CheckSeverity": {
                            "Steps": [
                                {
                                    "Type": "Plugin",
                                    "Formula": "orchestrator.trap.check_severity(ReqBody)"
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "Property",
                            "Path": "/bmc/kepler/EventService/Subscriptions/Snmp",
                            "Interface": "bmc.kepler.EventService.Subscriptions.Snmp",
                            "Source": {
                                "SeverityFilter": "${Statements/SeverityFilter()}"
                            },
                            "CallIf": {
                                "${Statements/CheckSeverity()}": true
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/trap_severity",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/trap/state",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set trap enable state",
                    "Usage": "ipmcset -t trap -d state -v [destination] <disabled|enabled>",
                    "Brief": "To enable or disable the trap function for a trap server, you must specifiy the destination parameter. The value range of destination is 1 to 4.\nTo enable or disable the trap function,leave destination unspecified.",
                    "Example": [
                        "ipmcset -t trap -d state -v disabled",
                        "ipmcset -t trap -d state -v enabled",
                        "ipmcset -t trap -d state -v 1 disabled",
                        "ipmcset -t trap -d state -v 4 enabled"
                    ],
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "destination": {
                                "Required": false,
                                "Type": "integer",
                                "Validator": [
                                    {
                                        "Type": "Enum",
                                        "Formula": [
                                            1,
                                            2,
                                            3,
                                            4
                                        ]
                                    }
                                ]
                            },
                            "state": {
                                "Required": true,
                                "Type": "string",
                                "Validator": [
                                    {
                                        "Type": "Enum",
                                        "Formula": [
                                            "enabled",
                                            "disabled"
                                        ]
                                    }
                                ]
                            }
                        }
                    },
                    "RspBody": {
                        "destination": "${Statements/Destination()}",
                        "state": "${ReqBody/state}"
                    },
                    "Statements": {
                        "state_bool": {
                            "Input": "${ReqBody/state}",
                            "Steps": [
                                {
                                    "Type": "Switch",
                                    "Formula": [
                                        {
                                            "Case": "enabled",
                                            "To": true
                                        },
                                        {
                                            "Case": "disabled",
                                            "To": false
                                        }
                                    ]
                                }
                            ]
                        },
                        "Destination": {
                            "Steps": [
                                {
                                    "Type": "Script",
                                    "Formula": "return ReqBody.destination == nil and '' or ' dest' .. ReqBody.destination"
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "Property",
                            "Path": "/bmc/kepler/EventService/Subscriptions/Snmp",
                            "Interface": "bmc.kepler.EventService.Subscriptions.Snmp",
                            "Source": {
                                "Enabled": "${Statements/state_bool()}"
                            },
                            "CallIf": {
                                "${ReqBody/destination}": "#WITHOUT"
                            }
                        },
                        {
                            "Type": "Property",
                            "Path": "/bmc/kepler/EventService/Subscriptions/Snmp/Nmses/${ReqBody/destination}",
                            "Interface": "bmc.kepler.EventService.Subscriptions.Snmp.Nms",
                            "Source": {
                                "Enabled": "${Statements/state_bool()}"
                            },
                            "CallIf": {
                                "${ReqBody/destination}": "#WITH"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/trap_state",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/trap/user",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set SNMP trap user",
                    "Usage": "ipmcset -t trap -d user -v <username>",
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "username": {
                                "Type": "string",
                                "Required": true,
                                "Validator": [
                                    {
                                        "Type": "Regex",
                                        "Formula": "^(?!.*[<>&,'/\\%:\" ])(?=[A-Za-z0-9`~!@#$%^&*()_+-={};[\\]?.|])(?!#)(?!\\+)(?!-)([A-Za-z0-9`~!@#$%^&*()_+-={};[\\]?.|]{1,16})$"
                                    }
                                ],
                                "Description": "\n    Contain any digits, letters, or characters except (:,\\<>&\"'/%) and space.\n    User name's length is limitted to 1-16.\n    User name cannot start with character \"#\" \"+\" or \"-\".\r\n    User name cannot be just a dot (.) or two consecutive dots (..).\r\n"
                            }
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "Method",
                            "Path": "/bmc/kepler/AccountService/Accounts",
                            "Interface": "bmc.kepler.AccountService.ManagerAccounts",
                            "Name": "GetIdByUserName",
                            "Params": [
                                "${ReqBody/username}"
                            ],
                            "Destination": {
                                "AccountId": "SNMPv3TrapAccountId"
                            }
                        },
                        {
                            "Type": "Property",
                            "Path": "/bmc/kepler/AccountService",
                            "Interface": "bmc.kepler.AccountService",
                            "Source": {
                                "SNMPv3TrapAccountId": "${ProcessingFlow[1]/Destination/SNMPv3TrapAccountId}"
                            },
                            "CallIf": {
                                "${ProcessingFlow[1]/Destination/SNMPv3TrapAccountId}": "#WITH"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/trap_user",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/trap/version",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set SNMP trap version",
                    "Usage": "ipmcset -t trap -d version -v <V1|V2C|V3>",
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "version": {
                                "Type": "string",
                                "Validator": [
                                    {
                                        "Type": "Enum",
                                        "Formula": [
                                            "V1",
                                            "V2C",
                                            "V3"
                                        ]
                                    }
                                ],
                                "Required": true
                            }
                        }
                    },
                    "RspBody": {
                        "version": "${ReqBody/version}"
                    },
                    "Statements": {
                        "version": {
                            "Input": "${ReqBody/version}",
                            "Steps": [
                                {
                                    "Type": "Switch",
                                    "Formula": [
                                        {
                                            "Case": "V1",
                                            "To": "SNMPv1"
                                        },
                                        {
                                            "Case": "V2C",
                                            "To": "SNMPv2c"
                                        },
                                        {
                                            "Case": "V3",
                                            "To": "SNMPv3"
                                        }
                                    ]
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "Property",
                            "Path": "/bmc/kepler/EventService/Subscriptions/Snmp",
                            "Interface": "bmc.kepler.EventService.Subscriptions.Snmp",
                            "Source": {
                                "Version": "${Statements/version()}"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/trap_version",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/trap/community",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set SNMP trap community",
                    "Usage": "ipmcset -t trap -d community",
                    "RspBody": {
                        "Result": "${Statements/GetCommunity()}"
                    },
                    "Statements": {
                        "GetCommunity": {
                            "Steps": [
                                {
                                    "Type": "Plugin",
                                    "Formula": "orchestrator.trap.get_community()"
                                }
                            ]
                        }
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "Method",
                            "Path": "/bmc/kepler/EventService/Subscriptions/Snmp",
                            "Interface": "bmc.kepler.EventService.Subscriptions.Snmp",
                            "Name": "SetCommunity",
                            "Params": [
                                "${Statements/GetCommunity()/ret}"
                            ],
                            "CallIf": {
                                "${Statements/GetCommunity()/ok}": true
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/trap_community",
                        ""
                    ]
                }
            ]
        },
        {
            "Uri": "/cli/v1/trap/mode",
            "Interfaces": [
                {
                    "Type": "Patch",
                    "Description": "Set SNMP trap mode",
                    "Usage": "ipmcset -t trap -d mode -v <option>   \nOptions are:  \n  1   OID \n  2   Precise Alarm",
                    "ReqBody": {
                        "Type": "object",
                        "Required": true,
                        "Properties": {
                            "mode": {
                                "Type": "integer",
                                "Validator": [
                                    {
                                        "Type": "Enum",
                                        "Formula": [
                                            1,
                                            2
                                        ]
                                    }
                                ],
                                "Required": true
                            }
                        }
                    },
                    "RspBody": {
                        "mode": "${ReqBody/mode}"
                    },
                    "ProcessingFlow": [
                        {
                            "Type": "Property",
                            "Path": "/bmc/kepler/EventService/Subscriptions/Snmp",
                            "Interface": "bmc.kepler.EventService.Subscriptions.Snmp",
                            "Source": {
                                "TrapMode": "${ReqBody/mode}"
                            }
                        }
                    ],
                    "Echoes": [
                        "ipmcset/trap_mode",
                        ""
                    ]
                }
            ]
        }
    ]
}