blujay 1.0.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.
- blujay/__init__.py +1198 -0
- blujay/_default_clients.py +30 -0
- blujay/_errors.py +105 -0
- blujay/_version.py +2 -0
- blujay/attachments/__init__.py +40 -0
- blujay/attachments/client.py +374 -0
- blujay/attachments/raw_client.py +1058 -0
- blujay/attachments/types/__init__.py +38 -0
- blujay/attachments/types/attachment_create_response.py +30 -0
- blujay/attachments/types/attachment_get_response.py +30 -0
- blujay/calls/__init__.py +4 -0
- blujay/calls/client.py +113 -0
- blujay/calls/raw_client.py +263 -0
- blujay/capability/__init__.py +36 -0
- blujay/capability/client.py +152 -0
- blujay/capability/raw_client.py +302 -0
- blujay/capability/types/__init__.py +34 -0
- blujay/capability/types/capability_evaluate_service_response.py +30 -0
- blujay/chats/__init__.py +72 -0
- blujay/chats/client.py +848 -0
- blujay/chats/messages/__init__.py +40 -0
- blujay/chats/messages/client.py +336 -0
- blujay/chats/messages/raw_client.py +652 -0
- blujay/chats/messages/types/__init__.py +38 -0
- blujay/chats/messages/types/chat_message_list_response.py +30 -0
- blujay/chats/messages/types/chat_message_send_response.py +30 -0
- blujay/chats/participants/__init__.py +42 -0
- blujay/chats/participants/client.py +355 -0
- blujay/chats/participants/raw_client.py +817 -0
- blujay/chats/participants/types/__init__.py +40 -0
- blujay/chats/participants/types/chat_participant_add_response.py +30 -0
- blujay/chats/participants/types/chat_participant_list_response.py +30 -0
- blujay/chats/participants/types/chat_participant_remove_response.py +30 -0
- blujay/chats/raw_client.py +1913 -0
- blujay/chats/types/__init__.py +44 -0
- blujay/chats/types/chat_create_response.py +30 -0
- blujay/chats/types/chat_get_response.py +30 -0
- blujay/chats/types/chat_leave_response.py +30 -0
- blujay/chats/types/chat_list_response.py +30 -0
- blujay/chats/types/chat_update_response.py +30 -0
- blujay/chats/typing/__init__.py +4 -0
- blujay/chats/typing/client.py +186 -0
- blujay/chats/typing/raw_client.py +453 -0
- blujay/client.py +426 -0
- blujay/contacts/__init__.py +87 -0
- blujay/contacts/client.py +1336 -0
- blujay/contacts/notes/__init__.py +40 -0
- blujay/contacts/notes/client.py +248 -0
- blujay/contacts/notes/raw_client.py +549 -0
- blujay/contacts/notes/types/__init__.py +38 -0
- blujay/contacts/notes/types/contact_note_create_response.py +30 -0
- blujay/contacts/notes/types/contact_note_list_response.py +30 -0
- blujay/contacts/raw_client.py +3005 -0
- blujay/contacts/types/__init__.py +74 -0
- blujay/contacts/types/contact_add_tag_response.py +30 -0
- blujay/contacts/types/contact_assign_response.py +30 -0
- blujay/contacts/types/contact_create_response.py +30 -0
- blujay/contacts/types/contact_get_response.py +30 -0
- blujay/contacts/types/contact_list_response.py +30 -0
- blujay/contacts/types/contact_mark_completed_response.py +30 -0
- blujay/contacts/types/contact_opt_out_address_response.py +30 -0
- blujay/contacts/types/contact_opt_out_response.py +30 -0
- blujay/contacts/types/contact_remove_opt_out_response.py +30 -0
- blujay/contacts/types/contact_search_response.py +30 -0
- blujay/contacts/types/contact_stage.py +5 -0
- blujay/contacts/types/contact_update_response.py +30 -0
- blujay/contacts/types/contact_upsert_response.py +30 -0
- blujay/core/__init__.py +139 -0
- blujay/core/api_error.py +62 -0
- blujay/core/client_wrapper.py +146 -0
- blujay/core/datetime_utils.py +70 -0
- blujay/core/file.py +67 -0
- blujay/core/force_multipart.py +18 -0
- blujay/core/http_client.py +1021 -0
- blujay/core/http_response.py +63 -0
- blujay/core/http_sse/__init__.py +42 -0
- blujay/core/http_sse/_api.py +455 -0
- blujay/core/http_sse/_decoders.py +74 -0
- blujay/core/http_sse/_exceptions.py +7 -0
- blujay/core/http_sse/_models.py +17 -0
- blujay/core/jsonable_encoder.py +145 -0
- blujay/core/logging.py +107 -0
- blujay/core/pagination.py +167 -0
- blujay/core/parse_error.py +36 -0
- blujay/core/pydantic_utilities.py +540 -0
- blujay/core/query_encoder.py +58 -0
- blujay/core/remove_none_from_dict.py +11 -0
- blujay/core/request_options.py +41 -0
- blujay/core/serialization.py +349 -0
- blujay/core/unchecked_base_model.py +505 -0
- blujay/environment.py +7 -0
- blujay/errors/__init__.py +71 -0
- blujay/errors/bad_gateway_error.py +11 -0
- blujay/errors/bad_request_error.py +11 -0
- blujay/errors/conflict_error.py +11 -0
- blujay/errors/content_too_large_error.py +11 -0
- blujay/errors/forbidden_error.py +11 -0
- blujay/errors/internal_server_error.py +11 -0
- blujay/errors/not_found_error.py +11 -0
- blujay/errors/service_unavailable_error.py +11 -0
- blujay/errors/too_many_requests_error.py +11 -0
- blujay/errors/unauthorized_error.py +11 -0
- blujay/errors/unprocessable_entity_error.py +11 -0
- blujay/errors/unsupported_media_type_error.py +11 -0
- blujay/me/__init__.py +34 -0
- blujay/me/client.py +100 -0
- blujay/me/raw_client.py +192 -0
- blujay/me/types/__init__.py +34 -0
- blujay/me/types/me_get_response.py +30 -0
- blujay/messages/__init__.py +69 -0
- blujay/messages/client.py +647 -0
- blujay/messages/raw_client.py +1406 -0
- blujay/messages/reactions/__init__.py +40 -0
- blujay/messages/reactions/client.py +315 -0
- blujay/messages/reactions/raw_client.py +741 -0
- blujay/messages/reactions/types/__init__.py +38 -0
- blujay/messages/reactions/types/message_reaction_add_response.py +30 -0
- blujay/messages/reactions/types/message_reaction_remove_response.py +30 -0
- blujay/messages/types/__init__.py +56 -0
- blujay/messages/types/message_edit_response.py +30 -0
- blujay/messages/types/message_get_response.py +30 -0
- blujay/messages/types/message_include.py +5 -0
- blujay/messages/types/message_list_response.py +30 -0
- blujay/messages/types/message_list_thread_order.py +5 -0
- blujay/messages/types/message_list_thread_response.py +30 -0
- blujay/messages/types/message_unsend_response.py +30 -0
- blujay/phone_numbers/__init__.py +54 -0
- blujay/phone_numbers/client.py +203 -0
- blujay/phone_numbers/contact_card/__init__.py +46 -0
- blujay/phone_numbers/contact_card/client.py +402 -0
- blujay/phone_numbers/contact_card/raw_client.py +1065 -0
- blujay/phone_numbers/contact_card/types/__init__.py +44 -0
- blujay/phone_numbers/contact_card/types/phone_number_contact_card_delete_response.py +30 -0
- blujay/phone_numbers/contact_card/types/phone_number_contact_card_get_response.py +30 -0
- blujay/phone_numbers/contact_card/types/phone_number_contact_card_set_response.py +30 -0
- blujay/phone_numbers/raw_client.py +396 -0
- blujay/phone_numbers/types/__init__.py +38 -0
- blujay/phone_numbers/types/phone_number_get_response.py +30 -0
- blujay/phone_numbers/types/phone_number_list_response.py +30 -0
- blujay/py.typed +0 -0
- blujay/requests/__init__.py +97 -0
- blujay/requests/audio_part.py +18 -0
- blujay/requests/bubble_effect.py +10 -0
- blujay/requests/chat_icon_input.py +11 -0
- blujay/requests/link_part.py +13 -0
- blujay/requests/media_part.py +18 -0
- blujay/requests/message_effect.py +8 -0
- blujay/requests/message_input.py +33 -0
- blujay/requests/message_part.py +11 -0
- blujay/requests/message_reply_to.py +26 -0
- blujay/requests/screen_effect.py +10 -0
- blujay/requests/text_decoration.py +19 -0
- blujay/requests/text_part.py +16 -0
- blujay/requests/vcard_email_input.py +9 -0
- blujay/requests/vcard_part.py +14 -0
- blujay/requests/vcard_phone_input.py +13 -0
- blujay/requests/webhook_phone_number_filter.py +21 -0
- blujay/requests/workflow_metadata.py +10 -0
- blujay/requests/workflow_metadata_value.py +5 -0
- blujay/team_members/__init__.py +36 -0
- blujay/team_members/client.py +104 -0
- blujay/team_members/raw_client.py +196 -0
- blujay/team_members/types/__init__.py +34 -0
- blujay/team_members/types/team_member_list_assignable_response.py +30 -0
- blujay/types/__init__.py +896 -0
- blujay/types/accepted_chat_leave.py +27 -0
- blujay/types/accepted_chat_leave_operation.py +5 -0
- blujay/types/accepted_chat_leave_status.py +5 -0
- blujay/types/accepted_chat_metadata_mutation.py +39 -0
- blujay/types/accepted_chat_metadata_mutation_operation.py +7 -0
- blujay/types/accepted_chat_metadata_mutation_status.py +5 -0
- blujay/types/accepted_group_participant_mutation.py +33 -0
- blujay/types/accepted_group_participant_mutation_operation.py +7 -0
- blujay/types/accepted_group_participant_mutation_participant.py +24 -0
- blujay/types/accepted_group_participant_mutation_participant_status.py +5 -0
- blujay/types/accepted_group_participant_mutation_participant_type.py +5 -0
- blujay/types/accepted_group_participant_mutation_status.py +7 -0
- blujay/types/accepted_message.py +23 -0
- blujay/types/accepted_message_reaction.py +35 -0
- blujay/types/accepted_message_reaction_operation.py +5 -0
- blujay/types/accepted_message_reaction_reaction.py +27 -0
- blujay/types/accepted_message_reaction_status.py +5 -0
- blujay/types/api_key_credential.py +24 -0
- blujay/types/api_key_credential_status.py +5 -0
- blujay/types/api_key_credential_type.py +5 -0
- blujay/types/api_key_summary.py +22 -0
- blujay/types/api_key_summary_status.py +5 -0
- blujay/types/assignable_team_member_list.py +21 -0
- blujay/types/assigned_team_member.py +23 -0
- blujay/types/attachment.py +30 -0
- blujay/types/attachment_id.py +3 -0
- blujay/types/attachment_status.py +5 -0
- blujay/types/attachment_upload.py +35 -0
- blujay/types/attachment_upload_upload_headers.py +31 -0
- blujay/types/audio_output_part.py +34 -0
- blujay/types/audio_output_part_type.py +5 -0
- blujay/types/audio_part.py +31 -0
- blujay/types/audio_part_type.py +5 -0
- blujay/types/bubble_effect.py +23 -0
- blujay/types/bubble_effect_name.py +5 -0
- blujay/types/bubble_effect_type.py +5 -0
- blujay/types/call_ended_webhook_data.py +87 -0
- blujay/types/call_ended_webhook_data_direction.py +5 -0
- blujay/types/call_ended_webhook_data_outcome.py +7 -0
- blujay/types/call_ended_webhook_data_type.py +5 -0
- blujay/types/call_ended_webhook_event.py +47 -0
- blujay/types/call_ended_webhook_event_api_version.py +5 -0
- blujay/types/call_id.py +3 -0
- blujay/types/call_recording_ready_webhook_data.py +94 -0
- blujay/types/call_recording_ready_webhook_data_direction.py +5 -0
- blujay/types/call_recording_ready_webhook_data_outcome.py +7 -0
- blujay/types/call_recording_ready_webhook_data_recording.py +30 -0
- blujay/types/call_recording_ready_webhook_data_recording_kind.py +5 -0
- blujay/types/call_recording_ready_webhook_data_summary.py +26 -0
- blujay/types/call_recording_ready_webhook_data_summary_status.py +5 -0
- blujay/types/call_recording_ready_webhook_data_transcript.py +26 -0
- blujay/types/call_recording_ready_webhook_data_transcript_status.py +5 -0
- blujay/types/call_recording_ready_webhook_data_type.py +5 -0
- blujay/types/call_recording_ready_webhook_event.py +47 -0
- blujay/types/call_recording_ready_webhook_event_api_version.py +5 -0
- blujay/types/capability_service_result.py +42 -0
- blujay/types/capability_service_result_service.py +5 -0
- blujay/types/capability_service_result_source.py +5 -0
- blujay/types/chat.py +66 -0
- blujay/types/chat_icon.py +28 -0
- blujay/types/chat_icon_input.py +24 -0
- blujay/types/chat_id.py +3 -0
- blujay/types/chat_list.py +24 -0
- blujay/types/chat_participant.py +8 -0
- blujay/types/chat_service.py +5 -0
- blujay/types/chat_type.py +5 -0
- blujay/types/contact.py +66 -0
- blujay/types/contact_assignment_action_result.py +66 -0
- blujay/types/contact_card_profile.py +52 -0
- blujay/types/contact_card_profile_photo.py +26 -0
- blujay/types/contact_card_profile_photo_content_type.py +5 -0
- blujay/types/contact_card_profile_status.py +5 -0
- blujay/types/contact_id.py +3 -0
- blujay/types/contact_list.py +24 -0
- blujay/types/contact_note.py +39 -0
- blujay/types/contact_note_list.py +24 -0
- blujay/types/contact_note_source.py +5 -0
- blujay/types/contact_search_result.py +21 -0
- blujay/types/contact_stage_action_result.py +66 -0
- blujay/types/contact_suppression.py +27 -0
- blujay/types/contact_suppression_address_type.py +5 -0
- blujay/types/contact_tag_action_result.py +66 -0
- blujay/types/direct_chat_participant.py +37 -0
- blujay/types/direct_chat_participant_type.py +5 -0
- blujay/types/error_envelope.py +35 -0
- blujay/types/error_envelope_status.py +5 -0
- blujay/types/error_object.py +64 -0
- blujay/types/event_id.py +3 -0
- blujay/types/generic_webhook_event.py +46 -0
- blujay/types/generic_webhook_event_api_version.py +5 -0
- blujay/types/group_name_webhook_data.py +26 -0
- blujay/types/group_name_webhook_event.py +47 -0
- blujay/types/group_name_webhook_event_api_version.py +5 -0
- blujay/types/group_participant.py +39 -0
- blujay/types/group_participant_list.py +21 -0
- blujay/types/group_participant_status.py +5 -0
- blujay/types/group_participant_type.py +5 -0
- blujay/types/group_participant_webhook_data.py +27 -0
- blujay/types/group_participant_webhook_event.py +47 -0
- blujay/types/group_participant_webhook_event_api_version.py +5 -0
- blujay/types/group_phone_number.py +46 -0
- blujay/types/group_sendability_reason.py +7 -0
- blujay/types/group_webhook_participant.py +30 -0
- blujay/types/group_webhook_participant_status.py +5 -0
- blujay/types/group_webhook_participant_type.py +5 -0
- blujay/types/link_part.py +26 -0
- blujay/types/link_part_type.py +5 -0
- blujay/types/me.py +29 -0
- blujay/types/media_output_part.py +30 -0
- blujay/types/media_output_part_type.py +5 -0
- blujay/types/media_part.py +31 -0
- blujay/types/media_part_type.py +5 -0
- blujay/types/member_id.py +3 -0
- blujay/types/message.py +159 -0
- blujay/types/message_actionable_failure_code.py +14 -0
- blujay/types/message_degradation.py +25 -0
- blujay/types/message_degradation_code.py +7 -0
- blujay/types/message_direction.py +5 -0
- blujay/types/message_edit_history_entry.py +22 -0
- blujay/types/message_edited_webhook_data.py +64 -0
- blujay/types/message_edited_webhook_event.py +47 -0
- blujay/types/message_edited_webhook_event_api_version.py +5 -0
- blujay/types/message_effect.py +8 -0
- blujay/types/message_failure.py +26 -0
- blujay/types/message_failure_code.py +18 -0
- blujay/types/message_id.py +3 -0
- blujay/types/message_input.py +44 -0
- blujay/types/message_input_preferred_service.py +5 -0
- blujay/types/message_lifecycle_webhook_data.py +88 -0
- blujay/types/message_lifecycle_webhook_data_direction.py +5 -0
- blujay/types/message_lifecycle_webhook_data_requested_service.py +5 -0
- blujay/types/message_lifecycle_webhook_data_service.py +5 -0
- blujay/types/message_lifecycle_webhook_data_status.py +7 -0
- blujay/types/message_lifecycle_webhook_event.py +47 -0
- blujay/types/message_lifecycle_webhook_event_api_version.py +5 -0
- blujay/types/message_list.py +24 -0
- blujay/types/message_output_part.py +10 -0
- blujay/types/message_part.py +11 -0
- blujay/types/message_preferred_service.py +5 -0
- blujay/types/message_reaction.py +46 -0
- blujay/types/message_received_webhook_data.py +95 -0
- blujay/types/message_received_webhook_data_direction.py +5 -0
- blujay/types/message_received_webhook_data_requested_service.py +5 -0
- blujay/types/message_received_webhook_data_service.py +5 -0
- blujay/types/message_received_webhook_data_status.py +5 -0
- blujay/types/message_received_webhook_event.py +47 -0
- blujay/types/message_received_webhook_event_api_version.py +5 -0
- blujay/types/message_reply_to.py +39 -0
- blujay/types/message_reply_to_info.py +34 -0
- blujay/types/message_sender.py +36 -0
- blujay/types/message_sender_type.py +5 -0
- blujay/types/message_service.py +5 -0
- blujay/types/message_status.py +7 -0
- blujay/types/message_team_member_id.py +10 -0
- blujay/types/message_unsent_scope.py +5 -0
- blujay/types/message_unsent_webhook_data.py +64 -0
- blujay/types/message_unsent_webhook_data_unsent_scope.py +5 -0
- blujay/types/message_unsent_webhook_event.py +47 -0
- blujay/types/message_unsent_webhook_event_api_version.py +5 -0
- blujay/types/message_webhook_recipient.py +32 -0
- blujay/types/message_webhook_recipient_type.py +5 -0
- blujay/types/new_message.py +68 -0
- blujay/types/new_message_delivery_status.py +5 -0
- blujay/types/new_message_direction.py +5 -0
- blujay/types/new_message_preferred_service.py +5 -0
- blujay/types/new_message_service.py +5 -0
- blujay/types/phone_number.py +79 -0
- blujay/types/phone_number_access_type.py +5 -0
- blujay/types/phone_number_assigned_webhook_data.py +29 -0
- blujay/types/phone_number_assigned_webhook_event.py +47 -0
- blujay/types/phone_number_assigned_webhook_event_api_version.py +5 -0
- blujay/types/phone_number_capabilities.py +26 -0
- blujay/types/phone_number_capabilities_messaging.py +23 -0
- blujay/types/phone_number_capabilities_voice.py +25 -0
- blujay/types/phone_number_health.py +29 -0
- blujay/types/phone_number_health_status.py +5 -0
- blujay/types/phone_number_id.py +3 -0
- blujay/types/phone_number_limits.py +34 -0
- blujay/types/phone_number_limits_daily.py +27 -0
- blujay/types/phone_number_limits_new_contacts.py +28 -0
- blujay/types/phone_number_line_type.py +5 -0
- blujay/types/phone_number_list.py +21 -0
- blujay/types/phone_number_outbound_policy.py +31 -0
- blujay/types/phone_number_queue.py +26 -0
- blujay/types/phone_number_released_webhook_data.py +29 -0
- blujay/types/phone_number_released_webhook_event.py +47 -0
- blujay/types/phone_number_released_webhook_event_api_version.py +5 -0
- blujay/types/phone_number_send_status.py +33 -0
- blujay/types/phone_number_send_status_reason_code.py +7 -0
- blujay/types/phone_number_status.py +5 -0
- blujay/types/reaction_emoji.py +6 -0
- blujay/types/reaction_kind.py +7 -0
- blujay/types/reaction_reactor.py +8 -0
- blujay/types/reaction_reactor_address.py +22 -0
- blujay/types/reaction_reactor_address_type.py +5 -0
- blujay/types/reaction_reactor_phone_number_id.py +23 -0
- blujay/types/reaction_reactor_phone_number_id_type.py +5 -0
- blujay/types/reaction_sticker.py +32 -0
- blujay/types/reaction_type.py +7 -0
- blujay/types/reaction_webhook_data.py +36 -0
- blujay/types/reaction_webhook_data_reaction.py +37 -0
- blujay/types/reaction_webhook_event.py +47 -0
- blujay/types/reaction_webhook_event_api_version.py +5 -0
- blujay/types/screen_effect.py +23 -0
- blujay/types/screen_effect_name.py +20 -0
- blujay/types/screen_effect_type.py +5 -0
- blujay/types/success_envelope.py +34 -0
- blujay/types/team_member.py +23 -0
- blujay/types/text_decoration.py +30 -0
- blujay/types/text_decoration_style.py +5 -0
- blujay/types/text_part.py +27 -0
- blujay/types/text_part_type.py +5 -0
- blujay/types/trace_id.py +3 -0
- blujay/types/typing_webhook_data.py +39 -0
- blujay/types/typing_webhook_event.py +47 -0
- blujay/types/typing_webhook_event_api_version.py +5 -0
- blujay/types/typing_webhook_participant.py +28 -0
- blujay/types/typing_webhook_participant_type.py +5 -0
- blujay/types/vcard.py +38 -0
- blujay/types/vcard_email.py +22 -0
- blujay/types/vcard_email_input.py +22 -0
- blujay/types/vcard_email_input_type.py +5 -0
- blujay/types/vcard_email_type.py +5 -0
- blujay/types/vcard_fields.py +39 -0
- blujay/types/vcard_id.py +3 -0
- blujay/types/vcard_list.py +24 -0
- blujay/types/vcard_part.py +27 -0
- blujay/types/vcard_part_type.py +5 -0
- blujay/types/vcard_phone.py +26 -0
- blujay/types/vcard_phone_input.py +26 -0
- blujay/types/vcard_phone_input_type.py +5 -0
- blujay/types/vcard_phone_type.py +5 -0
- blujay/types/webhook_delivery_attempt.py +54 -0
- blujay/types/webhook_delivery_attempt_delivery_mode.py +5 -0
- blujay/types/webhook_delivery_attempt_error_code.py +26 -0
- blujay/types/webhook_delivery_attempt_list.py +24 -0
- blujay/types/webhook_delivery_attempt_status.py +5 -0
- blujay/types/webhook_envelope.py +51 -0
- blujay/types/webhook_envelope_api_version.py +5 -0
- blujay/types/webhook_event.py +620 -0
- blujay/types/webhook_event_type.py +31 -0
- blujay/types/webhook_payload_version.py +7 -0
- blujay/types/webhook_phone_number_filter.py +50 -0
- blujay/types/webhook_phone_number_filter_all.py +18 -0
- blujay/types/webhook_phone_number_filter_selected.py +20 -0
- blujay/types/webhook_replay_accepted.py +25 -0
- blujay/types/webhook_replay_accepted_status.py +5 -0
- blujay/types/webhook_subscribable_event_type.py +31 -0
- blujay/types/webhook_subscription.py +38 -0
- blujay/types/webhook_subscription_id.py +3 -0
- blujay/types/webhook_subscription_list.py +24 -0
- blujay/types/webhook_subscription_status.py +5 -0
- blujay/types/webhook_subscription_with_secret.py +43 -0
- blujay/types/workflow.py +22 -0
- blujay/types/workflow_id.py +3 -0
- blujay/types/workflow_list.py +21 -0
- blujay/types/workflow_metadata.py +10 -0
- blujay/types/workflow_metadata_value.py +5 -0
- blujay/types/workflow_run_summary.py +24 -0
- blujay/types/workflow_trigger.py +32 -0
- blujay/types/workspace_id.py +3 -0
- blujay/vcards/__init__.py +44 -0
- blujay/vcards/client.py +578 -0
- blujay/vcards/raw_client.py +1191 -0
- blujay/vcards/types/__init__.py +42 -0
- blujay/vcards/types/vcard_create_response.py +30 -0
- blujay/vcards/types/vcard_get_response.py +30 -0
- blujay/vcards/types/vcard_list_response.py +30 -0
- blujay/vcards/types/vcard_update_response.py +30 -0
- blujay/webhook_subscriptions/__init__.py +55 -0
- blujay/webhook_subscriptions/client.py +804 -0
- blujay/webhook_subscriptions/raw_client.py +1723 -0
- blujay/webhook_subscriptions/types/__init__.py +53 -0
- blujay/webhook_subscriptions/types/webhook_subscription_create_response.py +30 -0
- blujay/webhook_subscriptions/types/webhook_subscription_get_response.py +30 -0
- blujay/webhook_subscriptions/types/webhook_subscription_list_deliveries_response.py +30 -0
- blujay/webhook_subscriptions/types/webhook_subscription_list_response.py +30 -0
- blujay/webhook_subscriptions/types/webhook_subscription_replay_event_response.py +30 -0
- blujay/webhook_subscriptions/types/webhook_subscription_update_response.py +30 -0
- blujay/webhooks.py +124 -0
- blujay/workflows/__init__.py +40 -0
- blujay/workflows/client.py +235 -0
- blujay/workflows/raw_client.py +510 -0
- blujay/workflows/types/__init__.py +38 -0
- blujay/workflows/types/workflow_enroll_response.py +30 -0
- blujay/workflows/types/workflow_list_response.py +30 -0
- blujay-1.0.0.dist-info/METADATA +274 -0
- blujay-1.0.0.dist-info/RECORD +455 -0
- blujay-1.0.0.dist-info/WHEEL +4 -0
- blujay-1.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,1058 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import contextlib
|
|
4
|
+
import typing
|
|
5
|
+
from json.decoder import JSONDecodeError
|
|
6
|
+
|
|
7
|
+
from ..core.api_error import ApiError
|
|
8
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
10
|
+
from ..core.jsonable_encoder import encode_path_param
|
|
11
|
+
from ..core.parse_error import ParsingError
|
|
12
|
+
from ..core.request_options import RequestOptions
|
|
13
|
+
from ..core.unchecked_base_model import construct_type
|
|
14
|
+
from ..errors.bad_request_error import BadRequestError
|
|
15
|
+
from ..errors.conflict_error import ConflictError
|
|
16
|
+
from ..errors.content_too_large_error import ContentTooLargeError
|
|
17
|
+
from ..errors.internal_server_error import InternalServerError
|
|
18
|
+
from ..errors.not_found_error import NotFoundError
|
|
19
|
+
from ..errors.service_unavailable_error import ServiceUnavailableError
|
|
20
|
+
from ..errors.too_many_requests_error import TooManyRequestsError
|
|
21
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
|
22
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
23
|
+
from ..errors.unsupported_media_type_error import UnsupportedMediaTypeError
|
|
24
|
+
from ..types.attachment_id import AttachmentId
|
|
25
|
+
from ..types.error_envelope import ErrorEnvelope
|
|
26
|
+
from .types.attachment_create_response import AttachmentCreateResponse
|
|
27
|
+
from .types.attachment_get_response import AttachmentGetResponse
|
|
28
|
+
from pydantic import ValidationError
|
|
29
|
+
|
|
30
|
+
# this is used as the default value for optional parameters
|
|
31
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class RawAttachmentsClient:
|
|
35
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
36
|
+
self._client_wrapper = client_wrapper
|
|
37
|
+
|
|
38
|
+
def create(
|
|
39
|
+
self,
|
|
40
|
+
*,
|
|
41
|
+
filename: str,
|
|
42
|
+
content_type: str,
|
|
43
|
+
size_bytes: int,
|
|
44
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
45
|
+
) -> HttpResponse[AttachmentCreateResponse]:
|
|
46
|
+
"""
|
|
47
|
+
Starts an upload for a file you can reuse in messages. The response gives you an `upload_url` and `upload_headers`.
|
|
48
|
+
|
|
49
|
+
1. `PUT` the file's raw bytes to `upload_url` with exactly the `upload_headers` returned. Don't use multipart form data. The URL expires after 15 minutes.
|
|
50
|
+
2. Send the `attachment_id` in a `media` message part, or call `GET /v1/attachments/{attachment_id}` to check it.
|
|
51
|
+
|
|
52
|
+
There's no separate "complete" call. Blujay checks the bytes the first time you read the attachment or send it, so the size and type must match what you declared. Files can be up to 100 MiB.
|
|
53
|
+
|
|
54
|
+
Attachment endpoints share a limit of 60 requests per minute per API key.
|
|
55
|
+
|
|
56
|
+
Parameters
|
|
57
|
+
----------
|
|
58
|
+
filename : str
|
|
59
|
+
The file name, without any folder path.
|
|
60
|
+
|
|
61
|
+
content_type : str
|
|
62
|
+
Lowercase MIME type without parameters, for example `image/jpeg`.
|
|
63
|
+
|
|
64
|
+
size_bytes : int
|
|
65
|
+
|
|
66
|
+
request_options : typing.Optional[RequestOptions]
|
|
67
|
+
Request-specific configuration.
|
|
68
|
+
|
|
69
|
+
Returns
|
|
70
|
+
-------
|
|
71
|
+
HttpResponse[AttachmentCreateResponse]
|
|
72
|
+
The upload URL and headers for the new attachment.
|
|
73
|
+
"""
|
|
74
|
+
_request_options_with_retries_disabled: typing.Optional[RequestOptions] = (
|
|
75
|
+
{**request_options, "max_retries": 0} if request_options is not None else {"max_retries": 0}
|
|
76
|
+
)
|
|
77
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
78
|
+
"v1/attachments",
|
|
79
|
+
method="POST",
|
|
80
|
+
json={
|
|
81
|
+
"filename": filename,
|
|
82
|
+
"content_type": content_type,
|
|
83
|
+
"size_bytes": size_bytes,
|
|
84
|
+
},
|
|
85
|
+
headers={
|
|
86
|
+
"content-type": "application/json",
|
|
87
|
+
},
|
|
88
|
+
request_options=_request_options_with_retries_disabled,
|
|
89
|
+
omit=OMIT,
|
|
90
|
+
)
|
|
91
|
+
try:
|
|
92
|
+
if 200 <= _response.status_code < 300:
|
|
93
|
+
_data = typing.cast(
|
|
94
|
+
AttachmentCreateResponse,
|
|
95
|
+
construct_type(
|
|
96
|
+
type_=AttachmentCreateResponse, # type: ignore
|
|
97
|
+
object_=_response.json(),
|
|
98
|
+
),
|
|
99
|
+
)
|
|
100
|
+
return HttpResponse(response=_response, data=_data)
|
|
101
|
+
if _response.status_code == 400:
|
|
102
|
+
raise BadRequestError(
|
|
103
|
+
headers=dict(_response.headers),
|
|
104
|
+
body=typing.cast(
|
|
105
|
+
ErrorEnvelope,
|
|
106
|
+
construct_type(
|
|
107
|
+
type_=ErrorEnvelope, # type: ignore
|
|
108
|
+
object_=_response.json(),
|
|
109
|
+
),
|
|
110
|
+
),
|
|
111
|
+
)
|
|
112
|
+
if _response.status_code == 401:
|
|
113
|
+
raise UnauthorizedError(
|
|
114
|
+
headers=dict(_response.headers),
|
|
115
|
+
body=typing.cast(
|
|
116
|
+
ErrorEnvelope,
|
|
117
|
+
construct_type(
|
|
118
|
+
type_=ErrorEnvelope, # type: ignore
|
|
119
|
+
object_=_response.json(),
|
|
120
|
+
),
|
|
121
|
+
),
|
|
122
|
+
)
|
|
123
|
+
if _response.status_code == 413:
|
|
124
|
+
raise ContentTooLargeError(
|
|
125
|
+
headers=dict(_response.headers),
|
|
126
|
+
body=typing.cast(
|
|
127
|
+
ErrorEnvelope,
|
|
128
|
+
construct_type(
|
|
129
|
+
type_=ErrorEnvelope, # type: ignore
|
|
130
|
+
object_=_response.json(),
|
|
131
|
+
),
|
|
132
|
+
),
|
|
133
|
+
)
|
|
134
|
+
if _response.status_code == 415:
|
|
135
|
+
raise UnsupportedMediaTypeError(
|
|
136
|
+
headers=dict(_response.headers),
|
|
137
|
+
body=typing.cast(
|
|
138
|
+
ErrorEnvelope,
|
|
139
|
+
construct_type(
|
|
140
|
+
type_=ErrorEnvelope, # type: ignore
|
|
141
|
+
object_=_response.json(),
|
|
142
|
+
),
|
|
143
|
+
),
|
|
144
|
+
)
|
|
145
|
+
if _response.status_code == 429:
|
|
146
|
+
raise TooManyRequestsError(
|
|
147
|
+
headers=dict(_response.headers),
|
|
148
|
+
body=typing.cast(
|
|
149
|
+
ErrorEnvelope,
|
|
150
|
+
construct_type(
|
|
151
|
+
type_=ErrorEnvelope, # type: ignore
|
|
152
|
+
object_=_response.json(),
|
|
153
|
+
),
|
|
154
|
+
),
|
|
155
|
+
)
|
|
156
|
+
if _response.status_code == 500:
|
|
157
|
+
raise InternalServerError(
|
|
158
|
+
headers=dict(_response.headers),
|
|
159
|
+
body=typing.cast(
|
|
160
|
+
ErrorEnvelope,
|
|
161
|
+
construct_type(
|
|
162
|
+
type_=ErrorEnvelope, # type: ignore
|
|
163
|
+
object_=_response.json(),
|
|
164
|
+
),
|
|
165
|
+
),
|
|
166
|
+
)
|
|
167
|
+
if _response.status_code == 503:
|
|
168
|
+
raise ServiceUnavailableError(
|
|
169
|
+
headers=dict(_response.headers),
|
|
170
|
+
body=typing.cast(
|
|
171
|
+
ErrorEnvelope,
|
|
172
|
+
construct_type(
|
|
173
|
+
type_=ErrorEnvelope, # type: ignore
|
|
174
|
+
object_=_response.json(),
|
|
175
|
+
),
|
|
176
|
+
),
|
|
177
|
+
)
|
|
178
|
+
_response_json = _response.json()
|
|
179
|
+
except JSONDecodeError:
|
|
180
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
181
|
+
except ValidationError as e:
|
|
182
|
+
raise ParsingError(
|
|
183
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
184
|
+
)
|
|
185
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
186
|
+
|
|
187
|
+
def get(
|
|
188
|
+
self, attachment_id: AttachmentId, *, request_options: typing.Optional[RequestOptions] = None
|
|
189
|
+
) -> HttpResponse[AttachmentGetResponse]:
|
|
190
|
+
"""
|
|
191
|
+
Returns an attachment's details. The first read after an upload checks the uploaded bytes. Until the upload finishes you get `409 ATTACHMENT_NOT_READY`; if the bytes don't match what you declared you get `422 ATTACHMENT_UPLOAD_INVALID`.
|
|
192
|
+
|
|
193
|
+
Parameters
|
|
194
|
+
----------
|
|
195
|
+
attachment_id : AttachmentId
|
|
196
|
+
|
|
197
|
+
request_options : typing.Optional[RequestOptions]
|
|
198
|
+
Request-specific configuration.
|
|
199
|
+
|
|
200
|
+
Returns
|
|
201
|
+
-------
|
|
202
|
+
HttpResponse[AttachmentGetResponse]
|
|
203
|
+
The attachment.
|
|
204
|
+
"""
|
|
205
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
206
|
+
f"v1/attachments/{encode_path_param(attachment_id)}",
|
|
207
|
+
method="GET",
|
|
208
|
+
request_options=request_options,
|
|
209
|
+
)
|
|
210
|
+
try:
|
|
211
|
+
if 200 <= _response.status_code < 300:
|
|
212
|
+
_data = typing.cast(
|
|
213
|
+
AttachmentGetResponse,
|
|
214
|
+
construct_type(
|
|
215
|
+
type_=AttachmentGetResponse, # type: ignore
|
|
216
|
+
object_=_response.json(),
|
|
217
|
+
),
|
|
218
|
+
)
|
|
219
|
+
return HttpResponse(response=_response, data=_data)
|
|
220
|
+
if _response.status_code == 400:
|
|
221
|
+
raise BadRequestError(
|
|
222
|
+
headers=dict(_response.headers),
|
|
223
|
+
body=typing.cast(
|
|
224
|
+
ErrorEnvelope,
|
|
225
|
+
construct_type(
|
|
226
|
+
type_=ErrorEnvelope, # type: ignore
|
|
227
|
+
object_=_response.json(),
|
|
228
|
+
),
|
|
229
|
+
),
|
|
230
|
+
)
|
|
231
|
+
if _response.status_code == 401:
|
|
232
|
+
raise UnauthorizedError(
|
|
233
|
+
headers=dict(_response.headers),
|
|
234
|
+
body=typing.cast(
|
|
235
|
+
ErrorEnvelope,
|
|
236
|
+
construct_type(
|
|
237
|
+
type_=ErrorEnvelope, # type: ignore
|
|
238
|
+
object_=_response.json(),
|
|
239
|
+
),
|
|
240
|
+
),
|
|
241
|
+
)
|
|
242
|
+
if _response.status_code == 404:
|
|
243
|
+
raise NotFoundError(
|
|
244
|
+
headers=dict(_response.headers),
|
|
245
|
+
body=typing.cast(
|
|
246
|
+
ErrorEnvelope,
|
|
247
|
+
construct_type(
|
|
248
|
+
type_=ErrorEnvelope, # type: ignore
|
|
249
|
+
object_=_response.json(),
|
|
250
|
+
),
|
|
251
|
+
),
|
|
252
|
+
)
|
|
253
|
+
if _response.status_code == 409:
|
|
254
|
+
raise ConflictError(
|
|
255
|
+
headers=dict(_response.headers),
|
|
256
|
+
body=typing.cast(
|
|
257
|
+
ErrorEnvelope,
|
|
258
|
+
construct_type(
|
|
259
|
+
type_=ErrorEnvelope, # type: ignore
|
|
260
|
+
object_=_response.json(),
|
|
261
|
+
),
|
|
262
|
+
),
|
|
263
|
+
)
|
|
264
|
+
if _response.status_code == 422:
|
|
265
|
+
raise UnprocessableEntityError(
|
|
266
|
+
headers=dict(_response.headers),
|
|
267
|
+
body=typing.cast(
|
|
268
|
+
ErrorEnvelope,
|
|
269
|
+
construct_type(
|
|
270
|
+
type_=ErrorEnvelope, # type: ignore
|
|
271
|
+
object_=_response.json(),
|
|
272
|
+
),
|
|
273
|
+
),
|
|
274
|
+
)
|
|
275
|
+
if _response.status_code == 429:
|
|
276
|
+
raise TooManyRequestsError(
|
|
277
|
+
headers=dict(_response.headers),
|
|
278
|
+
body=typing.cast(
|
|
279
|
+
ErrorEnvelope,
|
|
280
|
+
construct_type(
|
|
281
|
+
type_=ErrorEnvelope, # type: ignore
|
|
282
|
+
object_=_response.json(),
|
|
283
|
+
),
|
|
284
|
+
),
|
|
285
|
+
)
|
|
286
|
+
if _response.status_code == 500:
|
|
287
|
+
raise InternalServerError(
|
|
288
|
+
headers=dict(_response.headers),
|
|
289
|
+
body=typing.cast(
|
|
290
|
+
ErrorEnvelope,
|
|
291
|
+
construct_type(
|
|
292
|
+
type_=ErrorEnvelope, # type: ignore
|
|
293
|
+
object_=_response.json(),
|
|
294
|
+
),
|
|
295
|
+
),
|
|
296
|
+
)
|
|
297
|
+
if _response.status_code == 503:
|
|
298
|
+
raise ServiceUnavailableError(
|
|
299
|
+
headers=dict(_response.headers),
|
|
300
|
+
body=typing.cast(
|
|
301
|
+
ErrorEnvelope,
|
|
302
|
+
construct_type(
|
|
303
|
+
type_=ErrorEnvelope, # type: ignore
|
|
304
|
+
object_=_response.json(),
|
|
305
|
+
),
|
|
306
|
+
),
|
|
307
|
+
)
|
|
308
|
+
_response_json = _response.json()
|
|
309
|
+
except JSONDecodeError:
|
|
310
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
311
|
+
except ValidationError as e:
|
|
312
|
+
raise ParsingError(
|
|
313
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
314
|
+
)
|
|
315
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
316
|
+
|
|
317
|
+
def delete(
|
|
318
|
+
self, attachment_id: AttachmentId, *, request_options: typing.Optional[RequestOptions] = None
|
|
319
|
+
) -> HttpResponse[None]:
|
|
320
|
+
"""
|
|
321
|
+
Stops the attachment from being sent or downloaded again, effective immediately. Messages that already include it keep their reference to it.
|
|
322
|
+
|
|
323
|
+
Parameters
|
|
324
|
+
----------
|
|
325
|
+
attachment_id : AttachmentId
|
|
326
|
+
|
|
327
|
+
request_options : typing.Optional[RequestOptions]
|
|
328
|
+
Request-specific configuration.
|
|
329
|
+
|
|
330
|
+
Returns
|
|
331
|
+
-------
|
|
332
|
+
HttpResponse[None]
|
|
333
|
+
"""
|
|
334
|
+
_request_options_with_retries_disabled: typing.Optional[RequestOptions] = (
|
|
335
|
+
{**request_options, "max_retries": 0} if request_options is not None else {"max_retries": 0}
|
|
336
|
+
)
|
|
337
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
338
|
+
f"v1/attachments/{encode_path_param(attachment_id)}",
|
|
339
|
+
method="DELETE",
|
|
340
|
+
request_options=_request_options_with_retries_disabled,
|
|
341
|
+
)
|
|
342
|
+
try:
|
|
343
|
+
if 200 <= _response.status_code < 300:
|
|
344
|
+
return HttpResponse(response=_response, data=None)
|
|
345
|
+
if _response.status_code == 400:
|
|
346
|
+
raise BadRequestError(
|
|
347
|
+
headers=dict(_response.headers),
|
|
348
|
+
body=typing.cast(
|
|
349
|
+
ErrorEnvelope,
|
|
350
|
+
construct_type(
|
|
351
|
+
type_=ErrorEnvelope, # type: ignore
|
|
352
|
+
object_=_response.json(),
|
|
353
|
+
),
|
|
354
|
+
),
|
|
355
|
+
)
|
|
356
|
+
if _response.status_code == 401:
|
|
357
|
+
raise UnauthorizedError(
|
|
358
|
+
headers=dict(_response.headers),
|
|
359
|
+
body=typing.cast(
|
|
360
|
+
ErrorEnvelope,
|
|
361
|
+
construct_type(
|
|
362
|
+
type_=ErrorEnvelope, # type: ignore
|
|
363
|
+
object_=_response.json(),
|
|
364
|
+
),
|
|
365
|
+
),
|
|
366
|
+
)
|
|
367
|
+
if _response.status_code == 404:
|
|
368
|
+
raise NotFoundError(
|
|
369
|
+
headers=dict(_response.headers),
|
|
370
|
+
body=typing.cast(
|
|
371
|
+
ErrorEnvelope,
|
|
372
|
+
construct_type(
|
|
373
|
+
type_=ErrorEnvelope, # type: ignore
|
|
374
|
+
object_=_response.json(),
|
|
375
|
+
),
|
|
376
|
+
),
|
|
377
|
+
)
|
|
378
|
+
if _response.status_code == 429:
|
|
379
|
+
raise TooManyRequestsError(
|
|
380
|
+
headers=dict(_response.headers),
|
|
381
|
+
body=typing.cast(
|
|
382
|
+
ErrorEnvelope,
|
|
383
|
+
construct_type(
|
|
384
|
+
type_=ErrorEnvelope, # type: ignore
|
|
385
|
+
object_=_response.json(),
|
|
386
|
+
),
|
|
387
|
+
),
|
|
388
|
+
)
|
|
389
|
+
if _response.status_code == 500:
|
|
390
|
+
raise InternalServerError(
|
|
391
|
+
headers=dict(_response.headers),
|
|
392
|
+
body=typing.cast(
|
|
393
|
+
ErrorEnvelope,
|
|
394
|
+
construct_type(
|
|
395
|
+
type_=ErrorEnvelope, # type: ignore
|
|
396
|
+
object_=_response.json(),
|
|
397
|
+
),
|
|
398
|
+
),
|
|
399
|
+
)
|
|
400
|
+
if _response.status_code == 503:
|
|
401
|
+
raise ServiceUnavailableError(
|
|
402
|
+
headers=dict(_response.headers),
|
|
403
|
+
body=typing.cast(
|
|
404
|
+
ErrorEnvelope,
|
|
405
|
+
construct_type(
|
|
406
|
+
type_=ErrorEnvelope, # type: ignore
|
|
407
|
+
object_=_response.json(),
|
|
408
|
+
),
|
|
409
|
+
),
|
|
410
|
+
)
|
|
411
|
+
_response_json = _response.json()
|
|
412
|
+
except JSONDecodeError:
|
|
413
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
414
|
+
except ValidationError as e:
|
|
415
|
+
raise ParsingError(
|
|
416
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
417
|
+
)
|
|
418
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
419
|
+
|
|
420
|
+
@contextlib.contextmanager
|
|
421
|
+
def download(
|
|
422
|
+
self, attachment_id: AttachmentId, *, request_options: typing.Optional[RequestOptions] = None
|
|
423
|
+
) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]:
|
|
424
|
+
"""
|
|
425
|
+
Returns the attachment's file. Authenticate the same way as any other API call. Message parts link here through `download_url`.
|
|
426
|
+
|
|
427
|
+
Parameters
|
|
428
|
+
----------
|
|
429
|
+
attachment_id : AttachmentId
|
|
430
|
+
|
|
431
|
+
request_options : typing.Optional[RequestOptions]
|
|
432
|
+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
|
433
|
+
|
|
434
|
+
Returns
|
|
435
|
+
-------
|
|
436
|
+
typing.Iterator[HttpResponse[typing.Iterator[bytes]]]
|
|
437
|
+
The file.
|
|
438
|
+
"""
|
|
439
|
+
with self._client_wrapper.httpx_client.stream(
|
|
440
|
+
f"v1/attachments/{encode_path_param(attachment_id)}/content",
|
|
441
|
+
method="GET",
|
|
442
|
+
request_options=request_options,
|
|
443
|
+
) as _response:
|
|
444
|
+
|
|
445
|
+
def _stream() -> HttpResponse[typing.Iterator[bytes]]:
|
|
446
|
+
try:
|
|
447
|
+
if 200 <= _response.status_code < 300:
|
|
448
|
+
_chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
|
|
449
|
+
return HttpResponse(
|
|
450
|
+
response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size))
|
|
451
|
+
)
|
|
452
|
+
_response.read()
|
|
453
|
+
if _response.status_code == 400:
|
|
454
|
+
raise BadRequestError(
|
|
455
|
+
headers=dict(_response.headers),
|
|
456
|
+
body=typing.cast(
|
|
457
|
+
ErrorEnvelope,
|
|
458
|
+
construct_type(
|
|
459
|
+
type_=ErrorEnvelope, # type: ignore
|
|
460
|
+
object_=_response.json(),
|
|
461
|
+
),
|
|
462
|
+
),
|
|
463
|
+
)
|
|
464
|
+
if _response.status_code == 401:
|
|
465
|
+
raise UnauthorizedError(
|
|
466
|
+
headers=dict(_response.headers),
|
|
467
|
+
body=typing.cast(
|
|
468
|
+
ErrorEnvelope,
|
|
469
|
+
construct_type(
|
|
470
|
+
type_=ErrorEnvelope, # type: ignore
|
|
471
|
+
object_=_response.json(),
|
|
472
|
+
),
|
|
473
|
+
),
|
|
474
|
+
)
|
|
475
|
+
if _response.status_code == 404:
|
|
476
|
+
raise NotFoundError(
|
|
477
|
+
headers=dict(_response.headers),
|
|
478
|
+
body=typing.cast(
|
|
479
|
+
ErrorEnvelope,
|
|
480
|
+
construct_type(
|
|
481
|
+
type_=ErrorEnvelope, # type: ignore
|
|
482
|
+
object_=_response.json(),
|
|
483
|
+
),
|
|
484
|
+
),
|
|
485
|
+
)
|
|
486
|
+
if _response.status_code == 409:
|
|
487
|
+
raise ConflictError(
|
|
488
|
+
headers=dict(_response.headers),
|
|
489
|
+
body=typing.cast(
|
|
490
|
+
ErrorEnvelope,
|
|
491
|
+
construct_type(
|
|
492
|
+
type_=ErrorEnvelope, # type: ignore
|
|
493
|
+
object_=_response.json(),
|
|
494
|
+
),
|
|
495
|
+
),
|
|
496
|
+
)
|
|
497
|
+
if _response.status_code == 429:
|
|
498
|
+
raise TooManyRequestsError(
|
|
499
|
+
headers=dict(_response.headers),
|
|
500
|
+
body=typing.cast(
|
|
501
|
+
ErrorEnvelope,
|
|
502
|
+
construct_type(
|
|
503
|
+
type_=ErrorEnvelope, # type: ignore
|
|
504
|
+
object_=_response.json(),
|
|
505
|
+
),
|
|
506
|
+
),
|
|
507
|
+
)
|
|
508
|
+
if _response.status_code == 500:
|
|
509
|
+
raise InternalServerError(
|
|
510
|
+
headers=dict(_response.headers),
|
|
511
|
+
body=typing.cast(
|
|
512
|
+
ErrorEnvelope,
|
|
513
|
+
construct_type(
|
|
514
|
+
type_=ErrorEnvelope, # type: ignore
|
|
515
|
+
object_=_response.json(),
|
|
516
|
+
),
|
|
517
|
+
),
|
|
518
|
+
)
|
|
519
|
+
if _response.status_code == 503:
|
|
520
|
+
raise ServiceUnavailableError(
|
|
521
|
+
headers=dict(_response.headers),
|
|
522
|
+
body=typing.cast(
|
|
523
|
+
ErrorEnvelope,
|
|
524
|
+
construct_type(
|
|
525
|
+
type_=ErrorEnvelope, # type: ignore
|
|
526
|
+
object_=_response.json(),
|
|
527
|
+
),
|
|
528
|
+
),
|
|
529
|
+
)
|
|
530
|
+
_response_json = _response.json()
|
|
531
|
+
except JSONDecodeError:
|
|
532
|
+
raise ApiError(
|
|
533
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
|
|
534
|
+
)
|
|
535
|
+
except ValidationError as e:
|
|
536
|
+
raise ParsingError(
|
|
537
|
+
status_code=_response.status_code,
|
|
538
|
+
headers=dict(_response.headers),
|
|
539
|
+
body=_response.json(),
|
|
540
|
+
cause=e,
|
|
541
|
+
)
|
|
542
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
543
|
+
|
|
544
|
+
yield _stream()
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
class AsyncRawAttachmentsClient:
|
|
548
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
549
|
+
self._client_wrapper = client_wrapper
|
|
550
|
+
|
|
551
|
+
async def create(
|
|
552
|
+
self,
|
|
553
|
+
*,
|
|
554
|
+
filename: str,
|
|
555
|
+
content_type: str,
|
|
556
|
+
size_bytes: int,
|
|
557
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
558
|
+
) -> AsyncHttpResponse[AttachmentCreateResponse]:
|
|
559
|
+
"""
|
|
560
|
+
Starts an upload for a file you can reuse in messages. The response gives you an `upload_url` and `upload_headers`.
|
|
561
|
+
|
|
562
|
+
1. `PUT` the file's raw bytes to `upload_url` with exactly the `upload_headers` returned. Don't use multipart form data. The URL expires after 15 minutes.
|
|
563
|
+
2. Send the `attachment_id` in a `media` message part, or call `GET /v1/attachments/{attachment_id}` to check it.
|
|
564
|
+
|
|
565
|
+
There's no separate "complete" call. Blujay checks the bytes the first time you read the attachment or send it, so the size and type must match what you declared. Files can be up to 100 MiB.
|
|
566
|
+
|
|
567
|
+
Attachment endpoints share a limit of 60 requests per minute per API key.
|
|
568
|
+
|
|
569
|
+
Parameters
|
|
570
|
+
----------
|
|
571
|
+
filename : str
|
|
572
|
+
The file name, without any folder path.
|
|
573
|
+
|
|
574
|
+
content_type : str
|
|
575
|
+
Lowercase MIME type without parameters, for example `image/jpeg`.
|
|
576
|
+
|
|
577
|
+
size_bytes : int
|
|
578
|
+
|
|
579
|
+
request_options : typing.Optional[RequestOptions]
|
|
580
|
+
Request-specific configuration.
|
|
581
|
+
|
|
582
|
+
Returns
|
|
583
|
+
-------
|
|
584
|
+
AsyncHttpResponse[AttachmentCreateResponse]
|
|
585
|
+
The upload URL and headers for the new attachment.
|
|
586
|
+
"""
|
|
587
|
+
_request_options_with_retries_disabled: typing.Optional[RequestOptions] = (
|
|
588
|
+
{**request_options, "max_retries": 0} if request_options is not None else {"max_retries": 0}
|
|
589
|
+
)
|
|
590
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
591
|
+
"v1/attachments",
|
|
592
|
+
method="POST",
|
|
593
|
+
json={
|
|
594
|
+
"filename": filename,
|
|
595
|
+
"content_type": content_type,
|
|
596
|
+
"size_bytes": size_bytes,
|
|
597
|
+
},
|
|
598
|
+
headers={
|
|
599
|
+
"content-type": "application/json",
|
|
600
|
+
},
|
|
601
|
+
request_options=_request_options_with_retries_disabled,
|
|
602
|
+
omit=OMIT,
|
|
603
|
+
)
|
|
604
|
+
try:
|
|
605
|
+
if 200 <= _response.status_code < 300:
|
|
606
|
+
_data = typing.cast(
|
|
607
|
+
AttachmentCreateResponse,
|
|
608
|
+
construct_type(
|
|
609
|
+
type_=AttachmentCreateResponse, # type: ignore
|
|
610
|
+
object_=_response.json(),
|
|
611
|
+
),
|
|
612
|
+
)
|
|
613
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
614
|
+
if _response.status_code == 400:
|
|
615
|
+
raise BadRequestError(
|
|
616
|
+
headers=dict(_response.headers),
|
|
617
|
+
body=typing.cast(
|
|
618
|
+
ErrorEnvelope,
|
|
619
|
+
construct_type(
|
|
620
|
+
type_=ErrorEnvelope, # type: ignore
|
|
621
|
+
object_=_response.json(),
|
|
622
|
+
),
|
|
623
|
+
),
|
|
624
|
+
)
|
|
625
|
+
if _response.status_code == 401:
|
|
626
|
+
raise UnauthorizedError(
|
|
627
|
+
headers=dict(_response.headers),
|
|
628
|
+
body=typing.cast(
|
|
629
|
+
ErrorEnvelope,
|
|
630
|
+
construct_type(
|
|
631
|
+
type_=ErrorEnvelope, # type: ignore
|
|
632
|
+
object_=_response.json(),
|
|
633
|
+
),
|
|
634
|
+
),
|
|
635
|
+
)
|
|
636
|
+
if _response.status_code == 413:
|
|
637
|
+
raise ContentTooLargeError(
|
|
638
|
+
headers=dict(_response.headers),
|
|
639
|
+
body=typing.cast(
|
|
640
|
+
ErrorEnvelope,
|
|
641
|
+
construct_type(
|
|
642
|
+
type_=ErrorEnvelope, # type: ignore
|
|
643
|
+
object_=_response.json(),
|
|
644
|
+
),
|
|
645
|
+
),
|
|
646
|
+
)
|
|
647
|
+
if _response.status_code == 415:
|
|
648
|
+
raise UnsupportedMediaTypeError(
|
|
649
|
+
headers=dict(_response.headers),
|
|
650
|
+
body=typing.cast(
|
|
651
|
+
ErrorEnvelope,
|
|
652
|
+
construct_type(
|
|
653
|
+
type_=ErrorEnvelope, # type: ignore
|
|
654
|
+
object_=_response.json(),
|
|
655
|
+
),
|
|
656
|
+
),
|
|
657
|
+
)
|
|
658
|
+
if _response.status_code == 429:
|
|
659
|
+
raise TooManyRequestsError(
|
|
660
|
+
headers=dict(_response.headers),
|
|
661
|
+
body=typing.cast(
|
|
662
|
+
ErrorEnvelope,
|
|
663
|
+
construct_type(
|
|
664
|
+
type_=ErrorEnvelope, # type: ignore
|
|
665
|
+
object_=_response.json(),
|
|
666
|
+
),
|
|
667
|
+
),
|
|
668
|
+
)
|
|
669
|
+
if _response.status_code == 500:
|
|
670
|
+
raise InternalServerError(
|
|
671
|
+
headers=dict(_response.headers),
|
|
672
|
+
body=typing.cast(
|
|
673
|
+
ErrorEnvelope,
|
|
674
|
+
construct_type(
|
|
675
|
+
type_=ErrorEnvelope, # type: ignore
|
|
676
|
+
object_=_response.json(),
|
|
677
|
+
),
|
|
678
|
+
),
|
|
679
|
+
)
|
|
680
|
+
if _response.status_code == 503:
|
|
681
|
+
raise ServiceUnavailableError(
|
|
682
|
+
headers=dict(_response.headers),
|
|
683
|
+
body=typing.cast(
|
|
684
|
+
ErrorEnvelope,
|
|
685
|
+
construct_type(
|
|
686
|
+
type_=ErrorEnvelope, # type: ignore
|
|
687
|
+
object_=_response.json(),
|
|
688
|
+
),
|
|
689
|
+
),
|
|
690
|
+
)
|
|
691
|
+
_response_json = _response.json()
|
|
692
|
+
except JSONDecodeError:
|
|
693
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
694
|
+
except ValidationError as e:
|
|
695
|
+
raise ParsingError(
|
|
696
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
697
|
+
)
|
|
698
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
699
|
+
|
|
700
|
+
async def get(
|
|
701
|
+
self, attachment_id: AttachmentId, *, request_options: typing.Optional[RequestOptions] = None
|
|
702
|
+
) -> AsyncHttpResponse[AttachmentGetResponse]:
|
|
703
|
+
"""
|
|
704
|
+
Returns an attachment's details. The first read after an upload checks the uploaded bytes. Until the upload finishes you get `409 ATTACHMENT_NOT_READY`; if the bytes don't match what you declared you get `422 ATTACHMENT_UPLOAD_INVALID`.
|
|
705
|
+
|
|
706
|
+
Parameters
|
|
707
|
+
----------
|
|
708
|
+
attachment_id : AttachmentId
|
|
709
|
+
|
|
710
|
+
request_options : typing.Optional[RequestOptions]
|
|
711
|
+
Request-specific configuration.
|
|
712
|
+
|
|
713
|
+
Returns
|
|
714
|
+
-------
|
|
715
|
+
AsyncHttpResponse[AttachmentGetResponse]
|
|
716
|
+
The attachment.
|
|
717
|
+
"""
|
|
718
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
719
|
+
f"v1/attachments/{encode_path_param(attachment_id)}",
|
|
720
|
+
method="GET",
|
|
721
|
+
request_options=request_options,
|
|
722
|
+
)
|
|
723
|
+
try:
|
|
724
|
+
if 200 <= _response.status_code < 300:
|
|
725
|
+
_data = typing.cast(
|
|
726
|
+
AttachmentGetResponse,
|
|
727
|
+
construct_type(
|
|
728
|
+
type_=AttachmentGetResponse, # type: ignore
|
|
729
|
+
object_=_response.json(),
|
|
730
|
+
),
|
|
731
|
+
)
|
|
732
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
733
|
+
if _response.status_code == 400:
|
|
734
|
+
raise BadRequestError(
|
|
735
|
+
headers=dict(_response.headers),
|
|
736
|
+
body=typing.cast(
|
|
737
|
+
ErrorEnvelope,
|
|
738
|
+
construct_type(
|
|
739
|
+
type_=ErrorEnvelope, # type: ignore
|
|
740
|
+
object_=_response.json(),
|
|
741
|
+
),
|
|
742
|
+
),
|
|
743
|
+
)
|
|
744
|
+
if _response.status_code == 401:
|
|
745
|
+
raise UnauthorizedError(
|
|
746
|
+
headers=dict(_response.headers),
|
|
747
|
+
body=typing.cast(
|
|
748
|
+
ErrorEnvelope,
|
|
749
|
+
construct_type(
|
|
750
|
+
type_=ErrorEnvelope, # type: ignore
|
|
751
|
+
object_=_response.json(),
|
|
752
|
+
),
|
|
753
|
+
),
|
|
754
|
+
)
|
|
755
|
+
if _response.status_code == 404:
|
|
756
|
+
raise NotFoundError(
|
|
757
|
+
headers=dict(_response.headers),
|
|
758
|
+
body=typing.cast(
|
|
759
|
+
ErrorEnvelope,
|
|
760
|
+
construct_type(
|
|
761
|
+
type_=ErrorEnvelope, # type: ignore
|
|
762
|
+
object_=_response.json(),
|
|
763
|
+
),
|
|
764
|
+
),
|
|
765
|
+
)
|
|
766
|
+
if _response.status_code == 409:
|
|
767
|
+
raise ConflictError(
|
|
768
|
+
headers=dict(_response.headers),
|
|
769
|
+
body=typing.cast(
|
|
770
|
+
ErrorEnvelope,
|
|
771
|
+
construct_type(
|
|
772
|
+
type_=ErrorEnvelope, # type: ignore
|
|
773
|
+
object_=_response.json(),
|
|
774
|
+
),
|
|
775
|
+
),
|
|
776
|
+
)
|
|
777
|
+
if _response.status_code == 422:
|
|
778
|
+
raise UnprocessableEntityError(
|
|
779
|
+
headers=dict(_response.headers),
|
|
780
|
+
body=typing.cast(
|
|
781
|
+
ErrorEnvelope,
|
|
782
|
+
construct_type(
|
|
783
|
+
type_=ErrorEnvelope, # type: ignore
|
|
784
|
+
object_=_response.json(),
|
|
785
|
+
),
|
|
786
|
+
),
|
|
787
|
+
)
|
|
788
|
+
if _response.status_code == 429:
|
|
789
|
+
raise TooManyRequestsError(
|
|
790
|
+
headers=dict(_response.headers),
|
|
791
|
+
body=typing.cast(
|
|
792
|
+
ErrorEnvelope,
|
|
793
|
+
construct_type(
|
|
794
|
+
type_=ErrorEnvelope, # type: ignore
|
|
795
|
+
object_=_response.json(),
|
|
796
|
+
),
|
|
797
|
+
),
|
|
798
|
+
)
|
|
799
|
+
if _response.status_code == 500:
|
|
800
|
+
raise InternalServerError(
|
|
801
|
+
headers=dict(_response.headers),
|
|
802
|
+
body=typing.cast(
|
|
803
|
+
ErrorEnvelope,
|
|
804
|
+
construct_type(
|
|
805
|
+
type_=ErrorEnvelope, # type: ignore
|
|
806
|
+
object_=_response.json(),
|
|
807
|
+
),
|
|
808
|
+
),
|
|
809
|
+
)
|
|
810
|
+
if _response.status_code == 503:
|
|
811
|
+
raise ServiceUnavailableError(
|
|
812
|
+
headers=dict(_response.headers),
|
|
813
|
+
body=typing.cast(
|
|
814
|
+
ErrorEnvelope,
|
|
815
|
+
construct_type(
|
|
816
|
+
type_=ErrorEnvelope, # type: ignore
|
|
817
|
+
object_=_response.json(),
|
|
818
|
+
),
|
|
819
|
+
),
|
|
820
|
+
)
|
|
821
|
+
_response_json = _response.json()
|
|
822
|
+
except JSONDecodeError:
|
|
823
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
824
|
+
except ValidationError as e:
|
|
825
|
+
raise ParsingError(
|
|
826
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
827
|
+
)
|
|
828
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
829
|
+
|
|
830
|
+
async def delete(
|
|
831
|
+
self, attachment_id: AttachmentId, *, request_options: typing.Optional[RequestOptions] = None
|
|
832
|
+
) -> AsyncHttpResponse[None]:
|
|
833
|
+
"""
|
|
834
|
+
Stops the attachment from being sent or downloaded again, effective immediately. Messages that already include it keep their reference to it.
|
|
835
|
+
|
|
836
|
+
Parameters
|
|
837
|
+
----------
|
|
838
|
+
attachment_id : AttachmentId
|
|
839
|
+
|
|
840
|
+
request_options : typing.Optional[RequestOptions]
|
|
841
|
+
Request-specific configuration.
|
|
842
|
+
|
|
843
|
+
Returns
|
|
844
|
+
-------
|
|
845
|
+
AsyncHttpResponse[None]
|
|
846
|
+
"""
|
|
847
|
+
_request_options_with_retries_disabled: typing.Optional[RequestOptions] = (
|
|
848
|
+
{**request_options, "max_retries": 0} if request_options is not None else {"max_retries": 0}
|
|
849
|
+
)
|
|
850
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
851
|
+
f"v1/attachments/{encode_path_param(attachment_id)}",
|
|
852
|
+
method="DELETE",
|
|
853
|
+
request_options=_request_options_with_retries_disabled,
|
|
854
|
+
)
|
|
855
|
+
try:
|
|
856
|
+
if 200 <= _response.status_code < 300:
|
|
857
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
858
|
+
if _response.status_code == 400:
|
|
859
|
+
raise BadRequestError(
|
|
860
|
+
headers=dict(_response.headers),
|
|
861
|
+
body=typing.cast(
|
|
862
|
+
ErrorEnvelope,
|
|
863
|
+
construct_type(
|
|
864
|
+
type_=ErrorEnvelope, # type: ignore
|
|
865
|
+
object_=_response.json(),
|
|
866
|
+
),
|
|
867
|
+
),
|
|
868
|
+
)
|
|
869
|
+
if _response.status_code == 401:
|
|
870
|
+
raise UnauthorizedError(
|
|
871
|
+
headers=dict(_response.headers),
|
|
872
|
+
body=typing.cast(
|
|
873
|
+
ErrorEnvelope,
|
|
874
|
+
construct_type(
|
|
875
|
+
type_=ErrorEnvelope, # type: ignore
|
|
876
|
+
object_=_response.json(),
|
|
877
|
+
),
|
|
878
|
+
),
|
|
879
|
+
)
|
|
880
|
+
if _response.status_code == 404:
|
|
881
|
+
raise NotFoundError(
|
|
882
|
+
headers=dict(_response.headers),
|
|
883
|
+
body=typing.cast(
|
|
884
|
+
ErrorEnvelope,
|
|
885
|
+
construct_type(
|
|
886
|
+
type_=ErrorEnvelope, # type: ignore
|
|
887
|
+
object_=_response.json(),
|
|
888
|
+
),
|
|
889
|
+
),
|
|
890
|
+
)
|
|
891
|
+
if _response.status_code == 429:
|
|
892
|
+
raise TooManyRequestsError(
|
|
893
|
+
headers=dict(_response.headers),
|
|
894
|
+
body=typing.cast(
|
|
895
|
+
ErrorEnvelope,
|
|
896
|
+
construct_type(
|
|
897
|
+
type_=ErrorEnvelope, # type: ignore
|
|
898
|
+
object_=_response.json(),
|
|
899
|
+
),
|
|
900
|
+
),
|
|
901
|
+
)
|
|
902
|
+
if _response.status_code == 500:
|
|
903
|
+
raise InternalServerError(
|
|
904
|
+
headers=dict(_response.headers),
|
|
905
|
+
body=typing.cast(
|
|
906
|
+
ErrorEnvelope,
|
|
907
|
+
construct_type(
|
|
908
|
+
type_=ErrorEnvelope, # type: ignore
|
|
909
|
+
object_=_response.json(),
|
|
910
|
+
),
|
|
911
|
+
),
|
|
912
|
+
)
|
|
913
|
+
if _response.status_code == 503:
|
|
914
|
+
raise ServiceUnavailableError(
|
|
915
|
+
headers=dict(_response.headers),
|
|
916
|
+
body=typing.cast(
|
|
917
|
+
ErrorEnvelope,
|
|
918
|
+
construct_type(
|
|
919
|
+
type_=ErrorEnvelope, # type: ignore
|
|
920
|
+
object_=_response.json(),
|
|
921
|
+
),
|
|
922
|
+
),
|
|
923
|
+
)
|
|
924
|
+
_response_json = _response.json()
|
|
925
|
+
except JSONDecodeError:
|
|
926
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
927
|
+
except ValidationError as e:
|
|
928
|
+
raise ParsingError(
|
|
929
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
930
|
+
)
|
|
931
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
932
|
+
|
|
933
|
+
@contextlib.asynccontextmanager
|
|
934
|
+
async def download(
|
|
935
|
+
self, attachment_id: AttachmentId, *, request_options: typing.Optional[RequestOptions] = None
|
|
936
|
+
) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]:
|
|
937
|
+
"""
|
|
938
|
+
Returns the attachment's file. Authenticate the same way as any other API call. Message parts link here through `download_url`.
|
|
939
|
+
|
|
940
|
+
Parameters
|
|
941
|
+
----------
|
|
942
|
+
attachment_id : AttachmentId
|
|
943
|
+
|
|
944
|
+
request_options : typing.Optional[RequestOptions]
|
|
945
|
+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
|
946
|
+
|
|
947
|
+
Returns
|
|
948
|
+
-------
|
|
949
|
+
typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]
|
|
950
|
+
The file.
|
|
951
|
+
"""
|
|
952
|
+
async with self._client_wrapper.httpx_client.stream(
|
|
953
|
+
f"v1/attachments/{encode_path_param(attachment_id)}/content",
|
|
954
|
+
method="GET",
|
|
955
|
+
request_options=request_options,
|
|
956
|
+
) as _response:
|
|
957
|
+
|
|
958
|
+
async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]:
|
|
959
|
+
try:
|
|
960
|
+
if 200 <= _response.status_code < 300:
|
|
961
|
+
_chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
|
|
962
|
+
return AsyncHttpResponse(
|
|
963
|
+
response=_response,
|
|
964
|
+
data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)),
|
|
965
|
+
)
|
|
966
|
+
await _response.aread()
|
|
967
|
+
if _response.status_code == 400:
|
|
968
|
+
raise BadRequestError(
|
|
969
|
+
headers=dict(_response.headers),
|
|
970
|
+
body=typing.cast(
|
|
971
|
+
ErrorEnvelope,
|
|
972
|
+
construct_type(
|
|
973
|
+
type_=ErrorEnvelope, # type: ignore
|
|
974
|
+
object_=_response.json(),
|
|
975
|
+
),
|
|
976
|
+
),
|
|
977
|
+
)
|
|
978
|
+
if _response.status_code == 401:
|
|
979
|
+
raise UnauthorizedError(
|
|
980
|
+
headers=dict(_response.headers),
|
|
981
|
+
body=typing.cast(
|
|
982
|
+
ErrorEnvelope,
|
|
983
|
+
construct_type(
|
|
984
|
+
type_=ErrorEnvelope, # type: ignore
|
|
985
|
+
object_=_response.json(),
|
|
986
|
+
),
|
|
987
|
+
),
|
|
988
|
+
)
|
|
989
|
+
if _response.status_code == 404:
|
|
990
|
+
raise NotFoundError(
|
|
991
|
+
headers=dict(_response.headers),
|
|
992
|
+
body=typing.cast(
|
|
993
|
+
ErrorEnvelope,
|
|
994
|
+
construct_type(
|
|
995
|
+
type_=ErrorEnvelope, # type: ignore
|
|
996
|
+
object_=_response.json(),
|
|
997
|
+
),
|
|
998
|
+
),
|
|
999
|
+
)
|
|
1000
|
+
if _response.status_code == 409:
|
|
1001
|
+
raise ConflictError(
|
|
1002
|
+
headers=dict(_response.headers),
|
|
1003
|
+
body=typing.cast(
|
|
1004
|
+
ErrorEnvelope,
|
|
1005
|
+
construct_type(
|
|
1006
|
+
type_=ErrorEnvelope, # type: ignore
|
|
1007
|
+
object_=_response.json(),
|
|
1008
|
+
),
|
|
1009
|
+
),
|
|
1010
|
+
)
|
|
1011
|
+
if _response.status_code == 429:
|
|
1012
|
+
raise TooManyRequestsError(
|
|
1013
|
+
headers=dict(_response.headers),
|
|
1014
|
+
body=typing.cast(
|
|
1015
|
+
ErrorEnvelope,
|
|
1016
|
+
construct_type(
|
|
1017
|
+
type_=ErrorEnvelope, # type: ignore
|
|
1018
|
+
object_=_response.json(),
|
|
1019
|
+
),
|
|
1020
|
+
),
|
|
1021
|
+
)
|
|
1022
|
+
if _response.status_code == 500:
|
|
1023
|
+
raise InternalServerError(
|
|
1024
|
+
headers=dict(_response.headers),
|
|
1025
|
+
body=typing.cast(
|
|
1026
|
+
ErrorEnvelope,
|
|
1027
|
+
construct_type(
|
|
1028
|
+
type_=ErrorEnvelope, # type: ignore
|
|
1029
|
+
object_=_response.json(),
|
|
1030
|
+
),
|
|
1031
|
+
),
|
|
1032
|
+
)
|
|
1033
|
+
if _response.status_code == 503:
|
|
1034
|
+
raise ServiceUnavailableError(
|
|
1035
|
+
headers=dict(_response.headers),
|
|
1036
|
+
body=typing.cast(
|
|
1037
|
+
ErrorEnvelope,
|
|
1038
|
+
construct_type(
|
|
1039
|
+
type_=ErrorEnvelope, # type: ignore
|
|
1040
|
+
object_=_response.json(),
|
|
1041
|
+
),
|
|
1042
|
+
),
|
|
1043
|
+
)
|
|
1044
|
+
_response_json = _response.json()
|
|
1045
|
+
except JSONDecodeError:
|
|
1046
|
+
raise ApiError(
|
|
1047
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
|
|
1048
|
+
)
|
|
1049
|
+
except ValidationError as e:
|
|
1050
|
+
raise ParsingError(
|
|
1051
|
+
status_code=_response.status_code,
|
|
1052
|
+
headers=dict(_response.headers),
|
|
1053
|
+
body=_response.json(),
|
|
1054
|
+
cause=e,
|
|
1055
|
+
)
|
|
1056
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1057
|
+
|
|
1058
|
+
yield await _stream()
|