Repository: AnalogJ/lexicon

Issue:
Plesk provider not working: invalid request (error code 1014)
The Plesk provider seems to be not working at all:

```
lexicon plesk --log_level DEBUG --auth-username apiuser --auth-password secret --plesk-server "https://plesk-api-host:8443" list mydomain.com A
```

leads to:

```
Arguments: Namespace(delegated=None, config_dir='/home/spike/ansible', provider_name='plesk', action='list', domain='mydomain.com', type='A', name=None, content=None, ttl=None, priority=None, identifier=None, log_level='DEBUG', output='TABLE', auth_username='apiuser', auth_password='secret', plesk_server='https://plesk-api-host:8443')
unable to cache publicsuffix.org-tlds.{'urls': ('https://publicsuffix.org/list/public_suffix_list.dat', 'https://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.dat'), 'fallback_to_snapshot': True} in /home/spike/.lexicon_tld_set/publicsuffix.org-tlds/de84b5ca2167d4c83e38fb162f2e8738.tldextract.json. This could refresh the Public Suffix List over HTTP every app startup. Construct your `TLDExtract` with a writable `cache_dir` or set `cache_dir=False` to silence this warning. [Errno 20] Not a directory: '/home/spike/.lexicon_tld_set/publicsuffix.org-tlds'
Starting new HTTPS connection (1): publicsuffix.org:443
https://publicsuffix.org:443 "GET /list/public_suffix_list.dat HTTP/1.1" 200 None
Request: <?xml version="1.0" encoding="utf-8"?>
<packet><site><get><filter><name>mydomain.com</name><dataset /></filter></get></site></packet>
Starting new HTTPS connection (1): plesk-api-host:8443
https://plesk-api-host:8443 "POST /enterprise/control/agent.php HTTP/1.1" 200 None
Response: <?xml version="1.0"?>
        <packet version="1.6.9.1">
                <system>
                        <status>error</status>
                        <errcode>1014</errcode>
                        <errtext>Parser error: Request is invalid. Error in line 2: Element 'dataset': This element is not expected. Expected is ( name ). Error in line 2: Element 'get': Missing child element(s). Expected is ( dataset ).</errtext>
                </system>       </packet>
Traceback (most recent call last):
  File "/home/spike/.local/bin/lexicon", line 8, in <module>
    sys.exit(main())
  File "/home/spike/.local/lib/python3.9/site-packages/lexicon/cli.py", line 131, in main
    results = client.execute()
  File "/home/spike/.local/lib/python3.9/site-packages/lexicon/client.py", line 79, in execute
    self.provider.authenticate()
  File "/home/spike/.local/lib/python3.9/site-packages/lexicon/providers/base.py", line 73, in authenticate
    self._authenticate()
  File "/home/spike/.local/lib/python3.9/site-packages/lexicon/providers/plesk.py", line 115, in _authenticate
    self.domain_id = self.__find_site()
  File "/home/spike/.local/lib/python3.9/site-packages/lexicon/providers/plesk.py", line 110, in __find_site
    return self.__simple_request(
  File "/home/spike/.local/lib/python3.9/site-packages/lexicon/providers/plesk.py", line 63, in __simple_request
    response = self.__plesk_request({rtype: {operation: req}})[rtype][operation]
KeyError: 'site'
```
Other actions are affected similarly as well.  
This seems to be because the request:
```
<?xml version="1.0" encoding="utf-8"?>
<packet><site><get><filter><name>mydomain.com</name><dataset /></filter></get></site></packet>
```
is not valid according to the api documentation: https://docs.plesk.com/en-US/obsidian/api-rpc/about-xml-api/reference/managing-sites-domains/getting-information-about-sites.66583/ (`dataset` is not a valid child of the `filter` node, it needs to be a child of the `get` node)


Discussion:

Resolving patch:
diff --git a/lexicon/providers/plesk.py b/lexicon/providers/plesk.py
--- a/lexicon/providers/plesk.py
+++ b/lexicon/providers/plesk.py
@@ -108,7 +108,7 @@ def __plesk_request(self, request):
 
     def __find_site(self):
         return self.__simple_request(
-            "site", "get", {"filter": {"name": self.domain, "dataset": {}}}
+            "site", "get", {"filter": {"name": self.domain}, "dataset": {}}
         )["result"]["id"]
 
     def _authenticate(self):


Test patch: