1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

uptimerobot.py: added missing api actions

This commit is contained in:
Leon Thiel 2023-11-02 09:35:02 +01:00
parent f1c9b56646
commit cd23d61e69
2 changed files with 21 additions and 5 deletions

View file

@ -0,0 +1,2 @@
major_changes:
- added all missing actions offered by the uptimerobot api (v2)

View file

@ -99,7 +99,7 @@ if __name__ == '__main__':
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
api_key=dict(type='str', required=True), api_key=dict(type='str', required=True, aliases=['apikey']),
action=dict( action=dict(
type='str', type='str',
required=True, required=True,
@ -121,20 +121,34 @@ if __name__ == '__main__':
'getPSPs', 'getPSPs',
'newPSP', 'newPSP',
'editPSP', 'editPSP',
'deletePSP' 'deletePSP',
] # for backwards compatibility
'started',
'paused'
],
aliases=['state']
), ),
params=dict(type='dict', required=False) params=dict(type='dict', required=False),
# for backwards compatibility
state=dict(type='str', required=False),
monitorid=dict(type='str', required=False)
), ),
supports_check_mode=SUPPORTS_CHECK_MODE supports_check_mode=SUPPORTS_CHECK_MODE
) )
action = module.params['action'] # collect necessary information for the api call
params = module.params['params'] or dict() params = module.params['params'] or dict()
action = module.params['action']
params['api_key'] = module.params['api_key'] params['api_key'] = module.params['api_key']
params['format'] = API_FORMAT params['format'] = API_FORMAT
params['noJsonCallback'] = API_NOJSONCALLBACK params['noJsonCallback'] = API_NOJSONCALLBACK
# test for backwards compatibility
if module.params['action'] in ['started', 'paused']:
action = 'editMonitor'
params['status'] = 1 if module.params['action'] == 'started' else 0
params['id'] = module.params['monitorid']
try: try:
result = uptimerobot_api_call(action, params, module=module) result = uptimerobot_api_call(action, params, module=module)
module.exit_json(changed=True, result=result) module.exit_json(changed=True, result=result)