6 This is the initial REST API for RIC subscription # noqa: E501
8 OpenAPI spec version: 0.0.4
10 Generated by: https://github.com/swagger-api/swagger-codegen.git
14 from __future__ import absolute_import
18 import multiprocessing
23 from six.moves import http_client as httplib
26 class Configuration(object):
27 """NOTE: This class is auto generated by the swagger code generator program.
29 Ref: https://github.com/swagger-api/swagger-codegen
30 Do not edit the class manually.
38 for key in self._default.__dict__.keys():
39 self.__dict__[key] = copy.copy(self._default.__dict__[key])
43 self.host = "http://hostname/ric/v1"
44 # Temp file folder for downloading files
45 self.temp_folder_path = None
47 # Authentication Settings
48 # dict to store API key(s)
50 # dict to store API prefix (e.g. Bearer)
51 self.api_key_prefix = {}
52 # function to refresh API key if expired
53 self.refresh_api_key_hook = None
54 # Username for HTTP basic authentication
56 # Password for HTTP basic authentication
61 self.logger["package_logger"] = logging.getLogger("ricxappframe.subsclient")
62 self.logger["urllib3_logger"] = logging.getLogger("urllib3")
64 self.logger_format = '%(asctime)s %(levelname)s %(message)s'
66 self.logger_stream_handler = None
68 self.logger_file_handler = None
70 self.logger_file = None
74 # SSL/TLS verification
75 # Set this to false to skip verifying SSL certificate when calling API
77 self.verify_ssl = True
78 # Set this to customize the certificate file to verify the peer.
79 self.ssl_ca_cert = None
80 # client certificate file
84 # Set this to True/False to enable/disable SSL hostname verification.
85 self.assert_hostname = None
87 # urllib3 connection pool's maximum number of connections saved
88 # per pool. urllib3 uses 1 connection as default value, but this is
89 # not the best value when you are making a lot of possibly parallel
90 # requests to the same host, which is often the case here.
91 # cpu_count * 5 is used as default value to increase performance.
92 self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
96 # Safe chars for path_param
97 self.safe_chars_for_path_param = ''
99 # Disable client side validation
100 self.client_side_validation = True
103 def set_default(cls, default):
104 cls._default = default
107 def logger_file(self):
110 If the logger_file is None, then add stream handler and remove file
111 handler. Otherwise, add file handler and remove stream handler.
113 :param value: The logger_file path.
116 return self.__logger_file
119 def logger_file(self, value):
122 If the logger_file is None, then add stream handler and remove file
123 handler. Otherwise, add file handler and remove stream handler.
125 :param value: The logger_file path.
128 self.__logger_file = value
129 if self.__logger_file:
130 # If set logging file,
131 # then add file handler and remove stream handler.
132 self.logger_file_handler = logging.FileHandler(self.__logger_file)
133 self.logger_file_handler.setFormatter(self.logger_formatter)
134 for _, logger in six.iteritems(self.logger):
135 logger.addHandler(self.logger_file_handler)
136 if self.logger_stream_handler:
137 logger.removeHandler(self.logger_stream_handler)
139 # If not set logging file,
140 # then add stream handler and remove file handler.
141 self.logger_stream_handler = logging.StreamHandler()
142 self.logger_stream_handler.setFormatter(self.logger_formatter)
143 for _, logger in six.iteritems(self.logger):
144 logger.addHandler(self.logger_stream_handler)
145 if self.logger_file_handler:
146 logger.removeHandler(self.logger_file_handler)
152 :param value: The debug status, True or False.
158 def debug(self, value):
161 :param value: The debug status, True or False.
166 # if debug status is True, turn on debug logging
167 for _, logger in six.iteritems(self.logger):
168 logger.setLevel(logging.DEBUG)
169 # turn on httplib debug
170 httplib.HTTPConnection.debuglevel = 1
172 # if debug status is False, turn off debug logging,
173 # setting log level to default `logging.WARNING`
174 for _, logger in six.iteritems(self.logger):
175 logger.setLevel(logging.WARNING)
176 # turn off httplib debug
177 httplib.HTTPConnection.debuglevel = 0
180 def logger_format(self):
181 """The logger format.
183 The logger_formatter will be updated when sets logger_format.
185 :param value: The format string.
188 return self.__logger_format
190 @logger_format.setter
191 def logger_format(self, value):
192 """The logger format.
194 The logger_formatter will be updated when sets logger_format.
196 :param value: The format string.
199 self.__logger_format = value
200 self.logger_formatter = logging.Formatter(self.__logger_format)
202 def get_api_key_with_prefix(self, identifier):
203 """Gets API key (with prefix if set).
205 :param identifier: The identifier of apiKey.
206 :return: The token for api key authentication.
209 if self.refresh_api_key_hook:
210 self.refresh_api_key_hook(self)
212 key = self.api_key.get(identifier)
214 prefix = self.api_key_prefix.get(identifier)
216 return "%s %s" % (prefix, key)
220 def get_basic_auth_token(self):
221 """Gets HTTP basic authentication header (string).
223 :return: The token for basic HTTP authentication.
225 return urllib3.util.make_headers(
226 basic_auth=self.username + ':' + self.password
227 ).get('authorization')
229 def auth_settings(self):
230 """Gets Auth Settings dict for api client.
232 :return: The Auth Settings information dict.
238 def to_debug_report(self):
239 """Gets the essential information for debugging.
241 :return: The report for debugging.
243 return "Python SDK Debug Report:\n"\
245 "Python Version: {pyversion}\n"\
246 "Version of the API: 0.0.4\n"\
247 "SDK Package Version: 1.0.0".\
248 format(env=sys.platform, pyversion=sys.version)