myvsb-developer-api 1.0.1__tar.gz → 1.0.3__tar.gz

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.
Files changed (28) hide show
  1. {myvsb_developer_api-1.0.1/src/myvsb_developer_api.egg-info → myvsb_developer_api-1.0.3}/PKG-INFO +1 -1
  2. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/pyproject.toml +1 -1
  3. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/api_layer/exceptions.py +6 -2
  4. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/api_layer/open_api_client.py +17 -17
  5. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/api_layer/rest_api.py +15 -4
  6. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3/src/myvsb_developer_api.egg-info}/PKG-INFO +1 -1
  7. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/LICENSE +0 -0
  8. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/README.md +0 -0
  9. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/setup.cfg +0 -0
  10. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/api_layer/const.py +0 -0
  11. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/api_layer/utils.py +0 -0
  12. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/models/active_ventilation.py +0 -0
  13. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/models/air_conditioning.py +0 -0
  14. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/models/auxiliary_heating.py +0 -0
  15. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/models/base_model.py +0 -0
  16. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/models/charging.py +0 -0
  17. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/models/charging_profiles.py +0 -0
  18. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/models/common.py +0 -0
  19. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/models/configurations.py +0 -0
  20. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/models/driving_range.py +0 -0
  21. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/models/enums.py +0 -0
  22. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/models/parking_position.py +0 -0
  23. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/models/vehicle.py +0 -0
  24. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myskoda_openapi/models/vehicle_status.py +0 -0
  25. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myvsb_developer_api.egg-info/SOURCES.txt +0 -0
  26. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myvsb_developer_api.egg-info/dependency_links.txt +0 -0
  27. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myvsb_developer_api.egg-info/requires.txt +0 -0
  28. {myvsb_developer_api-1.0.1 → myvsb_developer_api-1.0.3}/src/myvsb_developer_api.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: myvsb-developer-api
3
- Version: 1.0.1
3
+ Version: 1.0.3
4
4
  Summary: Asynchronous Python library for the MyVSB Developer API
5
5
  Author-email: net0045 <stepan.netolicky@vsb.cz>
6
6
  Project-URL: Homepage, https://github.com/mobility-lab-vsb/myvsb-developer-api
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "myvsb-developer-api"
7
- version = "1.0.1"
7
+ version = "1.0.3"
8
8
  authors = [
9
9
  { name="net0045", email="stepan.netolicky@vsb.cz" },
10
10
  ]
@@ -25,6 +25,10 @@ class OpenApiVehicleNotFoundError(OpenApiError):
25
25
  def __init__(self, message: str = "Vehicle with this VIN does not exist.") -> None:
26
26
  super().__init__(message, status_code=404)
27
27
 
28
+ class OpenApiUnsupportedError(OpenApiError):
29
+ """Error 422 - Unsupported operation."""
30
+ def __init__(self, message: str = "Vehicle does not support this operation") -> None:
31
+ super().__init__(message, status_code=422)
28
32
 
29
33
  class OpenApiRateLimitError(OpenApiError):
30
34
  """Error 429 - Rate limit exceeded or weak 12V battery."""
@@ -32,6 +36,6 @@ class OpenApiRateLimitError(OpenApiError):
32
36
  super().__init__(message, status_code=429)
33
37
 
34
38
  class OpenApiServerError(OpenApiError):
35
- """Error 500 / 504 - Server error or timeout."""
39
+ """Error 500 - Server error or timeout."""
36
40
  def __init__(self, message: str, status_code: int = 500) -> None:
37
- super().__init__(message, status_code=status_code)
41
+ super().__init__(message, status_code=status_code)
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
  from typing import Any, Optional, List
3
3
  from aiohttp import ClientSession
4
- from .rest_api import SkodaRestAPI
4
+ from .rest_api import PostEndpointResult, SkodaRestAPI
5
5
  from ..models.vehicle import VehicleResponse, Odometer
6
6
  from ..models.vehicle_status import VehicleStatus
7
7
  from ..models.active_ventilation import ActiveVentilation
@@ -71,7 +71,7 @@ class OpenAPIClient:
71
71
 
72
72
 
73
73
 
74
- async def start_air_conditioning(self, vin: str, temperature: float, unit: str = "CELSIUS", without_external_power: bool = True) -> None:
74
+ async def start_air_conditioning(self, vin: str, temperature: float, unit: str = "CELSIUS", without_external_power: bool = True) -> PostEndpointResult:
75
75
  """Starts the air conditioning for the vehicle with the given VIN."""
76
76
  config = StartAirConditioningConfiguration(
77
77
  target_temperature=ConfigurationTargetTemperature(
@@ -80,13 +80,13 @@ class OpenAPIClient:
80
80
  ),
81
81
  air_conditioning_without_external_power=without_external_power,
82
82
  )
83
- await self.rest_api.start_air_conditioning(vin, config)
83
+ return await self.rest_api.start_air_conditioning(vin, config)
84
84
 
85
- async def stop_air_conditioning(self, vin: str) -> None:
85
+ async def stop_air_conditioning(self, vin: str) -> PostEndpointResult:
86
86
  """Stops the air_conditioning of the vehicle and return None if it was succesfull else catch an exception in HomeAssistant"""
87
- await self.rest_api.stop_air_conditioning(vin)
87
+ return await self.rest_api.stop_air_conditioning(vin)
88
88
 
89
- async def start_auxiliary_heating(self, vin: str, spin: str, duration_in_seconds: int = 120, start_mode: str = "HEATING", target_temperature: Optional[float] = None, unit: str = "CELSIUS") -> None:
89
+ async def start_auxiliary_heating(self, vin: str, spin: str, duration_in_seconds: int = 120, start_mode: str = "HEATING", target_temperature: Optional[float] = None, unit: str = "CELSIUS") -> PostEndpointResult:
90
90
  """Starts the auxiliary heating for the vehicle with the given VIN."""
91
91
  temp_obj = None
92
92
  if target_temperature is not None:
@@ -101,27 +101,27 @@ class OpenAPIClient:
101
101
  start_mode=start_mode,
102
102
  target_temperature=temp_obj,
103
103
  )
104
- await self.rest_api.start_auxiliary_heating(vin, config)
104
+ return await self.rest_api.start_auxiliary_heating(vin, config)
105
105
 
106
- async def stop_auxiliary_heating(self, vin: str) -> None:
106
+ async def stop_auxiliary_heating(self, vin: str) -> PostEndpointResult:
107
107
  """Stops the auxiliary_heating of the vehicle and return None if it was succesfull else catch an exception in HomeAssistant"""
108
- await self.rest_api.stop_auxiliary_heating(vin)
108
+ return await self.rest_api.stop_auxiliary_heating(vin)
109
109
 
110
- async def start_active_ventilation(self, vin: str) -> None:
110
+ async def start_active_ventilation(self, vin: str) -> PostEndpointResult:
111
111
  """Starts the active_ventilation for the vehicle with the given VIN."""
112
- await self.rest_api.start_active_ventilation(vin)
112
+ return await self.rest_api.start_active_ventilation(vin)
113
113
 
114
- async def stop_active_ventilation(self, vin: str) -> None:
114
+ async def stop_active_ventilation(self, vin: str) -> PostEndpointResult:
115
115
  """Stops the active_ventilation of the vehicle and return None if it was succesfull else catch an exception in HomeAssistant"""
116
- await self.rest_api.stop_active_ventilation(vin)
116
+ return await self.rest_api.stop_active_ventilation(vin)
117
117
 
118
- async def start_charging(self, vin: str) -> None:
118
+ async def start_charging(self, vin: str) -> PostEndpointResult:
119
119
  """Starts the charging process for the vehicle with the given VIN."""
120
- await self.rest_api.start_charging(vin)
120
+ return await self.rest_api.start_charging(vin)
121
121
 
122
- async def stop_charging(self, vin: str) -> None:
122
+ async def stop_charging(self, vin: str) -> PostEndpointResult:
123
123
  """Stops the charging process for the vehicle with the given VIN."""
124
- await self.rest_api.stop_charging(vin)
124
+ return await self.rest_api.stop_charging(vin)
125
125
 
126
126
  async def connect(self):
127
127
  """TODO: Implementation of connect mechanism."""
@@ -18,9 +18,11 @@ from ..models.configurations import StartAirConditioningConfiguration, StartAuxi
18
18
  from .exceptions import (
19
19
  OpenApiError,
20
20
  OpenApiAuthenticationError,
21
+ OpenApiUnsupportedError,
21
22
  OpenApiForbiddenError,
22
23
  OpenApiVehicleNotFoundError,
23
24
  OpenApiRateLimitError,
25
+ OpenApiServerError
24
26
  )
25
27
 
26
28
  T = TypeVar("T")
@@ -66,8 +68,12 @@ class SkodaRestAPI:
66
68
  case 401: raise OpenApiAuthenticationError("Invalid or expired X-API-Key.")
67
69
  case 403: raise OpenApiForbiddenError("Access forbidden. User not allowed to execute operation.")
68
70
  case 404: raise OpenApiVehicleNotFoundError("Vehicle with this VIN does not exist.")
71
+ case 422: raise OpenApiUnsupportedError("Vehicle does not support this operation")
69
72
  case 429: raise OpenApiRateLimitError("Rate limit exceeded or insufficient battery level.")
70
73
  case 400: raise OpenApiError("Bad request (e.g. validation or VIN issues).")
74
+ case 500: raise OpenApiServerError("An unexpected error occurred while processing the request.", 500)
75
+ case 503: raise OpenApiServerError("API key validation is temporarily unavailable. Retry after 10 seconds.", 503)
76
+ case 504: raise OpenApiServerError("The vehicle did not respond in time.", 504)
71
77
 
72
78
  return response.status
73
79
  except Exception as err:
@@ -87,10 +93,15 @@ class SkodaRestAPI:
87
93
  async with self._session.get(full_url, headers=headers, params=params) as response:
88
94
  if response.status not in (200, 202):
89
95
  match response.status:
90
- case 401: raise OpenApiAuthenticationError("Invalid or expired X-API-Key.")
91
- case 403: raise OpenApiForbiddenError("Access to the requested resource is forbidden.")
92
- case 404: raise OpenApiVehicleNotFoundError("Vehicle with this VIN does not exist.")
93
- case 429: raise OpenApiRateLimitError("Rate limit exceeded or weak 12V battery.")
96
+ case 401: raise OpenApiAuthenticationError("Invalid or expired X-API-Key.")
97
+ case 403: raise OpenApiForbiddenError("Access forbidden. User not allowed to execute operation.")
98
+ case 404: raise OpenApiVehicleNotFoundError("Vehicle with this VIN does not exist.")
99
+ case 422: raise OpenApiUnsupportedError("Vehicle does not support this operation")
100
+ case 429: raise OpenApiRateLimitError("Rate limit exceeded or insufficient battery level.")
101
+ case 400: raise OpenApiError("Bad request (e.g. validation or VIN issues).")
102
+ case 500: raise OpenApiServerError("An unexpected error occurred while processing the request.", 500)
103
+ case 503: raise OpenApiServerError("API key validation is temporarily unavailable. Retry after 10 seconds.", 503)
104
+ case 504: raise OpenApiServerError("The vehicle did not respond in time.", 504)
94
105
  return await response.json()
95
106
  except Exception as err:
96
107
  raise OpenApiError(f"There has been an error when trying to make the request: {err}") from err
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: myvsb-developer-api
3
- Version: 1.0.1
3
+ Version: 1.0.3
4
4
  Summary: Asynchronous Python library for the MyVSB Developer API
5
5
  Author-email: net0045 <stepan.netolicky@vsb.cz>
6
6
  Project-URL: Homepage, https://github.com/mobility-lab-vsb/myvsb-developer-api