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