(defclass uri ()
((scheme :initarg :scheme :accessor scheme :initform nil)
(userinfo :initarg :userinfo :accessor userinfo :initform nil)
(host :initarg :host :accessor host :initform nil)
(port :initarg :port :accessor port :initform nil)
(path :initarg :path :accessor path :initform nil)
(query :initarg :query :accessor query :initform nil)
(fragment :initarg :fragment :accessor fragment :initform nil)))
(defparameter *plesk-xml-uri-defaults*
(make-instance 'uri
:scheme "https"
:port "8443"
:path "enterprise/control/agent.php"))
(defmethod uri->string ((uri uri) &rest uri-keys)
"https://en.wikipedia.org/wiki/Uniform_Resource_Identifier"
(let* ((scheme (or (getf uri-keys :scheme) (scheme uri)))
(userinfo (or (getf uri-keys :userinfo) (userinfo uri)))
(host (or (getf uri-keys :host) (host uri)))
(port (or (getf uri-keys :port) (port uri)))
(path (or (getf uri-keys :path) (path uri)))
(query (or (getf uri-keys :query) (query uri)))
(fragment (or (getf uri-keys :fragment) (fragment uri)))
(authority (concatenate 'string
userinfo
(when userinfo
"@")
host
(when port
":")
port)))
(concatenate 'string
scheme
":"
(when authority
"//")
authority
(when path
"/")
path
(when query
"?")
query
(when fragment
"#")
fragment)))
(defun get-all-dns-plesk (server-name servers-config)
(let ((server-config (gethash server-name servers-config)))
(when server-config
(with-accessors ((ip ip) (api-key api-key)) server-config
(drakma:http-request (uri->string *plesk-xml-uri-defaults* :host ip)
:method :post
:additional-headers (list (cons "KEY" api-key))
:content *get-all-dns-plesk-xml-packet*)))))