Repository: ansible-collections/community.general

Issue:
DNS MadeEasy unable to delete or update existing records
### Summary

When I try executing update or delete command I get 404 not found.  The only commands I can execute are insert a new record (i.e. POST on dnsmadeeasy  api).  Example
```
...
community.general.dnsmadeeasy: account_key="xxxxxxxxxxxxxxxx" account_secret="xxxxxxxxxxxxxxx" domain={{item.domain}} state=absent record_type={{item.type}} record_name={{item.name}} record_value={{item.value}} protocol=HTTPS port=443 validate_certs=False
  with_items: "{{dns_records}}"
...
failed: [web3n3-la.siptalk.com] (item={'name': 'web3n3-la', 'type': 'A', 'domain': 'siptalk.com', 'value': '10.0.74.1'}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "invocation": {
        "module_args": {
            "account_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "account_secret": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "autoFailover": false,
            "contactList": null,
            "domain": "siptalk.com",
            "failover": false,
            "httpFile": null,
            "httpFqdn": null,
            "httpQueryString": null,
            "ip1": null,
            "ip2": null,
            "ip3": null,
            "ip4": null,
            "ip5": null,
            "maxEmails": 1,
            "monitor": false,
            "port": 443,
            "protocol": "HTTPS",
            "record_name": "web3n3-la",
            "record_ttl": 1800,
            "record_type": "A",
            "record_value": "10.0.74.1",
            "sandbox": false,
            "sensitivity": "Medium",
            "state": "absent",
            "systemDescription": "",
            "validate_certs": false
        }
    },
    "item": {
        "domain": "siptalk.com",
        "name": "web3n3-la",
        "type": "A",
        "value": "10.0.74.1"
    }
}

MSG:

https://api.dnsmadeeasy.com/V2.0/monitor/158157264 returned 404, with body: HTTP Error 404: Not Found

PLAY RECAP *************************************************************************************************************************************************************************************************************
web3n3-la.siptalk.com      : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
```
Needless to say the records are present and I can manually edit / remove them via web console.

### Issue Type

Bug Report

### Component Name

dnsmadeeasy

### Ansible Version

```console (paste below)
$ ansible --version
ansible 2.10.8
  config file = /home/alexl/IdeaProjects/ansible/ansible.cfg
  configured module search path = ['/home/alexl/IdeaProjects/ansible/library']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
```


### Community.general Version

```console (paste below)
$ ansible-galaxy collection list community.general
[DEPRECATION WARNING]: DEFAULT_HASH_BEHAVIOUR option, this feature is fragile and not portable, leading to continual confusion and misuse, use the ``combine`` filter explicitly instead. This feature will be removed 
from ansible-base in version 2.13. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

# /usr/lib/python3/dist-packages/ansible_collections
Collection        Version
----------------- -------
community.general 1.3.6  

# /home/alexl/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 3.8.0  

```


### Configuration

```console (paste below)
$ ansible-config dump --only-changed
[DEPRECATION WARNING]: DEFAULT_HASH_BEHAVIOUR option, this feature is fragile and not portable, leading to continual confusion and misuse, use the ``combine`` filter explicitly instead. This feature will be removed 
from ansible-base in version 2.13. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
ANSIBLE_FORCE_COLOR(/home/alexl/IdeaProjects/ansible/ansible.cfg) = True
CACHE_PLUGIN(/home/alexl/IdeaProjects/ansible/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(env: ANSIBLE_CACHE_PLUGIN_CONNECTION) = ~/.ansible-cache
CACHE_PLUGIN_TIMEOUT(/home/alexl/IdeaProjects/ansible/ansible.cfg) = 86400
DEFAULT_GATHERING(/home/alexl/IdeaProjects/ansible/ansible.cfg) = smart
DEFAULT_HASH_BEHAVIOUR(/home/alexl/IdeaProjects/ansible/ansible.cfg) = merge
DEFAULT_HOST_LIST(env: ANSIBLE_INVENTORY) = ['/home/alexl/IdeaProjects/ansible/inventory']
DEFAULT_MODULE_PATH(env: ANSIBLE_LIBRARY) = ['/home/alexl/IdeaProjects/ansible/library']
DEFAULT_REMOTE_USER(/home/alexl/IdeaProjects/ansible/ansible.cfg) = root
DEFAULT_ROLES_PATH(env: ANSIBLE_ROLES_PATH) = ['/etc/ansible/roles', '/home/alexl/IdeaProjects/ansible/roles']
DEFAULT_STDOUT_CALLBACK(/home/alexl/IdeaProjects/ansible/ansible.cfg) = debug

```


### OS / Environment

Ubuntu 21.10, Centos 7.9, Ubuntu 20.04

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)
community.general.dnsmadeeasy: account_key="xxxxxxxxxxxxxxxx" account_secret="xxxxxxxxxxxxxxx" domain={{item.domain}} state=absent record_type={{item.type}} record_name={{item.name}} record_value={{item.value}} protocol=HTTPS port=443 validate_certs=False
  with_items: "{{dns_records}}"
```


### Expected Results

I expected records removed but got errors instead.

### Actual Results

```console (paste below)
failed: [web3n3-la.siptalk.com] (item={'name': 'web3n3-la', 'type': 'A', 'domain': 'siptalk.com', 'value': '10.0.74.1'}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "invocation": {
        "module_args": {
            "account_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "account_secret": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "autoFailover": false,
            "contactList": null,
            "domain": "siptalk.com",
            "failover": false,
            "httpFile": null,
            "httpFqdn": null,
            "httpQueryString": null,
            "ip1": null,
            "ip2": null,
            "ip3": null,
            "ip4": null,
            "ip5": null,
            "maxEmails": 1,
            "monitor": false,
            "port": 443,
            "protocol": "HTTPS",
            "record_name": "web3n3-la",
            "record_ttl": 1800,
            "record_type": "A",
            "record_value": "10.0.74.1",
            "sandbox": false,
            "sensitivity": "Medium",
            "state": "absent",
            "systemDescription": "",
            "validate_certs": false
        }
    },
    "item": {
        "domain": "siptalk.com",
        "name": "web3n3-la",
        "type": "A",
        "value": "10.0.74.1"
    }
}

MSG:

https://api.dnsmadeeasy.com/V2.0/monitor/158157264 returned 404, with body: HTTP Error 404: Not Found

PLAY RECAP *************************************************************************************************************************************************************************************************************
web3n3-la.siptalk.com      : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/net_tools/dnsmadeeasy.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/net_tools/dnsmadeeasy.py)

If these files are incorrect, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @briceburg
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/plugins/modules/net_tools/dnsmadeeasy.py b/plugins/modules/net_tools/dnsmadeeasy.py
--- a/plugins/modules/net_tools/dnsmadeeasy.py
+++ b/plugins/modules/net_tools/dnsmadeeasy.py
@@ -623,7 +623,7 @@ def main():
     # Fetch existing monitor if the A record indicates it should exist and build the new monitor
     current_monitor = dict()
     new_monitor = dict()
-    if current_record and current_record['type'] == 'A':
+    if current_record and current_record['type'] == 'A' and current_record.get('monitor'):
         current_monitor = DME.getMonitor(current_record['id'])
 
     # Build the new monitor


Test patch: