From cf2c59eb65ad2aeb254e4bb646bd269d237d764d Mon Sep 17 00:00:00 2001 From: mahtin Date: Fri, 17 Jun 2016 10:07:32 -0700 Subject: [PATCH] Fixed some exceptions. Cleaned up more code. More pylint work. --- CloudFlare/api_extras.py | 6 +- CloudFlare/api_v4.py | 168 ++++++++++++++-------------- CloudFlare/cloudflare.py | 235 +++++++++++++++++---------------------- setup.cfg | 0 4 files changed, 192 insertions(+), 217 deletions(-) create mode 100644 setup.cfg diff --git a/CloudFlare/api_extras.py b/CloudFlare/api_extras.py index 36bd7a3..3e6ba5b 100644 --- a/CloudFlare/api_extras.py +++ b/CloudFlare/api_extras.py @@ -37,7 +37,7 @@ def api_extras(self, extras=None): api_call_part1 = '/'.join(element_path) api_call_part2 = '/'.join(parts[1]) setattr(m, parts[1][0], - self._client_with_auth(self.base, api_call_part1, api_call_part2)) + self.add_with_auth(self.base, api_call_part1, api_call_part2)) current = m continue except: @@ -48,10 +48,10 @@ def api_extras(self, extras=None): api_call_part1 = '/'.join(element_path) api_call_part2 = '/'.join(parts[1]) setattr(current, element, - self._client_with_auth(self.base, api_call_part1, api_call_part2)) + self.add_with_auth(self.base, api_call_part1, api_call_part2)) else: api_call_part1 = '/'.join(element_path) setattr(current, element, - self._client_with_auth(self.base, api_call_part1)) + self.add_with_auth(self.base, api_call_part1)) current = getattr(current, element) diff --git a/CloudFlare/api_v4.py b/CloudFlare/api_v4.py index 812b946..446f440 100644 --- a/CloudFlare/api_v4.py +++ b/CloudFlare/api_v4.py @@ -5,202 +5,202 @@ def api_v4(self): # The API commands for /user/ setattr(self, "user", - self._client_with_auth(self.base, "user")) + self.add_with_auth(self.base, "user")) user = getattr(self, "user") setattr(user, "billing", - self._unused(self.base, "user/billing")) + self.add_unused(self.base, "user/billing")) user_billing = getattr(user, "billing") setattr(user_billing, "history", - self._client_with_auth(self.base, "user/billing/history")) + self.add_with_auth(self.base, "user/billing/history")) setattr(user_billing, "profile", - self._client_with_auth(self.base, "user/billing/profile")) + self.add_with_auth(self.base, "user/billing/profile")) setattr(user_billing, "subscriptions", - self._unused(self.base, "user/billing/subscriptions")) + self.add_unused(self.base, "user/billing/subscriptions")) user_billing_subscriptions = getattr(user_billing, "subscriptions") setattr(user_billing_subscriptions, "apps", - self._client_with_auth(self.base, "user/billing/subscriptions/apps")) + self.add_with_auth(self.base, "user/billing/subscriptions/apps")) setattr(user_billing_subscriptions, "zones", - self._client_with_auth(self.base, "user/billing/subscriptions/zones")) + self.add_with_auth(self.base, "user/billing/subscriptions/zones")) setattr(user, "firewall", - self._unused(self.base, "user/firewall")) + self.add_unused(self.base, "user/firewall")) user_firewall = getattr(user, "firewall") setattr(user_firewall, "access_rules", - self._unused(self.base, "user/firewall/access_rules")) + self.add_unused(self.base, "user/firewall/access_rules")) user_firewall_access_rules = getattr(user_firewall, "access_rules") setattr(user_firewall_access_rules, "rules", - self._client_with_auth(self.base, "user/firewall/access_rules/rules")) + self.add_with_auth(self.base, "user/firewall/access_rules/rules")) setattr(user, "organizations", - self._client_with_auth(self.base, "user/organizations")) + self.add_with_auth(self.base, "user/organizations")) setattr(user, "invites", - self._client_with_auth(self.base, "user/invites")) + self.add_with_auth(self.base, "user/invites")) setattr(user, "virtual_dns", - self._client_with_auth(self.base, "user/virtual_dns")) + self.add_with_auth(self.base, "user/virtual_dns")) # The API commands for /zones/ setattr(self, "zones", - self._client_with_auth(self.base, "zones")) + self.add_with_auth(self.base, "zones")) zones = getattr(self, "zones") setattr(zones, "activation_check", - self._client_with_auth(self.base, "zones", "activation_check")) + self.add_with_auth(self.base, "zones", "activation_check")) setattr(zones, "available_plans", - self._client_with_auth(self.base, "zones", "available_plans")) + self.add_with_auth(self.base, "zones", "available_plans")) setattr(zones, "custom_certificates", - self._client_with_auth(self.base, "zones", "custom_certificates")) + self.add_with_auth(self.base, "zones", "custom_certificates")) zones_custom_certificates = getattr(zones, "custom_certificates") setattr(zones_custom_certificates, "prioritize", - self._client_with_auth(self.base, "zones", "custom_certificates/prioritize")) + self.add_with_auth(self.base, "zones", "custom_certificates/prioritize")) setattr(zones, "custom_pages", - self._client_with_auth(self.base, "zones", "custom_pages")) + self.add_with_auth(self.base, "zones", "custom_pages")) setattr(zones, "dns_records", - self._client_with_auth(self.base, "zones", "dns_records")) + self.add_with_auth(self.base, "zones", "dns_records")) setattr(zones, "keyless_certificates", - self._client_with_auth(self.base, "zones", "keyless_certificates")) + self.add_with_auth(self.base, "zones", "keyless_certificates")) setattr(zones, "pagerules", - self._client_with_auth(self.base, "zones", "pagerules")) + self.add_with_auth(self.base, "zones", "pagerules")) setattr(zones, "purge_cache", - self._client_with_auth(self.base, "zones", "purge_cache")) + self.add_with_auth(self.base, "zones", "purge_cache")) setattr(zones, "railguns", - self._client_with_auth(self.base, "zones", "railguns")) + self.add_with_auth(self.base, "zones", "railguns")) zones_railguns = getattr(zones, "railguns") setattr(zones_railguns, "diagnose", - self._client_with_auth(self.base, "zones", "railguns", "diagnose")) + self.add_with_auth(self.base, "zones", "railguns", "diagnose")) setattr(zones, "settings", - self._client_with_auth(self.base, "zones", "settings")) + self.add_with_auth(self.base, "zones", "settings")) zones_settings = getattr(zones, "settings") setattr(zones_settings, "advanced_ddos", - self._client_with_auth(self.base, "zones", "settings/advanced_ddos")) + self.add_with_auth(self.base, "zones", "settings/advanced_ddos")) setattr(zones_settings, "always_online", - self._client_with_auth(self.base, "zones", "settings/always_online")) + self.add_with_auth(self.base, "zones", "settings/always_online")) setattr(zones_settings, "browser_cache_ttl", - self._client_with_auth(self.base, "zones", "settings/browser_cache_ttl")) + self.add_with_auth(self.base, "zones", "settings/browser_cache_ttl")) setattr(zones_settings, "browser_check", - self._client_with_auth(self.base, "zones", "settings/browser_check")) + self.add_with_auth(self.base, "zones", "settings/browser_check")) setattr(zones_settings, "cache_level", - self._client_with_auth(self.base, "zones", "settings/cache_level")) + self.add_with_auth(self.base, "zones", "settings/cache_level")) setattr(zones_settings, "challenge_ttl", - self._client_with_auth(self.base, "zones", "settings/challenge_ttl")) + self.add_with_auth(self.base, "zones", "settings/challenge_ttl")) setattr(zones_settings, "development_mode", - self._client_with_auth(self.base, "zones", "settings/development_mode")) + self.add_with_auth(self.base, "zones", "settings/development_mode")) setattr(zones_settings, "email_obfuscation", - self._client_with_auth(self.base, "zones", "settings/email_obfuscation")) + self.add_with_auth(self.base, "zones", "settings/email_obfuscation")) setattr(zones_settings, "hotlink_protection", - self._client_with_auth(self.base, "zones", "settings/hotlink_protection")) + self.add_with_auth(self.base, "zones", "settings/hotlink_protection")) setattr(zones_settings, "ip_geolocation", - self._client_with_auth(self.base, "zones", "settings/ip_geolocation")) + self.add_with_auth(self.base, "zones", "settings/ip_geolocation")) setattr(zones_settings, "ipv6", - self._client_with_auth(self.base, "zones", "settings/ipv6")) + self.add_with_auth(self.base, "zones", "settings/ipv6")) setattr(zones_settings, "minify", - self._client_with_auth(self.base, "zones", "settings/minify")) + self.add_with_auth(self.base, "zones", "settings/minify")) setattr(zones_settings, "mirage", - self._client_with_auth(self.base, "zones", "settings/mirage")) + self.add_with_auth(self.base, "zones", "settings/mirage")) setattr(zones_settings, "mobile_redirect", - self._client_with_auth(self.base, "zones", "settings/mobile_redirect")) + self.add_with_auth(self.base, "zones", "settings/mobile_redirect")) setattr(zones_settings, "origin_error_page_pass_thru", - self._client_with_auth(self.base, "zones", "settings/origin_error_page_pass_thru")) + self.add_with_auth(self.base, "zones", "settings/origin_error_page_pass_thru")) setattr(zones_settings, "polish", - self._client_with_auth(self.base, "zones", "settings/polish")) + self.add_with_auth(self.base, "zones", "settings/polish")) setattr(zones_settings, "prefetch_preload", - self._client_with_auth(self.base, "zones", "settings/prefetch_preload")) + self.add_with_auth(self.base, "zones", "settings/prefetch_preload")) setattr(zones_settings, "response_buffering", - self._client_with_auth(self.base, "zones", "settings/response_buffering")) + self.add_with_auth(self.base, "zones", "settings/response_buffering")) setattr(zones_settings, "rocket_loader", - self._client_with_auth(self.base, "zones", "settings/rocket_loader")) + self.add_with_auth(self.base, "zones", "settings/rocket_loader")) setattr(zones_settings, "security_header", - self._client_with_auth(self.base, "zones", "settings/security_header")) + self.add_with_auth(self.base, "zones", "settings/security_header")) setattr(zones_settings, "security_level", - self._client_with_auth(self.base, "zones", "settings/security_level")) + self.add_with_auth(self.base, "zones", "settings/security_level")) setattr(zones_settings, "server_side_exclude", - self._client_with_auth(self.base, "zones", "settings/server_side_exclude")) + self.add_with_auth(self.base, "zones", "settings/server_side_exclude")) setattr(zones_settings, "sort_query_string_for_cache", - self._client_with_auth(self.base, "zones", "settings/sort_query_string_for_cache")) + self.add_with_auth(self.base, "zones", "settings/sort_query_string_for_cache")) setattr(zones_settings, "ssl", - self._client_with_auth(self.base, "zones", "settings/ssl")) + self.add_with_auth(self.base, "zones", "settings/ssl")) setattr(zones_settings, "tls_1_2_only", - self._client_with_auth(self.base, "zones", "settings/tls_1_2_only")) - setattr(zones_settings, "tls_client_auth", - self._client_with_auth(self.base, "zones", "settings/tls_client_auth")) - setattr(zones_settings, "true_client_ip_header", - self._client_with_auth(self.base, "zones", "settings/true_client_ip_header")) + self.add_with_auth(self.base, "zones", "settings/tls_1_2_only")) + setattr(zones_settings, "tlsadd_auth", + self.add_with_auth(self.base, "zones", "settings/tlsadd_auth")) + setattr(zones_settings, "trueadd_ip_header", + self.add_with_auth(self.base, "zones", "settings/trueadd_ip_header")) setattr(zones_settings, "waf", - self._client_with_auth(self.base, "zones", "settings/waf")) + self.add_with_auth(self.base, "zones", "settings/waf")) setattr(zones, "analytics", - self._unused(self.base, "zones", "analytics")) + self.add_unused(self.base, "zones", "analytics")) zones_analytics = getattr(zones, "analytics") setattr(zones_analytics, "colos", - self._client_with_auth(self.base, "zones", "analytics/colos")) + self.add_with_auth(self.base, "zones", "analytics/colos")) setattr(zones_analytics, "dashboard", - self._client_with_auth(self.base, "zones", "analytics/dashboard")) + self.add_with_auth(self.base, "zones", "analytics/dashboard")) setattr(zones, "firewall", - self._unused(self.base, "zones", "firewall")) + self.add_unused(self.base, "zones", "firewall")) zones_firewall = getattr(zones, "firewall") setattr(zones_firewall, "access_rules", - self._unused(self.base, "zones", "firewall/access_rules")) + self.add_unused(self.base, "zones", "firewall/access_rules")) setattr(zones_firewall, "waf", - self._unused(self.base, "zones", "firewall/waf")) + self.add_unused(self.base, "zones", "firewall/waf")) zones_firewall_waf = getattr(zones_firewall, "waf") setattr(zones_firewall_waf, "packages", - self._client_with_auth(self.base, "zones", "firewall/waf/packages")) + self.add_with_auth(self.base, "zones", "firewall/waf/packages")) zones_firewall_waf_packages = getattr(zones_firewall_waf, "packages") setattr(zones_firewall_waf_packages, "groups", - self._client_with_auth(self.base, "zones", "firewall/waf/packages", "groups")) + self.add_with_auth(self.base, "zones", "firewall/waf/packages", "groups")) setattr(zones_firewall_waf_packages, "rules", - self._client_with_auth(self.base, "zones", "firewall/waf/packages", "rules")) + self.add_with_auth(self.base, "zones", "firewall/waf/packages", "rules")) zones_firewall_access_rules = getattr(zones_firewall, "access_rules") setattr(zones_firewall_access_rules, "rules", - self._client_with_auth(self.base, "zones", "firewall/access_rules/rules")) + self.add_with_auth(self.base, "zones", "firewall/access_rules/rules")) # The API commands for /railguns/ setattr(self, "railguns", - self._client_with_auth(self.base, "railguns")) + self.add_with_auth(self.base, "railguns")) railguns = getattr(self, "railguns") setattr(railguns, "zones", - self._client_with_auth(self.base, "railguns", "zones")) + self.add_with_auth(self.base, "railguns", "zones")) # The API commands for /organizations/ setattr(self, "organizations", - self._client_with_auth(self.base, "organizations")) + self.add_with_auth(self.base, "organizations")) organizations = getattr(self, "organizations") setattr(organizations, "members", - self._client_with_auth(self.base, "organizations", "members")) + self.add_with_auth(self.base, "organizations", "members")) setattr(organizations, "invite", - self._client_with_auth(self.base, "organizations", "invite")) + self.add_with_auth(self.base, "organizations", "invite")) setattr(organizations, "invites", - self._client_with_auth(self.base, "organizations", "invites")) + self.add_with_auth(self.base, "organizations", "invites")) setattr(organizations, "railguns", - self._client_with_auth(self.base, "organizations", "railguns")) + self.add_with_auth(self.base, "organizations", "railguns")) organizations_railguns = getattr(organizations, "railguns") setattr(organizations_railguns, "zones", - self._client_with_auth(self.base, "organizations", "railguns", "zones")) + self.add_with_auth(self.base, "organizations", "railguns", "zones")) setattr(organizations, "roles", - self._client_with_auth(self.base, "organizations", "roles")) + self.add_with_auth(self.base, "organizations", "roles")) setattr(organizations, "firewall", - self._unused(self.base, "organizations", "firewall")) + self.add_unused(self.base, "organizations", "firewall")) organizations_firewall = getattr(organizations, "firewall") setattr(organizations_firewall, "access_rules", - self._unused(self.base, "organizations", "firewall/access_rules")) + self.add_unused(self.base, "organizations", "firewall/access_rules")) organizations_firewall_access_rules = getattr(organizations_firewall, "access_rules") setattr(organizations_firewall_access_rules, "rules", - self._client_with_auth(self.base, "organizations", "firewall/access_rules/rules")) + self.add_with_auth(self.base, "organizations", "firewall/access_rules/rules")) setattr(organizations, "virtual_dns", - self._client_with_auth(self.base, "organizations", "virtual_dns")) + self.add_with_auth(self.base, "organizations", "virtual_dns")) # The API commands for /certificates/ setattr(self, "certificates", - self._client_with_cert_auth(self.base, "certificates")) + self.add_with_cert_auth(self.base, "certificates")) # The API commands for /ips/ setattr(self, "ips", - self._client_noauth(self.base, "ips")) + self.add_noauth(self.base, "ips")) # The DNSSEC commands setattr(zones, "dnssec", - self._client_with_auth(self.base, "zones", "dnssec")) + self.add_with_auth(self.base, "zones", "dnssec")) # EXTRAS # /zones/:zone_id/ssl/certificate_packs setattr(zones, "ssl", - self._unused(self.base, "zones", "ssl")) + self.add_unused(self.base, "zones", "ssl")) zones_ssl = getattr(zones, "ssl") setattr(zones_ssl, "certificate_packs", - self._client_with_auth(self.base, "zones", "ssl/certificate_packs")) + self.add_with_auth(self.base, "zones", "ssl/certificate_packs")) diff --git a/CloudFlare/cloudflare.py b/CloudFlare/cloudflare.py index ab6e85d..2bad68c 100644 --- a/CloudFlare/cloudflare.py +++ b/CloudFlare/cloudflare.py @@ -32,12 +32,12 @@ def __init__(self, email, token, certtoken, base_url, debug): else: self.logger = None - def _call_with_no_auth(self, method, - api_call_part1, - api_call_part2=None, - api_call_part3=None, - identifier1=None, identifier2=None, - params=None, data=None): + def call_with_no_auth(self, method, + api_call_part1, + api_call_part2=None, + api_call_part3=None, + identifier1=None, identifier2=None, + params=None, data=None): """ CloudFlare v4 API""" headers = { @@ -48,12 +48,12 @@ def _call_with_no_auth(self, method, identifier1, identifier2, params, data) - def _call_with_auth(self, method, - api_call_part1, - api_call_part2=None, - api_call_part3=None, - identifier1=None, identifier2=None, - params=None, data=None): + def call_with_auth(self, method, + api_call_part1, + api_call_part2=None, + api_call_part3=None, + identifier1=None, identifier2=None, + params=None, data=None): """ CloudFlare v4 API""" if self.email is '' or self.token is '': @@ -68,12 +68,12 @@ def _call_with_auth(self, method, identifier1, identifier2, params, data) - def _call_with_certauth(self, method, - api_call_part1, - api_call_part2=None, - api_call_part3=None, - identifier1=None, identifier2=None, - params=None, data=None): + def call_with_certauth(self, method, + api_call_part1, + api_call_part2=None, + api_call_part3=None, + identifier1=None, identifier2=None, + params=None, data=None): """ CloudFlare v4 API""" if self.certtoken is '': @@ -90,9 +90,9 @@ def _call_with_certauth(self, method, def _call(self, method, headers, api_call_part1, api_call_part2=None, - api_call_part3=None, identifier1=None, - identifier2=None, params=None, - data=None): + api_call_part3=None, + identifier1=None, identifier2=None, + params=None, data=None): """ CloudFlare v4 API""" if api_call_part2 is not None or (data is not None and method == 'GET'): @@ -124,15 +124,14 @@ def _call(self, method, headers, str(api_call_part2), str(identifier2), str(api_call_part3))) - self.logger.debug("Call: optional params and data: %s %s" % (str(params), - str(data))) - self.logger.debug("Call: url is: %s" % (str(url))) - self.logger.debug("Call: method is: %s" % (str(method))) + self.logger.debug("Call: optional params and data %s %s" % (str(params), + str(data))) + self.logger.debug("Call: method and url %s %s" % (str(method, url))) self.logger.debug("Call: headers %s" % str(utils.sanitize_secrets(headers))) if (method is None) or (api_call_part1 is None): # should never happen - raise CloudFlareInternalError('You must specify a method and endpoint') + raise CloudFlareInternalError(0, 'You must specify a method and endpoint') method = method.upper() @@ -143,32 +142,20 @@ def _call(self, method, headers, elif method == 'PUT': response = requests.put(url, headers=headers, params=params, json=data) elif method == 'DELETE': - if data: - response = requests.delete(url, headers=headers, json=data) - else: - response = requests.delete(url, headers=headers) + response = requests.delete(url, headers=headers, json=data) elif method == 'PATCH': - if data: - response = requests.request('PATCH', - url, - headers=headers, - params=params, - json=data) - else: - response = requests.request('PATCH', - url, - headers=headers, - params=params) + response = requests.request('PATCH', url, + headers=headers, params=params, json=data) else: # should never happen raise CloudFlareAPIError(0, 'method not supported') if self.logger: - self.logger.debug("Response url: %s", response.url) + self.logger.debug("Response: url %s", response.url) response_data = response.text if self.logger: - self.logger.debug("Response_data: %s" % response_data) + self.logger.debug("Response: data %s" % response_data) try: response_data = json.loads(response_data) except ValueError: @@ -178,12 +165,15 @@ def _call(self, method, headers, code = response_data['errors'][0]['code'] message = response_data['errors'][0]['message'] if self.logger: - self.logger.debug("response_data error: %d %s" % (code, message)) + self.logger.debug("Response: error %d %s" % (code, message)) raise CloudFlareAPIError(code, message) - return response_data['result'] + result = response_data['result'] + if self.logger: + self.logger.debug("Response: %s" % (result)) + return result - class _unused(object): + class add_unused(object): """ CloudFlare v4 API""" def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=None): @@ -194,7 +184,7 @@ def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=Non self.api_call_part2 = api_call_part2 self.api_call_part3 = api_call_part3 - class _client_noauth(object): + class add_noauth(object): """ CloudFlare v4 API""" def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=None): @@ -208,15 +198,14 @@ def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=Non def get(self, identifier1=None, identifier2=None, params=None, data=None): """ CloudFlare v4 API""" - return self.base._call_with_no_auth('GET', - self.api_call_part1, - self.api_call_part2, - self.api_call_part3, - identifier1, - identifier2, - params, data) + return self.base.call_with_no_auth('GET', + self.api_call_part1, + self.api_call_part2, + self.api_call_part3, + identifier1, identifier2, + params, data) - class _client_with_auth(object): + class add_with_auth(object): """ CloudFlare v4 API""" def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=None): @@ -230,59 +219,54 @@ def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=Non def get(self, identifier1=None, identifier2=None, params=None, data=None): """ CloudFlare v4 API""" - return self.base._call_with_auth('GET', - self.api_call_part1, - self.api_call_part2, - self.api_call_part3, - identifier1, - identifier2, - params, data) + return self.base.call_with_auth('GET', + self.api_call_part1, + self.api_call_part2, + self.api_call_part3, + identifier1, identifier2, + params, data) def patch(self, identifier1=None, identifier2=None, params=None, data=None): """ CloudFlare v4 API""" - return self.base._call_with_auth('PATCH', - self.api_call_part1, - self.api_call_part2, - self.api_call_part3, - identifier1, - identifier2, - params, data) + return self.base.call_with_auth('PATCH', + self.api_call_part1, + self.api_call_part2, + self.api_call_part3, + identifier1, identifier2, + params, data) def post(self, identifier1=None, identifier2=None, params=None, data=None): """ CloudFlare v4 API""" - return self.base._call_with_auth('POST', - self.api_call_part1, - self.api_call_part2, - self.api_call_part3, - identifier1, - identifier2, - params, data) + return self.base.call_with_auth('POST', + self.api_call_part1, + self.api_call_part2, + self.api_call_part3, + identifier1, identifier2, + params, data) def put(self, identifier1=None, identifier2=None, params=None, data=None): """ CloudFlare v4 API""" - return self.base._call_with_auth('PUT', - self.api_call_part1, - self.api_call_part2, - self.api_call_part3, - identifier1, - identifier2, - params, data) + return self.base.call_with_auth('PUT', + self.api_call_part1, + self.api_call_part2, + self.api_call_part3, + identifier1, identifier2, + params, data) def delete(self, identifier1=None, identifier2=None, params=None, data=None): """ CloudFlare v4 API""" - return self.base._call_with_auth('DELETE', - self.api_call_part1, - self.api_call_part2, - self.api_call_part3, - identifier1, - identifier2, - params, data) + return self.base.call_with_auth('DELETE', + self.api_call_part1, + self.api_call_part2, + self.api_call_part3, + identifier1, identifier2, + params, data) - class _client_with_cert_auth(object): + class add_with_cert_auth(object): """ CloudFlare v4 API""" def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=None): @@ -296,57 +280,52 @@ def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=Non def get(self, identifier1=None, identifier2=None, params=None, data=None): """ CloudFlare v4 API""" - return self.base._call_with_certauth('GET', - self.api_call_part1, - self.api_call_part2, - self.api_call_part3, - identifier1, - identifier2, - params, data) + return self.base.call_with_certauth('GET', + self.api_call_part1, + self.api_call_part2, + self.api_call_part3, + identifier1, identifier2, + params, data) def patch(self, identifier1=None, identifier2=None, params=None, data=None): """ CloudFlare v4 API""" - return self.base._call_with_certauth('PATCH', - self.api_call_part1, - self.api_call_part2, - self.api_call_part3, - identifier1, - identifier2, - params, data) + return self.base.call_with_certauth('PATCH', + self.api_call_part1, + self.api_call_part2, + self.api_call_part3, + identifier1, identifier2, + params, data) def post(self, identifier1=None, identifier2=None, params=None, data=None): """ CloudFlare v4 API""" - return self.base._call_with_certauth('POST', - self.api_call_part1, - self.api_call_part2, - self.api_call_part3, - identifier1, - identifier2, - params, data) + return self.base.call_with_certauth('POST', + self.api_call_part1, + self.api_call_part2, + self.api_call_part3, + identifier1, identifier2, + params, data) def put(self, identifier1=None, identifier2=None, params=None, data=None): """ CloudFlare v4 API""" - return self.base._call_with_certauth('PUT', - self.api_call_part1, - self.api_call_part2, - self.api_call_part3, - identifier1, - identifier2, - params, data) + return self.base.call_with_certauth('PUT', + self.api_call_part1, + self.api_call_part2, + self.api_call_part3, + identifier1, identifier2, + params, data) def delete(self, identifier1=None, identifier2=None, params=None, data=None): """ CloudFlare v4 API""" - return self.base._call_with_certauth('DELETE', - self.api_call_part1, - self.api_call_part2, - self.api_call_part3, - identifier1, - identifier2, - params, data) + return self.base.call_with_certauth('DELETE', + self.api_call_part1, + self.api_call_part2, + self.api_call_part3, + identifier1, identifier2, + params, data) def __init__(self, email=None, token=None, certtoken=None, debug=False): """ CloudFlare v4 API""" @@ -363,10 +342,6 @@ def __init__(self, email=None, token=None, certtoken=None, debug=False): if certtoken is None: certtoken = conf_certtoken - # Removed: There are cases where you don't need an email and token - # if email is None or token is None: - # raise CloudFlareInternalError('You must at least specify an email and token string') - self.base = self._base(email, token, certtoken, base_url, debug) # add the API calls diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..e69de29