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,2947 @@
|
|
|
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.pagination import AsyncPager, SyncPager
|
|
12
|
+
from ...core.parse_error import ParsingError
|
|
13
|
+
from ...core.pydantic_utilities import parse_obj_as
|
|
14
|
+
from ...core.request_options import RequestOptions
|
|
15
|
+
from ...core.serialization import convert_and_respect_annotation_metadata
|
|
16
|
+
from ...errors.bad_gateway_error import BadGatewayError
|
|
17
|
+
from ...errors.bad_request_error import BadRequestError
|
|
18
|
+
from ...errors.conflict_error import ConflictError
|
|
19
|
+
from ...errors.gateway_timeout_error import GatewayTimeoutError
|
|
20
|
+
from ...errors.not_found_error import NotFoundError
|
|
21
|
+
from ...errors.too_many_requests_error import TooManyRequestsError
|
|
22
|
+
from ...errors.unauthorized_error import UnauthorizedError
|
|
23
|
+
from ...errors.unprocessable_entity_error import UnprocessableEntityError
|
|
24
|
+
from ...types.energy_contract import EnergyContract
|
|
25
|
+
from ...types.http_error_response import HttpErrorResponse
|
|
26
|
+
from ...types.http_validation_error import HttpValidationError
|
|
27
|
+
from ...types.token_bulk_out import TokenBulkOut
|
|
28
|
+
from ...types.token_create import TokenCreate
|
|
29
|
+
from ...types.token_create_default_profile_type import TokenCreateDefaultProfileType
|
|
30
|
+
from ...types.token_create_ocpi_version import TokenCreateOcpiVersion
|
|
31
|
+
from ...types.token_create_type import TokenCreateType
|
|
32
|
+
from ...types.token_create_whitelist import TokenCreateWhitelist
|
|
33
|
+
from ...types.token_event_out import TokenEventOut
|
|
34
|
+
from ...types.token_event_page import TokenEventPage
|
|
35
|
+
from ...types.token_out import TokenOut
|
|
36
|
+
from ...types.token_page import TokenPage
|
|
37
|
+
from ...types.token_reason import TokenReason
|
|
38
|
+
from .types.list_tokens_request_status import ListTokensRequestStatus
|
|
39
|
+
from .types.list_tokens_request_type import ListTokensRequestType
|
|
40
|
+
from .types.token_update_default_profile_type import TokenUpdateDefaultProfileType
|
|
41
|
+
from .types.token_update_whitelist import TokenUpdateWhitelist
|
|
42
|
+
from pydantic import ValidationError
|
|
43
|
+
|
|
44
|
+
# this is used as the default value for optional parameters
|
|
45
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class RawTokensClient:
|
|
49
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
50
|
+
self._client_wrapper = client_wrapper
|
|
51
|
+
|
|
52
|
+
def list(
|
|
53
|
+
self,
|
|
54
|
+
*,
|
|
55
|
+
status: typing.Optional[ListTokensRequestStatus] = None,
|
|
56
|
+
type: typing.Optional[ListTokensRequestType] = None,
|
|
57
|
+
search: typing.Optional[str] = None,
|
|
58
|
+
after: typing.Optional[str] = None,
|
|
59
|
+
limit: typing.Optional[int] = None,
|
|
60
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
61
|
+
) -> SyncPager[TokenOut, TokenPage]:
|
|
62
|
+
"""
|
|
63
|
+
Tokens you issued, filtered by status, type or text in uid, contract id or printed number.
|
|
64
|
+
|
|
65
|
+
Parameters
|
|
66
|
+
----------
|
|
67
|
+
status : typing.Optional[ListTokensRequestStatus]
|
|
68
|
+
Only this status. EXPIRED means ``valid_until`` has passed and the token is not revoked.
|
|
69
|
+
|
|
70
|
+
type : typing.Optional[ListTokensRequestType]
|
|
71
|
+
Only this OCPI token type.
|
|
72
|
+
|
|
73
|
+
search : typing.Optional[str]
|
|
74
|
+
Text in uid, contract id or printed number.
|
|
75
|
+
|
|
76
|
+
after : typing.Optional[str]
|
|
77
|
+
Cursor: the previous page's ``pagination.end_cursor``. Omit it for the first page.
|
|
78
|
+
|
|
79
|
+
limit : typing.Optional[int]
|
|
80
|
+
Maximum rows per page (default 50, max 200).
|
|
81
|
+
|
|
82
|
+
request_options : typing.Optional[RequestOptions]
|
|
83
|
+
Request-specific configuration.
|
|
84
|
+
|
|
85
|
+
Returns
|
|
86
|
+
-------
|
|
87
|
+
SyncPager[TokenOut, TokenPage]
|
|
88
|
+
One page of tokens.
|
|
89
|
+
"""
|
|
90
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
91
|
+
"emsp/tokens",
|
|
92
|
+
method="GET",
|
|
93
|
+
params={
|
|
94
|
+
"status": status,
|
|
95
|
+
"type": type,
|
|
96
|
+
"search": search,
|
|
97
|
+
"after": after,
|
|
98
|
+
"limit": limit,
|
|
99
|
+
},
|
|
100
|
+
request_options=request_options,
|
|
101
|
+
)
|
|
102
|
+
try:
|
|
103
|
+
if 200 <= _response.status_code < 300:
|
|
104
|
+
_parsed_response = typing.cast(
|
|
105
|
+
TokenPage,
|
|
106
|
+
parse_obj_as(
|
|
107
|
+
type_=TokenPage, # type: ignore
|
|
108
|
+
object_=_response.json(),
|
|
109
|
+
),
|
|
110
|
+
)
|
|
111
|
+
_items = _parsed_response.data
|
|
112
|
+
_has_next = False
|
|
113
|
+
_get_next = None
|
|
114
|
+
if _parsed_response.pagination is not None:
|
|
115
|
+
_parsed_next = _parsed_response.pagination.end_cursor
|
|
116
|
+
_has_next = _parsed_next is not None and _parsed_next != ""
|
|
117
|
+
_get_next = lambda: self.list(
|
|
118
|
+
status=status,
|
|
119
|
+
type=type,
|
|
120
|
+
search=search,
|
|
121
|
+
after=_parsed_next,
|
|
122
|
+
limit=limit,
|
|
123
|
+
request_options=request_options,
|
|
124
|
+
)
|
|
125
|
+
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
|
|
126
|
+
if _response.status_code == 401:
|
|
127
|
+
raise UnauthorizedError(
|
|
128
|
+
headers=dict(_response.headers),
|
|
129
|
+
body=typing.cast(
|
|
130
|
+
HttpErrorResponse,
|
|
131
|
+
parse_obj_as(
|
|
132
|
+
type_=HttpErrorResponse, # type: ignore
|
|
133
|
+
object_=_response.json(),
|
|
134
|
+
),
|
|
135
|
+
),
|
|
136
|
+
)
|
|
137
|
+
if _response.status_code == 422:
|
|
138
|
+
raise UnprocessableEntityError(
|
|
139
|
+
headers=dict(_response.headers),
|
|
140
|
+
body=typing.cast(
|
|
141
|
+
HttpValidationError,
|
|
142
|
+
parse_obj_as(
|
|
143
|
+
type_=HttpValidationError, # type: ignore
|
|
144
|
+
object_=_response.json(),
|
|
145
|
+
),
|
|
146
|
+
),
|
|
147
|
+
)
|
|
148
|
+
if _response.status_code == 429:
|
|
149
|
+
raise TooManyRequestsError(
|
|
150
|
+
headers=dict(_response.headers),
|
|
151
|
+
body=typing.cast(
|
|
152
|
+
HttpErrorResponse,
|
|
153
|
+
parse_obj_as(
|
|
154
|
+
type_=HttpErrorResponse, # type: ignore
|
|
155
|
+
object_=_response.json(),
|
|
156
|
+
),
|
|
157
|
+
),
|
|
158
|
+
)
|
|
159
|
+
if _response.status_code == 502:
|
|
160
|
+
raise BadGatewayError(
|
|
161
|
+
headers=dict(_response.headers),
|
|
162
|
+
body=typing.cast(
|
|
163
|
+
HttpErrorResponse,
|
|
164
|
+
parse_obj_as(
|
|
165
|
+
type_=HttpErrorResponse, # type: ignore
|
|
166
|
+
object_=_response.json(),
|
|
167
|
+
),
|
|
168
|
+
),
|
|
169
|
+
)
|
|
170
|
+
if _response.status_code == 504:
|
|
171
|
+
raise GatewayTimeoutError(
|
|
172
|
+
headers=dict(_response.headers),
|
|
173
|
+
body=typing.cast(
|
|
174
|
+
HttpErrorResponse,
|
|
175
|
+
parse_obj_as(
|
|
176
|
+
type_=HttpErrorResponse, # type: ignore
|
|
177
|
+
object_=_response.json(),
|
|
178
|
+
),
|
|
179
|
+
),
|
|
180
|
+
)
|
|
181
|
+
_response_json = _response.json()
|
|
182
|
+
except JSONDecodeError:
|
|
183
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
184
|
+
except ValidationError as e:
|
|
185
|
+
raise ParsingError(
|
|
186
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
187
|
+
)
|
|
188
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
189
|
+
|
|
190
|
+
def provision(
|
|
191
|
+
self,
|
|
192
|
+
*,
|
|
193
|
+
idempotency_key: str,
|
|
194
|
+
uid: str,
|
|
195
|
+
type: TokenCreateType,
|
|
196
|
+
contract_id: str,
|
|
197
|
+
issuer: str,
|
|
198
|
+
visual_number: typing.Optional[str] = OMIT,
|
|
199
|
+
group_id: typing.Optional[str] = OMIT,
|
|
200
|
+
whitelist: typing.Optional[TokenCreateWhitelist] = OMIT,
|
|
201
|
+
language: typing.Optional[str] = OMIT,
|
|
202
|
+
valid_from: typing.Optional[dt.datetime] = OMIT,
|
|
203
|
+
valid_until: typing.Optional[dt.datetime] = OMIT,
|
|
204
|
+
country_code: typing.Optional[str] = OMIT,
|
|
205
|
+
party_id: typing.Optional[str] = OMIT,
|
|
206
|
+
ocpi_version: typing.Optional[TokenCreateOcpiVersion] = OMIT,
|
|
207
|
+
metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
208
|
+
is_roaming: typing.Optional[bool] = OMIT,
|
|
209
|
+
default_profile_type: typing.Optional[TokenCreateDefaultProfileType] = OMIT,
|
|
210
|
+
energy_contract: typing.Optional[EnergyContract] = OMIT,
|
|
211
|
+
auto_activate: typing.Optional[bool] = OMIT,
|
|
212
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
213
|
+
) -> HttpResponse[TokenOut]:
|
|
214
|
+
"""
|
|
215
|
+
Creates the token as PROVISIONED; with ``auto_activate`` it is pushed to roaming partners and stored ACTIVE. If the push to roaming partners fails the call answers 502 and the token is left as it was; retry with the same Idempotency-Key.
|
|
216
|
+
|
|
217
|
+
Parameters
|
|
218
|
+
----------
|
|
219
|
+
idempotency_key : str
|
|
220
|
+
A unique key you choose for this call, e.g. a UUID. Retrying with the same key returns the first result instead of acting twice.
|
|
221
|
+
|
|
222
|
+
uid : str
|
|
223
|
+
|
|
224
|
+
type : TokenCreateType
|
|
225
|
+
|
|
226
|
+
contract_id : str
|
|
227
|
+
|
|
228
|
+
issuer : str
|
|
229
|
+
|
|
230
|
+
visual_number : typing.Optional[str]
|
|
231
|
+
|
|
232
|
+
group_id : typing.Optional[str]
|
|
233
|
+
|
|
234
|
+
whitelist : typing.Optional[TokenCreateWhitelist]
|
|
235
|
+
|
|
236
|
+
language : typing.Optional[str]
|
|
237
|
+
|
|
238
|
+
valid_from : typing.Optional[dt.datetime]
|
|
239
|
+
|
|
240
|
+
valid_until : typing.Optional[dt.datetime]
|
|
241
|
+
|
|
242
|
+
country_code : typing.Optional[str]
|
|
243
|
+
|
|
244
|
+
party_id : typing.Optional[str]
|
|
245
|
+
|
|
246
|
+
ocpi_version : typing.Optional[TokenCreateOcpiVersion]
|
|
247
|
+
|
|
248
|
+
metadata : typing.Optional[typing.Dict[str, typing.Any]]
|
|
249
|
+
|
|
250
|
+
is_roaming : typing.Optional[bool]
|
|
251
|
+
|
|
252
|
+
default_profile_type : typing.Optional[TokenCreateDefaultProfileType]
|
|
253
|
+
|
|
254
|
+
energy_contract : typing.Optional[EnergyContract]
|
|
255
|
+
|
|
256
|
+
auto_activate : typing.Optional[bool]
|
|
257
|
+
|
|
258
|
+
request_options : typing.Optional[RequestOptions]
|
|
259
|
+
Request-specific configuration.
|
|
260
|
+
|
|
261
|
+
Returns
|
|
262
|
+
-------
|
|
263
|
+
HttpResponse[TokenOut]
|
|
264
|
+
The token; ACTIVE when ``auto_activate`` was set, else PROVISIONED.
|
|
265
|
+
"""
|
|
266
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
267
|
+
"emsp/tokens",
|
|
268
|
+
method="POST",
|
|
269
|
+
json={
|
|
270
|
+
"uid": uid,
|
|
271
|
+
"type": type,
|
|
272
|
+
"contract_id": contract_id,
|
|
273
|
+
"issuer": issuer,
|
|
274
|
+
"visual_number": visual_number,
|
|
275
|
+
"group_id": group_id,
|
|
276
|
+
"whitelist": whitelist,
|
|
277
|
+
"language": language,
|
|
278
|
+
"valid_from": valid_from,
|
|
279
|
+
"valid_until": valid_until,
|
|
280
|
+
"country_code": country_code,
|
|
281
|
+
"party_id": party_id,
|
|
282
|
+
"ocpi_version": ocpi_version,
|
|
283
|
+
"metadata": metadata,
|
|
284
|
+
"is_roaming": is_roaming,
|
|
285
|
+
"default_profile_type": default_profile_type,
|
|
286
|
+
"energy_contract": convert_and_respect_annotation_metadata(
|
|
287
|
+
object_=energy_contract, annotation=typing.Optional[EnergyContract], direction="write"
|
|
288
|
+
),
|
|
289
|
+
"auto_activate": auto_activate,
|
|
290
|
+
},
|
|
291
|
+
headers={
|
|
292
|
+
"content-type": "application/json",
|
|
293
|
+
"Idempotency-Key": str(idempotency_key) if idempotency_key is not None else None,
|
|
294
|
+
},
|
|
295
|
+
request_options=request_options,
|
|
296
|
+
omit=OMIT,
|
|
297
|
+
)
|
|
298
|
+
try:
|
|
299
|
+
if 200 <= _response.status_code < 300:
|
|
300
|
+
_data = typing.cast(
|
|
301
|
+
TokenOut,
|
|
302
|
+
parse_obj_as(
|
|
303
|
+
type_=TokenOut, # type: ignore
|
|
304
|
+
object_=_response.json(),
|
|
305
|
+
),
|
|
306
|
+
)
|
|
307
|
+
return HttpResponse(response=_response, data=_data)
|
|
308
|
+
if _response.status_code == 400:
|
|
309
|
+
raise BadRequestError(
|
|
310
|
+
headers=dict(_response.headers),
|
|
311
|
+
body=typing.cast(
|
|
312
|
+
HttpErrorResponse,
|
|
313
|
+
parse_obj_as(
|
|
314
|
+
type_=HttpErrorResponse, # type: ignore
|
|
315
|
+
object_=_response.json(),
|
|
316
|
+
),
|
|
317
|
+
),
|
|
318
|
+
)
|
|
319
|
+
if _response.status_code == 401:
|
|
320
|
+
raise UnauthorizedError(
|
|
321
|
+
headers=dict(_response.headers),
|
|
322
|
+
body=typing.cast(
|
|
323
|
+
HttpErrorResponse,
|
|
324
|
+
parse_obj_as(
|
|
325
|
+
type_=HttpErrorResponse, # type: ignore
|
|
326
|
+
object_=_response.json(),
|
|
327
|
+
),
|
|
328
|
+
),
|
|
329
|
+
)
|
|
330
|
+
if _response.status_code == 409:
|
|
331
|
+
raise ConflictError(
|
|
332
|
+
headers=dict(_response.headers),
|
|
333
|
+
body=typing.cast(
|
|
334
|
+
HttpErrorResponse,
|
|
335
|
+
parse_obj_as(
|
|
336
|
+
type_=HttpErrorResponse, # type: ignore
|
|
337
|
+
object_=_response.json(),
|
|
338
|
+
),
|
|
339
|
+
),
|
|
340
|
+
)
|
|
341
|
+
if _response.status_code == 422:
|
|
342
|
+
raise UnprocessableEntityError(
|
|
343
|
+
headers=dict(_response.headers),
|
|
344
|
+
body=typing.cast(
|
|
345
|
+
HttpValidationError,
|
|
346
|
+
parse_obj_as(
|
|
347
|
+
type_=HttpValidationError, # type: ignore
|
|
348
|
+
object_=_response.json(),
|
|
349
|
+
),
|
|
350
|
+
),
|
|
351
|
+
)
|
|
352
|
+
if _response.status_code == 429:
|
|
353
|
+
raise TooManyRequestsError(
|
|
354
|
+
headers=dict(_response.headers),
|
|
355
|
+
body=typing.cast(
|
|
356
|
+
HttpErrorResponse,
|
|
357
|
+
parse_obj_as(
|
|
358
|
+
type_=HttpErrorResponse, # type: ignore
|
|
359
|
+
object_=_response.json(),
|
|
360
|
+
),
|
|
361
|
+
),
|
|
362
|
+
)
|
|
363
|
+
if _response.status_code == 502:
|
|
364
|
+
raise BadGatewayError(
|
|
365
|
+
headers=dict(_response.headers),
|
|
366
|
+
body=typing.cast(
|
|
367
|
+
HttpErrorResponse,
|
|
368
|
+
parse_obj_as(
|
|
369
|
+
type_=HttpErrorResponse, # type: ignore
|
|
370
|
+
object_=_response.json(),
|
|
371
|
+
),
|
|
372
|
+
),
|
|
373
|
+
)
|
|
374
|
+
if _response.status_code == 504:
|
|
375
|
+
raise GatewayTimeoutError(
|
|
376
|
+
headers=dict(_response.headers),
|
|
377
|
+
body=typing.cast(
|
|
378
|
+
HttpErrorResponse,
|
|
379
|
+
parse_obj_as(
|
|
380
|
+
type_=HttpErrorResponse, # type: ignore
|
|
381
|
+
object_=_response.json(),
|
|
382
|
+
),
|
|
383
|
+
),
|
|
384
|
+
)
|
|
385
|
+
_response_json = _response.json()
|
|
386
|
+
except JSONDecodeError:
|
|
387
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
388
|
+
except ValidationError as e:
|
|
389
|
+
raise ParsingError(
|
|
390
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
391
|
+
)
|
|
392
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
393
|
+
|
|
394
|
+
def bulk_provision(
|
|
395
|
+
self,
|
|
396
|
+
*,
|
|
397
|
+
idempotency_key: str,
|
|
398
|
+
tokens: typing.Sequence[TokenCreate],
|
|
399
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
400
|
+
) -> HttpResponse[TokenBulkOut]:
|
|
401
|
+
"""
|
|
402
|
+
The batch is validated and created as a whole. With ``auto_activate`` each token is pushed in turn; a failed push is listed and that token stays PROVISIONED.
|
|
403
|
+
|
|
404
|
+
Parameters
|
|
405
|
+
----------
|
|
406
|
+
idempotency_key : str
|
|
407
|
+
A unique key you choose for this call, e.g. a UUID. Retrying with the same key returns the first result instead of acting twice.
|
|
408
|
+
|
|
409
|
+
tokens : typing.Sequence[TokenCreate]
|
|
410
|
+
|
|
411
|
+
request_options : typing.Optional[RequestOptions]
|
|
412
|
+
Request-specific configuration.
|
|
413
|
+
|
|
414
|
+
Returns
|
|
415
|
+
-------
|
|
416
|
+
HttpResponse[TokenBulkOut]
|
|
417
|
+
How many tokens were provisioned and activated, and which pushes failed.
|
|
418
|
+
"""
|
|
419
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
420
|
+
"emsp/tokens/bulk",
|
|
421
|
+
method="POST",
|
|
422
|
+
json={
|
|
423
|
+
"tokens": convert_and_respect_annotation_metadata(
|
|
424
|
+
object_=tokens, annotation=typing.Sequence[TokenCreate], direction="write"
|
|
425
|
+
),
|
|
426
|
+
},
|
|
427
|
+
headers={
|
|
428
|
+
"content-type": "application/json",
|
|
429
|
+
"Idempotency-Key": str(idempotency_key) if idempotency_key is not None else None,
|
|
430
|
+
},
|
|
431
|
+
request_options=request_options,
|
|
432
|
+
omit=OMIT,
|
|
433
|
+
)
|
|
434
|
+
try:
|
|
435
|
+
if 200 <= _response.status_code < 300:
|
|
436
|
+
_data = typing.cast(
|
|
437
|
+
TokenBulkOut,
|
|
438
|
+
parse_obj_as(
|
|
439
|
+
type_=TokenBulkOut, # type: ignore
|
|
440
|
+
object_=_response.json(),
|
|
441
|
+
),
|
|
442
|
+
)
|
|
443
|
+
return HttpResponse(response=_response, data=_data)
|
|
444
|
+
if _response.status_code == 401:
|
|
445
|
+
raise UnauthorizedError(
|
|
446
|
+
headers=dict(_response.headers),
|
|
447
|
+
body=typing.cast(
|
|
448
|
+
HttpErrorResponse,
|
|
449
|
+
parse_obj_as(
|
|
450
|
+
type_=HttpErrorResponse, # type: ignore
|
|
451
|
+
object_=_response.json(),
|
|
452
|
+
),
|
|
453
|
+
),
|
|
454
|
+
)
|
|
455
|
+
if _response.status_code == 409:
|
|
456
|
+
raise ConflictError(
|
|
457
|
+
headers=dict(_response.headers),
|
|
458
|
+
body=typing.cast(
|
|
459
|
+
HttpErrorResponse,
|
|
460
|
+
parse_obj_as(
|
|
461
|
+
type_=HttpErrorResponse, # type: ignore
|
|
462
|
+
object_=_response.json(),
|
|
463
|
+
),
|
|
464
|
+
),
|
|
465
|
+
)
|
|
466
|
+
if _response.status_code == 422:
|
|
467
|
+
raise UnprocessableEntityError(
|
|
468
|
+
headers=dict(_response.headers),
|
|
469
|
+
body=typing.cast(
|
|
470
|
+
HttpValidationError,
|
|
471
|
+
parse_obj_as(
|
|
472
|
+
type_=HttpValidationError, # type: ignore
|
|
473
|
+
object_=_response.json(),
|
|
474
|
+
),
|
|
475
|
+
),
|
|
476
|
+
)
|
|
477
|
+
if _response.status_code == 429:
|
|
478
|
+
raise TooManyRequestsError(
|
|
479
|
+
headers=dict(_response.headers),
|
|
480
|
+
body=typing.cast(
|
|
481
|
+
HttpErrorResponse,
|
|
482
|
+
parse_obj_as(
|
|
483
|
+
type_=HttpErrorResponse, # type: ignore
|
|
484
|
+
object_=_response.json(),
|
|
485
|
+
),
|
|
486
|
+
),
|
|
487
|
+
)
|
|
488
|
+
if _response.status_code == 502:
|
|
489
|
+
raise BadGatewayError(
|
|
490
|
+
headers=dict(_response.headers),
|
|
491
|
+
body=typing.cast(
|
|
492
|
+
HttpErrorResponse,
|
|
493
|
+
parse_obj_as(
|
|
494
|
+
type_=HttpErrorResponse, # type: ignore
|
|
495
|
+
object_=_response.json(),
|
|
496
|
+
),
|
|
497
|
+
),
|
|
498
|
+
)
|
|
499
|
+
if _response.status_code == 504:
|
|
500
|
+
raise GatewayTimeoutError(
|
|
501
|
+
headers=dict(_response.headers),
|
|
502
|
+
body=typing.cast(
|
|
503
|
+
HttpErrorResponse,
|
|
504
|
+
parse_obj_as(
|
|
505
|
+
type_=HttpErrorResponse, # type: ignore
|
|
506
|
+
object_=_response.json(),
|
|
507
|
+
),
|
|
508
|
+
),
|
|
509
|
+
)
|
|
510
|
+
_response_json = _response.json()
|
|
511
|
+
except JSONDecodeError:
|
|
512
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
513
|
+
except ValidationError as e:
|
|
514
|
+
raise ParsingError(
|
|
515
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
516
|
+
)
|
|
517
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
518
|
+
|
|
519
|
+
def get(self, token_id: int, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[TokenOut]:
|
|
520
|
+
"""
|
|
521
|
+
One token you issued.
|
|
522
|
+
|
|
523
|
+
Parameters
|
|
524
|
+
----------
|
|
525
|
+
token_id : int
|
|
526
|
+
The token's ``id``.
|
|
527
|
+
|
|
528
|
+
request_options : typing.Optional[RequestOptions]
|
|
529
|
+
Request-specific configuration.
|
|
530
|
+
|
|
531
|
+
Returns
|
|
532
|
+
-------
|
|
533
|
+
HttpResponse[TokenOut]
|
|
534
|
+
The token.
|
|
535
|
+
"""
|
|
536
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
537
|
+
f"emsp/tokens/{encode_path_param(token_id)}",
|
|
538
|
+
method="GET",
|
|
539
|
+
request_options=request_options,
|
|
540
|
+
)
|
|
541
|
+
try:
|
|
542
|
+
if 200 <= _response.status_code < 300:
|
|
543
|
+
_data = typing.cast(
|
|
544
|
+
TokenOut,
|
|
545
|
+
parse_obj_as(
|
|
546
|
+
type_=TokenOut, # type: ignore
|
|
547
|
+
object_=_response.json(),
|
|
548
|
+
),
|
|
549
|
+
)
|
|
550
|
+
return HttpResponse(response=_response, data=_data)
|
|
551
|
+
if _response.status_code == 401:
|
|
552
|
+
raise UnauthorizedError(
|
|
553
|
+
headers=dict(_response.headers),
|
|
554
|
+
body=typing.cast(
|
|
555
|
+
HttpErrorResponse,
|
|
556
|
+
parse_obj_as(
|
|
557
|
+
type_=HttpErrorResponse, # type: ignore
|
|
558
|
+
object_=_response.json(),
|
|
559
|
+
),
|
|
560
|
+
),
|
|
561
|
+
)
|
|
562
|
+
if _response.status_code == 404:
|
|
563
|
+
raise NotFoundError(
|
|
564
|
+
headers=dict(_response.headers),
|
|
565
|
+
body=typing.cast(
|
|
566
|
+
HttpErrorResponse,
|
|
567
|
+
parse_obj_as(
|
|
568
|
+
type_=HttpErrorResponse, # type: ignore
|
|
569
|
+
object_=_response.json(),
|
|
570
|
+
),
|
|
571
|
+
),
|
|
572
|
+
)
|
|
573
|
+
if _response.status_code == 422:
|
|
574
|
+
raise UnprocessableEntityError(
|
|
575
|
+
headers=dict(_response.headers),
|
|
576
|
+
body=typing.cast(
|
|
577
|
+
HttpValidationError,
|
|
578
|
+
parse_obj_as(
|
|
579
|
+
type_=HttpValidationError, # type: ignore
|
|
580
|
+
object_=_response.json(),
|
|
581
|
+
),
|
|
582
|
+
),
|
|
583
|
+
)
|
|
584
|
+
if _response.status_code == 429:
|
|
585
|
+
raise TooManyRequestsError(
|
|
586
|
+
headers=dict(_response.headers),
|
|
587
|
+
body=typing.cast(
|
|
588
|
+
HttpErrorResponse,
|
|
589
|
+
parse_obj_as(
|
|
590
|
+
type_=HttpErrorResponse, # type: ignore
|
|
591
|
+
object_=_response.json(),
|
|
592
|
+
),
|
|
593
|
+
),
|
|
594
|
+
)
|
|
595
|
+
if _response.status_code == 502:
|
|
596
|
+
raise BadGatewayError(
|
|
597
|
+
headers=dict(_response.headers),
|
|
598
|
+
body=typing.cast(
|
|
599
|
+
HttpErrorResponse,
|
|
600
|
+
parse_obj_as(
|
|
601
|
+
type_=HttpErrorResponse, # type: ignore
|
|
602
|
+
object_=_response.json(),
|
|
603
|
+
),
|
|
604
|
+
),
|
|
605
|
+
)
|
|
606
|
+
if _response.status_code == 504:
|
|
607
|
+
raise GatewayTimeoutError(
|
|
608
|
+
headers=dict(_response.headers),
|
|
609
|
+
body=typing.cast(
|
|
610
|
+
HttpErrorResponse,
|
|
611
|
+
parse_obj_as(
|
|
612
|
+
type_=HttpErrorResponse, # type: ignore
|
|
613
|
+
object_=_response.json(),
|
|
614
|
+
),
|
|
615
|
+
),
|
|
616
|
+
)
|
|
617
|
+
_response_json = _response.json()
|
|
618
|
+
except JSONDecodeError:
|
|
619
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
620
|
+
except ValidationError as e:
|
|
621
|
+
raise ParsingError(
|
|
622
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
623
|
+
)
|
|
624
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
625
|
+
|
|
626
|
+
def update(
|
|
627
|
+
self,
|
|
628
|
+
token_id: int,
|
|
629
|
+
*,
|
|
630
|
+
visual_number: typing.Optional[str] = OMIT,
|
|
631
|
+
contract_id: typing.Optional[str] = OMIT,
|
|
632
|
+
issuer: typing.Optional[str] = OMIT,
|
|
633
|
+
language: typing.Optional[str] = OMIT,
|
|
634
|
+
whitelist: typing.Optional[TokenUpdateWhitelist] = OMIT,
|
|
635
|
+
group_id: typing.Optional[str] = OMIT,
|
|
636
|
+
metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
637
|
+
is_roaming: typing.Optional[bool] = OMIT,
|
|
638
|
+
default_profile_type: typing.Optional[TokenUpdateDefaultProfileType] = OMIT,
|
|
639
|
+
energy_contract: typing.Optional[EnergyContract] = OMIT,
|
|
640
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
641
|
+
) -> HttpResponse[TokenOut]:
|
|
642
|
+
"""
|
|
643
|
+
Only the fields sent change. ACTIVE and SUSPENDED tokens are pushed to partners again before the change is saved. If the push to roaming partners fails the call answers 502 and the token is left as it was; retry with the same Idempotency-Key.
|
|
644
|
+
|
|
645
|
+
Parameters
|
|
646
|
+
----------
|
|
647
|
+
token_id : int
|
|
648
|
+
The token's ``id``.
|
|
649
|
+
|
|
650
|
+
visual_number : typing.Optional[str]
|
|
651
|
+
|
|
652
|
+
contract_id : typing.Optional[str]
|
|
653
|
+
|
|
654
|
+
issuer : typing.Optional[str]
|
|
655
|
+
|
|
656
|
+
language : typing.Optional[str]
|
|
657
|
+
|
|
658
|
+
whitelist : typing.Optional[TokenUpdateWhitelist]
|
|
659
|
+
|
|
660
|
+
group_id : typing.Optional[str]
|
|
661
|
+
|
|
662
|
+
metadata : typing.Optional[typing.Dict[str, typing.Any]]
|
|
663
|
+
|
|
664
|
+
is_roaming : typing.Optional[bool]
|
|
665
|
+
|
|
666
|
+
default_profile_type : typing.Optional[TokenUpdateDefaultProfileType]
|
|
667
|
+
|
|
668
|
+
energy_contract : typing.Optional[EnergyContract]
|
|
669
|
+
|
|
670
|
+
request_options : typing.Optional[RequestOptions]
|
|
671
|
+
Request-specific configuration.
|
|
672
|
+
|
|
673
|
+
Returns
|
|
674
|
+
-------
|
|
675
|
+
HttpResponse[TokenOut]
|
|
676
|
+
The token after the update.
|
|
677
|
+
"""
|
|
678
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
679
|
+
f"emsp/tokens/{encode_path_param(token_id)}",
|
|
680
|
+
method="PATCH",
|
|
681
|
+
json={
|
|
682
|
+
"visual_number": visual_number,
|
|
683
|
+
"contract_id": contract_id,
|
|
684
|
+
"issuer": issuer,
|
|
685
|
+
"language": language,
|
|
686
|
+
"whitelist": whitelist,
|
|
687
|
+
"group_id": group_id,
|
|
688
|
+
"metadata": metadata,
|
|
689
|
+
"is_roaming": is_roaming,
|
|
690
|
+
"default_profile_type": default_profile_type,
|
|
691
|
+
"energy_contract": convert_and_respect_annotation_metadata(
|
|
692
|
+
object_=energy_contract, annotation=typing.Optional[EnergyContract], direction="write"
|
|
693
|
+
),
|
|
694
|
+
},
|
|
695
|
+
headers={
|
|
696
|
+
"content-type": "application/json",
|
|
697
|
+
},
|
|
698
|
+
request_options=request_options,
|
|
699
|
+
omit=OMIT,
|
|
700
|
+
)
|
|
701
|
+
try:
|
|
702
|
+
if 200 <= _response.status_code < 300:
|
|
703
|
+
_data = typing.cast(
|
|
704
|
+
TokenOut,
|
|
705
|
+
parse_obj_as(
|
|
706
|
+
type_=TokenOut, # type: ignore
|
|
707
|
+
object_=_response.json(),
|
|
708
|
+
),
|
|
709
|
+
)
|
|
710
|
+
return HttpResponse(response=_response, data=_data)
|
|
711
|
+
if _response.status_code == 401:
|
|
712
|
+
raise UnauthorizedError(
|
|
713
|
+
headers=dict(_response.headers),
|
|
714
|
+
body=typing.cast(
|
|
715
|
+
HttpErrorResponse,
|
|
716
|
+
parse_obj_as(
|
|
717
|
+
type_=HttpErrorResponse, # type: ignore
|
|
718
|
+
object_=_response.json(),
|
|
719
|
+
),
|
|
720
|
+
),
|
|
721
|
+
)
|
|
722
|
+
if _response.status_code == 404:
|
|
723
|
+
raise NotFoundError(
|
|
724
|
+
headers=dict(_response.headers),
|
|
725
|
+
body=typing.cast(
|
|
726
|
+
HttpErrorResponse,
|
|
727
|
+
parse_obj_as(
|
|
728
|
+
type_=HttpErrorResponse, # type: ignore
|
|
729
|
+
object_=_response.json(),
|
|
730
|
+
),
|
|
731
|
+
),
|
|
732
|
+
)
|
|
733
|
+
if _response.status_code == 422:
|
|
734
|
+
raise UnprocessableEntityError(
|
|
735
|
+
headers=dict(_response.headers),
|
|
736
|
+
body=typing.cast(
|
|
737
|
+
HttpValidationError,
|
|
738
|
+
parse_obj_as(
|
|
739
|
+
type_=HttpValidationError, # type: ignore
|
|
740
|
+
object_=_response.json(),
|
|
741
|
+
),
|
|
742
|
+
),
|
|
743
|
+
)
|
|
744
|
+
if _response.status_code == 429:
|
|
745
|
+
raise TooManyRequestsError(
|
|
746
|
+
headers=dict(_response.headers),
|
|
747
|
+
body=typing.cast(
|
|
748
|
+
HttpErrorResponse,
|
|
749
|
+
parse_obj_as(
|
|
750
|
+
type_=HttpErrorResponse, # type: ignore
|
|
751
|
+
object_=_response.json(),
|
|
752
|
+
),
|
|
753
|
+
),
|
|
754
|
+
)
|
|
755
|
+
if _response.status_code == 502:
|
|
756
|
+
raise BadGatewayError(
|
|
757
|
+
headers=dict(_response.headers),
|
|
758
|
+
body=typing.cast(
|
|
759
|
+
HttpErrorResponse,
|
|
760
|
+
parse_obj_as(
|
|
761
|
+
type_=HttpErrorResponse, # type: ignore
|
|
762
|
+
object_=_response.json(),
|
|
763
|
+
),
|
|
764
|
+
),
|
|
765
|
+
)
|
|
766
|
+
if _response.status_code == 504:
|
|
767
|
+
raise GatewayTimeoutError(
|
|
768
|
+
headers=dict(_response.headers),
|
|
769
|
+
body=typing.cast(
|
|
770
|
+
HttpErrorResponse,
|
|
771
|
+
parse_obj_as(
|
|
772
|
+
type_=HttpErrorResponse, # type: ignore
|
|
773
|
+
object_=_response.json(),
|
|
774
|
+
),
|
|
775
|
+
),
|
|
776
|
+
)
|
|
777
|
+
_response_json = _response.json()
|
|
778
|
+
except JSONDecodeError:
|
|
779
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
780
|
+
except ValidationError as e:
|
|
781
|
+
raise ParsingError(
|
|
782
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
783
|
+
)
|
|
784
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
785
|
+
|
|
786
|
+
def activate(
|
|
787
|
+
self, token_id: int, *, idempotency_key: str, request_options: typing.Optional[RequestOptions] = None
|
|
788
|
+
) -> HttpResponse[TokenOut]:
|
|
789
|
+
"""
|
|
790
|
+
PROVISIONED → ACTIVE: pushed to partners with ``valid: true``. If the push to roaming partners fails the call answers 502 and the token is left as it was; retry with the same Idempotency-Key.
|
|
791
|
+
|
|
792
|
+
Parameters
|
|
793
|
+
----------
|
|
794
|
+
token_id : int
|
|
795
|
+
The token's ``id``.
|
|
796
|
+
|
|
797
|
+
idempotency_key : str
|
|
798
|
+
A unique key you choose for this call, e.g. a UUID. Retrying with the same key returns the first result instead of acting twice.
|
|
799
|
+
|
|
800
|
+
request_options : typing.Optional[RequestOptions]
|
|
801
|
+
Request-specific configuration.
|
|
802
|
+
|
|
803
|
+
Returns
|
|
804
|
+
-------
|
|
805
|
+
HttpResponse[TokenOut]
|
|
806
|
+
The token after the change.
|
|
807
|
+
"""
|
|
808
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
809
|
+
f"emsp/tokens/{encode_path_param(token_id)}/activate",
|
|
810
|
+
method="POST",
|
|
811
|
+
headers={
|
|
812
|
+
"Idempotency-Key": str(idempotency_key) if idempotency_key is not None else None,
|
|
813
|
+
},
|
|
814
|
+
request_options=request_options,
|
|
815
|
+
)
|
|
816
|
+
try:
|
|
817
|
+
if 200 <= _response.status_code < 300:
|
|
818
|
+
_data = typing.cast(
|
|
819
|
+
TokenOut,
|
|
820
|
+
parse_obj_as(
|
|
821
|
+
type_=TokenOut, # type: ignore
|
|
822
|
+
object_=_response.json(),
|
|
823
|
+
),
|
|
824
|
+
)
|
|
825
|
+
return HttpResponse(response=_response, data=_data)
|
|
826
|
+
if _response.status_code == 400:
|
|
827
|
+
raise BadRequestError(
|
|
828
|
+
headers=dict(_response.headers),
|
|
829
|
+
body=typing.cast(
|
|
830
|
+
HttpErrorResponse,
|
|
831
|
+
parse_obj_as(
|
|
832
|
+
type_=HttpErrorResponse, # type: ignore
|
|
833
|
+
object_=_response.json(),
|
|
834
|
+
),
|
|
835
|
+
),
|
|
836
|
+
)
|
|
837
|
+
if _response.status_code == 401:
|
|
838
|
+
raise UnauthorizedError(
|
|
839
|
+
headers=dict(_response.headers),
|
|
840
|
+
body=typing.cast(
|
|
841
|
+
HttpErrorResponse,
|
|
842
|
+
parse_obj_as(
|
|
843
|
+
type_=HttpErrorResponse, # type: ignore
|
|
844
|
+
object_=_response.json(),
|
|
845
|
+
),
|
|
846
|
+
),
|
|
847
|
+
)
|
|
848
|
+
if _response.status_code == 404:
|
|
849
|
+
raise NotFoundError(
|
|
850
|
+
headers=dict(_response.headers),
|
|
851
|
+
body=typing.cast(
|
|
852
|
+
HttpErrorResponse,
|
|
853
|
+
parse_obj_as(
|
|
854
|
+
type_=HttpErrorResponse, # type: ignore
|
|
855
|
+
object_=_response.json(),
|
|
856
|
+
),
|
|
857
|
+
),
|
|
858
|
+
)
|
|
859
|
+
if _response.status_code == 409:
|
|
860
|
+
raise ConflictError(
|
|
861
|
+
headers=dict(_response.headers),
|
|
862
|
+
body=typing.cast(
|
|
863
|
+
HttpErrorResponse,
|
|
864
|
+
parse_obj_as(
|
|
865
|
+
type_=HttpErrorResponse, # type: ignore
|
|
866
|
+
object_=_response.json(),
|
|
867
|
+
),
|
|
868
|
+
),
|
|
869
|
+
)
|
|
870
|
+
if _response.status_code == 422:
|
|
871
|
+
raise UnprocessableEntityError(
|
|
872
|
+
headers=dict(_response.headers),
|
|
873
|
+
body=typing.cast(
|
|
874
|
+
HttpValidationError,
|
|
875
|
+
parse_obj_as(
|
|
876
|
+
type_=HttpValidationError, # type: ignore
|
|
877
|
+
object_=_response.json(),
|
|
878
|
+
),
|
|
879
|
+
),
|
|
880
|
+
)
|
|
881
|
+
if _response.status_code == 429:
|
|
882
|
+
raise TooManyRequestsError(
|
|
883
|
+
headers=dict(_response.headers),
|
|
884
|
+
body=typing.cast(
|
|
885
|
+
HttpErrorResponse,
|
|
886
|
+
parse_obj_as(
|
|
887
|
+
type_=HttpErrorResponse, # type: ignore
|
|
888
|
+
object_=_response.json(),
|
|
889
|
+
),
|
|
890
|
+
),
|
|
891
|
+
)
|
|
892
|
+
if _response.status_code == 502:
|
|
893
|
+
raise BadGatewayError(
|
|
894
|
+
headers=dict(_response.headers),
|
|
895
|
+
body=typing.cast(
|
|
896
|
+
HttpErrorResponse,
|
|
897
|
+
parse_obj_as(
|
|
898
|
+
type_=HttpErrorResponse, # type: ignore
|
|
899
|
+
object_=_response.json(),
|
|
900
|
+
),
|
|
901
|
+
),
|
|
902
|
+
)
|
|
903
|
+
if _response.status_code == 504:
|
|
904
|
+
raise GatewayTimeoutError(
|
|
905
|
+
headers=dict(_response.headers),
|
|
906
|
+
body=typing.cast(
|
|
907
|
+
HttpErrorResponse,
|
|
908
|
+
parse_obj_as(
|
|
909
|
+
type_=HttpErrorResponse, # type: ignore
|
|
910
|
+
object_=_response.json(),
|
|
911
|
+
),
|
|
912
|
+
),
|
|
913
|
+
)
|
|
914
|
+
_response_json = _response.json()
|
|
915
|
+
except JSONDecodeError:
|
|
916
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
917
|
+
except ValidationError as e:
|
|
918
|
+
raise ParsingError(
|
|
919
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
920
|
+
)
|
|
921
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
922
|
+
|
|
923
|
+
def history(
|
|
924
|
+
self,
|
|
925
|
+
token_id: int,
|
|
926
|
+
*,
|
|
927
|
+
after: typing.Optional[str] = None,
|
|
928
|
+
limit: typing.Optional[int] = None,
|
|
929
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
930
|
+
) -> SyncPager[TokenEventOut, TokenEventPage]:
|
|
931
|
+
"""
|
|
932
|
+
Lifecycle changes of the token, newest first.
|
|
933
|
+
|
|
934
|
+
Parameters
|
|
935
|
+
----------
|
|
936
|
+
token_id : int
|
|
937
|
+
The token's ``id``.
|
|
938
|
+
|
|
939
|
+
after : typing.Optional[str]
|
|
940
|
+
Cursor: the previous page's ``pagination.end_cursor``. Omit it for the first page.
|
|
941
|
+
|
|
942
|
+
limit : typing.Optional[int]
|
|
943
|
+
Maximum rows per page (default 50, max 200).
|
|
944
|
+
|
|
945
|
+
request_options : typing.Optional[RequestOptions]
|
|
946
|
+
Request-specific configuration.
|
|
947
|
+
|
|
948
|
+
Returns
|
|
949
|
+
-------
|
|
950
|
+
SyncPager[TokenEventOut, TokenEventPage]
|
|
951
|
+
One page of lifecycle events, newest first.
|
|
952
|
+
"""
|
|
953
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
954
|
+
f"emsp/tokens/{encode_path_param(token_id)}/history",
|
|
955
|
+
method="GET",
|
|
956
|
+
params={
|
|
957
|
+
"after": after,
|
|
958
|
+
"limit": limit,
|
|
959
|
+
},
|
|
960
|
+
request_options=request_options,
|
|
961
|
+
)
|
|
962
|
+
try:
|
|
963
|
+
if 200 <= _response.status_code < 300:
|
|
964
|
+
_parsed_response = typing.cast(
|
|
965
|
+
TokenEventPage,
|
|
966
|
+
parse_obj_as(
|
|
967
|
+
type_=TokenEventPage, # type: ignore
|
|
968
|
+
object_=_response.json(),
|
|
969
|
+
),
|
|
970
|
+
)
|
|
971
|
+
_items = _parsed_response.data
|
|
972
|
+
_has_next = False
|
|
973
|
+
_get_next = None
|
|
974
|
+
if _parsed_response.pagination is not None:
|
|
975
|
+
_parsed_next = _parsed_response.pagination.end_cursor
|
|
976
|
+
_has_next = _parsed_next is not None and _parsed_next != ""
|
|
977
|
+
_get_next = lambda: self.history(
|
|
978
|
+
token_id,
|
|
979
|
+
after=_parsed_next,
|
|
980
|
+
limit=limit,
|
|
981
|
+
request_options=request_options,
|
|
982
|
+
)
|
|
983
|
+
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
|
|
984
|
+
if _response.status_code == 401:
|
|
985
|
+
raise UnauthorizedError(
|
|
986
|
+
headers=dict(_response.headers),
|
|
987
|
+
body=typing.cast(
|
|
988
|
+
HttpErrorResponse,
|
|
989
|
+
parse_obj_as(
|
|
990
|
+
type_=HttpErrorResponse, # type: ignore
|
|
991
|
+
object_=_response.json(),
|
|
992
|
+
),
|
|
993
|
+
),
|
|
994
|
+
)
|
|
995
|
+
if _response.status_code == 404:
|
|
996
|
+
raise NotFoundError(
|
|
997
|
+
headers=dict(_response.headers),
|
|
998
|
+
body=typing.cast(
|
|
999
|
+
HttpErrorResponse,
|
|
1000
|
+
parse_obj_as(
|
|
1001
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1002
|
+
object_=_response.json(),
|
|
1003
|
+
),
|
|
1004
|
+
),
|
|
1005
|
+
)
|
|
1006
|
+
if _response.status_code == 422:
|
|
1007
|
+
raise UnprocessableEntityError(
|
|
1008
|
+
headers=dict(_response.headers),
|
|
1009
|
+
body=typing.cast(
|
|
1010
|
+
HttpValidationError,
|
|
1011
|
+
parse_obj_as(
|
|
1012
|
+
type_=HttpValidationError, # type: ignore
|
|
1013
|
+
object_=_response.json(),
|
|
1014
|
+
),
|
|
1015
|
+
),
|
|
1016
|
+
)
|
|
1017
|
+
if _response.status_code == 429:
|
|
1018
|
+
raise TooManyRequestsError(
|
|
1019
|
+
headers=dict(_response.headers),
|
|
1020
|
+
body=typing.cast(
|
|
1021
|
+
HttpErrorResponse,
|
|
1022
|
+
parse_obj_as(
|
|
1023
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1024
|
+
object_=_response.json(),
|
|
1025
|
+
),
|
|
1026
|
+
),
|
|
1027
|
+
)
|
|
1028
|
+
if _response.status_code == 502:
|
|
1029
|
+
raise BadGatewayError(
|
|
1030
|
+
headers=dict(_response.headers),
|
|
1031
|
+
body=typing.cast(
|
|
1032
|
+
HttpErrorResponse,
|
|
1033
|
+
parse_obj_as(
|
|
1034
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1035
|
+
object_=_response.json(),
|
|
1036
|
+
),
|
|
1037
|
+
),
|
|
1038
|
+
)
|
|
1039
|
+
if _response.status_code == 504:
|
|
1040
|
+
raise GatewayTimeoutError(
|
|
1041
|
+
headers=dict(_response.headers),
|
|
1042
|
+
body=typing.cast(
|
|
1043
|
+
HttpErrorResponse,
|
|
1044
|
+
parse_obj_as(
|
|
1045
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1046
|
+
object_=_response.json(),
|
|
1047
|
+
),
|
|
1048
|
+
),
|
|
1049
|
+
)
|
|
1050
|
+
_response_json = _response.json()
|
|
1051
|
+
except JSONDecodeError:
|
|
1052
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1053
|
+
except ValidationError as e:
|
|
1054
|
+
raise ParsingError(
|
|
1055
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
1056
|
+
)
|
|
1057
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1058
|
+
|
|
1059
|
+
def reactivate(
|
|
1060
|
+
self, token_id: int, *, idempotency_key: str, request_options: typing.Optional[RequestOptions] = None
|
|
1061
|
+
) -> HttpResponse[TokenOut]:
|
|
1062
|
+
"""
|
|
1063
|
+
SUSPENDED → ACTIVE: pushed to partners with ``valid: true``. If the push to roaming partners fails the call answers 502 and the token is left as it was; retry with the same Idempotency-Key.
|
|
1064
|
+
|
|
1065
|
+
Parameters
|
|
1066
|
+
----------
|
|
1067
|
+
token_id : int
|
|
1068
|
+
The token's ``id``.
|
|
1069
|
+
|
|
1070
|
+
idempotency_key : str
|
|
1071
|
+
A unique key you choose for this call, e.g. a UUID. Retrying with the same key returns the first result instead of acting twice.
|
|
1072
|
+
|
|
1073
|
+
request_options : typing.Optional[RequestOptions]
|
|
1074
|
+
Request-specific configuration.
|
|
1075
|
+
|
|
1076
|
+
Returns
|
|
1077
|
+
-------
|
|
1078
|
+
HttpResponse[TokenOut]
|
|
1079
|
+
The token after the change.
|
|
1080
|
+
"""
|
|
1081
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1082
|
+
f"emsp/tokens/{encode_path_param(token_id)}/reactivate",
|
|
1083
|
+
method="POST",
|
|
1084
|
+
headers={
|
|
1085
|
+
"Idempotency-Key": str(idempotency_key) if idempotency_key is not None else None,
|
|
1086
|
+
},
|
|
1087
|
+
request_options=request_options,
|
|
1088
|
+
)
|
|
1089
|
+
try:
|
|
1090
|
+
if 200 <= _response.status_code < 300:
|
|
1091
|
+
_data = typing.cast(
|
|
1092
|
+
TokenOut,
|
|
1093
|
+
parse_obj_as(
|
|
1094
|
+
type_=TokenOut, # type: ignore
|
|
1095
|
+
object_=_response.json(),
|
|
1096
|
+
),
|
|
1097
|
+
)
|
|
1098
|
+
return HttpResponse(response=_response, data=_data)
|
|
1099
|
+
if _response.status_code == 400:
|
|
1100
|
+
raise BadRequestError(
|
|
1101
|
+
headers=dict(_response.headers),
|
|
1102
|
+
body=typing.cast(
|
|
1103
|
+
HttpErrorResponse,
|
|
1104
|
+
parse_obj_as(
|
|
1105
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1106
|
+
object_=_response.json(),
|
|
1107
|
+
),
|
|
1108
|
+
),
|
|
1109
|
+
)
|
|
1110
|
+
if _response.status_code == 401:
|
|
1111
|
+
raise UnauthorizedError(
|
|
1112
|
+
headers=dict(_response.headers),
|
|
1113
|
+
body=typing.cast(
|
|
1114
|
+
HttpErrorResponse,
|
|
1115
|
+
parse_obj_as(
|
|
1116
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1117
|
+
object_=_response.json(),
|
|
1118
|
+
),
|
|
1119
|
+
),
|
|
1120
|
+
)
|
|
1121
|
+
if _response.status_code == 404:
|
|
1122
|
+
raise NotFoundError(
|
|
1123
|
+
headers=dict(_response.headers),
|
|
1124
|
+
body=typing.cast(
|
|
1125
|
+
HttpErrorResponse,
|
|
1126
|
+
parse_obj_as(
|
|
1127
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1128
|
+
object_=_response.json(),
|
|
1129
|
+
),
|
|
1130
|
+
),
|
|
1131
|
+
)
|
|
1132
|
+
if _response.status_code == 409:
|
|
1133
|
+
raise ConflictError(
|
|
1134
|
+
headers=dict(_response.headers),
|
|
1135
|
+
body=typing.cast(
|
|
1136
|
+
HttpErrorResponse,
|
|
1137
|
+
parse_obj_as(
|
|
1138
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1139
|
+
object_=_response.json(),
|
|
1140
|
+
),
|
|
1141
|
+
),
|
|
1142
|
+
)
|
|
1143
|
+
if _response.status_code == 422:
|
|
1144
|
+
raise UnprocessableEntityError(
|
|
1145
|
+
headers=dict(_response.headers),
|
|
1146
|
+
body=typing.cast(
|
|
1147
|
+
HttpValidationError,
|
|
1148
|
+
parse_obj_as(
|
|
1149
|
+
type_=HttpValidationError, # type: ignore
|
|
1150
|
+
object_=_response.json(),
|
|
1151
|
+
),
|
|
1152
|
+
),
|
|
1153
|
+
)
|
|
1154
|
+
if _response.status_code == 429:
|
|
1155
|
+
raise TooManyRequestsError(
|
|
1156
|
+
headers=dict(_response.headers),
|
|
1157
|
+
body=typing.cast(
|
|
1158
|
+
HttpErrorResponse,
|
|
1159
|
+
parse_obj_as(
|
|
1160
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1161
|
+
object_=_response.json(),
|
|
1162
|
+
),
|
|
1163
|
+
),
|
|
1164
|
+
)
|
|
1165
|
+
if _response.status_code == 502:
|
|
1166
|
+
raise BadGatewayError(
|
|
1167
|
+
headers=dict(_response.headers),
|
|
1168
|
+
body=typing.cast(
|
|
1169
|
+
HttpErrorResponse,
|
|
1170
|
+
parse_obj_as(
|
|
1171
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1172
|
+
object_=_response.json(),
|
|
1173
|
+
),
|
|
1174
|
+
),
|
|
1175
|
+
)
|
|
1176
|
+
if _response.status_code == 504:
|
|
1177
|
+
raise GatewayTimeoutError(
|
|
1178
|
+
headers=dict(_response.headers),
|
|
1179
|
+
body=typing.cast(
|
|
1180
|
+
HttpErrorResponse,
|
|
1181
|
+
parse_obj_as(
|
|
1182
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1183
|
+
object_=_response.json(),
|
|
1184
|
+
),
|
|
1185
|
+
),
|
|
1186
|
+
)
|
|
1187
|
+
_response_json = _response.json()
|
|
1188
|
+
except JSONDecodeError:
|
|
1189
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1190
|
+
except ValidationError as e:
|
|
1191
|
+
raise ParsingError(
|
|
1192
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
1193
|
+
)
|
|
1194
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1195
|
+
|
|
1196
|
+
def revoke(
|
|
1197
|
+
self,
|
|
1198
|
+
token_id: int,
|
|
1199
|
+
*,
|
|
1200
|
+
idempotency_key: str,
|
|
1201
|
+
request: typing.Optional[TokenReason] = None,
|
|
1202
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1203
|
+
) -> HttpResponse[TokenOut]:
|
|
1204
|
+
"""
|
|
1205
|
+
Final: any status except REVOKED. A token partners already have is pushed with ``valid: false`` first. If the push to roaming partners fails the call answers 502 and the token is left as it was; retry with the same Idempotency-Key.
|
|
1206
|
+
|
|
1207
|
+
Parameters
|
|
1208
|
+
----------
|
|
1209
|
+
token_id : int
|
|
1210
|
+
The token's ``id``.
|
|
1211
|
+
|
|
1212
|
+
idempotency_key : str
|
|
1213
|
+
A unique key you choose for this call, e.g. a UUID. Retrying with the same key returns the first result instead of acting twice.
|
|
1214
|
+
|
|
1215
|
+
request : typing.Optional[TokenReason]
|
|
1216
|
+
|
|
1217
|
+
request_options : typing.Optional[RequestOptions]
|
|
1218
|
+
Request-specific configuration.
|
|
1219
|
+
|
|
1220
|
+
Returns
|
|
1221
|
+
-------
|
|
1222
|
+
HttpResponse[TokenOut]
|
|
1223
|
+
The token after the change.
|
|
1224
|
+
"""
|
|
1225
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1226
|
+
f"emsp/tokens/{encode_path_param(token_id)}/revoke",
|
|
1227
|
+
method="POST",
|
|
1228
|
+
json=convert_and_respect_annotation_metadata(
|
|
1229
|
+
object_=request, annotation=typing.Optional[TokenReason], direction="write"
|
|
1230
|
+
),
|
|
1231
|
+
headers={
|
|
1232
|
+
"content-type": "application/json",
|
|
1233
|
+
"Idempotency-Key": str(idempotency_key) if idempotency_key is not None else None,
|
|
1234
|
+
},
|
|
1235
|
+
request_options=request_options,
|
|
1236
|
+
omit=OMIT,
|
|
1237
|
+
)
|
|
1238
|
+
try:
|
|
1239
|
+
if 200 <= _response.status_code < 300:
|
|
1240
|
+
_data = typing.cast(
|
|
1241
|
+
TokenOut,
|
|
1242
|
+
parse_obj_as(
|
|
1243
|
+
type_=TokenOut, # type: ignore
|
|
1244
|
+
object_=_response.json(),
|
|
1245
|
+
),
|
|
1246
|
+
)
|
|
1247
|
+
return HttpResponse(response=_response, data=_data)
|
|
1248
|
+
if _response.status_code == 400:
|
|
1249
|
+
raise BadRequestError(
|
|
1250
|
+
headers=dict(_response.headers),
|
|
1251
|
+
body=typing.cast(
|
|
1252
|
+
HttpErrorResponse,
|
|
1253
|
+
parse_obj_as(
|
|
1254
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1255
|
+
object_=_response.json(),
|
|
1256
|
+
),
|
|
1257
|
+
),
|
|
1258
|
+
)
|
|
1259
|
+
if _response.status_code == 401:
|
|
1260
|
+
raise UnauthorizedError(
|
|
1261
|
+
headers=dict(_response.headers),
|
|
1262
|
+
body=typing.cast(
|
|
1263
|
+
HttpErrorResponse,
|
|
1264
|
+
parse_obj_as(
|
|
1265
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1266
|
+
object_=_response.json(),
|
|
1267
|
+
),
|
|
1268
|
+
),
|
|
1269
|
+
)
|
|
1270
|
+
if _response.status_code == 404:
|
|
1271
|
+
raise NotFoundError(
|
|
1272
|
+
headers=dict(_response.headers),
|
|
1273
|
+
body=typing.cast(
|
|
1274
|
+
HttpErrorResponse,
|
|
1275
|
+
parse_obj_as(
|
|
1276
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1277
|
+
object_=_response.json(),
|
|
1278
|
+
),
|
|
1279
|
+
),
|
|
1280
|
+
)
|
|
1281
|
+
if _response.status_code == 409:
|
|
1282
|
+
raise ConflictError(
|
|
1283
|
+
headers=dict(_response.headers),
|
|
1284
|
+
body=typing.cast(
|
|
1285
|
+
HttpErrorResponse,
|
|
1286
|
+
parse_obj_as(
|
|
1287
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1288
|
+
object_=_response.json(),
|
|
1289
|
+
),
|
|
1290
|
+
),
|
|
1291
|
+
)
|
|
1292
|
+
if _response.status_code == 422:
|
|
1293
|
+
raise UnprocessableEntityError(
|
|
1294
|
+
headers=dict(_response.headers),
|
|
1295
|
+
body=typing.cast(
|
|
1296
|
+
HttpValidationError,
|
|
1297
|
+
parse_obj_as(
|
|
1298
|
+
type_=HttpValidationError, # type: ignore
|
|
1299
|
+
object_=_response.json(),
|
|
1300
|
+
),
|
|
1301
|
+
),
|
|
1302
|
+
)
|
|
1303
|
+
if _response.status_code == 429:
|
|
1304
|
+
raise TooManyRequestsError(
|
|
1305
|
+
headers=dict(_response.headers),
|
|
1306
|
+
body=typing.cast(
|
|
1307
|
+
HttpErrorResponse,
|
|
1308
|
+
parse_obj_as(
|
|
1309
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1310
|
+
object_=_response.json(),
|
|
1311
|
+
),
|
|
1312
|
+
),
|
|
1313
|
+
)
|
|
1314
|
+
if _response.status_code == 502:
|
|
1315
|
+
raise BadGatewayError(
|
|
1316
|
+
headers=dict(_response.headers),
|
|
1317
|
+
body=typing.cast(
|
|
1318
|
+
HttpErrorResponse,
|
|
1319
|
+
parse_obj_as(
|
|
1320
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1321
|
+
object_=_response.json(),
|
|
1322
|
+
),
|
|
1323
|
+
),
|
|
1324
|
+
)
|
|
1325
|
+
if _response.status_code == 504:
|
|
1326
|
+
raise GatewayTimeoutError(
|
|
1327
|
+
headers=dict(_response.headers),
|
|
1328
|
+
body=typing.cast(
|
|
1329
|
+
HttpErrorResponse,
|
|
1330
|
+
parse_obj_as(
|
|
1331
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1332
|
+
object_=_response.json(),
|
|
1333
|
+
),
|
|
1334
|
+
),
|
|
1335
|
+
)
|
|
1336
|
+
_response_json = _response.json()
|
|
1337
|
+
except JSONDecodeError:
|
|
1338
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1339
|
+
except ValidationError as e:
|
|
1340
|
+
raise ParsingError(
|
|
1341
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
1342
|
+
)
|
|
1343
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1344
|
+
|
|
1345
|
+
def suspend(
|
|
1346
|
+
self,
|
|
1347
|
+
token_id: int,
|
|
1348
|
+
*,
|
|
1349
|
+
idempotency_key: str,
|
|
1350
|
+
request: typing.Optional[TokenReason] = None,
|
|
1351
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1352
|
+
) -> HttpResponse[TokenOut]:
|
|
1353
|
+
"""
|
|
1354
|
+
ACTIVE → SUSPENDED: pushed to partners with ``valid: false``. If the push to roaming partners fails the call answers 502 and the token is left as it was; retry with the same Idempotency-Key.
|
|
1355
|
+
|
|
1356
|
+
Parameters
|
|
1357
|
+
----------
|
|
1358
|
+
token_id : int
|
|
1359
|
+
The token's ``id``.
|
|
1360
|
+
|
|
1361
|
+
idempotency_key : str
|
|
1362
|
+
A unique key you choose for this call, e.g. a UUID. Retrying with the same key returns the first result instead of acting twice.
|
|
1363
|
+
|
|
1364
|
+
request : typing.Optional[TokenReason]
|
|
1365
|
+
|
|
1366
|
+
request_options : typing.Optional[RequestOptions]
|
|
1367
|
+
Request-specific configuration.
|
|
1368
|
+
|
|
1369
|
+
Returns
|
|
1370
|
+
-------
|
|
1371
|
+
HttpResponse[TokenOut]
|
|
1372
|
+
The token after the change.
|
|
1373
|
+
"""
|
|
1374
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1375
|
+
f"emsp/tokens/{encode_path_param(token_id)}/suspend",
|
|
1376
|
+
method="POST",
|
|
1377
|
+
json=convert_and_respect_annotation_metadata(
|
|
1378
|
+
object_=request, annotation=typing.Optional[TokenReason], direction="write"
|
|
1379
|
+
),
|
|
1380
|
+
headers={
|
|
1381
|
+
"content-type": "application/json",
|
|
1382
|
+
"Idempotency-Key": str(idempotency_key) if idempotency_key is not None else None,
|
|
1383
|
+
},
|
|
1384
|
+
request_options=request_options,
|
|
1385
|
+
omit=OMIT,
|
|
1386
|
+
)
|
|
1387
|
+
try:
|
|
1388
|
+
if 200 <= _response.status_code < 300:
|
|
1389
|
+
_data = typing.cast(
|
|
1390
|
+
TokenOut,
|
|
1391
|
+
parse_obj_as(
|
|
1392
|
+
type_=TokenOut, # type: ignore
|
|
1393
|
+
object_=_response.json(),
|
|
1394
|
+
),
|
|
1395
|
+
)
|
|
1396
|
+
return HttpResponse(response=_response, data=_data)
|
|
1397
|
+
if _response.status_code == 400:
|
|
1398
|
+
raise BadRequestError(
|
|
1399
|
+
headers=dict(_response.headers),
|
|
1400
|
+
body=typing.cast(
|
|
1401
|
+
HttpErrorResponse,
|
|
1402
|
+
parse_obj_as(
|
|
1403
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1404
|
+
object_=_response.json(),
|
|
1405
|
+
),
|
|
1406
|
+
),
|
|
1407
|
+
)
|
|
1408
|
+
if _response.status_code == 401:
|
|
1409
|
+
raise UnauthorizedError(
|
|
1410
|
+
headers=dict(_response.headers),
|
|
1411
|
+
body=typing.cast(
|
|
1412
|
+
HttpErrorResponse,
|
|
1413
|
+
parse_obj_as(
|
|
1414
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1415
|
+
object_=_response.json(),
|
|
1416
|
+
),
|
|
1417
|
+
),
|
|
1418
|
+
)
|
|
1419
|
+
if _response.status_code == 404:
|
|
1420
|
+
raise NotFoundError(
|
|
1421
|
+
headers=dict(_response.headers),
|
|
1422
|
+
body=typing.cast(
|
|
1423
|
+
HttpErrorResponse,
|
|
1424
|
+
parse_obj_as(
|
|
1425
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1426
|
+
object_=_response.json(),
|
|
1427
|
+
),
|
|
1428
|
+
),
|
|
1429
|
+
)
|
|
1430
|
+
if _response.status_code == 409:
|
|
1431
|
+
raise ConflictError(
|
|
1432
|
+
headers=dict(_response.headers),
|
|
1433
|
+
body=typing.cast(
|
|
1434
|
+
HttpErrorResponse,
|
|
1435
|
+
parse_obj_as(
|
|
1436
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1437
|
+
object_=_response.json(),
|
|
1438
|
+
),
|
|
1439
|
+
),
|
|
1440
|
+
)
|
|
1441
|
+
if _response.status_code == 422:
|
|
1442
|
+
raise UnprocessableEntityError(
|
|
1443
|
+
headers=dict(_response.headers),
|
|
1444
|
+
body=typing.cast(
|
|
1445
|
+
HttpValidationError,
|
|
1446
|
+
parse_obj_as(
|
|
1447
|
+
type_=HttpValidationError, # type: ignore
|
|
1448
|
+
object_=_response.json(),
|
|
1449
|
+
),
|
|
1450
|
+
),
|
|
1451
|
+
)
|
|
1452
|
+
if _response.status_code == 429:
|
|
1453
|
+
raise TooManyRequestsError(
|
|
1454
|
+
headers=dict(_response.headers),
|
|
1455
|
+
body=typing.cast(
|
|
1456
|
+
HttpErrorResponse,
|
|
1457
|
+
parse_obj_as(
|
|
1458
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1459
|
+
object_=_response.json(),
|
|
1460
|
+
),
|
|
1461
|
+
),
|
|
1462
|
+
)
|
|
1463
|
+
if _response.status_code == 502:
|
|
1464
|
+
raise BadGatewayError(
|
|
1465
|
+
headers=dict(_response.headers),
|
|
1466
|
+
body=typing.cast(
|
|
1467
|
+
HttpErrorResponse,
|
|
1468
|
+
parse_obj_as(
|
|
1469
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1470
|
+
object_=_response.json(),
|
|
1471
|
+
),
|
|
1472
|
+
),
|
|
1473
|
+
)
|
|
1474
|
+
if _response.status_code == 504:
|
|
1475
|
+
raise GatewayTimeoutError(
|
|
1476
|
+
headers=dict(_response.headers),
|
|
1477
|
+
body=typing.cast(
|
|
1478
|
+
HttpErrorResponse,
|
|
1479
|
+
parse_obj_as(
|
|
1480
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1481
|
+
object_=_response.json(),
|
|
1482
|
+
),
|
|
1483
|
+
),
|
|
1484
|
+
)
|
|
1485
|
+
_response_json = _response.json()
|
|
1486
|
+
except JSONDecodeError:
|
|
1487
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1488
|
+
except ValidationError as e:
|
|
1489
|
+
raise ParsingError(
|
|
1490
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
1491
|
+
)
|
|
1492
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1493
|
+
|
|
1494
|
+
|
|
1495
|
+
class AsyncRawTokensClient:
|
|
1496
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
1497
|
+
self._client_wrapper = client_wrapper
|
|
1498
|
+
|
|
1499
|
+
async def list(
|
|
1500
|
+
self,
|
|
1501
|
+
*,
|
|
1502
|
+
status: typing.Optional[ListTokensRequestStatus] = None,
|
|
1503
|
+
type: typing.Optional[ListTokensRequestType] = None,
|
|
1504
|
+
search: typing.Optional[str] = None,
|
|
1505
|
+
after: typing.Optional[str] = None,
|
|
1506
|
+
limit: typing.Optional[int] = None,
|
|
1507
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1508
|
+
) -> AsyncPager[TokenOut, TokenPage]:
|
|
1509
|
+
"""
|
|
1510
|
+
Tokens you issued, filtered by status, type or text in uid, contract id or printed number.
|
|
1511
|
+
|
|
1512
|
+
Parameters
|
|
1513
|
+
----------
|
|
1514
|
+
status : typing.Optional[ListTokensRequestStatus]
|
|
1515
|
+
Only this status. EXPIRED means ``valid_until`` has passed and the token is not revoked.
|
|
1516
|
+
|
|
1517
|
+
type : typing.Optional[ListTokensRequestType]
|
|
1518
|
+
Only this OCPI token type.
|
|
1519
|
+
|
|
1520
|
+
search : typing.Optional[str]
|
|
1521
|
+
Text in uid, contract id or printed number.
|
|
1522
|
+
|
|
1523
|
+
after : typing.Optional[str]
|
|
1524
|
+
Cursor: the previous page's ``pagination.end_cursor``. Omit it for the first page.
|
|
1525
|
+
|
|
1526
|
+
limit : typing.Optional[int]
|
|
1527
|
+
Maximum rows per page (default 50, max 200).
|
|
1528
|
+
|
|
1529
|
+
request_options : typing.Optional[RequestOptions]
|
|
1530
|
+
Request-specific configuration.
|
|
1531
|
+
|
|
1532
|
+
Returns
|
|
1533
|
+
-------
|
|
1534
|
+
AsyncPager[TokenOut, TokenPage]
|
|
1535
|
+
One page of tokens.
|
|
1536
|
+
"""
|
|
1537
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1538
|
+
"emsp/tokens",
|
|
1539
|
+
method="GET",
|
|
1540
|
+
params={
|
|
1541
|
+
"status": status,
|
|
1542
|
+
"type": type,
|
|
1543
|
+
"search": search,
|
|
1544
|
+
"after": after,
|
|
1545
|
+
"limit": limit,
|
|
1546
|
+
},
|
|
1547
|
+
request_options=request_options,
|
|
1548
|
+
)
|
|
1549
|
+
try:
|
|
1550
|
+
if 200 <= _response.status_code < 300:
|
|
1551
|
+
_parsed_response = typing.cast(
|
|
1552
|
+
TokenPage,
|
|
1553
|
+
parse_obj_as(
|
|
1554
|
+
type_=TokenPage, # type: ignore
|
|
1555
|
+
object_=_response.json(),
|
|
1556
|
+
),
|
|
1557
|
+
)
|
|
1558
|
+
_items = _parsed_response.data
|
|
1559
|
+
_has_next = False
|
|
1560
|
+
_get_next = None
|
|
1561
|
+
if _parsed_response.pagination is not None:
|
|
1562
|
+
_parsed_next = _parsed_response.pagination.end_cursor
|
|
1563
|
+
_has_next = _parsed_next is not None and _parsed_next != ""
|
|
1564
|
+
|
|
1565
|
+
async def _get_next():
|
|
1566
|
+
return await self.list(
|
|
1567
|
+
status=status,
|
|
1568
|
+
type=type,
|
|
1569
|
+
search=search,
|
|
1570
|
+
after=_parsed_next,
|
|
1571
|
+
limit=limit,
|
|
1572
|
+
request_options=request_options,
|
|
1573
|
+
)
|
|
1574
|
+
|
|
1575
|
+
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
|
|
1576
|
+
if _response.status_code == 401:
|
|
1577
|
+
raise UnauthorizedError(
|
|
1578
|
+
headers=dict(_response.headers),
|
|
1579
|
+
body=typing.cast(
|
|
1580
|
+
HttpErrorResponse,
|
|
1581
|
+
parse_obj_as(
|
|
1582
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1583
|
+
object_=_response.json(),
|
|
1584
|
+
),
|
|
1585
|
+
),
|
|
1586
|
+
)
|
|
1587
|
+
if _response.status_code == 422:
|
|
1588
|
+
raise UnprocessableEntityError(
|
|
1589
|
+
headers=dict(_response.headers),
|
|
1590
|
+
body=typing.cast(
|
|
1591
|
+
HttpValidationError,
|
|
1592
|
+
parse_obj_as(
|
|
1593
|
+
type_=HttpValidationError, # type: ignore
|
|
1594
|
+
object_=_response.json(),
|
|
1595
|
+
),
|
|
1596
|
+
),
|
|
1597
|
+
)
|
|
1598
|
+
if _response.status_code == 429:
|
|
1599
|
+
raise TooManyRequestsError(
|
|
1600
|
+
headers=dict(_response.headers),
|
|
1601
|
+
body=typing.cast(
|
|
1602
|
+
HttpErrorResponse,
|
|
1603
|
+
parse_obj_as(
|
|
1604
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1605
|
+
object_=_response.json(),
|
|
1606
|
+
),
|
|
1607
|
+
),
|
|
1608
|
+
)
|
|
1609
|
+
if _response.status_code == 502:
|
|
1610
|
+
raise BadGatewayError(
|
|
1611
|
+
headers=dict(_response.headers),
|
|
1612
|
+
body=typing.cast(
|
|
1613
|
+
HttpErrorResponse,
|
|
1614
|
+
parse_obj_as(
|
|
1615
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1616
|
+
object_=_response.json(),
|
|
1617
|
+
),
|
|
1618
|
+
),
|
|
1619
|
+
)
|
|
1620
|
+
if _response.status_code == 504:
|
|
1621
|
+
raise GatewayTimeoutError(
|
|
1622
|
+
headers=dict(_response.headers),
|
|
1623
|
+
body=typing.cast(
|
|
1624
|
+
HttpErrorResponse,
|
|
1625
|
+
parse_obj_as(
|
|
1626
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1627
|
+
object_=_response.json(),
|
|
1628
|
+
),
|
|
1629
|
+
),
|
|
1630
|
+
)
|
|
1631
|
+
_response_json = _response.json()
|
|
1632
|
+
except JSONDecodeError:
|
|
1633
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1634
|
+
except ValidationError as e:
|
|
1635
|
+
raise ParsingError(
|
|
1636
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
1637
|
+
)
|
|
1638
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1639
|
+
|
|
1640
|
+
async def provision(
|
|
1641
|
+
self,
|
|
1642
|
+
*,
|
|
1643
|
+
idempotency_key: str,
|
|
1644
|
+
uid: str,
|
|
1645
|
+
type: TokenCreateType,
|
|
1646
|
+
contract_id: str,
|
|
1647
|
+
issuer: str,
|
|
1648
|
+
visual_number: typing.Optional[str] = OMIT,
|
|
1649
|
+
group_id: typing.Optional[str] = OMIT,
|
|
1650
|
+
whitelist: typing.Optional[TokenCreateWhitelist] = OMIT,
|
|
1651
|
+
language: typing.Optional[str] = OMIT,
|
|
1652
|
+
valid_from: typing.Optional[dt.datetime] = OMIT,
|
|
1653
|
+
valid_until: typing.Optional[dt.datetime] = OMIT,
|
|
1654
|
+
country_code: typing.Optional[str] = OMIT,
|
|
1655
|
+
party_id: typing.Optional[str] = OMIT,
|
|
1656
|
+
ocpi_version: typing.Optional[TokenCreateOcpiVersion] = OMIT,
|
|
1657
|
+
metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
1658
|
+
is_roaming: typing.Optional[bool] = OMIT,
|
|
1659
|
+
default_profile_type: typing.Optional[TokenCreateDefaultProfileType] = OMIT,
|
|
1660
|
+
energy_contract: typing.Optional[EnergyContract] = OMIT,
|
|
1661
|
+
auto_activate: typing.Optional[bool] = OMIT,
|
|
1662
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1663
|
+
) -> AsyncHttpResponse[TokenOut]:
|
|
1664
|
+
"""
|
|
1665
|
+
Creates the token as PROVISIONED; with ``auto_activate`` it is pushed to roaming partners and stored ACTIVE. If the push to roaming partners fails the call answers 502 and the token is left as it was; retry with the same Idempotency-Key.
|
|
1666
|
+
|
|
1667
|
+
Parameters
|
|
1668
|
+
----------
|
|
1669
|
+
idempotency_key : str
|
|
1670
|
+
A unique key you choose for this call, e.g. a UUID. Retrying with the same key returns the first result instead of acting twice.
|
|
1671
|
+
|
|
1672
|
+
uid : str
|
|
1673
|
+
|
|
1674
|
+
type : TokenCreateType
|
|
1675
|
+
|
|
1676
|
+
contract_id : str
|
|
1677
|
+
|
|
1678
|
+
issuer : str
|
|
1679
|
+
|
|
1680
|
+
visual_number : typing.Optional[str]
|
|
1681
|
+
|
|
1682
|
+
group_id : typing.Optional[str]
|
|
1683
|
+
|
|
1684
|
+
whitelist : typing.Optional[TokenCreateWhitelist]
|
|
1685
|
+
|
|
1686
|
+
language : typing.Optional[str]
|
|
1687
|
+
|
|
1688
|
+
valid_from : typing.Optional[dt.datetime]
|
|
1689
|
+
|
|
1690
|
+
valid_until : typing.Optional[dt.datetime]
|
|
1691
|
+
|
|
1692
|
+
country_code : typing.Optional[str]
|
|
1693
|
+
|
|
1694
|
+
party_id : typing.Optional[str]
|
|
1695
|
+
|
|
1696
|
+
ocpi_version : typing.Optional[TokenCreateOcpiVersion]
|
|
1697
|
+
|
|
1698
|
+
metadata : typing.Optional[typing.Dict[str, typing.Any]]
|
|
1699
|
+
|
|
1700
|
+
is_roaming : typing.Optional[bool]
|
|
1701
|
+
|
|
1702
|
+
default_profile_type : typing.Optional[TokenCreateDefaultProfileType]
|
|
1703
|
+
|
|
1704
|
+
energy_contract : typing.Optional[EnergyContract]
|
|
1705
|
+
|
|
1706
|
+
auto_activate : typing.Optional[bool]
|
|
1707
|
+
|
|
1708
|
+
request_options : typing.Optional[RequestOptions]
|
|
1709
|
+
Request-specific configuration.
|
|
1710
|
+
|
|
1711
|
+
Returns
|
|
1712
|
+
-------
|
|
1713
|
+
AsyncHttpResponse[TokenOut]
|
|
1714
|
+
The token; ACTIVE when ``auto_activate`` was set, else PROVISIONED.
|
|
1715
|
+
"""
|
|
1716
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1717
|
+
"emsp/tokens",
|
|
1718
|
+
method="POST",
|
|
1719
|
+
json={
|
|
1720
|
+
"uid": uid,
|
|
1721
|
+
"type": type,
|
|
1722
|
+
"contract_id": contract_id,
|
|
1723
|
+
"issuer": issuer,
|
|
1724
|
+
"visual_number": visual_number,
|
|
1725
|
+
"group_id": group_id,
|
|
1726
|
+
"whitelist": whitelist,
|
|
1727
|
+
"language": language,
|
|
1728
|
+
"valid_from": valid_from,
|
|
1729
|
+
"valid_until": valid_until,
|
|
1730
|
+
"country_code": country_code,
|
|
1731
|
+
"party_id": party_id,
|
|
1732
|
+
"ocpi_version": ocpi_version,
|
|
1733
|
+
"metadata": metadata,
|
|
1734
|
+
"is_roaming": is_roaming,
|
|
1735
|
+
"default_profile_type": default_profile_type,
|
|
1736
|
+
"energy_contract": convert_and_respect_annotation_metadata(
|
|
1737
|
+
object_=energy_contract, annotation=typing.Optional[EnergyContract], direction="write"
|
|
1738
|
+
),
|
|
1739
|
+
"auto_activate": auto_activate,
|
|
1740
|
+
},
|
|
1741
|
+
headers={
|
|
1742
|
+
"content-type": "application/json",
|
|
1743
|
+
"Idempotency-Key": str(idempotency_key) if idempotency_key is not None else None,
|
|
1744
|
+
},
|
|
1745
|
+
request_options=request_options,
|
|
1746
|
+
omit=OMIT,
|
|
1747
|
+
)
|
|
1748
|
+
try:
|
|
1749
|
+
if 200 <= _response.status_code < 300:
|
|
1750
|
+
_data = typing.cast(
|
|
1751
|
+
TokenOut,
|
|
1752
|
+
parse_obj_as(
|
|
1753
|
+
type_=TokenOut, # type: ignore
|
|
1754
|
+
object_=_response.json(),
|
|
1755
|
+
),
|
|
1756
|
+
)
|
|
1757
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1758
|
+
if _response.status_code == 400:
|
|
1759
|
+
raise BadRequestError(
|
|
1760
|
+
headers=dict(_response.headers),
|
|
1761
|
+
body=typing.cast(
|
|
1762
|
+
HttpErrorResponse,
|
|
1763
|
+
parse_obj_as(
|
|
1764
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1765
|
+
object_=_response.json(),
|
|
1766
|
+
),
|
|
1767
|
+
),
|
|
1768
|
+
)
|
|
1769
|
+
if _response.status_code == 401:
|
|
1770
|
+
raise UnauthorizedError(
|
|
1771
|
+
headers=dict(_response.headers),
|
|
1772
|
+
body=typing.cast(
|
|
1773
|
+
HttpErrorResponse,
|
|
1774
|
+
parse_obj_as(
|
|
1775
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1776
|
+
object_=_response.json(),
|
|
1777
|
+
),
|
|
1778
|
+
),
|
|
1779
|
+
)
|
|
1780
|
+
if _response.status_code == 409:
|
|
1781
|
+
raise ConflictError(
|
|
1782
|
+
headers=dict(_response.headers),
|
|
1783
|
+
body=typing.cast(
|
|
1784
|
+
HttpErrorResponse,
|
|
1785
|
+
parse_obj_as(
|
|
1786
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1787
|
+
object_=_response.json(),
|
|
1788
|
+
),
|
|
1789
|
+
),
|
|
1790
|
+
)
|
|
1791
|
+
if _response.status_code == 422:
|
|
1792
|
+
raise UnprocessableEntityError(
|
|
1793
|
+
headers=dict(_response.headers),
|
|
1794
|
+
body=typing.cast(
|
|
1795
|
+
HttpValidationError,
|
|
1796
|
+
parse_obj_as(
|
|
1797
|
+
type_=HttpValidationError, # type: ignore
|
|
1798
|
+
object_=_response.json(),
|
|
1799
|
+
),
|
|
1800
|
+
),
|
|
1801
|
+
)
|
|
1802
|
+
if _response.status_code == 429:
|
|
1803
|
+
raise TooManyRequestsError(
|
|
1804
|
+
headers=dict(_response.headers),
|
|
1805
|
+
body=typing.cast(
|
|
1806
|
+
HttpErrorResponse,
|
|
1807
|
+
parse_obj_as(
|
|
1808
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1809
|
+
object_=_response.json(),
|
|
1810
|
+
),
|
|
1811
|
+
),
|
|
1812
|
+
)
|
|
1813
|
+
if _response.status_code == 502:
|
|
1814
|
+
raise BadGatewayError(
|
|
1815
|
+
headers=dict(_response.headers),
|
|
1816
|
+
body=typing.cast(
|
|
1817
|
+
HttpErrorResponse,
|
|
1818
|
+
parse_obj_as(
|
|
1819
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1820
|
+
object_=_response.json(),
|
|
1821
|
+
),
|
|
1822
|
+
),
|
|
1823
|
+
)
|
|
1824
|
+
if _response.status_code == 504:
|
|
1825
|
+
raise GatewayTimeoutError(
|
|
1826
|
+
headers=dict(_response.headers),
|
|
1827
|
+
body=typing.cast(
|
|
1828
|
+
HttpErrorResponse,
|
|
1829
|
+
parse_obj_as(
|
|
1830
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1831
|
+
object_=_response.json(),
|
|
1832
|
+
),
|
|
1833
|
+
),
|
|
1834
|
+
)
|
|
1835
|
+
_response_json = _response.json()
|
|
1836
|
+
except JSONDecodeError:
|
|
1837
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1838
|
+
except ValidationError as e:
|
|
1839
|
+
raise ParsingError(
|
|
1840
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
1841
|
+
)
|
|
1842
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1843
|
+
|
|
1844
|
+
async def bulk_provision(
|
|
1845
|
+
self,
|
|
1846
|
+
*,
|
|
1847
|
+
idempotency_key: str,
|
|
1848
|
+
tokens: typing.Sequence[TokenCreate],
|
|
1849
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1850
|
+
) -> AsyncHttpResponse[TokenBulkOut]:
|
|
1851
|
+
"""
|
|
1852
|
+
The batch is validated and created as a whole. With ``auto_activate`` each token is pushed in turn; a failed push is listed and that token stays PROVISIONED.
|
|
1853
|
+
|
|
1854
|
+
Parameters
|
|
1855
|
+
----------
|
|
1856
|
+
idempotency_key : str
|
|
1857
|
+
A unique key you choose for this call, e.g. a UUID. Retrying with the same key returns the first result instead of acting twice.
|
|
1858
|
+
|
|
1859
|
+
tokens : typing.Sequence[TokenCreate]
|
|
1860
|
+
|
|
1861
|
+
request_options : typing.Optional[RequestOptions]
|
|
1862
|
+
Request-specific configuration.
|
|
1863
|
+
|
|
1864
|
+
Returns
|
|
1865
|
+
-------
|
|
1866
|
+
AsyncHttpResponse[TokenBulkOut]
|
|
1867
|
+
How many tokens were provisioned and activated, and which pushes failed.
|
|
1868
|
+
"""
|
|
1869
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1870
|
+
"emsp/tokens/bulk",
|
|
1871
|
+
method="POST",
|
|
1872
|
+
json={
|
|
1873
|
+
"tokens": convert_and_respect_annotation_metadata(
|
|
1874
|
+
object_=tokens, annotation=typing.Sequence[TokenCreate], direction="write"
|
|
1875
|
+
),
|
|
1876
|
+
},
|
|
1877
|
+
headers={
|
|
1878
|
+
"content-type": "application/json",
|
|
1879
|
+
"Idempotency-Key": str(idempotency_key) if idempotency_key is not None else None,
|
|
1880
|
+
},
|
|
1881
|
+
request_options=request_options,
|
|
1882
|
+
omit=OMIT,
|
|
1883
|
+
)
|
|
1884
|
+
try:
|
|
1885
|
+
if 200 <= _response.status_code < 300:
|
|
1886
|
+
_data = typing.cast(
|
|
1887
|
+
TokenBulkOut,
|
|
1888
|
+
parse_obj_as(
|
|
1889
|
+
type_=TokenBulkOut, # type: ignore
|
|
1890
|
+
object_=_response.json(),
|
|
1891
|
+
),
|
|
1892
|
+
)
|
|
1893
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1894
|
+
if _response.status_code == 401:
|
|
1895
|
+
raise UnauthorizedError(
|
|
1896
|
+
headers=dict(_response.headers),
|
|
1897
|
+
body=typing.cast(
|
|
1898
|
+
HttpErrorResponse,
|
|
1899
|
+
parse_obj_as(
|
|
1900
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1901
|
+
object_=_response.json(),
|
|
1902
|
+
),
|
|
1903
|
+
),
|
|
1904
|
+
)
|
|
1905
|
+
if _response.status_code == 409:
|
|
1906
|
+
raise ConflictError(
|
|
1907
|
+
headers=dict(_response.headers),
|
|
1908
|
+
body=typing.cast(
|
|
1909
|
+
HttpErrorResponse,
|
|
1910
|
+
parse_obj_as(
|
|
1911
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1912
|
+
object_=_response.json(),
|
|
1913
|
+
),
|
|
1914
|
+
),
|
|
1915
|
+
)
|
|
1916
|
+
if _response.status_code == 422:
|
|
1917
|
+
raise UnprocessableEntityError(
|
|
1918
|
+
headers=dict(_response.headers),
|
|
1919
|
+
body=typing.cast(
|
|
1920
|
+
HttpValidationError,
|
|
1921
|
+
parse_obj_as(
|
|
1922
|
+
type_=HttpValidationError, # type: ignore
|
|
1923
|
+
object_=_response.json(),
|
|
1924
|
+
),
|
|
1925
|
+
),
|
|
1926
|
+
)
|
|
1927
|
+
if _response.status_code == 429:
|
|
1928
|
+
raise TooManyRequestsError(
|
|
1929
|
+
headers=dict(_response.headers),
|
|
1930
|
+
body=typing.cast(
|
|
1931
|
+
HttpErrorResponse,
|
|
1932
|
+
parse_obj_as(
|
|
1933
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1934
|
+
object_=_response.json(),
|
|
1935
|
+
),
|
|
1936
|
+
),
|
|
1937
|
+
)
|
|
1938
|
+
if _response.status_code == 502:
|
|
1939
|
+
raise BadGatewayError(
|
|
1940
|
+
headers=dict(_response.headers),
|
|
1941
|
+
body=typing.cast(
|
|
1942
|
+
HttpErrorResponse,
|
|
1943
|
+
parse_obj_as(
|
|
1944
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1945
|
+
object_=_response.json(),
|
|
1946
|
+
),
|
|
1947
|
+
),
|
|
1948
|
+
)
|
|
1949
|
+
if _response.status_code == 504:
|
|
1950
|
+
raise GatewayTimeoutError(
|
|
1951
|
+
headers=dict(_response.headers),
|
|
1952
|
+
body=typing.cast(
|
|
1953
|
+
HttpErrorResponse,
|
|
1954
|
+
parse_obj_as(
|
|
1955
|
+
type_=HttpErrorResponse, # type: ignore
|
|
1956
|
+
object_=_response.json(),
|
|
1957
|
+
),
|
|
1958
|
+
),
|
|
1959
|
+
)
|
|
1960
|
+
_response_json = _response.json()
|
|
1961
|
+
except JSONDecodeError:
|
|
1962
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1963
|
+
except ValidationError as e:
|
|
1964
|
+
raise ParsingError(
|
|
1965
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
1966
|
+
)
|
|
1967
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1968
|
+
|
|
1969
|
+
async def get(
|
|
1970
|
+
self, token_id: int, *, request_options: typing.Optional[RequestOptions] = None
|
|
1971
|
+
) -> AsyncHttpResponse[TokenOut]:
|
|
1972
|
+
"""
|
|
1973
|
+
One token you issued.
|
|
1974
|
+
|
|
1975
|
+
Parameters
|
|
1976
|
+
----------
|
|
1977
|
+
token_id : int
|
|
1978
|
+
The token's ``id``.
|
|
1979
|
+
|
|
1980
|
+
request_options : typing.Optional[RequestOptions]
|
|
1981
|
+
Request-specific configuration.
|
|
1982
|
+
|
|
1983
|
+
Returns
|
|
1984
|
+
-------
|
|
1985
|
+
AsyncHttpResponse[TokenOut]
|
|
1986
|
+
The token.
|
|
1987
|
+
"""
|
|
1988
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1989
|
+
f"emsp/tokens/{encode_path_param(token_id)}",
|
|
1990
|
+
method="GET",
|
|
1991
|
+
request_options=request_options,
|
|
1992
|
+
)
|
|
1993
|
+
try:
|
|
1994
|
+
if 200 <= _response.status_code < 300:
|
|
1995
|
+
_data = typing.cast(
|
|
1996
|
+
TokenOut,
|
|
1997
|
+
parse_obj_as(
|
|
1998
|
+
type_=TokenOut, # type: ignore
|
|
1999
|
+
object_=_response.json(),
|
|
2000
|
+
),
|
|
2001
|
+
)
|
|
2002
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2003
|
+
if _response.status_code == 401:
|
|
2004
|
+
raise UnauthorizedError(
|
|
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 == 404:
|
|
2015
|
+
raise NotFoundError(
|
|
2016
|
+
headers=dict(_response.headers),
|
|
2017
|
+
body=typing.cast(
|
|
2018
|
+
HttpErrorResponse,
|
|
2019
|
+
parse_obj_as(
|
|
2020
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2021
|
+
object_=_response.json(),
|
|
2022
|
+
),
|
|
2023
|
+
),
|
|
2024
|
+
)
|
|
2025
|
+
if _response.status_code == 422:
|
|
2026
|
+
raise UnprocessableEntityError(
|
|
2027
|
+
headers=dict(_response.headers),
|
|
2028
|
+
body=typing.cast(
|
|
2029
|
+
HttpValidationError,
|
|
2030
|
+
parse_obj_as(
|
|
2031
|
+
type_=HttpValidationError, # type: ignore
|
|
2032
|
+
object_=_response.json(),
|
|
2033
|
+
),
|
|
2034
|
+
),
|
|
2035
|
+
)
|
|
2036
|
+
if _response.status_code == 429:
|
|
2037
|
+
raise TooManyRequestsError(
|
|
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 == 502:
|
|
2048
|
+
raise BadGatewayError(
|
|
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
|
+
if _response.status_code == 504:
|
|
2059
|
+
raise GatewayTimeoutError(
|
|
2060
|
+
headers=dict(_response.headers),
|
|
2061
|
+
body=typing.cast(
|
|
2062
|
+
HttpErrorResponse,
|
|
2063
|
+
parse_obj_as(
|
|
2064
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2065
|
+
object_=_response.json(),
|
|
2066
|
+
),
|
|
2067
|
+
),
|
|
2068
|
+
)
|
|
2069
|
+
_response_json = _response.json()
|
|
2070
|
+
except JSONDecodeError:
|
|
2071
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2072
|
+
except ValidationError as e:
|
|
2073
|
+
raise ParsingError(
|
|
2074
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
2075
|
+
)
|
|
2076
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2077
|
+
|
|
2078
|
+
async def update(
|
|
2079
|
+
self,
|
|
2080
|
+
token_id: int,
|
|
2081
|
+
*,
|
|
2082
|
+
visual_number: typing.Optional[str] = OMIT,
|
|
2083
|
+
contract_id: typing.Optional[str] = OMIT,
|
|
2084
|
+
issuer: typing.Optional[str] = OMIT,
|
|
2085
|
+
language: typing.Optional[str] = OMIT,
|
|
2086
|
+
whitelist: typing.Optional[TokenUpdateWhitelist] = OMIT,
|
|
2087
|
+
group_id: typing.Optional[str] = OMIT,
|
|
2088
|
+
metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
2089
|
+
is_roaming: typing.Optional[bool] = OMIT,
|
|
2090
|
+
default_profile_type: typing.Optional[TokenUpdateDefaultProfileType] = OMIT,
|
|
2091
|
+
energy_contract: typing.Optional[EnergyContract] = OMIT,
|
|
2092
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2093
|
+
) -> AsyncHttpResponse[TokenOut]:
|
|
2094
|
+
"""
|
|
2095
|
+
Only the fields sent change. ACTIVE and SUSPENDED tokens are pushed to partners again before the change is saved. If the push to roaming partners fails the call answers 502 and the token is left as it was; retry with the same Idempotency-Key.
|
|
2096
|
+
|
|
2097
|
+
Parameters
|
|
2098
|
+
----------
|
|
2099
|
+
token_id : int
|
|
2100
|
+
The token's ``id``.
|
|
2101
|
+
|
|
2102
|
+
visual_number : typing.Optional[str]
|
|
2103
|
+
|
|
2104
|
+
contract_id : typing.Optional[str]
|
|
2105
|
+
|
|
2106
|
+
issuer : typing.Optional[str]
|
|
2107
|
+
|
|
2108
|
+
language : typing.Optional[str]
|
|
2109
|
+
|
|
2110
|
+
whitelist : typing.Optional[TokenUpdateWhitelist]
|
|
2111
|
+
|
|
2112
|
+
group_id : typing.Optional[str]
|
|
2113
|
+
|
|
2114
|
+
metadata : typing.Optional[typing.Dict[str, typing.Any]]
|
|
2115
|
+
|
|
2116
|
+
is_roaming : typing.Optional[bool]
|
|
2117
|
+
|
|
2118
|
+
default_profile_type : typing.Optional[TokenUpdateDefaultProfileType]
|
|
2119
|
+
|
|
2120
|
+
energy_contract : typing.Optional[EnergyContract]
|
|
2121
|
+
|
|
2122
|
+
request_options : typing.Optional[RequestOptions]
|
|
2123
|
+
Request-specific configuration.
|
|
2124
|
+
|
|
2125
|
+
Returns
|
|
2126
|
+
-------
|
|
2127
|
+
AsyncHttpResponse[TokenOut]
|
|
2128
|
+
The token after the update.
|
|
2129
|
+
"""
|
|
2130
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2131
|
+
f"emsp/tokens/{encode_path_param(token_id)}",
|
|
2132
|
+
method="PATCH",
|
|
2133
|
+
json={
|
|
2134
|
+
"visual_number": visual_number,
|
|
2135
|
+
"contract_id": contract_id,
|
|
2136
|
+
"issuer": issuer,
|
|
2137
|
+
"language": language,
|
|
2138
|
+
"whitelist": whitelist,
|
|
2139
|
+
"group_id": group_id,
|
|
2140
|
+
"metadata": metadata,
|
|
2141
|
+
"is_roaming": is_roaming,
|
|
2142
|
+
"default_profile_type": default_profile_type,
|
|
2143
|
+
"energy_contract": convert_and_respect_annotation_metadata(
|
|
2144
|
+
object_=energy_contract, annotation=typing.Optional[EnergyContract], direction="write"
|
|
2145
|
+
),
|
|
2146
|
+
},
|
|
2147
|
+
headers={
|
|
2148
|
+
"content-type": "application/json",
|
|
2149
|
+
},
|
|
2150
|
+
request_options=request_options,
|
|
2151
|
+
omit=OMIT,
|
|
2152
|
+
)
|
|
2153
|
+
try:
|
|
2154
|
+
if 200 <= _response.status_code < 300:
|
|
2155
|
+
_data = typing.cast(
|
|
2156
|
+
TokenOut,
|
|
2157
|
+
parse_obj_as(
|
|
2158
|
+
type_=TokenOut, # type: ignore
|
|
2159
|
+
object_=_response.json(),
|
|
2160
|
+
),
|
|
2161
|
+
)
|
|
2162
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2163
|
+
if _response.status_code == 401:
|
|
2164
|
+
raise UnauthorizedError(
|
|
2165
|
+
headers=dict(_response.headers),
|
|
2166
|
+
body=typing.cast(
|
|
2167
|
+
HttpErrorResponse,
|
|
2168
|
+
parse_obj_as(
|
|
2169
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2170
|
+
object_=_response.json(),
|
|
2171
|
+
),
|
|
2172
|
+
),
|
|
2173
|
+
)
|
|
2174
|
+
if _response.status_code == 404:
|
|
2175
|
+
raise NotFoundError(
|
|
2176
|
+
headers=dict(_response.headers),
|
|
2177
|
+
body=typing.cast(
|
|
2178
|
+
HttpErrorResponse,
|
|
2179
|
+
parse_obj_as(
|
|
2180
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2181
|
+
object_=_response.json(),
|
|
2182
|
+
),
|
|
2183
|
+
),
|
|
2184
|
+
)
|
|
2185
|
+
if _response.status_code == 422:
|
|
2186
|
+
raise UnprocessableEntityError(
|
|
2187
|
+
headers=dict(_response.headers),
|
|
2188
|
+
body=typing.cast(
|
|
2189
|
+
HttpValidationError,
|
|
2190
|
+
parse_obj_as(
|
|
2191
|
+
type_=HttpValidationError, # type: ignore
|
|
2192
|
+
object_=_response.json(),
|
|
2193
|
+
),
|
|
2194
|
+
),
|
|
2195
|
+
)
|
|
2196
|
+
if _response.status_code == 429:
|
|
2197
|
+
raise TooManyRequestsError(
|
|
2198
|
+
headers=dict(_response.headers),
|
|
2199
|
+
body=typing.cast(
|
|
2200
|
+
HttpErrorResponse,
|
|
2201
|
+
parse_obj_as(
|
|
2202
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2203
|
+
object_=_response.json(),
|
|
2204
|
+
),
|
|
2205
|
+
),
|
|
2206
|
+
)
|
|
2207
|
+
if _response.status_code == 502:
|
|
2208
|
+
raise BadGatewayError(
|
|
2209
|
+
headers=dict(_response.headers),
|
|
2210
|
+
body=typing.cast(
|
|
2211
|
+
HttpErrorResponse,
|
|
2212
|
+
parse_obj_as(
|
|
2213
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2214
|
+
object_=_response.json(),
|
|
2215
|
+
),
|
|
2216
|
+
),
|
|
2217
|
+
)
|
|
2218
|
+
if _response.status_code == 504:
|
|
2219
|
+
raise GatewayTimeoutError(
|
|
2220
|
+
headers=dict(_response.headers),
|
|
2221
|
+
body=typing.cast(
|
|
2222
|
+
HttpErrorResponse,
|
|
2223
|
+
parse_obj_as(
|
|
2224
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2225
|
+
object_=_response.json(),
|
|
2226
|
+
),
|
|
2227
|
+
),
|
|
2228
|
+
)
|
|
2229
|
+
_response_json = _response.json()
|
|
2230
|
+
except JSONDecodeError:
|
|
2231
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2232
|
+
except ValidationError as e:
|
|
2233
|
+
raise ParsingError(
|
|
2234
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
2235
|
+
)
|
|
2236
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2237
|
+
|
|
2238
|
+
async def activate(
|
|
2239
|
+
self, token_id: int, *, idempotency_key: str, request_options: typing.Optional[RequestOptions] = None
|
|
2240
|
+
) -> AsyncHttpResponse[TokenOut]:
|
|
2241
|
+
"""
|
|
2242
|
+
PROVISIONED → ACTIVE: pushed to partners with ``valid: true``. If the push to roaming partners fails the call answers 502 and the token is left as it was; retry with the same Idempotency-Key.
|
|
2243
|
+
|
|
2244
|
+
Parameters
|
|
2245
|
+
----------
|
|
2246
|
+
token_id : int
|
|
2247
|
+
The token's ``id``.
|
|
2248
|
+
|
|
2249
|
+
idempotency_key : str
|
|
2250
|
+
A unique key you choose for this call, e.g. a UUID. Retrying with the same key returns the first result instead of acting twice.
|
|
2251
|
+
|
|
2252
|
+
request_options : typing.Optional[RequestOptions]
|
|
2253
|
+
Request-specific configuration.
|
|
2254
|
+
|
|
2255
|
+
Returns
|
|
2256
|
+
-------
|
|
2257
|
+
AsyncHttpResponse[TokenOut]
|
|
2258
|
+
The token after the change.
|
|
2259
|
+
"""
|
|
2260
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2261
|
+
f"emsp/tokens/{encode_path_param(token_id)}/activate",
|
|
2262
|
+
method="POST",
|
|
2263
|
+
headers={
|
|
2264
|
+
"Idempotency-Key": str(idempotency_key) if idempotency_key is not None else None,
|
|
2265
|
+
},
|
|
2266
|
+
request_options=request_options,
|
|
2267
|
+
)
|
|
2268
|
+
try:
|
|
2269
|
+
if 200 <= _response.status_code < 300:
|
|
2270
|
+
_data = typing.cast(
|
|
2271
|
+
TokenOut,
|
|
2272
|
+
parse_obj_as(
|
|
2273
|
+
type_=TokenOut, # type: ignore
|
|
2274
|
+
object_=_response.json(),
|
|
2275
|
+
),
|
|
2276
|
+
)
|
|
2277
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2278
|
+
if _response.status_code == 400:
|
|
2279
|
+
raise BadRequestError(
|
|
2280
|
+
headers=dict(_response.headers),
|
|
2281
|
+
body=typing.cast(
|
|
2282
|
+
HttpErrorResponse,
|
|
2283
|
+
parse_obj_as(
|
|
2284
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2285
|
+
object_=_response.json(),
|
|
2286
|
+
),
|
|
2287
|
+
),
|
|
2288
|
+
)
|
|
2289
|
+
if _response.status_code == 401:
|
|
2290
|
+
raise UnauthorizedError(
|
|
2291
|
+
headers=dict(_response.headers),
|
|
2292
|
+
body=typing.cast(
|
|
2293
|
+
HttpErrorResponse,
|
|
2294
|
+
parse_obj_as(
|
|
2295
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2296
|
+
object_=_response.json(),
|
|
2297
|
+
),
|
|
2298
|
+
),
|
|
2299
|
+
)
|
|
2300
|
+
if _response.status_code == 404:
|
|
2301
|
+
raise NotFoundError(
|
|
2302
|
+
headers=dict(_response.headers),
|
|
2303
|
+
body=typing.cast(
|
|
2304
|
+
HttpErrorResponse,
|
|
2305
|
+
parse_obj_as(
|
|
2306
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2307
|
+
object_=_response.json(),
|
|
2308
|
+
),
|
|
2309
|
+
),
|
|
2310
|
+
)
|
|
2311
|
+
if _response.status_code == 409:
|
|
2312
|
+
raise ConflictError(
|
|
2313
|
+
headers=dict(_response.headers),
|
|
2314
|
+
body=typing.cast(
|
|
2315
|
+
HttpErrorResponse,
|
|
2316
|
+
parse_obj_as(
|
|
2317
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2318
|
+
object_=_response.json(),
|
|
2319
|
+
),
|
|
2320
|
+
),
|
|
2321
|
+
)
|
|
2322
|
+
if _response.status_code == 422:
|
|
2323
|
+
raise UnprocessableEntityError(
|
|
2324
|
+
headers=dict(_response.headers),
|
|
2325
|
+
body=typing.cast(
|
|
2326
|
+
HttpValidationError,
|
|
2327
|
+
parse_obj_as(
|
|
2328
|
+
type_=HttpValidationError, # type: ignore
|
|
2329
|
+
object_=_response.json(),
|
|
2330
|
+
),
|
|
2331
|
+
),
|
|
2332
|
+
)
|
|
2333
|
+
if _response.status_code == 429:
|
|
2334
|
+
raise TooManyRequestsError(
|
|
2335
|
+
headers=dict(_response.headers),
|
|
2336
|
+
body=typing.cast(
|
|
2337
|
+
HttpErrorResponse,
|
|
2338
|
+
parse_obj_as(
|
|
2339
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2340
|
+
object_=_response.json(),
|
|
2341
|
+
),
|
|
2342
|
+
),
|
|
2343
|
+
)
|
|
2344
|
+
if _response.status_code == 502:
|
|
2345
|
+
raise BadGatewayError(
|
|
2346
|
+
headers=dict(_response.headers),
|
|
2347
|
+
body=typing.cast(
|
|
2348
|
+
HttpErrorResponse,
|
|
2349
|
+
parse_obj_as(
|
|
2350
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2351
|
+
object_=_response.json(),
|
|
2352
|
+
),
|
|
2353
|
+
),
|
|
2354
|
+
)
|
|
2355
|
+
if _response.status_code == 504:
|
|
2356
|
+
raise GatewayTimeoutError(
|
|
2357
|
+
headers=dict(_response.headers),
|
|
2358
|
+
body=typing.cast(
|
|
2359
|
+
HttpErrorResponse,
|
|
2360
|
+
parse_obj_as(
|
|
2361
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2362
|
+
object_=_response.json(),
|
|
2363
|
+
),
|
|
2364
|
+
),
|
|
2365
|
+
)
|
|
2366
|
+
_response_json = _response.json()
|
|
2367
|
+
except JSONDecodeError:
|
|
2368
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2369
|
+
except ValidationError as e:
|
|
2370
|
+
raise ParsingError(
|
|
2371
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
2372
|
+
)
|
|
2373
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2374
|
+
|
|
2375
|
+
async def history(
|
|
2376
|
+
self,
|
|
2377
|
+
token_id: int,
|
|
2378
|
+
*,
|
|
2379
|
+
after: typing.Optional[str] = None,
|
|
2380
|
+
limit: typing.Optional[int] = None,
|
|
2381
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2382
|
+
) -> AsyncPager[TokenEventOut, TokenEventPage]:
|
|
2383
|
+
"""
|
|
2384
|
+
Lifecycle changes of the token, newest first.
|
|
2385
|
+
|
|
2386
|
+
Parameters
|
|
2387
|
+
----------
|
|
2388
|
+
token_id : int
|
|
2389
|
+
The token's ``id``.
|
|
2390
|
+
|
|
2391
|
+
after : typing.Optional[str]
|
|
2392
|
+
Cursor: the previous page's ``pagination.end_cursor``. Omit it for the first page.
|
|
2393
|
+
|
|
2394
|
+
limit : typing.Optional[int]
|
|
2395
|
+
Maximum rows per page (default 50, max 200).
|
|
2396
|
+
|
|
2397
|
+
request_options : typing.Optional[RequestOptions]
|
|
2398
|
+
Request-specific configuration.
|
|
2399
|
+
|
|
2400
|
+
Returns
|
|
2401
|
+
-------
|
|
2402
|
+
AsyncPager[TokenEventOut, TokenEventPage]
|
|
2403
|
+
One page of lifecycle events, newest first.
|
|
2404
|
+
"""
|
|
2405
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2406
|
+
f"emsp/tokens/{encode_path_param(token_id)}/history",
|
|
2407
|
+
method="GET",
|
|
2408
|
+
params={
|
|
2409
|
+
"after": after,
|
|
2410
|
+
"limit": limit,
|
|
2411
|
+
},
|
|
2412
|
+
request_options=request_options,
|
|
2413
|
+
)
|
|
2414
|
+
try:
|
|
2415
|
+
if 200 <= _response.status_code < 300:
|
|
2416
|
+
_parsed_response = typing.cast(
|
|
2417
|
+
TokenEventPage,
|
|
2418
|
+
parse_obj_as(
|
|
2419
|
+
type_=TokenEventPage, # type: ignore
|
|
2420
|
+
object_=_response.json(),
|
|
2421
|
+
),
|
|
2422
|
+
)
|
|
2423
|
+
_items = _parsed_response.data
|
|
2424
|
+
_has_next = False
|
|
2425
|
+
_get_next = None
|
|
2426
|
+
if _parsed_response.pagination is not None:
|
|
2427
|
+
_parsed_next = _parsed_response.pagination.end_cursor
|
|
2428
|
+
_has_next = _parsed_next is not None and _parsed_next != ""
|
|
2429
|
+
|
|
2430
|
+
async def _get_next():
|
|
2431
|
+
return await self.history(
|
|
2432
|
+
token_id,
|
|
2433
|
+
after=_parsed_next,
|
|
2434
|
+
limit=limit,
|
|
2435
|
+
request_options=request_options,
|
|
2436
|
+
)
|
|
2437
|
+
|
|
2438
|
+
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
|
|
2439
|
+
if _response.status_code == 401:
|
|
2440
|
+
raise UnauthorizedError(
|
|
2441
|
+
headers=dict(_response.headers),
|
|
2442
|
+
body=typing.cast(
|
|
2443
|
+
HttpErrorResponse,
|
|
2444
|
+
parse_obj_as(
|
|
2445
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2446
|
+
object_=_response.json(),
|
|
2447
|
+
),
|
|
2448
|
+
),
|
|
2449
|
+
)
|
|
2450
|
+
if _response.status_code == 404:
|
|
2451
|
+
raise NotFoundError(
|
|
2452
|
+
headers=dict(_response.headers),
|
|
2453
|
+
body=typing.cast(
|
|
2454
|
+
HttpErrorResponse,
|
|
2455
|
+
parse_obj_as(
|
|
2456
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2457
|
+
object_=_response.json(),
|
|
2458
|
+
),
|
|
2459
|
+
),
|
|
2460
|
+
)
|
|
2461
|
+
if _response.status_code == 422:
|
|
2462
|
+
raise UnprocessableEntityError(
|
|
2463
|
+
headers=dict(_response.headers),
|
|
2464
|
+
body=typing.cast(
|
|
2465
|
+
HttpValidationError,
|
|
2466
|
+
parse_obj_as(
|
|
2467
|
+
type_=HttpValidationError, # type: ignore
|
|
2468
|
+
object_=_response.json(),
|
|
2469
|
+
),
|
|
2470
|
+
),
|
|
2471
|
+
)
|
|
2472
|
+
if _response.status_code == 429:
|
|
2473
|
+
raise TooManyRequestsError(
|
|
2474
|
+
headers=dict(_response.headers),
|
|
2475
|
+
body=typing.cast(
|
|
2476
|
+
HttpErrorResponse,
|
|
2477
|
+
parse_obj_as(
|
|
2478
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2479
|
+
object_=_response.json(),
|
|
2480
|
+
),
|
|
2481
|
+
),
|
|
2482
|
+
)
|
|
2483
|
+
if _response.status_code == 502:
|
|
2484
|
+
raise BadGatewayError(
|
|
2485
|
+
headers=dict(_response.headers),
|
|
2486
|
+
body=typing.cast(
|
|
2487
|
+
HttpErrorResponse,
|
|
2488
|
+
parse_obj_as(
|
|
2489
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2490
|
+
object_=_response.json(),
|
|
2491
|
+
),
|
|
2492
|
+
),
|
|
2493
|
+
)
|
|
2494
|
+
if _response.status_code == 504:
|
|
2495
|
+
raise GatewayTimeoutError(
|
|
2496
|
+
headers=dict(_response.headers),
|
|
2497
|
+
body=typing.cast(
|
|
2498
|
+
HttpErrorResponse,
|
|
2499
|
+
parse_obj_as(
|
|
2500
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2501
|
+
object_=_response.json(),
|
|
2502
|
+
),
|
|
2503
|
+
),
|
|
2504
|
+
)
|
|
2505
|
+
_response_json = _response.json()
|
|
2506
|
+
except JSONDecodeError:
|
|
2507
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2508
|
+
except ValidationError as e:
|
|
2509
|
+
raise ParsingError(
|
|
2510
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
2511
|
+
)
|
|
2512
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2513
|
+
|
|
2514
|
+
async def reactivate(
|
|
2515
|
+
self, token_id: int, *, idempotency_key: str, request_options: typing.Optional[RequestOptions] = None
|
|
2516
|
+
) -> AsyncHttpResponse[TokenOut]:
|
|
2517
|
+
"""
|
|
2518
|
+
SUSPENDED → ACTIVE: pushed to partners with ``valid: true``. If the push to roaming partners fails the call answers 502 and the token is left as it was; retry with the same Idempotency-Key.
|
|
2519
|
+
|
|
2520
|
+
Parameters
|
|
2521
|
+
----------
|
|
2522
|
+
token_id : int
|
|
2523
|
+
The token's ``id``.
|
|
2524
|
+
|
|
2525
|
+
idempotency_key : str
|
|
2526
|
+
A unique key you choose for this call, e.g. a UUID. Retrying with the same key returns the first result instead of acting twice.
|
|
2527
|
+
|
|
2528
|
+
request_options : typing.Optional[RequestOptions]
|
|
2529
|
+
Request-specific configuration.
|
|
2530
|
+
|
|
2531
|
+
Returns
|
|
2532
|
+
-------
|
|
2533
|
+
AsyncHttpResponse[TokenOut]
|
|
2534
|
+
The token after the change.
|
|
2535
|
+
"""
|
|
2536
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2537
|
+
f"emsp/tokens/{encode_path_param(token_id)}/reactivate",
|
|
2538
|
+
method="POST",
|
|
2539
|
+
headers={
|
|
2540
|
+
"Idempotency-Key": str(idempotency_key) if idempotency_key is not None else None,
|
|
2541
|
+
},
|
|
2542
|
+
request_options=request_options,
|
|
2543
|
+
)
|
|
2544
|
+
try:
|
|
2545
|
+
if 200 <= _response.status_code < 300:
|
|
2546
|
+
_data = typing.cast(
|
|
2547
|
+
TokenOut,
|
|
2548
|
+
parse_obj_as(
|
|
2549
|
+
type_=TokenOut, # type: ignore
|
|
2550
|
+
object_=_response.json(),
|
|
2551
|
+
),
|
|
2552
|
+
)
|
|
2553
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2554
|
+
if _response.status_code == 400:
|
|
2555
|
+
raise BadRequestError(
|
|
2556
|
+
headers=dict(_response.headers),
|
|
2557
|
+
body=typing.cast(
|
|
2558
|
+
HttpErrorResponse,
|
|
2559
|
+
parse_obj_as(
|
|
2560
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2561
|
+
object_=_response.json(),
|
|
2562
|
+
),
|
|
2563
|
+
),
|
|
2564
|
+
)
|
|
2565
|
+
if _response.status_code == 401:
|
|
2566
|
+
raise UnauthorizedError(
|
|
2567
|
+
headers=dict(_response.headers),
|
|
2568
|
+
body=typing.cast(
|
|
2569
|
+
HttpErrorResponse,
|
|
2570
|
+
parse_obj_as(
|
|
2571
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2572
|
+
object_=_response.json(),
|
|
2573
|
+
),
|
|
2574
|
+
),
|
|
2575
|
+
)
|
|
2576
|
+
if _response.status_code == 404:
|
|
2577
|
+
raise NotFoundError(
|
|
2578
|
+
headers=dict(_response.headers),
|
|
2579
|
+
body=typing.cast(
|
|
2580
|
+
HttpErrorResponse,
|
|
2581
|
+
parse_obj_as(
|
|
2582
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2583
|
+
object_=_response.json(),
|
|
2584
|
+
),
|
|
2585
|
+
),
|
|
2586
|
+
)
|
|
2587
|
+
if _response.status_code == 409:
|
|
2588
|
+
raise ConflictError(
|
|
2589
|
+
headers=dict(_response.headers),
|
|
2590
|
+
body=typing.cast(
|
|
2591
|
+
HttpErrorResponse,
|
|
2592
|
+
parse_obj_as(
|
|
2593
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2594
|
+
object_=_response.json(),
|
|
2595
|
+
),
|
|
2596
|
+
),
|
|
2597
|
+
)
|
|
2598
|
+
if _response.status_code == 422:
|
|
2599
|
+
raise UnprocessableEntityError(
|
|
2600
|
+
headers=dict(_response.headers),
|
|
2601
|
+
body=typing.cast(
|
|
2602
|
+
HttpValidationError,
|
|
2603
|
+
parse_obj_as(
|
|
2604
|
+
type_=HttpValidationError, # type: ignore
|
|
2605
|
+
object_=_response.json(),
|
|
2606
|
+
),
|
|
2607
|
+
),
|
|
2608
|
+
)
|
|
2609
|
+
if _response.status_code == 429:
|
|
2610
|
+
raise TooManyRequestsError(
|
|
2611
|
+
headers=dict(_response.headers),
|
|
2612
|
+
body=typing.cast(
|
|
2613
|
+
HttpErrorResponse,
|
|
2614
|
+
parse_obj_as(
|
|
2615
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2616
|
+
object_=_response.json(),
|
|
2617
|
+
),
|
|
2618
|
+
),
|
|
2619
|
+
)
|
|
2620
|
+
if _response.status_code == 502:
|
|
2621
|
+
raise BadGatewayError(
|
|
2622
|
+
headers=dict(_response.headers),
|
|
2623
|
+
body=typing.cast(
|
|
2624
|
+
HttpErrorResponse,
|
|
2625
|
+
parse_obj_as(
|
|
2626
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2627
|
+
object_=_response.json(),
|
|
2628
|
+
),
|
|
2629
|
+
),
|
|
2630
|
+
)
|
|
2631
|
+
if _response.status_code == 504:
|
|
2632
|
+
raise GatewayTimeoutError(
|
|
2633
|
+
headers=dict(_response.headers),
|
|
2634
|
+
body=typing.cast(
|
|
2635
|
+
HttpErrorResponse,
|
|
2636
|
+
parse_obj_as(
|
|
2637
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2638
|
+
object_=_response.json(),
|
|
2639
|
+
),
|
|
2640
|
+
),
|
|
2641
|
+
)
|
|
2642
|
+
_response_json = _response.json()
|
|
2643
|
+
except JSONDecodeError:
|
|
2644
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2645
|
+
except ValidationError as e:
|
|
2646
|
+
raise ParsingError(
|
|
2647
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
2648
|
+
)
|
|
2649
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2650
|
+
|
|
2651
|
+
async def revoke(
|
|
2652
|
+
self,
|
|
2653
|
+
token_id: int,
|
|
2654
|
+
*,
|
|
2655
|
+
idempotency_key: str,
|
|
2656
|
+
request: typing.Optional[TokenReason] = None,
|
|
2657
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2658
|
+
) -> AsyncHttpResponse[TokenOut]:
|
|
2659
|
+
"""
|
|
2660
|
+
Final: any status except REVOKED. A token partners already have is pushed with ``valid: false`` first. If the push to roaming partners fails the call answers 502 and the token is left as it was; retry with the same Idempotency-Key.
|
|
2661
|
+
|
|
2662
|
+
Parameters
|
|
2663
|
+
----------
|
|
2664
|
+
token_id : int
|
|
2665
|
+
The token's ``id``.
|
|
2666
|
+
|
|
2667
|
+
idempotency_key : str
|
|
2668
|
+
A unique key you choose for this call, e.g. a UUID. Retrying with the same key returns the first result instead of acting twice.
|
|
2669
|
+
|
|
2670
|
+
request : typing.Optional[TokenReason]
|
|
2671
|
+
|
|
2672
|
+
request_options : typing.Optional[RequestOptions]
|
|
2673
|
+
Request-specific configuration.
|
|
2674
|
+
|
|
2675
|
+
Returns
|
|
2676
|
+
-------
|
|
2677
|
+
AsyncHttpResponse[TokenOut]
|
|
2678
|
+
The token after the change.
|
|
2679
|
+
"""
|
|
2680
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2681
|
+
f"emsp/tokens/{encode_path_param(token_id)}/revoke",
|
|
2682
|
+
method="POST",
|
|
2683
|
+
json=convert_and_respect_annotation_metadata(
|
|
2684
|
+
object_=request, annotation=typing.Optional[TokenReason], direction="write"
|
|
2685
|
+
),
|
|
2686
|
+
headers={
|
|
2687
|
+
"content-type": "application/json",
|
|
2688
|
+
"Idempotency-Key": str(idempotency_key) if idempotency_key is not None else None,
|
|
2689
|
+
},
|
|
2690
|
+
request_options=request_options,
|
|
2691
|
+
omit=OMIT,
|
|
2692
|
+
)
|
|
2693
|
+
try:
|
|
2694
|
+
if 200 <= _response.status_code < 300:
|
|
2695
|
+
_data = typing.cast(
|
|
2696
|
+
TokenOut,
|
|
2697
|
+
parse_obj_as(
|
|
2698
|
+
type_=TokenOut, # type: ignore
|
|
2699
|
+
object_=_response.json(),
|
|
2700
|
+
),
|
|
2701
|
+
)
|
|
2702
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2703
|
+
if _response.status_code == 400:
|
|
2704
|
+
raise BadRequestError(
|
|
2705
|
+
headers=dict(_response.headers),
|
|
2706
|
+
body=typing.cast(
|
|
2707
|
+
HttpErrorResponse,
|
|
2708
|
+
parse_obj_as(
|
|
2709
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2710
|
+
object_=_response.json(),
|
|
2711
|
+
),
|
|
2712
|
+
),
|
|
2713
|
+
)
|
|
2714
|
+
if _response.status_code == 401:
|
|
2715
|
+
raise UnauthorizedError(
|
|
2716
|
+
headers=dict(_response.headers),
|
|
2717
|
+
body=typing.cast(
|
|
2718
|
+
HttpErrorResponse,
|
|
2719
|
+
parse_obj_as(
|
|
2720
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2721
|
+
object_=_response.json(),
|
|
2722
|
+
),
|
|
2723
|
+
),
|
|
2724
|
+
)
|
|
2725
|
+
if _response.status_code == 404:
|
|
2726
|
+
raise NotFoundError(
|
|
2727
|
+
headers=dict(_response.headers),
|
|
2728
|
+
body=typing.cast(
|
|
2729
|
+
HttpErrorResponse,
|
|
2730
|
+
parse_obj_as(
|
|
2731
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2732
|
+
object_=_response.json(),
|
|
2733
|
+
),
|
|
2734
|
+
),
|
|
2735
|
+
)
|
|
2736
|
+
if _response.status_code == 409:
|
|
2737
|
+
raise ConflictError(
|
|
2738
|
+
headers=dict(_response.headers),
|
|
2739
|
+
body=typing.cast(
|
|
2740
|
+
HttpErrorResponse,
|
|
2741
|
+
parse_obj_as(
|
|
2742
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2743
|
+
object_=_response.json(),
|
|
2744
|
+
),
|
|
2745
|
+
),
|
|
2746
|
+
)
|
|
2747
|
+
if _response.status_code == 422:
|
|
2748
|
+
raise UnprocessableEntityError(
|
|
2749
|
+
headers=dict(_response.headers),
|
|
2750
|
+
body=typing.cast(
|
|
2751
|
+
HttpValidationError,
|
|
2752
|
+
parse_obj_as(
|
|
2753
|
+
type_=HttpValidationError, # type: ignore
|
|
2754
|
+
object_=_response.json(),
|
|
2755
|
+
),
|
|
2756
|
+
),
|
|
2757
|
+
)
|
|
2758
|
+
if _response.status_code == 429:
|
|
2759
|
+
raise TooManyRequestsError(
|
|
2760
|
+
headers=dict(_response.headers),
|
|
2761
|
+
body=typing.cast(
|
|
2762
|
+
HttpErrorResponse,
|
|
2763
|
+
parse_obj_as(
|
|
2764
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2765
|
+
object_=_response.json(),
|
|
2766
|
+
),
|
|
2767
|
+
),
|
|
2768
|
+
)
|
|
2769
|
+
if _response.status_code == 502:
|
|
2770
|
+
raise BadGatewayError(
|
|
2771
|
+
headers=dict(_response.headers),
|
|
2772
|
+
body=typing.cast(
|
|
2773
|
+
HttpErrorResponse,
|
|
2774
|
+
parse_obj_as(
|
|
2775
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2776
|
+
object_=_response.json(),
|
|
2777
|
+
),
|
|
2778
|
+
),
|
|
2779
|
+
)
|
|
2780
|
+
if _response.status_code == 504:
|
|
2781
|
+
raise GatewayTimeoutError(
|
|
2782
|
+
headers=dict(_response.headers),
|
|
2783
|
+
body=typing.cast(
|
|
2784
|
+
HttpErrorResponse,
|
|
2785
|
+
parse_obj_as(
|
|
2786
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2787
|
+
object_=_response.json(),
|
|
2788
|
+
),
|
|
2789
|
+
),
|
|
2790
|
+
)
|
|
2791
|
+
_response_json = _response.json()
|
|
2792
|
+
except JSONDecodeError:
|
|
2793
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2794
|
+
except ValidationError as e:
|
|
2795
|
+
raise ParsingError(
|
|
2796
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
2797
|
+
)
|
|
2798
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2799
|
+
|
|
2800
|
+
async def suspend(
|
|
2801
|
+
self,
|
|
2802
|
+
token_id: int,
|
|
2803
|
+
*,
|
|
2804
|
+
idempotency_key: str,
|
|
2805
|
+
request: typing.Optional[TokenReason] = None,
|
|
2806
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2807
|
+
) -> AsyncHttpResponse[TokenOut]:
|
|
2808
|
+
"""
|
|
2809
|
+
ACTIVE → SUSPENDED: pushed to partners with ``valid: false``. If the push to roaming partners fails the call answers 502 and the token is left as it was; retry with the same Idempotency-Key.
|
|
2810
|
+
|
|
2811
|
+
Parameters
|
|
2812
|
+
----------
|
|
2813
|
+
token_id : int
|
|
2814
|
+
The token's ``id``.
|
|
2815
|
+
|
|
2816
|
+
idempotency_key : str
|
|
2817
|
+
A unique key you choose for this call, e.g. a UUID. Retrying with the same key returns the first result instead of acting twice.
|
|
2818
|
+
|
|
2819
|
+
request : typing.Optional[TokenReason]
|
|
2820
|
+
|
|
2821
|
+
request_options : typing.Optional[RequestOptions]
|
|
2822
|
+
Request-specific configuration.
|
|
2823
|
+
|
|
2824
|
+
Returns
|
|
2825
|
+
-------
|
|
2826
|
+
AsyncHttpResponse[TokenOut]
|
|
2827
|
+
The token after the change.
|
|
2828
|
+
"""
|
|
2829
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2830
|
+
f"emsp/tokens/{encode_path_param(token_id)}/suspend",
|
|
2831
|
+
method="POST",
|
|
2832
|
+
json=convert_and_respect_annotation_metadata(
|
|
2833
|
+
object_=request, annotation=typing.Optional[TokenReason], direction="write"
|
|
2834
|
+
),
|
|
2835
|
+
headers={
|
|
2836
|
+
"content-type": "application/json",
|
|
2837
|
+
"Idempotency-Key": str(idempotency_key) if idempotency_key is not None else None,
|
|
2838
|
+
},
|
|
2839
|
+
request_options=request_options,
|
|
2840
|
+
omit=OMIT,
|
|
2841
|
+
)
|
|
2842
|
+
try:
|
|
2843
|
+
if 200 <= _response.status_code < 300:
|
|
2844
|
+
_data = typing.cast(
|
|
2845
|
+
TokenOut,
|
|
2846
|
+
parse_obj_as(
|
|
2847
|
+
type_=TokenOut, # type: ignore
|
|
2848
|
+
object_=_response.json(),
|
|
2849
|
+
),
|
|
2850
|
+
)
|
|
2851
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2852
|
+
if _response.status_code == 400:
|
|
2853
|
+
raise BadRequestError(
|
|
2854
|
+
headers=dict(_response.headers),
|
|
2855
|
+
body=typing.cast(
|
|
2856
|
+
HttpErrorResponse,
|
|
2857
|
+
parse_obj_as(
|
|
2858
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2859
|
+
object_=_response.json(),
|
|
2860
|
+
),
|
|
2861
|
+
),
|
|
2862
|
+
)
|
|
2863
|
+
if _response.status_code == 401:
|
|
2864
|
+
raise UnauthorizedError(
|
|
2865
|
+
headers=dict(_response.headers),
|
|
2866
|
+
body=typing.cast(
|
|
2867
|
+
HttpErrorResponse,
|
|
2868
|
+
parse_obj_as(
|
|
2869
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2870
|
+
object_=_response.json(),
|
|
2871
|
+
),
|
|
2872
|
+
),
|
|
2873
|
+
)
|
|
2874
|
+
if _response.status_code == 404:
|
|
2875
|
+
raise NotFoundError(
|
|
2876
|
+
headers=dict(_response.headers),
|
|
2877
|
+
body=typing.cast(
|
|
2878
|
+
HttpErrorResponse,
|
|
2879
|
+
parse_obj_as(
|
|
2880
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2881
|
+
object_=_response.json(),
|
|
2882
|
+
),
|
|
2883
|
+
),
|
|
2884
|
+
)
|
|
2885
|
+
if _response.status_code == 409:
|
|
2886
|
+
raise ConflictError(
|
|
2887
|
+
headers=dict(_response.headers),
|
|
2888
|
+
body=typing.cast(
|
|
2889
|
+
HttpErrorResponse,
|
|
2890
|
+
parse_obj_as(
|
|
2891
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2892
|
+
object_=_response.json(),
|
|
2893
|
+
),
|
|
2894
|
+
),
|
|
2895
|
+
)
|
|
2896
|
+
if _response.status_code == 422:
|
|
2897
|
+
raise UnprocessableEntityError(
|
|
2898
|
+
headers=dict(_response.headers),
|
|
2899
|
+
body=typing.cast(
|
|
2900
|
+
HttpValidationError,
|
|
2901
|
+
parse_obj_as(
|
|
2902
|
+
type_=HttpValidationError, # type: ignore
|
|
2903
|
+
object_=_response.json(),
|
|
2904
|
+
),
|
|
2905
|
+
),
|
|
2906
|
+
)
|
|
2907
|
+
if _response.status_code == 429:
|
|
2908
|
+
raise TooManyRequestsError(
|
|
2909
|
+
headers=dict(_response.headers),
|
|
2910
|
+
body=typing.cast(
|
|
2911
|
+
HttpErrorResponse,
|
|
2912
|
+
parse_obj_as(
|
|
2913
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2914
|
+
object_=_response.json(),
|
|
2915
|
+
),
|
|
2916
|
+
),
|
|
2917
|
+
)
|
|
2918
|
+
if _response.status_code == 502:
|
|
2919
|
+
raise BadGatewayError(
|
|
2920
|
+
headers=dict(_response.headers),
|
|
2921
|
+
body=typing.cast(
|
|
2922
|
+
HttpErrorResponse,
|
|
2923
|
+
parse_obj_as(
|
|
2924
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2925
|
+
object_=_response.json(),
|
|
2926
|
+
),
|
|
2927
|
+
),
|
|
2928
|
+
)
|
|
2929
|
+
if _response.status_code == 504:
|
|
2930
|
+
raise GatewayTimeoutError(
|
|
2931
|
+
headers=dict(_response.headers),
|
|
2932
|
+
body=typing.cast(
|
|
2933
|
+
HttpErrorResponse,
|
|
2934
|
+
parse_obj_as(
|
|
2935
|
+
type_=HttpErrorResponse, # type: ignore
|
|
2936
|
+
object_=_response.json(),
|
|
2937
|
+
),
|
|
2938
|
+
),
|
|
2939
|
+
)
|
|
2940
|
+
_response_json = _response.json()
|
|
2941
|
+
except JSONDecodeError:
|
|
2942
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2943
|
+
except ValidationError as e:
|
|
2944
|
+
raise ParsingError(
|
|
2945
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
2946
|
+
)
|
|
2947
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|