diff --git a/collection/plugins/module_utils/syncthing_api.py b/collection/plugins/module_utils/syncthing_api.py index d4544d5..386395e 100644 --- a/collection/plugins/module_utils/syncthing_api.py +++ b/collection/plugins/module_utils/syncthing_api.py @@ -14,7 +14,7 @@ else: DEFAULT_ST_CONFIG_LOCATION = '$HOME/.local/state/syncthing/config.xml' -class SyncthingBase(AnsibleModule): +class SyncthingModule(AnsibleModule): def _make_headers(self, target=None): url = '{}{}{}{}'.format( self.params['host'], @@ -87,23 +87,24 @@ class SyncthingBase(AnsibleModule): return self._api_call(method='PATCH', data=data, target=target) def exit_json(self): - super().exit_json(**self.module.result) + super().exit_json(**self.result) def fail_json(self, msg=""): - super().fail_json(msg, **self.module.result) + super().fail_json(msg, **self.result) - def __init__(self, api_url='/', module_args=None, supports_check_mode=True): - module_args_temp = url_argument_spec() - module_args_temp.update(dict( + def __init__(self, api_url='/', argument_spec=None, supports_check_mode=True): + self.api_url = api_url + argument_spec_temp = url_argument_spec() + argument_spec_temp.update(dict( host=dict(type='str', default='http://127.0.0.1:8384'), unix_socket=dict(type='str', required=False), api_key=dict(type='str', required=False, no_log=True), config_file=dict(type='str', required=False), timeout=dict(type='int', default=30), )) - if module_args is None: - module_args = {} - module_args_temp.update(module_args) - super().__init__(module_args=module_args_temp, supports_check_mode=True) + if argument_spec is None: + argument_spec = {} + argument_spec_temp.update(argument_spec) + super().__init__(argument_spec=argument_spec_temp, supports_check_mode=True) # Auto-configuration: Try to fetch API key from filesystem if not self.params['api_key']: diff --git a/collection/plugins/modules/device.py b/collection/plugins/modules/device.py index 7db37df..1465732 100644 --- a/collection/plugins/modules/device.py +++ b/collection/plugins/modules/device.py @@ -78,8 +78,7 @@ response: type: dict ''' -from ansible.collections.syncthing.plugins.module_utils.syncthing_api \ - import SyncthingModule +from ansible_collections.community.syncthing.plugins.module_utils.syncthing_api import SyncthingModule # Returns an object of a new device def create_device(params):