docusign_esign.client.configuration

Docusign eSignature REST API

The Docusign eSignature REST API provides you with a powerful, convenient, and simple Web services API for interacting with Docusign. # noqa: E501

OpenAPI spec version: v2.1 Contact: devcenter@docusign.com Generated by: https://github.com/swagger-api/swagger-codegen.git

  1# coding: utf-8
  2
  3"""
  4    Docusign eSignature REST API
  5
  6    The Docusign eSignature REST API provides you with a powerful, convenient, and simple Web services API for interacting with Docusign.  # noqa: E501
  7
  8    OpenAPI spec version: v2.1
  9    Contact: devcenter@docusign.com
 10    Generated by: https://github.com/swagger-api/swagger-codegen.git
 11"""
 12
 13
 14from __future__ import absolute_import
 15
 16import copy
 17import logging
 18import multiprocessing
 19import sys
 20import urllib3
 21import platform
 22
 23import six
 24from six.moves import http_client as httplib
 25
 26def singleton(cls, *args, **kw):
 27    instances = {}
 28
 29    def _singleton():
 30        if cls not in instances:
 31            instances[cls] = cls(*args, **kw)
 32        return instances[cls]
 33    return _singleton
 34
 35@singleton
 36class Configuration(object):
 37    """NOTE: This class is auto generated by the swagger code generator program.
 38
 39    Ref: https://github.com/swagger-api/swagger-codegen
 40    Do not edit the class manually.
 41    """
 42
 43    _default = None
 44
 45    def __init__(self):
 46        """Constructor"""
 47        if self._default:
 48            for key in self._default.__dict__.keys():
 49                self.__dict__[key] = copy.copy(self._default.__dict__[key])
 50            return
 51
 52        # Default Base url
 53        self.host = "https://www.docusign.net/restapi"
 54        
 55        # Default api client
 56        self.api_client = None
 57
 58        # Authentication Settings
 59        # dict to store API key(s)
 60        self.api_key = {}
 61        # dict to store API prefix (e.g. Bearer)
 62        self.api_key_prefix = {}
 63        # function to refresh API key if expired
 64        self.refresh_api_key_hook = None
 65        # Username for HTTP basic authentication
 66        self.username = ""
 67        # Password for HTTP basic authentication
 68        self.password = ""
 69
 70        # access token for OAuth
 71        self.access_token = ""
 72
 73        # Logging Settings
 74        self.logger = {}
 75        self.logger["package_logger"] = logging.getLogger("docusign_esign")
 76        self.logger["urllib3_logger"] = logging.getLogger("urllib3")
 77        # Log format
 78        self.logger_format = '%(asctime)s %(levelname)s %(message)s'
 79        # Log stream handler
 80        self.logger_stream_handler = None
 81        # Log file handler
 82        self.logger_file_handler = None
 83        # Debug file location
 84        self.logger_file = None
 85        # Debug switch
 86        self.debug = False
 87
 88        # SSL/TLS verification
 89        # Set this to false to skip verifying SSL certificate when calling API
 90        # from https server.
 91        self.verify_ssl = True
 92        # Set this to customize the certificate file to verify the peer.
 93        self.ssl_ca_cert = None
 94        # client certificate file
 95        self.cert_file = None
 96        # client key file
 97        self.key_file = None
 98        # Set this to True/False to enable/disable SSL hostname verification.
 99        self.assert_hostname = None
100
101        # urllib3 connection pool's maximum number of connections saved
102        # per pool. urllib3 uses 1 connection as default value, but this is
103        # not the best value when you are making a lot of possibly parallel
104        # requests to the same host, which is often the case here.
105        # cpu_count * 5 is used as default value to increase performance.
106        self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
107
108        # Proxy URL
109        self.proxy = None
110        # Safe chars for path_param
111        self.safe_chars_for_path_param = ''
112
113        # Disable client side validation
114        self.client_side_validation = True
115
116        python_version = platform.python_version()
117
118        if six.PY3:
119            self.user_agent = "Swagger-Codegen/v2.1/5.0.0rc2/python3/" + f"{python_version}"
120        else:
121            self.user_agent = "Swagger-Codegen/v2.1/5.0.0rc2/python2/" + f"{python_version}"
122
123
124    @classmethod
125    def set_default(cls, default):
126        cls._default = default
127
128    @property
129    def logger_file(self):
130        """The logger file.
131
132        If the logger_file is None, then add stream handler and remove file
133        handler. Otherwise, add file handler and remove stream handler.
134
135        :param value: The logger_file path.
136        :type: str
137        """
138        return self.__logger_file
139
140    @logger_file.setter
141    def logger_file(self, value):
142        """The logger file.
143
144        If the logger_file is None, then add stream handler and remove file
145        handler. Otherwise, add file handler and remove stream handler.
146
147        :param value: The logger_file path.
148        :type: str
149        """
150        self.__logger_file = value
151        if self.__logger_file:
152            # If set logging file,
153            # then add file handler and remove stream handler.
154            self.logger_file_handler = logging.FileHandler(self.__logger_file)
155            self.logger_file_handler.setFormatter(self.logger_formatter)
156            for _, logger in six.iteritems(self.logger):
157                logger.addHandler(self.logger_file_handler)
158                if self.logger_stream_handler:
159                    logger.removeHandler(self.logger_stream_handler)
160        else:
161            # If not set logging file,
162            # then add stream handler and remove file handler.
163            self.logger_stream_handler = logging.StreamHandler()
164            self.logger_stream_handler.setFormatter(self.logger_formatter)
165            for _, logger in six.iteritems(self.logger):
166                logger.addHandler(self.logger_stream_handler)
167                if self.logger_file_handler:
168                    logger.removeHandler(self.logger_file_handler)
169
170    @property
171    def debug(self):
172        """Debug status
173
174        :param value: The debug status, True or False.
175        :type: bool
176        """
177        return self.__debug
178
179    @debug.setter
180    def debug(self, value):
181        """Debug status
182
183        :param value: The debug status, True or False.
184        :type: bool
185        """
186        self.__debug = value
187        if self.__debug:
188            # if debug status is True, turn on debug logging
189            for _, logger in six.iteritems(self.logger):
190                logger.setLevel(logging.DEBUG)
191            # turn on httplib debug
192            httplib.HTTPConnection.debuglevel = 1
193        else:
194            # if debug status is False, turn off debug logging,
195            # setting log level to default `logging.WARNING`
196            for _, logger in six.iteritems(self.logger):
197                logger.setLevel(logging.WARNING)
198            # turn off httplib debug
199            httplib.HTTPConnection.debuglevel = 0
200
201    @property
202    def logger_format(self):
203        """The logger format.
204
205        The logger_formatter will be updated when sets logger_format.
206
207        :param value: The format string.
208        :type: str
209        """
210        return self.__logger_format
211
212    @logger_format.setter
213    def logger_format(self, value):
214        """The logger format.
215
216        The logger_formatter will be updated when sets logger_format.
217
218        :param value: The format string.
219        :type: str
220        """
221        self.__logger_format = value
222        self.logger_formatter = logging.Formatter(self.__logger_format)
223
224    def get_api_key_with_prefix(self, identifier):
225        """Gets API key (with prefix if set).
226
227        :param identifier: The identifier of apiKey.
228        :return: The token for api key authentication.
229        """
230
231        if self.refresh_api_key_hook:
232            self.refresh_api_key_hook(self)
233
234        key = self.api_key.get(identifier)
235        if key:
236            prefix = self.api_key_prefix.get(identifier)
237            if prefix:
238                return "%s %s" % (prefix, key)
239            else:
240                return key
241
242    def get_basic_auth_token(self):
243        """Gets HTTP basic authentication header (string).
244
245        :return: The token for basic HTTP authentication.
246        """
247        return urllib3.util.make_headers(
248            basic_auth=self.username + ':' + self.password
249        ).get('authorization')
250
251    def auth_settings(self):
252        """Gets Auth Settings dict for api client.
253
254        :return: The Auth Settings information dict.
255        """
256        return {
257
258            'docusignAccessCode':
259                {
260                    'type': 'oauth2',
261                    'in': 'header',
262                    'key': 'Authorization',
263                    'value': 'Bearer ' + self.access_token
264                },
265
266        }
267
268    def to_debug_report(self):
269        """Gets the essential information for debugging.
270
271        :return: The report for debugging.
272        """
273        return "Python SDK Debug Report:\n"\
274               "OS: {env}\n"\
275               "Python Version: {pyversion}\n"\
276               "Version of the API: v2.1\n"\
277               "SDK Package Version: 5.0.0rc2".\
278               format(env=sys.platform, pyversion=sys.version)
def singleton(cls, *args, **kw)
27def singleton(cls, *args, **kw):
28    instances = {}
29
30    def _singleton():
31        if cls not in instances:
32            instances[cls] = cls(*args, **kw)
33        return instances[cls]
34    return _singleton
def Configuration()
30    def _singleton():
31        if cls not in instances:
32            instances[cls] = cls(*args, **kw)
33        return instances[cls]