MCPcopy Index your code
hub / github.com/dataforseo/PythonClient / ApiClient

Class ApiClient

dataforseo_client/api_client.py:31–760  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]]
30
31class ApiClient:
32
33 PRIMITIVE_TYPES = (float, bool, bytes, str, int)
34 NATIVE_TYPES_MAPPING = {
35 'int': int,
36 'long': int, # TODO remove as only py3 is supported?
37 'float': float,
38 'str': str,
39 'bool': bool,
40 'date': datetime.date,
41 'datetime': datetime.datetime,
42 'decimal': decimal.Decimal,
43 'object': object,
44 }
45 _pool = None
46
47 def __init__(
48 self,
49 configuration=None,
50 header_name=None,
51 header_value=None,
52 cookie=None
53 ) -> None:
54 # use default configuration if none is provided
55 if configuration is None:
56 configuration = Configuration.get_default()
57 self.configuration = configuration
58
59 self.rest_client = rest.RESTClientObject(configuration)
60 self.default_headers = {}
61 if header_name is not None:
62 self.default_headers[header_name] = header_value
63 self.cookie = cookie
64 # Set default User-Agent.
65 self.user_agent = 'python-client/2.0.26'
66 self.client_side_validation = configuration.client_side_validation
67
68 def __enter__(self):
69 return self
70
71 def __exit__(self, exc_type, exc_value, traceback):
72 pass
73
74 @property
75 def user_agent(self):
76 """User agent for this API client"""
77 return self.default_headers['User-Agent']
78
79 @user_agent.setter
80 def user_agent(self, value):
81 self.default_headers['User-Agent'] = value
82
83 def set_default_header(self, header_name, header_value):
84 self.default_headers[header_name] = header_value
85
86
87 _default = None
88

Callers 1

get_defaultMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected