evcloud 0.1.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.
Files changed (635) hide show
  1. evcloud/__init__.py +802 -0
  2. evcloud/_default_clients.py +30 -0
  3. evcloud/client.py +200 -0
  4. evcloud/core/__init__.py +67 -0
  5. evcloud/core/api_error.py +23 -0
  6. evcloud/core/client_wrapper.py +108 -0
  7. evcloud/core/datetime_utils.py +70 -0
  8. evcloud/core/file.py +67 -0
  9. evcloud/core/force_multipart.py +18 -0
  10. evcloud/core/http_client.py +840 -0
  11. evcloud/core/http_response.py +59 -0
  12. evcloud/core/http_sse/__init__.py +9 -0
  13. evcloud/core/http_sse/_api.py +112 -0
  14. evcloud/core/http_sse/_decoders.py +61 -0
  15. evcloud/core/http_sse/_exceptions.py +7 -0
  16. evcloud/core/http_sse/_models.py +17 -0
  17. evcloud/core/jsonable_encoder.py +120 -0
  18. evcloud/core/logging.py +107 -0
  19. evcloud/core/pagination.py +82 -0
  20. evcloud/core/parse_error.py +36 -0
  21. evcloud/core/pydantic_utilities.py +634 -0
  22. evcloud/core/query_encoder.py +58 -0
  23. evcloud/core/remove_none_from_dict.py +11 -0
  24. evcloud/core/request_options.py +35 -0
  25. evcloud/core/serialization.py +276 -0
  26. evcloud/cpo/__init__.py +31 -0
  27. evcloud/cpo/cdrs/__init__.py +4 -0
  28. evcloud/cpo/cdrs/client.py +311 -0
  29. evcloud/cpo/cdrs/raw_client.py +592 -0
  30. evcloud/cpo/charge_points/__init__.py +7 -0
  31. evcloud/cpo/charge_points/client.py +1436 -0
  32. evcloud/cpo/charge_points/raw_client.py +2809 -0
  33. evcloud/cpo/charge_points/types/__init__.py +7 -0
  34. evcloud/cpo/charge_points/types/list_charge_points_request_ocpp_version.py +5 -0
  35. evcloud/cpo/client.py +62 -0
  36. evcloud/cpo/connectors/__init__.py +4 -0
  37. evcloud/cpo/connectors/client.py +698 -0
  38. evcloud/cpo/connectors/raw_client.py +1457 -0
  39. evcloud/cpo/evses/__init__.py +4 -0
  40. evcloud/cpo/evses/client.py +691 -0
  41. evcloud/cpo/evses/raw_client.py +1457 -0
  42. evcloud/cpo/health/__init__.py +4 -0
  43. evcloud/cpo/health/client.py +100 -0
  44. evcloud/cpo/health/raw_client.py +192 -0
  45. evcloud/cpo/locations/__init__.py +4 -0
  46. evcloud/cpo/locations/client.py +1021 -0
  47. evcloud/cpo/locations/raw_client.py +1887 -0
  48. evcloud/cpo/raw_client.py +13 -0
  49. evcloud/cpo/sessions/__init__.py +7 -0
  50. evcloud/cpo/sessions/client.py +430 -0
  51. evcloud/cpo/sessions/raw_client.py +889 -0
  52. evcloud/cpo/sessions/types/__init__.py +8 -0
  53. evcloud/cpo/sessions/types/list_sessions_request_billing_state.py +5 -0
  54. evcloud/cpo/sessions/types/list_sessions_request_status.py +7 -0
  55. evcloud/cpo/tariffs/__init__.py +17 -0
  56. evcloud/cpo/tariffs/client.py +1232 -0
  57. evcloud/cpo/tariffs/raw_client.py +2526 -0
  58. evcloud/cpo/tariffs/types/__init__.py +15 -0
  59. evcloud/cpo/tariffs/types/list_tariffs_request_type.py +7 -0
  60. evcloud/cpo/tariffs/types/tariff_create_ocpi_version.py +5 -0
  61. evcloud/cpo/tariffs/types/tariff_create_preauthorize_amount.py +5 -0
  62. evcloud/cpo/tariffs/types/tariff_patch_preauthorize_amount.py +5 -0
  63. evcloud/emsp/__init__.py +55 -0
  64. evcloud/emsp/cdrs/__init__.py +4 -0
  65. evcloud/emsp/cdrs/client.py +300 -0
  66. evcloud/emsp/cdrs/raw_client.py +610 -0
  67. evcloud/emsp/chargers/__init__.py +7 -0
  68. evcloud/emsp/chargers/client.py +167 -0
  69. evcloud/emsp/chargers/raw_client.py +331 -0
  70. evcloud/emsp/chargers/types/__init__.py +11 -0
  71. evcloud/emsp/chargers/types/resolve_chargers_response.py +53 -0
  72. evcloud/emsp/client.py +77 -0
  73. evcloud/emsp/commands/__init__.py +7 -0
  74. evcloud/emsp/commands/client.py +516 -0
  75. evcloud/emsp/commands/raw_client.py +979 -0
  76. evcloud/emsp/commands/types/__init__.py +7 -0
  77. evcloud/emsp/commands/types/send_commands_request_command.py +7 -0
  78. evcloud/emsp/emp_identities/__init__.py +4 -0
  79. evcloud/emsp/emp_identities/client.py +548 -0
  80. evcloud/emsp/emp_identities/raw_client.py +1277 -0
  81. evcloud/emsp/evses/__init__.py +4 -0
  82. evcloud/emsp/evses/client.py +154 -0
  83. evcloud/emsp/evses/raw_client.py +288 -0
  84. evcloud/emsp/health/__init__.py +4 -0
  85. evcloud/emsp/health/client.py +100 -0
  86. evcloud/emsp/health/raw_client.py +192 -0
  87. evcloud/emsp/locations/__init__.py +4 -0
  88. evcloud/emsp/locations/client.py +1386 -0
  89. evcloud/emsp/locations/raw_client.py +2903 -0
  90. evcloud/emsp/networks/__init__.py +7 -0
  91. evcloud/emsp/networks/client.py +1615 -0
  92. evcloud/emsp/networks/raw_client.py +3725 -0
  93. evcloud/emsp/networks/types/__init__.py +9 -0
  94. evcloud/emsp/networks/types/list_networks_request_network_type.py +5 -0
  95. evcloud/emsp/networks/types/list_rules_networks_request_validity.py +5 -0
  96. evcloud/emsp/networks/types/network_rule_create_request_rule_type.py +5 -0
  97. evcloud/emsp/raw_client.py +13 -0
  98. evcloud/emsp/sessions/__init__.py +4 -0
  99. evcloud/emsp/sessions/client.py +300 -0
  100. evcloud/emsp/sessions/raw_client.py +610 -0
  101. evcloud/emsp/tariffs/__init__.py +7 -0
  102. evcloud/emsp/tariffs/client.py +421 -0
  103. evcloud/emsp/tariffs/raw_client.py +883 -0
  104. evcloud/emsp/tariffs/types/__init__.py +8 -0
  105. evcloud/emsp/tariffs/types/estimate_request_kwh.py +5 -0
  106. evcloud/emsp/tariffs/types/estimate_request_minutes.py +5 -0
  107. evcloud/emsp/tenant/__init__.py +4 -0
  108. evcloud/emsp/tenant/client.py +328 -0
  109. evcloud/emsp/tenant/raw_client.py +869 -0
  110. evcloud/emsp/token_groups/__init__.py +7 -0
  111. evcloud/emsp/token_groups/client.py +1256 -0
  112. evcloud/emsp/token_groups/raw_client.py +3288 -0
  113. evcloud/emsp/token_groups/types/__init__.py +7 -0
  114. evcloud/emsp/token_groups/types/remove_token_token_groups_request_type.py +5 -0
  115. evcloud/emsp/tokens/__init__.py +7 -0
  116. evcloud/emsp/tokens/client.py +1298 -0
  117. evcloud/emsp/tokens/raw_client.py +2947 -0
  118. evcloud/emsp/tokens/types/__init__.py +10 -0
  119. evcloud/emsp/tokens/types/list_tokens_request_status.py +7 -0
  120. evcloud/emsp/tokens/types/list_tokens_request_type.py +5 -0
  121. evcloud/emsp/tokens/types/token_update_default_profile_type.py +5 -0
  122. evcloud/emsp/tokens/types/token_update_whitelist.py +5 -0
  123. evcloud/energy/__init__.py +8 -0
  124. evcloud/energy/client.py +47 -0
  125. evcloud/energy/control_requests/__init__.py +7 -0
  126. evcloud/energy/control_requests/client.py +399 -0
  127. evcloud/energy/control_requests/raw_client.py +835 -0
  128. evcloud/energy/control_requests/types/__init__.py +7 -0
  129. evcloud/energy/control_requests/types/list_control_requests_request_result.py +15 -0
  130. evcloud/energy/health/__init__.py +4 -0
  131. evcloud/energy/health/client.py +100 -0
  132. evcloud/energy/health/raw_client.py +192 -0
  133. evcloud/energy/power_measurements/__init__.py +4 -0
  134. evcloud/energy/power_measurements/client.py +254 -0
  135. evcloud/energy/power_measurements/raw_client.py +527 -0
  136. evcloud/energy/raw_client.py +13 -0
  137. evcloud/environment.py +7 -0
  138. evcloud/errors/__init__.py +25 -0
  139. evcloud/errors/bad_gateway_error.py +11 -0
  140. evcloud/errors/bad_request_error.py +11 -0
  141. evcloud/errors/conflict_error.py +11 -0
  142. evcloud/errors/forbidden_error.py +11 -0
  143. evcloud/errors/gateway_timeout_error.py +11 -0
  144. evcloud/errors/not_found_error.py +11 -0
  145. evcloud/errors/too_many_requests_error.py +11 -0
  146. evcloud/errors/unauthorized_error.py +11 -0
  147. evcloud/errors/unprocessable_entity_error.py +11 -0
  148. evcloud/health/__init__.py +4 -0
  149. evcloud/health/client.py +99 -0
  150. evcloud/health/raw_client.py +100 -0
  151. evcloud/ocpi/__init__.py +123 -0
  152. evcloud/ocpi/client.py +56 -0
  153. evcloud/ocpi/cpo_data/__init__.py +31 -0
  154. evcloud/ocpi/cpo_data/client.py +1553 -0
  155. evcloud/ocpi/cpo_data/raw_client.py +3119 -0
  156. evcloud/ocpi/cpo_data/types/__init__.py +29 -0
  157. evcloud/ocpi/cpo_data/types/cancel_reservation_cpo_data_request_version.py +5 -0
  158. evcloud/ocpi/cpo_data/types/create_cdr_cpo_data_request_version.py +5 -0
  159. evcloud/ocpi/cpo_data/types/delete_tariff_cpo_data_request_version.py +5 -0
  160. evcloud/ocpi/cpo_data/types/send_active_charging_profile_cpo_data_request_version.py +5 -0
  161. evcloud/ocpi/cpo_data/types/update_connector_cpo_data_request_version.py +5 -0
  162. evcloud/ocpi/cpo_data/types/update_evse_status_cpo_data_request_version.py +5 -0
  163. evcloud/ocpi/cpo_data/types/update_location_cpo_data_request_version.py +5 -0
  164. evcloud/ocpi/cpo_data/types/update_session_cpo_data_request_version.py +5 -0
  165. evcloud/ocpi/cpo_data/types/upsert_location_cpo_data_request_version.py +5 -0
  166. evcloud/ocpi/cpo_data/types/upsert_session_cpo_data_request_version.py +5 -0
  167. evcloud/ocpi/cpo_data/types/upsert_tariff_cpo_data_request_version.py +5 -0
  168. evcloud/ocpi/credentials/__init__.py +31 -0
  169. evcloud/ocpi/credentials/client.py +750 -0
  170. evcloud/ocpi/credentials/raw_client.py +1537 -0
  171. evcloud/ocpi/credentials/types/__init__.py +29 -0
  172. evcloud/ocpi/credentials/types/partner_versions_pull_request_partner_token_encoding.py +5 -0
  173. evcloud/ocpi/credentials/types/pull_versions_credentials_request_role.py +5 -0
  174. evcloud/ocpi/credentials/types/pull_versions_credentials_request_version.py +5 -0
  175. evcloud/ocpi/credentials/types/rotate_credentials_request_role.py +5 -0
  176. evcloud/ocpi/credentials/types/rotate_credentials_request_version.py +5 -0
  177. evcloud/ocpi/credentials/types/start_handshake_credentials_request_role.py +5 -0
  178. evcloud/ocpi/credentials/types/start_handshake_credentials_request_version.py +5 -0
  179. evcloud/ocpi/credentials/types/status_credentials_request_role.py +5 -0
  180. evcloud/ocpi/credentials/types/status_credentials_request_version.py +5 -0
  181. evcloud/ocpi/credentials/types/unregister_credentials_request_role.py +5 -0
  182. evcloud/ocpi/credentials/types/unregister_credentials_request_version.py +5 -0
  183. evcloud/ocpi/emsp/__init__.py +27 -0
  184. evcloud/ocpi/emsp/client.py +1142 -0
  185. evcloud/ocpi/emsp/raw_client.py +2209 -0
  186. evcloud/ocpi/emsp/types/__init__.py +25 -0
  187. evcloud/ocpi/emsp/types/charging_preferences_request_profile_type.py +5 -0
  188. evcloud/ocpi/emsp/types/clear_charging_profile_emsp_request_version.py +5 -0
  189. evcloud/ocpi/emsp/types/get_active_charging_profile_emsp_request_version.py +5 -0
  190. evcloud/ocpi/emsp/types/send_command_emsp_request_command.py +7 -0
  191. evcloud/ocpi/emsp/types/send_command_emsp_request_version.py +5 -0
  192. evcloud/ocpi/emsp/types/set_charging_preferences_emsp_request_version.py +5 -0
  193. evcloud/ocpi/emsp/types/set_charging_profile_emsp_request_version.py +5 -0
  194. evcloud/ocpi/emsp/types/update_token_emsp_request_version.py +5 -0
  195. evcloud/ocpi/emsp/types/upsert_token_emsp_request_version.py +5 -0
  196. evcloud/ocpi/invites/__init__.py +19 -0
  197. evcloud/ocpi/invites/client.py +385 -0
  198. evcloud/ocpi/invites/raw_client.py +887 -0
  199. evcloud/ocpi/invites/types/__init__.py +17 -0
  200. evcloud/ocpi/invites/types/partner_invite_create_request_gateway_role.py +5 -0
  201. evcloud/ocpi/invites/types/partner_invite_create_request_role.py +5 -0
  202. evcloud/ocpi/invites/types/partner_invite_create_request_version.py +5 -0
  203. evcloud/ocpi/invites/types/partner_invite_update_request_gateway_role.py +5 -0
  204. evcloud/ocpi/invites/types/partner_invite_update_request_version.py +5 -0
  205. evcloud/ocpi/partners/__init__.py +7 -0
  206. evcloud/ocpi/partners/client.py +581 -0
  207. evcloud/ocpi/partners/raw_client.py +1340 -0
  208. evcloud/ocpi/partners/types/__init__.py +8 -0
  209. evcloud/ocpi/partners/types/partner_register_request_ocpi_version.py +5 -0
  210. evcloud/ocpi/partners/types/partner_update_request_ocpi_version.py +5 -0
  211. evcloud/ocpi/raw_client.py +13 -0
  212. evcloud/ocpi/sync/__init__.py +33 -0
  213. evcloud/ocpi/sync/client.py +1701 -0
  214. evcloud/ocpi/sync/raw_client.py +3685 -0
  215. evcloud/ocpi/sync/types/__init__.py +31 -0
  216. evcloud/ocpi/sync/types/pull_cdrs_sync_request_version.py +5 -0
  217. evcloud/ocpi/sync/types/pull_hub_client_info_as_cpo_sync_request_version.py +5 -0
  218. evcloud/ocpi/sync/types/pull_hub_client_info_as_emsp_sync_request_version.py +5 -0
  219. evcloud/ocpi/sync/types/pull_locations_sync_request_version.py +5 -0
  220. evcloud/ocpi/sync/types/pull_sessions_sync_request_version.py +5 -0
  221. evcloud/ocpi/sync/types/pull_tariffs_sync_request_version.py +5 -0
  222. evcloud/ocpi/sync/types/pull_tokens_sync_request_version.py +5 -0
  223. evcloud/ocpi/sync/types/push_cdr_sync_request_version.py +5 -0
  224. evcloud/ocpi/sync/types/push_location_sync_request_version.py +5 -0
  225. evcloud/ocpi/sync/types/push_session_sync_request_version.py +5 -0
  226. evcloud/ocpi/sync/types/push_tariff_sync_request_version.py +5 -0
  227. evcloud/ocpi/sync/types/push_token_sync_request_version.py +5 -0
  228. evcloud/py.typed +0 -0
  229. evcloud/types/__init__.py +759 -0
  230. evcloud/types/access_mode.py +5 -0
  231. evcloud/types/asset_connector.py +26 -0
  232. evcloud/types/asset_updated_event.py +29 -0
  233. evcloud/types/availability_page.py +26 -0
  234. evcloud/types/batch_response.py +26 -0
  235. evcloud/types/batch_response_missing_item.py +7 -0
  236. evcloud/types/cdr_event.py +41 -0
  237. evcloud/types/cdr_out.py +75 -0
  238. evcloud/types/cdr_out_auth_method.py +7 -0
  239. evcloud/types/cdr_out_auth_method_zero.py +5 -0
  240. evcloud/types/cdr_out_origin.py +7 -0
  241. evcloud/types/cdr_out_origin_zero.py +5 -0
  242. evcloud/types/cdr_page.py +27 -0
  243. evcloud/types/cdr_write_response.py +26 -0
  244. evcloud/types/charge_point_created_out.py +74 -0
  245. evcloud/types/charge_point_created_out_access_mode.py +7 -0
  246. evcloud/types/charge_point_created_out_access_mode_zero.py +5 -0
  247. evcloud/types/charge_point_created_out_pricing.py +7 -0
  248. evcloud/types/charge_point_created_out_pricing_zero.py +5 -0
  249. evcloud/types/charge_point_created_out_site_type.py +7 -0
  250. evcloud/types/charge_point_created_out_site_type_zero.py +5 -0
  251. evcloud/types/charge_point_out.py +73 -0
  252. evcloud/types/charge_point_out_access_mode.py +7 -0
  253. evcloud/types/charge_point_out_access_mode_zero.py +5 -0
  254. evcloud/types/charge_point_out_pricing.py +7 -0
  255. evcloud/types/charge_point_out_pricing_zero.py +5 -0
  256. evcloud/types/charge_point_out_site_type.py +7 -0
  257. evcloud/types/charge_point_out_site_type_zero.py +5 -0
  258. evcloud/types/charge_point_page.py +27 -0
  259. evcloud/types/charging_preferences_response.py +28 -0
  260. evcloud/types/charging_preferences_response_result.py +10 -0
  261. evcloud/types/charging_profile.py +30 -0
  262. evcloud/types/charging_profile_charging_rate_unit.py +5 -0
  263. evcloud/types/charging_profile_period.py +31 -0
  264. evcloud/types/charging_profile_response.py +32 -0
  265. evcloud/types/cluster_page.py +26 -0
  266. evcloud/types/command_accepted.py +30 -0
  267. evcloud/types/command_accepted_route.py +53 -0
  268. evcloud/types/command_accepted_route_own.py +28 -0
  269. evcloud/types/command_accepted_route_own_ocpi_version.py +7 -0
  270. evcloud/types/command_accepted_route_own_ocpi_version_zero.py +5 -0
  271. evcloud/types/command_accepted_route_roaming.py +30 -0
  272. evcloud/types/command_accepted_route_roaming_ocpi_version.py +7 -0
  273. evcloud/types/command_accepted_route_roaming_ocpi_version_zero.py +5 -0
  274. evcloud/types/command_accepted_status.py +7 -0
  275. evcloud/types/command_accepted_status_zero.py +20 -0
  276. evcloud/types/command_page.py +26 -0
  277. evcloud/types/command_record.py +40 -0
  278. evcloud/types/command_record_command.py +7 -0
  279. evcloud/types/command_record_command_zero.py +7 -0
  280. evcloud/types/command_record_route.py +53 -0
  281. evcloud/types/command_record_route_own.py +28 -0
  282. evcloud/types/command_record_route_own_ocpi_version.py +7 -0
  283. evcloud/types/command_record_route_own_ocpi_version_zero.py +5 -0
  284. evcloud/types/command_record_route_roaming.py +30 -0
  285. evcloud/types/command_record_route_roaming_ocpi_version.py +7 -0
  286. evcloud/types/command_record_route_roaming_ocpi_version_zero.py +5 -0
  287. evcloud/types/command_record_status.py +7 -0
  288. evcloud/types/command_record_status_zero.py +20 -0
  289. evcloud/types/command_response_out.py +26 -0
  290. evcloud/types/command_response_out_result.py +7 -0
  291. evcloud/types/command_response_out_result_zero.py +7 -0
  292. evcloud/types/command_result_event.py +39 -0
  293. evcloud/types/command_result_event_module.py +5 -0
  294. evcloud/types/command_result_event_protocol.py +5 -0
  295. evcloud/types/command_result_event_status.py +5 -0
  296. evcloud/types/command_send_response.py +31 -0
  297. evcloud/types/command_token.py +36 -0
  298. evcloud/types/connector_format.py +5 -0
  299. evcloud/types/connector_page.py +27 -0
  300. evcloud/types/connector_status_event.py +29 -0
  301. evcloud/types/connector_write_response.py +27 -0
  302. evcloud/types/control_action.py +5 -0
  303. evcloud/types/control_request_page.py +27 -0
  304. evcloud/types/control_request_response.py +38 -0
  305. evcloud/types/control_request_response_action.py +7 -0
  306. evcloud/types/control_request_response_action_zero.py +7 -0
  307. evcloud/types/control_request_response_result.py +7 -0
  308. evcloud/types/control_request_response_result_zero.py +15 -0
  309. evcloud/types/control_request_response_unit.py +7 -0
  310. evcloud/types/control_request_response_unit_zero.py +5 -0
  311. evcloud/types/control_response_event.py +38 -0
  312. evcloud/types/control_response_event_action.py +5 -0
  313. evcloud/types/control_response_event_result.py +15 -0
  314. evcloud/types/control_response_event_unit.py +5 -0
  315. evcloud/types/cpo_connector_out.py +58 -0
  316. evcloud/types/cpo_connector_out_format.py +7 -0
  317. evcloud/types/cpo_connector_out_format_zero.py +5 -0
  318. evcloud/types/cpo_connector_out_ocpi_status.py +7 -0
  319. evcloud/types/cpo_connector_out_ocpi_status_zero.py +10 -0
  320. evcloud/types/cpo_connector_out_power_type.py +7 -0
  321. evcloud/types/cpo_connector_out_power_type_zero.py +7 -0
  322. evcloud/types/cpo_evse_out.py +61 -0
  323. evcloud/types/cpo_evse_out_origin.py +7 -0
  324. evcloud/types/cpo_evse_out_origin_zero.py +5 -0
  325. evcloud/types/cpo_evse_out_status.py +7 -0
  326. evcloud/types/cpo_evse_out_status_zero.py +10 -0
  327. evcloud/types/credentials_handshake_request.py +44 -0
  328. evcloud/types/credentials_handshake_request_partner_token_encoding.py +5 -0
  329. evcloud/types/credentials_handshake_response.py +32 -0
  330. evcloud/types/credentials_handshake_response_action.py +7 -0
  331. evcloud/types/credentials_handshake_response_version.py +5 -0
  332. evcloud/types/deliver_event_response.py +23 -0
  333. evcloud/types/delivery_drift_event.py +30 -0
  334. evcloud/types/display_text.py +24 -0
  335. evcloud/types/effective_cpo.py +27 -0
  336. evcloud/types/effective_cpo_source.py +7 -0
  337. evcloud/types/effective_cpo_source_zero.py +5 -0
  338. evcloud/types/effective_view_response.py +29 -0
  339. evcloud/types/emp_identity_out.py +35 -0
  340. evcloud/types/emp_identity_out_status.py +7 -0
  341. evcloud/types/emp_identity_out_status_zero.py +5 -0
  342. evcloud/types/emp_identity_page.py +26 -0
  343. evcloud/types/emsp_cdr_out.py +41 -0
  344. evcloud/types/emsp_cdr_out_source.py +7 -0
  345. evcloud/types/emsp_cdr_out_source_zero.py +5 -0
  346. evcloud/types/emsp_cdr_page.py +26 -0
  347. evcloud/types/emsp_connector_out.py +30 -0
  348. evcloud/types/emsp_evse_out.py +32 -0
  349. evcloud/types/emsp_gateway_schema_commands_location_key.py +25 -0
  350. evcloud/types/emsp_gateway_schema_location_lookup_location_key.py +25 -0
  351. evcloud/types/emsp_gateway_schema_locations_location_out.py +47 -0
  352. evcloud/types/emsp_gateway_schema_locations_location_page.py +26 -0
  353. evcloud/types/emsp_gateway_schema_networks_location_out.py +37 -0
  354. evcloud/types/emsp_gateway_schema_networks_location_page.py +26 -0
  355. evcloud/types/emsp_session_out.py +41 -0
  356. evcloud/types/emsp_session_out_source.py +7 -0
  357. evcloud/types/emsp_session_out_source_zero.py +5 -0
  358. evcloud/types/emsp_session_page.py +26 -0
  359. evcloud/types/emsp_tariff_page.py +26 -0
  360. evcloud/types/energy_contract.py +24 -0
  361. evcloud/types/estimate_line.py +27 -0
  362. evcloud/types/estimate_line_type.py +7 -0
  363. evcloud/types/estimate_line_type_zero.py +5 -0
  364. evcloud/types/estimate_response.py +30 -0
  365. evcloud/types/event_type_list.py +24 -0
  366. evcloud/types/event_type_response.py +27 -0
  367. evcloud/types/event_type_response_type.py +7 -0
  368. evcloud/types/event_type_response_type_zero.py +27 -0
  369. evcloud/types/event_type_version.py +24 -0
  370. evcloud/types/evse_connector_status.py +26 -0
  371. evcloud/types/evse_page.py +27 -0
  372. evcloud/types/evse_parking.py +25 -0
  373. evcloud/types/evse_parking_evse_position.py +7 -0
  374. evcloud/types/evse_parking_evse_position_zero.py +5 -0
  375. evcloud/types/evse_status_event.py +31 -0
  376. evcloud/types/evse_status_out.py +32 -0
  377. evcloud/types/evse_status_write_response.py +28 -0
  378. evcloud/types/facility_count.py +24 -0
  379. evcloud/types/facility_page.py +26 -0
  380. evcloud/types/health_ok.py +24 -0
  381. evcloud/types/health_ok_status.py +7 -0
  382. evcloud/types/health_ok_status_zero.py +5 -0
  383. evcloud/types/http_error_response.py +29 -0
  384. evcloud/types/http_validation_error.py +24 -0
  385. evcloud/types/limit_unit.py +5 -0
  386. evcloud/types/location_availability.py +28 -0
  387. evcloud/types/location_availability_status.py +7 -0
  388. evcloud/types/location_availability_status_zero.py +7 -0
  389. evcloud/types/location_base.py +53 -0
  390. evcloud/types/location_base_parking_type.py +7 -0
  391. evcloud/types/location_base_parking_type_zero.py +8 -0
  392. evcloud/types/location_cluster.py +26 -0
  393. evcloud/types/location_detail.py +51 -0
  394. evcloud/types/location_key_input.py +25 -0
  395. evcloud/types/location_list.py +24 -0
  396. evcloud/types/location_out.py +79 -0
  397. evcloud/types/location_out_access_mode.py +7 -0
  398. evcloud/types/location_out_access_mode_zero.py +5 -0
  399. evcloud/types/location_out_ocpi_version.py +7 -0
  400. evcloud/types/location_out_ocpi_version_zero.py +5 -0
  401. evcloud/types/location_out_origin.py +7 -0
  402. evcloud/types/location_out_origin_zero.py +5 -0
  403. evcloud/types/location_out_parking_type.py +7 -0
  404. evcloud/types/location_out_parking_type_zero.py +8 -0
  405. evcloud/types/location_out_role.py +7 -0
  406. evcloud/types/location_out_role_zero.py +5 -0
  407. evcloud/types/location_out_site_type.py +7 -0
  408. evcloud/types/location_out_site_type_zero.py +5 -0
  409. evcloud/types/location_page.py +27 -0
  410. evcloud/types/location_summary.py +43 -0
  411. evcloud/types/location_updated_event.py +30 -0
  412. evcloud/types/location_write_response.py +26 -0
  413. evcloud/types/map_cluster.py +28 -0
  414. evcloud/types/map_page.py +29 -0
  415. evcloud/types/network_consumer.py +25 -0
  416. evcloud/types/network_consumer_page.py +26 -0
  417. evcloud/types/network_detail_response.py +49 -0
  418. evcloud/types/network_detail_response_network_type.py +7 -0
  419. evcloud/types/network_detail_response_network_type_zero.py +5 -0
  420. evcloud/types/network_detail_response_publish_state.py +7 -0
  421. evcloud/types/network_detail_response_publish_state_zero.py +7 -0
  422. evcloud/types/network_page.py +26 -0
  423. evcloud/types/network_priority_order.py +23 -0
  424. evcloud/types/network_response.py +46 -0
  425. evcloud/types/network_response_network_type.py +7 -0
  426. evcloud/types/network_response_network_type_zero.py +5 -0
  427. evcloud/types/network_response_publish_state.py +7 -0
  428. evcloud/types/network_response_publish_state_zero.py +5 -0
  429. evcloud/types/network_rule_page.py +26 -0
  430. evcloud/types/network_rule_response.py +33 -0
  431. evcloud/types/network_rule_response_rule_type.py +7 -0
  432. evcloud/types/network_rule_response_rule_type_zero.py +5 -0
  433. evcloud/types/ocpi_business_details.py +26 -0
  434. evcloud/types/ocpi_business_details_input.py +26 -0
  435. evcloud/types/ocpi_cdr_dimension.py +24 -0
  436. evcloud/types/ocpi_cdr_location.py +30 -0
  437. evcloud/types/ocpi_cdr_token.py +30 -0
  438. evcloud/types/ocpi_charging_period.py +27 -0
  439. evcloud/types/ocpi_display_text.py +24 -0
  440. evcloud/types/ocpi_energy_mix.py +29 -0
  441. evcloud/types/ocpi_energy_mix_input.py +29 -0
  442. evcloud/types/ocpi_energy_source.py +24 -0
  443. evcloud/types/ocpi_energy_source_input.py +24 -0
  444. evcloud/types/ocpi_environmental_impact.py +24 -0
  445. evcloud/types/ocpi_evse_parking.py +24 -0
  446. evcloud/types/ocpi_exceptional_period.py +25 -0
  447. evcloud/types/ocpi_geo_location.py +24 -0
  448. evcloud/types/ocpi_geo_location_in.py +24 -0
  449. evcloud/types/ocpi_image.py +28 -0
  450. evcloud/types/ocpi_image_input.py +28 -0
  451. evcloud/types/ocpi_opening_times.py +28 -0
  452. evcloud/types/ocpi_opening_times_input.py +28 -0
  453. evcloud/types/ocpi_parking_place.py +44 -0
  454. evcloud/types/ocpi_parking_place_input.py +44 -0
  455. evcloud/types/ocpi_price_component_input.py +28 -0
  456. evcloud/types/ocpi_price_component_input_price.py +5 -0
  457. evcloud/types/ocpi_price_component_input_vat.py +5 -0
  458. evcloud/types/ocpi_price_component_output.py +26 -0
  459. evcloud/types/ocpi_price_input.py +26 -0
  460. evcloud/types/ocpi_price_input_excl_vat.py +5 -0
  461. evcloud/types/ocpi_price_input_incl_vat.py +5 -0
  462. evcloud/types/ocpi_price_output.py +24 -0
  463. evcloud/types/ocpi_publish_token.py +27 -0
  464. evcloud/types/ocpi_regular_hours.py +25 -0
  465. evcloud/types/ocpi_regular_hours_input.py +25 -0
  466. evcloud/types/ocpi_related_location.py +26 -0
  467. evcloud/types/ocpi_signed_data.py +28 -0
  468. evcloud/types/ocpi_signed_value.py +25 -0
  469. evcloud/types/ocpi_status_schedule.py +26 -0
  470. evcloud/types/ocpi_tariff_element_input.py +26 -0
  471. evcloud/types/ocpi_tariff_element_output.py +26 -0
  472. evcloud/types/ocpi_tariff_restrictions_input.py +33 -0
  473. evcloud/types/ocpi_tariff_restrictions_input_max_kwh.py +5 -0
  474. evcloud/types/ocpi_tariff_restrictions_input_min_kwh.py +5 -0
  475. evcloud/types/ocpi_tariff_restrictions_output.py +31 -0
  476. evcloud/types/ocpi_tariff_snapshot.py +26 -0
  477. evcloud/types/ocpp_version.py +5 -0
  478. evcloud/types/page_info.py +24 -0
  479. evcloud/types/parking.py +45 -0
  480. evcloud/types/parking_direction.py +7 -0
  481. evcloud/types/parking_direction_zero.py +5 -0
  482. evcloud/types/parking_type.py +8 -0
  483. evcloud/types/parking_vehicle_types_item.py +7 -0
  484. evcloud/types/parking_vehicle_types_item_zero.py +18 -0
  485. evcloud/types/partner_invite_response.py +47 -0
  486. evcloud/types/partner_invite_response_action.py +5 -0
  487. evcloud/types/partner_invite_response_role.py +5 -0
  488. evcloud/types/partner_invite_response_version.py +5 -0
  489. evcloud/types/partner_invite_revoke_response.py +31 -0
  490. evcloud/types/partner_invite_revoke_response_role.py +5 -0
  491. evcloud/types/partner_response.py +41 -0
  492. evcloud/types/partner_response_ocpi_version.py +5 -0
  493. evcloud/types/partner_token_updated_event.py +35 -0
  494. evcloud/types/partner_versions_pull_response.py +29 -0
  495. evcloud/types/partner_versions_pull_response_code.py +8 -0
  496. evcloud/types/partner_versions_pull_response_version.py +5 -0
  497. evcloud/types/power_measurement.py +30 -0
  498. evcloud/types/power_measurement_event.py +30 -0
  499. evcloud/types/power_measurement_list.py +24 -0
  500. evcloud/types/power_type.py +5 -0
  501. evcloud/types/price_component.py +26 -0
  502. evcloud/types/price_limit.py +24 -0
  503. evcloud/types/pricing_mode.py +5 -0
  504. evcloud/types/queue_health.py +34 -0
  505. evcloud/types/reservation_cancel_response.py +25 -0
  506. evcloud/types/resolve_chargers_response_own.py +28 -0
  507. evcloud/types/resolve_chargers_response_own_ocpi_version.py +7 -0
  508. evcloud/types/resolve_chargers_response_own_ocpi_version_zero.py +5 -0
  509. evcloud/types/resolve_chargers_response_roaming.py +30 -0
  510. evcloud/types/resolve_chargers_response_roaming_ocpi_version.py +7 -0
  511. evcloud/types/resolve_chargers_response_roaming_ocpi_version_zero.py +5 -0
  512. evcloud/types/session_event.py +39 -0
  513. evcloud/types/session_out.py +60 -0
  514. evcloud/types/session_out_auth_method.py +7 -0
  515. evcloud/types/session_out_auth_method_zero.py +5 -0
  516. evcloud/types/session_out_billing_state.py +7 -0
  517. evcloud/types/session_out_billing_state_zero.py +5 -0
  518. evcloud/types/session_out_origin.py +7 -0
  519. evcloud/types/session_out_origin_zero.py +5 -0
  520. evcloud/types/session_out_status.py +7 -0
  521. evcloud/types/session_out_status_zero.py +7 -0
  522. evcloud/types/session_page.py +27 -0
  523. evcloud/types/session_write_response.py +27 -0
  524. evcloud/types/sharing_slot.py +25 -0
  525. evcloud/types/sharing_slot_input.py +25 -0
  526. evcloud/types/site_type.py +5 -0
  527. evcloud/types/sync_patch_request.py +26 -0
  528. evcloud/types/sync_pull_response.py +31 -0
  529. evcloud/types/sync_push_response.py +31 -0
  530. evcloud/types/sync_push_response_status.py +5 -0
  531. evcloud/types/tariff.py +42 -0
  532. evcloud/types/tariff_assignment_out.py +32 -0
  533. evcloud/types/tariff_assignment_page.py +27 -0
  534. evcloud/types/tariff_delete_response.py +26 -0
  535. evcloud/types/tariff_display.py +27 -0
  536. evcloud/types/tariff_element.py +26 -0
  537. evcloud/types/tariff_out.py +57 -0
  538. evcloud/types/tariff_out_origin.py +7 -0
  539. evcloud/types/tariff_out_origin_zero.py +5 -0
  540. evcloud/types/tariff_out_tax_included.py +7 -0
  541. evcloud/types/tariff_out_tax_included_zero.py +5 -0
  542. evcloud/types/tariff_out_type.py +7 -0
  543. evcloud/types/tariff_out_type_zero.py +7 -0
  544. evcloud/types/tariff_page.py +27 -0
  545. evcloud/types/tariff_restrictions.py +36 -0
  546. evcloud/types/tariff_summary.py +29 -0
  547. evcloud/types/tariff_tax_included.py +7 -0
  548. evcloud/types/tariff_tax_included_zero.py +5 -0
  549. evcloud/types/tariff_type.py +7 -0
  550. evcloud/types/tariff_updated_event.py +29 -0
  551. evcloud/types/tariff_write_response.py +26 -0
  552. evcloud/types/tax_included.py +5 -0
  553. evcloud/types/tenant_profile_out.py +31 -0
  554. evcloud/types/token_bulk_out.py +26 -0
  555. evcloud/types/token_create.py +46 -0
  556. evcloud/types/token_create_default_profile_type.py +5 -0
  557. evcloud/types/token_create_ocpi_version.py +5 -0
  558. evcloud/types/token_create_type.py +5 -0
  559. evcloud/types/token_create_whitelist.py +5 -0
  560. evcloud/types/token_event_data.py +47 -0
  561. evcloud/types/token_event_data_status.py +7 -0
  562. evcloud/types/token_event_data_type.py +5 -0
  563. evcloud/types/token_event_data_whitelist.py +5 -0
  564. evcloud/types/token_event_out.py +32 -0
  565. evcloud/types/token_event_out_event.py +7 -0
  566. evcloud/types/token_event_out_event_zero.py +7 -0
  567. evcloud/types/token_event_page.py +26 -0
  568. evcloud/types/token_failure_item.py +24 -0
  569. evcloud/types/token_group_action_out.py +27 -0
  570. evcloud/types/token_group_failure.py +24 -0
  571. evcloud/types/token_group_member_out.py +26 -0
  572. evcloud/types/token_group_network_out.py +35 -0
  573. evcloud/types/token_group_network_page.py +26 -0
  574. evcloud/types/token_group_out.py +31 -0
  575. evcloud/types/token_group_page.py +26 -0
  576. evcloud/types/token_out.py +55 -0
  577. evcloud/types/token_out_status.py +7 -0
  578. evcloud/types/token_out_status_zero.py +7 -0
  579. evcloud/types/token_out_type.py +7 -0
  580. evcloud/types/token_out_type_zero.py +5 -0
  581. evcloud/types/token_out_whitelist.py +7 -0
  582. evcloud/types/token_out_whitelist_zero.py +5 -0
  583. evcloud/types/token_page.py +26 -0
  584. evcloud/types/token_reason.py +23 -0
  585. evcloud/types/token_ref.py +26 -0
  586. evcloud/types/token_ref_ocpi_version.py +5 -0
  587. evcloud/types/token_write_response.py +28 -0
  588. evcloud/types/validation_error.py +28 -0
  589. evcloud/types/validation_error_loc_item.py +5 -0
  590. evcloud/types/webhook_delivery_page.py +27 -0
  591. evcloud/types/webhook_delivery_response.py +35 -0
  592. evcloud/types/webhook_page.py +27 -0
  593. evcloud/types/webhook_response.py +42 -0
  594. evcloud/types/webhook_response_event.py +7 -0
  595. evcloud/types/webhook_response_event_zero.py +27 -0
  596. evcloud/types/webhook_response_status.py +7 -0
  597. evcloud/types/webhook_response_status_zero.py +5 -0
  598. evcloud/types/webhook_test_result.py +25 -0
  599. evcloud/types/webhook_with_secret_response.py +43 -0
  600. evcloud/types/webhook_with_secret_response_event.py +7 -0
  601. evcloud/types/webhook_with_secret_response_event_zero.py +27 -0
  602. evcloud/types/webhook_with_secret_response_status.py +7 -0
  603. evcloud/types/webhook_with_secret_response_status_zero.py +5 -0
  604. evcloud/version.py +3 -0
  605. evcloud/webhooks/__init__.py +28 -0
  606. evcloud/webhooks/client.py +53 -0
  607. evcloud/webhooks/deliveries/__init__.py +4 -0
  608. evcloud/webhooks/deliveries/client.py +141 -0
  609. evcloud/webhooks/deliveries/raw_client.py +268 -0
  610. evcloud/webhooks/endpoints/__init__.py +17 -0
  611. evcloud/webhooks/endpoints/client.py +642 -0
  612. evcloud/webhooks/endpoints/raw_client.py +1521 -0
  613. evcloud/webhooks/endpoints/types/__init__.py +15 -0
  614. evcloud/webhooks/endpoints/types/list_endpoints_request_event_types_item.py +27 -0
  615. evcloud/webhooks/endpoints/types/webhook_create_request_api_version.py +5 -0
  616. evcloud/webhooks/endpoints/types/webhook_create_request_event.py +27 -0
  617. evcloud/webhooks/endpoints/types/webhook_update_request_status.py +5 -0
  618. evcloud/webhooks/event_types/__init__.py +7 -0
  619. evcloud/webhooks/event_types/client.py +176 -0
  620. evcloud/webhooks/event_types/raw_client.py +418 -0
  621. evcloud/webhooks/event_types/types/__init__.py +7 -0
  622. evcloud/webhooks/event_types/types/get_event_types_request_type.py +27 -0
  623. evcloud/webhooks/events/__init__.py +7 -0
  624. evcloud/webhooks/events/client.py +207 -0
  625. evcloud/webhooks/events/raw_client.py +355 -0
  626. evcloud/webhooks/events/types/__init__.py +8 -0
  627. evcloud/webhooks/events/types/deliver_event_request_data.py +33 -0
  628. evcloud/webhooks/events/types/deliver_event_request_event.py +27 -0
  629. evcloud/webhooks/health/__init__.py +4 -0
  630. evcloud/webhooks/health/client.py +161 -0
  631. evcloud/webhooks/health/raw_client.py +380 -0
  632. evcloud/webhooks/raw_client.py +13 -0
  633. evcloud-0.1.0.dist-info/METADATA +257 -0
  634. evcloud-0.1.0.dist-info/RECORD +635 -0
  635. evcloud-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,2526 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+ from json.decoder import JSONDecodeError
6
+
7
+ from ...core.api_error import ApiError
8
+ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from ...core.datetime_utils import serialize_datetime
10
+ from ...core.http_response import AsyncHttpResponse, HttpResponse
11
+ from ...core.jsonable_encoder import encode_path_param
12
+ from ...core.pagination import AsyncPager, SyncPager
13
+ from ...core.parse_error import ParsingError
14
+ from ...core.pydantic_utilities import parse_obj_as
15
+ from ...core.request_options import RequestOptions
16
+ from ...core.serialization import convert_and_respect_annotation_metadata
17
+ from ...errors.bad_gateway_error import BadGatewayError
18
+ from ...errors.bad_request_error import BadRequestError
19
+ from ...errors.conflict_error import ConflictError
20
+ from ...errors.gateway_timeout_error import GatewayTimeoutError
21
+ from ...errors.not_found_error import NotFoundError
22
+ from ...errors.too_many_requests_error import TooManyRequestsError
23
+ from ...errors.unauthorized_error import UnauthorizedError
24
+ from ...errors.unprocessable_entity_error import UnprocessableEntityError
25
+ from ...types.http_error_response import HttpErrorResponse
26
+ from ...types.http_validation_error import HttpValidationError
27
+ from ...types.ocpi_display_text import OcpiDisplayText
28
+ from ...types.ocpi_energy_mix_input import OcpiEnergyMixInput
29
+ from ...types.ocpi_price_input import OcpiPriceInput
30
+ from ...types.ocpi_tariff_element_input import OcpiTariffElementInput
31
+ from ...types.tariff_assignment_out import TariffAssignmentOut
32
+ from ...types.tariff_assignment_page import TariffAssignmentPage
33
+ from ...types.tariff_out import TariffOut
34
+ from ...types.tariff_page import TariffPage
35
+ from ...types.tariff_type import TariffType
36
+ from ...types.tax_included import TaxIncluded
37
+ from .types.list_tariffs_request_type import ListTariffsRequestType
38
+ from .types.tariff_create_ocpi_version import TariffCreateOcpiVersion
39
+ from .types.tariff_create_preauthorize_amount import TariffCreatePreauthorizeAmount
40
+ from .types.tariff_patch_preauthorize_amount import TariffPatchPreauthorizeAmount
41
+ from pydantic import ValidationError
42
+
43
+ # this is used as the default value for optional parameters
44
+ OMIT = typing.cast(typing.Any, ...)
45
+
46
+
47
+ class RawTariffsClient:
48
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
49
+ self._client_wrapper = client_wrapper
50
+
51
+ def list_assignments(
52
+ self,
53
+ *,
54
+ tariff_id: typing.Optional[str] = None,
55
+ charge_point_id: typing.Optional[str] = None,
56
+ include_deleted: typing.Optional[bool] = None,
57
+ date_from: typing.Optional[dt.datetime] = None,
58
+ date_to: typing.Optional[dt.datetime] = None,
59
+ offset: typing.Optional[int] = None,
60
+ limit: typing.Optional[int] = None,
61
+ request_options: typing.Optional[RequestOptions] = None,
62
+ ) -> SyncPager[TariffAssignmentOut, TariffAssignmentPage]:
63
+ """
64
+ Which tariff each of your chargers uses, newest first. A charger uses one tariff at a time. Ended assignments are history, returned with ``include_deleted``. ``date_from`` and ``date_to`` filter on when the charger started using the tariff.
65
+
66
+ Parameters
67
+ ----------
68
+ tariff_id : typing.Optional[str]
69
+ Only this OCPI tariff id.
70
+
71
+ charge_point_id : typing.Optional[str]
72
+ Only this charger (its OCPP identity).
73
+
74
+ include_deleted : typing.Optional[bool]
75
+ Also return assignments that have ended.
76
+
77
+ date_from : typing.Optional[dt.datetime]
78
+ Only rows starting at or after this time (inclusive).
79
+
80
+ date_to : typing.Optional[dt.datetime]
81
+ Only rows starting before this time (exclusive).
82
+
83
+ offset : typing.Optional[int]
84
+ Rows to skip. Pass the previous page's ``next_offset`` to continue.
85
+
86
+ limit : typing.Optional[int]
87
+ Maximum rows per page (default 50, max 200).
88
+
89
+ request_options : typing.Optional[RequestOptions]
90
+ Request-specific configuration.
91
+
92
+ Returns
93
+ -------
94
+ SyncPager[TariffAssignmentOut, TariffAssignmentPage]
95
+ One page of results; ``next_offset`` is null on the last page.
96
+ """
97
+ _response = self._client_wrapper.httpx_client.request(
98
+ "cpo/tariff-assignments",
99
+ method="GET",
100
+ params={
101
+ "tariff_id": tariff_id,
102
+ "charge_point_id": charge_point_id,
103
+ "include_deleted": include_deleted,
104
+ "date_from": serialize_datetime(date_from) if date_from is not None else None,
105
+ "date_to": serialize_datetime(date_to) if date_to is not None else None,
106
+ "offset": offset,
107
+ "limit": limit,
108
+ },
109
+ request_options=request_options,
110
+ )
111
+ try:
112
+ if 200 <= _response.status_code < 300:
113
+ _parsed_response = typing.cast(
114
+ TariffAssignmentPage,
115
+ parse_obj_as(
116
+ type_=TariffAssignmentPage, # type: ignore
117
+ object_=_response.json(),
118
+ ),
119
+ )
120
+ _items = _parsed_response.items
121
+ _parsed_next = _parsed_response.next_offset
122
+ _has_next = _parsed_next is not None and _parsed_next != ""
123
+ _get_next = lambda: self.list_assignments(
124
+ tariff_id=tariff_id,
125
+ charge_point_id=charge_point_id,
126
+ include_deleted=include_deleted,
127
+ date_from=date_from,
128
+ date_to=date_to,
129
+ offset=_parsed_next,
130
+ limit=limit,
131
+ request_options=request_options,
132
+ )
133
+ return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
134
+ if _response.status_code == 401:
135
+ raise UnauthorizedError(
136
+ headers=dict(_response.headers),
137
+ body=typing.cast(
138
+ HttpErrorResponse,
139
+ parse_obj_as(
140
+ type_=HttpErrorResponse, # type: ignore
141
+ object_=_response.json(),
142
+ ),
143
+ ),
144
+ )
145
+ if _response.status_code == 422:
146
+ raise UnprocessableEntityError(
147
+ headers=dict(_response.headers),
148
+ body=typing.cast(
149
+ HttpValidationError,
150
+ parse_obj_as(
151
+ type_=HttpValidationError, # type: ignore
152
+ object_=_response.json(),
153
+ ),
154
+ ),
155
+ )
156
+ if _response.status_code == 429:
157
+ raise TooManyRequestsError(
158
+ headers=dict(_response.headers),
159
+ body=typing.cast(
160
+ HttpErrorResponse,
161
+ parse_obj_as(
162
+ type_=HttpErrorResponse, # type: ignore
163
+ object_=_response.json(),
164
+ ),
165
+ ),
166
+ )
167
+ if _response.status_code == 502:
168
+ raise BadGatewayError(
169
+ headers=dict(_response.headers),
170
+ body=typing.cast(
171
+ HttpErrorResponse,
172
+ parse_obj_as(
173
+ type_=HttpErrorResponse, # type: ignore
174
+ object_=_response.json(),
175
+ ),
176
+ ),
177
+ )
178
+ if _response.status_code == 504:
179
+ raise GatewayTimeoutError(
180
+ headers=dict(_response.headers),
181
+ body=typing.cast(
182
+ HttpErrorResponse,
183
+ parse_obj_as(
184
+ type_=HttpErrorResponse, # type: ignore
185
+ object_=_response.json(),
186
+ ),
187
+ ),
188
+ )
189
+ _response_json = _response.json()
190
+ except JSONDecodeError:
191
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
192
+ except ValidationError as e:
193
+ raise ParsingError(
194
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
195
+ )
196
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
197
+
198
+ def list(
199
+ self,
200
+ *,
201
+ currency: typing.Optional[str] = None,
202
+ type: typing.Optional[ListTariffsRequestType] = None,
203
+ country_code: typing.Optional[str] = None,
204
+ party_id: typing.Optional[str] = None,
205
+ date_from: typing.Optional[dt.datetime] = None,
206
+ date_to: typing.Optional[dt.datetime] = None,
207
+ offset: typing.Optional[int] = None,
208
+ limit: typing.Optional[int] = None,
209
+ request_options: typing.Optional[RequestOptions] = None,
210
+ ) -> SyncPager[TariffOut, TariffPage]:
211
+ """
212
+ Your live tariffs, most recently changed first. ``date_from`` and ``date_to`` filter on ``last_updated``.
213
+
214
+ Parameters
215
+ ----------
216
+ currency : typing.Optional[str]
217
+ Only this ISO 4217 currency, e.g. EUR.
218
+
219
+ type : typing.Optional[ListTariffsRequestType]
220
+ Only tariffs of this OCPI type.
221
+
222
+ country_code : typing.Optional[str]
223
+ Only this OCPI party country code, e.g. NL.
224
+
225
+ party_id : typing.Optional[str]
226
+ Only this OCPI party id, e.g. OCP.
227
+
228
+ date_from : typing.Optional[dt.datetime]
229
+ Only rows starting at or after this time (inclusive).
230
+
231
+ date_to : typing.Optional[dt.datetime]
232
+ Only rows starting before this time (exclusive).
233
+
234
+ offset : typing.Optional[int]
235
+ Rows to skip. Pass the previous page's ``next_offset`` to continue.
236
+
237
+ limit : typing.Optional[int]
238
+ Maximum rows per page (default 50, max 200).
239
+
240
+ request_options : typing.Optional[RequestOptions]
241
+ Request-specific configuration.
242
+
243
+ Returns
244
+ -------
245
+ SyncPager[TariffOut, TariffPage]
246
+ One page of results; ``next_offset`` is null on the last page.
247
+ """
248
+ _response = self._client_wrapper.httpx_client.request(
249
+ "cpo/tariffs",
250
+ method="GET",
251
+ params={
252
+ "currency": currency,
253
+ "type": type,
254
+ "country_code": country_code,
255
+ "party_id": party_id,
256
+ "date_from": serialize_datetime(date_from) if date_from is not None else None,
257
+ "date_to": serialize_datetime(date_to) if date_to is not None else None,
258
+ "offset": offset,
259
+ "limit": limit,
260
+ },
261
+ request_options=request_options,
262
+ )
263
+ try:
264
+ if 200 <= _response.status_code < 300:
265
+ _parsed_response = typing.cast(
266
+ TariffPage,
267
+ parse_obj_as(
268
+ type_=TariffPage, # type: ignore
269
+ object_=_response.json(),
270
+ ),
271
+ )
272
+ _items = _parsed_response.items
273
+ _parsed_next = _parsed_response.next_offset
274
+ _has_next = _parsed_next is not None and _parsed_next != ""
275
+ _get_next = lambda: self.list(
276
+ currency=currency,
277
+ type=type,
278
+ country_code=country_code,
279
+ party_id=party_id,
280
+ date_from=date_from,
281
+ date_to=date_to,
282
+ offset=_parsed_next,
283
+ limit=limit,
284
+ request_options=request_options,
285
+ )
286
+ return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
287
+ if _response.status_code == 401:
288
+ raise UnauthorizedError(
289
+ headers=dict(_response.headers),
290
+ body=typing.cast(
291
+ HttpErrorResponse,
292
+ parse_obj_as(
293
+ type_=HttpErrorResponse, # type: ignore
294
+ object_=_response.json(),
295
+ ),
296
+ ),
297
+ )
298
+ if _response.status_code == 422:
299
+ raise UnprocessableEntityError(
300
+ headers=dict(_response.headers),
301
+ body=typing.cast(
302
+ HttpValidationError,
303
+ parse_obj_as(
304
+ type_=HttpValidationError, # type: ignore
305
+ object_=_response.json(),
306
+ ),
307
+ ),
308
+ )
309
+ if _response.status_code == 429:
310
+ raise TooManyRequestsError(
311
+ headers=dict(_response.headers),
312
+ body=typing.cast(
313
+ HttpErrorResponse,
314
+ parse_obj_as(
315
+ type_=HttpErrorResponse, # type: ignore
316
+ object_=_response.json(),
317
+ ),
318
+ ),
319
+ )
320
+ if _response.status_code == 502:
321
+ raise BadGatewayError(
322
+ headers=dict(_response.headers),
323
+ body=typing.cast(
324
+ HttpErrorResponse,
325
+ parse_obj_as(
326
+ type_=HttpErrorResponse, # type: ignore
327
+ object_=_response.json(),
328
+ ),
329
+ ),
330
+ )
331
+ if _response.status_code == 504:
332
+ raise GatewayTimeoutError(
333
+ headers=dict(_response.headers),
334
+ body=typing.cast(
335
+ HttpErrorResponse,
336
+ parse_obj_as(
337
+ type_=HttpErrorResponse, # type: ignore
338
+ object_=_response.json(),
339
+ ),
340
+ ),
341
+ )
342
+ _response_json = _response.json()
343
+ except JSONDecodeError:
344
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
345
+ except ValidationError as e:
346
+ raise ParsingError(
347
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
348
+ )
349
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
350
+
351
+ def create(
352
+ self,
353
+ *,
354
+ tariff_id: str,
355
+ currency: str,
356
+ elements: typing.Sequence[OcpiTariffElementInput],
357
+ country_code: typing.Optional[str] = OMIT,
358
+ party_id: typing.Optional[str] = OMIT,
359
+ type: typing.Optional[TariffType] = OMIT,
360
+ tariff_alt_text: typing.Optional[typing.Sequence[OcpiDisplayText]] = OMIT,
361
+ tariff_alt_url: typing.Optional[str] = OMIT,
362
+ min_price: typing.Optional[OcpiPriceInput] = OMIT,
363
+ max_price: typing.Optional[OcpiPriceInput] = OMIT,
364
+ preauthorize_amount: typing.Optional[TariffCreatePreauthorizeAmount] = OMIT,
365
+ tax_included: typing.Optional[TaxIncluded] = OMIT,
366
+ start_date_time: typing.Optional[dt.datetime] = OMIT,
367
+ end_date_time: typing.Optional[dt.datetime] = OMIT,
368
+ energy_mix: typing.Optional[OcpiEnergyMixInput] = OMIT,
369
+ p2p_preset: typing.Optional[bool] = OMIT,
370
+ is_roaming: typing.Optional[bool] = OMIT,
371
+ ocpi_version: typing.Optional[TariffCreateOcpiVersion] = OMIT,
372
+ request_options: typing.Optional[RequestOptions] = None,
373
+ ) -> HttpResponse[TariffOut]:
374
+ """
375
+ Creates a tariff under your OCPI party. The id of a deleted tariff brings that tariff back as the body describes it. ``is_roaming`` marks it for roaming partners. Assign it to chargers with ``POST /cpo/tariffs/{tariff_id}/assign``.
376
+
377
+ Parameters
378
+ ----------
379
+ tariff_id : str
380
+
381
+ currency : str
382
+
383
+ elements : typing.Sequence[OcpiTariffElementInput]
384
+
385
+ country_code : typing.Optional[str]
386
+
387
+ party_id : typing.Optional[str]
388
+
389
+ type : typing.Optional[TariffType]
390
+
391
+ tariff_alt_text : typing.Optional[typing.Sequence[OcpiDisplayText]]
392
+
393
+ tariff_alt_url : typing.Optional[str]
394
+
395
+ min_price : typing.Optional[OcpiPriceInput]
396
+
397
+ max_price : typing.Optional[OcpiPriceInput]
398
+
399
+ preauthorize_amount : typing.Optional[TariffCreatePreauthorizeAmount]
400
+
401
+ tax_included : typing.Optional[TaxIncluded]
402
+
403
+ start_date_time : typing.Optional[dt.datetime]
404
+
405
+ end_date_time : typing.Optional[dt.datetime]
406
+
407
+ energy_mix : typing.Optional[OcpiEnergyMixInput]
408
+
409
+ p2p_preset : typing.Optional[bool]
410
+
411
+ is_roaming : typing.Optional[bool]
412
+
413
+ ocpi_version : typing.Optional[TariffCreateOcpiVersion]
414
+
415
+ request_options : typing.Optional[RequestOptions]
416
+ Request-specific configuration.
417
+
418
+ Returns
419
+ -------
420
+ HttpResponse[TariffOut]
421
+ The created object.
422
+ """
423
+ _request_options_with_retries_disabled: typing.Optional[RequestOptions] = (
424
+ {**request_options, "max_retries": 0} if request_options is not None else {"max_retries": 0}
425
+ )
426
+ _response = self._client_wrapper.httpx_client.request(
427
+ "cpo/tariffs",
428
+ method="POST",
429
+ json={
430
+ "tariff_id": tariff_id,
431
+ "currency": currency,
432
+ "country_code": country_code,
433
+ "party_id": party_id,
434
+ "elements": convert_and_respect_annotation_metadata(
435
+ object_=elements, annotation=typing.Sequence[OcpiTariffElementInput], direction="write"
436
+ ),
437
+ "type": type,
438
+ "tariff_alt_text": convert_and_respect_annotation_metadata(
439
+ object_=tariff_alt_text,
440
+ annotation=typing.Optional[typing.Sequence[OcpiDisplayText]],
441
+ direction="write",
442
+ ),
443
+ "tariff_alt_url": tariff_alt_url,
444
+ "min_price": convert_and_respect_annotation_metadata(
445
+ object_=min_price, annotation=typing.Optional[OcpiPriceInput], direction="write"
446
+ ),
447
+ "max_price": convert_and_respect_annotation_metadata(
448
+ object_=max_price, annotation=typing.Optional[OcpiPriceInput], direction="write"
449
+ ),
450
+ "preauthorize_amount": convert_and_respect_annotation_metadata(
451
+ object_=preauthorize_amount,
452
+ annotation=typing.Optional[TariffCreatePreauthorizeAmount],
453
+ direction="write",
454
+ ),
455
+ "tax_included": tax_included,
456
+ "start_date_time": start_date_time,
457
+ "end_date_time": end_date_time,
458
+ "energy_mix": convert_and_respect_annotation_metadata(
459
+ object_=energy_mix, annotation=typing.Optional[OcpiEnergyMixInput], direction="write"
460
+ ),
461
+ "p2p_preset": p2p_preset,
462
+ "is_roaming": is_roaming,
463
+ "ocpi_version": ocpi_version,
464
+ },
465
+ headers={
466
+ "content-type": "application/json",
467
+ },
468
+ request_options=_request_options_with_retries_disabled,
469
+ omit=OMIT,
470
+ )
471
+ try:
472
+ if 200 <= _response.status_code < 300:
473
+ _data = typing.cast(
474
+ TariffOut,
475
+ parse_obj_as(
476
+ type_=TariffOut, # type: ignore
477
+ object_=_response.json(),
478
+ ),
479
+ )
480
+ return HttpResponse(response=_response, data=_data)
481
+ if _response.status_code == 400:
482
+ raise BadRequestError(
483
+ headers=dict(_response.headers),
484
+ body=typing.cast(
485
+ HttpErrorResponse,
486
+ parse_obj_as(
487
+ type_=HttpErrorResponse, # type: ignore
488
+ object_=_response.json(),
489
+ ),
490
+ ),
491
+ )
492
+ if _response.status_code == 401:
493
+ raise UnauthorizedError(
494
+ headers=dict(_response.headers),
495
+ body=typing.cast(
496
+ HttpErrorResponse,
497
+ parse_obj_as(
498
+ type_=HttpErrorResponse, # type: ignore
499
+ object_=_response.json(),
500
+ ),
501
+ ),
502
+ )
503
+ if _response.status_code == 409:
504
+ raise ConflictError(
505
+ headers=dict(_response.headers),
506
+ body=typing.cast(
507
+ HttpErrorResponse,
508
+ parse_obj_as(
509
+ type_=HttpErrorResponse, # type: ignore
510
+ object_=_response.json(),
511
+ ),
512
+ ),
513
+ )
514
+ if _response.status_code == 422:
515
+ raise UnprocessableEntityError(
516
+ headers=dict(_response.headers),
517
+ body=typing.cast(
518
+ HttpValidationError,
519
+ parse_obj_as(
520
+ type_=HttpValidationError, # type: ignore
521
+ object_=_response.json(),
522
+ ),
523
+ ),
524
+ )
525
+ if _response.status_code == 429:
526
+ raise TooManyRequestsError(
527
+ headers=dict(_response.headers),
528
+ body=typing.cast(
529
+ HttpErrorResponse,
530
+ parse_obj_as(
531
+ type_=HttpErrorResponse, # type: ignore
532
+ object_=_response.json(),
533
+ ),
534
+ ),
535
+ )
536
+ if _response.status_code == 502:
537
+ raise BadGatewayError(
538
+ headers=dict(_response.headers),
539
+ body=typing.cast(
540
+ HttpErrorResponse,
541
+ parse_obj_as(
542
+ type_=HttpErrorResponse, # type: ignore
543
+ object_=_response.json(),
544
+ ),
545
+ ),
546
+ )
547
+ if _response.status_code == 504:
548
+ raise GatewayTimeoutError(
549
+ headers=dict(_response.headers),
550
+ body=typing.cast(
551
+ HttpErrorResponse,
552
+ parse_obj_as(
553
+ type_=HttpErrorResponse, # type: ignore
554
+ object_=_response.json(),
555
+ ),
556
+ ),
557
+ )
558
+ _response_json = _response.json()
559
+ except JSONDecodeError:
560
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
561
+ except ValidationError as e:
562
+ raise ParsingError(
563
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
564
+ )
565
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
566
+
567
+ def get(
568
+ self,
569
+ tariff_id: str,
570
+ *,
571
+ country_code: typing.Optional[str] = None,
572
+ party_id: typing.Optional[str] = None,
573
+ request_options: typing.Optional[RequestOptions] = None,
574
+ ) -> HttpResponse[TariffOut]:
575
+ """
576
+ One tariff by OCPI id. If two parties use the same id, pass ``country_code`` and ``party_id`` (409 otherwise).
577
+
578
+ Parameters
579
+ ----------
580
+ tariff_id : str
581
+ OCPI tariff id.
582
+
583
+ country_code : typing.Optional[str]
584
+ Only this OCPI party country code, e.g. NL.
585
+
586
+ party_id : typing.Optional[str]
587
+ Only this OCPI party id, e.g. OCP.
588
+
589
+ request_options : typing.Optional[RequestOptions]
590
+ Request-specific configuration.
591
+
592
+ Returns
593
+ -------
594
+ HttpResponse[TariffOut]
595
+ The requested object.
596
+ """
597
+ _response = self._client_wrapper.httpx_client.request(
598
+ f"cpo/tariffs/{encode_path_param(tariff_id)}",
599
+ method="GET",
600
+ params={
601
+ "country_code": country_code,
602
+ "party_id": party_id,
603
+ },
604
+ request_options=request_options,
605
+ )
606
+ try:
607
+ if 200 <= _response.status_code < 300:
608
+ _data = typing.cast(
609
+ TariffOut,
610
+ parse_obj_as(
611
+ type_=TariffOut, # type: ignore
612
+ object_=_response.json(),
613
+ ),
614
+ )
615
+ return HttpResponse(response=_response, data=_data)
616
+ if _response.status_code == 401:
617
+ raise UnauthorizedError(
618
+ headers=dict(_response.headers),
619
+ body=typing.cast(
620
+ HttpErrorResponse,
621
+ parse_obj_as(
622
+ type_=HttpErrorResponse, # type: ignore
623
+ object_=_response.json(),
624
+ ),
625
+ ),
626
+ )
627
+ if _response.status_code == 404:
628
+ raise NotFoundError(
629
+ headers=dict(_response.headers),
630
+ body=typing.cast(
631
+ HttpErrorResponse,
632
+ parse_obj_as(
633
+ type_=HttpErrorResponse, # type: ignore
634
+ object_=_response.json(),
635
+ ),
636
+ ),
637
+ )
638
+ if _response.status_code == 409:
639
+ raise ConflictError(
640
+ headers=dict(_response.headers),
641
+ body=typing.cast(
642
+ HttpErrorResponse,
643
+ parse_obj_as(
644
+ type_=HttpErrorResponse, # type: ignore
645
+ object_=_response.json(),
646
+ ),
647
+ ),
648
+ )
649
+ if _response.status_code == 422:
650
+ raise UnprocessableEntityError(
651
+ headers=dict(_response.headers),
652
+ body=typing.cast(
653
+ HttpValidationError,
654
+ parse_obj_as(
655
+ type_=HttpValidationError, # type: ignore
656
+ object_=_response.json(),
657
+ ),
658
+ ),
659
+ )
660
+ if _response.status_code == 429:
661
+ raise TooManyRequestsError(
662
+ headers=dict(_response.headers),
663
+ body=typing.cast(
664
+ HttpErrorResponse,
665
+ parse_obj_as(
666
+ type_=HttpErrorResponse, # type: ignore
667
+ object_=_response.json(),
668
+ ),
669
+ ),
670
+ )
671
+ if _response.status_code == 502:
672
+ raise BadGatewayError(
673
+ headers=dict(_response.headers),
674
+ body=typing.cast(
675
+ HttpErrorResponse,
676
+ parse_obj_as(
677
+ type_=HttpErrorResponse, # type: ignore
678
+ object_=_response.json(),
679
+ ),
680
+ ),
681
+ )
682
+ if _response.status_code == 504:
683
+ raise GatewayTimeoutError(
684
+ headers=dict(_response.headers),
685
+ body=typing.cast(
686
+ HttpErrorResponse,
687
+ parse_obj_as(
688
+ type_=HttpErrorResponse, # type: ignore
689
+ object_=_response.json(),
690
+ ),
691
+ ),
692
+ )
693
+ _response_json = _response.json()
694
+ except JSONDecodeError:
695
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
696
+ except ValidationError as e:
697
+ raise ParsingError(
698
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
699
+ )
700
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
701
+
702
+ def delete(self, tariff_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
703
+ """
704
+ Removes the tariff from reads; the chargers that use it stop using it. Sessions already started keep their price.
705
+
706
+ Parameters
707
+ ----------
708
+ tariff_id : str
709
+ OCPI tariff id.
710
+
711
+ request_options : typing.Optional[RequestOptions]
712
+ Request-specific configuration.
713
+
714
+ Returns
715
+ -------
716
+ HttpResponse[None]
717
+ """
718
+ _response = self._client_wrapper.httpx_client.request(
719
+ f"cpo/tariffs/{encode_path_param(tariff_id)}",
720
+ method="DELETE",
721
+ request_options=request_options,
722
+ )
723
+ try:
724
+ if 200 <= _response.status_code < 300:
725
+ return HttpResponse(response=_response, data=None)
726
+ if _response.status_code == 401:
727
+ raise UnauthorizedError(
728
+ headers=dict(_response.headers),
729
+ body=typing.cast(
730
+ HttpErrorResponse,
731
+ parse_obj_as(
732
+ type_=HttpErrorResponse, # type: ignore
733
+ object_=_response.json(),
734
+ ),
735
+ ),
736
+ )
737
+ if _response.status_code == 404:
738
+ raise NotFoundError(
739
+ headers=dict(_response.headers),
740
+ body=typing.cast(
741
+ HttpErrorResponse,
742
+ parse_obj_as(
743
+ type_=HttpErrorResponse, # type: ignore
744
+ object_=_response.json(),
745
+ ),
746
+ ),
747
+ )
748
+ if _response.status_code == 409:
749
+ raise ConflictError(
750
+ headers=dict(_response.headers),
751
+ body=typing.cast(
752
+ HttpErrorResponse,
753
+ parse_obj_as(
754
+ type_=HttpErrorResponse, # type: ignore
755
+ object_=_response.json(),
756
+ ),
757
+ ),
758
+ )
759
+ if _response.status_code == 422:
760
+ raise UnprocessableEntityError(
761
+ headers=dict(_response.headers),
762
+ body=typing.cast(
763
+ HttpValidationError,
764
+ parse_obj_as(
765
+ type_=HttpValidationError, # type: ignore
766
+ object_=_response.json(),
767
+ ),
768
+ ),
769
+ )
770
+ if _response.status_code == 429:
771
+ raise TooManyRequestsError(
772
+ headers=dict(_response.headers),
773
+ body=typing.cast(
774
+ HttpErrorResponse,
775
+ parse_obj_as(
776
+ type_=HttpErrorResponse, # type: ignore
777
+ object_=_response.json(),
778
+ ),
779
+ ),
780
+ )
781
+ if _response.status_code == 502:
782
+ raise BadGatewayError(
783
+ headers=dict(_response.headers),
784
+ body=typing.cast(
785
+ HttpErrorResponse,
786
+ parse_obj_as(
787
+ type_=HttpErrorResponse, # type: ignore
788
+ object_=_response.json(),
789
+ ),
790
+ ),
791
+ )
792
+ if _response.status_code == 504:
793
+ raise GatewayTimeoutError(
794
+ headers=dict(_response.headers),
795
+ body=typing.cast(
796
+ HttpErrorResponse,
797
+ parse_obj_as(
798
+ type_=HttpErrorResponse, # type: ignore
799
+ object_=_response.json(),
800
+ ),
801
+ ),
802
+ )
803
+ _response_json = _response.json()
804
+ except JSONDecodeError:
805
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
806
+ except ValidationError as e:
807
+ raise ParsingError(
808
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
809
+ )
810
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
811
+
812
+ def update(
813
+ self,
814
+ tariff_id: str,
815
+ *,
816
+ currency: typing.Optional[str] = OMIT,
817
+ type: typing.Optional[TariffType] = OMIT,
818
+ tariff_alt_text: typing.Optional[typing.Sequence[OcpiDisplayText]] = OMIT,
819
+ tariff_alt_url: typing.Optional[str] = OMIT,
820
+ min_price: typing.Optional[OcpiPriceInput] = OMIT,
821
+ max_price: typing.Optional[OcpiPriceInput] = OMIT,
822
+ preauthorize_amount: typing.Optional[TariffPatchPreauthorizeAmount] = OMIT,
823
+ tax_included: typing.Optional[TaxIncluded] = OMIT,
824
+ elements: typing.Optional[typing.Sequence[OcpiTariffElementInput]] = OMIT,
825
+ start_date_time: typing.Optional[dt.datetime] = OMIT,
826
+ end_date_time: typing.Optional[dt.datetime] = OMIT,
827
+ energy_mix: typing.Optional[OcpiEnergyMixInput] = OMIT,
828
+ p2p_preset: typing.Optional[bool] = OMIT,
829
+ is_roaming: typing.Optional[bool] = OMIT,
830
+ expected_revision: typing.Optional[int] = OMIT,
831
+ request_options: typing.Optional[RequestOptions] = None,
832
+ ) -> HttpResponse[TariffOut]:
833
+ """
834
+ Changes only the fields sent; send null to clear an optional field. ``currency``, ``elements``, ``p2p_preset`` and ``is_roaming`` cannot be cleared. ``expected_revision`` refuses a lost update with 409. Sessions already started keep their price.
835
+
836
+ Parameters
837
+ ----------
838
+ tariff_id : str
839
+ OCPI tariff id.
840
+
841
+ currency : typing.Optional[str]
842
+
843
+ type : typing.Optional[TariffType]
844
+
845
+ tariff_alt_text : typing.Optional[typing.Sequence[OcpiDisplayText]]
846
+
847
+ tariff_alt_url : typing.Optional[str]
848
+
849
+ min_price : typing.Optional[OcpiPriceInput]
850
+
851
+ max_price : typing.Optional[OcpiPriceInput]
852
+
853
+ preauthorize_amount : typing.Optional[TariffPatchPreauthorizeAmount]
854
+
855
+ tax_included : typing.Optional[TaxIncluded]
856
+
857
+ elements : typing.Optional[typing.Sequence[OcpiTariffElementInput]]
858
+
859
+ start_date_time : typing.Optional[dt.datetime]
860
+
861
+ end_date_time : typing.Optional[dt.datetime]
862
+
863
+ energy_mix : typing.Optional[OcpiEnergyMixInput]
864
+
865
+ p2p_preset : typing.Optional[bool]
866
+
867
+ is_roaming : typing.Optional[bool]
868
+
869
+ expected_revision : typing.Optional[int]
870
+
871
+ request_options : typing.Optional[RequestOptions]
872
+ Request-specific configuration.
873
+
874
+ Returns
875
+ -------
876
+ HttpResponse[TariffOut]
877
+ The object after the update.
878
+ """
879
+ _response = self._client_wrapper.httpx_client.request(
880
+ f"cpo/tariffs/{encode_path_param(tariff_id)}",
881
+ method="PATCH",
882
+ json={
883
+ "currency": currency,
884
+ "type": type,
885
+ "tariff_alt_text": convert_and_respect_annotation_metadata(
886
+ object_=tariff_alt_text,
887
+ annotation=typing.Optional[typing.Sequence[OcpiDisplayText]],
888
+ direction="write",
889
+ ),
890
+ "tariff_alt_url": tariff_alt_url,
891
+ "min_price": convert_and_respect_annotation_metadata(
892
+ object_=min_price, annotation=typing.Optional[OcpiPriceInput], direction="write"
893
+ ),
894
+ "max_price": convert_and_respect_annotation_metadata(
895
+ object_=max_price, annotation=typing.Optional[OcpiPriceInput], direction="write"
896
+ ),
897
+ "preauthorize_amount": convert_and_respect_annotation_metadata(
898
+ object_=preauthorize_amount,
899
+ annotation=typing.Optional[TariffPatchPreauthorizeAmount],
900
+ direction="write",
901
+ ),
902
+ "tax_included": tax_included,
903
+ "elements": convert_and_respect_annotation_metadata(
904
+ object_=elements,
905
+ annotation=typing.Optional[typing.Sequence[OcpiTariffElementInput]],
906
+ direction="write",
907
+ ),
908
+ "start_date_time": start_date_time,
909
+ "end_date_time": end_date_time,
910
+ "energy_mix": convert_and_respect_annotation_metadata(
911
+ object_=energy_mix, annotation=typing.Optional[OcpiEnergyMixInput], direction="write"
912
+ ),
913
+ "p2p_preset": p2p_preset,
914
+ "is_roaming": is_roaming,
915
+ "expected_revision": expected_revision,
916
+ },
917
+ headers={
918
+ "content-type": "application/json",
919
+ },
920
+ request_options=request_options,
921
+ omit=OMIT,
922
+ )
923
+ try:
924
+ if 200 <= _response.status_code < 300:
925
+ _data = typing.cast(
926
+ TariffOut,
927
+ parse_obj_as(
928
+ type_=TariffOut, # type: ignore
929
+ object_=_response.json(),
930
+ ),
931
+ )
932
+ return HttpResponse(response=_response, data=_data)
933
+ if _response.status_code == 400:
934
+ raise BadRequestError(
935
+ headers=dict(_response.headers),
936
+ body=typing.cast(
937
+ HttpErrorResponse,
938
+ parse_obj_as(
939
+ type_=HttpErrorResponse, # type: ignore
940
+ object_=_response.json(),
941
+ ),
942
+ ),
943
+ )
944
+ if _response.status_code == 401:
945
+ raise UnauthorizedError(
946
+ headers=dict(_response.headers),
947
+ body=typing.cast(
948
+ HttpErrorResponse,
949
+ parse_obj_as(
950
+ type_=HttpErrorResponse, # type: ignore
951
+ object_=_response.json(),
952
+ ),
953
+ ),
954
+ )
955
+ if _response.status_code == 404:
956
+ raise NotFoundError(
957
+ headers=dict(_response.headers),
958
+ body=typing.cast(
959
+ HttpErrorResponse,
960
+ parse_obj_as(
961
+ type_=HttpErrorResponse, # type: ignore
962
+ object_=_response.json(),
963
+ ),
964
+ ),
965
+ )
966
+ if _response.status_code == 409:
967
+ raise ConflictError(
968
+ headers=dict(_response.headers),
969
+ body=typing.cast(
970
+ HttpErrorResponse,
971
+ parse_obj_as(
972
+ type_=HttpErrorResponse, # type: ignore
973
+ object_=_response.json(),
974
+ ),
975
+ ),
976
+ )
977
+ if _response.status_code == 422:
978
+ raise UnprocessableEntityError(
979
+ headers=dict(_response.headers),
980
+ body=typing.cast(
981
+ HttpValidationError,
982
+ parse_obj_as(
983
+ type_=HttpValidationError, # type: ignore
984
+ object_=_response.json(),
985
+ ),
986
+ ),
987
+ )
988
+ if _response.status_code == 429:
989
+ raise TooManyRequestsError(
990
+ headers=dict(_response.headers),
991
+ body=typing.cast(
992
+ HttpErrorResponse,
993
+ parse_obj_as(
994
+ type_=HttpErrorResponse, # type: ignore
995
+ object_=_response.json(),
996
+ ),
997
+ ),
998
+ )
999
+ if _response.status_code == 502:
1000
+ raise BadGatewayError(
1001
+ headers=dict(_response.headers),
1002
+ body=typing.cast(
1003
+ HttpErrorResponse,
1004
+ parse_obj_as(
1005
+ type_=HttpErrorResponse, # type: ignore
1006
+ object_=_response.json(),
1007
+ ),
1008
+ ),
1009
+ )
1010
+ if _response.status_code == 504:
1011
+ raise GatewayTimeoutError(
1012
+ headers=dict(_response.headers),
1013
+ body=typing.cast(
1014
+ HttpErrorResponse,
1015
+ parse_obj_as(
1016
+ type_=HttpErrorResponse, # type: ignore
1017
+ object_=_response.json(),
1018
+ ),
1019
+ ),
1020
+ )
1021
+ _response_json = _response.json()
1022
+ except JSONDecodeError:
1023
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1024
+ except ValidationError as e:
1025
+ raise ParsingError(
1026
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1027
+ )
1028
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1029
+
1030
+ def assign(
1031
+ self,
1032
+ tariff_id: str,
1033
+ *,
1034
+ charge_point_id: str,
1035
+ replace: typing.Optional[bool] = OMIT,
1036
+ request_options: typing.Optional[RequestOptions] = None,
1037
+ ) -> HttpResponse[TariffAssignmentOut]:
1038
+ """
1039
+ Makes one charger use this tariff; a charger uses one tariff at a time. A charger already on this tariff gets its assignment back unchanged. A charger on another tariff is refused with 409 unless ``replace`` is true, which ends that assignment. Sessions already started keep their price.
1040
+
1041
+ Parameters
1042
+ ----------
1043
+ tariff_id : str
1044
+ OCPI tariff id.
1045
+
1046
+ charge_point_id : str
1047
+
1048
+ replace : typing.Optional[bool]
1049
+
1050
+ request_options : typing.Optional[RequestOptions]
1051
+ Request-specific configuration.
1052
+
1053
+ Returns
1054
+ -------
1055
+ HttpResponse[TariffAssignmentOut]
1056
+ The charger's assignment to this tariff.
1057
+ """
1058
+ _request_options_with_retries_disabled: typing.Optional[RequestOptions] = (
1059
+ {**request_options, "max_retries": 0} if request_options is not None else {"max_retries": 0}
1060
+ )
1061
+ _response = self._client_wrapper.httpx_client.request(
1062
+ f"cpo/tariffs/{encode_path_param(tariff_id)}/assign",
1063
+ method="POST",
1064
+ json={
1065
+ "charge_point_id": charge_point_id,
1066
+ "replace": replace,
1067
+ },
1068
+ headers={
1069
+ "content-type": "application/json",
1070
+ },
1071
+ request_options=_request_options_with_retries_disabled,
1072
+ omit=OMIT,
1073
+ )
1074
+ try:
1075
+ if 200 <= _response.status_code < 300:
1076
+ _data = typing.cast(
1077
+ TariffAssignmentOut,
1078
+ parse_obj_as(
1079
+ type_=TariffAssignmentOut, # type: ignore
1080
+ object_=_response.json(),
1081
+ ),
1082
+ )
1083
+ return HttpResponse(response=_response, data=_data)
1084
+ if _response.status_code == 401:
1085
+ raise UnauthorizedError(
1086
+ headers=dict(_response.headers),
1087
+ body=typing.cast(
1088
+ HttpErrorResponse,
1089
+ parse_obj_as(
1090
+ type_=HttpErrorResponse, # type: ignore
1091
+ object_=_response.json(),
1092
+ ),
1093
+ ),
1094
+ )
1095
+ if _response.status_code == 404:
1096
+ raise NotFoundError(
1097
+ headers=dict(_response.headers),
1098
+ body=typing.cast(
1099
+ HttpErrorResponse,
1100
+ parse_obj_as(
1101
+ type_=HttpErrorResponse, # type: ignore
1102
+ object_=_response.json(),
1103
+ ),
1104
+ ),
1105
+ )
1106
+ if _response.status_code == 409:
1107
+ raise ConflictError(
1108
+ headers=dict(_response.headers),
1109
+ body=typing.cast(
1110
+ HttpErrorResponse,
1111
+ parse_obj_as(
1112
+ type_=HttpErrorResponse, # type: ignore
1113
+ object_=_response.json(),
1114
+ ),
1115
+ ),
1116
+ )
1117
+ if _response.status_code == 422:
1118
+ raise UnprocessableEntityError(
1119
+ headers=dict(_response.headers),
1120
+ body=typing.cast(
1121
+ HttpValidationError,
1122
+ parse_obj_as(
1123
+ type_=HttpValidationError, # type: ignore
1124
+ object_=_response.json(),
1125
+ ),
1126
+ ),
1127
+ )
1128
+ if _response.status_code == 429:
1129
+ raise TooManyRequestsError(
1130
+ headers=dict(_response.headers),
1131
+ body=typing.cast(
1132
+ HttpErrorResponse,
1133
+ parse_obj_as(
1134
+ type_=HttpErrorResponse, # type: ignore
1135
+ object_=_response.json(),
1136
+ ),
1137
+ ),
1138
+ )
1139
+ if _response.status_code == 502:
1140
+ raise BadGatewayError(
1141
+ headers=dict(_response.headers),
1142
+ body=typing.cast(
1143
+ HttpErrorResponse,
1144
+ parse_obj_as(
1145
+ type_=HttpErrorResponse, # type: ignore
1146
+ object_=_response.json(),
1147
+ ),
1148
+ ),
1149
+ )
1150
+ if _response.status_code == 504:
1151
+ raise GatewayTimeoutError(
1152
+ headers=dict(_response.headers),
1153
+ body=typing.cast(
1154
+ HttpErrorResponse,
1155
+ parse_obj_as(
1156
+ type_=HttpErrorResponse, # type: ignore
1157
+ object_=_response.json(),
1158
+ ),
1159
+ ),
1160
+ )
1161
+ _response_json = _response.json()
1162
+ except JSONDecodeError:
1163
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1164
+ except ValidationError as e:
1165
+ raise ParsingError(
1166
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1167
+ )
1168
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1169
+
1170
+ def unassign(
1171
+ self, tariff_id: str, *, charge_point_id: str, request_options: typing.Optional[RequestOptions] = None
1172
+ ) -> HttpResponse[None]:
1173
+ """
1174
+ Ends the charger's assignment to this tariff; it stays as history. 404 when the charger does not use this tariff. Sessions already started keep their price.
1175
+
1176
+ Parameters
1177
+ ----------
1178
+ tariff_id : str
1179
+ OCPI tariff id.
1180
+
1181
+ charge_point_id : str
1182
+
1183
+ request_options : typing.Optional[RequestOptions]
1184
+ Request-specific configuration.
1185
+
1186
+ Returns
1187
+ -------
1188
+ HttpResponse[None]
1189
+ """
1190
+ _request_options_with_retries_disabled: typing.Optional[RequestOptions] = (
1191
+ {**request_options, "max_retries": 0} if request_options is not None else {"max_retries": 0}
1192
+ )
1193
+ _response = self._client_wrapper.httpx_client.request(
1194
+ f"cpo/tariffs/{encode_path_param(tariff_id)}/unassign",
1195
+ method="POST",
1196
+ json={
1197
+ "charge_point_id": charge_point_id,
1198
+ },
1199
+ headers={
1200
+ "content-type": "application/json",
1201
+ },
1202
+ request_options=_request_options_with_retries_disabled,
1203
+ omit=OMIT,
1204
+ )
1205
+ try:
1206
+ if 200 <= _response.status_code < 300:
1207
+ return HttpResponse(response=_response, data=None)
1208
+ if _response.status_code == 401:
1209
+ raise UnauthorizedError(
1210
+ headers=dict(_response.headers),
1211
+ body=typing.cast(
1212
+ HttpErrorResponse,
1213
+ parse_obj_as(
1214
+ type_=HttpErrorResponse, # type: ignore
1215
+ object_=_response.json(),
1216
+ ),
1217
+ ),
1218
+ )
1219
+ if _response.status_code == 404:
1220
+ raise NotFoundError(
1221
+ headers=dict(_response.headers),
1222
+ body=typing.cast(
1223
+ HttpErrorResponse,
1224
+ parse_obj_as(
1225
+ type_=HttpErrorResponse, # type: ignore
1226
+ object_=_response.json(),
1227
+ ),
1228
+ ),
1229
+ )
1230
+ if _response.status_code == 422:
1231
+ raise UnprocessableEntityError(
1232
+ headers=dict(_response.headers),
1233
+ body=typing.cast(
1234
+ HttpValidationError,
1235
+ parse_obj_as(
1236
+ type_=HttpValidationError, # type: ignore
1237
+ object_=_response.json(),
1238
+ ),
1239
+ ),
1240
+ )
1241
+ if _response.status_code == 429:
1242
+ raise TooManyRequestsError(
1243
+ headers=dict(_response.headers),
1244
+ body=typing.cast(
1245
+ HttpErrorResponse,
1246
+ parse_obj_as(
1247
+ type_=HttpErrorResponse, # type: ignore
1248
+ object_=_response.json(),
1249
+ ),
1250
+ ),
1251
+ )
1252
+ if _response.status_code == 502:
1253
+ raise BadGatewayError(
1254
+ headers=dict(_response.headers),
1255
+ body=typing.cast(
1256
+ HttpErrorResponse,
1257
+ parse_obj_as(
1258
+ type_=HttpErrorResponse, # type: ignore
1259
+ object_=_response.json(),
1260
+ ),
1261
+ ),
1262
+ )
1263
+ if _response.status_code == 504:
1264
+ raise GatewayTimeoutError(
1265
+ headers=dict(_response.headers),
1266
+ body=typing.cast(
1267
+ HttpErrorResponse,
1268
+ parse_obj_as(
1269
+ type_=HttpErrorResponse, # type: ignore
1270
+ object_=_response.json(),
1271
+ ),
1272
+ ),
1273
+ )
1274
+ _response_json = _response.json()
1275
+ except JSONDecodeError:
1276
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1277
+ except ValidationError as e:
1278
+ raise ParsingError(
1279
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1280
+ )
1281
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1282
+
1283
+
1284
+ class AsyncRawTariffsClient:
1285
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
1286
+ self._client_wrapper = client_wrapper
1287
+
1288
+ async def list_assignments(
1289
+ self,
1290
+ *,
1291
+ tariff_id: typing.Optional[str] = None,
1292
+ charge_point_id: typing.Optional[str] = None,
1293
+ include_deleted: typing.Optional[bool] = None,
1294
+ date_from: typing.Optional[dt.datetime] = None,
1295
+ date_to: typing.Optional[dt.datetime] = None,
1296
+ offset: typing.Optional[int] = None,
1297
+ limit: typing.Optional[int] = None,
1298
+ request_options: typing.Optional[RequestOptions] = None,
1299
+ ) -> AsyncPager[TariffAssignmentOut, TariffAssignmentPage]:
1300
+ """
1301
+ Which tariff each of your chargers uses, newest first. A charger uses one tariff at a time. Ended assignments are history, returned with ``include_deleted``. ``date_from`` and ``date_to`` filter on when the charger started using the tariff.
1302
+
1303
+ Parameters
1304
+ ----------
1305
+ tariff_id : typing.Optional[str]
1306
+ Only this OCPI tariff id.
1307
+
1308
+ charge_point_id : typing.Optional[str]
1309
+ Only this charger (its OCPP identity).
1310
+
1311
+ include_deleted : typing.Optional[bool]
1312
+ Also return assignments that have ended.
1313
+
1314
+ date_from : typing.Optional[dt.datetime]
1315
+ Only rows starting at or after this time (inclusive).
1316
+
1317
+ date_to : typing.Optional[dt.datetime]
1318
+ Only rows starting before this time (exclusive).
1319
+
1320
+ offset : typing.Optional[int]
1321
+ Rows to skip. Pass the previous page's ``next_offset`` to continue.
1322
+
1323
+ limit : typing.Optional[int]
1324
+ Maximum rows per page (default 50, max 200).
1325
+
1326
+ request_options : typing.Optional[RequestOptions]
1327
+ Request-specific configuration.
1328
+
1329
+ Returns
1330
+ -------
1331
+ AsyncPager[TariffAssignmentOut, TariffAssignmentPage]
1332
+ One page of results; ``next_offset`` is null on the last page.
1333
+ """
1334
+ _response = await self._client_wrapper.httpx_client.request(
1335
+ "cpo/tariff-assignments",
1336
+ method="GET",
1337
+ params={
1338
+ "tariff_id": tariff_id,
1339
+ "charge_point_id": charge_point_id,
1340
+ "include_deleted": include_deleted,
1341
+ "date_from": serialize_datetime(date_from) if date_from is not None else None,
1342
+ "date_to": serialize_datetime(date_to) if date_to is not None else None,
1343
+ "offset": offset,
1344
+ "limit": limit,
1345
+ },
1346
+ request_options=request_options,
1347
+ )
1348
+ try:
1349
+ if 200 <= _response.status_code < 300:
1350
+ _parsed_response = typing.cast(
1351
+ TariffAssignmentPage,
1352
+ parse_obj_as(
1353
+ type_=TariffAssignmentPage, # type: ignore
1354
+ object_=_response.json(),
1355
+ ),
1356
+ )
1357
+ _items = _parsed_response.items
1358
+ _parsed_next = _parsed_response.next_offset
1359
+ _has_next = _parsed_next is not None and _parsed_next != ""
1360
+
1361
+ async def _get_next():
1362
+ return await self.list_assignments(
1363
+ tariff_id=tariff_id,
1364
+ charge_point_id=charge_point_id,
1365
+ include_deleted=include_deleted,
1366
+ date_from=date_from,
1367
+ date_to=date_to,
1368
+ offset=_parsed_next,
1369
+ limit=limit,
1370
+ request_options=request_options,
1371
+ )
1372
+
1373
+ return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
1374
+ if _response.status_code == 401:
1375
+ raise UnauthorizedError(
1376
+ headers=dict(_response.headers),
1377
+ body=typing.cast(
1378
+ HttpErrorResponse,
1379
+ parse_obj_as(
1380
+ type_=HttpErrorResponse, # type: ignore
1381
+ object_=_response.json(),
1382
+ ),
1383
+ ),
1384
+ )
1385
+ if _response.status_code == 422:
1386
+ raise UnprocessableEntityError(
1387
+ headers=dict(_response.headers),
1388
+ body=typing.cast(
1389
+ HttpValidationError,
1390
+ parse_obj_as(
1391
+ type_=HttpValidationError, # type: ignore
1392
+ object_=_response.json(),
1393
+ ),
1394
+ ),
1395
+ )
1396
+ if _response.status_code == 429:
1397
+ raise TooManyRequestsError(
1398
+ headers=dict(_response.headers),
1399
+ body=typing.cast(
1400
+ HttpErrorResponse,
1401
+ parse_obj_as(
1402
+ type_=HttpErrorResponse, # type: ignore
1403
+ object_=_response.json(),
1404
+ ),
1405
+ ),
1406
+ )
1407
+ if _response.status_code == 502:
1408
+ raise BadGatewayError(
1409
+ headers=dict(_response.headers),
1410
+ body=typing.cast(
1411
+ HttpErrorResponse,
1412
+ parse_obj_as(
1413
+ type_=HttpErrorResponse, # type: ignore
1414
+ object_=_response.json(),
1415
+ ),
1416
+ ),
1417
+ )
1418
+ if _response.status_code == 504:
1419
+ raise GatewayTimeoutError(
1420
+ headers=dict(_response.headers),
1421
+ body=typing.cast(
1422
+ HttpErrorResponse,
1423
+ parse_obj_as(
1424
+ type_=HttpErrorResponse, # type: ignore
1425
+ object_=_response.json(),
1426
+ ),
1427
+ ),
1428
+ )
1429
+ _response_json = _response.json()
1430
+ except JSONDecodeError:
1431
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1432
+ except ValidationError as e:
1433
+ raise ParsingError(
1434
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1435
+ )
1436
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1437
+
1438
+ async def list(
1439
+ self,
1440
+ *,
1441
+ currency: typing.Optional[str] = None,
1442
+ type: typing.Optional[ListTariffsRequestType] = None,
1443
+ country_code: typing.Optional[str] = None,
1444
+ party_id: typing.Optional[str] = None,
1445
+ date_from: typing.Optional[dt.datetime] = None,
1446
+ date_to: typing.Optional[dt.datetime] = None,
1447
+ offset: typing.Optional[int] = None,
1448
+ limit: typing.Optional[int] = None,
1449
+ request_options: typing.Optional[RequestOptions] = None,
1450
+ ) -> AsyncPager[TariffOut, TariffPage]:
1451
+ """
1452
+ Your live tariffs, most recently changed first. ``date_from`` and ``date_to`` filter on ``last_updated``.
1453
+
1454
+ Parameters
1455
+ ----------
1456
+ currency : typing.Optional[str]
1457
+ Only this ISO 4217 currency, e.g. EUR.
1458
+
1459
+ type : typing.Optional[ListTariffsRequestType]
1460
+ Only tariffs of this OCPI type.
1461
+
1462
+ country_code : typing.Optional[str]
1463
+ Only this OCPI party country code, e.g. NL.
1464
+
1465
+ party_id : typing.Optional[str]
1466
+ Only this OCPI party id, e.g. OCP.
1467
+
1468
+ date_from : typing.Optional[dt.datetime]
1469
+ Only rows starting at or after this time (inclusive).
1470
+
1471
+ date_to : typing.Optional[dt.datetime]
1472
+ Only rows starting before this time (exclusive).
1473
+
1474
+ offset : typing.Optional[int]
1475
+ Rows to skip. Pass the previous page's ``next_offset`` to continue.
1476
+
1477
+ limit : typing.Optional[int]
1478
+ Maximum rows per page (default 50, max 200).
1479
+
1480
+ request_options : typing.Optional[RequestOptions]
1481
+ Request-specific configuration.
1482
+
1483
+ Returns
1484
+ -------
1485
+ AsyncPager[TariffOut, TariffPage]
1486
+ One page of results; ``next_offset`` is null on the last page.
1487
+ """
1488
+ _response = await self._client_wrapper.httpx_client.request(
1489
+ "cpo/tariffs",
1490
+ method="GET",
1491
+ params={
1492
+ "currency": currency,
1493
+ "type": type,
1494
+ "country_code": country_code,
1495
+ "party_id": party_id,
1496
+ "date_from": serialize_datetime(date_from) if date_from is not None else None,
1497
+ "date_to": serialize_datetime(date_to) if date_to is not None else None,
1498
+ "offset": offset,
1499
+ "limit": limit,
1500
+ },
1501
+ request_options=request_options,
1502
+ )
1503
+ try:
1504
+ if 200 <= _response.status_code < 300:
1505
+ _parsed_response = typing.cast(
1506
+ TariffPage,
1507
+ parse_obj_as(
1508
+ type_=TariffPage, # type: ignore
1509
+ object_=_response.json(),
1510
+ ),
1511
+ )
1512
+ _items = _parsed_response.items
1513
+ _parsed_next = _parsed_response.next_offset
1514
+ _has_next = _parsed_next is not None and _parsed_next != ""
1515
+
1516
+ async def _get_next():
1517
+ return await self.list(
1518
+ currency=currency,
1519
+ type=type,
1520
+ country_code=country_code,
1521
+ party_id=party_id,
1522
+ date_from=date_from,
1523
+ date_to=date_to,
1524
+ offset=_parsed_next,
1525
+ limit=limit,
1526
+ request_options=request_options,
1527
+ )
1528
+
1529
+ return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
1530
+ if _response.status_code == 401:
1531
+ raise UnauthorizedError(
1532
+ headers=dict(_response.headers),
1533
+ body=typing.cast(
1534
+ HttpErrorResponse,
1535
+ parse_obj_as(
1536
+ type_=HttpErrorResponse, # type: ignore
1537
+ object_=_response.json(),
1538
+ ),
1539
+ ),
1540
+ )
1541
+ if _response.status_code == 422:
1542
+ raise UnprocessableEntityError(
1543
+ headers=dict(_response.headers),
1544
+ body=typing.cast(
1545
+ HttpValidationError,
1546
+ parse_obj_as(
1547
+ type_=HttpValidationError, # type: ignore
1548
+ object_=_response.json(),
1549
+ ),
1550
+ ),
1551
+ )
1552
+ if _response.status_code == 429:
1553
+ raise TooManyRequestsError(
1554
+ headers=dict(_response.headers),
1555
+ body=typing.cast(
1556
+ HttpErrorResponse,
1557
+ parse_obj_as(
1558
+ type_=HttpErrorResponse, # type: ignore
1559
+ object_=_response.json(),
1560
+ ),
1561
+ ),
1562
+ )
1563
+ if _response.status_code == 502:
1564
+ raise BadGatewayError(
1565
+ headers=dict(_response.headers),
1566
+ body=typing.cast(
1567
+ HttpErrorResponse,
1568
+ parse_obj_as(
1569
+ type_=HttpErrorResponse, # type: ignore
1570
+ object_=_response.json(),
1571
+ ),
1572
+ ),
1573
+ )
1574
+ if _response.status_code == 504:
1575
+ raise GatewayTimeoutError(
1576
+ headers=dict(_response.headers),
1577
+ body=typing.cast(
1578
+ HttpErrorResponse,
1579
+ parse_obj_as(
1580
+ type_=HttpErrorResponse, # type: ignore
1581
+ object_=_response.json(),
1582
+ ),
1583
+ ),
1584
+ )
1585
+ _response_json = _response.json()
1586
+ except JSONDecodeError:
1587
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1588
+ except ValidationError as e:
1589
+ raise ParsingError(
1590
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1591
+ )
1592
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1593
+
1594
+ async def create(
1595
+ self,
1596
+ *,
1597
+ tariff_id: str,
1598
+ currency: str,
1599
+ elements: typing.Sequence[OcpiTariffElementInput],
1600
+ country_code: typing.Optional[str] = OMIT,
1601
+ party_id: typing.Optional[str] = OMIT,
1602
+ type: typing.Optional[TariffType] = OMIT,
1603
+ tariff_alt_text: typing.Optional[typing.Sequence[OcpiDisplayText]] = OMIT,
1604
+ tariff_alt_url: typing.Optional[str] = OMIT,
1605
+ min_price: typing.Optional[OcpiPriceInput] = OMIT,
1606
+ max_price: typing.Optional[OcpiPriceInput] = OMIT,
1607
+ preauthorize_amount: typing.Optional[TariffCreatePreauthorizeAmount] = OMIT,
1608
+ tax_included: typing.Optional[TaxIncluded] = OMIT,
1609
+ start_date_time: typing.Optional[dt.datetime] = OMIT,
1610
+ end_date_time: typing.Optional[dt.datetime] = OMIT,
1611
+ energy_mix: typing.Optional[OcpiEnergyMixInput] = OMIT,
1612
+ p2p_preset: typing.Optional[bool] = OMIT,
1613
+ is_roaming: typing.Optional[bool] = OMIT,
1614
+ ocpi_version: typing.Optional[TariffCreateOcpiVersion] = OMIT,
1615
+ request_options: typing.Optional[RequestOptions] = None,
1616
+ ) -> AsyncHttpResponse[TariffOut]:
1617
+ """
1618
+ Creates a tariff under your OCPI party. The id of a deleted tariff brings that tariff back as the body describes it. ``is_roaming`` marks it for roaming partners. Assign it to chargers with ``POST /cpo/tariffs/{tariff_id}/assign``.
1619
+
1620
+ Parameters
1621
+ ----------
1622
+ tariff_id : str
1623
+
1624
+ currency : str
1625
+
1626
+ elements : typing.Sequence[OcpiTariffElementInput]
1627
+
1628
+ country_code : typing.Optional[str]
1629
+
1630
+ party_id : typing.Optional[str]
1631
+
1632
+ type : typing.Optional[TariffType]
1633
+
1634
+ tariff_alt_text : typing.Optional[typing.Sequence[OcpiDisplayText]]
1635
+
1636
+ tariff_alt_url : typing.Optional[str]
1637
+
1638
+ min_price : typing.Optional[OcpiPriceInput]
1639
+
1640
+ max_price : typing.Optional[OcpiPriceInput]
1641
+
1642
+ preauthorize_amount : typing.Optional[TariffCreatePreauthorizeAmount]
1643
+
1644
+ tax_included : typing.Optional[TaxIncluded]
1645
+
1646
+ start_date_time : typing.Optional[dt.datetime]
1647
+
1648
+ end_date_time : typing.Optional[dt.datetime]
1649
+
1650
+ energy_mix : typing.Optional[OcpiEnergyMixInput]
1651
+
1652
+ p2p_preset : typing.Optional[bool]
1653
+
1654
+ is_roaming : typing.Optional[bool]
1655
+
1656
+ ocpi_version : typing.Optional[TariffCreateOcpiVersion]
1657
+
1658
+ request_options : typing.Optional[RequestOptions]
1659
+ Request-specific configuration.
1660
+
1661
+ Returns
1662
+ -------
1663
+ AsyncHttpResponse[TariffOut]
1664
+ The created object.
1665
+ """
1666
+ _request_options_with_retries_disabled: typing.Optional[RequestOptions] = (
1667
+ {**request_options, "max_retries": 0} if request_options is not None else {"max_retries": 0}
1668
+ )
1669
+ _response = await self._client_wrapper.httpx_client.request(
1670
+ "cpo/tariffs",
1671
+ method="POST",
1672
+ json={
1673
+ "tariff_id": tariff_id,
1674
+ "currency": currency,
1675
+ "country_code": country_code,
1676
+ "party_id": party_id,
1677
+ "elements": convert_and_respect_annotation_metadata(
1678
+ object_=elements, annotation=typing.Sequence[OcpiTariffElementInput], direction="write"
1679
+ ),
1680
+ "type": type,
1681
+ "tariff_alt_text": convert_and_respect_annotation_metadata(
1682
+ object_=tariff_alt_text,
1683
+ annotation=typing.Optional[typing.Sequence[OcpiDisplayText]],
1684
+ direction="write",
1685
+ ),
1686
+ "tariff_alt_url": tariff_alt_url,
1687
+ "min_price": convert_and_respect_annotation_metadata(
1688
+ object_=min_price, annotation=typing.Optional[OcpiPriceInput], direction="write"
1689
+ ),
1690
+ "max_price": convert_and_respect_annotation_metadata(
1691
+ object_=max_price, annotation=typing.Optional[OcpiPriceInput], direction="write"
1692
+ ),
1693
+ "preauthorize_amount": convert_and_respect_annotation_metadata(
1694
+ object_=preauthorize_amount,
1695
+ annotation=typing.Optional[TariffCreatePreauthorizeAmount],
1696
+ direction="write",
1697
+ ),
1698
+ "tax_included": tax_included,
1699
+ "start_date_time": start_date_time,
1700
+ "end_date_time": end_date_time,
1701
+ "energy_mix": convert_and_respect_annotation_metadata(
1702
+ object_=energy_mix, annotation=typing.Optional[OcpiEnergyMixInput], direction="write"
1703
+ ),
1704
+ "p2p_preset": p2p_preset,
1705
+ "is_roaming": is_roaming,
1706
+ "ocpi_version": ocpi_version,
1707
+ },
1708
+ headers={
1709
+ "content-type": "application/json",
1710
+ },
1711
+ request_options=_request_options_with_retries_disabled,
1712
+ omit=OMIT,
1713
+ )
1714
+ try:
1715
+ if 200 <= _response.status_code < 300:
1716
+ _data = typing.cast(
1717
+ TariffOut,
1718
+ parse_obj_as(
1719
+ type_=TariffOut, # type: ignore
1720
+ object_=_response.json(),
1721
+ ),
1722
+ )
1723
+ return AsyncHttpResponse(response=_response, data=_data)
1724
+ if _response.status_code == 400:
1725
+ raise BadRequestError(
1726
+ headers=dict(_response.headers),
1727
+ body=typing.cast(
1728
+ HttpErrorResponse,
1729
+ parse_obj_as(
1730
+ type_=HttpErrorResponse, # type: ignore
1731
+ object_=_response.json(),
1732
+ ),
1733
+ ),
1734
+ )
1735
+ if _response.status_code == 401:
1736
+ raise UnauthorizedError(
1737
+ headers=dict(_response.headers),
1738
+ body=typing.cast(
1739
+ HttpErrorResponse,
1740
+ parse_obj_as(
1741
+ type_=HttpErrorResponse, # type: ignore
1742
+ object_=_response.json(),
1743
+ ),
1744
+ ),
1745
+ )
1746
+ if _response.status_code == 409:
1747
+ raise ConflictError(
1748
+ headers=dict(_response.headers),
1749
+ body=typing.cast(
1750
+ HttpErrorResponse,
1751
+ parse_obj_as(
1752
+ type_=HttpErrorResponse, # type: ignore
1753
+ object_=_response.json(),
1754
+ ),
1755
+ ),
1756
+ )
1757
+ if _response.status_code == 422:
1758
+ raise UnprocessableEntityError(
1759
+ headers=dict(_response.headers),
1760
+ body=typing.cast(
1761
+ HttpValidationError,
1762
+ parse_obj_as(
1763
+ type_=HttpValidationError, # type: ignore
1764
+ object_=_response.json(),
1765
+ ),
1766
+ ),
1767
+ )
1768
+ if _response.status_code == 429:
1769
+ raise TooManyRequestsError(
1770
+ headers=dict(_response.headers),
1771
+ body=typing.cast(
1772
+ HttpErrorResponse,
1773
+ parse_obj_as(
1774
+ type_=HttpErrorResponse, # type: ignore
1775
+ object_=_response.json(),
1776
+ ),
1777
+ ),
1778
+ )
1779
+ if _response.status_code == 502:
1780
+ raise BadGatewayError(
1781
+ headers=dict(_response.headers),
1782
+ body=typing.cast(
1783
+ HttpErrorResponse,
1784
+ parse_obj_as(
1785
+ type_=HttpErrorResponse, # type: ignore
1786
+ object_=_response.json(),
1787
+ ),
1788
+ ),
1789
+ )
1790
+ if _response.status_code == 504:
1791
+ raise GatewayTimeoutError(
1792
+ headers=dict(_response.headers),
1793
+ body=typing.cast(
1794
+ HttpErrorResponse,
1795
+ parse_obj_as(
1796
+ type_=HttpErrorResponse, # type: ignore
1797
+ object_=_response.json(),
1798
+ ),
1799
+ ),
1800
+ )
1801
+ _response_json = _response.json()
1802
+ except JSONDecodeError:
1803
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1804
+ except ValidationError as e:
1805
+ raise ParsingError(
1806
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1807
+ )
1808
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1809
+
1810
+ async def get(
1811
+ self,
1812
+ tariff_id: str,
1813
+ *,
1814
+ country_code: typing.Optional[str] = None,
1815
+ party_id: typing.Optional[str] = None,
1816
+ request_options: typing.Optional[RequestOptions] = None,
1817
+ ) -> AsyncHttpResponse[TariffOut]:
1818
+ """
1819
+ One tariff by OCPI id. If two parties use the same id, pass ``country_code`` and ``party_id`` (409 otherwise).
1820
+
1821
+ Parameters
1822
+ ----------
1823
+ tariff_id : str
1824
+ OCPI tariff id.
1825
+
1826
+ country_code : typing.Optional[str]
1827
+ Only this OCPI party country code, e.g. NL.
1828
+
1829
+ party_id : typing.Optional[str]
1830
+ Only this OCPI party id, e.g. OCP.
1831
+
1832
+ request_options : typing.Optional[RequestOptions]
1833
+ Request-specific configuration.
1834
+
1835
+ Returns
1836
+ -------
1837
+ AsyncHttpResponse[TariffOut]
1838
+ The requested object.
1839
+ """
1840
+ _response = await self._client_wrapper.httpx_client.request(
1841
+ f"cpo/tariffs/{encode_path_param(tariff_id)}",
1842
+ method="GET",
1843
+ params={
1844
+ "country_code": country_code,
1845
+ "party_id": party_id,
1846
+ },
1847
+ request_options=request_options,
1848
+ )
1849
+ try:
1850
+ if 200 <= _response.status_code < 300:
1851
+ _data = typing.cast(
1852
+ TariffOut,
1853
+ parse_obj_as(
1854
+ type_=TariffOut, # type: ignore
1855
+ object_=_response.json(),
1856
+ ),
1857
+ )
1858
+ return AsyncHttpResponse(response=_response, data=_data)
1859
+ if _response.status_code == 401:
1860
+ raise UnauthorizedError(
1861
+ headers=dict(_response.headers),
1862
+ body=typing.cast(
1863
+ HttpErrorResponse,
1864
+ parse_obj_as(
1865
+ type_=HttpErrorResponse, # type: ignore
1866
+ object_=_response.json(),
1867
+ ),
1868
+ ),
1869
+ )
1870
+ if _response.status_code == 404:
1871
+ raise NotFoundError(
1872
+ headers=dict(_response.headers),
1873
+ body=typing.cast(
1874
+ HttpErrorResponse,
1875
+ parse_obj_as(
1876
+ type_=HttpErrorResponse, # type: ignore
1877
+ object_=_response.json(),
1878
+ ),
1879
+ ),
1880
+ )
1881
+ if _response.status_code == 409:
1882
+ raise ConflictError(
1883
+ headers=dict(_response.headers),
1884
+ body=typing.cast(
1885
+ HttpErrorResponse,
1886
+ parse_obj_as(
1887
+ type_=HttpErrorResponse, # type: ignore
1888
+ object_=_response.json(),
1889
+ ),
1890
+ ),
1891
+ )
1892
+ if _response.status_code == 422:
1893
+ raise UnprocessableEntityError(
1894
+ headers=dict(_response.headers),
1895
+ body=typing.cast(
1896
+ HttpValidationError,
1897
+ parse_obj_as(
1898
+ type_=HttpValidationError, # type: ignore
1899
+ object_=_response.json(),
1900
+ ),
1901
+ ),
1902
+ )
1903
+ if _response.status_code == 429:
1904
+ raise TooManyRequestsError(
1905
+ headers=dict(_response.headers),
1906
+ body=typing.cast(
1907
+ HttpErrorResponse,
1908
+ parse_obj_as(
1909
+ type_=HttpErrorResponse, # type: ignore
1910
+ object_=_response.json(),
1911
+ ),
1912
+ ),
1913
+ )
1914
+ if _response.status_code == 502:
1915
+ raise BadGatewayError(
1916
+ headers=dict(_response.headers),
1917
+ body=typing.cast(
1918
+ HttpErrorResponse,
1919
+ parse_obj_as(
1920
+ type_=HttpErrorResponse, # type: ignore
1921
+ object_=_response.json(),
1922
+ ),
1923
+ ),
1924
+ )
1925
+ if _response.status_code == 504:
1926
+ raise GatewayTimeoutError(
1927
+ headers=dict(_response.headers),
1928
+ body=typing.cast(
1929
+ HttpErrorResponse,
1930
+ parse_obj_as(
1931
+ type_=HttpErrorResponse, # type: ignore
1932
+ object_=_response.json(),
1933
+ ),
1934
+ ),
1935
+ )
1936
+ _response_json = _response.json()
1937
+ except JSONDecodeError:
1938
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1939
+ except ValidationError as e:
1940
+ raise ParsingError(
1941
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1942
+ )
1943
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1944
+
1945
+ async def delete(
1946
+ self, tariff_id: str, *, request_options: typing.Optional[RequestOptions] = None
1947
+ ) -> AsyncHttpResponse[None]:
1948
+ """
1949
+ Removes the tariff from reads; the chargers that use it stop using it. Sessions already started keep their price.
1950
+
1951
+ Parameters
1952
+ ----------
1953
+ tariff_id : str
1954
+ OCPI tariff id.
1955
+
1956
+ request_options : typing.Optional[RequestOptions]
1957
+ Request-specific configuration.
1958
+
1959
+ Returns
1960
+ -------
1961
+ AsyncHttpResponse[None]
1962
+ """
1963
+ _response = await self._client_wrapper.httpx_client.request(
1964
+ f"cpo/tariffs/{encode_path_param(tariff_id)}",
1965
+ method="DELETE",
1966
+ request_options=request_options,
1967
+ )
1968
+ try:
1969
+ if 200 <= _response.status_code < 300:
1970
+ return AsyncHttpResponse(response=_response, data=None)
1971
+ if _response.status_code == 401:
1972
+ raise UnauthorizedError(
1973
+ headers=dict(_response.headers),
1974
+ body=typing.cast(
1975
+ HttpErrorResponse,
1976
+ parse_obj_as(
1977
+ type_=HttpErrorResponse, # type: ignore
1978
+ object_=_response.json(),
1979
+ ),
1980
+ ),
1981
+ )
1982
+ if _response.status_code == 404:
1983
+ raise NotFoundError(
1984
+ headers=dict(_response.headers),
1985
+ body=typing.cast(
1986
+ HttpErrorResponse,
1987
+ parse_obj_as(
1988
+ type_=HttpErrorResponse, # type: ignore
1989
+ object_=_response.json(),
1990
+ ),
1991
+ ),
1992
+ )
1993
+ if _response.status_code == 409:
1994
+ raise ConflictError(
1995
+ headers=dict(_response.headers),
1996
+ body=typing.cast(
1997
+ HttpErrorResponse,
1998
+ parse_obj_as(
1999
+ type_=HttpErrorResponse, # type: ignore
2000
+ object_=_response.json(),
2001
+ ),
2002
+ ),
2003
+ )
2004
+ if _response.status_code == 422:
2005
+ raise UnprocessableEntityError(
2006
+ headers=dict(_response.headers),
2007
+ body=typing.cast(
2008
+ HttpValidationError,
2009
+ parse_obj_as(
2010
+ type_=HttpValidationError, # type: ignore
2011
+ object_=_response.json(),
2012
+ ),
2013
+ ),
2014
+ )
2015
+ if _response.status_code == 429:
2016
+ raise TooManyRequestsError(
2017
+ headers=dict(_response.headers),
2018
+ body=typing.cast(
2019
+ HttpErrorResponse,
2020
+ parse_obj_as(
2021
+ type_=HttpErrorResponse, # type: ignore
2022
+ object_=_response.json(),
2023
+ ),
2024
+ ),
2025
+ )
2026
+ if _response.status_code == 502:
2027
+ raise BadGatewayError(
2028
+ headers=dict(_response.headers),
2029
+ body=typing.cast(
2030
+ HttpErrorResponse,
2031
+ parse_obj_as(
2032
+ type_=HttpErrorResponse, # type: ignore
2033
+ object_=_response.json(),
2034
+ ),
2035
+ ),
2036
+ )
2037
+ if _response.status_code == 504:
2038
+ raise GatewayTimeoutError(
2039
+ headers=dict(_response.headers),
2040
+ body=typing.cast(
2041
+ HttpErrorResponse,
2042
+ parse_obj_as(
2043
+ type_=HttpErrorResponse, # type: ignore
2044
+ object_=_response.json(),
2045
+ ),
2046
+ ),
2047
+ )
2048
+ _response_json = _response.json()
2049
+ except JSONDecodeError:
2050
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2051
+ except ValidationError as e:
2052
+ raise ParsingError(
2053
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
2054
+ )
2055
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2056
+
2057
+ async def update(
2058
+ self,
2059
+ tariff_id: str,
2060
+ *,
2061
+ currency: typing.Optional[str] = OMIT,
2062
+ type: typing.Optional[TariffType] = OMIT,
2063
+ tariff_alt_text: typing.Optional[typing.Sequence[OcpiDisplayText]] = OMIT,
2064
+ tariff_alt_url: typing.Optional[str] = OMIT,
2065
+ min_price: typing.Optional[OcpiPriceInput] = OMIT,
2066
+ max_price: typing.Optional[OcpiPriceInput] = OMIT,
2067
+ preauthorize_amount: typing.Optional[TariffPatchPreauthorizeAmount] = OMIT,
2068
+ tax_included: typing.Optional[TaxIncluded] = OMIT,
2069
+ elements: typing.Optional[typing.Sequence[OcpiTariffElementInput]] = OMIT,
2070
+ start_date_time: typing.Optional[dt.datetime] = OMIT,
2071
+ end_date_time: typing.Optional[dt.datetime] = OMIT,
2072
+ energy_mix: typing.Optional[OcpiEnergyMixInput] = OMIT,
2073
+ p2p_preset: typing.Optional[bool] = OMIT,
2074
+ is_roaming: typing.Optional[bool] = OMIT,
2075
+ expected_revision: typing.Optional[int] = OMIT,
2076
+ request_options: typing.Optional[RequestOptions] = None,
2077
+ ) -> AsyncHttpResponse[TariffOut]:
2078
+ """
2079
+ Changes only the fields sent; send null to clear an optional field. ``currency``, ``elements``, ``p2p_preset`` and ``is_roaming`` cannot be cleared. ``expected_revision`` refuses a lost update with 409. Sessions already started keep their price.
2080
+
2081
+ Parameters
2082
+ ----------
2083
+ tariff_id : str
2084
+ OCPI tariff id.
2085
+
2086
+ currency : typing.Optional[str]
2087
+
2088
+ type : typing.Optional[TariffType]
2089
+
2090
+ tariff_alt_text : typing.Optional[typing.Sequence[OcpiDisplayText]]
2091
+
2092
+ tariff_alt_url : typing.Optional[str]
2093
+
2094
+ min_price : typing.Optional[OcpiPriceInput]
2095
+
2096
+ max_price : typing.Optional[OcpiPriceInput]
2097
+
2098
+ preauthorize_amount : typing.Optional[TariffPatchPreauthorizeAmount]
2099
+
2100
+ tax_included : typing.Optional[TaxIncluded]
2101
+
2102
+ elements : typing.Optional[typing.Sequence[OcpiTariffElementInput]]
2103
+
2104
+ start_date_time : typing.Optional[dt.datetime]
2105
+
2106
+ end_date_time : typing.Optional[dt.datetime]
2107
+
2108
+ energy_mix : typing.Optional[OcpiEnergyMixInput]
2109
+
2110
+ p2p_preset : typing.Optional[bool]
2111
+
2112
+ is_roaming : typing.Optional[bool]
2113
+
2114
+ expected_revision : typing.Optional[int]
2115
+
2116
+ request_options : typing.Optional[RequestOptions]
2117
+ Request-specific configuration.
2118
+
2119
+ Returns
2120
+ -------
2121
+ AsyncHttpResponse[TariffOut]
2122
+ The object after the update.
2123
+ """
2124
+ _response = await self._client_wrapper.httpx_client.request(
2125
+ f"cpo/tariffs/{encode_path_param(tariff_id)}",
2126
+ method="PATCH",
2127
+ json={
2128
+ "currency": currency,
2129
+ "type": type,
2130
+ "tariff_alt_text": convert_and_respect_annotation_metadata(
2131
+ object_=tariff_alt_text,
2132
+ annotation=typing.Optional[typing.Sequence[OcpiDisplayText]],
2133
+ direction="write",
2134
+ ),
2135
+ "tariff_alt_url": tariff_alt_url,
2136
+ "min_price": convert_and_respect_annotation_metadata(
2137
+ object_=min_price, annotation=typing.Optional[OcpiPriceInput], direction="write"
2138
+ ),
2139
+ "max_price": convert_and_respect_annotation_metadata(
2140
+ object_=max_price, annotation=typing.Optional[OcpiPriceInput], direction="write"
2141
+ ),
2142
+ "preauthorize_amount": convert_and_respect_annotation_metadata(
2143
+ object_=preauthorize_amount,
2144
+ annotation=typing.Optional[TariffPatchPreauthorizeAmount],
2145
+ direction="write",
2146
+ ),
2147
+ "tax_included": tax_included,
2148
+ "elements": convert_and_respect_annotation_metadata(
2149
+ object_=elements,
2150
+ annotation=typing.Optional[typing.Sequence[OcpiTariffElementInput]],
2151
+ direction="write",
2152
+ ),
2153
+ "start_date_time": start_date_time,
2154
+ "end_date_time": end_date_time,
2155
+ "energy_mix": convert_and_respect_annotation_metadata(
2156
+ object_=energy_mix, annotation=typing.Optional[OcpiEnergyMixInput], direction="write"
2157
+ ),
2158
+ "p2p_preset": p2p_preset,
2159
+ "is_roaming": is_roaming,
2160
+ "expected_revision": expected_revision,
2161
+ },
2162
+ headers={
2163
+ "content-type": "application/json",
2164
+ },
2165
+ request_options=request_options,
2166
+ omit=OMIT,
2167
+ )
2168
+ try:
2169
+ if 200 <= _response.status_code < 300:
2170
+ _data = typing.cast(
2171
+ TariffOut,
2172
+ parse_obj_as(
2173
+ type_=TariffOut, # type: ignore
2174
+ object_=_response.json(),
2175
+ ),
2176
+ )
2177
+ return AsyncHttpResponse(response=_response, data=_data)
2178
+ if _response.status_code == 400:
2179
+ raise BadRequestError(
2180
+ headers=dict(_response.headers),
2181
+ body=typing.cast(
2182
+ HttpErrorResponse,
2183
+ parse_obj_as(
2184
+ type_=HttpErrorResponse, # type: ignore
2185
+ object_=_response.json(),
2186
+ ),
2187
+ ),
2188
+ )
2189
+ if _response.status_code == 401:
2190
+ raise UnauthorizedError(
2191
+ headers=dict(_response.headers),
2192
+ body=typing.cast(
2193
+ HttpErrorResponse,
2194
+ parse_obj_as(
2195
+ type_=HttpErrorResponse, # type: ignore
2196
+ object_=_response.json(),
2197
+ ),
2198
+ ),
2199
+ )
2200
+ if _response.status_code == 404:
2201
+ raise NotFoundError(
2202
+ headers=dict(_response.headers),
2203
+ body=typing.cast(
2204
+ HttpErrorResponse,
2205
+ parse_obj_as(
2206
+ type_=HttpErrorResponse, # type: ignore
2207
+ object_=_response.json(),
2208
+ ),
2209
+ ),
2210
+ )
2211
+ if _response.status_code == 409:
2212
+ raise ConflictError(
2213
+ headers=dict(_response.headers),
2214
+ body=typing.cast(
2215
+ HttpErrorResponse,
2216
+ parse_obj_as(
2217
+ type_=HttpErrorResponse, # type: ignore
2218
+ object_=_response.json(),
2219
+ ),
2220
+ ),
2221
+ )
2222
+ if _response.status_code == 422:
2223
+ raise UnprocessableEntityError(
2224
+ headers=dict(_response.headers),
2225
+ body=typing.cast(
2226
+ HttpValidationError,
2227
+ parse_obj_as(
2228
+ type_=HttpValidationError, # type: ignore
2229
+ object_=_response.json(),
2230
+ ),
2231
+ ),
2232
+ )
2233
+ if _response.status_code == 429:
2234
+ raise TooManyRequestsError(
2235
+ headers=dict(_response.headers),
2236
+ body=typing.cast(
2237
+ HttpErrorResponse,
2238
+ parse_obj_as(
2239
+ type_=HttpErrorResponse, # type: ignore
2240
+ object_=_response.json(),
2241
+ ),
2242
+ ),
2243
+ )
2244
+ if _response.status_code == 502:
2245
+ raise BadGatewayError(
2246
+ headers=dict(_response.headers),
2247
+ body=typing.cast(
2248
+ HttpErrorResponse,
2249
+ parse_obj_as(
2250
+ type_=HttpErrorResponse, # type: ignore
2251
+ object_=_response.json(),
2252
+ ),
2253
+ ),
2254
+ )
2255
+ if _response.status_code == 504:
2256
+ raise GatewayTimeoutError(
2257
+ headers=dict(_response.headers),
2258
+ body=typing.cast(
2259
+ HttpErrorResponse,
2260
+ parse_obj_as(
2261
+ type_=HttpErrorResponse, # type: ignore
2262
+ object_=_response.json(),
2263
+ ),
2264
+ ),
2265
+ )
2266
+ _response_json = _response.json()
2267
+ except JSONDecodeError:
2268
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2269
+ except ValidationError as e:
2270
+ raise ParsingError(
2271
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
2272
+ )
2273
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2274
+
2275
+ async def assign(
2276
+ self,
2277
+ tariff_id: str,
2278
+ *,
2279
+ charge_point_id: str,
2280
+ replace: typing.Optional[bool] = OMIT,
2281
+ request_options: typing.Optional[RequestOptions] = None,
2282
+ ) -> AsyncHttpResponse[TariffAssignmentOut]:
2283
+ """
2284
+ Makes one charger use this tariff; a charger uses one tariff at a time. A charger already on this tariff gets its assignment back unchanged. A charger on another tariff is refused with 409 unless ``replace`` is true, which ends that assignment. Sessions already started keep their price.
2285
+
2286
+ Parameters
2287
+ ----------
2288
+ tariff_id : str
2289
+ OCPI tariff id.
2290
+
2291
+ charge_point_id : str
2292
+
2293
+ replace : typing.Optional[bool]
2294
+
2295
+ request_options : typing.Optional[RequestOptions]
2296
+ Request-specific configuration.
2297
+
2298
+ Returns
2299
+ -------
2300
+ AsyncHttpResponse[TariffAssignmentOut]
2301
+ The charger's assignment to this tariff.
2302
+ """
2303
+ _request_options_with_retries_disabled: typing.Optional[RequestOptions] = (
2304
+ {**request_options, "max_retries": 0} if request_options is not None else {"max_retries": 0}
2305
+ )
2306
+ _response = await self._client_wrapper.httpx_client.request(
2307
+ f"cpo/tariffs/{encode_path_param(tariff_id)}/assign",
2308
+ method="POST",
2309
+ json={
2310
+ "charge_point_id": charge_point_id,
2311
+ "replace": replace,
2312
+ },
2313
+ headers={
2314
+ "content-type": "application/json",
2315
+ },
2316
+ request_options=_request_options_with_retries_disabled,
2317
+ omit=OMIT,
2318
+ )
2319
+ try:
2320
+ if 200 <= _response.status_code < 300:
2321
+ _data = typing.cast(
2322
+ TariffAssignmentOut,
2323
+ parse_obj_as(
2324
+ type_=TariffAssignmentOut, # type: ignore
2325
+ object_=_response.json(),
2326
+ ),
2327
+ )
2328
+ return AsyncHttpResponse(response=_response, data=_data)
2329
+ if _response.status_code == 401:
2330
+ raise UnauthorizedError(
2331
+ headers=dict(_response.headers),
2332
+ body=typing.cast(
2333
+ HttpErrorResponse,
2334
+ parse_obj_as(
2335
+ type_=HttpErrorResponse, # type: ignore
2336
+ object_=_response.json(),
2337
+ ),
2338
+ ),
2339
+ )
2340
+ if _response.status_code == 404:
2341
+ raise NotFoundError(
2342
+ headers=dict(_response.headers),
2343
+ body=typing.cast(
2344
+ HttpErrorResponse,
2345
+ parse_obj_as(
2346
+ type_=HttpErrorResponse, # type: ignore
2347
+ object_=_response.json(),
2348
+ ),
2349
+ ),
2350
+ )
2351
+ if _response.status_code == 409:
2352
+ raise ConflictError(
2353
+ headers=dict(_response.headers),
2354
+ body=typing.cast(
2355
+ HttpErrorResponse,
2356
+ parse_obj_as(
2357
+ type_=HttpErrorResponse, # type: ignore
2358
+ object_=_response.json(),
2359
+ ),
2360
+ ),
2361
+ )
2362
+ if _response.status_code == 422:
2363
+ raise UnprocessableEntityError(
2364
+ headers=dict(_response.headers),
2365
+ body=typing.cast(
2366
+ HttpValidationError,
2367
+ parse_obj_as(
2368
+ type_=HttpValidationError, # type: ignore
2369
+ object_=_response.json(),
2370
+ ),
2371
+ ),
2372
+ )
2373
+ if _response.status_code == 429:
2374
+ raise TooManyRequestsError(
2375
+ headers=dict(_response.headers),
2376
+ body=typing.cast(
2377
+ HttpErrorResponse,
2378
+ parse_obj_as(
2379
+ type_=HttpErrorResponse, # type: ignore
2380
+ object_=_response.json(),
2381
+ ),
2382
+ ),
2383
+ )
2384
+ if _response.status_code == 502:
2385
+ raise BadGatewayError(
2386
+ headers=dict(_response.headers),
2387
+ body=typing.cast(
2388
+ HttpErrorResponse,
2389
+ parse_obj_as(
2390
+ type_=HttpErrorResponse, # type: ignore
2391
+ object_=_response.json(),
2392
+ ),
2393
+ ),
2394
+ )
2395
+ if _response.status_code == 504:
2396
+ raise GatewayTimeoutError(
2397
+ headers=dict(_response.headers),
2398
+ body=typing.cast(
2399
+ HttpErrorResponse,
2400
+ parse_obj_as(
2401
+ type_=HttpErrorResponse, # type: ignore
2402
+ object_=_response.json(),
2403
+ ),
2404
+ ),
2405
+ )
2406
+ _response_json = _response.json()
2407
+ except JSONDecodeError:
2408
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2409
+ except ValidationError as e:
2410
+ raise ParsingError(
2411
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
2412
+ )
2413
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
2414
+
2415
+ async def unassign(
2416
+ self, tariff_id: str, *, charge_point_id: str, request_options: typing.Optional[RequestOptions] = None
2417
+ ) -> AsyncHttpResponse[None]:
2418
+ """
2419
+ Ends the charger's assignment to this tariff; it stays as history. 404 when the charger does not use this tariff. Sessions already started keep their price.
2420
+
2421
+ Parameters
2422
+ ----------
2423
+ tariff_id : str
2424
+ OCPI tariff id.
2425
+
2426
+ charge_point_id : str
2427
+
2428
+ request_options : typing.Optional[RequestOptions]
2429
+ Request-specific configuration.
2430
+
2431
+ Returns
2432
+ -------
2433
+ AsyncHttpResponse[None]
2434
+ """
2435
+ _request_options_with_retries_disabled: typing.Optional[RequestOptions] = (
2436
+ {**request_options, "max_retries": 0} if request_options is not None else {"max_retries": 0}
2437
+ )
2438
+ _response = await self._client_wrapper.httpx_client.request(
2439
+ f"cpo/tariffs/{encode_path_param(tariff_id)}/unassign",
2440
+ method="POST",
2441
+ json={
2442
+ "charge_point_id": charge_point_id,
2443
+ },
2444
+ headers={
2445
+ "content-type": "application/json",
2446
+ },
2447
+ request_options=_request_options_with_retries_disabled,
2448
+ omit=OMIT,
2449
+ )
2450
+ try:
2451
+ if 200 <= _response.status_code < 300:
2452
+ return AsyncHttpResponse(response=_response, data=None)
2453
+ if _response.status_code == 401:
2454
+ raise UnauthorizedError(
2455
+ headers=dict(_response.headers),
2456
+ body=typing.cast(
2457
+ HttpErrorResponse,
2458
+ parse_obj_as(
2459
+ type_=HttpErrorResponse, # type: ignore
2460
+ object_=_response.json(),
2461
+ ),
2462
+ ),
2463
+ )
2464
+ if _response.status_code == 404:
2465
+ raise NotFoundError(
2466
+ headers=dict(_response.headers),
2467
+ body=typing.cast(
2468
+ HttpErrorResponse,
2469
+ parse_obj_as(
2470
+ type_=HttpErrorResponse, # type: ignore
2471
+ object_=_response.json(),
2472
+ ),
2473
+ ),
2474
+ )
2475
+ if _response.status_code == 422:
2476
+ raise UnprocessableEntityError(
2477
+ headers=dict(_response.headers),
2478
+ body=typing.cast(
2479
+ HttpValidationError,
2480
+ parse_obj_as(
2481
+ type_=HttpValidationError, # type: ignore
2482
+ object_=_response.json(),
2483
+ ),
2484
+ ),
2485
+ )
2486
+ if _response.status_code == 429:
2487
+ raise TooManyRequestsError(
2488
+ headers=dict(_response.headers),
2489
+ body=typing.cast(
2490
+ HttpErrorResponse,
2491
+ parse_obj_as(
2492
+ type_=HttpErrorResponse, # type: ignore
2493
+ object_=_response.json(),
2494
+ ),
2495
+ ),
2496
+ )
2497
+ if _response.status_code == 502:
2498
+ raise BadGatewayError(
2499
+ headers=dict(_response.headers),
2500
+ body=typing.cast(
2501
+ HttpErrorResponse,
2502
+ parse_obj_as(
2503
+ type_=HttpErrorResponse, # type: ignore
2504
+ object_=_response.json(),
2505
+ ),
2506
+ ),
2507
+ )
2508
+ if _response.status_code == 504:
2509
+ raise GatewayTimeoutError(
2510
+ headers=dict(_response.headers),
2511
+ body=typing.cast(
2512
+ HttpErrorResponse,
2513
+ parse_obj_as(
2514
+ type_=HttpErrorResponse, # type: ignore
2515
+ object_=_response.json(),
2516
+ ),
2517
+ ),
2518
+ )
2519
+ _response_json = _response.json()
2520
+ except JSONDecodeError:
2521
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
2522
+ except ValidationError as e:
2523
+ raise ParsingError(
2524
+ status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
2525
+ )
2526
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)