catocli 1.0.4__py3-none-any.whl → 1.0.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of catocli might be problematic. Click here for more details.

Files changed (92) hide show
  1. build/lib/catocli/Utils/clidriver.py +103 -0
  2. build/lib/catocli/__init__.py +2 -0
  3. build/lib/catocli/__main__.py +12 -0
  4. build/lib/catocli/parsers/custom/__init__.py +42 -0
  5. build/lib/catocli/parsers/custom/customLib.py +71 -0
  6. build/lib/catocli/parsers/mutation_admin/__init__.py +51 -0
  7. build/lib/catocli/parsers/mutation_container/__init__.py +23 -0
  8. build/lib/catocli/parsers/mutation_policy/__init__.py +357 -0
  9. build/lib/catocli/parsers/mutation_site/__init__.py +219 -0
  10. build/lib/catocli/parsers/mutation_sites/__init__.py +219 -0
  11. build/lib/catocli/parsers/parserApiClient.py +312 -0
  12. build/lib/catocli/parsers/query_accountBySubdomain/__init__.py +17 -0
  13. build/lib/catocli/parsers/query_accountMetrics/__init__.py +17 -0
  14. build/lib/catocli/parsers/query_accountRoles/__init__.py +17 -0
  15. build/lib/catocli/parsers/query_accountSnapshot/__init__.py +17 -0
  16. build/lib/catocli/parsers/query_admin/__init__.py +17 -0
  17. build/lib/catocli/parsers/query_admins/__init__.py +17 -0
  18. build/lib/catocli/parsers/query_appStats/__init__.py +17 -0
  19. build/lib/catocli/parsers/query_appStatsTimeSeries/__init__.py +17 -0
  20. build/lib/catocli/parsers/query_auditFeed/__init__.py +17 -0
  21. build/lib/catocli/parsers/query_container/__init__.py +17 -0
  22. build/lib/catocli/parsers/query_entityLookup/__init__.py +17 -0
  23. build/lib/catocli/parsers/query_events/__init__.py +17 -0
  24. build/lib/catocli/parsers/query_eventsFeed/__init__.py +17 -0
  25. build/lib/catocli/parsers/query_eventsTimeSeries/__init__.py +17 -0
  26. build/lib/catocli/parsers/query_hardwareManagement/__init__.py +17 -0
  27. build/lib/catocli/parsers/query_licensing/__init__.py +17 -0
  28. build/lib/catocli/parsers/query_policy/__init__.py +17 -0
  29. build/lib/catocli/parsers/query_siteLocation/__init__.py +17 -0
  30. build/lib/catocli/parsers/query_subDomains/__init__.py +17 -0
  31. build/lib/catocli/parsers/query_xdr/__init__.py +37 -0
  32. build/lib/catocli/parsers/raw/__init__.py +9 -0
  33. build/lib/graphql_client/__init__.py +11 -0
  34. build/lib/graphql_client/api/__init__.py +3 -0
  35. build/lib/graphql_client/api/call_api.py +73 -0
  36. build/lib/graphql_client/api_client.py +192 -0
  37. build/lib/graphql_client/api_client_types.py +404 -0
  38. build/lib/graphql_client/configuration.py +230 -0
  39. build/lib/graphql_client/models/__init__.py +13 -0
  40. build/lib/graphql_client/models/no_schema.py +71 -0
  41. build/lib/schema/catolib.py +1002 -0
  42. build/lib/schema/importSchema.py +60 -0
  43. build/lib/vendor/certifi/__init__.py +4 -0
  44. build/lib/vendor/certifi/__main__.py +12 -0
  45. build/lib/vendor/certifi/core.py +114 -0
  46. build/lib/vendor/certifi/py.typed +0 -0
  47. build/lib/vendor/six.py +998 -0
  48. build/lib/vendor/urllib3/__init__.py +211 -0
  49. build/lib/vendor/urllib3/_base_connection.py +172 -0
  50. build/lib/vendor/urllib3/_collections.py +483 -0
  51. build/lib/vendor/urllib3/_request_methods.py +278 -0
  52. build/lib/vendor/urllib3/_version.py +16 -0
  53. build/lib/vendor/urllib3/connection.py +1033 -0
  54. build/lib/vendor/urllib3/connectionpool.py +1182 -0
  55. build/lib/vendor/urllib3/contrib/__init__.py +0 -0
  56. build/lib/vendor/urllib3/contrib/emscripten/__init__.py +18 -0
  57. build/lib/vendor/urllib3/contrib/emscripten/connection.py +254 -0
  58. build/lib/vendor/urllib3/contrib/emscripten/fetch.py +418 -0
  59. build/lib/vendor/urllib3/contrib/emscripten/request.py +22 -0
  60. build/lib/vendor/urllib3/contrib/emscripten/response.py +285 -0
  61. build/lib/vendor/urllib3/contrib/pyopenssl.py +552 -0
  62. build/lib/vendor/urllib3/contrib/socks.py +228 -0
  63. build/lib/vendor/urllib3/exceptions.py +321 -0
  64. build/lib/vendor/urllib3/fields.py +341 -0
  65. build/lib/vendor/urllib3/filepost.py +89 -0
  66. build/lib/vendor/urllib3/http2/__init__.py +53 -0
  67. build/lib/vendor/urllib3/http2/connection.py +356 -0
  68. build/lib/vendor/urllib3/http2/probe.py +87 -0
  69. build/lib/vendor/urllib3/poolmanager.py +637 -0
  70. build/lib/vendor/urllib3/py.typed +2 -0
  71. build/lib/vendor/urllib3/response.py +1265 -0
  72. build/lib/vendor/urllib3/util/__init__.py +42 -0
  73. build/lib/vendor/urllib3/util/connection.py +137 -0
  74. build/lib/vendor/urllib3/util/proxy.py +43 -0
  75. build/lib/vendor/urllib3/util/request.py +256 -0
  76. build/lib/vendor/urllib3/util/response.py +101 -0
  77. build/lib/vendor/urllib3/util/retry.py +533 -0
  78. build/lib/vendor/urllib3/util/ssl_.py +513 -0
  79. build/lib/vendor/urllib3/util/ssl_match_hostname.py +159 -0
  80. build/lib/vendor/urllib3/util/ssltransport.py +276 -0
  81. build/lib/vendor/urllib3/util/timeout.py +275 -0
  82. build/lib/vendor/urllib3/util/url.py +471 -0
  83. build/lib/vendor/urllib3/util/util.py +42 -0
  84. build/lib/vendor/urllib3/util/wait.py +124 -0
  85. catocli/__init__.py +1 -1
  86. catocli/parsers/parserApiClient.py +7 -4
  87. {catocli-1.0.4.dist-info → catocli-1.0.5.dist-info}/METADATA +1 -1
  88. {catocli-1.0.4.dist-info → catocli-1.0.5.dist-info}/RECORD +92 -8
  89. {catocli-1.0.4.dist-info → catocli-1.0.5.dist-info}/top_level.txt +1 -0
  90. {catocli-1.0.4.dist-info → catocli-1.0.5.dist-info}/LICENSE +0 -0
  91. {catocli-1.0.4.dist-info → catocli-1.0.5.dist-info}/WHEEL +0 -0
  92. {catocli-1.0.4.dist-info → catocli-1.0.5.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,404 @@
1
+ # coding: utf-8
2
+
3
+ from __future__ import absolute_import
4
+
5
+ import datetime
6
+ import json
7
+ import mimetypes
8
+ from multiprocessing.pool import ThreadPool
9
+ import os
10
+ import re
11
+ import tempfile
12
+
13
+ from graphql_client.configuration import Configuration
14
+ import graphql_client.models
15
+ from graphql_client import api_client
16
+
17
+ # python 2 and python 3 compatibility library
18
+ import sys
19
+ sys.path.insert(0, 'vendor')
20
+ import six
21
+
22
+ class ApiClient(object):
23
+ PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types
24
+ NATIVE_TYPES_MAPPING = {
25
+ 'int': int,
26
+ 'long': int if six.PY3 else long,
27
+ 'float': float,
28
+ 'str': str,
29
+ 'bool': bool,
30
+ 'date': datetime.date,
31
+ 'datetime': datetime.datetime,
32
+ 'object': object,
33
+ }
34
+
35
+ def __init__(self, configuration=None, header_name=None, header_value=None,
36
+ cookie=None):
37
+ if configuration is None:
38
+ configuration = Configuration()
39
+ self.configuration = configuration
40
+
41
+ self.pool = ThreadPool()
42
+ self.rest_client = api_client.QUERYClientObject(configuration)
43
+ self.default_headers = {}
44
+ if header_name is not None:
45
+ self.default_headers[header_name] = header_value
46
+ self.cookie = cookie
47
+ self.user_agent = "Cato-CLI-v"+self.configuration.version
48
+
49
+ def __del__(self):
50
+ self.pool.close()
51
+ self.pool.join()
52
+
53
+ @property
54
+ def user_agent(self):
55
+ """User agent for this API client"""
56
+ return self.default_headers['User-Agent']
57
+
58
+ @user_agent.setter
59
+ def user_agent(self, value):
60
+ self.default_headers['User-Agent'] = value
61
+
62
+ def set_default_header(self, header_name, header_value):
63
+ self.default_headers[header_name] = header_value
64
+
65
+ def __call_api(
66
+ self, header_params=None, body=None,
67
+ files=None, response_type=None,
68
+ _return_http_data_only=None, collection_formats=None,
69
+ _preload_content=True, _request_timeout=None):
70
+
71
+ config = self.configuration
72
+
73
+ # header parameters
74
+ header_params = header_params or {}
75
+ header_params.update(self.default_headers)
76
+ if self.cookie:
77
+ header_params['Cookie'] = self.cookie
78
+ if header_params:
79
+ header_params = self.sanitize_for_serialization(header_params)
80
+ header_params = dict(self.parameters_to_tuples(header_params,
81
+ collection_formats))
82
+
83
+ # body
84
+ if body:
85
+ body = self.sanitize_for_serialization(body)
86
+
87
+ # request url
88
+ url = self.configuration.host
89
+
90
+ # perform request and return response
91
+ response_data = self.request(
92
+ url, headers=header_params, body=body,
93
+ _preload_content=_preload_content,
94
+ _request_timeout=_request_timeout)
95
+
96
+ self.last_response = response_data
97
+
98
+ return_data = response_data
99
+ if _preload_content:
100
+ # deserialize response data
101
+ if response_type:
102
+ return_data = self.deserialize(response_data, response_type)
103
+ else:
104
+ return_data = None
105
+
106
+ if _return_http_data_only:
107
+ return (return_data)
108
+ else:
109
+ return (return_data, response_data.status,
110
+ response_data.getheaders())
111
+
112
+ def sanitize_for_serialization(self, obj):
113
+ """Builds a JSON POST object.
114
+ If obj is None, return None.
115
+ If obj is str, int, long, float, bool, return directly.
116
+ If obj is datetime.datetime, datetime.date
117
+ convert to string in iso8601 format.
118
+ If obj is list, sanitize each element in the list.
119
+ If obj is dict, return the dict.
120
+ :param obj: The data to serialize.
121
+ :return: The serialized form of data.
122
+ """
123
+ if obj is None:
124
+ return None
125
+ elif isinstance(obj, self.PRIMITIVE_TYPES):
126
+ return obj
127
+ elif isinstance(obj, list):
128
+ return [self.sanitize_for_serialization(sub_obj)
129
+ for sub_obj in obj]
130
+ elif isinstance(obj, tuple):
131
+ return tuple(self.sanitize_for_serialization(sub_obj)
132
+ for sub_obj in obj)
133
+ elif isinstance(obj, (datetime.datetime, datetime.date)):
134
+ return obj.isoformat()
135
+
136
+ if isinstance(obj, dict):
137
+ obj_dict = obj
138
+ else:
139
+ obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
140
+ for attr, _ in six.iteritems(obj.swagger_types)
141
+ if getattr(obj, attr) is not None}
142
+
143
+ return {key: self.sanitize_for_serialization(val)
144
+ for key, val in six.iteritems(obj_dict)}
145
+
146
+ def deserialize(self, response, response_type):
147
+ # handle file downloading
148
+ # save response body into a tmp file and return the instance
149
+ if response_type == "file":
150
+ return self.__deserialize_file(response)
151
+
152
+ # fetch data from response object
153
+ try:
154
+ data = json.loads(response.data)
155
+ except ValueError:
156
+ data = response.data
157
+
158
+ return self.__deserialize(data, response_type)
159
+
160
+ def __deserialize(self, data, klass):
161
+ if data is None:
162
+ return None
163
+
164
+ if type(klass) == str:
165
+ if klass.startswith('list['):
166
+ sub_kls = re.match(r'list\[(.*)\]', klass).group(1)
167
+ return [self.__deserialize(sub_data, sub_kls)
168
+ for sub_data in data]
169
+
170
+ if klass.startswith('dict('):
171
+ sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2)
172
+ return {k: self.__deserialize(v, sub_kls)
173
+ for k, v in six.iteritems(data)}
174
+
175
+ # convert str to class
176
+ if klass in self.NATIVE_TYPES_MAPPING:
177
+ klass = self.NATIVE_TYPES_MAPPING[klass]
178
+ else:
179
+ klass = getattr(graphql_client.models, klass)
180
+
181
+ if klass in self.PRIMITIVE_TYPES:
182
+ return self.__deserialize_primitive(data, klass)
183
+ elif klass == object:
184
+ return self.__deserialize_object(data)
185
+ elif klass == datetime.date:
186
+ return self.__deserialize_date(data)
187
+ elif klass == datetime.datetime:
188
+ return self.__deserialize_datatime(data)
189
+ else:
190
+ return self.__deserialize_model(data, klass)
191
+
192
+ def call_api(self, header_params=None, body=None, files=None,
193
+ response_type=None, async_req=None,
194
+ _return_http_data_only=None, collection_formats=None,
195
+ _preload_content=True, _request_timeout=None):
196
+
197
+ if not async_req:
198
+ return self.__call_api( header_params, body, files,
199
+ response_type, _return_http_data_only, collection_formats,
200
+ _preload_content, _request_timeout)
201
+ else:
202
+ thread = self.pool.apply_async(self.__call_api, ( header_params,
203
+ body, files, response_type,
204
+ _return_http_data_only,
205
+ collection_formats,
206
+ _preload_content, _request_timeout))
207
+ return thread
208
+
209
+ def request(self, url, headers=None,
210
+ body=None, _preload_content=True,
211
+ _request_timeout=None):
212
+
213
+ return self.rest_client.POST(url, headers=headers,
214
+ _preload_content=_preload_content,
215
+ _request_timeout=_request_timeout,
216
+ body=body)
217
+
218
+ def parameters_to_tuples(self, params, collection_formats):
219
+ """Get parameters as list of tuples, formatting collections.
220
+
221
+ :param params: Parameters as dict or list of two-tuples
222
+ :param dict collection_formats: Parameter collection formats
223
+ :return: Parameters as list of tuples, collections formatted
224
+ """
225
+ new_params = []
226
+ if collection_formats is None:
227
+ collection_formats = {}
228
+ for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501
229
+ if k in collection_formats:
230
+ collection_format = collection_formats[k]
231
+ if collection_format == 'multi':
232
+ new_params.extend((k, value) for value in v)
233
+ else:
234
+ if collection_format == 'ssv':
235
+ delimiter = ' '
236
+ elif collection_format == 'tsv':
237
+ delimiter = '\t'
238
+ elif collection_format == 'pipes':
239
+ delimiter = '|'
240
+ else: # csv is the default
241
+ delimiter = ','
242
+ new_params.append(
243
+ (k, delimiter.join(str(value) for value in v)))
244
+ else:
245
+ new_params.append((k, v))
246
+ return new_params
247
+
248
+ def select_header_accept(self, accepts):
249
+ """Returns `Accept` based on an array of accepts provided.
250
+
251
+ :param accepts: List of headers.
252
+ :return: Accept (e.g. application/json).
253
+ """
254
+ if not accepts:
255
+ return
256
+
257
+ accepts = [x.lower() for x in accepts]
258
+
259
+ if 'application/json' in accepts:
260
+ return 'application/json'
261
+ else:
262
+ return ', '.join(accepts)
263
+
264
+ def select_header_content_type(self, content_types):
265
+ """Returns `Content-Type` based on an array of content_types provided.
266
+
267
+ :param content_types: List of content-types.
268
+ :return: Content-Type (e.g. application/json).
269
+ """
270
+ if not content_types:
271
+ return 'application/json'
272
+
273
+ content_types = [x.lower() for x in content_types]
274
+
275
+ if 'application/json' in content_types or '*/*' in content_types:
276
+ return 'application/json'
277
+ else:
278
+ return content_types[0]
279
+
280
+ def __deserialize_file(self, response):
281
+ """Deserializes body to file
282
+
283
+ Saves response body into a file in a temporary folder,
284
+ using the filename from the `Content-Disposition` header if provided.
285
+
286
+ :param response: RESTResponse.
287
+ :return: file path.
288
+ """
289
+ fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path)
290
+ os.close(fd)
291
+ os.remove(path)
292
+
293
+ content_disposition = response.getheader("Content-Disposition")
294
+ if content_disposition:
295
+ filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?',
296
+ content_disposition).group(1)
297
+ path = os.path.join(os.path.dirname(path), filename)
298
+ response_data = response.data
299
+ with open(path, "wb") as f:
300
+ if isinstance(response_data, str):
301
+ # change str to bytes so we can write it
302
+ response_data = response_data.encode('utf-8')
303
+ f.write(response_data)
304
+ else:
305
+ f.write(response_data)
306
+ return path
307
+
308
+ def __deserialize_primitive(self, data, klass):
309
+ """Deserializes string to primitive type.
310
+
311
+ :param data: str.
312
+ :param klass: class literal.
313
+
314
+ :return: int, long, float, str, bool.
315
+ """
316
+ try:
317
+ return klass(data)
318
+ except UnicodeEncodeError:
319
+ return six.text_type(data)
320
+ except TypeError:
321
+ return data
322
+
323
+ def __deserialize_object(self, value):
324
+ """Return a original value.
325
+
326
+ :return: object.
327
+ """
328
+ return value
329
+
330
+ def __deserialize_date(self, string):
331
+ """Deserializes string to date.
332
+
333
+ :param string: str.
334
+ :return: date.
335
+ """
336
+ try:
337
+ from dateutil.parser import parse
338
+ return parse(string).date()
339
+ except ImportError:
340
+ return string
341
+ except ValueError:
342
+ raise apiclient.ApiException(
343
+ status=0,
344
+ reason="Failed to parse `{0}` as date object".format(string)
345
+ )
346
+
347
+ def __deserialize_datatime(self, string):
348
+ """Deserializes string to datetime.
349
+
350
+ The string should be in iso8601 datetime format.
351
+
352
+ :param string: str.
353
+ :return: datetime.
354
+ """
355
+ try:
356
+ from dateutil.parser import parse
357
+ return parse(string)
358
+ except ImportError:
359
+ return string
360
+ except ValueError:
361
+ raise apiclient.ApiException(
362
+ status=0,
363
+ reason=(
364
+ "Failed to parse `{0}` as datetime object"
365
+ .format(string)
366
+ )
367
+ )
368
+
369
+ def __hasattr(self, object, name):
370
+ return name in object.__class__.__dict__
371
+
372
+ def __deserialize_model(self, data, klass):
373
+ """Deserializes list or dict to model.
374
+
375
+ :param data: dict, list.
376
+ :param klass: class literal.
377
+ :return: model object.
378
+ """
379
+
380
+ if not klass.swagger_types and not self.__hasattr(klass, 'get_real_child_model'):
381
+ return data
382
+
383
+ kwargs = {}
384
+ if klass.swagger_types is not None:
385
+ for attr, attr_type in six.iteritems(klass.swagger_types):
386
+ if (data is not None and
387
+ klass.attribute_map[attr] in data and
388
+ isinstance(data, (list, dict))):
389
+ value = data[klass.attribute_map[attr]]
390
+ kwargs[attr] = self.__deserialize(value, attr_type)
391
+
392
+ instance = klass(**kwargs)
393
+
394
+ if (isinstance(instance, dict) and
395
+ klass.swagger_types is not None and
396
+ isinstance(data, dict)):
397
+ for key, value in data.items():
398
+ if key not in klass.swagger_types:
399
+ instance[key] = value
400
+ if self.__hasattr(instance, 'get_real_child_model'):
401
+ klass_name = instance.get_real_child_model(data)
402
+ if klass_name:
403
+ instance = self.__deserialize(data, klass_name)
404
+ return instance
@@ -0,0 +1,230 @@
1
+ # coding: utf-8
2
+
3
+ from __future__ import absolute_import
4
+
5
+ import copy
6
+ import logging
7
+ import multiprocessing
8
+ import sys
9
+ sys.path.insert(0, 'vendor')
10
+ import urllib3
11
+ import six
12
+ from six.moves import http_client as httplib
13
+
14
+ class TypeWithDefault(type):
15
+ def __init__(cls, name, bases, dct):
16
+ super(TypeWithDefault, cls).__init__(name, bases, dct)
17
+ cls._default = None
18
+
19
+ def __call__(cls):
20
+ if cls._default is None:
21
+ cls._default = type.__call__(cls)
22
+ return copy.copy(cls._default)
23
+
24
+ def set_default(cls, default):
25
+ cls._default = copy.copy(default)
26
+
27
+
28
+ class Configuration(six.with_metaclass(TypeWithDefault, object)):
29
+ """NOTE: This class is auto generated by the swagger code generator program.
30
+
31
+ Ref: https://github.com/swagger-api/swagger-codegen
32
+ Do not edit the class manually.
33
+ """
34
+
35
+ def __init__(self):
36
+ """Constructor"""
37
+ # Default Base url
38
+ # Temp file folder for downloading files
39
+ self.temp_folder_path = None
40
+
41
+ # Authentication Settings
42
+ # dict to store API key(s)
43
+ self.api_key = {}
44
+ # dict to store API prefix (e.g. Bearer)
45
+ self.api_key_prefix = {}
46
+ # function to refresh API key if expired
47
+ self.refresh_api_key_hook = None
48
+ # Username for HTTP basic authentication
49
+ self.username = ""
50
+ # Password for HTTP basic authentication
51
+ self.password = ""
52
+ # Logging Settings
53
+ self.logger = {}
54
+ self.logger["package_logger"] = logging.getLogger("swagger_client")
55
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
56
+ # Log format
57
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
58
+ # Log stream handler
59
+ self.logger_stream_handler = None
60
+ # Log file handler
61
+ self.logger_file_handler = None
62
+ # Debug file location
63
+ self.logger_file = None
64
+ # Debug switch
65
+ self.debug = False
66
+
67
+ # SSL/TLS verification
68
+ # Set this to false to skip verifying SSL certificate when calling API
69
+ # from https server.
70
+ self.verify_ssl = True
71
+ # Set this to customize the certificate file to verify the peer.
72
+ self.ssl_ca_cert = None
73
+ # client certificate file
74
+ self.cert_file = None
75
+ # client key file
76
+ self.key_file = None
77
+ # Set this to True/False to enable/disable SSL hostname verification.
78
+ self.assert_hostname = None
79
+
80
+ # urllib3 connection pool's maximum number of connections saved
81
+ # per pool. urllib3 uses 1 connection as default value, but this is
82
+ # not the best value when you are making a lot of possibly parallel
83
+ # requests to the same host, which is often the case here.
84
+ # cpu_count * 5 is used as default value to increase performance.
85
+ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
86
+
87
+ # Proxy URL
88
+ self.proxy = None
89
+ # Safe chars for path_param
90
+ self.safe_chars_for_path_param = ''
91
+
92
+ @property
93
+ def logger_file(self):
94
+ """The logger file.
95
+
96
+ If the logger_file is None, then add stream handler and remove file
97
+ handler. Otherwise, add file handler and remove stream handler.
98
+
99
+ :param value: The logger_file path.
100
+ :type: str
101
+ """
102
+ return self.__logger_file
103
+
104
+ @logger_file.setter
105
+ def logger_file(self, value):
106
+ """The logger file.
107
+
108
+ If the logger_file is None, then add stream handler and remove file
109
+ handler. Otherwise, add file handler and remove stream handler.
110
+
111
+ :param value: The logger_file path.
112
+ :type: str
113
+ """
114
+ self.__logger_file = value
115
+ if self.__logger_file:
116
+ # If set logging file,
117
+ # then add file handler and remove stream handler.
118
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
119
+ self.logger_file_handler.setFormatter(self.logger_formatter)
120
+ for _, logger in six.iteritems(self.logger):
121
+ logger.addHandler(self.logger_file_handler)
122
+ if self.logger_stream_handler:
123
+ logger.removeHandler(self.logger_stream_handler)
124
+ else:
125
+ # If not set logging file,
126
+ # then add stream handler and remove file handler.
127
+ self.logger_stream_handler = logging.StreamHandler()
128
+ self.logger_stream_handler.setFormatter(self.logger_formatter)
129
+ for _, logger in six.iteritems(self.logger):
130
+ logger.addHandler(self.logger_stream_handler)
131
+ if self.logger_file_handler:
132
+ logger.removeHandler(self.logger_file_handler)
133
+
134
+ @property
135
+ def debug(self):
136
+ """Debug status
137
+
138
+ :param value: The debug status, True or False.
139
+ :type: bool
140
+ """
141
+ return self.__debug
142
+
143
+ @debug.setter
144
+ def debug(self, value):
145
+ """Debug status
146
+
147
+ :param value: The debug status, True or False.
148
+ :type: bool
149
+ """
150
+ self.__debug = value
151
+ if self.__debug:
152
+ # if debug status is True, turn on debug logging
153
+ for _, logger in six.iteritems(self.logger):
154
+ logger.setLevel(logging.DEBUG)
155
+ # turn on httplib debug
156
+ httplib.HTTPConnection.debuglevel = 1
157
+ else:
158
+ # if debug status is False, turn off debug logging,
159
+ # setting log level to default `logging.WARNING`
160
+ for _, logger in six.iteritems(self.logger):
161
+ logger.setLevel(logging.WARNING)
162
+ # turn off httplib debug
163
+ httplib.HTTPConnection.debuglevel = 0
164
+
165
+ @property
166
+ def logger_format(self):
167
+ """The logger format.
168
+
169
+ The logger_formatter will be updated when sets logger_format.
170
+
171
+ :param value: The format string.
172
+ :type: str
173
+ """
174
+ return self.__logger_format
175
+
176
+ @logger_format.setter
177
+ def logger_format(self, value):
178
+ """The logger format.
179
+
180
+ The logger_formatter will be updated when sets logger_format.
181
+
182
+ :param value: The format string.
183
+ :type: str
184
+ """
185
+ self.__logger_format = value
186
+ self.logger_formatter = logging.Formatter(self.__logger_format)
187
+
188
+ def get_api_key_with_prefix(self, identifier):
189
+ """Gets API key (with prefix if set).
190
+
191
+ :param identifier: The identifier of apiKey.
192
+ :return: The token for api key authentication.
193
+ """
194
+ if self.refresh_api_key_hook:
195
+ self.refresh_api_key_hook(self)
196
+
197
+ key = self.api_key.get(identifier)
198
+ if key:
199
+ prefix = self.api_key_prefix.get(identifier)
200
+ if prefix:
201
+ return "%s %s" % (prefix, key)
202
+ else:
203
+ return key
204
+
205
+ def auth_settings(self):
206
+ """Gets Auth Settings dict for api client.
207
+
208
+ :return: The Auth Settings information dict.
209
+ """
210
+ return {
211
+ 'auth_token':
212
+ {
213
+ 'type': 'api_key',
214
+ 'in': 'header',
215
+ 'key': 'Authorization',
216
+ 'value': self.api_key
217
+ },
218
+ }
219
+
220
+ def to_debug_report(self):
221
+ """Gets the essential information for debugging.
222
+
223
+ :return: The report for debugging.
224
+ """
225
+ return "Python SDK Debug Report:\n"\
226
+ "OS: {env}\n"\
227
+ "Python Version: {pyversion}\n"\
228
+ "Version of the API: 1.0.0\n"\
229
+ "SDK Package Version: 1.0.0".\
230
+ format(env=sys.platform, pyversion=sys.version)
@@ -0,0 +1,13 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+ """
5
+ OpenAPI spec version: 1.0.0
6
+
7
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
8
+ """
9
+
10
+ from __future__ import absolute_import
11
+
12
+ # import models into model package
13
+ from graphql_client.models.no_schema import NoSchema