|
18 | 18 | from .api_extras import api_extras |
19 | 19 | from .api_decode_from_openapi import api_decode_from_openapi |
20 | 20 | from .exceptions import CloudFlareAPIError, CloudFlareInternalError |
| 21 | +from .warning_2_20 import warning_2_20, print_warning_2_20 |
21 | 22 |
|
22 | 23 | BASE_URL = 'https://api.cloudflare.com/client/v4' |
23 | 24 | OPENAPI_URL = 'https://github.com/cloudflare/api-schemas/raw/main/openapi.json' |
@@ -48,7 +49,7 @@ class CloudFlare(): |
48 | 49 | class _v4base(): |
49 | 50 | """ :meta private: """ |
50 | 51 |
|
51 | | - def __init__(self, config): |
| 52 | + def __init__(self, config, warnings=True): |
52 | 53 | """ :meta private: """ |
53 | 54 |
|
54 | 55 | self.network = None |
@@ -88,6 +89,15 @@ def __init__(self, config): |
88 | 89 |
|
89 | 90 | self.logger = CFlogger(config['debug']).getLogger() if 'debug' in config and config['debug'] else None |
90 | 91 |
|
| 92 | + if warnings: |
| 93 | + # After 2.20.* there is a warning message posted to handle un-pinned versions |
| 94 | + warning = warning_2_20() |
| 95 | + if warning: |
| 96 | + if self.logger: |
| 97 | + self.logger.warning(''.join(['\n ' + v for v in warning.split('\n')])) |
| 98 | + else: |
| 99 | + print_warning_2_20(warning) |
| 100 | + |
91 | 101 | def __del__(self): |
92 | 102 | if self.network: |
93 | 103 | del self.network |
@@ -1024,7 +1034,7 @@ def api_from_openapi(self, url=None): |
1024 | 1034 |
|
1025 | 1035 | return self._base.api_from_openapi(url) |
1026 | 1036 |
|
1027 | | - def __init__(self, email=None, key=None, token=None, certtoken=None, debug=False, raw=False, use_sessions=True, profile=None, base_url=None, global_request_timeout=None, max_request_retries=None, http_headers=None): |
| 1037 | + def __init__(self, email=None, key=None, token=None, certtoken=None, debug=False, raw=False, use_sessions=True, profile=None, base_url=None, global_request_timeout=None, max_request_retries=None, http_headers=None, warnings=True): |
1028 | 1038 | """ :meta private: """ |
1029 | 1039 |
|
1030 | 1040 | self._base = None |
@@ -1085,7 +1095,7 @@ def __init__(self, email=None, key=None, token=None, certtoken=None, debug=False |
1085 | 1095 | if v == '': |
1086 | 1096 | config[k] = None |
1087 | 1097 |
|
1088 | | - self._base = self._v4base(config) |
| 1098 | + self._base = self._v4base(config, warnings=warnings) |
1089 | 1099 |
|
1090 | 1100 | # add the API calls |
1091 | 1101 | try: |
|
0 commit comments