tesla-api-sdk 1.0.0__py3-none-any.whl → 1.0.1__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 → tesla_api_sdk-1.0.1.dist-info}/METADATA +38 -32
- {tesla_api_sdk-1.0.0.dist-info → tesla_api_sdk-1.0.1.dist-info}/RECORD +32 -22
- {tesla_api_sdk-1.0.0.dist-info → tesla_api_sdk-1.0.1.dist-info}/WHEEL +1 -1
- teslafleetmanagementapi/controllers/__init__.py +2 -1
- teslafleetmanagementapi/controllers/base_controller.py +1 -1
- teslafleetmanagementapi/controllers/charging_controller.py +6 -3
- teslafleetmanagementapi/controllers/energy_controller.py +14 -11
- teslafleetmanagementapi/controllers/{oauth_authorization_controller.py → o_auth_authorization_controller.py} +13 -13
- teslafleetmanagementapi/controllers/partner_controller.py +7 -4
- teslafleetmanagementapi/controllers/user_controller.py +7 -4
- teslafleetmanagementapi/controllers/vehicle_commands_controller.py +891 -0
- teslafleetmanagementapi/controllers/vehicles_controller.py +24 -21
- teslafleetmanagementapi/exceptions/__init__.py +1 -1
- teslafleetmanagementapi/exceptions/{oauth_provider_exception.py → o_auth_provider_exception.py} +3 -3
- teslafleetmanagementapi/http/auth/oauth_2.py +105 -76
- teslafleetmanagementapi/models/__init__.py +12 -3
- teslafleetmanagementapi/models/actuate_trunk_request.py +92 -0
- teslafleetmanagementapi/models/add_charge_schedule_request.py +272 -0
- teslafleetmanagementapi/models/add_precondition_schedule_request.py +203 -0
- teslafleetmanagementapi/models/adjust_volume_request.py +92 -0
- teslafleetmanagementapi/models/api_1_vehicles_response_get_vehicle.py +1 -1
- teslafleetmanagementapi/models/command_response.py +109 -0
- teslafleetmanagementapi/models/command_result.py +105 -0
- teslafleetmanagementapi/models/guest_mode_request.py +92 -0
- teslafleetmanagementapi/models/kind_get_wall_connector_charging_history.py +1 -1
- teslafleetmanagementapi/models/{oauth_provider_error.py → o_auth_provider_error.py} +1 -1
- teslafleetmanagementapi/models/o_auth_scope_oauth_2.py +84 -0
- teslafleetmanagementapi/models/{oauth_token.py → o_auth_token.py} +2 -2
- teslafleetmanagementapi/models/which_trunk.py +45 -0
- teslafleetmanagementapi/teslafleetmanagementapi_client.py +13 -5
- {tesla_api_sdk-1.0.0.dist-info → tesla_api_sdk-1.0.1.dist-info}/licenses/LICENSE +0 -0
- {tesla_api_sdk-1.0.0.dist-info → tesla_api_sdk-1.0.1.dist-info}/top_level.txt +0 -0
|
@@ -4,6 +4,9 @@ This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
# ruff: noqa: D410, E501, E101, D206
|
|
7
|
+
from apimatic_core.authentication.multiple.and_auth_group import (
|
|
8
|
+
And,
|
|
9
|
+
)
|
|
7
10
|
from apimatic_core.authentication.multiple.single_auth import (
|
|
8
11
|
Single,
|
|
9
12
|
)
|
|
@@ -82,7 +85,7 @@ class VehiclesController(BaseController):
|
|
|
82
85
|
.header_param(Parameter()
|
|
83
86
|
.key("accept")
|
|
84
87
|
.value("application/json"))
|
|
85
|
-
.auth(Single("bearerAuth")),
|
|
88
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
86
89
|
).response(
|
|
87
90
|
ResponseHandler()
|
|
88
91
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -119,7 +122,7 @@ class VehiclesController(BaseController):
|
|
|
119
122
|
.header_param(Parameter()
|
|
120
123
|
.key("accept")
|
|
121
124
|
.value("application/json"))
|
|
122
|
-
.auth(Single("bearerAuth")),
|
|
125
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
123
126
|
).response(
|
|
124
127
|
ResponseHandler()
|
|
125
128
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -157,7 +160,7 @@ class VehiclesController(BaseController):
|
|
|
157
160
|
.header_param(Parameter()
|
|
158
161
|
.key("accept")
|
|
159
162
|
.value("application/json"))
|
|
160
|
-
.auth(Single("bearerAuth")),
|
|
163
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
161
164
|
).response(
|
|
162
165
|
ResponseHandler()
|
|
163
166
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -195,7 +198,7 @@ class VehiclesController(BaseController):
|
|
|
195
198
|
.header_param(Parameter()
|
|
196
199
|
.key("accept")
|
|
197
200
|
.value("application/json"))
|
|
198
|
-
.auth(Single("bearerAuth")),
|
|
201
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
199
202
|
).response(
|
|
200
203
|
ResponseHandler()
|
|
201
204
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -232,7 +235,7 @@ class VehiclesController(BaseController):
|
|
|
232
235
|
.header_param(Parameter()
|
|
233
236
|
.key("accept")
|
|
234
237
|
.value("application/json"))
|
|
235
|
-
.auth(Single("bearerAuth")),
|
|
238
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
236
239
|
).response(
|
|
237
240
|
ResponseHandler()
|
|
238
241
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -269,7 +272,7 @@ class VehiclesController(BaseController):
|
|
|
269
272
|
.header_param(Parameter()
|
|
270
273
|
.key("accept")
|
|
271
274
|
.value("application/json"))
|
|
272
|
-
.auth(Single("bearerAuth")),
|
|
275
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
273
276
|
).response(
|
|
274
277
|
ResponseHandler()
|
|
275
278
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -306,7 +309,7 @@ class VehiclesController(BaseController):
|
|
|
306
309
|
.header_param(Parameter()
|
|
307
310
|
.key("accept")
|
|
308
311
|
.value("application/json"))
|
|
309
|
-
.auth(Single("bearerAuth")),
|
|
312
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
310
313
|
).response(
|
|
311
314
|
ResponseHandler()
|
|
312
315
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -342,7 +345,7 @@ class VehiclesController(BaseController):
|
|
|
342
345
|
.header_param(Parameter()
|
|
343
346
|
.key("accept")
|
|
344
347
|
.value("application/json"))
|
|
345
|
-
.auth(Single("bearerAuth")),
|
|
348
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
346
349
|
).response(
|
|
347
350
|
ResponseHandler()
|
|
348
351
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -370,7 +373,7 @@ class VehiclesController(BaseController):
|
|
|
370
373
|
.header_param(Parameter()
|
|
371
374
|
.key("accept")
|
|
372
375
|
.value("application/json"))
|
|
373
|
-
.auth(Single("bearerAuth")),
|
|
376
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
374
377
|
).response(
|
|
375
378
|
ResponseHandler()
|
|
376
379
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -407,7 +410,7 @@ class VehiclesController(BaseController):
|
|
|
407
410
|
.header_param(Parameter()
|
|
408
411
|
.key("accept")
|
|
409
412
|
.value("application/json"))
|
|
410
|
-
.auth(Single("bearerAuth")),
|
|
413
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
411
414
|
).response(
|
|
412
415
|
ResponseHandler()
|
|
413
416
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -444,7 +447,7 @@ class VehiclesController(BaseController):
|
|
|
444
447
|
.header_param(Parameter()
|
|
445
448
|
.key("accept")
|
|
446
449
|
.value("application/json"))
|
|
447
|
-
.auth(Single("bearerAuth")),
|
|
450
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
448
451
|
).response(
|
|
449
452
|
ResponseHandler()
|
|
450
453
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -481,7 +484,7 @@ class VehiclesController(BaseController):
|
|
|
481
484
|
.header_param(Parameter()
|
|
482
485
|
.key("accept")
|
|
483
486
|
.value("application/json"))
|
|
484
|
-
.auth(Single("bearerAuth")),
|
|
487
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
485
488
|
).response(
|
|
486
489
|
ResponseHandler()
|
|
487
490
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -517,7 +520,7 @@ class VehiclesController(BaseController):
|
|
|
517
520
|
.header_param(Parameter()
|
|
518
521
|
.key("accept")
|
|
519
522
|
.value("application/json"))
|
|
520
|
-
.auth(Single("bearerAuth")),
|
|
523
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
521
524
|
).response(
|
|
522
525
|
ResponseHandler()
|
|
523
526
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -560,7 +563,7 @@ class VehiclesController(BaseController):
|
|
|
560
563
|
.value(body)
|
|
561
564
|
.is_required(True))
|
|
562
565
|
.body_serializer(APIHelper.json_serialize)
|
|
563
|
-
.auth(Single("bearerAuth")),
|
|
566
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
564
567
|
).response(
|
|
565
568
|
ResponseHandler()
|
|
566
569
|
.is_api_response(True),
|
|
@@ -595,7 +598,7 @@ class VehiclesController(BaseController):
|
|
|
595
598
|
.header_param(Parameter()
|
|
596
599
|
.key("accept")
|
|
597
600
|
.value("application/json"))
|
|
598
|
-
.auth(Single("bearerAuth")),
|
|
601
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
599
602
|
).response(
|
|
600
603
|
ResponseHandler()
|
|
601
604
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -633,7 +636,7 @@ class VehiclesController(BaseController):
|
|
|
633
636
|
.key("accept")
|
|
634
637
|
.value("application/json"))
|
|
635
638
|
.body_serializer(APIHelper.json_serialize)
|
|
636
|
-
.auth(Single("bearerAuth")),
|
|
639
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
637
640
|
).response(
|
|
638
641
|
ResponseHandler()
|
|
639
642
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -672,7 +675,7 @@ class VehiclesController(BaseController):
|
|
|
672
675
|
.key("accept")
|
|
673
676
|
.value("application/json"))
|
|
674
677
|
.body_serializer(APIHelper.json_serialize)
|
|
675
|
-
.auth(Single("bearerAuth")),
|
|
678
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
676
679
|
).response(
|
|
677
680
|
ResponseHandler()
|
|
678
681
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -710,7 +713,7 @@ class VehiclesController(BaseController):
|
|
|
710
713
|
.header_param(Parameter()
|
|
711
714
|
.key("accept")
|
|
712
715
|
.value("application/json"))
|
|
713
|
-
.auth(Single("bearerAuth")),
|
|
716
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
714
717
|
).response(
|
|
715
718
|
ResponseHandler()
|
|
716
719
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -747,7 +750,7 @@ class VehiclesController(BaseController):
|
|
|
747
750
|
.header_param(Parameter()
|
|
748
751
|
.key("accept")
|
|
749
752
|
.value("application/json"))
|
|
750
|
-
.auth(Single("bearerAuth")),
|
|
753
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
751
754
|
).response(
|
|
752
755
|
ResponseHandler()
|
|
753
756
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -787,7 +790,7 @@ class VehiclesController(BaseController):
|
|
|
787
790
|
.key("accept")
|
|
788
791
|
.value("application/json"))
|
|
789
792
|
.body_serializer(APIHelper.json_serialize)
|
|
790
|
-
.auth(Single("bearerAuth")),
|
|
793
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
791
794
|
).response(
|
|
792
795
|
ResponseHandler()
|
|
793
796
|
.deserializer(APIHelper.json_deserialize)
|
|
@@ -824,7 +827,7 @@ class VehiclesController(BaseController):
|
|
|
824
827
|
.header_param(Parameter()
|
|
825
828
|
.key("accept")
|
|
826
829
|
.value("application/json"))
|
|
827
|
-
.auth(Single("bearerAuth")),
|
|
830
|
+
.auth(And(Single("bearerAuth"), Single("oauth2"))),
|
|
828
831
|
).response(
|
|
829
832
|
ResponseHandler()
|
|
830
833
|
.deserializer(APIHelper.json_deserialize)
|
teslafleetmanagementapi/exceptions/{oauth_provider_exception.py → o_auth_provider_exception.py}
RENAMED
|
@@ -12,9 +12,9 @@ from teslafleetmanagementapi.exceptions.api_exception import (
|
|
|
12
12
|
)
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
class
|
|
15
|
+
class OAuthProviderException(ApiException):
|
|
16
16
|
def __init__(self, reason, response):
|
|
17
|
-
"""Initialize
|
|
17
|
+
"""Initialize OAuthProviderException object.
|
|
18
18
|
|
|
19
19
|
Args:
|
|
20
20
|
reason (string): The reason (or error message) for the Exception
|
|
@@ -22,7 +22,7 @@ class OauthProviderException(ApiException):
|
|
|
22
22
|
response (HttpResponse): The HttpResponse of the API call.
|
|
23
23
|
|
|
24
24
|
"""
|
|
25
|
-
super(
|
|
25
|
+
super(OAuthProviderException, self).__init__(reason, response)
|
|
26
26
|
dictionary = APIHelper.json_deserialize(self.response.text)
|
|
27
27
|
if isinstance(dictionary, dict):
|
|
28
28
|
self.unbox(dictionary)
|
|
@@ -21,11 +21,11 @@ from teslafleetmanagementapi.api_helper import (
|
|
|
21
21
|
from teslafleetmanagementapi.configuration import (
|
|
22
22
|
Server,
|
|
23
23
|
)
|
|
24
|
-
from teslafleetmanagementapi.controllers.
|
|
25
|
-
|
|
24
|
+
from teslafleetmanagementapi.controllers.o_auth_authorization_controller import (
|
|
25
|
+
OAuthAuthorizationController,
|
|
26
26
|
)
|
|
27
|
-
from teslafleetmanagementapi.models.
|
|
28
|
-
|
|
27
|
+
from teslafleetmanagementapi.models.o_auth_token import (
|
|
28
|
+
OAuthToken,
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
|
|
@@ -51,25 +51,30 @@ class Oauth2(HeaderAuth):
|
|
|
51
51
|
config: The configuration instance.
|
|
52
52
|
|
|
53
53
|
"""
|
|
54
|
-
self.
|
|
54
|
+
self._o_auth_client_id = auth_credentials_model.o_auth_client_id \
|
|
55
55
|
if auth_credentials_model is not None else None
|
|
56
|
-
self.
|
|
56
|
+
self._o_auth_client_secret = auth_credentials_model.o_auth_client_secret \
|
|
57
57
|
if auth_credentials_model is not None else None
|
|
58
|
-
self.
|
|
58
|
+
self._o_auth_redirect_uri = auth_credentials_model.o_auth_redirect_uri \
|
|
59
59
|
if auth_credentials_model is not None else None
|
|
60
60
|
if auth_credentials_model is not None \
|
|
61
|
-
and isinstance(auth_credentials_model.
|
|
62
|
-
self.
|
|
63
|
-
APIHelper.to_dictionary(auth_credentials_model.
|
|
61
|
+
and isinstance(auth_credentials_model.o_auth_token, OAuthToken):
|
|
62
|
+
self._o_auth_token = OAuthToken.from_dictionary(
|
|
63
|
+
APIHelper.to_dictionary(auth_credentials_model.o_auth_token))
|
|
64
64
|
else:
|
|
65
|
-
self.
|
|
65
|
+
self._o_auth_token = auth_credentials_model.o_auth_token \
|
|
66
66
|
if auth_credentials_model is not None else None
|
|
67
|
+
if auth_credentials_model is not None \
|
|
68
|
+
and isinstance(auth_credentials_model.o_auth_scopes, list):
|
|
69
|
+
self._o_auth_scopes = auth_credentials_model.o_auth_scopes
|
|
70
|
+
else:
|
|
71
|
+
self._o_auth_scopes = None
|
|
67
72
|
self._config = config
|
|
68
|
-
self._o_auth_api =
|
|
73
|
+
self._o_auth_api = OAuthAuthorizationController(config)
|
|
69
74
|
auth_params = {}
|
|
70
|
-
if (isinstance(self.
|
|
71
|
-
and hasattr(self.
|
|
72
|
-
auth_params = {"Authorization": f"Bearer {self.
|
|
75
|
+
if (isinstance(self._o_auth_token, OAuthToken)
|
|
76
|
+
and hasattr(self._o_auth_token, "access_token")):
|
|
77
|
+
auth_params = {"Authorization": f"Bearer {self._o_auth_token.access_token}"}
|
|
73
78
|
super().__init__(auth_params=auth_params)
|
|
74
79
|
|
|
75
80
|
def is_valid(self):
|
|
@@ -80,8 +85,8 @@ class Oauth2(HeaderAuth):
|
|
|
80
85
|
bool: True if the credentials are valid, False otherwise.
|
|
81
86
|
|
|
82
87
|
"""
|
|
83
|
-
return (self.
|
|
84
|
-
and not self.is_token_expired(self.
|
|
88
|
+
return (self._o_auth_token and isinstance(self._o_auth_token, OAuthToken)
|
|
89
|
+
and not self.is_token_expired(self._o_auth_token))
|
|
85
90
|
|
|
86
91
|
def get_authorization_url(self, state=None, additional_params=None):
|
|
87
92
|
"""
|
|
@@ -102,9 +107,11 @@ class Oauth2(HeaderAuth):
|
|
|
102
107
|
auth_url += "/authorize"
|
|
103
108
|
query_params = {
|
|
104
109
|
"response_type": "code",
|
|
105
|
-
"client_id": self.
|
|
106
|
-
"redirect_uri": self.
|
|
110
|
+
"client_id": self._o_auth_client_id,
|
|
111
|
+
"redirect_uri": self._o_auth_redirect_uri,
|
|
107
112
|
}
|
|
113
|
+
if self._o_auth_scopes:
|
|
114
|
+
query_params["scope"] = " ".join(self._o_auth_scopes)
|
|
108
115
|
if state:
|
|
109
116
|
query_params["state"] = state
|
|
110
117
|
if additional_params:
|
|
@@ -122,8 +129,8 @@ class Oauth2(HeaderAuth):
|
|
|
122
129
|
|
|
123
130
|
"""
|
|
124
131
|
encoded = AuthHelper.get_base64_encoded_value(
|
|
125
|
-
self.
|
|
126
|
-
self.
|
|
132
|
+
self._o_auth_client_id,
|
|
133
|
+
self._o_auth_client_secret,
|
|
127
134
|
)
|
|
128
135
|
return f"Basic {encoded}"
|
|
129
136
|
|
|
@@ -142,7 +149,7 @@ class Oauth2(HeaderAuth):
|
|
|
142
149
|
token = self._o_auth_api.request_token_oauth_2(
|
|
143
150
|
self.build_basic_auth_header(),
|
|
144
151
|
auth_code,
|
|
145
|
-
self.
|
|
152
|
+
self._o_auth_redirect_uri,
|
|
146
153
|
_optional_form_parameters=additional_params,
|
|
147
154
|
).body
|
|
148
155
|
if hasattr(token, "expires_in"):
|
|
@@ -153,25 +160,25 @@ class Oauth2(HeaderAuth):
|
|
|
153
160
|
)
|
|
154
161
|
return token
|
|
155
162
|
|
|
156
|
-
def is_token_expired(self,
|
|
163
|
+
def is_token_expired(self, o_auth_token=None):
|
|
157
164
|
"""
|
|
158
165
|
Check if OAuth token has expired.
|
|
159
166
|
|
|
160
167
|
Args:
|
|
161
|
-
|
|
168
|
+
o_auth_token (OAuthToken): The OAuth token whose expiry is to be checked.
|
|
162
169
|
|
|
163
170
|
Returns:
|
|
164
171
|
bool: True if OAuth token has expired, False otherwise.
|
|
165
172
|
|
|
166
173
|
"""
|
|
167
|
-
if
|
|
168
|
-
return (hasattr(self.
|
|
174
|
+
if o_auth_token is None:
|
|
175
|
+
return (hasattr(self._o_auth_token, "expiry")
|
|
169
176
|
and AuthHelper.is_token_expired(
|
|
170
|
-
self.
|
|
177
|
+
self._o_auth_token.expiry))
|
|
171
178
|
|
|
172
|
-
return (hasattr(
|
|
179
|
+
return (hasattr(o_auth_token, "expiry")
|
|
173
180
|
and AuthHelper.is_token_expired(
|
|
174
|
-
|
|
181
|
+
o_auth_token.expiry))
|
|
175
182
|
|
|
176
183
|
def refresh_token(self, additional_params=None):
|
|
177
184
|
"""
|
|
@@ -186,7 +193,8 @@ class Oauth2(HeaderAuth):
|
|
|
186
193
|
"""
|
|
187
194
|
token = self._o_auth_api.refresh_token_oauth_2(
|
|
188
195
|
self.build_basic_auth_header(),
|
|
189
|
-
self.
|
|
196
|
+
self._o_auth_token.refresh_token,
|
|
197
|
+
" ".join(self._o_auth_scopes) if self._o_auth_scopes else None,
|
|
190
198
|
_optional_form_parameters=additional_params,
|
|
191
199
|
).body
|
|
192
200
|
if hasattr(token, "expires_in"):
|
|
@@ -206,76 +214,88 @@ class Oauth2Credentials:
|
|
|
206
214
|
"""
|
|
207
215
|
|
|
208
216
|
@property
|
|
209
|
-
def
|
|
217
|
+
def o_auth_client_id(self):
|
|
210
218
|
"""
|
|
211
219
|
OAuth 2 Client ID.
|
|
212
220
|
"""
|
|
213
|
-
return self.
|
|
221
|
+
return self._o_auth_client_id
|
|
214
222
|
|
|
215
223
|
@property
|
|
216
|
-
def
|
|
224
|
+
def o_auth_client_secret(self):
|
|
217
225
|
"""
|
|
218
226
|
OAuth 2 Client Secret.
|
|
219
227
|
"""
|
|
220
|
-
return self.
|
|
228
|
+
return self._o_auth_client_secret
|
|
221
229
|
|
|
222
230
|
@property
|
|
223
|
-
def
|
|
231
|
+
def o_auth_redirect_uri(self):
|
|
224
232
|
"""
|
|
225
233
|
OAuth 2 Redirection endpoint or Callback Uri.
|
|
226
234
|
"""
|
|
227
|
-
return self.
|
|
235
|
+
return self._o_auth_redirect_uri
|
|
228
236
|
|
|
229
237
|
@property
|
|
230
|
-
def
|
|
238
|
+
def o_auth_token(self):
|
|
231
239
|
"""
|
|
232
240
|
Object for storing information about the OAuth token.
|
|
233
241
|
"""
|
|
234
|
-
return self.
|
|
242
|
+
return self._o_auth_token
|
|
235
243
|
|
|
236
|
-
|
|
237
|
-
|
|
244
|
+
@property
|
|
245
|
+
def o_auth_scopes(self):
|
|
246
|
+
"""
|
|
247
|
+
List of scopes that apply to the OAuth token.
|
|
248
|
+
"""
|
|
249
|
+
return self._o_auth_scopes
|
|
250
|
+
|
|
251
|
+
def __init__(self, o_auth_client_id, o_auth_client_secret,
|
|
252
|
+
o_auth_redirect_uri, o_auth_token=None, o_auth_scopes=None):
|
|
238
253
|
"""
|
|
239
254
|
Initialize the credentials.
|
|
240
255
|
|
|
241
256
|
Args:
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
257
|
+
o_auth_client_id: The o_auth_client_id property value to set.
|
|
258
|
+
o_auth_client_secret: The o_auth_client_secret property value to set.
|
|
259
|
+
o_auth_redirect_uri: The o_auth_redirect_uri property value to set.
|
|
260
|
+
o_auth_token: The o_auth_token property value to set.
|
|
261
|
+
o_auth_scopes: The o_auth_scopes property value to set.
|
|
246
262
|
|
|
247
263
|
Raises:
|
|
248
264
|
ValueError: If any required value is missing.
|
|
249
265
|
|
|
250
266
|
"""
|
|
251
|
-
if
|
|
252
|
-
raise ValueError("
|
|
253
|
-
if
|
|
254
|
-
raise ValueError("
|
|
255
|
-
if
|
|
256
|
-
raise ValueError("
|
|
257
|
-
self.
|
|
258
|
-
self.
|
|
259
|
-
self.
|
|
260
|
-
self.
|
|
267
|
+
if o_auth_client_id is None:
|
|
268
|
+
raise ValueError("o_auth_client_id cannot be None")
|
|
269
|
+
if o_auth_client_secret is None:
|
|
270
|
+
raise ValueError("o_auth_client_secret cannot be None")
|
|
271
|
+
if o_auth_redirect_uri is None:
|
|
272
|
+
raise ValueError("o_auth_redirect_uri cannot be None")
|
|
273
|
+
self._o_auth_client_id = o_auth_client_id
|
|
274
|
+
self._o_auth_client_secret = o_auth_client_secret
|
|
275
|
+
self._o_auth_redirect_uri = o_auth_redirect_uri
|
|
276
|
+
self._o_auth_token = o_auth_token
|
|
277
|
+
self._o_auth_scopes = o_auth_scopes
|
|
261
278
|
|
|
262
|
-
def clone_with(self,
|
|
263
|
-
|
|
279
|
+
def clone_with(self, o_auth_client_id=None, o_auth_client_secret=None,
|
|
280
|
+
o_auth_redirect_uri=None, o_auth_token=None,
|
|
281
|
+
o_auth_scopes=None):
|
|
264
282
|
"""
|
|
265
283
|
Return a new instance with optional value overrides.
|
|
266
284
|
|
|
267
285
|
Args:
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
286
|
+
o_auth_client_id: The o_auth_client_id property value to set.
|
|
287
|
+
o_auth_client_secret: The o_auth_client_secret property value to set.
|
|
288
|
+
o_auth_redirect_uri: The o_auth_redirect_uri property value to set.
|
|
289
|
+
o_auth_token: The o_auth_token property value to set.
|
|
290
|
+
o_auth_scopes: The o_auth_scopes property value to set.
|
|
272
291
|
|
|
273
292
|
"""
|
|
274
293
|
return Oauth2Credentials(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
294
|
+
o_auth_client_id or self.o_auth_client_id,
|
|
295
|
+
o_auth_client_secret or self.o_auth_client_secret,
|
|
296
|
+
o_auth_redirect_uri or self.o_auth_redirect_uri,
|
|
297
|
+
o_auth_token or self.o_auth_token,
|
|
298
|
+
o_auth_scopes or self.o_auth_scopes)
|
|
279
299
|
|
|
280
300
|
@classmethod
|
|
281
301
|
def from_environment(cls):
|
|
@@ -286,26 +306,35 @@ class Oauth2Credentials:
|
|
|
286
306
|
A credentials instance or ``None`` if values are missing.
|
|
287
307
|
|
|
288
308
|
"""
|
|
289
|
-
|
|
290
|
-
"
|
|
309
|
+
o_auth_client_id = os.getenv(
|
|
310
|
+
"OAUTH_2_O_AUTH_CLIENT_ID",
|
|
311
|
+
None,
|
|
312
|
+
)
|
|
313
|
+
o_auth_client_secret = os.getenv(
|
|
314
|
+
"OAUTH_2_O_AUTH_CLIENT_SECRET",
|
|
291
315
|
None,
|
|
292
316
|
)
|
|
293
|
-
|
|
294
|
-
"
|
|
317
|
+
o_auth_redirect_uri = os.getenv(
|
|
318
|
+
"OAUTH_2_O_AUTH_REDIRECT_URI",
|
|
295
319
|
None,
|
|
296
320
|
)
|
|
297
|
-
|
|
298
|
-
"
|
|
321
|
+
o_auth_scopes = os.getenv(
|
|
322
|
+
"OAUTH_2_O_AUTH_SCOPES",
|
|
299
323
|
None,
|
|
300
324
|
)
|
|
301
325
|
|
|
302
|
-
if (
|
|
303
|
-
or
|
|
304
|
-
or
|
|
326
|
+
if (o_auth_client_id is None
|
|
327
|
+
or o_auth_client_secret is None
|
|
328
|
+
or o_auth_redirect_uri is None):
|
|
305
329
|
return None
|
|
306
330
|
|
|
331
|
+
o_auth_scopes = [
|
|
332
|
+
v.strip() for v in o_auth_scopes.split(",") if v.strip()
|
|
333
|
+
] if o_auth_scopes else None
|
|
334
|
+
|
|
307
335
|
return cls(
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
336
|
+
o_auth_client_id=o_auth_client_id,
|
|
337
|
+
o_auth_client_secret=o_auth_client_secret,
|
|
338
|
+
o_auth_redirect_uri=o_auth_redirect_uri,
|
|
339
|
+
o_auth_scopes=o_auth_scopes,
|
|
311
340
|
)
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# ruff: noqa: D104 | Missing docstring in public package
|
|
2
2
|
# ruff: noqa: RUF022 | `__all__` is not sorted
|
|
3
3
|
__all__ = [
|
|
4
|
+
"actuate_trunk_request",
|
|
5
|
+
"add_charge_schedule_request",
|
|
6
|
+
"add_precondition_schedule_request",
|
|
7
|
+
"adjust_volume_request",
|
|
4
8
|
"api_1_dx_vehicles_options_response",
|
|
5
9
|
"api_1_dx_warranty_details_response",
|
|
6
10
|
"api_1_vehicles_mobile_enabled_response",
|
|
@@ -26,6 +30,8 @@ __all__ = [
|
|
|
26
30
|
"charging_session",
|
|
27
31
|
"charging_sessions_data",
|
|
28
32
|
"charging_sessions_response",
|
|
33
|
+
"command_response",
|
|
34
|
+
"command_result",
|
|
29
35
|
"default_real_mode",
|
|
30
36
|
"driver",
|
|
31
37
|
"drivers_response",
|
|
@@ -36,6 +42,7 @@ __all__ = [
|
|
|
36
42
|
"fleet_telemetry_errors_response",
|
|
37
43
|
"fleet_telemetry_jws_request",
|
|
38
44
|
"generic_update_response",
|
|
45
|
+
"guest_mode_request",
|
|
39
46
|
"kind",
|
|
40
47
|
"kind_get_wall_connector_charging_history",
|
|
41
48
|
"live_status_response",
|
|
@@ -43,8 +50,9 @@ __all__ = [
|
|
|
43
50
|
"location_1",
|
|
44
51
|
"me_response",
|
|
45
52
|
"mobile_enabled",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
53
|
+
"o_auth_provider_error",
|
|
54
|
+
"o_auth_scope_oauth_2",
|
|
55
|
+
"o_auth_token",
|
|
48
56
|
"off_grid_vehicle_charging_reserve_request",
|
|
49
57
|
"operation_request",
|
|
50
58
|
"orders_response",
|
|
@@ -81,5 +89,6 @@ __all__ = [
|
|
|
81
89
|
"tou_settings",
|
|
82
90
|
"vehicle_base",
|
|
83
91
|
"vehicle_option",
|
|
84
|
-
"warranty_item",
|
|
92
|
+
"warranty_item",
|
|
93
|
+
"which_trunk",
|
|
85
94
|
]
|