ory-client 1.9.0__py3-none-any.whl → 1.11.7__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.
- ory_client/__init__.py +279 -10
- ory_client/api/__init__.py +16 -3
- ory_client/api/courier_api.py +576 -287
- ory_client/api/events_api.py +1147 -576
- ory_client/api/frontend_api.py +8736 -4145
- ory_client/api/identity_api.py +5219 -2605
- ory_client/api/jwk_api.py +1881 -939
- ory_client/api/metadata_api.py +245 -376
- ory_client/api/o_auth2_api.py +7763 -3858
- ory_client/api/oidc_api.py +2071 -1034
- ory_client/api/permission_api.py +1675 -776
- ory_client/api/project_api.py +5314 -2638
- ory_client/api/relationship_api.py +1844 -860
- ory_client/api/wellknown_api.py +250 -131
- ory_client/api_client.py +520 -658
- ory_client/api_response.py +21 -0
- ory_client/configuration.py +65 -75
- ory_client/exceptions.py +73 -32
- ory_client/models/__init__.py +266 -291
- ory_client/models/accept_o_auth2_consent_request.py +118 -0
- ory_client/models/accept_o_auth2_consent_request_session.py +113 -0
- ory_client/models/accept_o_auth2_login_request.py +117 -0
- ory_client/models/active_project_in_console.py +101 -0
- ory_client/models/attribute.py +103 -0
- ory_client/models/attribute_filter.py +115 -0
- ory_client/models/attributes_count_datapoint.py +103 -0
- ory_client/models/authenticator_assurance_level.py +40 -0
- ory_client/models/batch_patch_identities_response.py +109 -0
- ory_client/models/check_opl_syntax_result.py +109 -0
- ory_client/models/check_permission_result.py +101 -0
- ory_client/models/cloud_account.py +105 -0
- ory_client/models/consistency_request_parameters.py +111 -0
- ory_client/models/continue_with.py +214 -0
- ory_client/models/continue_with_recovery_ui.py +114 -0
- ory_client/models/continue_with_recovery_ui_flow.py +103 -0
- ory_client/models/continue_with_set_ory_session_token.py +110 -0
- ory_client/models/continue_with_settings_ui.py +114 -0
- ory_client/models/continue_with_settings_ui_flow.py +101 -0
- ory_client/models/continue_with_verification_ui.py +114 -0
- ory_client/models/continue_with_verification_ui_flow.py +105 -0
- ory_client/models/courier_message_status.py +40 -0
- ory_client/models/courier_message_type.py +38 -0
- ory_client/models/create_custom_domain_body.py +109 -0
- ory_client/models/create_event_stream_body.py +112 -0
- ory_client/models/create_identity_body.py +155 -0
- ory_client/models/create_invite_response.py +114 -0
- ory_client/models/create_json_web_key_set.py +105 -0
- ory_client/models/create_project_api_key_request.py +101 -0
- ory_client/models/create_project_body.py +112 -0
- ory_client/models/create_project_branding.py +115 -0
- ory_client/models/create_project_member_invite_body.py +101 -0
- ory_client/models/create_project_normalized_payload.py +685 -0
- ory_client/models/create_recovery_code_for_identity_body.py +114 -0
- ory_client/models/create_recovery_link_for_identity_body.py +114 -0
- ory_client/models/create_relationship_body.py +113 -0
- ory_client/models/create_subscription_body.py +126 -0
- ory_client/models/create_subscription_common.py +124 -0
- ory_client/models/create_verifiable_credential_request_body.py +109 -0
- ory_client/models/create_workspace_member_invite_body.py +101 -0
- ory_client/models/create_workspace_payload.py +101 -0
- ory_client/models/create_workspace_subscription_body.py +124 -0
- ory_client/models/credential_supported_draft00.py +107 -0
- ory_client/models/custom_domain.py +132 -0
- ory_client/models/delete_my_sessions_count.py +101 -0
- ory_client/models/email_template_data.py +107 -0
- ory_client/models/email_template_data_body.py +103 -0
- ory_client/models/error_authenticator_assurance_level_not_satisfied.py +107 -0
- ory_client/models/error_browser_location_change_required.py +107 -0
- ory_client/models/error_flow_replaced.py +107 -0
- ory_client/models/error_generic.py +105 -0
- ory_client/models/error_o_auth2.py +109 -0
- ory_client/models/event_stream.py +112 -0
- ory_client/models/expanded_permission_tree.py +125 -0
- ory_client/models/flow_error.py +108 -0
- ory_client/models/generic_error.py +126 -0
- ory_client/models/generic_error_content.py +109 -0
- ory_client/models/generic_usage.py +103 -0
- ory_client/models/get_attributes_count_response.py +111 -0
- ory_client/models/get_managed_identity_schema_location.py +101 -0
- ory_client/models/get_metrics_event_attributes_response.py +103 -0
- ory_client/models/get_metrics_event_types_response.py +103 -0
- ory_client/models/get_organization_response.py +105 -0
- ory_client/models/get_project_events_body.py +120 -0
- ory_client/models/get_project_events_response.py +115 -0
- ory_client/models/get_project_metrics_response.py +111 -0
- ory_client/models/get_session_activity_response.py +111 -0
- ory_client/models/get_version200_response.py +101 -0
- ory_client/models/health_not_ready_status.py +101 -0
- ory_client/models/health_status.py +101 -0
- ory_client/models/identity.py +187 -0
- ory_client/models/identity_credentials.py +122 -0
- ory_client/models/identity_credentials_code.py +109 -0
- ory_client/models/identity_credentials_oidc.py +109 -0
- ory_client/models/identity_credentials_oidc_provider.py +111 -0
- ory_client/models/identity_credentials_password.py +101 -0
- ory_client/models/identity_patch.py +107 -0
- ory_client/models/identity_patch_response.py +115 -0
- ory_client/models/identity_schema_container.py +103 -0
- ory_client/models/identity_schema_preset.py +103 -0
- ory_client/models/identity_with_credentials.py +111 -0
- ory_client/models/identity_with_credentials_oidc.py +105 -0
- ory_client/models/identity_with_credentials_oidc_config.py +115 -0
- ory_client/models/identity_with_credentials_oidc_config_provider.py +103 -0
- ory_client/models/identity_with_credentials_password.py +105 -0
- ory_client/models/identity_with_credentials_password_config.py +103 -0
- ory_client/models/internal_get_project_branding_body.py +101 -0
- ory_client/models/internal_is_ax_welcome_screen_enabled_for_project_body.py +103 -0
- ory_client/models/internal_is_owner_for_project_by_slug_body.py +114 -0
- ory_client/models/internal_is_owner_for_project_by_slug_response.py +101 -0
- ory_client/models/introspected_o_auth2_token.py +127 -0
- ory_client/models/is_owner_for_project_by_slug.py +103 -0
- ory_client/models/json_patch.py +119 -0
- ory_client/models/json_web_key.py +133 -0
- ory_client/models/json_web_key_set.py +109 -0
- ory_client/models/keto_namespace.py +103 -0
- ory_client/models/list_event_streams.py +109 -0
- ory_client/models/list_my_workspaces_response.py +113 -0
- ory_client/models/list_organizations_response.py +109 -0
- ory_client/models/list_workspace_projects_response.py +113 -0
- ory_client/models/login_flow.py +165 -0
- ory_client/models/login_flow_state.py +39 -0
- ory_client/models/logout_flow.py +103 -0
- ory_client/models/managed_identity_schema.py +120 -0
- ory_client/models/managed_identity_schema_validation_result.py +103 -0
- ory_client/models/member_invite.py +148 -0
- ory_client/models/message.py +141 -0
- ory_client/models/message_dispatch.py +119 -0
- ory_client/models/metrics_datapoint.py +104 -0
- ory_client/models/migration_options.py +117 -0
- ory_client/models/namespace.py +101 -0
- ory_client/models/needs_privileged_session_error.py +107 -0
- ory_client/models/normalized_project.py +171 -0
- ory_client/models/normalized_project_revision.py +674 -0
- ory_client/models/normalized_project_revision_courier_channel.py +145 -0
- ory_client/models/normalized_project_revision_hook.py +140 -0
- ory_client/models/normalized_project_revision_identity_schema.py +133 -0
- ory_client/models/normalized_project_revision_third_party_provider.py +187 -0
- ory_client/models/normalized_project_revision_tokenizer_template.py +133 -0
- ory_client/models/o_auth2_client.py +352 -0
- ory_client/models/o_auth2_client_token_lifespans.py +270 -0
- ory_client/models/o_auth2_consent_request.py +133 -0
- ory_client/models/o_auth2_consent_request_open_id_connect_context.py +109 -0
- ory_client/models/o_auth2_consent_session.py +130 -0
- ory_client/models/o_auth2_consent_session_expires_at.py +110 -0
- ory_client/models/o_auth2_login_request.py +125 -0
- ory_client/models/o_auth2_logout_request.py +115 -0
- ory_client/models/o_auth2_redirect_to.py +101 -0
- ory_client/models/o_auth2_token_exchange.py +111 -0
- ory_client/models/oidc_configuration.py +169 -0
- ory_client/models/oidc_user_info.py +137 -0
- ory_client/models/organization.py +116 -0
- ory_client/models/organization_body.py +103 -0
- ory_client/models/pagination.py +104 -0
- ory_client/models/pagination_headers.py +103 -0
- ory_client/models/parse_error.py +112 -0
- ory_client/models/patch_identities_body.py +109 -0
- ory_client/models/perform_native_logout_body.py +101 -0
- ory_client/models/permissions_on_workpace_response.py +101 -0
- ory_client/models/plan.py +103 -0
- ory_client/models/plan_details.py +128 -0
- ory_client/models/post_check_permission_body.py +113 -0
- ory_client/models/post_check_permission_or_error_body.py +113 -0
- ory_client/models/project.py +148 -0
- ory_client/models/project_api_key.py +126 -0
- ory_client/models/project_branding.py +129 -0
- ory_client/models/project_branding_colors.py +157 -0
- ory_client/models/project_branding_theme.py +182 -0
- ory_client/models/project_cors.py +103 -0
- ory_client/models/project_events_datapoint.py +114 -0
- ory_client/models/project_host.py +107 -0
- ory_client/models/project_member.py +107 -0
- ory_client/models/project_metadata.py +161 -0
- ory_client/models/project_service_identity.py +101 -0
- ory_client/models/project_service_o_auth2.py +101 -0
- ory_client/models/project_service_permission.py +101 -0
- ory_client/models/project_services.py +117 -0
- ory_client/models/quota_usage.py +118 -0
- ory_client/models/recovery_code_for_identity.py +106 -0
- ory_client/models/recovery_flow.py +139 -0
- ory_client/models/recovery_flow_state.py +39 -0
- ory_client/models/recovery_identity_address.py +110 -0
- ory_client/models/recovery_link_for_identity.py +104 -0
- ory_client/models/registration_flow.py +156 -0
- ory_client/models/registration_flow_state.py +39 -0
- ory_client/models/reject_o_auth2_request.py +109 -0
- ory_client/models/relation_query.py +113 -0
- ory_client/models/relationship.py +113 -0
- ory_client/models/relationship_namespaces.py +109 -0
- ory_client/models/relationship_patch.py +117 -0
- ory_client/models/relationships.py +111 -0
- ory_client/models/rfc6749_error_json.py +109 -0
- ory_client/models/schema_patch.py +103 -0
- ory_client/models/self_service_flow_expired_error.py +112 -0
- ory_client/models/session.py +141 -0
- ory_client/models/session_activity_datapoint.py +105 -0
- ory_client/models/session_authentication_method.py +121 -0
- ory_client/models/session_device.py +107 -0
- ory_client/models/set_active_project_in_console_body.py +101 -0
- ory_client/models/set_custom_domain_body.py +109 -0
- ory_client/models/set_event_stream_body.py +112 -0
- ory_client/models/set_project.py +118 -0
- ory_client/models/set_project_branding_theme_body.py +115 -0
- ory_client/models/settings_flow.py +145 -0
- ory_client/models/settings_flow_state.py +38 -0
- ory_client/models/source_position.py +103 -0
- ory_client/models/subject_set.py +105 -0
- ory_client/models/subscription.py +179 -0
- ory_client/models/successful_code_exchange_response.py +107 -0
- ory_client/models/successful_native_login.py +117 -0
- ory_client/models/successful_native_registration.py +123 -0
- ory_client/models/successful_project_update.py +115 -0
- ory_client/models/token_pagination.py +104 -0
- ory_client/models/token_pagination_headers.py +103 -0
- ory_client/models/token_pagination_request_parameters.py +104 -0
- ory_client/models/token_pagination_response_headers.py +103 -0
- ory_client/models/trust_o_auth2_jwt_grant_issuer.py +116 -0
- ory_client/models/trusted_o_auth2_jwt_grant_issuer.py +120 -0
- ory_client/models/trusted_o_auth2_jwt_grant_json_web_key.py +103 -0
- ory_client/models/ui_container.py +123 -0
- ory_client/models/ui_node.py +139 -0
- ory_client/models/ui_node_anchor_attributes.py +118 -0
- ory_client/models/ui_node_attributes.py +238 -0
- ory_client/models/ui_node_image_attributes.py +116 -0
- ory_client/models/ui_node_input_attributes.py +154 -0
- ory_client/models/ui_node_meta.py +105 -0
- ory_client/models/ui_node_script_attributes.py +124 -0
- ory_client/models/ui_node_text_attributes.py +116 -0
- ory_client/models/ui_text.py +114 -0
- ory_client/models/update_identity_body.py +132 -0
- ory_client/models/update_login_flow_body.py +286 -0
- ory_client/models/update_login_flow_with_code_method.py +111 -0
- ory_client/models/update_login_flow_with_lookup_secret_method.py +105 -0
- ory_client/models/update_login_flow_with_oidc_method.py +115 -0
- ory_client/models/update_login_flow_with_passkey_method.py +105 -0
- ory_client/models/update_login_flow_with_password_method.py +111 -0
- ory_client/models/update_login_flow_with_totp_method.py +107 -0
- ory_client/models/update_login_flow_with_web_authn_method.py +109 -0
- ory_client/models/update_recovery_flow_body.py +166 -0
- ory_client/models/update_recovery_flow_with_code_method.py +116 -0
- ory_client/models/update_recovery_flow_with_link_method.py +114 -0
- ory_client/models/update_registration_flow_body.py +238 -0
- ory_client/models/update_registration_flow_with_code_method.py +111 -0
- ory_client/models/update_registration_flow_with_oidc_method.py +115 -0
- ory_client/models/update_registration_flow_with_passkey_method.py +109 -0
- ory_client/models/update_registration_flow_with_password_method.py +109 -0
- ory_client/models/update_registration_flow_with_profile_method.py +109 -0
- ory_client/models/update_registration_flow_with_web_authn_method.py +111 -0
- ory_client/models/update_settings_flow_body.py +286 -0
- ory_client/models/update_settings_flow_with_lookup_method.py +113 -0
- ory_client/models/update_settings_flow_with_oidc_method.py +113 -0
- ory_client/models/update_settings_flow_with_passkey_method.py +107 -0
- ory_client/models/update_settings_flow_with_password_method.py +107 -0
- ory_client/models/update_settings_flow_with_profile_method.py +107 -0
- ory_client/models/update_settings_flow_with_totp_method.py +109 -0
- ory_client/models/update_settings_flow_with_web_authn_method.py +111 -0
- ory_client/models/update_subscription_body.py +112 -0
- ory_client/models/update_verification_flow_body.py +166 -0
- ory_client/models/update_verification_flow_with_code_method.py +116 -0
- ory_client/models/update_verification_flow_with_link_method.py +114 -0
- ory_client/models/update_workspace_payload.py +101 -0
- ory_client/models/usage.py +105 -0
- ory_client/models/verifiable_credential_priming_response.py +115 -0
- ory_client/models/verifiable_credential_proof.py +103 -0
- ory_client/models/verifiable_credential_response.py +103 -0
- ory_client/models/verifiable_identity_address.py +123 -0
- ory_client/models/verification_flow.py +129 -0
- ory_client/models/verification_flow_state.py +39 -0
- ory_client/models/version.py +101 -0
- ory_client/models/warning.py +103 -0
- ory_client/models/workspace.py +115 -0
- ory_client/models/workspace_meta.py +122 -0
- ory_client/py.typed +0 -0
- ory_client/rest.py +139 -236
- {ory_client-1.9.0.dist-info → ory_client-1.11.7.dist-info}/METADATA +6 -4
- ory_client-1.11.7.dist-info/RECORD +278 -0
- ory_client/apis/__init__.py +0 -28
- ory_client/model/__init__.py +0 -5
- ory_client/model/accept_o_auth2_consent_request.py +0 -296
- ory_client/model/accept_o_auth2_consent_request_session.py +0 -268
- ory_client/model/accept_o_auth2_login_request.py +0 -308
- ory_client/model/active_project_in_console.py +0 -264
- ory_client/model/attribute.py +0 -268
- ory_client/model/attribute_filter.py +0 -282
- ory_client/model/attributes_count_datapoint.py +0 -276
- ory_client/model/authenticator_assurance_level.py +0 -293
- ory_client/model/batch_patch_identities_response.py +0 -270
- ory_client/model/check_opl_syntax_result.py +0 -270
- ory_client/model/check_permission_result.py +0 -270
- ory_client/model/cloud_account.py +0 -282
- ory_client/model/consistency_request_parameters.py +0 -269
- ory_client/model/continue_with.py +0 -356
- ory_client/model/continue_with_recovery_ui.py +0 -287
- ory_client/model/continue_with_recovery_ui_flow.py +0 -274
- ory_client/model/continue_with_set_ory_session_token.py +0 -281
- ory_client/model/continue_with_settings_ui.py +0 -287
- ory_client/model/continue_with_settings_ui_flow.py +0 -270
- ory_client/model/continue_with_verification_ui.py +0 -287
- ory_client/model/continue_with_verification_ui_flow.py +0 -280
- ory_client/model/courier_message_status.py +0 -293
- ory_client/model/courier_message_type.py +0 -291
- ory_client/model/create_custom_domain_body.py +0 -280
- ory_client/model/create_event_stream_body.py +0 -287
- ory_client/model/create_identity_body.py +0 -314
- ory_client/model/create_invite_response.py +0 -282
- ory_client/model/create_json_web_key_set.py +0 -282
- ory_client/model/create_member_invite_response.py +0 -287
- ory_client/model/create_project_api_key_request.py +0 -270
- ory_client/model/create_project_body.py +0 -284
- ory_client/model/create_project_branding.py +0 -290
- ory_client/model/create_project_member_invite_body.py +0 -264
- ory_client/model/create_project_normalized_payload.py +0 -1119
- ory_client/model/create_recovery_code_for_identity_body.py +0 -279
- ory_client/model/create_recovery_link_for_identity_body.py +0 -279
- ory_client/model/create_relationship_body.py +0 -286
- ory_client/model/create_subscription_body.py +0 -298
- ory_client/model/create_subscription_common.py +0 -292
- ory_client/model/create_verifiable_credential_request_body.py +0 -278
- ory_client/model/create_workspace_member_invite_body.py +0 -264
- ory_client/model/create_workspace_payload.py +0 -270
- ory_client/model/create_workspace_subscription_body.py +0 -292
- ory_client/model/credential_supported_draft00.py +0 -276
- ory_client/model/custom_domain.py +0 -334
- ory_client/model/delete_my_sessions_count.py +0 -264
- ory_client/model/email_template_data.py +0 -282
- ory_client/model/email_template_data_body.py +0 -276
- ory_client/model/error_authenticator_assurance_level_not_satisfied.py +0 -274
- ory_client/model/error_browser_location_change_required.py +0 -274
- ory_client/model/error_flow_replaced.py +0 -274
- ory_client/model/error_generic.py +0 -276
- ory_client/model/error_o_auth2.py +0 -280
- ory_client/model/event_stream.py +0 -284
- ory_client/model/expanded_permission_tree.py +0 -294
- ory_client/model/flow_error.py +0 -282
- ory_client/model/generic_error.py +0 -308
- ory_client/model/generic_error_content.py +0 -280
- ory_client/model/generic_usage.py +0 -276
- ory_client/model/get_attributes_count_response.py +0 -273
- ory_client/model/get_managed_identity_schema_location.py +0 -264
- ory_client/model/get_metrics_event_attributes_response.py +0 -267
- ory_client/model/get_metrics_event_types_response.py +0 -267
- ory_client/model/get_organization_response.py +0 -276
- ory_client/model/get_project_events_body.py +0 -298
- ory_client/model/get_project_events_response.py +0 -278
- ory_client/model/get_project_metrics_response.py +0 -273
- ory_client/model/get_session_activity_response.py +0 -273
- ory_client/model/get_version200_response.py +0 -270
- ory_client/model/health_not_ready_status.py +0 -264
- ory_client/model/health_status.py +0 -264
- ory_client/model/identity.py +0 -342
- ory_client/model/identity_credentials.py +0 -294
- ory_client/model/identity_credentials_code.py +0 -268
- ory_client/model/identity_credentials_oidc.py +0 -270
- ory_client/model/identity_credentials_oidc_provider.py +0 -284
- ory_client/model/identity_credentials_password.py +0 -264
- ory_client/model/identity_patch.py +0 -274
- ory_client/model/identity_patch_response.py +0 -275
- ory_client/model/identity_schema_container.py +0 -268
- ory_client/model/identity_schema_preset.py +0 -276
- ory_client/model/identity_schema_presets.py +0 -292
- ory_client/model/identity_schemas.py +0 -292
- ory_client/model/identity_with_credentials.py +0 -276
- ory_client/model/identity_with_credentials_oidc.py +0 -270
- ory_client/model/identity_with_credentials_oidc_config.py +0 -276
- ory_client/model/identity_with_credentials_oidc_config_provider.py +0 -276
- ory_client/model/identity_with_credentials_password.py +0 -270
- ory_client/model/identity_with_credentials_password_config.py +0 -268
- ory_client/model/internal_get_project_branding_body.py +0 -264
- ory_client/model/internal_is_ax_welcome_screen_enabled_for_project_body.py +0 -276
- ory_client/model/internal_is_owner_for_project_by_slug_body.py +0 -290
- ory_client/model/internal_is_owner_for_project_by_slug_response.py +0 -270
- ory_client/model/introspected_o_auth2_token.py +0 -322
- ory_client/model/is_owner_for_project_by_slug.py +0 -276
- ory_client/model/is_ready200_response.py +0 -270
- ory_client/model/is_ready503_response.py +0 -270
- ory_client/model/json_patch.py +0 -292
- ory_client/model/json_patch_document.py +0 -292
- ory_client/model/json_web_key.py +0 -340
- ory_client/model/json_web_key_set.py +0 -270
- ory_client/model/keto_namespace.py +0 -268
- ory_client/model/keto_namespaces.py +0 -292
- ory_client/model/list_custom_domains.py +0 -292
- ory_client/model/list_event_streams.py +0 -270
- ory_client/model/list_my_workspaces_response.py +0 -288
- ory_client/model/list_organizations_response.py +0 -276
- ory_client/model/list_workspace_projects_response.py +0 -288
- ory_client/model/login_flow.py +0 -370
- ory_client/model/login_flow_state.py +0 -292
- ory_client/model/logout_flow.py +0 -276
- ory_client/model/managed_identity_schema.py +0 -300
- ory_client/model/managed_identity_schema_validation_result.py +0 -268
- ory_client/model/managed_identity_schemas.py +0 -292
- ory_client/model/member_invite.py +0 -321
- ory_client/model/member_invites.py +0 -292
- ory_client/model/message.py +0 -355
- ory_client/model/message_dispatch.py +0 -302
- ory_client/model/metrics_datapoint.py +0 -276
- ory_client/model/migration_options.py +0 -284
- ory_client/model/namespace.py +0 -264
- ory_client/model/needs_privileged_session_error.py +0 -280
- ory_client/model/normalized_project.py +0 -337
- ory_client/model/normalized_project_revision.py +0 -1105
- ory_client/model/normalized_project_revision_courier_channel.py +0 -328
- ory_client/model/normalized_project_revision_hook.py +0 -342
- ory_client/model/normalized_project_revision_identity_schema.py +0 -308
- ory_client/model/normalized_project_revision_identity_schemas.py +0 -292
- ory_client/model/normalized_project_revision_third_party_provider.py +0 -368
- ory_client/model/normalized_project_revision_tokenizer_template.py +0 -300
- ory_client/model/normalized_project_revision_tokenizer_templates.py +0 -292
- ory_client/model/normalized_projects.py +0 -292
- ory_client/model/null_duration.py +0 -292
- ory_client/model/o_auth2_client.py +0 -460
- ory_client/model/o_auth2_client_token_lifespans.py +0 -306
- ory_client/model/o_auth2_consent_request.py +0 -328
- ory_client/model/o_auth2_consent_request_open_id_connect_context.py +0 -280
- ory_client/model/o_auth2_consent_session.py +0 -308
- ory_client/model/o_auth2_consent_session_expires_at.py +0 -280
- ory_client/model/o_auth2_consent_sessions.py +0 -292
- ory_client/model/o_auth2_login_request.py +0 -320
- ory_client/model/o_auth2_logout_request.py +0 -290
- ory_client/model/o_auth2_redirect_to.py +0 -270
- ory_client/model/o_auth2_token_exchange.py +0 -284
- ory_client/model/oidc_configuration.py +0 -412
- ory_client/model/oidc_user_info.py +0 -336
- ory_client/model/organization.py +0 -302
- ory_client/model/organization_body.py +0 -268
- ory_client/model/pagination.py +0 -274
- ory_client/model/pagination_headers.py +0 -268
- ory_client/model/parse_error.py +0 -278
- ory_client/model/patch_identities_body.py +0 -270
- ory_client/model/perform_native_logout_body.py +0 -270
- ory_client/model/permissions_on_project.py +0 -260
- ory_client/model/permissions_on_workpace_response.py +0 -264
- ory_client/model/plan.py +0 -276
- ory_client/model/plan_details.py +0 -316
- ory_client/model/plan_features.py +0 -266
- ory_client/model/plans.py +0 -287
- ory_client/model/post_check_permission_body.py +0 -286
- ory_client/model/post_check_permission_or_error_body.py +0 -286
- ory_client/model/pricing.py +0 -292
- ory_client/model/project.py +0 -319
- ory_client/model/project_api_key.py +0 -298
- ory_client/model/project_api_keys.py +0 -292
- ory_client/model/project_branding.py +0 -303
- ory_client/model/project_branding_colors.py +0 -376
- ory_client/model/project_branding_theme.py +0 -421
- ory_client/model/project_branding_themes.py +0 -292
- ory_client/model/project_cors.py +0 -268
- ory_client/model/project_events_datapoint.py +0 -288
- ory_client/model/project_host.py +0 -281
- ory_client/model/project_member.py +0 -288
- ory_client/model/project_members.py +0 -292
- ory_client/model/project_metadata.py +0 -337
- ory_client/model/project_metadata_list.py +0 -292
- ory_client/model/project_revision_hooks.py +0 -292
- ory_client/model/project_revision_identity_schemas.py +0 -292
- ory_client/model/project_revision_third_party_login_providers.py +0 -292
- ory_client/model/project_revisions.py +0 -292
- ory_client/model/project_service_identity.py +0 -270
- ory_client/model/project_service_o_auth2.py +0 -270
- ory_client/model/project_service_permission.py +0 -270
- ory_client/model/project_services.py +0 -282
- ory_client/model/projects.py +0 -292
- ory_client/model/quota_usage.py +0 -328
- ory_client/model/recovery_code_for_identity.py +0 -280
- ory_client/model/recovery_flow.py +0 -330
- ory_client/model/recovery_flow_state.py +0 -292
- ory_client/model/recovery_identity_address.py +0 -290
- ory_client/model/recovery_link_for_identity.py +0 -274
- ory_client/model/registration_flow.py +0 -352
- ory_client/model/registration_flow_state.py +0 -292
- ory_client/model/reject_o_auth2_request.py +0 -280
- ory_client/model/relation_query.py +0 -286
- ory_client/model/relationship.py +0 -296
- ory_client/model/relationship_namespaces.py +0 -270
- ory_client/model/relationship_patch.py +0 -278
- ory_client/model/relationships.py +0 -274
- ory_client/model/revision_courier_channels.py +0 -292
- ory_client/model/rfc6749_error_json.py +0 -280
- ory_client/model/schema_patch.py +0 -276
- ory_client/model/self_service_flow_expired_error.py +0 -282
- ory_client/model/session.py +0 -318
- ory_client/model/session_activity_datapoint.py +0 -282
- ory_client/model/session_authentication_method.py +0 -297
- ory_client/model/session_authentication_methods.py +0 -292
- ory_client/model/session_device.py +0 -282
- ory_client/model/set_active_project_in_console_body.py +0 -270
- ory_client/model/set_custom_domain_body.py +0 -280
- ory_client/model/set_event_stream_body.py +0 -287
- ory_client/model/set_project.py +0 -296
- ory_client/model/set_project_branding_theme_body.py +0 -290
- ory_client/model/settings_flow.py +0 -338
- ory_client/model/settings_flow_state.py +0 -291
- ory_client/model/source_position.py +0 -268
- ory_client/model/string_slice_json_format.py +0 -287
- ory_client/model/subject_set.py +0 -282
- ory_client/model/subscription.py +0 -350
- ory_client/model/successful_code_exchange_response.py +0 -280
- ory_client/model/successful_native_login.py +0 -280
- ory_client/model/successful_native_registration.py +0 -292
- ory_client/model/successful_project_update.py +0 -284
- ory_client/model/token_pagination.py +0 -274
- ory_client/model/token_pagination_headers.py +0 -268
- ory_client/model/token_pagination_request_parameters.py +0 -274
- ory_client/model/token_pagination_response_headers.py +0 -268
- ory_client/model/trust_o_auth2_jwt_grant_issuer.py +0 -302
- ory_client/model/trusted_o_auth2_jwt_grant_issuer.py +0 -298
- ory_client/model/trusted_o_auth2_jwt_grant_issuers.py +0 -292
- ory_client/model/trusted_o_auth2_jwt_grant_json_web_key.py +0 -268
- ory_client/model/ui_container.py +0 -294
- ory_client/model/ui_node.py +0 -322
- ory_client/model/ui_node_anchor_attributes.py +0 -294
- ory_client/model/ui_node_attributes.py +0 -440
- ory_client/model/ui_node_image_attributes.py +0 -294
- ory_client/model/ui_node_input_attributes.py +0 -340
- ory_client/model/ui_node_meta.py +0 -270
- ory_client/model/ui_node_script_attributes.py +0 -318
- ory_client/model/ui_node_text_attributes.py +0 -288
- ory_client/model/ui_nodes.py +0 -292
- ory_client/model/ui_text.py +0 -291
- ory_client/model/ui_texts.py +0 -292
- ory_client/model/update_identity_body.py +0 -304
- ory_client/model/update_login_flow_body.py +0 -411
- ory_client/model/update_login_flow_with_code_method.py +0 -292
- ory_client/model/update_login_flow_with_lookup_secret_method.py +0 -280
- ory_client/model/update_login_flow_with_oidc_method.py +0 -300
- ory_client/model/update_login_flow_with_password_method.py +0 -294
- ory_client/model/update_login_flow_with_totp_method.py +0 -284
- ory_client/model/update_login_flow_with_web_authn_method.py +0 -288
- ory_client/model/update_recovery_flow_body.py +0 -351
- ory_client/model/update_recovery_flow_with_code_method.py +0 -290
- ory_client/model/update_recovery_flow_with_link_method.py +0 -288
- ory_client/model/update_registration_flow_body.py +0 -389
- ory_client/model/update_registration_flow_with_code_method.py +0 -292
- ory_client/model/update_registration_flow_with_oidc_method.py +0 -300
- ory_client/model/update_registration_flow_with_password_method.py +0 -290
- ory_client/model/update_registration_flow_with_web_authn_method.py +0 -292
- ory_client/model/update_settings_flow_body.py +0 -419
- ory_client/model/update_settings_flow_with_lookup_method.py +0 -294
- ory_client/model/update_settings_flow_with_oidc_method.py +0 -294
- ory_client/model/update_settings_flow_with_password_method.py +0 -284
- ory_client/model/update_settings_flow_with_profile_method.py +0 -284
- ory_client/model/update_settings_flow_with_totp_method.py +0 -286
- ory_client/model/update_settings_flow_with_web_authn_method.py +0 -290
- ory_client/model/update_subscription_body.py +0 -284
- ory_client/model/update_verification_flow_body.py +0 -351
- ory_client/model/update_verification_flow_with_code_method.py +0 -290
- ory_client/model/update_verification_flow_with_link_method.py +0 -288
- ory_client/model/update_workspace_payload.py +0 -270
- ory_client/model/usage.py +0 -270
- ory_client/model/verifiable_credential_priming_response.py +0 -292
- ory_client/model/verifiable_credential_proof.py +0 -268
- ory_client/model/verifiable_credential_response.py +0 -268
- ory_client/model/verifiable_identity_address.py +0 -308
- ory_client/model/verification_flow.py +0 -318
- ory_client/model/verification_flow_state.py +0 -292
- ory_client/model/version.py +0 -264
- ory_client/model/warning.py +0 -268
- ory_client/model/workspace.py +0 -292
- ory_client/model/workspace_meta.py +0 -296
- ory_client/model/workspaces.py +0 -292
- ory_client/model_utils.py +0 -2059
- ory_client-1.9.0.dist-info/RECORD +0 -310
- {ory_client-1.9.0.dist-info → ory_client-1.11.7.dist-info}/LICENSE +0 -0
- {ory_client-1.9.0.dist-info → ory_client-1.11.7.dist-info}/WHEEL +0 -0
- {ory_client-1.9.0.dist-info → ory_client-1.11.7.dist-info}/top_level.txt +0 -0
ory_client/api_client.py
CHANGED
@@ -1,46 +1,47 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
1
3
|
"""
|
2
4
|
Ory APIs
|
3
5
|
|
4
|
-
Documentation for all public and administrative Ory APIs. Administrative APIs can only be accessed with a valid Personal Access Token. Public APIs are mostly used in browsers.
|
6
|
+
Documentation for all public and administrative Ory APIs. Administrative APIs can only be accessed with a valid Personal Access Token. Public APIs are mostly used in browsers.
|
5
7
|
|
6
|
-
The version of the OpenAPI document: v1.
|
8
|
+
The version of the OpenAPI document: v1.11.7
|
7
9
|
Contact: support@ory.sh
|
8
|
-
Generated by
|
9
|
-
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
11
|
+
|
12
|
+
Do not edit the class manually.
|
13
|
+
""" # noqa: E501
|
10
14
|
|
11
15
|
|
16
|
+
import datetime
|
17
|
+
from dateutil.parser import parse
|
18
|
+
from enum import Enum
|
12
19
|
import json
|
13
|
-
import atexit
|
14
20
|
import mimetypes
|
15
|
-
from multiprocessing.pool import ThreadPool
|
16
|
-
import io
|
17
21
|
import os
|
18
22
|
import re
|
19
|
-
import
|
20
|
-
from urllib.parse import quote
|
21
|
-
from urllib3.fields import RequestField
|
23
|
+
import tempfile
|
22
24
|
|
25
|
+
from urllib.parse import quote
|
26
|
+
from typing import Tuple, Optional, List, Dict
|
23
27
|
|
24
|
-
from ory_client import rest
|
25
28
|
from ory_client.configuration import Configuration
|
26
|
-
from ory_client.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
model_to_dict,
|
38
|
-
none_type,
|
39
|
-
validate_and_convert_types
|
29
|
+
from ory_client.api_response import ApiResponse, T as ApiResponseT
|
30
|
+
import ory_client.models
|
31
|
+
from ory_client import rest
|
32
|
+
from ory_client.exceptions import (
|
33
|
+
ApiValueError,
|
34
|
+
ApiException,
|
35
|
+
BadRequestException,
|
36
|
+
UnauthorizedException,
|
37
|
+
ForbiddenException,
|
38
|
+
NotFoundException,
|
39
|
+
ServiceException
|
40
40
|
)
|
41
41
|
|
42
|
+
RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]]
|
42
43
|
|
43
|
-
class ApiClient
|
44
|
+
class ApiClient:
|
44
45
|
"""Generic API client for OpenAPI client library builds.
|
45
46
|
|
46
47
|
OpenAPI generic API client. This client handles the client-
|
@@ -48,28 +49,38 @@ class ApiClient(object):
|
|
48
49
|
the methods and models for each application are generated from the OpenAPI
|
49
50
|
templates.
|
50
51
|
|
51
|
-
NOTE: This class is auto generated by OpenAPI Generator.
|
52
|
-
Ref: https://openapi-generator.tech
|
53
|
-
Do not edit the class manually.
|
54
|
-
|
55
52
|
:param configuration: .Configuration object for this client
|
56
53
|
:param header_name: a header to pass when making calls to the API.
|
57
54
|
:param header_value: a header value to pass when making calls to
|
58
55
|
the API.
|
59
56
|
:param cookie: a cookie to include in the header when making calls
|
60
57
|
to the API
|
61
|
-
:param pool_threads: The number of threads to use for async requests
|
62
|
-
to the API. More threads means more concurrent API requests.
|
63
58
|
"""
|
64
59
|
|
60
|
+
PRIMITIVE_TYPES = (float, bool, bytes, str, int)
|
61
|
+
NATIVE_TYPES_MAPPING = {
|
62
|
+
'int': int,
|
63
|
+
'long': int, # TODO remove as only py3 is supported?
|
64
|
+
'float': float,
|
65
|
+
'str': str,
|
66
|
+
'bool': bool,
|
67
|
+
'date': datetime.date,
|
68
|
+
'datetime': datetime.datetime,
|
69
|
+
'object': object,
|
70
|
+
}
|
65
71
|
_pool = None
|
66
72
|
|
67
|
-
def __init__(
|
68
|
-
|
73
|
+
def __init__(
|
74
|
+
self,
|
75
|
+
configuration=None,
|
76
|
+
header_name=None,
|
77
|
+
header_value=None,
|
78
|
+
cookie=None
|
79
|
+
) -> None:
|
80
|
+
# use default configuration if none is provided
|
69
81
|
if configuration is None:
|
70
|
-
configuration = Configuration.
|
82
|
+
configuration = Configuration.get_default()
|
71
83
|
self.configuration = configuration
|
72
|
-
self.pool_threads = pool_threads
|
73
84
|
|
74
85
|
self.rest_client = rest.RESTClientObject(configuration)
|
75
86
|
self.default_headers = {}
|
@@ -77,31 +88,14 @@ class ApiClient(object):
|
|
77
88
|
self.default_headers[header_name] = header_value
|
78
89
|
self.cookie = cookie
|
79
90
|
# Set default User-Agent.
|
80
|
-
self.user_agent = 'OpenAPI-Generator/v1.
|
91
|
+
self.user_agent = 'OpenAPI-Generator/v1.11.7/python'
|
92
|
+
self.client_side_validation = configuration.client_side_validation
|
81
93
|
|
82
94
|
def __enter__(self):
|
83
95
|
return self
|
84
96
|
|
85
97
|
def __exit__(self, exc_type, exc_value, traceback):
|
86
|
-
|
87
|
-
|
88
|
-
def close(self):
|
89
|
-
if self._pool:
|
90
|
-
self._pool.close()
|
91
|
-
self._pool.join()
|
92
|
-
self._pool = None
|
93
|
-
if hasattr(atexit, 'unregister'):
|
94
|
-
atexit.unregister(self.close)
|
95
|
-
|
96
|
-
@property
|
97
|
-
def pool(self):
|
98
|
-
"""Create thread pool on first request
|
99
|
-
avoids instantiating unused threadpool for blocking clients.
|
100
|
-
"""
|
101
|
-
if self._pool is None:
|
102
|
-
atexit.register(self.close)
|
103
|
-
self._pool = ThreadPool(self.pool_threads)
|
104
|
-
return self._pool
|
98
|
+
pass
|
105
99
|
|
106
100
|
@property
|
107
101
|
def user_agent(self):
|
@@ -115,27 +109,69 @@ class ApiClient(object):
|
|
115
109
|
def set_default_header(self, header_name, header_value):
|
116
110
|
self.default_headers[header_name] = header_value
|
117
111
|
|
118
|
-
|
112
|
+
|
113
|
+
_default = None
|
114
|
+
|
115
|
+
@classmethod
|
116
|
+
def get_default(cls):
|
117
|
+
"""Return new instance of ApiClient.
|
118
|
+
|
119
|
+
This method returns newly created, based on default constructor,
|
120
|
+
object of ApiClient class or returns a copy of default
|
121
|
+
ApiClient.
|
122
|
+
|
123
|
+
:return: The ApiClient object.
|
124
|
+
"""
|
125
|
+
if cls._default is None:
|
126
|
+
cls._default = ApiClient()
|
127
|
+
return cls._default
|
128
|
+
|
129
|
+
@classmethod
|
130
|
+
def set_default(cls, default):
|
131
|
+
"""Set default instance of ApiClient.
|
132
|
+
|
133
|
+
It stores default ApiClient.
|
134
|
+
|
135
|
+
:param default: object of ApiClient.
|
136
|
+
"""
|
137
|
+
cls._default = default
|
138
|
+
|
139
|
+
def param_serialize(
|
119
140
|
self,
|
120
|
-
|
121
|
-
|
122
|
-
path_params
|
123
|
-
query_params
|
124
|
-
header_params
|
125
|
-
body
|
126
|
-
post_params
|
127
|
-
files
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
141
|
+
method,
|
142
|
+
resource_path,
|
143
|
+
path_params=None,
|
144
|
+
query_params=None,
|
145
|
+
header_params=None,
|
146
|
+
body=None,
|
147
|
+
post_params=None,
|
148
|
+
files=None, auth_settings=None,
|
149
|
+
collection_formats=None,
|
150
|
+
_host=None,
|
151
|
+
_request_auth=None
|
152
|
+
) -> RequestSerialized:
|
153
|
+
|
154
|
+
"""Builds the HTTP request params needed by the request.
|
155
|
+
:param method: Method to call.
|
156
|
+
:param resource_path: Path to method endpoint.
|
157
|
+
:param path_params: Path parameters in the url.
|
158
|
+
:param query_params: Query parameters in the url.
|
159
|
+
:param header_params: Header parameters to be
|
160
|
+
placed in the request header.
|
161
|
+
:param body: Request body.
|
162
|
+
:param post_params dict: Request post form parameters,
|
163
|
+
for `application/x-www-form-urlencoded`, `multipart/form-data`.
|
164
|
+
:param auth_settings list: Auth Settings names for the request.
|
165
|
+
:param files dict: key -> filename, value -> filepath,
|
166
|
+
for `multipart/form-data`.
|
167
|
+
:param collection_formats: dict of collection formats for path, query,
|
168
|
+
header, and post parameters.
|
169
|
+
:param _request_auth: set to override the auth_settings for an a single
|
170
|
+
request; this effectively ignores the authentication
|
171
|
+
in the spec for a single request.
|
172
|
+
:return: tuple of form (path, http_method, query_params, header_params,
|
173
|
+
body, post_params, files)
|
174
|
+
"""
|
139
175
|
|
140
176
|
config = self.configuration
|
141
177
|
|
@@ -146,14 +182,17 @@ class ApiClient(object):
|
|
146
182
|
header_params['Cookie'] = self.cookie
|
147
183
|
if header_params:
|
148
184
|
header_params = self.sanitize_for_serialization(header_params)
|
149
|
-
header_params = dict(
|
150
|
-
|
185
|
+
header_params = dict(
|
186
|
+
self.parameters_to_tuples(header_params,collection_formats)
|
187
|
+
)
|
151
188
|
|
152
189
|
# path parameters
|
153
190
|
if path_params:
|
154
191
|
path_params = self.sanitize_for_serialization(path_params)
|
155
|
-
path_params = self.parameters_to_tuples(
|
156
|
-
|
192
|
+
path_params = self.parameters_to_tuples(
|
193
|
+
path_params,
|
194
|
+
collection_formats
|
195
|
+
)
|
157
196
|
for k, v in path_params:
|
158
197
|
# specified safe chars, encode everything
|
159
198
|
resource_path = resource_path.replace(
|
@@ -161,32 +200,31 @@ class ApiClient(object):
|
|
161
200
|
quote(str(v), safe=config.safe_chars_for_path_param)
|
162
201
|
)
|
163
202
|
|
164
|
-
# query parameters
|
165
|
-
if query_params:
|
166
|
-
query_params = self.sanitize_for_serialization(query_params)
|
167
|
-
query_params = self.parameters_to_tuples(query_params,
|
168
|
-
collection_formats)
|
169
|
-
|
170
203
|
# post parameters
|
171
204
|
if post_params or files:
|
172
205
|
post_params = post_params if post_params else []
|
173
206
|
post_params = self.sanitize_for_serialization(post_params)
|
174
|
-
post_params = self.parameters_to_tuples(
|
175
|
-
|
207
|
+
post_params = self.parameters_to_tuples(
|
208
|
+
post_params,
|
209
|
+
collection_formats
|
210
|
+
)
|
176
211
|
post_params.extend(self.files_parameters(files))
|
177
|
-
|
178
|
-
|
179
|
-
|
212
|
+
|
213
|
+
# auth setting
|
214
|
+
self.update_params_for_auth(
|
215
|
+
header_params,
|
216
|
+
query_params,
|
217
|
+
auth_settings,
|
218
|
+
resource_path,
|
219
|
+
method,
|
220
|
+
body,
|
221
|
+
request_auth=_request_auth
|
222
|
+
)
|
180
223
|
|
181
224
|
# body
|
182
225
|
if body:
|
183
226
|
body = self.sanitize_for_serialization(body)
|
184
227
|
|
185
|
-
# auth setting
|
186
|
-
self.update_params_for_auth(header_params, query_params,
|
187
|
-
auth_settings, resource_path, method, body,
|
188
|
-
request_auths=_request_auths)
|
189
|
-
|
190
228
|
# request url
|
191
229
|
if _host is None:
|
192
230
|
url = self.configuration.host + resource_path
|
@@ -194,74 +232,106 @@ class ApiClient(object):
|
|
194
232
|
# use server/host defined in path or operation instead
|
195
233
|
url = _host + resource_path
|
196
234
|
|
235
|
+
# query parameters
|
236
|
+
if query_params:
|
237
|
+
query_params = self.sanitize_for_serialization(query_params)
|
238
|
+
url_query = self.parameters_to_url_query(
|
239
|
+
query_params,
|
240
|
+
collection_formats
|
241
|
+
)
|
242
|
+
url += "?" + url_query
|
243
|
+
|
244
|
+
return method, url, header_params, body, post_params
|
245
|
+
|
246
|
+
|
247
|
+
def call_api(
|
248
|
+
self,
|
249
|
+
method,
|
250
|
+
url,
|
251
|
+
header_params=None,
|
252
|
+
body=None,
|
253
|
+
post_params=None,
|
254
|
+
_request_timeout=None
|
255
|
+
) -> rest.RESTResponse:
|
256
|
+
"""Makes the HTTP request (synchronous)
|
257
|
+
:param method: Method to call.
|
258
|
+
:param url: Path to method endpoint.
|
259
|
+
:param header_params: Header parameters to be
|
260
|
+
placed in the request header.
|
261
|
+
:param body: Request body.
|
262
|
+
:param post_params dict: Request post form parameters,
|
263
|
+
for `application/x-www-form-urlencoded`, `multipart/form-data`.
|
264
|
+
:param _request_timeout: timeout setting for this request.
|
265
|
+
:return: RESTResponse
|
266
|
+
"""
|
267
|
+
|
197
268
|
try:
|
198
269
|
# perform request and return response
|
199
|
-
response_data = self.request(
|
200
|
-
method, url,
|
201
|
-
|
202
|
-
|
203
|
-
_request_timeout=_request_timeout
|
270
|
+
response_data = self.rest_client.request(
|
271
|
+
method, url,
|
272
|
+
headers=header_params,
|
273
|
+
body=body, post_params=post_params,
|
274
|
+
_request_timeout=_request_timeout
|
275
|
+
)
|
276
|
+
|
204
277
|
except ApiException as e:
|
205
|
-
e.body = e.body.decode('utf-8')
|
206
278
|
raise e
|
207
279
|
|
208
|
-
|
280
|
+
return response_data
|
209
281
|
|
210
|
-
|
282
|
+
def response_deserialize(
|
283
|
+
self,
|
284
|
+
response_data: rest.RESTResponse,
|
285
|
+
response_types_map: Optional[Dict[str, ApiResponseT]]=None
|
286
|
+
) -> ApiResponse[ApiResponseT]:
|
287
|
+
"""Deserializes response into an object.
|
288
|
+
:param response_data: RESTResponse object to be deserialized.
|
289
|
+
:param response_types_map: dict of response types.
|
290
|
+
:return: ApiResponse
|
291
|
+
"""
|
292
|
+
|
293
|
+
msg = "RESTResponse.read() must be called before passing it to response_deserialize()"
|
294
|
+
assert response_data.data is not None, msg
|
211
295
|
|
212
|
-
|
213
|
-
|
214
|
-
|
296
|
+
response_type = response_types_map.get(str(response_data.status), None)
|
297
|
+
if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599:
|
298
|
+
# if not found, look for '1XX', '2XX', etc.
|
299
|
+
response_type = response_types_map.get(str(response_data.status)[0] + "XX", None)
|
215
300
|
|
216
301
|
# deserialize response data
|
217
|
-
|
218
|
-
|
219
|
-
|
302
|
+
response_text = None
|
303
|
+
return_data = None
|
304
|
+
try:
|
305
|
+
if response_type == "bytearray":
|
306
|
+
return_data = response_data.data
|
307
|
+
elif response_type == "file":
|
308
|
+
return_data = self.__deserialize_file(response_data)
|
309
|
+
elif response_type is not None:
|
310
|
+
match = None
|
220
311
|
content_type = response_data.getheader('content-type')
|
221
312
|
if content_type is not None:
|
222
|
-
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
return_data = None
|
234
|
-
|
235
|
-
if _return_http_data_only:
|
236
|
-
return (return_data)
|
237
|
-
else:
|
238
|
-
return (return_data, response_data.status,
|
239
|
-
response_data.getheaders())
|
313
|
+
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type)
|
314
|
+
encoding = match.group(1) if match else "utf-8"
|
315
|
+
response_text = response_data.data.decode(encoding)
|
316
|
+
return_data = self.deserialize(response_text, response_type)
|
317
|
+
finally:
|
318
|
+
if not 200 <= response_data.status <= 299:
|
319
|
+
raise ApiException.from_response(
|
320
|
+
http_resp=response_data,
|
321
|
+
body=response_text,
|
322
|
+
data=return_data,
|
323
|
+
)
|
240
324
|
|
241
|
-
|
242
|
-
|
325
|
+
return ApiResponse(
|
326
|
+
status_code = response_data.status,
|
327
|
+
data = return_data,
|
328
|
+
headers = response_data.getheaders(),
|
329
|
+
raw_data = response_data.data
|
330
|
+
)
|
243
331
|
|
244
|
-
|
245
|
-
|
246
|
-
:return: Parameters as list of tuple or urllib3.fields.RequestField
|
247
|
-
"""
|
248
|
-
new_params = []
|
249
|
-
if collection_types is None:
|
250
|
-
collection_types = (dict)
|
251
|
-
for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501
|
252
|
-
if isinstance(
|
253
|
-
v, collection_types): # v is instance of collection_type, formatting as application/json
|
254
|
-
v = json.dumps(v, ensure_ascii=False).encode("utf-8")
|
255
|
-
field = RequestField(k, v)
|
256
|
-
field.make_multipart(content_type="application/json; charset=utf-8")
|
257
|
-
new_params.append(field)
|
258
|
-
else:
|
259
|
-
new_params.append((k, v))
|
260
|
-
return new_params
|
332
|
+
def sanitize_for_serialization(self, obj):
|
333
|
+
"""Builds a JSON POST object.
|
261
334
|
|
262
|
-
@classmethod
|
263
|
-
def sanitize_for_serialization(cls, obj):
|
264
|
-
"""Prepares data for transmission before it is sent with the rest client
|
265
335
|
If obj is None, return None.
|
266
336
|
If obj is str, int, long, float, bool, return directly.
|
267
337
|
If obj is datetime.datetime, datetime.date
|
@@ -269,237 +339,102 @@ class ApiClient(object):
|
|
269
339
|
If obj is list, sanitize each element in the list.
|
270
340
|
If obj is dict, return the dict.
|
271
341
|
If obj is OpenAPI model, return the properties dict.
|
272
|
-
|
342
|
+
|
273
343
|
:param obj: The data to serialize.
|
274
344
|
:return: The serialized form of data.
|
275
345
|
"""
|
276
|
-
if
|
277
|
-
return
|
278
|
-
|
279
|
-
val in model_to_dict(
|
280
|
-
obj,
|
281
|
-
serialize=True).items()}
|
282
|
-
elif isinstance(obj, io.IOBase):
|
283
|
-
return cls.get_file_data_and_close_file(obj)
|
284
|
-
elif isinstance(obj, (str, int, float, none_type, bool)):
|
346
|
+
if obj is None:
|
347
|
+
return None
|
348
|
+
elif isinstance(obj, self.PRIMITIVE_TYPES):
|
285
349
|
return obj
|
286
|
-
elif isinstance(obj,
|
350
|
+
elif isinstance(obj, list):
|
351
|
+
return [
|
352
|
+
self.sanitize_for_serialization(sub_obj) for sub_obj in obj
|
353
|
+
]
|
354
|
+
elif isinstance(obj, tuple):
|
355
|
+
return tuple(
|
356
|
+
self.sanitize_for_serialization(sub_obj) for sub_obj in obj
|
357
|
+
)
|
358
|
+
elif isinstance(obj, (datetime.datetime, datetime.date)):
|
287
359
|
return obj.isoformat()
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
360
|
+
|
361
|
+
elif isinstance(obj, dict):
|
362
|
+
obj_dict = obj
|
363
|
+
else:
|
364
|
+
# Convert model obj to dict except
|
365
|
+
# attributes `openapi_types`, `attribute_map`
|
366
|
+
# and attributes which value is not None.
|
367
|
+
# Convert attribute name to json key in
|
368
|
+
# model definition for request.
|
369
|
+
obj_dict = obj.to_dict()
|
370
|
+
|
371
|
+
return {
|
372
|
+
key: self.sanitize_for_serialization(val)
|
373
|
+
for key, val in obj_dict.items()
|
374
|
+
}
|
375
|
+
|
376
|
+
def deserialize(self, response_text, response_type):
|
299
377
|
"""Deserializes response into an object.
|
300
378
|
|
301
379
|
:param response: RESTResponse object to be deserialized.
|
302
|
-
:param response_type:
|
303
|
-
|
304
|
-
a list containing valid classes (for list schemas)
|
305
|
-
a dict containing a tuple of valid classes as the value
|
306
|
-
Example values:
|
307
|
-
(str,)
|
308
|
-
(Pet,)
|
309
|
-
(float, none_type)
|
310
|
-
([int, none_type],)
|
311
|
-
({str: (bool, str, int, float, date, datetime, str, none_type)},)
|
312
|
-
:param _check_type: boolean, whether to check the types of the data
|
313
|
-
received from the server
|
314
|
-
:type _check_type: bool
|
380
|
+
:param response_type: class literal for
|
381
|
+
deserialized object, or string of class name.
|
315
382
|
|
316
383
|
:return: deserialized object.
|
317
384
|
"""
|
318
|
-
# handle file downloading
|
319
|
-
# save response body into a tmp file and return the instance
|
320
|
-
if response_type == (file_type,):
|
321
|
-
content_disposition = response.getheader("Content-Disposition")
|
322
|
-
return deserialize_file(response.data, self.configuration,
|
323
|
-
content_disposition=content_disposition)
|
324
385
|
|
325
386
|
# fetch data from response object
|
326
387
|
try:
|
327
|
-
|
388
|
+
data = json.loads(response_text)
|
328
389
|
except ValueError:
|
329
|
-
|
330
|
-
|
331
|
-
# store our data under the key of 'received_data' so users have some
|
332
|
-
# context if they are deserializing a string and the data type is wrong
|
333
|
-
deserialized_data = validate_and_convert_types(
|
334
|
-
received_data,
|
335
|
-
response_type,
|
336
|
-
['received_data'],
|
337
|
-
True,
|
338
|
-
_check_type,
|
339
|
-
configuration=self.configuration
|
340
|
-
)
|
341
|
-
return deserialized_data
|
390
|
+
data = response_text
|
342
391
|
|
343
|
-
|
344
|
-
self,
|
345
|
-
resource_path: str,
|
346
|
-
method: str,
|
347
|
-
path_params: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
348
|
-
query_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None,
|
349
|
-
header_params: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
350
|
-
body: typing.Optional[typing.Any] = None,
|
351
|
-
post_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None,
|
352
|
-
files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None,
|
353
|
-
response_type: typing.Optional[typing.Tuple[typing.Any]] = None,
|
354
|
-
auth_settings: typing.Optional[typing.List[str]] = None,
|
355
|
-
async_req: typing.Optional[bool] = None,
|
356
|
-
_return_http_data_only: typing.Optional[bool] = None,
|
357
|
-
collection_formats: typing.Optional[typing.Dict[str, str]] = None,
|
358
|
-
_preload_content: bool = True,
|
359
|
-
_request_timeout: typing.Optional[typing.Union[int, float, typing.Tuple]] = None,
|
360
|
-
_host: typing.Optional[str] = None,
|
361
|
-
_check_type: typing.Optional[bool] = None,
|
362
|
-
_request_auths: typing.Optional[typing.List[typing.Dict[str, typing.Any]]] = None
|
363
|
-
):
|
364
|
-
"""Makes the HTTP request (synchronous) and returns deserialized data.
|
365
|
-
|
366
|
-
To make an async_req request, set the async_req parameter.
|
392
|
+
return self.__deserialize(data, response_type)
|
367
393
|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
:param
|
372
|
-
:param
|
373
|
-
|
374
|
-
:
|
375
|
-
:param post_params dict: Request post form parameters,
|
376
|
-
for `application/x-www-form-urlencoded`, `multipart/form-data`.
|
377
|
-
:param auth_settings list: Auth Settings names for the request.
|
378
|
-
:param response_type: For the response, a tuple containing:
|
379
|
-
valid classes
|
380
|
-
a list containing valid classes (for list schemas)
|
381
|
-
a dict containing a tuple of valid classes as the value
|
382
|
-
Example values:
|
383
|
-
(str,)
|
384
|
-
(Pet,)
|
385
|
-
(float, none_type)
|
386
|
-
([int, none_type],)
|
387
|
-
({str: (bool, str, int, float, date, datetime, str, none_type)},)
|
388
|
-
:param files: key -> field name, value -> a list of open file
|
389
|
-
objects for `multipart/form-data`.
|
390
|
-
:type files: dict
|
391
|
-
:param async_req bool: execute request asynchronously
|
392
|
-
:type async_req: bool, optional
|
393
|
-
:param _return_http_data_only: response data without head status code
|
394
|
-
and headers
|
395
|
-
:type _return_http_data_only: bool, optional
|
396
|
-
:param collection_formats: dict of collection formats for path, query,
|
397
|
-
header, and post parameters.
|
398
|
-
:type collection_formats: dict, optional
|
399
|
-
:param _preload_content: if False, the urllib3.HTTPResponse object will
|
400
|
-
be returned without reading/decoding response
|
401
|
-
data. Default is True.
|
402
|
-
:type _preload_content: bool, optional
|
403
|
-
:param _request_timeout: timeout setting for this request. If one
|
404
|
-
number provided, it will be total request
|
405
|
-
timeout. It can also be a pair (tuple) of
|
406
|
-
(connection, read) timeouts.
|
407
|
-
:param _check_type: boolean describing if the data back from the server
|
408
|
-
should have its type checked.
|
409
|
-
:type _check_type: bool, optional
|
410
|
-
:param _request_auths: set to override the auth_settings for an a single
|
411
|
-
request; this effectively ignores the authentication
|
412
|
-
in the spec for a single request.
|
413
|
-
:type _request_auths: list, optional
|
414
|
-
:return:
|
415
|
-
If async_req parameter is True,
|
416
|
-
the request will be called asynchronously.
|
417
|
-
The method will return the request thread.
|
418
|
-
If parameter async_req is False or missing,
|
419
|
-
then the method will return the response directly.
|
394
|
+
def __deserialize(self, data, klass):
|
395
|
+
"""Deserializes dict, list, str into an object.
|
396
|
+
|
397
|
+
:param data: dict, list or str.
|
398
|
+
:param klass: class literal, or string of class name.
|
399
|
+
|
400
|
+
:return: object.
|
420
401
|
"""
|
421
|
-
if
|
422
|
-
return
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
return self.
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
elif
|
454
|
-
return self.
|
455
|
-
query_params=query_params,
|
456
|
-
_preload_content=_preload_content,
|
457
|
-
_request_timeout=_request_timeout,
|
458
|
-
headers=headers)
|
459
|
-
elif method == "OPTIONS":
|
460
|
-
return self.rest_client.OPTIONS(url,
|
461
|
-
query_params=query_params,
|
462
|
-
headers=headers,
|
463
|
-
post_params=post_params,
|
464
|
-
_preload_content=_preload_content,
|
465
|
-
_request_timeout=_request_timeout,
|
466
|
-
body=body)
|
467
|
-
elif method == "POST":
|
468
|
-
return self.rest_client.POST(url,
|
469
|
-
query_params=query_params,
|
470
|
-
headers=headers,
|
471
|
-
post_params=post_params,
|
472
|
-
_preload_content=_preload_content,
|
473
|
-
_request_timeout=_request_timeout,
|
474
|
-
body=body)
|
475
|
-
elif method == "PUT":
|
476
|
-
return self.rest_client.PUT(url,
|
477
|
-
query_params=query_params,
|
478
|
-
headers=headers,
|
479
|
-
post_params=post_params,
|
480
|
-
_preload_content=_preload_content,
|
481
|
-
_request_timeout=_request_timeout,
|
482
|
-
body=body)
|
483
|
-
elif method == "PATCH":
|
484
|
-
return self.rest_client.PATCH(url,
|
485
|
-
query_params=query_params,
|
486
|
-
headers=headers,
|
487
|
-
post_params=post_params,
|
488
|
-
_preload_content=_preload_content,
|
489
|
-
_request_timeout=_request_timeout,
|
490
|
-
body=body)
|
491
|
-
elif method == "DELETE":
|
492
|
-
return self.rest_client.DELETE(url,
|
493
|
-
query_params=query_params,
|
494
|
-
headers=headers,
|
495
|
-
_preload_content=_preload_content,
|
496
|
-
_request_timeout=_request_timeout,
|
497
|
-
body=body)
|
402
|
+
if data is None:
|
403
|
+
return None
|
404
|
+
|
405
|
+
if isinstance(klass, str):
|
406
|
+
if klass.startswith('List['):
|
407
|
+
m = re.match(r'List\[(.*)]', klass)
|
408
|
+
assert m is not None, "Malformed List type definition"
|
409
|
+
sub_kls = m.group(1)
|
410
|
+
return [self.__deserialize(sub_data, sub_kls)
|
411
|
+
for sub_data in data]
|
412
|
+
|
413
|
+
if klass.startswith('Dict['):
|
414
|
+
m = re.match(r'Dict\[([^,]*), (.*)]', klass)
|
415
|
+
assert m is not None, "Malformed Dict type definition"
|
416
|
+
sub_kls = m.group(2)
|
417
|
+
return {k: self.__deserialize(v, sub_kls)
|
418
|
+
for k, v in data.items()}
|
419
|
+
|
420
|
+
# convert str to class
|
421
|
+
if klass in self.NATIVE_TYPES_MAPPING:
|
422
|
+
klass = self.NATIVE_TYPES_MAPPING[klass]
|
423
|
+
else:
|
424
|
+
klass = getattr(ory_client.models, klass)
|
425
|
+
|
426
|
+
if klass in self.PRIMITIVE_TYPES:
|
427
|
+
return self.__deserialize_primitive(data, klass)
|
428
|
+
elif klass == object:
|
429
|
+
return self.__deserialize_object(data)
|
430
|
+
elif klass == datetime.date:
|
431
|
+
return self.__deserialize_date(data)
|
432
|
+
elif klass == datetime.datetime:
|
433
|
+
return self.__deserialize_datetime(data)
|
434
|
+
elif issubclass(klass, Enum):
|
435
|
+
return self.__deserialize_enum(data, klass)
|
498
436
|
else:
|
499
|
-
|
500
|
-
"http method must be `GET`, `HEAD`, `OPTIONS`,"
|
501
|
-
" `POST`, `PATCH`, `PUT` or `DELETE`."
|
502
|
-
)
|
437
|
+
return self.__deserialize_model(data, klass)
|
503
438
|
|
504
439
|
def parameters_to_tuples(self, params, collection_formats):
|
505
440
|
"""Get parameters as list of tuples, formatting collections.
|
@@ -508,10 +443,10 @@ class ApiClient(object):
|
|
508
443
|
:param dict collection_formats: Parameter collection formats
|
509
444
|
:return: Parameters as list of tuples, collections formatted
|
510
445
|
"""
|
511
|
-
new_params = []
|
446
|
+
new_params: List[Tuple[str, str]] = []
|
512
447
|
if collection_formats is None:
|
513
448
|
collection_formats = {}
|
514
|
-
for k, v in params.items() if isinstance(params, dict) else params:
|
449
|
+
for k, v in params.items() if isinstance(params, dict) else params:
|
515
450
|
if k in collection_formats:
|
516
451
|
collection_format = collection_formats[k]
|
517
452
|
if collection_format == 'multi':
|
@@ -531,118 +466,170 @@ class ApiClient(object):
|
|
531
466
|
new_params.append((k, v))
|
532
467
|
return new_params
|
533
468
|
|
534
|
-
|
535
|
-
|
536
|
-
file_data = file_instance.read()
|
537
|
-
file_instance.close()
|
538
|
-
return file_data
|
469
|
+
def parameters_to_url_query(self, params, collection_formats):
|
470
|
+
"""Get parameters as list of tuples, formatting collections.
|
539
471
|
|
540
|
-
|
541
|
-
|
542
|
-
|
472
|
+
:param params: Parameters as dict or list of two-tuples
|
473
|
+
:param dict collection_formats: Parameter collection formats
|
474
|
+
:return: URL query string (e.g. a=Hello%20World&b=123)
|
475
|
+
"""
|
476
|
+
new_params: List[Tuple[str, str]] = []
|
477
|
+
if collection_formats is None:
|
478
|
+
collection_formats = {}
|
479
|
+
for k, v in params.items() if isinstance(params, dict) else params:
|
480
|
+
if isinstance(v, bool):
|
481
|
+
v = str(v).lower()
|
482
|
+
if isinstance(v, (int, float)):
|
483
|
+
v = str(v)
|
484
|
+
if isinstance(v, dict):
|
485
|
+
v = json.dumps(v)
|
486
|
+
|
487
|
+
if k in collection_formats:
|
488
|
+
collection_format = collection_formats[k]
|
489
|
+
if collection_format == 'multi':
|
490
|
+
new_params.extend((k, str(value)) for value in v)
|
491
|
+
else:
|
492
|
+
if collection_format == 'ssv':
|
493
|
+
delimiter = ' '
|
494
|
+
elif collection_format == 'tsv':
|
495
|
+
delimiter = '\t'
|
496
|
+
elif collection_format == 'pipes':
|
497
|
+
delimiter = '|'
|
498
|
+
else: # csv is the default
|
499
|
+
delimiter = ','
|
500
|
+
new_params.append(
|
501
|
+
(k, delimiter.join(quote(str(value)) for value in v))
|
502
|
+
)
|
503
|
+
else:
|
504
|
+
new_params.append((k, quote(str(v))))
|
505
|
+
|
506
|
+
return "&".join(["=".join(map(str, item)) for item in new_params])
|
507
|
+
|
508
|
+
def files_parameters(self, files=None):
|
543
509
|
"""Builds form parameters.
|
544
510
|
|
545
|
-
:param files:
|
546
|
-
|
547
|
-
:return: List of tuples of form parameters with file data
|
511
|
+
:param files: File parameters.
|
512
|
+
:return: Form parameters with files.
|
548
513
|
"""
|
549
|
-
if files is None:
|
550
|
-
return []
|
551
|
-
|
552
514
|
params = []
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
for file_instance in file_instances:
|
558
|
-
if file_instance is None:
|
559
|
-
# if the file field is nullable, skip None values
|
515
|
+
|
516
|
+
if files:
|
517
|
+
for k, v in files.items():
|
518
|
+
if not v:
|
560
519
|
continue
|
561
|
-
if
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
520
|
+
file_names = v if type(v) is list else [v]
|
521
|
+
for n in file_names:
|
522
|
+
with open(n, 'rb') as f:
|
523
|
+
filename = os.path.basename(f.name)
|
524
|
+
filedata = f.read()
|
525
|
+
mimetype = (
|
526
|
+
mimetypes.guess_type(filename)[0]
|
527
|
+
or 'application/octet-stream'
|
528
|
+
)
|
529
|
+
params.append(
|
530
|
+
tuple([k, tuple([filename, filedata, mimetype])])
|
531
|
+
)
|
572
532
|
|
573
533
|
return params
|
574
534
|
|
575
|
-
def select_header_accept(self, accepts):
|
535
|
+
def select_header_accept(self, accepts: List[str]) -> Optional[str]:
|
576
536
|
"""Returns `Accept` based on an array of accepts provided.
|
577
537
|
|
578
538
|
:param accepts: List of headers.
|
579
539
|
:return: Accept (e.g. application/json).
|
580
540
|
"""
|
581
541
|
if not accepts:
|
582
|
-
return
|
542
|
+
return None
|
583
543
|
|
584
|
-
|
544
|
+
for accept in accepts:
|
545
|
+
if re.search('json', accept, re.IGNORECASE):
|
546
|
+
return accept
|
585
547
|
|
586
|
-
|
587
|
-
return 'application/json'
|
588
|
-
else:
|
589
|
-
return ', '.join(accepts)
|
548
|
+
return accepts[0]
|
590
549
|
|
591
|
-
def select_header_content_type(self, content_types
|
550
|
+
def select_header_content_type(self, content_types):
|
592
551
|
"""Returns `Content-Type` based on an array of content_types provided.
|
593
552
|
|
594
553
|
:param content_types: List of content-types.
|
595
|
-
:param method: http method (e.g. POST, PATCH).
|
596
|
-
:param body: http body to send.
|
597
554
|
:return: Content-Type (e.g. application/json).
|
598
555
|
"""
|
599
556
|
if not content_types:
|
600
557
|
return None
|
601
558
|
|
602
|
-
|
559
|
+
for content_type in content_types:
|
560
|
+
if re.search('json', content_type, re.IGNORECASE):
|
561
|
+
return content_type
|
603
562
|
|
604
|
-
|
605
|
-
'application/json-patch+json' in content_types and
|
606
|
-
isinstance(body, list)):
|
607
|
-
return 'application/json-patch+json'
|
563
|
+
return content_types[0]
|
608
564
|
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
565
|
+
def update_params_for_auth(
|
566
|
+
self,
|
567
|
+
headers,
|
568
|
+
queries,
|
569
|
+
auth_settings,
|
570
|
+
resource_path,
|
571
|
+
method,
|
572
|
+
body,
|
573
|
+
request_auth=None
|
574
|
+
) -> None:
|
616
575
|
"""Updates header and query params based on authentication setting.
|
617
576
|
|
618
577
|
:param headers: Header parameters dict to be updated.
|
619
578
|
:param queries: Query parameters tuple list to be updated.
|
620
579
|
:param auth_settings: Authentication setting identifiers list.
|
621
|
-
:
|
622
|
-
:
|
623
|
-
:
|
624
|
-
|
625
|
-
:param
|
626
|
-
|
580
|
+
:resource_path: A string representation of the HTTP request resource path.
|
581
|
+
:method: A string representation of the HTTP request method.
|
582
|
+
:body: A object representing the body of the HTTP request.
|
583
|
+
The object type is the return value of sanitize_for_serialization().
|
584
|
+
:param request_auth: if set, the provided settings will
|
585
|
+
override the token in the configuration.
|
627
586
|
"""
|
628
587
|
if not auth_settings:
|
629
588
|
return
|
630
589
|
|
631
|
-
if
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
590
|
+
if request_auth:
|
591
|
+
self._apply_auth_params(
|
592
|
+
headers,
|
593
|
+
queries,
|
594
|
+
resource_path,
|
595
|
+
method,
|
596
|
+
body,
|
597
|
+
request_auth
|
598
|
+
)
|
599
|
+
else:
|
600
|
+
for auth in auth_settings:
|
601
|
+
auth_setting = self.configuration.auth_settings().get(auth)
|
602
|
+
if auth_setting:
|
603
|
+
self._apply_auth_params(
|
604
|
+
headers,
|
605
|
+
queries,
|
606
|
+
resource_path,
|
607
|
+
method,
|
608
|
+
body,
|
609
|
+
auth_setting
|
610
|
+
)
|
636
611
|
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
612
|
+
def _apply_auth_params(
|
613
|
+
self,
|
614
|
+
headers,
|
615
|
+
queries,
|
616
|
+
resource_path,
|
617
|
+
method,
|
618
|
+
body,
|
619
|
+
auth_setting
|
620
|
+
) -> None:
|
621
|
+
"""Updates the request parameters based on a single auth_setting
|
642
622
|
|
643
|
-
|
623
|
+
:param headers: Header parameters dict to be updated.
|
624
|
+
:param queries: Query parameters tuple list to be updated.
|
625
|
+
:resource_path: A string representation of the HTTP request resource path.
|
626
|
+
:method: A string representation of the HTTP request method.
|
627
|
+
:body: A object representing the body of the HTTP request.
|
628
|
+
The object type is the return value of sanitize_for_serialization().
|
629
|
+
:param auth_setting: auth settings for the endpoint
|
630
|
+
"""
|
644
631
|
if auth_setting['in'] == 'cookie':
|
645
|
-
headers['Cookie'] = auth_setting['
|
632
|
+
headers['Cookie'] = auth_setting['value']
|
646
633
|
elif auth_setting['in'] == 'header':
|
647
634
|
if auth_setting['type'] != 'http-signature':
|
648
635
|
headers[auth_setting['key']] = auth_setting['value']
|
@@ -653,245 +640,120 @@ class ApiClient(object):
|
|
653
640
|
'Authentication token must be in `query` or `header`'
|
654
641
|
)
|
655
642
|
|
643
|
+
def __deserialize_file(self, response):
|
644
|
+
"""Deserializes body to file
|
656
645
|
|
657
|
-
|
658
|
-
|
659
|
-
headers_map=None, api_client=None, callable=None):
|
660
|
-
"""Creates an endpoint
|
661
|
-
|
662
|
-
Args:
|
663
|
-
settings (dict): see below key value pairs
|
664
|
-
'response_type' (tuple/None): response type
|
665
|
-
'auth' (list): a list of auth type keys
|
666
|
-
'endpoint_path' (str): the endpoint path
|
667
|
-
'operation_id' (str): endpoint string identifier
|
668
|
-
'http_method' (str): POST/PUT/PATCH/GET etc
|
669
|
-
'servers' (list): list of str servers that this endpoint is at
|
670
|
-
params_map (dict): see below key value pairs
|
671
|
-
'all' (list): list of str endpoint parameter names
|
672
|
-
'required' (list): list of required parameter names
|
673
|
-
'nullable' (list): list of nullable parameter names
|
674
|
-
'enum' (list): list of parameters with enum values
|
675
|
-
'validation' (list): list of parameters with validations
|
676
|
-
root_map
|
677
|
-
'validations' (dict): the dict mapping endpoint parameter tuple
|
678
|
-
paths to their validation dictionaries
|
679
|
-
'allowed_values' (dict): the dict mapping endpoint parameter
|
680
|
-
tuple paths to their allowed_values (enum) dictionaries
|
681
|
-
'openapi_types' (dict): param_name to openapi type
|
682
|
-
'attribute_map' (dict): param_name to camelCase name
|
683
|
-
'location_map' (dict): param_name to 'body', 'file', 'form',
|
684
|
-
'header', 'path', 'query'
|
685
|
-
collection_format_map (dict): param_name to `csv` etc.
|
686
|
-
headers_map (dict): see below key value pairs
|
687
|
-
'accept' (list): list of Accept header strings
|
688
|
-
'content_type' (list): list of Content-Type header strings
|
689
|
-
api_client (ApiClient) api client instance
|
690
|
-
callable (function): the function which is invoked when the
|
691
|
-
Endpoint is called
|
692
|
-
"""
|
693
|
-
self.settings = settings
|
694
|
-
self.params_map = params_map
|
695
|
-
self.params_map['all'].extend([
|
696
|
-
'async_req',
|
697
|
-
'_host_index',
|
698
|
-
'_preload_content',
|
699
|
-
'_request_timeout',
|
700
|
-
'_return_http_data_only',
|
701
|
-
'_check_input_type',
|
702
|
-
'_check_return_type',
|
703
|
-
'_content_type',
|
704
|
-
'_spec_property_naming',
|
705
|
-
'_request_auths'
|
706
|
-
])
|
707
|
-
self.params_map['nullable'].extend(['_request_timeout'])
|
708
|
-
self.validations = root_map['validations']
|
709
|
-
self.allowed_values = root_map['allowed_values']
|
710
|
-
self.openapi_types = root_map['openapi_types']
|
711
|
-
extra_types = {
|
712
|
-
'async_req': (bool,),
|
713
|
-
'_host_index': (none_type, int),
|
714
|
-
'_preload_content': (bool,),
|
715
|
-
'_request_timeout': (none_type, float, (float,), [float], int, (int,), [int]),
|
716
|
-
'_return_http_data_only': (bool,),
|
717
|
-
'_check_input_type': (bool,),
|
718
|
-
'_check_return_type': (bool,),
|
719
|
-
'_spec_property_naming': (bool,),
|
720
|
-
'_content_type': (none_type, str),
|
721
|
-
'_request_auths': (none_type, list)
|
722
|
-
}
|
723
|
-
self.openapi_types.update(extra_types)
|
724
|
-
self.attribute_map = root_map['attribute_map']
|
725
|
-
self.location_map = root_map['location_map']
|
726
|
-
self.collection_format_map = root_map['collection_format_map']
|
727
|
-
self.headers_map = headers_map
|
728
|
-
self.api_client = api_client
|
729
|
-
self.callable = callable
|
730
|
-
|
731
|
-
def __validate_inputs(self, kwargs):
|
732
|
-
for param in self.params_map['enum']:
|
733
|
-
if param in kwargs:
|
734
|
-
check_allowed_values(
|
735
|
-
self.allowed_values,
|
736
|
-
(param,),
|
737
|
-
kwargs[param]
|
738
|
-
)
|
739
|
-
|
740
|
-
for param in self.params_map['validation']:
|
741
|
-
if param in kwargs:
|
742
|
-
check_validations(
|
743
|
-
self.validations,
|
744
|
-
(param,),
|
745
|
-
kwargs[param],
|
746
|
-
configuration=self.api_client.configuration
|
747
|
-
)
|
646
|
+
Saves response body into a file in a temporary folder,
|
647
|
+
using the filename from the `Content-Disposition` header if provided.
|
748
648
|
|
749
|
-
|
750
|
-
|
649
|
+
handle file downloading
|
650
|
+
save response body into a tmp file and return the instance
|
751
651
|
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
652
|
+
:param response: RESTResponse.
|
653
|
+
:return: file path.
|
654
|
+
"""
|
655
|
+
fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path)
|
656
|
+
os.close(fd)
|
657
|
+
os.remove(path)
|
658
|
+
|
659
|
+
content_disposition = response.getheader("Content-Disposition")
|
660
|
+
if content_disposition:
|
661
|
+
m = re.search(
|
662
|
+
r'filename=[\'"]?([^\'"\s]+)[\'"]?',
|
663
|
+
content_disposition
|
760
664
|
)
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
params = {
|
765
|
-
'body': None,
|
766
|
-
'collection_format': {},
|
767
|
-
'file': {},
|
768
|
-
'form': [],
|
769
|
-
'header': {},
|
770
|
-
'path': {},
|
771
|
-
'query': []
|
772
|
-
}
|
665
|
+
assert m is not None, "Unexpected 'content-disposition' header value"
|
666
|
+
filename = m.group(1)
|
667
|
+
path = os.path.join(os.path.dirname(path), filename)
|
773
668
|
|
774
|
-
|
775
|
-
|
776
|
-
if param_location is None:
|
777
|
-
continue
|
778
|
-
if param_location:
|
779
|
-
if param_location == 'body':
|
780
|
-
params['body'] = param_value
|
781
|
-
continue
|
782
|
-
base_name = self.attribute_map[param_name]
|
783
|
-
if (param_location == 'form' and
|
784
|
-
self.openapi_types[param_name] == (file_type,)):
|
785
|
-
params['file'][base_name] = [param_value]
|
786
|
-
elif (param_location == 'form' and
|
787
|
-
self.openapi_types[param_name] == ([file_type],)):
|
788
|
-
# param_value is already a list
|
789
|
-
params['file'][base_name] = param_value
|
790
|
-
elif param_location in {'form', 'query'}:
|
791
|
-
param_value_full = (base_name, param_value)
|
792
|
-
params[param_location].append(param_value_full)
|
793
|
-
if param_location not in {'form', 'query'}:
|
794
|
-
params[param_location][base_name] = param_value
|
795
|
-
collection_format = self.collection_format_map.get(param_name)
|
796
|
-
if collection_format:
|
797
|
-
params['collection_format'][base_name] = collection_format
|
669
|
+
with open(path, "wb") as f:
|
670
|
+
f.write(response.data)
|
798
671
|
|
799
|
-
return
|
672
|
+
return path
|
800
673
|
|
801
|
-
def
|
802
|
-
"""
|
803
|
-
Example:
|
674
|
+
def __deserialize_primitive(self, data, klass):
|
675
|
+
"""Deserializes string to primitive type.
|
804
676
|
|
805
|
-
|
806
|
-
|
807
|
-
api_instance.get_courier_message() # this invokes api_instance.get_courier_message.__call__()
|
808
|
-
which then invokes the callable functions stored in that endpoint at
|
809
|
-
api_instance.get_courier_message.callable or self.callable in this class
|
677
|
+
:param data: str.
|
678
|
+
:param klass: class literal.
|
810
679
|
|
680
|
+
:return: int, long, float, str, bool.
|
811
681
|
"""
|
812
|
-
|
682
|
+
try:
|
683
|
+
return klass(data)
|
684
|
+
except UnicodeEncodeError:
|
685
|
+
return str(data)
|
686
|
+
except TypeError:
|
687
|
+
return data
|
688
|
+
|
689
|
+
def __deserialize_object(self, value):
|
690
|
+
"""Return an original value.
|
691
|
+
|
692
|
+
:return: object.
|
693
|
+
"""
|
694
|
+
return value
|
813
695
|
|
814
|
-
def
|
696
|
+
def __deserialize_date(self, string):
|
697
|
+
"""Deserializes string to date.
|
815
698
|
|
699
|
+
:param string: str.
|
700
|
+
:return: date.
|
701
|
+
"""
|
816
702
|
try:
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
index, variables=server_variables, servers=self.settings['servers']
|
703
|
+
return parse(string).date()
|
704
|
+
except ImportError:
|
705
|
+
return string
|
706
|
+
except ValueError:
|
707
|
+
raise rest.ApiException(
|
708
|
+
status=0,
|
709
|
+
reason="Failed to parse `{0}` as date object".format(string)
|
825
710
|
)
|
826
|
-
except IndexError:
|
827
|
-
if self.settings['servers']:
|
828
|
-
raise ApiValueError(
|
829
|
-
"Invalid host index. Must be 0 <= index < %s" %
|
830
|
-
len(self.settings['servers'])
|
831
|
-
)
|
832
|
-
_host = None
|
833
|
-
|
834
|
-
for key, value in kwargs.items():
|
835
|
-
if key not in self.params_map['all']:
|
836
|
-
raise ApiTypeError(
|
837
|
-
"Got an unexpected parameter '%s'"
|
838
|
-
" to method `%s`" %
|
839
|
-
(key, self.settings['operation_id'])
|
840
|
-
)
|
841
|
-
# only throw this nullable ApiValueError if _check_input_type
|
842
|
-
# is False, if _check_input_type==True we catch this case
|
843
|
-
# in self.__validate_inputs
|
844
|
-
if (key not in self.params_map['nullable'] and value is None
|
845
|
-
and kwargs['_check_input_type'] is False):
|
846
|
-
raise ApiValueError(
|
847
|
-
"Value may not be None for non-nullable parameter `%s`"
|
848
|
-
" when calling `%s`" %
|
849
|
-
(key, self.settings['operation_id'])
|
850
|
-
)
|
851
711
|
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
712
|
+
def __deserialize_datetime(self, string):
|
713
|
+
"""Deserializes string to datetime.
|
714
|
+
|
715
|
+
The string should be in iso8601 datetime format.
|
716
|
+
|
717
|
+
:param string: str.
|
718
|
+
:return: datetime.
|
719
|
+
"""
|
720
|
+
try:
|
721
|
+
return parse(string)
|
722
|
+
except ImportError:
|
723
|
+
return string
|
724
|
+
except ValueError:
|
725
|
+
raise rest.ApiException(
|
726
|
+
status=0,
|
727
|
+
reason=(
|
728
|
+
"Failed to parse `{0}` as datetime object"
|
729
|
+
.format(string)
|
857
730
|
)
|
731
|
+
)
|
732
|
+
|
733
|
+
def __deserialize_enum(self, data, klass):
|
734
|
+
"""Deserializes primitive type to enum.
|
858
735
|
|
859
|
-
|
736
|
+
:param data: primitive type.
|
737
|
+
:param klass: class literal.
|
738
|
+
:return: enum value.
|
739
|
+
"""
|
740
|
+
try:
|
741
|
+
return klass(data)
|
742
|
+
except ValueError:
|
743
|
+
raise rest.ApiException(
|
744
|
+
status=0,
|
745
|
+
reason=(
|
746
|
+
"Failed to parse `{0}` as `{1}`"
|
747
|
+
.format(data, klass)
|
748
|
+
)
|
749
|
+
)
|
860
750
|
|
861
|
-
|
751
|
+
def __deserialize_model(self, data, klass):
|
752
|
+
"""Deserializes list or dict to model.
|
862
753
|
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
754
|
+
:param data: dict, list.
|
755
|
+
:param klass: class literal.
|
756
|
+
:return: model object.
|
757
|
+
"""
|
867
758
|
|
868
|
-
|
869
|
-
params['header']['Content-Type'] = kwargs['_content_type']
|
870
|
-
else:
|
871
|
-
content_type_headers_list = self.headers_map['content_type']
|
872
|
-
if content_type_headers_list:
|
873
|
-
if params['body'] != "":
|
874
|
-
content_types_list = self.api_client.select_header_content_type(
|
875
|
-
content_type_headers_list, self.settings['http_method'],
|
876
|
-
params['body'])
|
877
|
-
if content_types_list:
|
878
|
-
params['header']['Content-Type'] = content_types_list
|
879
|
-
|
880
|
-
return self.api_client.call_api(
|
881
|
-
self.settings['endpoint_path'], self.settings['http_method'],
|
882
|
-
params['path'],
|
883
|
-
params['query'],
|
884
|
-
params['header'],
|
885
|
-
body=params['body'],
|
886
|
-
post_params=params['form'],
|
887
|
-
files=params['file'],
|
888
|
-
response_type=self.settings['response_type'],
|
889
|
-
auth_settings=self.settings['auth'],
|
890
|
-
async_req=kwargs['async_req'],
|
891
|
-
_check_type=kwargs['_check_return_type'],
|
892
|
-
_return_http_data_only=kwargs['_return_http_data_only'],
|
893
|
-
_preload_content=kwargs['_preload_content'],
|
894
|
-
_request_timeout=kwargs['_request_timeout'],
|
895
|
-
_host=_host,
|
896
|
-
_request_auths=kwargs['_request_auths'],
|
897
|
-
collection_formats=params['collection_format'])
|
759
|
+
return klass.from_dict(data)
|