tesla-api-sdk 1.0.0__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.
- tesla_api_sdk-1.0.0.dist-info/METADATA +145 -0
- tesla_api_sdk-1.0.0.dist-info/RECORD +119 -0
- tesla_api_sdk-1.0.0.dist-info/WHEEL +5 -0
- tesla_api_sdk-1.0.0.dist-info/licenses/LICENSE +28 -0
- tesla_api_sdk-1.0.0.dist-info/top_level.txt +1 -0
- teslafleetmanagementapi/__init__.py +13 -0
- teslafleetmanagementapi/api_helper.py +19 -0
- teslafleetmanagementapi/configuration.py +270 -0
- teslafleetmanagementapi/controllers/__init__.py +11 -0
- teslafleetmanagementapi/controllers/base_controller.py +70 -0
- teslafleetmanagementapi/controllers/charging_controller.py +140 -0
- teslafleetmanagementapi/controllers/energy_controller.py +572 -0
- teslafleetmanagementapi/controllers/oauth_authorization_controller.py +165 -0
- teslafleetmanagementapi/controllers/partner_controller.py +181 -0
- teslafleetmanagementapi/controllers/user_controller.py +158 -0
- teslafleetmanagementapi/controllers/vehicles_controller.py +832 -0
- teslafleetmanagementapi/exceptions/__init__.py +6 -0
- teslafleetmanagementapi/exceptions/api_exception.py +36 -0
- teslafleetmanagementapi/exceptions/oauth_provider_exception.py +75 -0
- teslafleetmanagementapi/http/__init__.py +11 -0
- teslafleetmanagementapi/http/api_response.py +67 -0
- teslafleetmanagementapi/http/auth/__init__.py +6 -0
- teslafleetmanagementapi/http/auth/bearer_auth.py +103 -0
- teslafleetmanagementapi/http/auth/oauth_2.py +311 -0
- teslafleetmanagementapi/http/http_call_back.py +20 -0
- teslafleetmanagementapi/http/http_client_provider.py +23 -0
- teslafleetmanagementapi/http/http_method_enum.py +25 -0
- teslafleetmanagementapi/http/http_request.py +55 -0
- teslafleetmanagementapi/http/http_response.py +45 -0
- teslafleetmanagementapi/http/proxy_settings.py +50 -0
- teslafleetmanagementapi/logging/__init__.py +6 -0
- teslafleetmanagementapi/logging/configuration/__init__.py +5 -0
- teslafleetmanagementapi/logging/configuration/api_logging_configuration.py +398 -0
- teslafleetmanagementapi/logging/sdk_logger.py +28 -0
- teslafleetmanagementapi/models/__init__.py +85 -0
- teslafleetmanagementapi/models/api_1_dx_vehicles_options_response.py +110 -0
- teslafleetmanagementapi/models/api_1_dx_warranty_details_response.py +110 -0
- teslafleetmanagementapi/models/api_1_vehicles_mobile_enabled_response.py +109 -0
- teslafleetmanagementapi/models/api_1_vehicles_nearby_charging_sites_response.py +109 -0
- teslafleetmanagementapi/models/api_1_vehicles_response.py +162 -0
- teslafleetmanagementapi/models/api_1_vehicles_response_get_vehicle.py +109 -0
- teslafleetmanagementapi/models/api_1_vehicles_wake_up_response.py +109 -0
- teslafleetmanagementapi/models/backup_request.py +92 -0
- teslafleetmanagementapi/models/backup_response.py +95 -0
- teslafleetmanagementapi/models/calendar_history_response.py +96 -0
- teslafleetmanagementapi/models/charge_duration.py +92 -0
- teslafleetmanagementapi/models/charge_history.py +125 -0
- teslafleetmanagementapi/models/charge_history_response.py +96 -0
- teslafleetmanagementapi/models/charge_start_time.py +92 -0
- teslafleetmanagementapi/models/charging_dimension.py +128 -0
- teslafleetmanagementapi/models/charging_fee.py +641 -0
- teslafleetmanagementapi/models/charging_history_data.py +98 -0
- teslafleetmanagementapi/models/charging_history_item.py +336 -0
- teslafleetmanagementapi/models/charging_history_response.py +96 -0
- teslafleetmanagementapi/models/charging_invoice.py +151 -0
- teslafleetmanagementapi/models/charging_location.py +293 -0
- teslafleetmanagementapi/models/charging_period.py +136 -0
- teslafleetmanagementapi/models/charging_session.py +355 -0
- teslafleetmanagementapi/models/charging_sessions_data.py +182 -0
- teslafleetmanagementapi/models/charging_sessions_response.py +96 -0
- teslafleetmanagementapi/models/default_real_mode.py +45 -0
- teslafleetmanagementapi/models/driver.py +289 -0
- teslafleetmanagementapi/models/drivers_response.py +135 -0
- teslafleetmanagementapi/models/enterprise_payer_request.py +141 -0
- teslafleetmanagementapi/models/event.py +107 -0
- teslafleetmanagementapi/models/fleet_status_request.py +105 -0
- teslafleetmanagementapi/models/fleet_telemetry_error.py +118 -0
- teslafleetmanagementapi/models/fleet_telemetry_errors_response.py +96 -0
- teslafleetmanagementapi/models/fleet_telemetry_jws_request.py +128 -0
- teslafleetmanagementapi/models/generic_update_response.py +95 -0
- teslafleetmanagementapi/models/kind.py +45 -0
- teslafleetmanagementapi/models/kind_get_wall_connector_charging_history.py +42 -0
- teslafleetmanagementapi/models/live_status_response.py +96 -0
- teslafleetmanagementapi/models/location.py +128 -0
- teslafleetmanagementapi/models/location_1.py +128 -0
- teslafleetmanagementapi/models/me_response.py +95 -0
- teslafleetmanagementapi/models/mobile_enabled.py +128 -0
- teslafleetmanagementapi/models/oauth_provider_error.py +67 -0
- teslafleetmanagementapi/models/oauth_token.py +115 -0
- teslafleetmanagementapi/models/off_grid_vehicle_charging_reserve_request.py +95 -0
- teslafleetmanagementapi/models/operation_request.py +93 -0
- teslafleetmanagementapi/models/orders_response.py +111 -0
- teslafleetmanagementapi/models/pagination.py +225 -0
- teslafleetmanagementapi/models/price_component.py +151 -0
- teslafleetmanagementapi/models/products_response.py +128 -0
- teslafleetmanagementapi/models/public_key_response.py +96 -0
- teslafleetmanagementapi/models/region_response.py +96 -0
- teslafleetmanagementapi/models/register_partner_request.py +92 -0
- teslafleetmanagementapi/models/register_partner_response.py +96 -0
- teslafleetmanagementapi/models/response.py +105 -0
- teslafleetmanagementapi/models/response_1.py +92 -0
- teslafleetmanagementapi/models/response_2.py +95 -0
- teslafleetmanagementapi/models/response_3.py +164 -0
- teslafleetmanagementapi/models/response_api_1_dx_vehicles_options_response.py +112 -0
- teslafleetmanagementapi/models/response_api_1_dx_warranty_details_response.py +169 -0
- teslafleetmanagementapi/models/response_calendar_history_response.py +110 -0
- teslafleetmanagementapi/models/response_charge_history_response.py +98 -0
- teslafleetmanagementapi/models/response_fleet_telemetry_errors_response.py +98 -0
- teslafleetmanagementapi/models/response_live_status_response.py +310 -0
- teslafleetmanagementapi/models/response_me_response.py +131 -0
- teslafleetmanagementapi/models/response_orders_response.py +209 -0
- teslafleetmanagementapi/models/response_public_key_response.py +92 -0
- teslafleetmanagementapi/models/response_region_response.py +105 -0
- teslafleetmanagementapi/models/response_register_partner_response.py +331 -0
- teslafleetmanagementapi/models/signaling.py +118 -0
- teslafleetmanagementapi/models/simple_ok_response.py +105 -0
- teslafleetmanagementapi/models/site_info_response.py +105 -0
- teslafleetmanagementapi/models/storm_mode_request.py +92 -0
- teslafleetmanagementapi/models/tariff_element.py +136 -0
- teslafleetmanagementapi/models/tariffs.py +136 -0
- teslafleetmanagementapi/models/time_of_use_settings_request.py +95 -0
- teslafleetmanagementapi/models/total_cost.py +151 -0
- teslafleetmanagementapi/models/tou_settings.py +105 -0
- teslafleetmanagementapi/models/vehicle_base.py +266 -0
- teslafleetmanagementapi/models/vehicle_option.py +178 -0
- teslafleetmanagementapi/models/warranty_item.py +249 -0
- teslafleetmanagementapi/teslafleetmanagementapi_client.py +128 -0
- teslafleetmanagementapi/utilities/__init__.py +6 -0
- teslafleetmanagementapi/utilities/file_wrapper.py +45 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
"""
|
|
3
|
+
teslafleetmanagementapi
|
|
4
|
+
|
|
5
|
+
This file was automatically generated by APIMATIC v3.0 (
|
|
6
|
+
https://www.apimatic.io ).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from apimatic_core.http.request.http_request import HttpRequest as CoreHttpRequest
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class HttpRequest(CoreHttpRequest):
|
|
13
|
+
"""
|
|
14
|
+
Represent an HTTP request to be sent to the server.
|
|
15
|
+
|
|
16
|
+
Encapsulates request details such as the HTTP method, target URL, headers,
|
|
17
|
+
query parameters, body parameters, and any files included with the request.
|
|
18
|
+
|
|
19
|
+
Attributes:
|
|
20
|
+
http_method: The HTTP method to use for the request.
|
|
21
|
+
query_url (str): The URL to which the request will be sent.
|
|
22
|
+
headers (dict[str, str] | None): Headers to include with the request.
|
|
23
|
+
query_parameters (dict[str, str] | None): Query parameters appended
|
|
24
|
+
to the request URL.
|
|
25
|
+
parameters (dict[str, str] | None): Form or body parameters sent
|
|
26
|
+
with the request.
|
|
27
|
+
files (dict | None): Files to be sent with the request.
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self,
|
|
32
|
+
http_method,
|
|
33
|
+
query_url,
|
|
34
|
+
headers=None,
|
|
35
|
+
query_parameters=None,
|
|
36
|
+
parameters=None,
|
|
37
|
+
files=None):
|
|
38
|
+
"""
|
|
39
|
+
Initialize an HttpRequest instance.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
http_method: The HTTP method to use for the request.
|
|
43
|
+
query_url: The URL to which the request will be sent.
|
|
44
|
+
headers: Headers to include with the request.
|
|
45
|
+
query_parameters: Query parameters appended to the request URL.
|
|
46
|
+
parameters: Form or body parameters sent with the request.
|
|
47
|
+
files: Files to be sent with the request.
|
|
48
|
+
|
|
49
|
+
"""
|
|
50
|
+
super().__init__(http_method,
|
|
51
|
+
query_url,
|
|
52
|
+
headers,
|
|
53
|
+
query_parameters,
|
|
54
|
+
parameters,
|
|
55
|
+
files)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
"""
|
|
3
|
+
teslafleetmanagementapi
|
|
4
|
+
|
|
5
|
+
This file was automatically generated by APIMATIC v3.0 (
|
|
6
|
+
https://www.apimatic.io ).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from apimatic_core.http.response.http_response import HttpResponse as CoreHttpResponse
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class HttpResponse(CoreHttpResponse):
|
|
13
|
+
"""
|
|
14
|
+
Represent an HTTP response returned by the server.
|
|
15
|
+
|
|
16
|
+
Stores response metadata such as status code, reason phrase, headers, and
|
|
17
|
+
the raw response body, along with the originating request.
|
|
18
|
+
|
|
19
|
+
Attributes:
|
|
20
|
+
status_code (int): The HTTP status code returned by the server.
|
|
21
|
+
reason_phrase (str): The reason phrase associated with the status code.
|
|
22
|
+
headers (dict[str, str]): Response headers as key-value pairs.
|
|
23
|
+
text (str): The raw response body as a string.
|
|
24
|
+
request: The request object that resulted in this response.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self,
|
|
29
|
+
status_code,
|
|
30
|
+
reason_phrase,
|
|
31
|
+
headers,
|
|
32
|
+
text,
|
|
33
|
+
request):
|
|
34
|
+
"""
|
|
35
|
+
Initialize an HttpResponse instance.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
status_code: The HTTP status code returned by the server.
|
|
39
|
+
reason_phrase: The reason phrase associated with the status code.
|
|
40
|
+
headers: Response headers as key-value pairs.
|
|
41
|
+
text: The raw response body as a string.
|
|
42
|
+
request: The request object that resulted in this response.
|
|
43
|
+
|
|
44
|
+
"""
|
|
45
|
+
super().__init__(status_code, reason_phrase, headers, text, request)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""
|
|
2
|
+
teslafleetmanagementapi
|
|
3
|
+
|
|
4
|
+
This file was automatically generated by APIMATIC v3.0 (
|
|
5
|
+
https://www.apimatic.io ).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
from typing import Optional
|
|
10
|
+
|
|
11
|
+
from apimatic_core.http.configurations.proxy_settings import (
|
|
12
|
+
ProxySettings as CoreProxySettings,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ProxySettings(CoreProxySettings):
|
|
17
|
+
"""A simple data model for configuring HTTP(S) proxy settings."""
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def from_environment(cls) -> Optional["ProxySettings"]:
|
|
21
|
+
"""
|
|
22
|
+
Create an instance of this class using environment-based configuration.
|
|
23
|
+
|
|
24
|
+
This method attempts to construct and return an instance using relevant
|
|
25
|
+
environment variables, if available. If the required configuration is
|
|
26
|
+
not present, it may return `None` to indicate that no valid instance
|
|
27
|
+
could be created.
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
Optional[cls]: A configured instance of this class, or `None` if
|
|
31
|
+
configuration data is missing or invalid.
|
|
32
|
+
|
|
33
|
+
"""
|
|
34
|
+
address = os.getenv("PROXY_ADDRESS", None)
|
|
35
|
+
if not address:
|
|
36
|
+
return None
|
|
37
|
+
|
|
38
|
+
port = os.getenv("PROXY_PORT", None)
|
|
39
|
+
if port is not None:
|
|
40
|
+
try:
|
|
41
|
+
port = int(port)
|
|
42
|
+
except (TypeError, ValueError):
|
|
43
|
+
port = None
|
|
44
|
+
|
|
45
|
+
return cls(
|
|
46
|
+
address=address,
|
|
47
|
+
port=port,
|
|
48
|
+
username=os.getenv("PROXY_USERNAME", None),
|
|
49
|
+
password=os.getenv("PROXY_PASSWORD", None),
|
|
50
|
+
)
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
|
|
2
|
+
"""
|
|
3
|
+
teslafleetmanagementapi
|
|
4
|
+
|
|
5
|
+
This file was automatically generated by APIMATIC v3.0 (
|
|
6
|
+
https://www.apimatic.io ).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
import os
|
|
11
|
+
|
|
12
|
+
from apimatic_core.logger.configuration.api_logging_configuration import (
|
|
13
|
+
ApiLoggingConfiguration,
|
|
14
|
+
ApiRequestLoggingConfiguration,
|
|
15
|
+
ApiResponseLoggingConfiguration,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class RequestLoggingConfiguration(ApiRequestLoggingConfiguration):
|
|
20
|
+
"""
|
|
21
|
+
Configuration for controlling how API request details are logged.
|
|
22
|
+
Provides options to include or exclude data such as headers, query
|
|
23
|
+
parameters and request body to support flexible logging behavior.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(self, log_body=False, log_headers=False, headers_to_include=None,
|
|
27
|
+
headers_to_exclude=None, headers_to_unmask=None,
|
|
28
|
+
include_query_in_path=False):
|
|
29
|
+
"""
|
|
30
|
+
Initialize the Request Logging Configuration.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
log_body (bool): Controls the logging of the request body.
|
|
34
|
+
log_headers (bool): Controls the logging of request headers.
|
|
35
|
+
headers_to_include (List[str]): Includes only specified headers in
|
|
36
|
+
the log output.
|
|
37
|
+
headers_to_exclude (List[str]): Excludes specified headers from
|
|
38
|
+
the log output.
|
|
39
|
+
headers_to_unmask (List[str]): Logs specified headers without masking,
|
|
40
|
+
revealing their actual values.
|
|
41
|
+
include_query_in_path (bool): Determines whether to include query
|
|
42
|
+
parameters in the logged request path.
|
|
43
|
+
|
|
44
|
+
"""
|
|
45
|
+
super().__init__(
|
|
46
|
+
log_body,
|
|
47
|
+
log_headers,
|
|
48
|
+
headers_to_include,
|
|
49
|
+
headers_to_exclude,
|
|
50
|
+
headers_to_unmask,
|
|
51
|
+
include_query_in_path,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
def clone_with(self, log_body=None, log_headers=None,
|
|
55
|
+
headers_to_include=None, headers_to_exclude=None,
|
|
56
|
+
headers_to_unmask=None, include_query_in_path=False):
|
|
57
|
+
"""
|
|
58
|
+
Create a copy of this configuration with overridden attributes.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
log_body (bool): Optional override for logging the body.
|
|
62
|
+
log_headers (bool): Optional override for logging headers.
|
|
63
|
+
headers_to_include (List[str]): Optional override for included headers.
|
|
64
|
+
headers_to_exclude (List[str]): Optional override for excluded headers.
|
|
65
|
+
headers_to_unmask (List[str]): Optional override for unmasked headers.
|
|
66
|
+
include_query_in_path (bool): Optional override for including queries.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
RequestLoggingConfiguration: A new configuration instance.
|
|
70
|
+
|
|
71
|
+
"""
|
|
72
|
+
log_body = log_body or self.log_body
|
|
73
|
+
log_headers = log_headers or self.log_headers
|
|
74
|
+
headers_to_include = headers_to_include or self.headers_to_include
|
|
75
|
+
headers_to_exclude = headers_to_exclude or self.headers_to_exclude
|
|
76
|
+
headers_to_unmask = headers_to_unmask or self.headers_to_unmask
|
|
77
|
+
include_query_in_path = include_query_in_path or self.include_query_in_path
|
|
78
|
+
|
|
79
|
+
return RequestLoggingConfiguration(
|
|
80
|
+
log_body,
|
|
81
|
+
log_headers,
|
|
82
|
+
headers_to_include,
|
|
83
|
+
headers_to_exclude,
|
|
84
|
+
headers_to_unmask,
|
|
85
|
+
include_query_in_path,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
@classmethod
|
|
89
|
+
def from_dict(cls, dictionary):
|
|
90
|
+
"""
|
|
91
|
+
Create an instance of RequestLoggingConfiguration from a dictionary.
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
dictionary (dict): The input data to convert from.
|
|
95
|
+
|
|
96
|
+
"""
|
|
97
|
+
if not dictionary:
|
|
98
|
+
return cls()
|
|
99
|
+
|
|
100
|
+
headers_to_include = dictionary.get("headers_to_include")
|
|
101
|
+
headers_to_include = [
|
|
102
|
+
v.strip() for v in headers_to_include.split(",") if v.strip()
|
|
103
|
+
] if headers_to_include else None
|
|
104
|
+
|
|
105
|
+
headers_to_exclude = dictionary.get("headers_to_exclude")
|
|
106
|
+
headers_to_exclude = [
|
|
107
|
+
v.strip() for v in headers_to_exclude.split(",") if v.strip()
|
|
108
|
+
] if headers_to_exclude else None
|
|
109
|
+
|
|
110
|
+
headers_to_unmask = dictionary.get("headers_to_unmask")
|
|
111
|
+
headers_to_unmask = [
|
|
112
|
+
v.strip() for v in headers_to_unmask.split(",") if v.strip()
|
|
113
|
+
] if headers_to_unmask else None
|
|
114
|
+
|
|
115
|
+
return cls(
|
|
116
|
+
log_body=dictionary.get("log_body", False),
|
|
117
|
+
log_headers=dictionary.get("log_headers", False),
|
|
118
|
+
headers_to_include=headers_to_include,
|
|
119
|
+
headers_to_exclude=headers_to_exclude,
|
|
120
|
+
headers_to_unmask=headers_to_unmask,
|
|
121
|
+
include_query_in_path=dictionary.get("include_query_in_path", False),
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
class ResponseLoggingConfiguration(ApiResponseLoggingConfiguration):
|
|
125
|
+
"""
|
|
126
|
+
Configuration for controlling how API response details are logged.
|
|
127
|
+
Supports selective logging of headers and body data while allowing
|
|
128
|
+
masking of sensitive response information.
|
|
129
|
+
"""
|
|
130
|
+
|
|
131
|
+
def __init__(self, log_body=False, log_headers=False, headers_to_include=None,
|
|
132
|
+
headers_to_exclude=None, headers_to_unmask=None):
|
|
133
|
+
"""
|
|
134
|
+
Initialize the Response Logging Configuration.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
log_body (bool): Controls the logging of the request body.
|
|
138
|
+
log_headers (bool): Controls the logging of request headers.
|
|
139
|
+
headers_to_include (List[str]): Includes only specified headers in the log
|
|
140
|
+
output.
|
|
141
|
+
headers_to_exclude (List[str]): Excludes specified headers from the log
|
|
142
|
+
output.
|
|
143
|
+
headers_to_unmask (List[str]): Logs specified headers without
|
|
144
|
+
masking, revealing their actual values.
|
|
145
|
+
|
|
146
|
+
"""
|
|
147
|
+
super().__init__(
|
|
148
|
+
log_body,
|
|
149
|
+
log_headers,
|
|
150
|
+
headers_to_include,
|
|
151
|
+
headers_to_exclude,
|
|
152
|
+
headers_to_unmask,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
def clone_with(self, log_body=None, log_headers=None,
|
|
156
|
+
headers_to_include=None, headers_to_exclude=None,
|
|
157
|
+
headers_to_unmask=None):
|
|
158
|
+
"""
|
|
159
|
+
Create a copy of this configuration with overridden attributes.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
log_body (bool): Optional override for logging the body.
|
|
163
|
+
log_headers (bool): Optional override for logging headers.
|
|
164
|
+
headers_to_include (List[str]): Optional override for included headers.
|
|
165
|
+
headers_to_exclude (List[str]): Optional override for excluded headers.
|
|
166
|
+
headers_to_unmask (List[str]): Optional override for unmasked headers.
|
|
167
|
+
|
|
168
|
+
Returns:
|
|
169
|
+
ResponseLoggingConfiguration: A new configuration instance.
|
|
170
|
+
|
|
171
|
+
"""
|
|
172
|
+
log_body = log_body or self.log_body
|
|
173
|
+
log_headers = log_headers or self.log_headers
|
|
174
|
+
headers_to_include = headers_to_include or self.headers_to_include
|
|
175
|
+
headers_to_exclude = headers_to_exclude or self.headers_to_exclude
|
|
176
|
+
headers_to_unmask = headers_to_unmask or self.headers_to_unmask
|
|
177
|
+
|
|
178
|
+
return ResponseLoggingConfiguration(
|
|
179
|
+
log_body,
|
|
180
|
+
log_headers,
|
|
181
|
+
headers_to_include,
|
|
182
|
+
headers_to_exclude,
|
|
183
|
+
headers_to_unmask,
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
@classmethod
|
|
187
|
+
def from_dict(cls, dictionary):
|
|
188
|
+
"""
|
|
189
|
+
Create an instance of ResponseLoggingConfiguration from a dictionary.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
dictionary (dict): The input data to convert from.
|
|
193
|
+
|
|
194
|
+
"""
|
|
195
|
+
if not dictionary:
|
|
196
|
+
return cls()
|
|
197
|
+
|
|
198
|
+
headers_to_include = dictionary.get("headers_to_include")
|
|
199
|
+
headers_to_include = [
|
|
200
|
+
v.strip() for v in headers_to_include.split(",") if v.strip()
|
|
201
|
+
] if headers_to_include else None
|
|
202
|
+
|
|
203
|
+
headers_to_exclude = dictionary.get("headers_to_exclude")
|
|
204
|
+
headers_to_exclude = [
|
|
205
|
+
v.strip() for v in headers_to_exclude.split(",") if v.strip()
|
|
206
|
+
] if headers_to_exclude else None
|
|
207
|
+
|
|
208
|
+
headers_to_unmask = dictionary.get("headers_to_unmask")
|
|
209
|
+
headers_to_unmask = [
|
|
210
|
+
v.strip() for v in headers_to_unmask.split(",") if v.strip()
|
|
211
|
+
] if headers_to_unmask else None
|
|
212
|
+
|
|
213
|
+
return cls(
|
|
214
|
+
log_body=dictionary.get("log_body", False),
|
|
215
|
+
log_headers=dictionary.get("log_headers", False),
|
|
216
|
+
headers_to_include=headers_to_include,
|
|
217
|
+
headers_to_exclude=headers_to_exclude,
|
|
218
|
+
headers_to_unmask=headers_to_unmask,
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
class LoggingConfiguration(ApiLoggingConfiguration):
|
|
222
|
+
"""
|
|
223
|
+
High-level configuration for API logging behavior. Aggregates both
|
|
224
|
+
request and response logging settings and applies shared options such
|
|
225
|
+
as log level and header masking across log events.
|
|
226
|
+
"""
|
|
227
|
+
|
|
228
|
+
def __init__(self, logger=None, log_level=None, mask_sensitive_headers=True,
|
|
229
|
+
request_logging_config=None, response_logging_config=None):
|
|
230
|
+
"""
|
|
231
|
+
Initialize the Logging Configuration.
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
logger (Logger): The logging implementation to log with.
|
|
235
|
+
log_level (LogLevel): The log level to apply to the log message.
|
|
236
|
+
mask_sensitive_headers (bool): Flag to control masking of sensitive headers.
|
|
237
|
+
request_logging_config (RequestLoggingConfiguration): The API request
|
|
238
|
+
logging configuration.
|
|
239
|
+
response_logging_config (ResponseLoggingConfiguration): The API response
|
|
240
|
+
logging configuration.
|
|
241
|
+
|
|
242
|
+
"""
|
|
243
|
+
request_logging_config = request_logging_config or RequestLoggingConfiguration()
|
|
244
|
+
response_logging_config =\
|
|
245
|
+
response_logging_config or ResponseLoggingConfiguration()
|
|
246
|
+
super().__init__(
|
|
247
|
+
logger,
|
|
248
|
+
log_level,
|
|
249
|
+
mask_sensitive_headers,
|
|
250
|
+
request_logging_config,
|
|
251
|
+
response_logging_config,
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
def clone_with(self, logger=None, log_level=None, mask_sensitive_headers=None,
|
|
255
|
+
request_logging_config=None, response_logging_config=None):
|
|
256
|
+
"""
|
|
257
|
+
Create a copy of this configuration with overridden attributes.
|
|
258
|
+
|
|
259
|
+
Args:
|
|
260
|
+
logger (Logger): Optional override for the logging implementation.
|
|
261
|
+
log_level (bool): Optional override for logging level.
|
|
262
|
+
mask_sensitive_headers (bool): Optional override for masking headers.
|
|
263
|
+
request_logging_config (RequestLoggingConfiguration): Optional
|
|
264
|
+
override for request logging configuration.
|
|
265
|
+
response_logging_config (ResponseLoggingConfiguration): Optional
|
|
266
|
+
override for response logging configuration.
|
|
267
|
+
|
|
268
|
+
Returns:
|
|
269
|
+
LoggingConfiguration: A new configuration instance.
|
|
270
|
+
|
|
271
|
+
"""
|
|
272
|
+
logger = logger or self.logger
|
|
273
|
+
log_level = log_level or self.log_level
|
|
274
|
+
mask_sensitive_headers = mask_sensitive_headers or self.mask_sensitive_headers
|
|
275
|
+
request_logging_config = request_logging_config or self.request_logging_config
|
|
276
|
+
response_logging_config =\
|
|
277
|
+
response_logging_config or self.response_logging_config
|
|
278
|
+
|
|
279
|
+
return LoggingConfiguration(
|
|
280
|
+
logger,
|
|
281
|
+
log_level,
|
|
282
|
+
mask_sensitive_headers,
|
|
283
|
+
request_logging_config,
|
|
284
|
+
response_logging_config,
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
@classmethod
|
|
288
|
+
def from_dict(cls, dictionary):
|
|
289
|
+
"""
|
|
290
|
+
Create an instance of LoggingConfiguration from a dictionary.
|
|
291
|
+
Supports nested request/response logging config dictionaries.
|
|
292
|
+
|
|
293
|
+
Args:
|
|
294
|
+
dictionary (dict): The input data to convert from.
|
|
295
|
+
|
|
296
|
+
"""
|
|
297
|
+
if not dictionary:
|
|
298
|
+
return None
|
|
299
|
+
|
|
300
|
+
req_config_dict = dictionary.get("request_logging_config") or {}
|
|
301
|
+
res_config_dict = dictionary.get("response_logging_config") or {}
|
|
302
|
+
|
|
303
|
+
return cls(
|
|
304
|
+
logger=dictionary.get("logger"),
|
|
305
|
+
log_level=dictionary.get("log_level"),
|
|
306
|
+
mask_sensitive_headers=dictionary.get("mask_sensitive_headers", True),
|
|
307
|
+
request_logging_config=RequestLoggingConfiguration.from_dict(req_config_dict),
|
|
308
|
+
response_logging_config=ResponseLoggingConfiguration.from_dict(res_config_dict),
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
@classmethod
|
|
312
|
+
def from_environment(cls):
|
|
313
|
+
"""
|
|
314
|
+
Create a LoggingConfiguration instance based on environment variables.
|
|
315
|
+
Environment flags determine whether logging is enabled and how it is
|
|
316
|
+
configured for requests and responses.
|
|
317
|
+
"""
|
|
318
|
+
request_logging_env = {
|
|
319
|
+
"log_body": os.getenv("REQUEST_LOG_BODY", None),
|
|
320
|
+
"log_headers": os.getenv("REQUEST_LOG_HEADERS", None),
|
|
321
|
+
"headers_to_include": os.getenv("REQUEST_HEADERS_TO_INCLUDE", None),
|
|
322
|
+
"headers_to_exclude": os.getenv("REQUEST_HEADERS_TO_EXCLUDE", None),
|
|
323
|
+
"headers_to_unmask": os.getenv("REQUEST_HEADERS_TO_UNMASK", None),
|
|
324
|
+
"include_query_in_path": os.getenv("REQUEST_INCLUDE_QUERY_IN_PATH", None),
|
|
325
|
+
}
|
|
326
|
+
# Only include if at least one env var is set
|
|
327
|
+
request_logging_config = (
|
|
328
|
+
{k: (v.lower() == "true" if v and v.lower() in ["true", "false"] else v)
|
|
329
|
+
for k, v in request_logging_env.items() if v is not None}
|
|
330
|
+
or None
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
# Collect environment variables for response logging
|
|
334
|
+
response_logging_env = {
|
|
335
|
+
"log_body": os.getenv("RESPONSE_LOG_BODY", None),
|
|
336
|
+
"log_headers": os.getenv("RESPONSE_LOG_HEADERS", None),
|
|
337
|
+
"headers_to_include": os.getenv("RESPONSE_HEADERS_TO_INCLUDE", None),
|
|
338
|
+
"headers_to_exclude": os.getenv("RESPONSE_HEADERS_TO_EXCLUDE", None),
|
|
339
|
+
"headers_to_unmask": os.getenv("RESPONSE_HEADERS_TO_UNMASK", None),
|
|
340
|
+
}
|
|
341
|
+
response_logging_config = (
|
|
342
|
+
{k: (v.lower() == "true" if v and v.lower() in ["true", "false"] else v)
|
|
343
|
+
for k, v in response_logging_env.items() if v is not None}
|
|
344
|
+
or None
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
# Determine if any logging-related env variable is set
|
|
348
|
+
has_logging_env = any([
|
|
349
|
+
os.getenv("LOG_LEVEL", None),
|
|
350
|
+
os.getenv("MASK_SENSITIVE_HEADERS", None),
|
|
351
|
+
request_logging_config,
|
|
352
|
+
response_logging_config,
|
|
353
|
+
])
|
|
354
|
+
|
|
355
|
+
log_level = cls._resolve_level(os.getenv("LOG_LEVEL", None))
|
|
356
|
+
|
|
357
|
+
# Only instantiate LoggingConfiguration if something is configured
|
|
358
|
+
return cls.from_dict({
|
|
359
|
+
"log_level": log_level,
|
|
360
|
+
"mask_sensitive_headers": os.getenv("MASK_SENSITIVE_HEADERS",
|
|
361
|
+
"true").lower() == "true",
|
|
362
|
+
"request_logging_config": request_logging_config,
|
|
363
|
+
"response_logging_config": response_logging_config,
|
|
364
|
+
}) if has_logging_env else None
|
|
365
|
+
|
|
366
|
+
@staticmethod
|
|
367
|
+
def _resolve_level(value):
|
|
368
|
+
"""
|
|
369
|
+
Resolve a log level from a string or numeric representation.
|
|
370
|
+
|
|
371
|
+
Args:
|
|
372
|
+
value (str|int): The desired level or its textual name.
|
|
373
|
+
|
|
374
|
+
Returns:
|
|
375
|
+
int: The resolved Python logging level constant.
|
|
376
|
+
|
|
377
|
+
"""
|
|
378
|
+
if value is None:
|
|
379
|
+
return None
|
|
380
|
+
|
|
381
|
+
possible_levels = {
|
|
382
|
+
logging.CRITICAL,
|
|
383
|
+
logging.ERROR,
|
|
384
|
+
logging.WARNING,
|
|
385
|
+
logging.INFO,
|
|
386
|
+
logging.DEBUG,
|
|
387
|
+
logging.NOTSET,
|
|
388
|
+
}
|
|
389
|
+
# handle numeric values (string or int)
|
|
390
|
+
if value.isdigit():
|
|
391
|
+
return int(value) if int(value) in possible_levels else logging.INFO
|
|
392
|
+
# handle string log level names
|
|
393
|
+
if isinstance(value, str):
|
|
394
|
+
level = logging.getLevelName(value.upper())
|
|
395
|
+
if isinstance(level, int):
|
|
396
|
+
return level
|
|
397
|
+
|
|
398
|
+
return logging.INFO
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
"""
|
|
3
|
+
teslafleetmanagementapi
|
|
4
|
+
|
|
5
|
+
This file was automatically generated by APIMATIC v3.0 (
|
|
6
|
+
https://www.apimatic.io ).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from abc import abstractmethod
|
|
10
|
+
|
|
11
|
+
from apimatic_core_interfaces.logger.logger import Logger
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AbstractLogger(Logger):
|
|
15
|
+
"""An abstract class for custom logger implementation."""
|
|
16
|
+
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def log(self, level, message, params):
|
|
19
|
+
"""
|
|
20
|
+
Log a message with a specified log level and additional parameters.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
level (int): The log level of the message.
|
|
24
|
+
message (str): The message to log.
|
|
25
|
+
params (dict): Additional parameters to include in the log message.
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
...
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# ruff: noqa: D104 | Missing docstring in public package
|
|
2
|
+
# ruff: noqa: RUF022 | `__all__` is not sorted
|
|
3
|
+
__all__ = [
|
|
4
|
+
"api_1_dx_vehicles_options_response",
|
|
5
|
+
"api_1_dx_warranty_details_response",
|
|
6
|
+
"api_1_vehicles_mobile_enabled_response",
|
|
7
|
+
"api_1_vehicles_nearby_charging_sites_response",
|
|
8
|
+
"api_1_vehicles_response",
|
|
9
|
+
"api_1_vehicles_response_get_vehicle",
|
|
10
|
+
"api_1_vehicles_wake_up_response",
|
|
11
|
+
"backup_request",
|
|
12
|
+
"backup_response",
|
|
13
|
+
"calendar_history_response",
|
|
14
|
+
"charge_duration",
|
|
15
|
+
"charge_history",
|
|
16
|
+
"charge_history_response",
|
|
17
|
+
"charge_start_time",
|
|
18
|
+
"charging_dimension",
|
|
19
|
+
"charging_fee",
|
|
20
|
+
"charging_history_data",
|
|
21
|
+
"charging_history_item",
|
|
22
|
+
"charging_history_response",
|
|
23
|
+
"charging_invoice",
|
|
24
|
+
"charging_location",
|
|
25
|
+
"charging_period",
|
|
26
|
+
"charging_session",
|
|
27
|
+
"charging_sessions_data",
|
|
28
|
+
"charging_sessions_response",
|
|
29
|
+
"default_real_mode",
|
|
30
|
+
"driver",
|
|
31
|
+
"drivers_response",
|
|
32
|
+
"enterprise_payer_request",
|
|
33
|
+
"event",
|
|
34
|
+
"fleet_status_request",
|
|
35
|
+
"fleet_telemetry_error",
|
|
36
|
+
"fleet_telemetry_errors_response",
|
|
37
|
+
"fleet_telemetry_jws_request",
|
|
38
|
+
"generic_update_response",
|
|
39
|
+
"kind",
|
|
40
|
+
"kind_get_wall_connector_charging_history",
|
|
41
|
+
"live_status_response",
|
|
42
|
+
"location",
|
|
43
|
+
"location_1",
|
|
44
|
+
"me_response",
|
|
45
|
+
"mobile_enabled",
|
|
46
|
+
"oauth_provider_error",
|
|
47
|
+
"oauth_token",
|
|
48
|
+
"off_grid_vehicle_charging_reserve_request",
|
|
49
|
+
"operation_request",
|
|
50
|
+
"orders_response",
|
|
51
|
+
"pagination",
|
|
52
|
+
"price_component",
|
|
53
|
+
"products_response",
|
|
54
|
+
"public_key_response",
|
|
55
|
+
"region_response",
|
|
56
|
+
"register_partner_request",
|
|
57
|
+
"register_partner_response",
|
|
58
|
+
"response",
|
|
59
|
+
"response_1",
|
|
60
|
+
"response_2",
|
|
61
|
+
"response_3",
|
|
62
|
+
"response_api_1_dx_vehicles_options_response",
|
|
63
|
+
"response_api_1_dx_warranty_details_response",
|
|
64
|
+
"response_calendar_history_response",
|
|
65
|
+
"response_charge_history_response",
|
|
66
|
+
"response_fleet_telemetry_errors_response",
|
|
67
|
+
"response_live_status_response",
|
|
68
|
+
"response_me_response",
|
|
69
|
+
"response_orders_response",
|
|
70
|
+
"response_public_key_response",
|
|
71
|
+
"response_region_response",
|
|
72
|
+
"response_register_partner_response",
|
|
73
|
+
"signaling",
|
|
74
|
+
"simple_ok_response",
|
|
75
|
+
"site_info_response",
|
|
76
|
+
"storm_mode_request",
|
|
77
|
+
"tariff_element",
|
|
78
|
+
"tariffs",
|
|
79
|
+
"time_of_use_settings_request",
|
|
80
|
+
"total_cost",
|
|
81
|
+
"tou_settings",
|
|
82
|
+
"vehicle_base",
|
|
83
|
+
"vehicle_option",
|
|
84
|
+
"warranty_item",
|
|
85
|
+
]
|