frameio 0.0.23__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.
Potentially problematic release.
This version of frameio might be problematic. Click here for more details.
- frameio/__init__.py +1115 -0
- frameio/account_permissions/__init__.py +4 -0
- frameio/account_permissions/client.py +182 -0
- frameio/account_permissions/raw_client.py +301 -0
- frameio/accounts/__init__.py +4 -0
- frameio/accounts/client.py +151 -0
- frameio/accounts/raw_client.py +281 -0
- frameio/client.py +439 -0
- frameio/comments/__init__.py +34 -0
- frameio/comments/client.py +596 -0
- frameio/comments/raw_client.py +1252 -0
- frameio/comments/types/__init__.py +38 -0
- frameio/comments/types/create_comment_params_data.py +25 -0
- frameio/comments/types/update_comment_params_data.py +25 -0
- frameio/core/__init__.py +110 -0
- frameio/core/api_error.py +23 -0
- frameio/core/client_wrapper.py +87 -0
- frameio/core/datetime_utils.py +28 -0
- frameio/core/file.py +67 -0
- frameio/core/force_multipart.py +18 -0
- frameio/core/http_client.py +543 -0
- frameio/core/http_response.py +55 -0
- frameio/core/jsonable_encoder.py +100 -0
- frameio/core/pagination.py +82 -0
- frameio/core/pydantic_utilities.py +258 -0
- frameio/core/query_encoder.py +58 -0
- frameio/core/remove_none_from_dict.py +11 -0
- frameio/core/request_options.py +35 -0
- frameio/core/serialization.py +276 -0
- frameio/environment.py +7 -0
- frameio/errors/__init__.py +53 -0
- frameio/errors/bad_request_error.py +11 -0
- frameio/errors/forbidden_error.py +11 -0
- frameio/errors/not_found_error.py +11 -0
- frameio/errors/too_many_requests_error.py +11 -0
- frameio/errors/unauthorized_error.py +11 -0
- frameio/errors/unprocessable_entity_error.py +10 -0
- frameio/files/__init__.py +55 -0
- frameio/files/client.py +1136 -0
- frameio/files/raw_client.py +2492 -0
- frameio/files/types/__init__.py +53 -0
- frameio/files/types/file_copy_params_data.py +15 -0
- frameio/files/types/file_create_local_upload_params_data.py +20 -0
- frameio/files/types/file_create_params_data.py +31 -0
- frameio/files/types/file_create_remote_upload_params_data.py +20 -0
- frameio/files/types/file_move_params_data.py +15 -0
- frameio/files/types/file_update_params_data.py +15 -0
- frameio/folders/__init__.py +39 -0
- frameio/folders/client.py +988 -0
- frameio/folders/raw_client.py +2058 -0
- frameio/folders/types/__init__.py +42 -0
- frameio/folders/types/folder_copy_params_data.py +15 -0
- frameio/folders/types/folder_create_params_data.py +15 -0
- frameio/folders/types/folder_move_params_data.py +15 -0
- frameio/folders/types/folder_update_params_data.py +15 -0
- frameio/metadata/__init__.py +37 -0
- frameio/metadata/client.py +291 -0
- frameio/metadata/raw_client.py +509 -0
- frameio/metadata/types/__init__.py +38 -0
- frameio/metadata/types/bulk_update_metadata_params_data.py +23 -0
- frameio/metadata/types/bulk_update_metadata_params_data_values_item.py +13 -0
- frameio/metadata_fields/__init__.py +103 -0
- frameio/metadata_fields/client.py +536 -0
- frameio/metadata_fields/raw_client.py +996 -0
- frameio/metadata_fields/types/__init__.py +105 -0
- frameio/metadata_fields/types/create_field_definition_params_data.py +108 -0
- frameio/metadata_fields/types/update_field_definition_params_data.py +114 -0
- frameio/project_permissions/__init__.py +4 -0
- frameio/project_permissions/client.py +415 -0
- frameio/project_permissions/raw_client.py +789 -0
- frameio/projects/__init__.py +4 -0
- frameio/projects/client.py +582 -0
- frameio/projects/raw_client.py +1250 -0
- frameio/py.typed +0 -0
- frameio/shares/__init__.py +64 -0
- frameio/shares/client.py +1192 -0
- frameio/shares/raw_client.py +2446 -0
- frameio/shares/types/__init__.py +61 -0
- frameio/shares/types/add_asset_params_data.py +15 -0
- frameio/shares/types/add_reviewers_to_share_params_data.py +18 -0
- frameio/shares/types/add_reviewers_to_share_params_data_reviewers.py +27 -0
- frameio/shares/types/create_share_params_data.py +25 -0
- frameio/shares/types/remove_reviewer_params_data.py +13 -0
- frameio/shares/types/remove_reviewer_params_data_reviewers.py +27 -0
- frameio/shares/types/update_share_params_data.py +33 -0
- frameio/shares/types/update_share_params_data_access.py +5 -0
- frameio/types/__init__.py +959 -0
- frameio/types/account.py +65 -0
- frameio/types/account_roles_item.py +5 -0
- frameio/types/account_user_role.py +23 -0
- frameio/types/account_user_role_role.py +5 -0
- frameio/types/account_user_roles_response.py +27 -0
- frameio/types/accounts_response.py +23 -0
- frameio/types/add_asset_response.py +13 -0
- frameio/types/add_asset_response_data.py +15 -0
- frameio/types/asset_common.py +48 -0
- frameio/types/asset_common_type.py +5 -0
- frameio/types/asset_common_with_includes.py +56 -0
- frameio/types/asset_include.py +5 -0
- frameio/types/asset_share_params.py +38 -0
- frameio/types/asset_share_params_access.py +5 -0
- frameio/types/asset_with_includes.py +72 -0
- frameio/types/assets_with_includes_response.py +23 -0
- frameio/types/bad_request.py +13 -0
- frameio/types/bad_request_errors_item.py +15 -0
- frameio/types/bad_request_errors_item_source.py +12 -0
- frameio/types/boolean_value.py +12 -0
- frameio/types/children_type.py +3 -0
- frameio/types/comment.py +52 -0
- frameio/types/comment_include.py +5 -0
- frameio/types/comment_response.py +13 -0
- frameio/types/comment_with_includes.py +17 -0
- frameio/types/comment_with_includes_response.py +13 -0
- frameio/types/comments_with_includes_response.py +23 -0
- frameio/types/date_definition.py +43 -0
- frameio/types/date_definition_field_configuration.py +21 -0
- frameio/types/date_definition_field_configuration_display_format.py +7 -0
- frameio/types/date_definition_field_configuration_time_format.py +5 -0
- frameio/types/date_definition_params.py +17 -0
- frameio/types/date_definition_params_field_configuration.py +23 -0
- frameio/types/date_definition_params_field_configuration_display_format.py +7 -0
- frameio/types/date_definition_params_field_configuration_time_format.py +7 -0
- frameio/types/date_definition_with_includes.py +13 -0
- frameio/types/date_value.py +12 -0
- frameio/types/email.py +3 -0
- frameio/types/field_definition.py +163 -0
- frameio/types/field_definition_include.py +5 -0
- frameio/types/field_definition_response.py +13 -0
- frameio/types/field_definition_with_includes.py +174 -0
- frameio/types/field_definitions_with_includes_response.py +27 -0
- frameio/types/field_value_common.py +29 -0
- frameio/types/file.py +60 -0
- frameio/types/file_copy_response.py +13 -0
- frameio/types/file_remote_upload_response.py +17 -0
- frameio/types/file_response.py +13 -0
- frameio/types/file_status.py +5 -0
- frameio/types/file_upload_status.py +41 -0
- frameio/types/file_upload_status_response.py +13 -0
- frameio/types/file_with_includes.py +25 -0
- frameio/types/file_with_includes_response.py +13 -0
- frameio/types/file_with_includes_status.py +5 -0
- frameio/types/file_with_media_links_include.py +19 -0
- frameio/types/file_with_upload_urls.py +16 -0
- frameio/types/file_with_upload_urls_response.py +13 -0
- frameio/types/folder.py +15 -0
- frameio/types/folder_copy_response.py +13 -0
- frameio/types/folder_response.py +13 -0
- frameio/types/folder_with_includes.py +61 -0
- frameio/types/folder_with_includes_response.py +13 -0
- frameio/types/folders_with_includes_response.py +23 -0
- frameio/types/forbidden.py +13 -0
- frameio/types/forbidden_errors_item.py +15 -0
- frameio/types/forbidden_errors_item_source.py +12 -0
- frameio/types/include.py +5 -0
- frameio/types/include_total_count.py +3 -0
- frameio/types/integer_value.py +12 -0
- frameio/types/json_error_response.py +13 -0
- frameio/types/json_error_response_errors_item.py +15 -0
- frameio/types/json_error_response_errors_item_source.py +12 -0
- frameio/types/links.py +22 -0
- frameio/types/long_text_definition.py +43 -0
- frameio/types/long_text_definition_field_configuration.py +10 -0
- frameio/types/long_text_definition_params.py +15 -0
- frameio/types/long_text_definition_with_includes.py +13 -0
- frameio/types/media_link_common.py +17 -0
- frameio/types/media_links_collection.py +23 -0
- frameio/types/metadata_field.py +145 -0
- frameio/types/metadata_response.py +13 -0
- frameio/types/metadata_with_definition.py +21 -0
- frameio/types/multi_select_value.py +14 -0
- frameio/types/multi_user_value.py +20 -0
- frameio/types/multi_user_value_member_options_type.py +5 -0
- frameio/types/no_content.py +3 -0
- frameio/types/not_found.py +13 -0
- frameio/types/not_found_errors_item.py +15 -0
- frameio/types/not_found_errors_item_source.py +12 -0
- frameio/types/number_definition.py +43 -0
- frameio/types/number_definition_field_configuration.py +21 -0
- frameio/types/number_definition_field_configuration_number_format.py +7 -0
- frameio/types/number_definition_params.py +17 -0
- frameio/types/number_definition_params_field_configuration.py +23 -0
- frameio/types/number_definition_params_field_configuration_number_format.py +7 -0
- frameio/types/number_definition_with_includes.py +13 -0
- frameio/types/number_value.py +12 -0
- frameio/types/original_media_link.py +16 -0
- frameio/types/profile.py +34 -0
- frameio/types/profile_response.py +17 -0
- frameio/types/project.py +55 -0
- frameio/types/project_include.py +5 -0
- frameio/types/project_params.py +17 -0
- frameio/types/project_params_data.py +15 -0
- frameio/types/project_response.py +17 -0
- frameio/types/project_with_includes.py +18 -0
- frameio/types/project_with_includes_response.py +17 -0
- frameio/types/projects_with_includes_response.py +27 -0
- frameio/types/rating_definition.py +43 -0
- frameio/types/rating_definition_field_configuration.py +22 -0
- frameio/types/rating_definition_field_configuration_style.py +5 -0
- frameio/types/rating_definition_params.py +17 -0
- frameio/types/rating_definition_params_field_configuration.py +22 -0
- frameio/types/rating_definition_params_field_configuration_style.py +5 -0
- frameio/types/rating_definition_with_includes.py +13 -0
- frameio/types/remove_asset_response.py +13 -0
- frameio/types/remove_asset_response_data.py +15 -0
- frameio/types/rendition_media_link.py +19 -0
- frameio/types/request_after_opaque_cursor.py +5 -0
- frameio/types/request_page_size.py +3 -0
- frameio/types/select_definition.py +43 -0
- frameio/types/select_definition_field_configuration.py +18 -0
- frameio/types/select_definition_field_configuration_options_item.py +22 -0
- frameio/types/select_definition_params.py +17 -0
- frameio/types/select_definition_params_field_configuration.py +20 -0
- frameio/types/select_definition_params_field_configuration_options_item.py +20 -0
- frameio/types/select_definition_with_includes.py +13 -0
- frameio/types/select_multi_definition.py +43 -0
- frameio/types/select_multi_definition_field_configuration.py +18 -0
- frameio/types/select_multi_definition_field_configuration_options_item.py +22 -0
- frameio/types/select_multi_definition_params.py +17 -0
- frameio/types/select_multi_definition_params_field_configuration.py +20 -0
- frameio/types/select_multi_definition_params_field_configuration_options_item.py +20 -0
- frameio/types/select_multi_definition_with_includes.py +13 -0
- frameio/types/select_option.py +20 -0
- frameio/types/select_value.py +14 -0
- frameio/types/share.py +66 -0
- frameio/types/share_access.py +5 -0
- frameio/types/share_response.py +13 -0
- frameio/types/share_reviewers_response.py +27 -0
- frameio/types/shares_response.py +27 -0
- frameio/types/single_user_value.py +20 -0
- frameio/types/single_user_value_member_options_type.py +5 -0
- frameio/types/text_definition.py +43 -0
- frameio/types/text_definition_field_configuration.py +10 -0
- frameio/types/text_definition_params.py +15 -0
- frameio/types/text_definition_with_includes.py +13 -0
- frameio/types/text_value.py +12 -0
- frameio/types/toggle_definition.py +43 -0
- frameio/types/toggle_definition_field_configuration.py +15 -0
- frameio/types/toggle_definition_params.py +17 -0
- frameio/types/toggle_definition_params_field_configuration.py +15 -0
- frameio/types/toggle_definition_with_includes.py +13 -0
- frameio/types/too_many_requests.py +13 -0
- frameio/types/too_many_requests_errors_item.py +15 -0
- frameio/types/too_many_requests_errors_item_source.py +12 -0
- frameio/types/unauthorized.py +13 -0
- frameio/types/unauthorized_errors_item.py +15 -0
- frameio/types/unauthorized_errors_item_source.py +12 -0
- frameio/types/unprocessable_entity.py +13 -0
- frameio/types/unprocessable_entity_errors_item.py +15 -0
- frameio/types/unprocessable_entity_errors_item_source.py +12 -0
- frameio/types/update_date_definition_params.py +17 -0
- frameio/types/update_date_definition_params_field_configuration.py +25 -0
- frameio/types/update_date_definition_params_field_configuration_display_format.py +7 -0
- frameio/types/update_date_definition_params_field_configuration_time_format.py +7 -0
- frameio/types/update_long_text_definition_params.py +15 -0
- frameio/types/update_number_definition_params.py +17 -0
- frameio/types/update_number_definition_params_field_configuration.py +25 -0
- frameio/types/update_number_definition_params_field_configuration_number_format.py +7 -0
- frameio/types/update_rating_definition_params.py +17 -0
- frameio/types/update_rating_definition_params_field_configuration.py +24 -0
- frameio/types/update_rating_definition_params_field_configuration_style.py +7 -0
- frameio/types/update_select_definition_params.py +17 -0
- frameio/types/update_select_definition_params_field_configuration.py +20 -0
- frameio/types/update_select_definition_params_field_configuration_options_item.py +20 -0
- frameio/types/update_select_multi_definition_params.py +19 -0
- frameio/types/update_select_multi_definition_params_field_configuration.py +20 -0
- frameio/types/update_select_multi_definition_params_field_configuration_options_item.py +20 -0
- frameio/types/update_text_definition_params.py +15 -0
- frameio/types/update_toggle_definition_params.py +17 -0
- frameio/types/update_toggle_definition_params_field_configuration.py +15 -0
- frameio/types/update_user_multi_definition_params.py +17 -0
- frameio/types/update_user_multi_definition_params_field_configuration.py +25 -0
- frameio/types/update_user_multi_definition_params_field_configuration_custom_members_item.py +20 -0
- frameio/types/update_user_multi_definition_params_field_configuration_custom_members_item_type.py +7 -0
- frameio/types/update_user_multi_definition_params_field_configuration_member_options_type.py +7 -0
- frameio/types/update_user_roles_params.py +17 -0
- frameio/types/update_user_roles_params_data.py +13 -0
- frameio/types/update_user_roles_params_data_role.py +7 -0
- frameio/types/update_user_roles_response.py +13 -0
- frameio/types/update_user_roles_response_data.py +13 -0
- frameio/types/update_user_roles_response_data_role.py +7 -0
- frameio/types/update_user_single_definition_params.py +17 -0
- frameio/types/update_user_single_definition_params_field_configuration.py +25 -0
- frameio/types/update_user_single_definition_params_field_configuration_custom_members_item.py +20 -0
- frameio/types/update_user_single_definition_params_field_configuration_custom_members_item_type.py +7 -0
- frameio/types/update_user_single_definition_params_field_configuration_member_options_type.py +7 -0
- frameio/types/upload_url.py +20 -0
- frameio/types/user.py +44 -0
- frameio/types/user_multi_definition.py +43 -0
- frameio/types/user_multi_definition_field_configuration.py +23 -0
- frameio/types/user_multi_definition_field_configuration_custom_members_item.py +20 -0
- frameio/types/user_multi_definition_field_configuration_custom_members_item_type.py +7 -0
- frameio/types/user_multi_definition_field_configuration_member_options_type.py +7 -0
- frameio/types/user_multi_definition_params.py +17 -0
- frameio/types/user_multi_definition_params_field_configuration.py +23 -0
- frameio/types/user_multi_definition_params_field_configuration_custom_members_item.py +20 -0
- frameio/types/user_multi_definition_params_field_configuration_custom_members_item_type.py +7 -0
- frameio/types/user_multi_definition_params_field_configuration_member_options_type.py +7 -0
- frameio/types/user_multi_definition_with_includes.py +13 -0
- frameio/types/user_role.py +19 -0
- frameio/types/user_role_role.py +7 -0
- frameio/types/user_roles_response.py +27 -0
- frameio/types/user_single_definition.py +43 -0
- frameio/types/user_single_definition_field_configuration.py +23 -0
- frameio/types/user_single_definition_field_configuration_custom_members_item.py +20 -0
- frameio/types/user_single_definition_field_configuration_custom_members_item_type.py +7 -0
- frameio/types/user_single_definition_field_configuration_member_options_type.py +7 -0
- frameio/types/user_single_definition_params.py +17 -0
- frameio/types/user_single_definition_params_field_configuration.py +23 -0
- frameio/types/user_single_definition_params_field_configuration_custom_members_item.py +20 -0
- frameio/types/user_single_definition_params_field_configuration_custom_members_item_type.py +7 -0
- frameio/types/user_single_definition_params_field_configuration_member_options_type.py +7 -0
- frameio/types/user_single_definition_with_includes.py +13 -0
- frameio/types/user_value.py +18 -0
- frameio/types/user_value_type.py +5 -0
- frameio/types/uuid_.py +3 -0
- frameio/types/version_stack.py +50 -0
- frameio/types/version_stack_copy_response.py +13 -0
- frameio/types/version_stack_response.py +13 -0
- frameio/types/version_stack_with_includes.py +58 -0
- frameio/types/version_stack_with_includes_response.py +13 -0
- frameio/types/version_stacks_with_includes_response.py +19 -0
- frameio/types/webhook.py +36 -0
- frameio/types/webhook_create_response.py +17 -0
- frameio/types/webhook_create_response_data.py +15 -0
- frameio/types/webhook_events.py +5 -0
- frameio/types/webhook_response.py +13 -0
- frameio/types/webhook_with_includes.py +13 -0
- frameio/types/webhook_with_includes_response.py +13 -0
- frameio/types/webhooks_with_includes_response.py +23 -0
- frameio/types/workspace.py +40 -0
- frameio/types/workspace_include.py +5 -0
- frameio/types/workspace_params.py +17 -0
- frameio/types/workspace_params_data.py +15 -0
- frameio/types/workspace_response.py +17 -0
- frameio/types/workspace_with_includes.py +13 -0
- frameio/types/workspace_with_includes_response.py +17 -0
- frameio/types/workspaces_with_includes_response.py +27 -0
- frameio/users/__init__.py +4 -0
- frameio/users/client.py +100 -0
- frameio/users/raw_client.py +234 -0
- frameio/version.py +3 -0
- frameio/version_stacks/__init__.py +38 -0
- frameio/version_stacks/client.py +699 -0
- frameio/version_stacks/raw_client.py +1359 -0
- frameio/version_stacks/types/__init__.py +40 -0
- frameio/version_stacks/types/version_stack_copy_params_data.py +15 -0
- frameio/version_stacks/types/version_stack_create_params_data.py +19 -0
- frameio/version_stacks/types/version_stack_move_params_data.py +15 -0
- frameio/webhooks/__init__.py +34 -0
- frameio/webhooks/client.py +782 -0
- frameio/webhooks/raw_client.py +1312 -0
- frameio/webhooks/types/__init__.py +38 -0
- frameio/webhooks/types/webhook_create_params_data.py +18 -0
- frameio/webhooks/types/webhook_update_params_data.py +23 -0
- frameio/workspace_permissions/__init__.py +4 -0
- frameio/workspace_permissions/client.py +419 -0
- frameio/workspace_permissions/raw_client.py +789 -0
- frameio/workspaces/__init__.py +4 -0
- frameio/workspaces/client.py +552 -0
- frameio/workspaces/raw_client.py +1226 -0
- frameio-0.0.23.dist-info/METADATA +255 -0
- frameio-0.0.23.dist-info/RECORD +363 -0
- frameio-0.0.23.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import AsyncIterator, Awaitable, Callable, Generic, Iterator, List, Optional, TypeVar
|
|
7
|
+
|
|
8
|
+
from .http_response import BaseHttpResponse
|
|
9
|
+
|
|
10
|
+
# Generic to represent the underlying type of the results within a page
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# SDKs implement a Page ABC per-pagination request, the endpoint then returns a pager that wraps this type
|
|
15
|
+
# for example, an endpoint will return SyncPager[UserPage] where UserPage implements the Page ABC. ex:
|
|
16
|
+
#
|
|
17
|
+
# SyncPager<InnerListType>(
|
|
18
|
+
# has_next=response.list_metadata.after is not None,
|
|
19
|
+
# items=response.data,
|
|
20
|
+
# # This should be the outer function that returns the SyncPager again
|
|
21
|
+
# get_next=lambda: list(..., cursor: response.cursor) (or list(..., offset: offset + 1))
|
|
22
|
+
# )
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass(frozen=True)
|
|
26
|
+
class SyncPager(Generic[T]):
|
|
27
|
+
get_next: Optional[Callable[[], Optional[SyncPager[T]]]]
|
|
28
|
+
has_next: bool
|
|
29
|
+
items: Optional[List[T]]
|
|
30
|
+
response: Optional[BaseHttpResponse]
|
|
31
|
+
|
|
32
|
+
# Here we type ignore the iterator to avoid a mypy error
|
|
33
|
+
# caused by the type conflict with Pydanitc's __iter__ method
|
|
34
|
+
# brought in by extending the base model
|
|
35
|
+
def __iter__(self) -> Iterator[T]: # type: ignore[override]
|
|
36
|
+
for page in self.iter_pages():
|
|
37
|
+
if page.items is not None:
|
|
38
|
+
yield from page.items
|
|
39
|
+
|
|
40
|
+
def iter_pages(self) -> Iterator[SyncPager[T]]:
|
|
41
|
+
page: Optional[SyncPager[T]] = self
|
|
42
|
+
while page is not None:
|
|
43
|
+
yield page
|
|
44
|
+
|
|
45
|
+
if not page.has_next or page.get_next is None:
|
|
46
|
+
return
|
|
47
|
+
|
|
48
|
+
page = page.get_next()
|
|
49
|
+
if page is None or page.items is None or len(page.items) == 0:
|
|
50
|
+
return
|
|
51
|
+
|
|
52
|
+
def next_page(self) -> Optional[SyncPager[T]]:
|
|
53
|
+
return self.get_next() if self.get_next is not None else None
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@dataclass(frozen=True)
|
|
57
|
+
class AsyncPager(Generic[T]):
|
|
58
|
+
get_next: Optional[Callable[[], Awaitable[Optional[AsyncPager[T]]]]]
|
|
59
|
+
has_next: bool
|
|
60
|
+
items: Optional[List[T]]
|
|
61
|
+
response: Optional[BaseHttpResponse]
|
|
62
|
+
|
|
63
|
+
async def __aiter__(self) -> AsyncIterator[T]:
|
|
64
|
+
async for page in self.iter_pages():
|
|
65
|
+
if page.items is not None:
|
|
66
|
+
for item in page.items:
|
|
67
|
+
yield item
|
|
68
|
+
|
|
69
|
+
async def iter_pages(self) -> AsyncIterator[AsyncPager[T]]:
|
|
70
|
+
page: Optional[AsyncPager[T]] = self
|
|
71
|
+
while page is not None:
|
|
72
|
+
yield page
|
|
73
|
+
|
|
74
|
+
if not page.has_next or page.get_next is None:
|
|
75
|
+
return
|
|
76
|
+
|
|
77
|
+
page = await page.get_next()
|
|
78
|
+
if page is None or page.items is None or len(page.items) == 0:
|
|
79
|
+
return
|
|
80
|
+
|
|
81
|
+
async def next_page(self) -> Optional[AsyncPager[T]]:
|
|
82
|
+
return await self.get_next() if self.get_next is not None else None
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
# nopycln: file
|
|
4
|
+
import datetime as dt
|
|
5
|
+
from collections import defaultdict
|
|
6
|
+
from typing import Any, Callable, ClassVar, Dict, List, Mapping, Optional, Set, Tuple, Type, TypeVar, Union, cast
|
|
7
|
+
|
|
8
|
+
import pydantic
|
|
9
|
+
|
|
10
|
+
IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.")
|
|
11
|
+
|
|
12
|
+
if IS_PYDANTIC_V2:
|
|
13
|
+
from pydantic.v1.datetime_parse import parse_date as parse_date
|
|
14
|
+
from pydantic.v1.datetime_parse import parse_datetime as parse_datetime
|
|
15
|
+
from pydantic.v1.fields import ModelField as ModelField
|
|
16
|
+
from pydantic.v1.json import ENCODERS_BY_TYPE as encoders_by_type # type: ignore[attr-defined]
|
|
17
|
+
from pydantic.v1.typing import get_args as get_args
|
|
18
|
+
from pydantic.v1.typing import get_origin as get_origin
|
|
19
|
+
from pydantic.v1.typing import is_literal_type as is_literal_type
|
|
20
|
+
from pydantic.v1.typing import is_union as is_union
|
|
21
|
+
else:
|
|
22
|
+
from pydantic.datetime_parse import parse_date as parse_date # type: ignore[no-redef]
|
|
23
|
+
from pydantic.datetime_parse import parse_datetime as parse_datetime # type: ignore[no-redef]
|
|
24
|
+
from pydantic.fields import ModelField as ModelField # type: ignore[attr-defined, no-redef]
|
|
25
|
+
from pydantic.json import ENCODERS_BY_TYPE as encoders_by_type # type: ignore[no-redef]
|
|
26
|
+
from pydantic.typing import get_args as get_args # type: ignore[no-redef]
|
|
27
|
+
from pydantic.typing import get_origin as get_origin # type: ignore[no-redef]
|
|
28
|
+
from pydantic.typing import is_literal_type as is_literal_type # type: ignore[no-redef]
|
|
29
|
+
from pydantic.typing import is_union as is_union # type: ignore[no-redef]
|
|
30
|
+
|
|
31
|
+
from .datetime_utils import serialize_datetime
|
|
32
|
+
from .serialization import convert_and_respect_annotation_metadata
|
|
33
|
+
from typing_extensions import TypeAlias
|
|
34
|
+
|
|
35
|
+
T = TypeVar("T")
|
|
36
|
+
Model = TypeVar("Model", bound=pydantic.BaseModel)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def parse_obj_as(type_: Type[T], object_: Any) -> T:
|
|
40
|
+
dealiased_object = convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read")
|
|
41
|
+
if IS_PYDANTIC_V2:
|
|
42
|
+
adapter = pydantic.TypeAdapter(type_) # type: ignore[attr-defined]
|
|
43
|
+
return adapter.validate_python(dealiased_object)
|
|
44
|
+
return pydantic.parse_obj_as(type_, dealiased_object)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def to_jsonable_with_fallback(obj: Any, fallback_serializer: Callable[[Any], Any]) -> Any:
|
|
48
|
+
if IS_PYDANTIC_V2:
|
|
49
|
+
from pydantic_core import to_jsonable_python
|
|
50
|
+
|
|
51
|
+
return to_jsonable_python(obj, fallback=fallback_serializer)
|
|
52
|
+
return fallback_serializer(obj)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class UniversalBaseModel(pydantic.BaseModel):
|
|
56
|
+
if IS_PYDANTIC_V2:
|
|
57
|
+
model_config: ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( # type: ignore[typeddict-unknown-key]
|
|
58
|
+
# Allow fields beginning with `model_` to be used in the model
|
|
59
|
+
protected_namespaces=(),
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
@pydantic.model_serializer(mode="plain", when_used="json") # type: ignore[attr-defined]
|
|
63
|
+
def serialize_model(self) -> Any: # type: ignore[name-defined]
|
|
64
|
+
serialized = self.dict() # type: ignore[attr-defined]
|
|
65
|
+
data = {k: serialize_datetime(v) if isinstance(v, dt.datetime) else v for k, v in serialized.items()}
|
|
66
|
+
return data
|
|
67
|
+
|
|
68
|
+
else:
|
|
69
|
+
|
|
70
|
+
class Config:
|
|
71
|
+
smart_union = True
|
|
72
|
+
json_encoders = {dt.datetime: serialize_datetime}
|
|
73
|
+
|
|
74
|
+
@classmethod
|
|
75
|
+
def model_construct(cls: Type["Model"], _fields_set: Optional[Set[str]] = None, **values: Any) -> "Model":
|
|
76
|
+
dealiased_object = convert_and_respect_annotation_metadata(object_=values, annotation=cls, direction="read")
|
|
77
|
+
return cls.construct(_fields_set, **dealiased_object)
|
|
78
|
+
|
|
79
|
+
@classmethod
|
|
80
|
+
def construct(cls: Type["Model"], _fields_set: Optional[Set[str]] = None, **values: Any) -> "Model":
|
|
81
|
+
dealiased_object = convert_and_respect_annotation_metadata(object_=values, annotation=cls, direction="read")
|
|
82
|
+
if IS_PYDANTIC_V2:
|
|
83
|
+
return super().model_construct(_fields_set, **dealiased_object) # type: ignore[misc]
|
|
84
|
+
return super().construct(_fields_set, **dealiased_object)
|
|
85
|
+
|
|
86
|
+
def json(self, **kwargs: Any) -> str:
|
|
87
|
+
kwargs_with_defaults = {
|
|
88
|
+
"by_alias": True,
|
|
89
|
+
"exclude_unset": True,
|
|
90
|
+
**kwargs,
|
|
91
|
+
}
|
|
92
|
+
if IS_PYDANTIC_V2:
|
|
93
|
+
return super().model_dump_json(**kwargs_with_defaults) # type: ignore[misc]
|
|
94
|
+
return super().json(**kwargs_with_defaults)
|
|
95
|
+
|
|
96
|
+
def dict(self, **kwargs: Any) -> Dict[str, Any]:
|
|
97
|
+
"""
|
|
98
|
+
Override the default dict method to `exclude_unset` by default. This function patches
|
|
99
|
+
`exclude_unset` to work include fields within non-None default values.
|
|
100
|
+
"""
|
|
101
|
+
# Note: the logic here is multiplexed given the levers exposed in Pydantic V1 vs V2
|
|
102
|
+
# Pydantic V1's .dict can be extremely slow, so we do not want to call it twice.
|
|
103
|
+
#
|
|
104
|
+
# We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models
|
|
105
|
+
# that we have less control over, and this is less intrusive than custom serializers for now.
|
|
106
|
+
if IS_PYDANTIC_V2:
|
|
107
|
+
kwargs_with_defaults_exclude_unset = {
|
|
108
|
+
**kwargs,
|
|
109
|
+
"by_alias": True,
|
|
110
|
+
"exclude_unset": True,
|
|
111
|
+
"exclude_none": False,
|
|
112
|
+
}
|
|
113
|
+
kwargs_with_defaults_exclude_none = {
|
|
114
|
+
**kwargs,
|
|
115
|
+
"by_alias": True,
|
|
116
|
+
"exclude_none": True,
|
|
117
|
+
"exclude_unset": False,
|
|
118
|
+
}
|
|
119
|
+
dict_dump = deep_union_pydantic_dicts(
|
|
120
|
+
super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore[misc]
|
|
121
|
+
super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore[misc]
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
else:
|
|
125
|
+
_fields_set = self.__fields_set__.copy()
|
|
126
|
+
|
|
127
|
+
fields = _get_model_fields(self.__class__)
|
|
128
|
+
for name, field in fields.items():
|
|
129
|
+
if name not in _fields_set:
|
|
130
|
+
default = _get_field_default(field)
|
|
131
|
+
|
|
132
|
+
# If the default values are non-null act like they've been set
|
|
133
|
+
# This effectively allows exclude_unset to work like exclude_none where
|
|
134
|
+
# the latter passes through intentionally set none values.
|
|
135
|
+
if default is not None or ("exclude_unset" in kwargs and not kwargs["exclude_unset"]):
|
|
136
|
+
_fields_set.add(name)
|
|
137
|
+
|
|
138
|
+
if default is not None:
|
|
139
|
+
self.__fields_set__.add(name)
|
|
140
|
+
|
|
141
|
+
kwargs_with_defaults_exclude_unset_include_fields = {
|
|
142
|
+
"by_alias": True,
|
|
143
|
+
"exclude_unset": True,
|
|
144
|
+
"include": _fields_set,
|
|
145
|
+
**kwargs,
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields)
|
|
149
|
+
|
|
150
|
+
return cast(
|
|
151
|
+
Dict[str, Any],
|
|
152
|
+
convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write"),
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def _union_list_of_pydantic_dicts(source: List[Any], destination: List[Any]) -> List[Any]:
|
|
157
|
+
converted_list: List[Any] = []
|
|
158
|
+
for i, item in enumerate(source):
|
|
159
|
+
destination_value = destination[i]
|
|
160
|
+
if isinstance(item, dict):
|
|
161
|
+
converted_list.append(deep_union_pydantic_dicts(item, destination_value))
|
|
162
|
+
elif isinstance(item, list):
|
|
163
|
+
converted_list.append(_union_list_of_pydantic_dicts(item, destination_value))
|
|
164
|
+
else:
|
|
165
|
+
converted_list.append(item)
|
|
166
|
+
return converted_list
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def deep_union_pydantic_dicts(source: Dict[str, Any], destination: Dict[str, Any]) -> Dict[str, Any]:
|
|
170
|
+
for key, value in source.items():
|
|
171
|
+
node = destination.setdefault(key, {})
|
|
172
|
+
if isinstance(value, dict):
|
|
173
|
+
deep_union_pydantic_dicts(value, node)
|
|
174
|
+
# Note: we do not do this same processing for sets given we do not have sets of models
|
|
175
|
+
# and given the sets are unordered, the processing of the set and matching objects would
|
|
176
|
+
# be non-trivial.
|
|
177
|
+
elif isinstance(value, list):
|
|
178
|
+
destination[key] = _union_list_of_pydantic_dicts(value, node)
|
|
179
|
+
else:
|
|
180
|
+
destination[key] = value
|
|
181
|
+
|
|
182
|
+
return destination
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
if IS_PYDANTIC_V2:
|
|
186
|
+
|
|
187
|
+
class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore[misc, name-defined, type-arg]
|
|
188
|
+
pass
|
|
189
|
+
|
|
190
|
+
UniversalRootModel: TypeAlias = V2RootModel # type: ignore[misc]
|
|
191
|
+
else:
|
|
192
|
+
UniversalRootModel: TypeAlias = UniversalBaseModel # type: ignore[misc, no-redef]
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def encode_by_type(o: Any) -> Any:
|
|
196
|
+
encoders_by_class_tuples: Dict[Callable[[Any], Any], Tuple[Any, ...]] = defaultdict(tuple)
|
|
197
|
+
for type_, encoder in encoders_by_type.items():
|
|
198
|
+
encoders_by_class_tuples[encoder] += (type_,)
|
|
199
|
+
|
|
200
|
+
if type(o) in encoders_by_type:
|
|
201
|
+
return encoders_by_type[type(o)](o)
|
|
202
|
+
for encoder, classes_tuple in encoders_by_class_tuples.items():
|
|
203
|
+
if isinstance(o, classes_tuple):
|
|
204
|
+
return encoder(o)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def update_forward_refs(model: Type["Model"], **localns: Any) -> None:
|
|
208
|
+
if IS_PYDANTIC_V2:
|
|
209
|
+
model.model_rebuild(raise_errors=False) # type: ignore[attr-defined]
|
|
210
|
+
else:
|
|
211
|
+
model.update_forward_refs(**localns)
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
# Mirrors Pydantic's internal typing
|
|
215
|
+
AnyCallable = Callable[..., Any]
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def universal_root_validator(
|
|
219
|
+
pre: bool = False,
|
|
220
|
+
) -> Callable[[AnyCallable], AnyCallable]:
|
|
221
|
+
def decorator(func: AnyCallable) -> AnyCallable:
|
|
222
|
+
if IS_PYDANTIC_V2:
|
|
223
|
+
return cast(AnyCallable, pydantic.model_validator(mode="before" if pre else "after")(func)) # type: ignore[attr-defined]
|
|
224
|
+
return cast(AnyCallable, pydantic.root_validator(pre=pre)(func)) # type: ignore[call-overload]
|
|
225
|
+
|
|
226
|
+
return decorator
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def universal_field_validator(field_name: str, pre: bool = False) -> Callable[[AnyCallable], AnyCallable]:
|
|
230
|
+
def decorator(func: AnyCallable) -> AnyCallable:
|
|
231
|
+
if IS_PYDANTIC_V2:
|
|
232
|
+
return cast(AnyCallable, pydantic.field_validator(field_name, mode="before" if pre else "after")(func)) # type: ignore[attr-defined]
|
|
233
|
+
return cast(AnyCallable, pydantic.validator(field_name, pre=pre)(func))
|
|
234
|
+
|
|
235
|
+
return decorator
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
PydanticField = Union[ModelField, pydantic.fields.FieldInfo]
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def _get_model_fields(model: Type["Model"]) -> Mapping[str, PydanticField]:
|
|
242
|
+
if IS_PYDANTIC_V2:
|
|
243
|
+
return cast(Mapping[str, PydanticField], model.model_fields) # type: ignore[attr-defined]
|
|
244
|
+
return cast(Mapping[str, PydanticField], model.__fields__)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def _get_field_default(field: PydanticField) -> Any:
|
|
248
|
+
try:
|
|
249
|
+
value = field.get_default() # type: ignore[union-attr]
|
|
250
|
+
except:
|
|
251
|
+
value = field.default
|
|
252
|
+
if IS_PYDANTIC_V2:
|
|
253
|
+
from pydantic_core import PydanticUndefined
|
|
254
|
+
|
|
255
|
+
if value == PydanticUndefined:
|
|
256
|
+
return None
|
|
257
|
+
return value
|
|
258
|
+
return value
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict
|
|
9
|
+
def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]:
|
|
10
|
+
result = []
|
|
11
|
+
for k, v in dict_flat.items():
|
|
12
|
+
key = f"{key_prefix}[{k}]" if key_prefix is not None else k
|
|
13
|
+
if isinstance(v, dict):
|
|
14
|
+
result.extend(traverse_query_dict(v, key))
|
|
15
|
+
elif isinstance(v, list):
|
|
16
|
+
for arr_v in v:
|
|
17
|
+
if isinstance(arr_v, dict):
|
|
18
|
+
result.extend(traverse_query_dict(arr_v, key))
|
|
19
|
+
else:
|
|
20
|
+
result.append((key, arr_v))
|
|
21
|
+
else:
|
|
22
|
+
result.append((key, v))
|
|
23
|
+
return result
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]:
|
|
27
|
+
if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict):
|
|
28
|
+
if isinstance(query_value, pydantic.BaseModel):
|
|
29
|
+
obj_dict = query_value.dict(by_alias=True)
|
|
30
|
+
else:
|
|
31
|
+
obj_dict = query_value
|
|
32
|
+
return traverse_query_dict(obj_dict, query_key)
|
|
33
|
+
elif isinstance(query_value, list):
|
|
34
|
+
encoded_values: List[Tuple[str, Any]] = []
|
|
35
|
+
for value in query_value:
|
|
36
|
+
if isinstance(value, pydantic.BaseModel) or isinstance(value, dict):
|
|
37
|
+
if isinstance(value, pydantic.BaseModel):
|
|
38
|
+
obj_dict = value.dict(by_alias=True)
|
|
39
|
+
elif isinstance(value, dict):
|
|
40
|
+
obj_dict = value
|
|
41
|
+
|
|
42
|
+
encoded_values.extend(single_query_encoder(query_key, obj_dict))
|
|
43
|
+
else:
|
|
44
|
+
encoded_values.append((query_key, value))
|
|
45
|
+
|
|
46
|
+
return encoded_values
|
|
47
|
+
|
|
48
|
+
return [(query_key, query_value)]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]:
|
|
52
|
+
if query is None:
|
|
53
|
+
return None
|
|
54
|
+
|
|
55
|
+
encoded_query = []
|
|
56
|
+
for k, v in query.items():
|
|
57
|
+
encoded_query.extend(single_query_encoder(k, v))
|
|
58
|
+
return encoded_query
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, Mapping, Optional
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def remove_none_from_dict(original: Mapping[str, Optional[Any]]) -> Dict[str, Any]:
|
|
7
|
+
new: Dict[str, Any] = {}
|
|
8
|
+
for key, value in original.items():
|
|
9
|
+
if value is not None:
|
|
10
|
+
new[key] = value
|
|
11
|
+
return new
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
from typing import NotRequired # type: ignore
|
|
7
|
+
except ImportError:
|
|
8
|
+
from typing_extensions import NotRequired
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class RequestOptions(typing.TypedDict, total=False):
|
|
12
|
+
"""
|
|
13
|
+
Additional options for request-specific configuration when calling APIs via the SDK.
|
|
14
|
+
This is used primarily as an optional final parameter for service functions.
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
- timeout_in_seconds: int. The number of seconds to await an API call before timing out.
|
|
18
|
+
|
|
19
|
+
- max_retries: int. The max number of retries to attempt if the API call fails.
|
|
20
|
+
|
|
21
|
+
- additional_headers: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's header dict
|
|
22
|
+
|
|
23
|
+
- additional_query_parameters: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's query parameters dict
|
|
24
|
+
|
|
25
|
+
- additional_body_parameters: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's body parameters dict
|
|
26
|
+
|
|
27
|
+
- chunk_size: int. The size, in bytes, to process each chunk of data being streamed back within the response. This equates to leveraging `chunk_size` within `requests` or `httpx`, and is only leveraged for file downloads.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
timeout_in_seconds: NotRequired[int]
|
|
31
|
+
max_retries: NotRequired[int]
|
|
32
|
+
additional_headers: NotRequired[typing.Dict[str, typing.Any]]
|
|
33
|
+
additional_query_parameters: NotRequired[typing.Dict[str, typing.Any]]
|
|
34
|
+
additional_body_parameters: NotRequired[typing.Dict[str, typing.Any]]
|
|
35
|
+
chunk_size: NotRequired[int]
|