fix: add type to notification provider options

This commit is contained in:
lucasheld 2022-11-05 18:48:31 +01:00
parent 3c17b2bf16
commit dac368e2a5
2 changed files with 267 additions and 266 deletions

View file

@ -222,24 +222,24 @@ def _check_arguments_monitor(kwargs):
required_args = required_args_by_type[type_] required_args = required_args_by_type[type_]
_check_missing_arguments(required_args, kwargs) _check_missing_arguments(required_args, kwargs)
conditions = { conditions = dict(
"interval": { interval=dict(
"min": 20 min=20,
}, ),
"maxretries": { maxretries=dict(
"min": 0 min=0,
}, ),
"retryInterval": { retryInterval=dict(
"min": 20 min=20,
}, ),
"maxredirects": { maxredirects=dict(
"min": 0 min=0,
}, ),
"port": { port=dict(
"min": 0, min=0,
"max": 65535 max=65535,
} ),
} )
_check_argument_conditions(conditions, kwargs) _check_argument_conditions(conditions, kwargs)
@ -260,12 +260,12 @@ def _check_arguments_proxy(kwargs):
required_args.extend(["username", "password"]) required_args.extend(["username", "password"])
_check_missing_arguments(required_args, kwargs) _check_missing_arguments(required_args, kwargs)
conditions = { conditions = dict(
"port": { port=dict(
"min": 0, min=0,
"max": 65535 max=65535,
} )
} )
_check_argument_conditions(conditions, kwargs) _check_argument_conditions(conditions, kwargs)

View file

@ -48,247 +48,248 @@ class NotificationType(str, Enum):
notification_provider_options = { notification_provider_options = {
NotificationType.ALERTA: [ NotificationType.ALERTA: dict(
"alertaApiEndpoint", alertaApiEndpoint=dict(
"alertaApiKey", type="str"
"alertaEnvironment", ),
"alertaAlertState", alertaApiKey=dict(type="str"),
"alertaRecoverState", alertaEnvironment=dict(type="str"),
], alertaAlertState=dict(type="str"),
NotificationType.ALIYUNSMS: [ alertaRecoverState=dict(type="str"),
"phonenumber", ),
"templateCode", NotificationType.ALIYUNSMS: dict(
"signName", phonenumber=dict(type="str"),
"accessKeyId", templateCode=dict(type="str"),
"secretAccessKey", signName=dict(type="str"),
], accessKeyId=dict(type="str"),
NotificationType.APPRISE: [ secretAccessKey=dict(type="str"),
"appriseURL", ),
"title", NotificationType.APPRISE: dict(
], appriseURL=dict(type="str"),
NotificationType.CLICKSENDSMS: [ title=dict(type="str"),
"clicksendsmsLogin", ),
"clicksendsmsPassword", NotificationType.CLICKSENDSMS: dict(
"clicksendsmsToNumber", clicksendsmsLogin=dict(type="str"),
"clicksendsmsSenderName", clicksendsmsPassword=dict(type="str"),
], clicksendsmsToNumber=dict(type="str"),
NotificationType.DINGDING: [ clicksendsmsSenderName=dict(type="str"),
"webHookUrl", ),
"secretKey", NotificationType.DINGDING: dict(
], webHookUrl=dict(type="str"),
NotificationType.DISCORD: [ secretKey=dict(type="str"),
"discordUsername", ),
"discordWebhookUrl", NotificationType.DISCORD: dict(
"discordPrefixMessage", discordUsername=dict(type="str"),
], discordWebhookUrl=dict(type="str"),
NotificationType.FEISHU: [ discordPrefixMessage=dict(type="str"),
"feishuWebHookUrl", ),
], NotificationType.FEISHU: dict(
NotificationType.GOOGLECHAT: [ feishuWebHookUrl=dict(type="str"),
"googleChatWebhookURL", ),
], NotificationType.GOOGLECHAT: dict(
NotificationType.GORUSH: [ googleChatWebhookURL=dict(type="str"),
"gorushDeviceToken", ),
"gorushPlatform", NotificationType.GORUSH: dict(
"gorushTitle", gorushDeviceToken=dict(type="str"),
"gorushPriority", gorushPlatform=dict(type="str"),
"gorushRetry", gorushTitle=dict(type="str"),
"gorushTopic", gorushPriority=dict(type="str"),
"gorushServerURL", gorushRetry=dict(type="str"),
], gorushTopic=dict(type="str"),
NotificationType.GOTIFY: [ gorushServerURL=dict(type="str"),
"gotifyserverurl", ),
"gotifyapplicationToken", NotificationType.GOTIFY: dict(
"gotifyPriority", gotifyserverurl=dict(type="str"),
], gotifyapplicationToken=dict(type="str"),
NotificationType.LINE: [ gotifyPriority=dict(type="int"),
"lineChannelAccessToken", ),
"lineUserID", NotificationType.LINE: dict(
], lineChannelAccessToken=dict(type="str"),
NotificationType.LUNASEA: [ lineUserID=dict(type="str"),
"lunaseaDevice", ),
], NotificationType.LUNASEA: dict(
NotificationType.MATRIX: [ lunaseaDevice=dict(type="str"),
"internalRoomId", ),
"accessToken", NotificationType.MATRIX: dict(
"homeserverUrl", internalRoomId=dict(type="str"),
], accessToken=dict(type="str"),
NotificationType.MATTERMOST: [ homeserverUrl=dict(type="str"),
"mattermostusername", ),
"mattermostWebhookUrl", NotificationType.MATTERMOST: dict(
"mattermostchannel", mattermostusername=dict(type="str"),
"mattermosticonemo", mattermostWebhookUrl=dict(type="str"),
"mattermosticonurl", mattermostchannel=dict(type="str"),
], mattermosticonemo=dict(type="str"),
NotificationType.ONEBOT: [ mattermosticonurl=dict(type="str"),
"httpAddr", ),
"accessToken", NotificationType.ONEBOT: dict(
"msgType", httpAddr=dict(type="str"),
"recieverId", accessToken=dict(type="str"),
], msgType=dict(type="str"),
NotificationType.PAGERDUTY: [ recieverId=dict(type="str"),
"pagerdutyAutoResolve", ),
"pagerdutyIntegrationUrl", NotificationType.PAGERDUTY: dict(
"pagerdutyPriority", pagerdutyAutoResolve=dict(type="str"),
"pagerdutyIntegrationKey", pagerdutyIntegrationUrl=dict(type="str"),
], pagerdutyPriority=dict(type="str"),
NotificationType.PROMOSMS: [ pagerdutyIntegrationKey=dict(type="str"),
"promosmsLogin", ),
"promosmsPassword", NotificationType.PROMOSMS: dict(
"promosmsPhoneNumber", promosmsLogin=dict(type="str"),
"promosmsSMSType", promosmsPassword=dict(type="str"),
"promosmsSenderName", promosmsPhoneNumber=dict(type="str"),
], promosmsSMSType=dict(type="str"),
NotificationType.PUSHBULLET: [ promosmsSenderName=dict(type="str"),
"pushbulletAccessToken", ),
], NotificationType.PUSHBULLET: dict(
NotificationType.PUSHDEER: [ pushbulletAccessToken=dict(type="str"),
"pushdeerKey", ),
], NotificationType.PUSHDEER: dict(
NotificationType.PUSHOVER: [ pushdeerKey=dict(type="str"),
"pushoveruserkey", ),
"pushoverapptoken", NotificationType.PUSHOVER: dict(
"pushoversounds", pushoveruserkey=dict(type="str"),
"pushoverpriority", pushoverapptoken=dict(type="str"),
"pushovertitle", pushoversounds=dict(type="str"),
"pushoverdevice", pushoverpriority=dict(type="str"),
], pushovertitle=dict(type="str"),
NotificationType.PUSHY: [ pushoverdevice=dict(type="str"),
"pushyAPIKey", ),
"pushyToken", NotificationType.PUSHY: dict(
], pushyAPIKey=dict(type="str"),
NotificationType.ROCKET_CHAT: [ pushyToken=dict(type="str"),
"rocketchannel", ),
"rocketusername", NotificationType.ROCKET_CHAT: dict(
"rocketiconemo", rocketchannel=dict(type="str"),
"rocketwebhookURL", rocketusername=dict(type="str"),
"rocketbutton", rocketiconemo=dict(type="str"),
], rocketwebhookURL=dict(type="str"),
NotificationType.SERWERSMS: [ rocketbutton=dict(type="str"),
"serwersmsUsername", ),
"serwersmsPassword", NotificationType.SERWERSMS: dict(
"serwersmsPhoneNumber", serwersmsUsername=dict(type="str"),
"serwersmsSenderName", serwersmsPassword=dict(type="str"),
], serwersmsPhoneNumber=dict(type="str"),
NotificationType.SIGNAL: [ serwersmsSenderName=dict(type="str"),
"signalNumber", ),
"signalRecipients", NotificationType.SIGNAL: dict(
"signalURL", signalNumber=dict(type="str"),
], signalRecipients=dict(type="str"),
NotificationType.SLACK: [ signalURL=dict(type="str"),
"slackbutton", ),
"slackchannel", NotificationType.SLACK: dict(
"slackusername", slackbutton=dict(type="str"),
"slackiconemo", slackchannel=dict(type="str"),
"slackwebhookURL", slackusername=dict(type="str"),
"slackbutton", slackiconemo=dict(type="str"),
], slackwebhookURL=dict(type="str"),
NotificationType.SMTP: [ ),
"smtpHost", NotificationType.SMTP: dict(
"smtpPort", smtpHost=dict(type="str"),
"smtpSecure", smtpPort=dict(type="int"),
"smtpIgnoreTLSError", smtpSecure=dict(type="str"),
"smtpDkimDomain", smtpIgnoreTLSError=dict(type="str"),
"smtpDkimKeySelector", smtpDkimDomain=dict(type="str"),
"smtpDkimPrivateKey", smtpDkimKeySelector=dict(type="str"),
"smtpDkimHashAlgo", smtpDkimPrivateKey=dict(type="str"),
"smtpDkimheaderFieldNames", smtpDkimHashAlgo=dict(type="str"),
"smtpDkimskipFields", smtpDkimheaderFieldNames=dict(type="str"),
"smtpUsername", smtpDkimskipFields=dict(type="str"),
"smtpPassword", smtpUsername=dict(type="str"),
"customSubject", smtpPassword=dict(type="str"),
"smtpFrom", customSubject=dict(type="str"),
"smtpCC", smtpFrom=dict(type="str"),
"smtpBCC", smtpCC=dict(type="str"),
"smtpTo", smtpBCC=dict(type="str"),
], smtpTo=dict(type="str"),
NotificationType.STACKFIELD: [ ),
"stackfieldwebhookURL", NotificationType.STACKFIELD: dict(
], stackfieldwebhookURL=dict(type="str"),
NotificationType.PUSHBYTECHULUS: [ ),
"pushAPIKey", NotificationType.PUSHBYTECHULUS: dict(
], pushAPIKey=dict(type="str"),
NotificationType.TELEGRAM: [ ),
"telegramBotToken", NotificationType.TELEGRAM: dict(
"telegramChatID", telegramBotToken=dict(type="str"),
], telegramChatID=dict(type="str"),
NotificationType.WEBHOOK: [ ),
"webhookContentType", NotificationType.WEBHOOK: dict(
"webhookURL", webhookContentType=dict(type="str"),
], webhookURL=dict(type="str"),
NotificationType.WECOM: [ ),
"weComBotKey", NotificationType.WECOM: dict(
], weComBotKey=dict(type="str"),
NotificationType.ALERTNOW: [ ),
"alertNowWebhookURL", NotificationType.ALERTNOW: dict(
], alertNowWebhookURL=dict(type="str"),
NotificationType.HOMEASSISTANT: [ ),
"homeAssistantUrl", NotificationType.HOMEASSISTANT: dict(
"longLivedAccessToken", homeAssistantUrl=dict(type="str"),
], longLivedAccessToken=dict(type="str"),
NotificationType.LINENOTIFY: [ ),
"lineNotifyAccessToken", NotificationType.LINENOTIFY: dict(
], lineNotifyAccessToken=dict(type="str"),
NotificationType.BARK: [ ),
"barkEndpoint", NotificationType.BARK: dict(
"barkGroup", barkEndpoint=dict(type="str"),
"barkSound", barkGroup=dict(type="str"),
], barkSound=dict(type="str"),
NotificationType.GOALERT: [ ),
"goAlertBaseURL", NotificationType.GOALERT: dict(
"goAlertToken", goAlertBaseURL=dict(type="str"),
], goAlertToken=dict(type="str"),
NotificationType.OCTOPUSH: [ ),
"octopushVersion", NotificationType.OCTOPUSH: dict(
"octopushAPIKey", octopushVersion=dict(type="str"),
"octopushLogin", octopushAPIKey=dict(type="str"),
"octopushPhoneNumber", octopushLogin=dict(type="str"),
"octopushSMSType", octopushPhoneNumber=dict(type="str"),
"octopushSenderName", octopushSMSType=dict(type="str"),
"octopushDMLogin", octopushSenderName=dict(type="str"),
"octopushDMAPIKey", octopushDMLogin=dict(type="str"),
"octopushDMPhoneNumber", octopushDMAPIKey=dict(type="str"),
"octopushDMSenderName", octopushDMPhoneNumber=dict(type="str"),
"octopushDMSMSType", octopushDMSenderName=dict(type="str"),
], octopushDMSMSType=dict(type="str"),
NotificationType.SERVERCHAN: [ ),
"serverChanSendKey", NotificationType.SERVERCHAN: dict(
], serverChanSendKey=dict(type="str"),
NotificationType.SMSMANAGER: [ ),
"smsmanagerApiKey", NotificationType.SMSMANAGER: dict(
"numbers", smsmanagerApiKey=dict(type="str"),
"messageType", numbers=dict(type="str"),
], messageType=dict(type="str"),
NotificationType.SQUADCAST: [ ),
"squadcastWebhookURL", NotificationType.SQUADCAST: dict(
], squadcastWebhookURL=dict(type="str"),
NotificationType.TEAMS: [ ),
"webhookUrl", NotificationType.TEAMS: dict(
], webhookUrl=dict(type="str"),
NotificationType.FREEMOBILE: [ ),
"freemobileUser", NotificationType.FREEMOBILE: dict(
"freemobilePass", freemobileUser=dict(type="str"),
], freemobilePass=dict(type="str"),
NotificationType.NTFY: [ ),
"ntfyusername", NotificationType.NTFY: dict(
"ntfypassword", ntfyusername=dict(type="str"),
"ntfytopic", ntfypassword=dict(type="str"),
"ntfyPriority", ntfytopic=dict(type="str"),
"ntfyserverurl", ntfyPriority=dict(type="int"),
], ntfyserverurl=dict(type="str"),
),
} }
notification_provider_conditions = { notification_provider_conditions = dict(
"gotifyPriority": { gotifyPriority=dict(
"min": 0, min=0,
"max": 10, max=10
}, ),
"smtpPort": { smtpPort=dict(
"min": 0, min=0,
"max": 65535, max=65535
}, ),
"ntfyPriority": { ntfyPriority=dict(
"min": 1, min=1,
"max": 5, max=5
}, ),
} )