weheat 2025.1.15rc1__py3-none-any.whl → 2025.2.13__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.

Potentially problematic release.


This version of weheat might be problematic. Click here for more details.

@@ -1,3 +1,3 @@
1
- from weheat.abstractions.auth import AbstractAuth
2
1
  from weheat.abstractions.discovery import HeatPumpDiscovery
3
2
  from weheat.abstractions.heat_pump import HeatPump
3
+ from weheat.abstractions.user import async_get_user_id_from_token
@@ -1,6 +1,8 @@
1
1
  import asyncio
2
2
  from dataclasses import dataclass
3
3
 
4
+ import aiohttp
5
+
4
6
  from weheat import DeviceState
5
7
  from weheat.configuration import Configuration
6
8
  from weheat.api_client import ApiClient
@@ -17,10 +19,10 @@ class HeatPumpDiscovery:
17
19
  has_dhw: bool = False
18
20
 
19
21
  @staticmethod
20
- async def async_discover_active(api_url: str, access_token: str) -> list[HeatPumpInfo]:
22
+ async def async_discover_active(api_url: str, access_token: str, client_session:aiohttp.ClientSession|None = None) -> list[HeatPumpInfo]:
21
23
  discovered_pumps = []
22
24
 
23
- config = Configuration(host=api_url, access_token=access_token)
25
+ config = Configuration(host=api_url, access_token=access_token, client_session=client_session)
24
26
 
25
27
  async with ApiClient(configuration=config) as client:
26
28
 
@@ -2,19 +2,25 @@
2
2
  import asyncio
3
3
  from enum import Enum, auto
4
4
 
5
+ import aiohttp
6
+
5
7
  from weheat import HeatPumpApi
6
8
  from weheat.configuration import Configuration
7
9
  from weheat.api_client import ApiClient
8
10
  from weheat.api.heat_pump_log_api import HeatPumpLogApi
9
11
  from weheat.api.energy_log_api import EnergyLogApi
10
12
  from datetime import datetime, timedelta
13
+ from typing import TypeVar, Union, Optional
11
14
 
12
15
  # before this date no energy logs are available, so start from this point onwards
13
16
  START_DATE = datetime(2023, 1, 1, 0, 0, 0)
14
17
 
18
+ T = TypeVar("T", bool, int, float)
19
+
15
20
 
16
21
  class HeatPump:
17
22
  """Heat pump class representing a heat pump."""
23
+
18
24
  class State(Enum):
19
25
  STANDBY = auto()
20
26
  WATER_CHECK = auto()
@@ -26,42 +32,62 @@ class HeatPump:
26
32
  SELF_TEST = auto()
27
33
  MANUAL_CONTROL = auto()
28
34
 
29
- def __init__(self, api_url: str, uuid: str) -> None:
35
+ def __init__(self, api_url: str, uuid: str, client_session: aiohttp.ClientSession | None = None) -> None:
30
36
  self._api_url = api_url
31
37
  self._uuid = uuid
32
38
  self._last_log = None
33
- self._energy_consumption = None
34
- self._energy_output = None
35
- self._nominal_max_power = None
39
+ self._energy_consumption: Union[float, None] = None
40
+ self._energy_output: Union[float, None] = None
41
+ self._nominal_max_power: Union[float, None] = None
42
+ self._client = client_session
36
43
 
37
- async def async_get_status(self, access_token: str):
44
+ async def async_get_status(self, access_token: str) -> None:
45
+ """Updates the heat pump instance with data from the API."""
46
+ await self.async_get_logs(access_token)
47
+ await self.async_get_energy(access_token)
48
+
49
+
50
+ async def async_get_logs(self, access_token: str) -> None:
38
51
  """Updates the heat pump instance with data from the API."""
39
52
  try:
40
- config = Configuration(host=self._api_url, access_token=access_token)
53
+ config = Configuration(host=self._api_url, access_token=access_token, client_session=self._client)
41
54
 
42
55
  async with ApiClient(configuration=config) as client:
43
56
  # Set the max power once
44
57
  if self._nominal_max_power is None:
45
- response = await HeatPumpApi(client).api_v1_heat_pumps_heat_pump_id_get_with_http_info(heat_pump_id=self._uuid)
58
+ response = await HeatPumpApi(client).api_v1_heat_pumps_heat_pump_id_get_with_http_info(
59
+ heat_pump_id=self._uuid)
46
60
 
47
61
  if response.status_code == 200:
48
62
  self._set_nominal_max_power_for_model(response.data.model)
49
63
 
50
-
51
64
  response = await HeatPumpLogApi(
52
65
  client
53
66
  ).api_v1_heat_pumps_heat_pump_id_logs_latest_get_with_http_info(
54
- heat_pump_id=self._uuid )
67
+ heat_pump_id=self._uuid)
55
68
 
56
69
  if response.status_code == 200:
57
70
  self._last_log = response.data
58
71
 
72
+
73
+ except Exception as e:
74
+ self._last_log = None
75
+ raise e
76
+
77
+
78
+ async def async_get_energy(self, access_token: str) -> None:
79
+ """Updates the heat pump instance with data from the API."""
80
+ try:
81
+ config = Configuration(host=self._api_url, access_token=access_token, client_session=self._client)
82
+
83
+ async with ApiClient(configuration=config) as client:
59
84
  # Also get all energy totals form past years and add them together
60
85
  # As end time pick today + 1 day to avoid issues with timezones
61
- response = await EnergyLogApi(client).api_v1_energy_logs_heat_pump_id_get_with_http_info(heat_pump_id=self._uuid,
62
- start_time=START_DATE,
63
- end_time=datetime.now() + timedelta(days=1),
64
- interval='Month')
86
+ response = await EnergyLogApi(client).api_v1_energy_logs_heat_pump_id_get_with_http_info(
87
+ heat_pump_id=self._uuid,
88
+ start_time=START_DATE,
89
+ end_time=datetime.now() + timedelta(days=1),
90
+ interval='Month')
65
91
 
66
92
  if response.status_code == 200:
67
93
  # aggregate the energy consumption
@@ -79,109 +105,112 @@ class HeatPump:
79
105
  self._energy_output += year.total_e_out_dhw
80
106
  self._energy_output += year.total_e_out_dhw_defrost
81
107
 
82
-
83
-
84
108
  except Exception as e:
85
- self._last_log = None
86
109
  self._energy_consumption = None
87
- raise e
110
+ self._energy_output = None
88
111
 
89
- def _if_available(self, key):
112
+ def _if_available(self, key: str) -> Optional[T]:
90
113
  """Returns the value from the last logged value if available. None otherwise."""
91
114
  if self._last_log is not None and hasattr(self._last_log, key):
92
115
  return getattr(self._last_log, key)
93
116
  return None
94
117
 
95
- def _set_nominal_max_power_for_model(self, model_id:int):
118
+ def _set_nominal_max_power_for_model(self, model_id: int) -> None:
96
119
  # These numbers are the rpm at 100% power in the portal
97
120
  # RPM can go above 100% if the limit is increased in the portal.
98
121
  # except for the Flint, that cannot go above 100%.
99
122
  if model_id == 1:
100
- #BB60
123
+ # BB60
101
124
  self._nominal_max_power = 5280
102
125
  elif 2 <= model_id <= 4:
103
- #SP60
126
+ # SP60
104
127
  self._nominal_max_power = 5280
105
128
  elif model_id == 5:
106
129
  # Flint
107
130
  self._nominal_max_power = 5400
108
131
  else:
109
- #BB80
132
+ # BB80
110
133
  self._nominal_max_power = 4500
111
134
 
112
- def __str__(self):
135
+ def __str__(self) -> str:
113
136
  return f"WeheatHeatPump(uuid={self._uuid}, last update={self._if_available('timestamp')})"
114
137
 
115
- def __repr__(self):
138
+ def __repr__(self) -> str:
116
139
  return self.__str__()
117
140
 
118
141
  @property
119
- def water_inlet_temperature(self):
142
+ def raw_content(self) -> Optional[dict]:
143
+ if self._last_log is not None:
144
+ return vars(self._last_log) # type: ignore[unreachable]
145
+ return None
146
+
147
+ @property
148
+ def water_inlet_temperature(self) -> Union[float, None]:
120
149
  """The heat pump water inlet temperature."""
121
150
  return self._if_available("t_water_in")
122
151
 
123
152
  @property
124
- def water_outlet_temperature(self):
153
+ def water_outlet_temperature(self) -> Union[float, None]:
125
154
  """The heat pump water outlet temperature."""
126
155
  return self._if_available("t_water_out")
127
156
 
128
157
  @property
129
- def water_house_in_temperature(self):
158
+ def water_house_in_temperature(self) -> Union[float, None]:
130
159
  """The water house in temperature."""
131
160
  return self._if_available("t_water_house_in")
132
161
 
133
162
  @property
134
- def air_inlet_temperature(self):
163
+ def air_inlet_temperature(self) -> Union[float, None]:
135
164
  """The heat pump air inlet temperature."""
136
165
  return self._if_available("t_air_in")
137
166
 
138
167
  @property
139
- def air_outlet_temperature(self):
168
+ def air_outlet_temperature(self) -> Union[float, None]:
140
169
  """The heat pump air outlet temperature."""
141
170
  return self._if_available("t_air_out")
142
171
 
143
172
  @property
144
- def thermostat_water_setpoint(self):
173
+ def thermostat_water_setpoint(self) -> Union[float, None]:
145
174
  """The thermostat water setpoint."""
146
175
  return self._if_available("t_thermostat_setpoint")
147
176
 
148
177
  @property
149
- def thermostat_room_temperature(self):
178
+ def thermostat_room_temperature(self) -> Union[float, None]:
150
179
  """The thermostat current room temperature."""
151
180
  return self._if_available("t_room")
152
181
 
153
182
  @property
154
- def thermostat_room_temperature_setpoint(self):
183
+ def thermostat_room_temperature_setpoint(self) -> Union[float, None]:
155
184
  """The thermostat room temperature setpoint."""
156
185
  return self._if_available("t_room_target")
157
186
 
158
187
  @property
159
- def thermostat_on_off_state(self):
188
+ def thermostat_on_off_state(self) -> Union[bool, None]:
160
189
  """The thermostat on/off state."""
161
190
  return self._if_available("on_off_thermostat_state")
162
191
 
163
192
  @property
164
- def power_input(self):
193
+ def power_input(self) -> Union[float, None]:
165
194
  """The heat pumps power input."""
166
195
  return self._if_available("cm_mass_power_in")
167
196
 
168
197
  @property
169
- def power_output(self):
198
+ def power_output(self) -> Union[float, None]:
170
199
  """The heat pumps hydraulic output power."""
171
200
  return self._if_available("cm_mass_power_out")
172
201
 
173
202
  @property
174
- def dhw_top_temperature(self):
203
+ def dhw_top_temperature(self) -> Union[float, None]:
175
204
  """The DHW vessel top temperature."""
176
205
  return self._if_available("t1")
177
206
 
178
207
  @property
179
- def dhw_bottom_temperature(self):
208
+ def dhw_bottom_temperature(self) -> Union[float, None]:
180
209
  """The DHW vessel bottom temperature."""
181
210
  return self._if_available("t2")
182
211
 
183
212
  @property
184
- def cop(self):
213
+ def cop(self) -> Union[float, None]:
185
214
  """
186
215
  Returns the coefficient of performance of the heat pump.
187
216
  Note that this is calculated from a singular log entry and might not be accurate when the
@@ -191,34 +220,35 @@ class HeatPump:
191
220
  output = self.power_output
192
221
  if input is not None and output is not None and input != 0:
193
222
  return output / input
223
+ return None
194
224
 
195
225
  @property
196
- def indoor_unit_water_pump_state(self):
226
+ def indoor_unit_water_pump_state(self) -> Union[bool, None]:
197
227
  """Decoded water pump state."""
198
228
  return self._if_available("control_bridge_status_decoded_water_pump")
199
229
 
200
230
  @property
201
- def indoor_unit_auxiliary_pump_state(self):
231
+ def indoor_unit_auxiliary_pump_state(self) -> Union[bool, None]:
202
232
  """Decoded auxiliary pump state."""
203
233
  return self._if_available("control_bridge_status_decoded_water_pump2")
204
234
 
205
235
  @property
206
- def indoor_unit_dhw_valve_or_pump_state(self):
236
+ def indoor_unit_dhw_valve_or_pump_state(self) -> Union[bool, None]:
207
237
  """Decoded DHW valve or pump state."""
208
238
  return self._if_available("control_bridge_status_decoded_dhw_valve")
209
239
 
210
240
  @property
211
- def indoor_unit_gas_boiler_state(self):
241
+ def indoor_unit_gas_boiler_state(self) -> Union[bool, None]:
212
242
  """Decoded gas boiler state."""
213
243
  return self._if_available("control_bridge_status_decoded_gas_boiler")
214
244
 
215
245
  @property
216
- def indoor_unit_electric_heater_state(self):
246
+ def indoor_unit_electric_heater_state(self) -> Union[bool, None]:
217
247
  """Decoded electric heater state."""
218
248
  return self._if_available("control_bridge_status_decoded_electric_heater")
219
249
 
220
250
  @property
221
- def compressor_percentage(self):
251
+ def compressor_percentage(self) -> Union[int, None]:
222
252
  current_rpm = self._if_available("rpm")
223
253
  if self._nominal_max_power is not None and current_rpm is not None:
224
254
  # calculate percentage of rpm
@@ -226,12 +256,12 @@ class HeatPump:
226
256
  return None
227
257
 
228
258
  @property
229
- def compressor_rpm(self):
259
+ def compressor_rpm(self) -> Union[float, None]:
230
260
  """Compressor RPM."""
231
261
  return self._if_available("rpm")
232
262
 
233
263
  @property
234
- def heat_pump_state(self) -> State | None:
264
+ def heat_pump_state(self) -> Union[State, None]:
235
265
  """The heat pump state."""
236
266
  numeric_state = self._if_available("state")
237
267
  if numeric_state is None:
@@ -256,11 +286,11 @@ class HeatPump:
256
286
  return None
257
287
 
258
288
  @property
259
- def energy_total(self):
289
+ def energy_total(self) -> Union[float, None]:
260
290
  """The total used energy in kWh from 2023 to now."""
261
291
  return self._energy_consumption
262
292
 
263
293
  @property
264
- def energy_output(self):
294
+ def energy_output(self) -> Union[float, None]:
265
295
  """The total energy output in kWh from 2023 to now."""
266
296
  return self._energy_output
@@ -1,21 +1,23 @@
1
1
  import asyncio
2
+ from typing import Union
3
+
4
+ import aiohttp
2
5
 
3
6
  from weheat.configuration import Configuration
4
7
  from weheat.api_client import ApiClient
5
8
  from weheat.api.user_api import UserApi
6
9
 
7
10
 
8
- async def async_get_user_id_from_token(api_url: str, access_token: str):
11
+ async def async_get_user_id_from_token(api_url: str, access_token: str, client_session:aiohttp.ClientSession|None = None) -> Union[str,None]:
9
12
  """ Get the user id from the current logged-in user. """
10
- try:
11
- config = Configuration(host=api_url, access_token=access_token)
13
+ config = Configuration(host=api_url, access_token=access_token, client_session=client_session)
14
+
15
+ async with ApiClient(configuration=config) as client:
16
+ response = await UserApi(
17
+ client
18
+ ).api_v1_users_me_get_with_http_info()
12
19
 
13
- async with ApiClient(configuration=config) as client:
14
- response = await UserApi(
15
- client
16
- ).api_v1_users_me_get_with_http_info()
20
+ if response.status_code == 200:
21
+ return response.data.id # type: ignore[no-any-return]
22
+ return None
17
23
 
18
- if response.status_code == 200:
19
- return response.data.id
20
- except Exception as e:
21
- raise e
weheat/configuration.py CHANGED
@@ -15,6 +15,8 @@
15
15
  import copy
16
16
  import logging
17
17
  import sys
18
+
19
+ import aiohttp
18
20
  import urllib3
19
21
 
20
22
  import http.client as httplib
@@ -51,6 +53,7 @@ class Configuration:
51
53
  values before.
52
54
  :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
53
55
  in PEM format.
56
+ : param client_session: A aiohttp.ClientSession to use
54
57
 
55
58
  :Example:
56
59
  """
@@ -63,7 +66,7 @@ class Configuration:
63
66
  access_token=None,
64
67
  server_index=None, server_variables=None,
65
68
  server_operation_index=None, server_operation_variables=None,
66
- ssl_ca_cert=None,
69
+ ssl_ca_cert=None, client_session=None
67
70
  ) -> None:
68
71
  """Constructor
69
72
  """
@@ -179,6 +182,8 @@ class Configuration:
179
182
  """date format
180
183
  """
181
184
 
185
+ self._client_session = client_session
186
+
182
187
  def __deepcopy__(self, memo):
183
188
  cls = self.__class__
184
189
  result = cls.__new__(cls)
@@ -196,6 +201,10 @@ class Configuration:
196
201
  def __setattr__(self, name, value):
197
202
  object.__setattr__(self, name, value)
198
203
 
204
+ @property
205
+ def client_session(self) -> aiohttp.ClientSession|None:
206
+ return self._client_session
207
+
199
208
  @classmethod
200
209
  def set_default(cls, default):
201
210
  """Set default instance of configuration.
weheat/rest.py CHANGED
@@ -55,32 +55,37 @@ class RESTClientObject:
55
55
  # maxsize is number of requests to host that are allowed in parallel
56
56
  maxsize = configuration.connection_pool_maxsize
57
57
 
58
- ssl_context = ssl.create_default_context(
59
- cafile=configuration.ssl_ca_cert
60
- )
61
- if configuration.cert_file:
62
- ssl_context.load_cert_chain(
63
- configuration.cert_file, keyfile=configuration.key_file
58
+ self._client_session = configuration.client_session
59
+ # only setup SSL when the session is not provided. Otherwise, it will do disk access and HA will get mad.
60
+ if not configuration.client_session:
61
+ ssl_context = ssl.create_default_context(
62
+ cafile=configuration.ssl_ca_cert
64
63
  )
64
+ if configuration.cert_file:
65
+ ssl_context.load_cert_chain(
66
+ configuration.cert_file, keyfile=configuration.key_file
67
+ )
68
+
69
+ if not configuration.verify_ssl:
70
+ ssl_context.check_hostname = False
71
+ ssl_context.verify_mode = ssl.CERT_NONE
65
72
 
66
- if not configuration.verify_ssl:
67
- ssl_context.check_hostname = False
68
- ssl_context.verify_mode = ssl.CERT_NONE
73
+ connector = aiohttp.TCPConnector(
74
+ limit=maxsize,
75
+ ssl=ssl_context
76
+ )
69
77
 
70
- connector = aiohttp.TCPConnector(
71
- limit=maxsize,
72
- ssl=ssl_context
73
- )
78
+ # https pool manager
79
+ self.pool_manager = aiohttp.ClientSession(
80
+ connector=connector,
81
+ trust_env=True
82
+ )
83
+ else:
84
+ self.pool_manager = configuration.client_session
74
85
 
75
86
  self.proxy = configuration.proxy
76
87
  self.proxy_headers = configuration.proxy_headers
77
88
 
78
- # https pool manager
79
- self.pool_manager = aiohttp.ClientSession(
80
- connector=connector,
81
- trust_env=True
82
- )
83
-
84
89
  retries = configuration.retries
85
90
  if retries is not None:
86
91
  self.retry_client = aiohttp_retry.RetryClient(
@@ -96,6 +101,9 @@ class RESTClientObject:
96
101
  self.retry_client = None
97
102
 
98
103
  async def close(self):
104
+ # do not close the session if provided via client_session
105
+ if self._client_session:
106
+ return
99
107
  await self.pool_manager.close()
100
108
  if self.retry_client is not None:
101
109
  await self.retry_client.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: weheat
3
- Version: 2025.1.15rc1
3
+ Version: 2025.2.13
4
4
  Summary: Weheat Backend client
5
5
  Home-page: https://github.com/wefabricate/wh-python
6
6
  Author: Jesper Raemaekers
@@ -1,15 +1,14 @@
1
1
  weheat/__init__.py,sha256=C24j_uAbbyEzqh8DmQyORUrVMdFDlzEv4jGClf4TY34,1765
2
2
  weheat/api_client.py,sha256=Bh5xHchRGCcsHbT3rXrcmhKCMiumi1_2L6n0Q57KODw,24803
3
3
  weheat/api_response.py,sha256=A7O_XgliD6y7jEv82fgIaxR3T8KiwaOqHR6djpZyh_o,674
4
- weheat/configuration.py,sha256=bSjeNWmg5SuxyULRbUR9KCuPK9yHSYCbrZlIbY6UiAo,14278
4
+ weheat/configuration.py,sha256=8D0zAgx7B6YmVNuyS0AarcCAl5TmKKH655jHqWrvSl0,14531
5
5
  weheat/exceptions.py,sha256=jZjLtEMBKFpLTdV1GPsbQSPriG1ilgMSodGnhEKlWh4,5913
6
6
  weheat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- weheat/rest.py,sha256=r0ot19pStSTb4Nwco98UeSsppIQAR8FxQecABO4y9aY,6598
8
- weheat/abstractions/__init__.py,sha256=cRdA_kyTIooo39I13_mqShSfZMqdzNGHbmrnITqgx6A,161
9
- weheat/abstractions/auth.py,sha256=VCAxJ4OIj7bsYttqJl5-juU0VUlSd3xPu7kUjtHZr3U,979
10
- weheat/abstractions/discovery.py,sha256=Z1_tLFJzZkbA8CYIs2KpxoMB7S6Xc-V8jRk-LQeX1UE,2287
11
- weheat/abstractions/heat_pump.py,sha256=MwOXkUSJaq820clvM-iYaeMmYn4YfR7k6ML3pPR5nbY,9787
12
- weheat/abstractions/user.py,sha256=gQ5hSthG7c434lqsliI91uBOIkUQ8uTdRmCV-e7Y_Gk,663
7
+ weheat/rest.py,sha256=hSt8T6NQfdrgz_7Dxo9U-DO5ZEgUVVG38OUErThWqlU,7086
8
+ weheat/abstractions/__init__.py,sha256=BbA5WW8RE8vtpK0Dq80ayMILN4m6lmCyIPYzYXy3rTE,177
9
+ weheat/abstractions/discovery.py,sha256=PrhyM29OKvCgKzWig5BAjaEF15CIcTp_AIBZg2lyJ6Y,2384
10
+ weheat/abstractions/heat_pump.py,sha256=roUDxZZsKTbTmI9ZJqXKy51IoMlyJGY5N1tqSl8TIv8,11322
11
+ weheat/abstractions/user.py,sha256=moeJAmbjdYuXAkL7Xuks5w4zcPpjKUXM9nYJDv8WEXs,775
13
12
  weheat/api/__init__.py,sha256=zZ_Xqek8VY6gARsJK6hRess0qqGii-Ls1uXm92k0jPE,244
14
13
  weheat/api/energy_log_api.py,sha256=plZ9YoQ9O39qufzr3B6CduuzJMY1K6iJS5f5AXN-vUo,17587
15
14
  weheat/api/heat_pump_api.py,sha256=tyFA-Xf-Ld4cAVSYblCq1s5I1CDRQmKJx9UBJivnS0Y,28211
@@ -30,8 +29,8 @@ weheat/models/read_heat_pump_dto.py,sha256=7jH2MwMVKv_dOoJUUsKE8sTR5mROqco71OzOA
30
29
  weheat/models/read_user_dto.py,sha256=OIsWQZcdByN94ViSv0DjFHORRsMnkQ93jc-gJuudRdg,4018
31
30
  weheat/models/read_user_me_dto.py,sha256=Ger6qKlbZBBvG_4MStl6aEMkrBBJIjQtV6pvK1-lw28,4441
32
31
  weheat/models/role.py,sha256=6KUInAmkhoxEdWxBo9jBHXiy_nqJHrKXVeh8RvQPEYM,1101
33
- weheat-2025.1.15rc1.dist-info/LICENSE,sha256=rWmFUq0uth2jpet-RQ2QPd2VhZkcPSUs6Dxfmbqkbis,1068
34
- weheat-2025.1.15rc1.dist-info/METADATA,sha256=6-x-xTzWRV5bFUC4lUNjN1PULmzeH7IpHtnsHu3F8cM,3877
35
- weheat-2025.1.15rc1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
36
- weheat-2025.1.15rc1.dist-info/top_level.txt,sha256=hLzdyvGZ9rs4AqK7U48mdHx_-FcP5sDuTSleDUvGAZw,7
37
- weheat-2025.1.15rc1.dist-info/RECORD,,
32
+ weheat-2025.2.13.dist-info/LICENSE,sha256=rWmFUq0uth2jpet-RQ2QPd2VhZkcPSUs6Dxfmbqkbis,1068
33
+ weheat-2025.2.13.dist-info/METADATA,sha256=0bLyZ1P3cZCQ18fR8tKgh_FkB1jbaMcZw90bCSkIhPk,3874
34
+ weheat-2025.2.13.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
35
+ weheat-2025.2.13.dist-info/top_level.txt,sha256=hLzdyvGZ9rs4AqK7U48mdHx_-FcP5sDuTSleDUvGAZw,7
36
+ weheat-2025.2.13.dist-info/RECORD,,
@@ -1,34 +0,0 @@
1
- from abc import ABC, abstractmethod
2
- from aiohttp import ClientSession, ClientResponse
3
-
4
-
5
- class AbstractAuth(ABC):
6
- """Abstract class to make authenticated requests."""
7
-
8
- def __init__(self, websession: ClientSession, host: str) -> None:
9
- """Initialize the auth."""
10
- self.websession = websession
11
- self.host = host
12
-
13
- @abstractmethod
14
- async def async_get_access_token(self) -> str:
15
- """Return a valid access token."""
16
-
17
- async def request(self, method, url, **kwargs) -> ClientResponse:
18
- """Make a request."""
19
- headers = kwargs.get("headers")
20
-
21
- if headers is None:
22
- headers = {}
23
- else:
24
- headers = dict(headers)
25
-
26
- access_token = await self.async_get_access_token()
27
- headers["authorization"] = f"Bearer {access_token}"
28
-
29
- return await self.websession.request(
30
- method,
31
- f"{self.host}/{url}",
32
- **kwargs,
33
- headers=headers,
34
- )