We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Can't use lexicon with pending Cloudflare domains
I cannot use Lexicon with a domain that is `pending` (not `active`) in Cloudflare. It's useful to to be able to manipulate DNS records for `pending` domains before changing nameservers to minimize disruption.

## Context

1. Add a domain (e.g., `example.com`) in Cloudflare.
2. Do not change the nameservers for `example.com` to point to Cloudflare so that it remains with a `pending` status.
3. Add an API token in Cloudflare with Zone.DNS Edit and Zone.Zone Read permissions.

## Example

```sh
$ lexicon --version
lexicon 3.12.0
$ lexicon cloudflare --auth-token abc...XYZ list example.com A
Traceback (most recent call last):
  File "/home/user/.local/bin/lexicon", line 8, in <module>
    sys.exit(main())
  File "/home/user/.local/pipx/venvs/dns-lexicon/lib/python3.9/site-packages/lexicon/cli.py", line 132, in main
    results = client.execute()
  File "/home/user/.local/pipx/venvs/dns-lexicon/lib/python3.9/site-packages/lexicon/client.py", line 81, in execute
    self.provider.authenticate()
  File "/home/user/.local/pipx/venvs/dns-lexicon/lib/python3.9/site-packages/lexicon/providers/base.py", line 73, in authenticate
    self._authenticate()
  File "/home/user/.local/pipx/venvs/dns-lexicon/lib/python3.9/site-packages/lexicon/providers/cloudflare.py", line 51, in _authenticate
    raise AuthenticationError("No domain found")
lexicon.exceptions.AuthenticationError: No domain found
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lexicon/providers/cloudflare.py`
Content:
```
1 """Module provider for Cloudflare"""
2 import json
3 import logging
4 
5 import requests
6 
7 from lexicon.exceptions import AuthenticationError
8 from lexicon.providers.base import Provider as BaseProvider
9 
10 LOGGER = logging.getLogger(__name__)
11 
12 NAMESERVER_DOMAINS = ["cloudflare.com"]
13 
14 
15 def provider_parser(subparser):
16     """Return the parser for this provider"""
17     subparser.description = """
18         There are two ways to provide an authentication granting edition to the target CloudFlare DNS zone.
19         1 - A Global API key, with --auth-username and --auth-token flags.
20         2 - An unscoped API token (permissions Zone:Zone(read) + Zone:DNS(edit) for all zones), with --auth-token flag.
21         3 - A scoped API token (permissions Zone:Zone(read) + Zone:DNS(edit) for one zone), with --auth-token and --zone-id flags.
22     """
23     subparser.add_argument(
24         "--auth-username",
25         help="specify email address for authentication (for Global API key only)",
26     )
27     subparser.add_argument(
28         "--auth-token",
29         help="specify token for authentication (Global API key or API token)",
30     )
31     subparser.add_argument(
32         "--zone-id",
33         help="specify the zone id (if set, API token can be scoped to the target zone)",
34     )
35 
36 
37 class Provider(BaseProvider):
38     """Provider class for Cloudflare"""
39 
40     def __init__(self, config):
41         super(Provider, self).__init__(config)
42         self.domain_id = None
43         self.api_endpoint = "https://api.cloudflare.com/client/v4"
44 
45     def _authenticate(self):
46         zone_id = self._get_provider_option("zone_id")
47         if not zone_id:
48             payload = self._get("/zones", {"name": self.domain, "status": "active"})
49 
50             if not payload["result"]:
51                 raise AuthenticationError("No domain found")
52             if len(payload["result"]) > 1:
53                 raise AuthenticationError(
54                     "Too many domains found. This should not happen"
55                 )
56 
57             self.domain_id = payload["result"][0]["id"]
58         else:
59             payload = self._get(f"/zones/{zone_id}")
60 
61             if not payload["result"]:
62                 raise AuthenticationError(f"No domain found for Zone ID {zone_id}")
63 
64             self.domain_id = zone_id
65 
66     # Create record. If record already exists with the same content, do nothing'
67     def _create_record(self, rtype, name, content):
68         content, cf_data = self._format_content(rtype, content)
69         data = {
70             "type": rtype,
71             "name": self._full_name(name),
72             "content": content,
73             "data": cf_data,
74         }
75         if self._get_lexicon_option("ttl"):
76             data["ttl"] = self._get_lexicon_option("ttl")
77 
78         payload = {"success": True}
79         try:
80             payload = self._post(f"/zones/{self.domain_id}/dns_records", data)
81         except requests.exceptions.HTTPError as err:
82             already_exists = next(
83                 (
84                     True
85                     for error in err.response.json()["errors"]
86                     if error["code"] == 81057
87                 ),
88                 False,
89             )
90             if not already_exists:
91                 raise
92 
93         LOGGER.debug("create_record: %s", payload["success"])
94         return payload["success"]
95 
96     # List all records. Return an empty list if no records found
97     # type, name and content are used to filter records.
98     # If possible filter during the query, otherwise filter after response is received.
99     def _list_records(self, rtype=None, name=None, content=None):
100         filter_obj = {"per_page": 100}
101         if rtype:
102             filter_obj["type"] = rtype
103         if name:
104             filter_obj["name"] = self._full_name(name)
105         if content:
106             filter_obj["content"] = content
107 
108         records = []
109         while True:
110             payload = self._get(f"/zones/{self.domain_id}/dns_records", filter_obj)
111 
112             LOGGER.debug("payload: %s", payload)
113 
114             for record in payload["result"]:
115                 processed_record = {
116                     "type": record["type"],
117                     "name": record["name"],
118                     "ttl": record["ttl"],
119                     "content": record["content"],
120                     "id": record["id"],
121                 }
122                 records.append(processed_record)
123 
124             pages = payload["result_info"]["total_pages"]
125             page = payload["result_info"]["page"]
126             if page >= pages:
127                 break
128             filter_obj["page"] = page + 1
129 
130         LOGGER.debug("list_records: %s", records)
131         LOGGER.debug("Number of records retrieved: %d", len(records))
132         return records
133 
134     # Create or update a record.
135     def _update_record(self, identifier, rtype=None, name=None, content=None):
136         if identifier is None:
137             records = self._list_records(rtype, name)
138             if len(records) == 1:
139                 identifier = records[0]["id"]
140             elif len(records) < 1:
141                 raise Exception(
142                     "No records found matching type and name - won't update"
143                 )
144             else:
145                 raise Exception(
146                     "Multiple records found matching type and name - won't update"
147                 )
148 
149         data = {}
150         if rtype:
151             data["type"] = rtype
152         if name:
153             data["name"] = self._full_name(name)
154         if content:
155             data["content"] = content
156         if self._get_lexicon_option("ttl"):
157             data["ttl"] = self._get_lexicon_option("ttl")
158 
159         payload = self._put(f"/zones/{self.domain_id}/dns_records/{identifier}", data)
160 
161         LOGGER.debug("update_record: %s", payload["success"])
162         return payload["success"]
163 
164     # Delete an existing record.
165     # If record does not exist, do nothing.
166     def _delete_record(self, identifier=None, rtype=None, name=None, content=None):
167         delete_record_id = []
168         if not identifier:
169             records = self._list_records(rtype, name, content)
170             delete_record_id = [record["id"] for record in records]
171         else:
172             delete_record_id.append(identifier)
173 
174         LOGGER.debug("delete_records: %s", delete_record_id)
175 
176         for record_id in delete_record_id:
177             self._delete(f"/zones/{self.domain_id}/dns_records/{record_id}")
178 
179         LOGGER.debug("delete_record: %s", True)
180         return True
181 
182     # Helpers
183     def _request(self, action="GET", url="/", data=None, query_params=None):
184         if data is None:
185             data = {}
186         if query_params is None:
187             query_params = {}
188         headers = {"Content-Type": "application/json"}
189         if self._get_provider_option("auth_username"):
190             headers["X-Auth-Email"] = self._get_provider_option("auth_username")
191             headers["X-Auth-Key"] = self._get_provider_option("auth_token")
192         else:
193             headers[
194                 "Authorization"
195             ] = f"Bearer {self._get_provider_option('auth_token')}"
196         response = requests.request(
197             action,
198             self.api_endpoint + url,
199             params=query_params,
200             data=json.dumps(data),
201             headers=headers,
202         )
203         # if the request fails for any reason, throw an error.
204         response.raise_for_status()
205         return response.json()
206 
207     def _format_content(self, rtype, content):
208         """
209         Special case handling from some record types that Cloudflare needs
210         formatted differently
211 
212         Returns new values for the content and data properties to be sent
213         on the request
214         """
215         data = None
216         if rtype == "SSHFP":
217             # For some reason the CloudFlare API does not let you set content
218             # directly when creating an SSHFP record. You need to pass the
219             # fields that make up the record seperately, then the API joins
220             # them back together
221             _fp = content.split(" ")
222             data = {"algorithm": _fp[0], "type": _fp[1], "fingerprint": _fp[2]}
223             content = None
224 
225         return content, data
226
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/lexicon/providers/cloudflare.py b/lexicon/providers/cloudflare.py
--- a/lexicon/providers/cloudflare.py
+++ b/lexicon/providers/cloudflare.py
@@ -45,7 +45,7 @@
     def _authenticate(self):
         zone_id = self._get_provider_option("zone_id")
         if not zone_id:
-            payload = self._get("/zones", {"name": self.domain, "status": "active"})
+            payload = self._get("/zones", {"name": self.domain})
 
             if not payload["result"]:
                 raise AuthenticationError("No domain found")

{"golden_diff": "diff --git a/lexicon/providers/cloudflare.py b/lexicon/providers/cloudflare.py\n--- a/lexicon/providers/cloudflare.py\n+++ b/lexicon/providers/cloudflare.py\n@@ -45,7 +45,7 @@\n     def _authenticate(self):\n         zone_id = self._get_provider_option(\"zone_id\")\n         if not zone_id:\n-            payload = self._get(\"/zones\", {\"name\": self.domain, \"status\": \"active\"})\n+            payload = self._get(\"/zones\", {\"name\": self.domain})\n \n             if not payload[\"result\"]:\n                 raise AuthenticationError(\"No domain found\")\n", "issue": "Can't use lexicon with pending Cloudflare domains\nI cannot use Lexicon with a domain that is `pending` (not `active`) in Cloudflare. It's useful to to be able to manipulate DNS records for `pending` domains before changing nameservers to minimize disruption.\r\n\r\n## Context\r\n\r\n1. Add a domain (e.g., `example.com`) in Cloudflare.\r\n2. Do not change the nameservers for `example.com` to point to Cloudflare so that it remains with a `pending` status.\r\n3. Add an API token in Cloudflare with Zone.DNS Edit and Zone.Zone Read permissions.\r\n\r\n## Example\r\n\r\n```sh\r\n$ lexicon --version\r\nlexicon 3.12.0\r\n$ lexicon cloudflare --auth-token abc...XYZ list example.com A\r\nTraceback (most recent call last):\r\n  File \"/home/user/.local/bin/lexicon\", line 8, in <module>\r\n    sys.exit(main())\r\n  File \"/home/user/.local/pipx/venvs/dns-lexicon/lib/python3.9/site-packages/lexicon/cli.py\", line 132, in main\r\n    results = client.execute()\r\n  File \"/home/user/.local/pipx/venvs/dns-lexicon/lib/python3.9/site-packages/lexicon/client.py\", line 81, in execute\r\n    self.provider.authenticate()\r\n  File \"/home/user/.local/pipx/venvs/dns-lexicon/lib/python3.9/site-packages/lexicon/providers/base.py\", line 73, in authenticate\r\n    self._authenticate()\r\n  File \"/home/user/.local/pipx/venvs/dns-lexicon/lib/python3.9/site-packages/lexicon/providers/cloudflare.py\", line 51, in _authenticate\r\n    raise AuthenticationError(\"No domain found\")\r\nlexicon.exceptions.AuthenticationError: No domain found\r\n```\n", "before_files": [{"content": "\"\"\"Module provider for Cloudflare\"\"\"\nimport json\nimport logging\n\nimport requests\n\nfrom lexicon.exceptions import AuthenticationError\nfrom lexicon.providers.base import Provider as BaseProvider\n\nLOGGER = logging.getLogger(__name__)\n\nNAMESERVER_DOMAINS = [\"cloudflare.com\"]\n\n\ndef provider_parser(subparser):\n    \"\"\"Return the parser for this provider\"\"\"\n    subparser.description = \"\"\"\n        There are two ways to provide an authentication granting edition to the target CloudFlare DNS zone.\n        1 - A Global API key, with --auth-username and --auth-token flags.\n        2 - An unscoped API token (permissions Zone:Zone(read) + Zone:DNS(edit) for all zones), with --auth-token flag.\n        3 - A scoped API token (permissions Zone:Zone(read) + Zone:DNS(edit) for one zone), with --auth-token and --zone-id flags.\n    \"\"\"\n    subparser.add_argument(\n        \"--auth-username\",\n        help=\"specify email address for authentication (for Global API key only)\",\n    )\n    subparser.add_argument(\n        \"--auth-token\",\n        help=\"specify token for authentication (Global API key or API token)\",\n    )\n    subparser.add_argument(\n        \"--zone-id\",\n        help=\"specify the zone id (if set, API token can be scoped to the target zone)\",\n    )\n\n\nclass Provider(BaseProvider):\n    \"\"\"Provider class for Cloudflare\"\"\"\n\n    def __init__(self, config):\n        super(Provider, self).__init__(config)\n        self.domain_id = None\n        self.api_endpoint = \"https://api.cloudflare.com/client/v4\"\n\n    def _authenticate(self):\n        zone_id = self._get_provider_option(\"zone_id\")\n        if not zone_id:\n            payload = self._get(\"/zones\", {\"name\": self.domain, \"status\": \"active\"})\n\n            if not payload[\"result\"]:\n                raise AuthenticationError(\"No domain found\")\n            if len(payload[\"result\"]) > 1:\n                raise AuthenticationError(\n                    \"Too many domains found. This should not happen\"\n                )\n\n            self.domain_id = payload[\"result\"][0][\"id\"]\n        else:\n            payload = self._get(f\"/zones/{zone_id}\")\n\n            if not payload[\"result\"]:\n                raise AuthenticationError(f\"No domain found for Zone ID {zone_id}\")\n\n            self.domain_id = zone_id\n\n    # Create record. If record already exists with the same content, do nothing'\n    def _create_record(self, rtype, name, content):\n        content, cf_data = self._format_content(rtype, content)\n        data = {\n            \"type\": rtype,\n            \"name\": self._full_name(name),\n            \"content\": content,\n            \"data\": cf_data,\n        }\n        if self._get_lexicon_option(\"ttl\"):\n            data[\"ttl\"] = self._get_lexicon_option(\"ttl\")\n\n        payload = {\"success\": True}\n        try:\n            payload = self._post(f\"/zones/{self.domain_id}/dns_records\", data)\n        except requests.exceptions.HTTPError as err:\n            already_exists = next(\n                (\n                    True\n                    for error in err.response.json()[\"errors\"]\n                    if error[\"code\"] == 81057\n                ),\n                False,\n            )\n            if not already_exists:\n                raise\n\n        LOGGER.debug(\"create_record: %s\", payload[\"success\"])\n        return payload[\"success\"]\n\n    # List all records. Return an empty list if no records found\n    # type, name and content are used to filter records.\n    # If possible filter during the query, otherwise filter after response is received.\n    def _list_records(self, rtype=None, name=None, content=None):\n        filter_obj = {\"per_page\": 100}\n        if rtype:\n            filter_obj[\"type\"] = rtype\n        if name:\n            filter_obj[\"name\"] = self._full_name(name)\n        if content:\n            filter_obj[\"content\"] = content\n\n        records = []\n        while True:\n            payload = self._get(f\"/zones/{self.domain_id}/dns_records\", filter_obj)\n\n            LOGGER.debug(\"payload: %s\", payload)\n\n            for record in payload[\"result\"]:\n                processed_record = {\n                    \"type\": record[\"type\"],\n                    \"name\": record[\"name\"],\n                    \"ttl\": record[\"ttl\"],\n                    \"content\": record[\"content\"],\n                    \"id\": record[\"id\"],\n                }\n                records.append(processed_record)\n\n            pages = payload[\"result_info\"][\"total_pages\"]\n            page = payload[\"result_info\"][\"page\"]\n            if page >= pages:\n                break\n            filter_obj[\"page\"] = page + 1\n\n        LOGGER.debug(\"list_records: %s\", records)\n        LOGGER.debug(\"Number of records retrieved: %d\", len(records))\n        return records\n\n    # Create or update a record.\n    def _update_record(self, identifier, rtype=None, name=None, content=None):\n        if identifier is None:\n            records = self._list_records(rtype, name)\n            if len(records) == 1:\n                identifier = records[0][\"id\"]\n            elif len(records) < 1:\n                raise Exception(\n                    \"No records found matching type and name - won't update\"\n                )\n            else:\n                raise Exception(\n                    \"Multiple records found matching type and name - won't update\"\n                )\n\n        data = {}\n        if rtype:\n            data[\"type\"] = rtype\n        if name:\n            data[\"name\"] = self._full_name(name)\n        if content:\n            data[\"content\"] = content\n        if self._get_lexicon_option(\"ttl\"):\n            data[\"ttl\"] = self._get_lexicon_option(\"ttl\")\n\n        payload = self._put(f\"/zones/{self.domain_id}/dns_records/{identifier}\", data)\n\n        LOGGER.debug(\"update_record: %s\", payload[\"success\"])\n        return payload[\"success\"]\n\n    # Delete an existing record.\n    # If record does not exist, do nothing.\n    def _delete_record(self, identifier=None, rtype=None, name=None, content=None):\n        delete_record_id = []\n        if not identifier:\n            records = self._list_records(rtype, name, content)\n            delete_record_id = [record[\"id\"] for record in records]\n        else:\n            delete_record_id.append(identifier)\n\n        LOGGER.debug(\"delete_records: %s\", delete_record_id)\n\n        for record_id in delete_record_id:\n            self._delete(f\"/zones/{self.domain_id}/dns_records/{record_id}\")\n\n        LOGGER.debug(\"delete_record: %s\", True)\n        return True\n\n    # Helpers\n    def _request(self, action=\"GET\", url=\"/\", data=None, query_params=None):\n        if data is None:\n            data = {}\n        if query_params is None:\n            query_params = {}\n        headers = {\"Content-Type\": \"application/json\"}\n        if self._get_provider_option(\"auth_username\"):\n            headers[\"X-Auth-Email\"] = self._get_provider_option(\"auth_username\")\n            headers[\"X-Auth-Key\"] = self._get_provider_option(\"auth_token\")\n        else:\n            headers[\n                \"Authorization\"\n            ] = f\"Bearer {self._get_provider_option('auth_token')}\"\n        response = requests.request(\n            action,\n            self.api_endpoint + url,\n            params=query_params,\n            data=json.dumps(data),\n            headers=headers,\n        )\n        # if the request fails for any reason, throw an error.\n        response.raise_for_status()\n        return response.json()\n\n    def _format_content(self, rtype, content):\n        \"\"\"\n        Special case handling from some record types that Cloudflare needs\n        formatted differently\n\n        Returns new values for the content and data properties to be sent\n        on the request\n        \"\"\"\n        data = None\n        if rtype == \"SSHFP\":\n            # For some reason the CloudFlare API does not let you set content\n            # directly when creating an SSHFP record. You need to pass the\n            # fields that make up the record seperately, then the API joins\n            # them back together\n            _fp = content.split(\" \")\n            data = {\"algorithm\": _fp[0], \"type\": _fp[1], \"fingerprint\": _fp[2]}\n            content = None\n\n        return content, data\n", "path": "lexicon/providers/cloudflare.py"}], "after_files": [{"content": "\"\"\"Module provider for Cloudflare\"\"\"\nimport json\nimport logging\n\nimport requests\n\nfrom lexicon.exceptions import AuthenticationError\nfrom lexicon.providers.base import Provider as BaseProvider\n\nLOGGER = logging.getLogger(__name__)\n\nNAMESERVER_DOMAINS = [\"cloudflare.com\"]\n\n\ndef provider_parser(subparser):\n    \"\"\"Return the parser for this provider\"\"\"\n    subparser.description = \"\"\"\n        There are two ways to provide an authentication granting edition to the target CloudFlare DNS zone.\n        1 - A Global API key, with --auth-username and --auth-token flags.\n        2 - An unscoped API token (permissions Zone:Zone(read) + Zone:DNS(edit) for all zones), with --auth-token flag.\n        3 - A scoped API token (permissions Zone:Zone(read) + Zone:DNS(edit) for one zone), with --auth-token and --zone-id flags.\n    \"\"\"\n    subparser.add_argument(\n        \"--auth-username\",\n        help=\"specify email address for authentication (for Global API key only)\",\n    )\n    subparser.add_argument(\n        \"--auth-token\",\n        help=\"specify token for authentication (Global API key or API token)\",\n    )\n    subparser.add_argument(\n        \"--zone-id\",\n        help=\"specify the zone id (if set, API token can be scoped to the target zone)\",\n    )\n\n\nclass Provider(BaseProvider):\n    \"\"\"Provider class for Cloudflare\"\"\"\n\n    def __init__(self, config):\n        super(Provider, self).__init__(config)\n        self.domain_id = None\n        self.api_endpoint = \"https://api.cloudflare.com/client/v4\"\n\n    def _authenticate(self):\n        zone_id = self._get_provider_option(\"zone_id\")\n        if not zone_id:\n            payload = self._get(\"/zones\", {\"name\": self.domain})\n\n            if not payload[\"result\"]:\n                raise AuthenticationError(\"No domain found\")\n            if len(payload[\"result\"]) > 1:\n                raise AuthenticationError(\n                    \"Too many domains found. This should not happen\"\n                )\n\n            self.domain_id = payload[\"result\"][0][\"id\"]\n        else:\n            payload = self._get(f\"/zones/{zone_id}\")\n\n            if not payload[\"result\"]:\n                raise AuthenticationError(f\"No domain found for Zone ID {zone_id}\")\n\n            self.domain_id = zone_id\n\n    # Create record. If record already exists with the same content, do nothing'\n    def _create_record(self, rtype, name, content):\n        content, cf_data = self._format_content(rtype, content)\n        data = {\n            \"type\": rtype,\n            \"name\": self._full_name(name),\n            \"content\": content,\n            \"data\": cf_data,\n        }\n        if self._get_lexicon_option(\"ttl\"):\n            data[\"ttl\"] = self._get_lexicon_option(\"ttl\")\n\n        payload = {\"success\": True}\n        try:\n            payload = self._post(f\"/zones/{self.domain_id}/dns_records\", data)\n        except requests.exceptions.HTTPError as err:\n            already_exists = next(\n                (\n                    True\n                    for error in err.response.json()[\"errors\"]\n                    if error[\"code\"] == 81057\n                ),\n                False,\n            )\n            if not already_exists:\n                raise\n\n        LOGGER.debug(\"create_record: %s\", payload[\"success\"])\n        return payload[\"success\"]\n\n    # List all records. Return an empty list if no records found\n    # type, name and content are used to filter records.\n    # If possible filter during the query, otherwise filter after response is received.\n    def _list_records(self, rtype=None, name=None, content=None):\n        filter_obj = {\"per_page\": 100}\n        if rtype:\n            filter_obj[\"type\"] = rtype\n        if name:\n            filter_obj[\"name\"] = self._full_name(name)\n        if content:\n            filter_obj[\"content\"] = content\n\n        records = []\n        while True:\n            payload = self._get(f\"/zones/{self.domain_id}/dns_records\", filter_obj)\n\n            LOGGER.debug(\"payload: %s\", payload)\n\n            for record in payload[\"result\"]:\n                processed_record = {\n                    \"type\": record[\"type\"],\n                    \"name\": record[\"name\"],\n                    \"ttl\": record[\"ttl\"],\n                    \"content\": record[\"content\"],\n                    \"id\": record[\"id\"],\n                }\n                records.append(processed_record)\n\n            pages = payload[\"result_info\"][\"total_pages\"]\n            page = payload[\"result_info\"][\"page\"]\n            if page >= pages:\n                break\n            filter_obj[\"page\"] = page + 1\n\n        LOGGER.debug(\"list_records: %s\", records)\n        LOGGER.debug(\"Number of records retrieved: %d\", len(records))\n        return records\n\n    # Create or update a record.\n    def _update_record(self, identifier, rtype=None, name=None, content=None):\n        if identifier is None:\n            records = self._list_records(rtype, name)\n            if len(records) == 1:\n                identifier = records[0][\"id\"]\n            elif len(records) < 1:\n                raise Exception(\n                    \"No records found matching type and name - won't update\"\n                )\n            else:\n                raise Exception(\n                    \"Multiple records found matching type and name - won't update\"\n                )\n\n        data = {}\n        if rtype:\n            data[\"type\"] = rtype\n        if name:\n            data[\"name\"] = self._full_name(name)\n        if content:\n            data[\"content\"] = content\n        if self._get_lexicon_option(\"ttl\"):\n            data[\"ttl\"] = self._get_lexicon_option(\"ttl\")\n\n        payload = self._put(f\"/zones/{self.domain_id}/dns_records/{identifier}\", data)\n\n        LOGGER.debug(\"update_record: %s\", payload[\"success\"])\n        return payload[\"success\"]\n\n    # Delete an existing record.\n    # If record does not exist, do nothing.\n    def _delete_record(self, identifier=None, rtype=None, name=None, content=None):\n        delete_record_id = []\n        if not identifier:\n            records = self._list_records(rtype, name, content)\n            delete_record_id = [record[\"id\"] for record in records]\n        else:\n            delete_record_id.append(identifier)\n\n        LOGGER.debug(\"delete_records: %s\", delete_record_id)\n\n        for record_id in delete_record_id:\n            self._delete(f\"/zones/{self.domain_id}/dns_records/{record_id}\")\n\n        LOGGER.debug(\"delete_record: %s\", True)\n        return True\n\n    # Helpers\n    def _request(self, action=\"GET\", url=\"/\", data=None, query_params=None):\n        if data is None:\n            data = {}\n        if query_params is None:\n            query_params = {}\n        headers = {\"Content-Type\": \"application/json\"}\n        if self._get_provider_option(\"auth_username\"):\n            headers[\"X-Auth-Email\"] = self._get_provider_option(\"auth_username\")\n            headers[\"X-Auth-Key\"] = self._get_provider_option(\"auth_token\")\n        else:\n            headers[\n                \"Authorization\"\n            ] = f\"Bearer {self._get_provider_option('auth_token')}\"\n        response = requests.request(\n            action,\n            self.api_endpoint + url,\n            params=query_params,\n            data=json.dumps(data),\n            headers=headers,\n        )\n        # if the request fails for any reason, throw an error.\n        response.raise_for_status()\n        return response.json()\n\n    def _format_content(self, rtype, content):\n        \"\"\"\n        Special case handling from some record types that Cloudflare needs\n        formatted differently\n\n        Returns new values for the content and data properties to be sent\n        on the request\n        \"\"\"\n        data = None\n        if rtype == \"SSHFP\":\n            # For some reason the CloudFlare API does not let you set content\n            # directly when creating an SSHFP record. You need to pass the\n            # fields that make up the record seperately, then the API joins\n            # them back together\n            _fp = content.split(\" \")\n            data = {\"algorithm\": _fp[0], \"type\": _fp[1], \"fingerprint\": _fp[2]}\n            content = None\n\n        return content, data\n", "path": "lexicon/providers/cloudflare.py"}]}