|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + Kubernetes |
| 5 | +
|
| 6 | + No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) |
| 7 | +
|
| 8 | + OpenAPI spec version: v1.5.0-snapshot |
| 9 | + |
| 10 | + Generated by: https://github.com/swagger-api/swagger-codegen.git |
| 11 | +
|
| 12 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 13 | + you may not use this file except in compliance with the License. |
| 14 | + You may obtain a copy of the License at |
| 15 | +
|
| 16 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 17 | +
|
| 18 | + Unless required by applicable law or agreed to in writing, software |
| 19 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 20 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 21 | + See the License for the specific language governing permissions and |
| 22 | + limitations under the License. |
| 23 | +""" |
| 24 | + |
| 25 | +from __future__ import absolute_import |
| 26 | + |
| 27 | +import urllib3 |
| 28 | + |
| 29 | +import sys |
| 30 | +import logging |
| 31 | + |
| 32 | +from six import iteritems |
| 33 | +from six.moves import http_client as httplib |
| 34 | + |
| 35 | + |
| 36 | +class ConfigurationObject(object): |
| 37 | + """ |
| 38 | + NOTE: This class is auto generated by the swagger code generator program. |
| 39 | + Ref: https://github.com/swagger-api/swagger-codegen |
| 40 | + Do not edit the class manually. |
| 41 | + """ |
| 42 | + |
| 43 | + def __init__(self): |
| 44 | + """ |
| 45 | + Constructor |
| 46 | + """ |
| 47 | + # Default Base url |
| 48 | + self.host = "https://localhost" |
| 49 | + # Default api client |
| 50 | + self.api_client = None |
| 51 | + # Temp file folder for downloading files |
| 52 | + self.temp_folder_path = None |
| 53 | + |
| 54 | + # Authentication Settings |
| 55 | + # dict to store API key(s) |
| 56 | + self.api_key = {} |
| 57 | + # dict to store API prefix (e.g. Bearer) |
| 58 | + self.api_key_prefix = {} |
| 59 | + # Username for HTTP basic authentication |
| 60 | + self.username = "" |
| 61 | + # Password for HTTP basic authentication |
| 62 | + self.password = "" |
| 63 | + |
| 64 | + # Logging Settings |
| 65 | + self.logger = {} |
| 66 | + self.logger["package_logger"] = logging.getLogger("client") |
| 67 | + self.logger["urllib3_logger"] = logging.getLogger("urllib3") |
| 68 | + # Log format |
| 69 | + self.logger_format = '%(asctime)s %(levelname)s %(message)s' |
| 70 | + # Log stream handler |
| 71 | + self.logger_stream_handler = None |
| 72 | + # Log file handler |
| 73 | + self.logger_file_handler = None |
| 74 | + # Debug file location |
| 75 | + self.logger_file = None |
| 76 | + # Debug switch |
| 77 | + self.debug = False |
| 78 | + |
| 79 | + # SSL/TLS verification |
| 80 | + # Set this to false to skip verifying SSL certificate when calling API from https server. |
| 81 | + self.verify_ssl = True |
| 82 | + # Set this to customize the certificate file to verify the peer. |
| 83 | + self.ssl_ca_cert = None |
| 84 | + # client certificate file |
| 85 | + self.cert_file = None |
| 86 | + # client key file |
| 87 | + self.key_file = None |
| 88 | + # check host name |
| 89 | + # Set this to True/False to enable/disable SSL hostname verification. |
| 90 | + self.assert_hostname = None |
| 91 | + |
| 92 | + @property |
| 93 | + def logger_file(self): |
| 94 | + """ |
| 95 | + Gets the logger_file. |
| 96 | + """ |
| 97 | + return self.__logger_file |
| 98 | + |
| 99 | + @logger_file.setter |
| 100 | + def logger_file(self, value): |
| 101 | + """ |
| 102 | + Sets the logger_file. |
| 103 | +
|
| 104 | + If the logger_file is None, then add stream handler and remove file handler. |
| 105 | + Otherwise, add file handler and remove stream handler. |
| 106 | +
|
| 107 | + :param value: The logger_file path. |
| 108 | + :type: str |
| 109 | + """ |
| 110 | + self.__logger_file = value |
| 111 | + if self.__logger_file: |
| 112 | + # If set logging file, |
| 113 | + # then add file handler and remove stream handler. |
| 114 | + self.logger_file_handler = logging.FileHandler(self.__logger_file) |
| 115 | + self.logger_file_handler.setFormatter(self.logger_formatter) |
| 116 | + for _, logger in iteritems(self.logger): |
| 117 | + logger.addHandler(self.logger_file_handler) |
| 118 | + if self.logger_stream_handler: |
| 119 | + logger.removeHandler(self.logger_stream_handler) |
| 120 | + else: |
| 121 | + # If not set logging file, |
| 122 | + # then add stream handler and remove file handler. |
| 123 | + self.logger_stream_handler = logging.StreamHandler() |
| 124 | + self.logger_stream_handler.setFormatter(self.logger_formatter) |
| 125 | + for _, logger in iteritems(self.logger): |
| 126 | + logger.addHandler(self.logger_stream_handler) |
| 127 | + if self.logger_file_handler: |
| 128 | + logger.removeHandler(self.logger_file_handler) |
| 129 | + |
| 130 | + @property |
| 131 | + def debug(self): |
| 132 | + """ |
| 133 | + Gets the debug status. |
| 134 | + """ |
| 135 | + return self.__debug |
| 136 | + |
| 137 | + @debug.setter |
| 138 | + def debug(self, value): |
| 139 | + """ |
| 140 | + Sets the debug status. |
| 141 | +
|
| 142 | + :param value: The debug status, True or False. |
| 143 | + :type: bool |
| 144 | + """ |
| 145 | + self.__debug = value |
| 146 | + if self.__debug: |
| 147 | + # if debug status is True, turn on debug logging |
| 148 | + for _, logger in iteritems(self.logger): |
| 149 | + logger.setLevel(logging.DEBUG) |
| 150 | + # turn on httplib debug |
| 151 | + httplib.HTTPConnection.debuglevel = 1 |
| 152 | + else: |
| 153 | + # if debug status is False, turn off debug logging, |
| 154 | + # setting log level to default `logging.WARNING` |
| 155 | + for _, logger in iteritems(self.logger): |
| 156 | + logger.setLevel(logging.WARNING) |
| 157 | + # turn off httplib debug |
| 158 | + httplib.HTTPConnection.debuglevel = 0 |
| 159 | + |
| 160 | + @property |
| 161 | + def logger_format(self): |
| 162 | + """ |
| 163 | + Gets the logger_format. |
| 164 | + """ |
| 165 | + return self.__logger_format |
| 166 | + |
| 167 | + @logger_format.setter |
| 168 | + def logger_format(self, value): |
| 169 | + """ |
| 170 | + Sets the logger_format. |
| 171 | +
|
| 172 | + The logger_formatter will be updated when sets logger_format. |
| 173 | +
|
| 174 | + :param value: The format string. |
| 175 | + :type: str |
| 176 | + """ |
| 177 | + self.__logger_format = value |
| 178 | + self.logger_formatter = logging.Formatter(self.__logger_format) |
| 179 | + |
| 180 | + def get_api_key_with_prefix(self, identifier): |
| 181 | + """ |
| 182 | + Gets API key (with prefix if set). |
| 183 | +
|
| 184 | + :param identifier: The identifier of apiKey. |
| 185 | + :return: The token for api key authentication. |
| 186 | + """ |
| 187 | + if self.api_key.get(identifier) and self.api_key_prefix.get(identifier): |
| 188 | + return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier] |
| 189 | + elif self.api_key.get(identifier): |
| 190 | + return self.api_key[identifier] |
| 191 | + |
| 192 | + def get_basic_auth_token(self): |
| 193 | + """ |
| 194 | + Gets HTTP basic authentication header (string). |
| 195 | +
|
| 196 | + :return: The token for basic HTTP authentication. |
| 197 | + """ |
| 198 | + return urllib3.util.make_headers(basic_auth=self.username + ':' + self.password)\ |
| 199 | + .get('authorization') |
| 200 | + |
| 201 | + def auth_settings(self): |
| 202 | + """ |
| 203 | + Gets Auth Settings dict for api client. |
| 204 | +
|
| 205 | + :return: The Auth Settings information dict. |
| 206 | + """ |
| 207 | + return { |
| 208 | + 'BearerToken': |
| 209 | + { |
| 210 | + 'type': 'api_key', |
| 211 | + 'in': 'header', |
| 212 | + 'key': 'authorization', |
| 213 | + 'value': self.get_api_key_with_prefix('authorization') |
| 214 | + }, |
| 215 | + |
| 216 | + } |
| 217 | + |
| 218 | + def to_debug_report(self): |
| 219 | + """ |
| 220 | + Gets the essential information for debugging. |
| 221 | +
|
| 222 | + :return: The report for debugging. |
| 223 | + """ |
| 224 | + return "Python SDK Debug Report:\n"\ |
| 225 | + "OS: {env}\n"\ |
| 226 | + "Python Version: {pyversion}\n"\ |
| 227 | + "Version of the API: v1.5.0-snapshot\n"\ |
| 228 | + "SDK Package Version: 1.0.0-snapshot".\ |
| 229 | + format(env=sys.platform, pyversion=sys.version) |
| 230 | + |
| 231 | + |
| 232 | +configuration = ConfigurationObject() |
| 233 | + |
| 234 | + |
| 235 | +def Configuration(): |
| 236 | + """Simulate a singelton Configuration object for backward compatibility.""" |
| 237 | + return configuration |
0 commit comments