From 5b74a93ed588186d501465761dcbc780436c7732 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Mon, 30 Mar 2026 21:52:17 +0000 Subject: [PATCH] SDK regeneration --- .fern/metadata.json | 10 + .gitignore | 4 +- poetry.lock | 239 +- pyproject.toml | 37 +- reference.md | 1472 +++++---- requirements.txt | 2 +- src/polytomic/__init__.py | 743 +++-- src/polytomic/bulk_sync/__init__.py | 39 +- src/polytomic/bulk_sync/client.py | 1637 ++-------- .../bulk_sync/executions/__init__.py | 2 + src/polytomic/bulk_sync/executions/client.py | 640 +--- .../bulk_sync/executions/raw_client.py | 1034 ++++++ src/polytomic/bulk_sync/raw_client.py | 2450 ++++++++++++++ src/polytomic/bulk_sync/schedules/__init__.py | 2 + src/polytomic/bulk_sync/schedules/client.py | 709 +--- .../bulk_sync/schedules/raw_client.py | 1011 ++++++ src/polytomic/bulk_sync/schemas/__init__.py | 2 + src/polytomic/bulk_sync/schemas/client.py | 683 +--- src/polytomic/bulk_sync/schemas/raw_client.py | 1011 ++++++ src/polytomic/bulk_sync/types/__init__.py | 36 +- ...2_create_bulk_sync_request_schemas_item.py | 1 + ...2_update_bulk_sync_request_schemas_item.py | 1 + src/polytomic/client.py | 369 ++- src/polytomic/connections/__init__.py | 2 + src/polytomic/connections/client.py | 1743 ++-------- src/polytomic/connections/raw_client.py | 2684 +++++++++++++++ src/polytomic/core/__init__.py | 116 +- src/polytomic/core/api_error.py | 18 +- src/polytomic/core/client_wrapper.py | 52 +- src/polytomic/core/datetime_utils.py | 42 + src/polytomic/core/force_multipart.py | 18 + src/polytomic/core/http_client.py | 585 +++- src/polytomic/core/http_response.py | 59 + src/polytomic/core/http_sse/__init__.py | 42 + src/polytomic/core/http_sse/_api.py | 112 + src/polytomic/core/http_sse/_decoders.py | 61 + src/polytomic/core/http_sse/_exceptions.py | 7 + src/polytomic/core/http_sse/_models.py | 17 + src/polytomic/core/jsonable_encoder.py | 9 +- src/polytomic/core/logging.py | 107 + src/polytomic/core/parse_error.py | 36 + src/polytomic/core/pydantic_utilities.py | 554 +++- src/polytomic/core/serialization.py | 10 +- src/polytomic/errors/__init__.py | 51 +- src/polytomic/errors/bad_request_error.py | 6 +- src/polytomic/errors/conflict_error.py | 6 +- src/polytomic/errors/forbidden_error.py | 6 +- src/polytomic/errors/internal_server_error.py | 6 +- src/polytomic/errors/not_found_error.py | 6 +- src/polytomic/errors/unauthorized_error.py | 6 +- .../errors/unprocessable_entity_error.py | 6 +- src/polytomic/events/__init__.py | 2 + src/polytomic/events/client.py | 224 +- src/polytomic/events/raw_client.py | 333 ++ src/polytomic/identity/__init__.py | 2 + src/polytomic/identity/client.py | 118 +- src/polytomic/identity/raw_client.py | 159 + src/polytomic/jobs/__init__.py | 2 + src/polytomic/jobs/client.py | 177 +- src/polytomic/jobs/raw_client.py | 210 ++ src/polytomic/model_sync/__init__.py | 31 +- src/polytomic/model_sync/client.py | 1884 ++--------- .../model_sync/executions/__init__.py | 2 + src/polytomic/model_sync/executions/client.py | 624 +--- .../model_sync/executions/raw_client.py | 962 ++++++ src/polytomic/model_sync/raw_client.py | 2880 +++++++++++++++++ src/polytomic/model_sync/targets/__init__.py | 2 + src/polytomic/model_sync/targets/client.py | 598 +--- .../model_sync/targets/raw_client.py | 958 ++++++ src/polytomic/models/__init__.py | 2 + src/polytomic/models/client.py | 1371 +------- src/polytomic/models/raw_client.py | 2067 ++++++++++++ src/polytomic/notifications/__init__.py | 2 + src/polytomic/notifications/client.py | 233 +- src/polytomic/notifications/raw_client.py | 333 ++ src/polytomic/organization/__init__.py | 2 + src/polytomic/organization/client.py | 598 +--- src/polytomic/organization/raw_client.py | 1014 ++++++ src/polytomic/permissions/__init__.py | 31 +- src/polytomic/permissions/client.py | 80 +- .../permissions/policies/__init__.py | 2 + src/polytomic/permissions/policies/client.py | 659 +--- .../permissions/policies/raw_client.py | 959 ++++++ src/polytomic/permissions/raw_client.py | 13 + src/polytomic/permissions/roles/__init__.py | 2 + src/polytomic/permissions/roles/client.py | 622 +--- src/polytomic/permissions/roles/raw_client.py | 911 ++++++ src/polytomic/query_runner/__init__.py | 2 + src/polytomic/query_runner/client.py | 313 +- src/polytomic/query_runner/raw_client.py | 434 +++ src/polytomic/schemas/__init__.py | 2 + src/polytomic/schemas/client.py | 1005 +----- src/polytomic/schemas/raw_client.py | 1501 +++++++++ src/polytomic/types/__init__.py | 658 ++-- src/polytomic/types/activate_sync_envelope.py | 6 +- src/polytomic/types/activate_sync_input.py | 4 +- src/polytomic/types/activate_sync_output.py | 4 +- src/polytomic/types/api_error.py | 6 +- src/polytomic/types/api_key_response.py | 4 +- .../types/api_key_response_envelope.py | 6 +- .../types/backend_connection_capabilities.py | 4 +- src/polytomic/types/backend_o_auth_prompt.py | 4 +- .../types/bulk_bulk_sync_schedule.py | 60 +- src/polytomic/types/bulk_field.py | 4 +- src/polytomic/types/bulk_filter.py | 6 +- src/polytomic/types/bulk_filter_2.py | 26 + src/polytomic/types/bulk_itemized_schedule.py | 16 +- .../bulk_multi_schedule_configuration.py | 14 +- src/polytomic/types/bulk_schedule.py | 18 +- src/polytomic/types/bulk_schema.py | 22 +- src/polytomic/types/bulk_schema_envelope.py | 6 +- .../types/bulk_schema_execution_status.py | 4 +- .../types/bulk_sync_canceled_event.py | 4 +- .../types/bulk_sync_completed_event.py | 4 +- .../bulk_sync_completed_with_error_event.py | 4 +- src/polytomic/types/bulk_sync_dest.py | 8 +- .../types/bulk_sync_dest_envelope.py | 6 +- src/polytomic/types/bulk_sync_execution.py | 10 +- .../types/bulk_sync_execution_envelope.py | 6 +- .../types/bulk_sync_execution_status.py | 16 +- src/polytomic/types/bulk_sync_failed_event.py | 4 +- .../types/bulk_sync_ingestion_status.py | 28 + .../types/bulk_sync_list_envelope.py | 14 +- src/polytomic/types/bulk_sync_response.py | 37 +- .../types/bulk_sync_response_envelope.py | 14 +- .../types/bulk_sync_running_event.py | 4 +- .../types/bulk_sync_schema_execution.py | 12 +- .../bulk_sync_schema_execution_status.py | 10 +- src/polytomic/types/bulk_sync_source.py | 8 +- .../types/bulk_sync_source_envelope.py | 6 +- .../types/bulk_sync_source_schema_envelope.py | 6 +- .../types/bulk_sync_source_status.py | 6 +- .../types/bulk_sync_source_status_envelope.py | 6 +- .../types/bulk_sync_status_envelope.py | 6 +- .../types/bulk_sync_status_response.py | 10 +- .../types/cancel_bulk_sync_response.py | 4 +- .../cancel_bulk_sync_response_envelope.py | 6 +- .../types/cancel_model_sync_response.py | 4 +- .../cancel_model_sync_response_envelope.py | 6 +- src/polytomic/types/common_output_actor.py | 4 +- src/polytomic/types/configuration_value.py | 6 +- src/polytomic/types/configuration_value_2.py | 20 + src/polytomic/types/connect_card_response.py | 4 +- .../types/connect_card_response_envelope.py | 6 +- .../connection_list_response_envelope.py | 6 +- src/polytomic/types/connection_meta.py | 6 +- .../types/connection_meta_response.py | 6 +- .../types/connection_parameter_value.py | 6 +- .../types/connection_parameter_values_resp.py | 6 +- ...tion_parameter_values_response_envelope.py | 6 +- .../types/connection_response_envelope.py | 6 +- .../types/connection_response_schema.py | 8 +- src/polytomic/types/connection_type.py | 24 +- .../connection_type_response_envelope.py | 6 +- src/polytomic/types/connection_type_schema.py | 4 +- .../create_connection_response_envelope.py | 6 +- .../create_connection_response_schema.py | 6 +- src/polytomic/types/create_model_request.py | 10 +- ...reate_shared_connection_response_schema.py | 4 +- src/polytomic/types/enrichment.py | 6 +- src/polytomic/types/event.py | 8 +- src/polytomic/types/event_body.py | 15 +- src/polytomic/types/event_types_envelope.py | 4 +- src/polytomic/types/events_envelope.py | 6 +- src/polytomic/types/execution_counts.py | 4 +- src/polytomic/types/execution_log_response.py | 6 +- .../types/execution_logs_response_envelope.py | 6 +- src/polytomic/types/field_configuration.py | 4 +- src/polytomic/types/filter.py | 8 +- .../types/get_connection_meta_envelope.py | 6 +- .../types/get_execution_response_envelope.py | 6 +- .../types/get_execution_response_schema.py | 8 +- .../types/get_identity_response_envelope.py | 6 +- .../types/get_identity_response_schema.py | 4 +- .../get_model_sync_source_meta_envelope.py | 6 +- src/polytomic/types/identity.py | 8 +- src/polytomic/types/identity_function.py | 4 +- src/polytomic/types/ingestion_status_level.py | 5 + src/polytomic/types/job_response.py | 8 +- src/polytomic/types/job_response_envelope.py | 6 +- src/polytomic/types/jsonschema_form.py | 2 +- src/polytomic/types/jsonschema_schema.py | 158 +- src/polytomic/types/label_label.py | 2 +- src/polytomic/types/list_bulk_schema.py | 6 +- ...ist_bulk_sync_execution_status_envelope.py | 6 +- .../list_bulk_sync_executions_envelope.py | 10 +- .../types/list_execution_response_envelope.py | 6 +- .../list_model_sync_response_envelope.py | 6 +- .../types/list_policies_response_envelope.py | 6 +- src/polytomic/types/list_users_envelope.py | 6 +- src/polytomic/types/mode.py | 4 +- src/polytomic/types/model_field.py | 10 +- src/polytomic/types/model_field_response.py | 6 +- .../types/model_list_response_envelope.py | 6 +- .../types/model_model_field_request.py | 4 +- src/polytomic/types/model_relation.py | 12 +- src/polytomic/types/model_relation_to.py | 4 +- src/polytomic/types/model_response.py | 12 +- .../types/model_response_envelope.py | 8 +- src/polytomic/types/model_sample.py | 6 +- .../types/model_sample_response_envelope.py | 8 +- src/polytomic/types/model_sync_field.py | 4 +- src/polytomic/types/model_sync_mode.py | 2 +- src/polytomic/types/model_sync_response.py | 10 +- .../types/model_sync_response_envelope.py | 6 +- .../types/model_sync_source_meta_response.py | 10 +- src/polytomic/types/organization.py | 4 +- src/polytomic/types/organization_envelope.py | 6 +- src/polytomic/types/organizations_envelope.py | 6 +- src/polytomic/types/override.py | 10 +- src/polytomic/types/pagination.py | 4 +- src/polytomic/types/pagination_details.py | 4 +- src/polytomic/types/pagination_details_2.py | 19 + src/polytomic/types/pick_value.py | 4 +- src/polytomic/types/policy_action.py | 4 +- src/polytomic/types/policy_response.py | 6 +- .../types/policy_response_envelope.py | 6 +- src/polytomic/types/relation.py | 12 +- src/polytomic/types/relation_to.py | 4 +- src/polytomic/types/rest_err_response.py | 6 +- .../types/role_list_response_envelope.py | 6 +- src/polytomic/types/role_response.py | 4 +- src/polytomic/types/role_response_envelope.py | 6 +- src/polytomic/types/run_after.py | 4 +- src/polytomic/types/schedule.py | 8 +- src/polytomic/types/schedule_envelope.py | 6 +- .../types/schedule_option_response.py | 6 +- .../schedule_option_response_envelope.py | 6 +- .../types/schedule_schedule_option.py | 6 +- src/polytomic/types/schedules_envelope.py | 6 +- src/polytomic/types/schema.py | 6 +- src/polytomic/types/schema_association.py | 4 +- src/polytomic/types/schema_configuration.py | 8 +- src/polytomic/types/schema_field.py | 10 +- .../schema_primary_key_override_input.py | 4 +- .../types/schema_records_response_envelope.py | 6 +- src/polytomic/types/source.py | 4 +- src/polytomic/types/source_meta.py | 6 +- .../start_model_sync_response_envelope.py | 6 +- .../types/start_model_sync_response_schema.py | 6 +- src/polytomic/types/supported_bulk_mode.py | 6 +- src/polytomic/types/supported_mode.py | 6 +- src/polytomic/types/sync_canceled_event.py | 6 +- src/polytomic/types/sync_completed_event.py | 6 +- .../types/sync_completed_with_errors_event.py | 4 +- .../types/sync_destination_properties.py | 4 +- src/polytomic/types/sync_failed_event.py | 4 +- src/polytomic/types/sync_running_event.py | 4 +- src/polytomic/types/sync_status_envelope.py | 6 +- src/polytomic/types/sync_status_response.py | 8 +- src/polytomic/types/target.py | 8 +- src/polytomic/types/target_create_input.py | 4 +- src/polytomic/types/target_field.py | 6 +- src/polytomic/types/target_object.py | 4 +- src/polytomic/types/target_response.py | 10 +- .../types/target_response_envelope.py | 6 +- src/polytomic/types/types_type.py | 2 +- src/polytomic/types/update_bulk_field.py | 4 +- src/polytomic/types/user.py | 4 +- src/polytomic/types/user_envelope.py | 6 +- src/polytomic/types/util_enum_value.py | 4 +- src/polytomic/types/v_2_connection_form.py | 8 +- ...ate_shared_connection_response_envelope.py | 6 +- .../types/v_2_enricher_configuration.py | 2 +- ...richment_input_fields_response_envelope.py | 4 +- ...ng_github_com_invopop_jsonschema_schema.py | 2 +- src/polytomic/types/v_2_sample_record.py | 2 +- .../v_2_schema_configuration_fields_item.py | 1 + .../types/v_4_bulk_sync_execution_logs.py | 2 +- .../v_4_bulk_sync_execution_logs_envelope.py | 6 +- .../types/v_4_bulk_sync_schedule_api.py | 20 +- .../types/v_4_export_sync_logs_envelope.py | 8 +- .../types/v_4_export_sync_logs_response.py | 4 +- .../v_4_global_error_subscribers_response.py | 4 +- .../types/v_4_query_results_envelope.py | 8 +- src/polytomic/types/v_4_run_query_envelope.py | 6 +- src/polytomic/types/v_4_run_query_result.py | 8 +- src/polytomic/types/v_4_target_creator.py | 6 +- .../v_4_target_objects_response_envelope.py | 6 +- .../types/v_4_target_property_values.py | 4 +- .../v_4_target_property_values_envelope.py | 6 +- src/polytomic/types/v_4_user_field_request.py | 6 +- src/polytomic/types/webhook.py | 6 +- src/polytomic/types/webhook_envelope.py | 6 +- src/polytomic/types/webhook_list_envelope.py | 6 +- src/polytomic/users/__init__.py | 2 + src/polytomic/users/client.py | 818 +---- src/polytomic/users/raw_client.py | 1200 +++++++ src/polytomic/webhooks/__init__.py | 2 + src/polytomic/webhooks/client.py | 727 +---- src/polytomic/webhooks/raw_client.py | 1168 +++++++ tests/custom/test_client.py | 2 +- tests/utils/assets/models/__init__.py | 2 +- tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +- tests/utils/assets/models/shape.py | 6 +- tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + tests/utils/test_http_client.py | 249 +- tests/utils/test_query_encoding.py | 3 +- tests/utils/test_serialization.py | 6 +- 302 files changed, 30368 insertions(+), 15846 deletions(-) create mode 100644 .fern/metadata.json create mode 100644 src/polytomic/bulk_sync/executions/raw_client.py create mode 100644 src/polytomic/bulk_sync/raw_client.py create mode 100644 src/polytomic/bulk_sync/schedules/raw_client.py create mode 100644 src/polytomic/bulk_sync/schemas/raw_client.py create mode 100644 src/polytomic/connections/raw_client.py create mode 100644 src/polytomic/core/force_multipart.py create mode 100644 src/polytomic/core/http_response.py create mode 100644 src/polytomic/core/http_sse/__init__.py create mode 100644 src/polytomic/core/http_sse/_api.py create mode 100644 src/polytomic/core/http_sse/_decoders.py create mode 100644 src/polytomic/core/http_sse/_exceptions.py create mode 100644 src/polytomic/core/http_sse/_models.py create mode 100644 src/polytomic/core/logging.py create mode 100644 src/polytomic/core/parse_error.py create mode 100644 src/polytomic/events/raw_client.py create mode 100644 src/polytomic/identity/raw_client.py create mode 100644 src/polytomic/jobs/raw_client.py create mode 100644 src/polytomic/model_sync/executions/raw_client.py create mode 100644 src/polytomic/model_sync/raw_client.py create mode 100644 src/polytomic/model_sync/targets/raw_client.py create mode 100644 src/polytomic/models/raw_client.py create mode 100644 src/polytomic/notifications/raw_client.py create mode 100644 src/polytomic/organization/raw_client.py create mode 100644 src/polytomic/permissions/policies/raw_client.py create mode 100644 src/polytomic/permissions/raw_client.py create mode 100644 src/polytomic/permissions/roles/raw_client.py create mode 100644 src/polytomic/query_runner/raw_client.py create mode 100644 src/polytomic/schemas/raw_client.py create mode 100644 src/polytomic/types/bulk_filter_2.py create mode 100644 src/polytomic/types/bulk_sync_ingestion_status.py create mode 100644 src/polytomic/types/configuration_value_2.py create mode 100644 src/polytomic/types/ingestion_status_level.py create mode 100644 src/polytomic/types/pagination_details_2.py create mode 100644 src/polytomic/users/raw_client.py create mode 100644 src/polytomic/webhooks/raw_client.py diff --git a/.fern/metadata.json b/.fern/metadata.json new file mode 100644 index 0000000..ff0ded8 --- /dev/null +++ b/.fern/metadata.json @@ -0,0 +1,10 @@ +{ + "cliVersion": "4.48.1", + "generatorName": "fernapi/fern-python-sdk", + "generatorVersion": "4.64.1", + "generatorConfig": { + "client_class_name": "Polytomic" + }, + "originGitCommit": "913cf94029db4c2f1775516f624f18b82067e333", + "sdkVersion": "1.16.2" +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0da665f..d2e4ca8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -dist/ .mypy_cache/ +.ruff_cache/ __pycache__/ +dist/ poetry.toml -.ruff_cache/ diff --git a/poetry.lock b/poetry.lock index ea2269c..fdfe780 100644 --- a/poetry.lock +++ b/poetry.lock @@ -75,6 +75,20 @@ typing-extensions = {version = ">=4.6.0", markers = "python_version < \"3.13\""} [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "execnet" +version = "2.1.2" +description = "execnet: rapid multi-Python deployment" +optional = false +python-versions = ">=3.8" +files = [ + {file = "execnet-2.1.2-py3-none-any.whl", hash = "sha256:67fba928dd5a544b783f6056f449e5e3931a5c378b128bc18501f7ea79e296ec"}, + {file = "execnet-2.1.2.tar.gz", hash = "sha256:63d83bfdd9a23e35b9c6a3261412324f964c2ec8dcd8d3c6916ee9373e0befcd"}, +] + +[package.extras] +testing = ["hatch", "pre-commit", "pytest", "tox"] + [[package]] name = "h11" version = "0.16.0" @@ -158,48 +172,55 @@ files = [ [[package]] name = "mypy" -version = "1.0.1" +version = "1.13.0" description = "Optional static typing for Python" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "mypy-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:71a808334d3f41ef011faa5a5cd8153606df5fc0b56de5b2e89566c8093a0c9a"}, - {file = "mypy-1.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:920169f0184215eef19294fa86ea49ffd4635dedfdea2b57e45cb4ee85d5ccaf"}, - {file = "mypy-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:27a0f74a298769d9fdc8498fcb4f2beb86f0564bcdb1a37b58cbbe78e55cf8c0"}, - {file = "mypy-1.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:65b122a993d9c81ea0bfde7689b3365318a88bde952e4dfa1b3a8b4ac05d168b"}, - {file = "mypy-1.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:5deb252fd42a77add936b463033a59b8e48eb2eaec2976d76b6878d031933fe4"}, - {file = "mypy-1.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:2013226d17f20468f34feddd6aae4635a55f79626549099354ce641bc7d40262"}, - {file = "mypy-1.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:48525aec92b47baed9b3380371ab8ab6e63a5aab317347dfe9e55e02aaad22e8"}, - {file = "mypy-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c96b8a0c019fe29040d520d9257d8c8f122a7343a8307bf8d6d4a43f5c5bfcc8"}, - {file = "mypy-1.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:448de661536d270ce04f2d7dddaa49b2fdba6e3bd8a83212164d4174ff43aa65"}, - {file = "mypy-1.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:d42a98e76070a365a1d1c220fcac8aa4ada12ae0db679cb4d910fabefc88b994"}, - {file = "mypy-1.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:e64f48c6176e243ad015e995de05af7f22bbe370dbb5b32bd6988438ec873919"}, - {file = "mypy-1.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5fdd63e4f50e3538617887e9aee91855368d9fc1dea30da743837b0df7373bc4"}, - {file = "mypy-1.0.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:dbeb24514c4acbc78d205f85dd0e800f34062efcc1f4a4857c57e4b4b8712bff"}, - {file = "mypy-1.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:a2948c40a7dd46c1c33765718936669dc1f628f134013b02ff5ac6c7ef6942bf"}, - {file = "mypy-1.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5bc8d6bd3b274dd3846597855d96d38d947aedba18776aa998a8d46fabdaed76"}, - {file = "mypy-1.0.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:17455cda53eeee0a4adb6371a21dd3dbf465897de82843751cf822605d152c8c"}, - {file = "mypy-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e831662208055b006eef68392a768ff83596035ffd6d846786578ba1714ba8f6"}, - {file = "mypy-1.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:e60d0b09f62ae97a94605c3f73fd952395286cf3e3b9e7b97f60b01ddfbbda88"}, - {file = "mypy-1.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:0af4f0e20706aadf4e6f8f8dc5ab739089146b83fd53cb4a7e0e850ef3de0bb6"}, - {file = "mypy-1.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:24189f23dc66f83b839bd1cce2dfc356020dfc9a8bae03978477b15be61b062e"}, - {file = "mypy-1.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:93a85495fb13dc484251b4c1fd7a5ac370cd0d812bbfc3b39c1bafefe95275d5"}, - {file = "mypy-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f546ac34093c6ce33f6278f7c88f0f147a4849386d3bf3ae193702f4fe31407"}, - {file = "mypy-1.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:c6c2ccb7af7154673c591189c3687b013122c5a891bb5651eca3db8e6c6c55bd"}, - {file = "mypy-1.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:15b5a824b58c7c822c51bc66308e759243c32631896743f030daf449fe3677f3"}, - {file = "mypy-1.0.1-py3-none-any.whl", hash = "sha256:eda5c8b9949ed411ff752b9a01adda31afe7eae1e53e946dbdf9db23865e66c4"}, - {file = "mypy-1.0.1.tar.gz", hash = "sha256:28cea5a6392bb43d266782983b5a4216c25544cd7d80be681a155ddcdafd152d"}, + {file = "mypy-1.13.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6607e0f1dd1fb7f0aca14d936d13fd19eba5e17e1cd2a14f808fa5f8f6d8f60a"}, + {file = "mypy-1.13.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8a21be69bd26fa81b1f80a61ee7ab05b076c674d9b18fb56239d72e21d9f4c80"}, + {file = "mypy-1.13.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7b2353a44d2179846a096e25691d54d59904559f4232519d420d64da6828a3a7"}, + {file = "mypy-1.13.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:0730d1c6a2739d4511dc4253f8274cdd140c55c32dfb0a4cf8b7a43f40abfa6f"}, + {file = "mypy-1.13.0-cp310-cp310-win_amd64.whl", hash = "sha256:c5fc54dbb712ff5e5a0fca797e6e0aa25726c7e72c6a5850cfd2adbc1eb0a372"}, + {file = "mypy-1.13.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:581665e6f3a8a9078f28d5502f4c334c0c8d802ef55ea0e7276a6e409bc0d82d"}, + {file = "mypy-1.13.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3ddb5b9bf82e05cc9a627e84707b528e5c7caaa1c55c69e175abb15a761cec2d"}, + {file = "mypy-1.13.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:20c7ee0bc0d5a9595c46f38beb04201f2620065a93755704e141fcac9f59db2b"}, + {file = "mypy-1.13.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:3790ded76f0b34bc9c8ba4def8f919dd6a46db0f5a6610fb994fe8efdd447f73"}, + {file = "mypy-1.13.0-cp311-cp311-win_amd64.whl", hash = "sha256:51f869f4b6b538229c1d1bcc1dd7d119817206e2bc54e8e374b3dfa202defcca"}, + {file = "mypy-1.13.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:5c7051a3461ae84dfb5dd15eff5094640c61c5f22257c8b766794e6dd85e72d5"}, + {file = "mypy-1.13.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:39bb21c69a5d6342f4ce526e4584bc5c197fd20a60d14a8624d8743fffb9472e"}, + {file = "mypy-1.13.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:164f28cb9d6367439031f4c81e84d3ccaa1e19232d9d05d37cb0bd880d3f93c2"}, + {file = "mypy-1.13.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a4c1bfcdbce96ff5d96fc9b08e3831acb30dc44ab02671eca5953eadad07d6d0"}, + {file = "mypy-1.13.0-cp312-cp312-win_amd64.whl", hash = "sha256:a0affb3a79a256b4183ba09811e3577c5163ed06685e4d4b46429a271ba174d2"}, + {file = "mypy-1.13.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:a7b44178c9760ce1a43f544e595d35ed61ac2c3de306599fa59b38a6048e1aa7"}, + {file = "mypy-1.13.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:5d5092efb8516d08440e36626f0153b5006d4088c1d663d88bf79625af3d1d62"}, + {file = "mypy-1.13.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:de2904956dac40ced10931ac967ae63c5089bd498542194b436eb097a9f77bc8"}, + {file = "mypy-1.13.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:7bfd8836970d33c2105562650656b6846149374dc8ed77d98424b40b09340ba7"}, + {file = "mypy-1.13.0-cp313-cp313-win_amd64.whl", hash = "sha256:9f73dba9ec77acb86457a8fc04b5239822df0c14a082564737833d2963677dbc"}, + {file = "mypy-1.13.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:100fac22ce82925f676a734af0db922ecfea991e1d7ec0ceb1e115ebe501301a"}, + {file = "mypy-1.13.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7bcb0bb7f42a978bb323a7c88f1081d1b5dee77ca86f4100735a6f541299d8fb"}, + {file = "mypy-1.13.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bde31fc887c213e223bbfc34328070996061b0833b0a4cfec53745ed61f3519b"}, + {file = "mypy-1.13.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:07de989f89786f62b937851295ed62e51774722e5444a27cecca993fc3f9cd74"}, + {file = "mypy-1.13.0-cp38-cp38-win_amd64.whl", hash = "sha256:4bde84334fbe19bad704b3f5b78c4abd35ff1026f8ba72b29de70dda0916beb6"}, + {file = "mypy-1.13.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0246bcb1b5de7f08f2826451abd947bf656945209b140d16ed317f65a17dc7dc"}, + {file = "mypy-1.13.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:7f5b7deae912cf8b77e990b9280f170381fdfbddf61b4ef80927edd813163732"}, + {file = "mypy-1.13.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7029881ec6ffb8bc233a4fa364736789582c738217b133f1b55967115288a2bc"}, + {file = "mypy-1.13.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:3e38b980e5681f28f033f3be86b099a247b13c491f14bb8b1e1e134d23bb599d"}, + {file = "mypy-1.13.0-cp39-cp39-win_amd64.whl", hash = "sha256:a6789be98a2017c912ae6ccb77ea553bbaf13d27605d2ca20a76dfbced631b24"}, + {file = "mypy-1.13.0-py3-none-any.whl", hash = "sha256:9c250883f9fd81d212e0952c92dbfcc96fc237f4b7c92f56ac81fd48460b3e5a"}, + {file = "mypy-1.13.0.tar.gz", hash = "sha256:0291a61b6fbf3e6673e3405cfcc0e7650bebc7939659fdca2702958038bd835e"}, ] [package.dependencies] -mypy-extensions = ">=0.4.3" +mypy-extensions = ">=1.0.0" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = ">=3.10" +typing-extensions = ">=4.6.0" [package.extras] dmypy = ["psutil (>=4.0)"] +faster-cache = ["orjson"] install-types = ["pip"] -python2 = ["typed-ast (>=1.4.0,<2)"] +mypyc = ["setuptools (>=50)"] reports = ["lxml"] [[package]] @@ -411,6 +432,26 @@ pytest = ">=7.0.0,<9" docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"] +[[package]] +name = "pytest-xdist" +version = "3.6.1" +description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pytest_xdist-3.6.1-py3-none-any.whl", hash = "sha256:9ed4adfb68a016610848639bb7e02c9352d5d9f03d04809919e2dafc3be4cca7"}, + {file = "pytest_xdist-3.6.1.tar.gz", hash = "sha256:ead156a4db231eec769737f57668ef58a2084a34b2e55c4a8fa20d861107300d"}, +] + +[package.dependencies] +execnet = ">=2.1" +pytest = ">=7.0.0" + +[package.extras] +psutil = ["psutil (>=3.0)"] +setproctitle = ["setproctitle"] +testing = ["filelock"] + [[package]] name = "python-dateutil" version = "2.9.0.post0" @@ -427,29 +468,29 @@ six = ">=1.5" [[package]] name = "ruff" -version = "0.5.7" +version = "0.11.5" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.5.7-py3-none-linux_armv6l.whl", hash = "sha256:548992d342fc404ee2e15a242cdbea4f8e39a52f2e7752d0e4cbe88d2d2f416a"}, - {file = "ruff-0.5.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:00cc8872331055ee017c4f1071a8a31ca0809ccc0657da1d154a1d2abac5c0be"}, - {file = "ruff-0.5.7-py3-none-macosx_11_0_arm64.whl", hash = "sha256:eaf3d86a1fdac1aec8a3417a63587d93f906c678bb9ed0b796da7b59c1114a1e"}, - {file = "ruff-0.5.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a01c34400097b06cf8a6e61b35d6d456d5bd1ae6961542de18ec81eaf33b4cb8"}, - {file = "ruff-0.5.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:fcc8054f1a717e2213500edaddcf1dbb0abad40d98e1bd9d0ad364f75c763eea"}, - {file = "ruff-0.5.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7f70284e73f36558ef51602254451e50dd6cc479f8b6f8413a95fcb5db4a55fc"}, - {file = "ruff-0.5.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:a78ad870ae3c460394fc95437d43deb5c04b5c29297815a2a1de028903f19692"}, - {file = "ruff-0.5.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9ccd078c66a8e419475174bfe60a69adb36ce04f8d4e91b006f1329d5cd44bcf"}, - {file = "ruff-0.5.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7e31c9bad4ebf8fdb77b59cae75814440731060a09a0e0077d559a556453acbb"}, - {file = "ruff-0.5.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d796327eed8e168164346b769dd9a27a70e0298d667b4ecee6877ce8095ec8e"}, - {file = "ruff-0.5.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:4a09ea2c3f7778cc635e7f6edf57d566a8ee8f485f3c4454db7771efb692c499"}, - {file = "ruff-0.5.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:a36d8dcf55b3a3bc353270d544fb170d75d2dff41eba5df57b4e0b67a95bb64e"}, - {file = "ruff-0.5.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:9369c218f789eefbd1b8d82a8cf25017b523ac47d96b2f531eba73770971c9e5"}, - {file = "ruff-0.5.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:b88ca3db7eb377eb24fb7c82840546fb7acef75af4a74bd36e9ceb37a890257e"}, - {file = "ruff-0.5.7-py3-none-win32.whl", hash = "sha256:33d61fc0e902198a3e55719f4be6b375b28f860b09c281e4bdbf783c0566576a"}, - {file = "ruff-0.5.7-py3-none-win_amd64.whl", hash = "sha256:083bbcbe6fadb93cd86709037acc510f86eed5a314203079df174c40bbbca6b3"}, - {file = "ruff-0.5.7-py3-none-win_arm64.whl", hash = "sha256:2dca26154ff9571995107221d0aeaad0e75a77b5a682d6236cf89a58c70b76f4"}, - {file = "ruff-0.5.7.tar.gz", hash = "sha256:8dfc0a458797f5d9fb622dd0efc52d796f23f0a1493a9527f4e49a550ae9a7e5"}, + {file = "ruff-0.11.5-py3-none-linux_armv6l.whl", hash = "sha256:2561294e108eb648e50f210671cc56aee590fb6167b594144401532138c66c7b"}, + {file = "ruff-0.11.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:ac12884b9e005c12d0bd121f56ccf8033e1614f736f766c118ad60780882a077"}, + {file = "ruff-0.11.5-py3-none-macosx_11_0_arm64.whl", hash = "sha256:4bfd80a6ec559a5eeb96c33f832418bf0fb96752de0539905cf7b0cc1d31d779"}, + {file = "ruff-0.11.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0947c0a1afa75dcb5db4b34b070ec2bccee869d40e6cc8ab25aca11a7d527794"}, + {file = "ruff-0.11.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ad871ff74b5ec9caa66cb725b85d4ef89b53f8170f47c3406e32ef040400b038"}, + {file = "ruff-0.11.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e6cf918390cfe46d240732d4d72fa6e18e528ca1f60e318a10835cf2fa3dc19f"}, + {file = "ruff-0.11.5-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:56145ee1478582f61c08f21076dc59153310d606ad663acc00ea3ab5b2125f82"}, + {file = "ruff-0.11.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e5f66f8f1e8c9fc594cbd66fbc5f246a8d91f916cb9667e80208663ec3728304"}, + {file = "ruff-0.11.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:80b4df4d335a80315ab9afc81ed1cff62be112bd165e162b5eed8ac55bfc8470"}, + {file = "ruff-0.11.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3068befab73620b8a0cc2431bd46b3cd619bc17d6f7695a3e1bb166b652c382a"}, + {file = "ruff-0.11.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:f5da2e710a9641828e09aa98b92c9ebbc60518fdf3921241326ca3e8f8e55b8b"}, + {file = "ruff-0.11.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:ef39f19cb8ec98cbc762344921e216f3857a06c47412030374fffd413fb8fd3a"}, + {file = "ruff-0.11.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:b2a7cedf47244f431fd11aa5a7e2806dda2e0c365873bda7834e8f7d785ae159"}, + {file = "ruff-0.11.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:81be52e7519f3d1a0beadcf8e974715b2dfc808ae8ec729ecfc79bddf8dbb783"}, + {file = "ruff-0.11.5-py3-none-win32.whl", hash = "sha256:e268da7b40f56e3eca571508a7e567e794f9bfcc0f412c4b607931d3af9c4afe"}, + {file = "ruff-0.11.5-py3-none-win_amd64.whl", hash = "sha256:6c6dc38af3cfe2863213ea25b6dc616d679205732dc0fb673356c2d69608f800"}, + {file = "ruff-0.11.5-py3-none-win_arm64.whl", hash = "sha256:67e241b4314f4eacf14a601d586026a962f4002a475aa702c69980a38087aa4e"}, + {file = "ruff-0.11.5.tar.gz", hash = "sha256:cae2e2439cb88853e421901ec040a758960b576126dab520fa08e9de431d1bef"}, ] [[package]] @@ -476,58 +517,58 @@ files = [ [[package]] name = "tomli" -version = "2.4.0" +version = "2.4.1" description = "A lil' TOML parser" optional = false python-versions = ">=3.8" files = [ - {file = "tomli-2.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b5ef256a3fd497d4973c11bf142e9ed78b150d36f5773f1ca6088c230ffc5867"}, - {file = "tomli-2.4.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5572e41282d5268eb09a697c89a7bee84fae66511f87533a6f88bd2f7b652da9"}, - {file = "tomli-2.4.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:551e321c6ba03b55676970b47cb1b73f14a0a4dce6a3e1a9458fd6d921d72e95"}, - {file = "tomli-2.4.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5e3f639a7a8f10069d0e15408c0b96a2a828cfdec6fca05296ebcdcc28ca7c76"}, - {file = "tomli-2.4.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1b168f2731796b045128c45982d3a4874057626da0e2ef1fdd722848b741361d"}, - {file = "tomli-2.4.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:133e93646ec4300d651839d382d63edff11d8978be23da4cc106f5a18b7d0576"}, - {file = "tomli-2.4.0-cp311-cp311-win32.whl", hash = "sha256:b6c78bdf37764092d369722d9946cb65b8767bfa4110f902a1b2542d8d173c8a"}, - {file = "tomli-2.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:d3d1654e11d724760cdb37a3d7691f0be9db5fbdaef59c9f532aabf87006dbaa"}, - {file = "tomli-2.4.0-cp311-cp311-win_arm64.whl", hash = "sha256:cae9c19ed12d4e8f3ebf46d1a75090e4c0dc16271c5bce1c833ac168f08fb614"}, - {file = "tomli-2.4.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:920b1de295e72887bafa3ad9f7a792f811847d57ea6b1215154030cf131f16b1"}, - {file = "tomli-2.4.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:7d6d9a4aee98fac3eab4952ad1d73aee87359452d1c086b5ceb43ed02ddb16b8"}, - {file = "tomli-2.4.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:36b9d05b51e65b254ea6c2585b59d2c4cb91c8a3d91d0ed0f17591a29aaea54a"}, - {file = "tomli-2.4.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1c8a885b370751837c029ef9bc014f27d80840e48bac415f3412e6593bbc18c1"}, - {file = "tomli-2.4.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8768715ffc41f0008abe25d808c20c3d990f42b6e2e58305d5da280ae7d1fa3b"}, - {file = "tomli-2.4.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:7b438885858efd5be02a9a133caf5812b8776ee0c969fea02c45e8e3f296ba51"}, - {file = "tomli-2.4.0-cp312-cp312-win32.whl", hash = "sha256:0408e3de5ec77cc7f81960c362543cbbd91ef883e3138e81b729fc3eea5b9729"}, - {file = "tomli-2.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:685306e2cc7da35be4ee914fd34ab801a6acacb061b6a7abca922aaf9ad368da"}, - {file = "tomli-2.4.0-cp312-cp312-win_arm64.whl", hash = "sha256:5aa48d7c2356055feef06a43611fc401a07337d5b006be13a30f6c58f869e3c3"}, - {file = "tomli-2.4.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:84d081fbc252d1b6a982e1870660e7330fb8f90f676f6e78b052ad4e64714bf0"}, - {file = "tomli-2.4.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:9a08144fa4cba33db5255f9b74f0b89888622109bd2776148f2597447f92a94e"}, - {file = "tomli-2.4.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c73add4bb52a206fd0c0723432db123c0c75c280cbd67174dd9d2db228ebb1b4"}, - {file = "tomli-2.4.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1fb2945cbe303b1419e2706e711b7113da57b7db31ee378d08712d678a34e51e"}, - {file = "tomli-2.4.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:bbb1b10aa643d973366dc2cb1ad94f99c1726a02343d43cbc011edbfac579e7c"}, - {file = "tomli-2.4.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4cbcb367d44a1f0c2be408758b43e1ffb5308abe0ea222897d6bfc8e8281ef2f"}, - {file = "tomli-2.4.0-cp313-cp313-win32.whl", hash = "sha256:7d49c66a7d5e56ac959cb6fc583aff0651094ec071ba9ad43df785abc2320d86"}, - {file = "tomli-2.4.0-cp313-cp313-win_amd64.whl", hash = "sha256:3cf226acb51d8f1c394c1b310e0e0e61fecdd7adcb78d01e294ac297dd2e7f87"}, - {file = "tomli-2.4.0-cp313-cp313-win_arm64.whl", hash = "sha256:d20b797a5c1ad80c516e41bc1fb0443ddb5006e9aaa7bda2d71978346aeb9132"}, - {file = "tomli-2.4.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:26ab906a1eb794cd4e103691daa23d95c6919cc2fa9160000ac02370cc9dd3f6"}, - {file = "tomli-2.4.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:20cedb4ee43278bc4f2fee6cb50daec836959aadaf948db5172e776dd3d993fc"}, - {file = "tomli-2.4.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:39b0b5d1b6dd03684b3fb276407ebed7090bbec989fa55838c98560c01113b66"}, - {file = "tomli-2.4.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a26d7ff68dfdb9f87a016ecfd1e1c2bacbe3108f4e0f8bcd2228ef9a766c787d"}, - {file = "tomli-2.4.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:20ffd184fb1df76a66e34bd1b36b4a4641bd2b82954befa32fe8163e79f1a702"}, - {file = "tomli-2.4.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:75c2f8bbddf170e8effc98f5e9084a8751f8174ea6ccf4fca5398436e0320bc8"}, - {file = "tomli-2.4.0-cp314-cp314-win32.whl", hash = "sha256:31d556d079d72db7c584c0627ff3a24c5d3fb4f730221d3444f3efb1b2514776"}, - {file = "tomli-2.4.0-cp314-cp314-win_amd64.whl", hash = "sha256:43e685b9b2341681907759cf3a04e14d7104b3580f808cfde1dfdb60ada85475"}, - {file = "tomli-2.4.0-cp314-cp314-win_arm64.whl", hash = "sha256:3d895d56bd3f82ddd6faaff993c275efc2ff38e52322ea264122d72729dca2b2"}, - {file = "tomli-2.4.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:5b5807f3999fb66776dbce568cc9a828544244a8eb84b84b9bafc080c99597b9"}, - {file = "tomli-2.4.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c084ad935abe686bd9c898e62a02a19abfc9760b5a79bc29644463eaf2840cb0"}, - {file = "tomli-2.4.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0f2e3955efea4d1cfbcb87bc321e00dc08d2bcb737fd1d5e398af111d86db5df"}, - {file = "tomli-2.4.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0e0fe8a0b8312acf3a88077a0802565cb09ee34107813bba1c7cd591fa6cfc8d"}, - {file = "tomli-2.4.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:413540dce94673591859c4c6f794dfeaa845e98bf35d72ed59636f869ef9f86f"}, - {file = "tomli-2.4.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:0dc56fef0e2c1c470aeac5b6ca8cc7b640bb93e92d9803ddaf9ea03e198f5b0b"}, - {file = "tomli-2.4.0-cp314-cp314t-win32.whl", hash = "sha256:d878f2a6707cc9d53a1be1414bbb419e629c3d6e67f69230217bb663e76b5087"}, - {file = "tomli-2.4.0-cp314-cp314t-win_amd64.whl", hash = "sha256:2add28aacc7425117ff6364fe9e06a183bb0251b03f986df0e78e974047571fd"}, - {file = "tomli-2.4.0-cp314-cp314t-win_arm64.whl", hash = "sha256:2b1e3b80e1d5e52e40e9b924ec43d81570f0e7d09d11081b797bc4692765a3d4"}, - {file = "tomli-2.4.0-py3-none-any.whl", hash = "sha256:1f776e7d669ebceb01dee46484485f43a4048746235e683bcdffacdf1fb4785a"}, - {file = "tomli-2.4.0.tar.gz", hash = "sha256:aa89c3f6c277dd275d8e243ad24f3b5e701491a860d5121f2cdd399fbb31fc9c"}, + {file = "tomli-2.4.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f8f0fc26ec2cc2b965b7a3b87cd19c5c6b8c5e5f436b984e85f486d652285c30"}, + {file = "tomli-2.4.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4ab97e64ccda8756376892c53a72bd1f964e519c77236368527f758fbc36a53a"}, + {file = "tomli-2.4.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:96481a5786729fd470164b47cdb3e0e58062a496f455ee41b4403be77cb5a076"}, + {file = "tomli-2.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5a881ab208c0baf688221f8cecc5401bd291d67e38a1ac884d6736cbcd8247e9"}, + {file = "tomli-2.4.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:47149d5bd38761ac8be13a84864bf0b7b70bc051806bc3669ab1cbc56216b23c"}, + {file = "tomli-2.4.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ec9bfaf3ad2df51ace80688143a6a4ebc09a248f6ff781a9945e51937008fcbc"}, + {file = "tomli-2.4.1-cp311-cp311-win32.whl", hash = "sha256:ff2983983d34813c1aeb0fa89091e76c3a22889ee83ab27c5eeb45100560c049"}, + {file = "tomli-2.4.1-cp311-cp311-win_amd64.whl", hash = "sha256:5ee18d9ebdb417e384b58fe414e8d6af9f4e7a0ae761519fb50f721de398dd4e"}, + {file = "tomli-2.4.1-cp311-cp311-win_arm64.whl", hash = "sha256:c2541745709bad0264b7d4705ad453b76ccd191e64aa6f0fc66b69a293a45ece"}, + {file = "tomli-2.4.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:c742f741d58a28940ce01d58f0ab2ea3ced8b12402f162f4d534dfe18ba1cd6a"}, + {file = "tomli-2.4.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:7f86fd587c4ed9dd76f318225e7d9b29cfc5a9d43de44e5754db8d1128487085"}, + {file = "tomli-2.4.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ff18e6a727ee0ab0388507b89d1bc6a22b138d1e2fa56d1ad494586d61d2eae9"}, + {file = "tomli-2.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:136443dbd7e1dee43c68ac2694fde36b2849865fa258d39bf822c10e8068eac5"}, + {file = "tomli-2.4.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:5e262d41726bc187e69af7825504c933b6794dc3fbd5945e41a79bb14c31f585"}, + {file = "tomli-2.4.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:5cb41aa38891e073ee49d55fbc7839cfdb2bc0e600add13874d048c94aadddd1"}, + {file = "tomli-2.4.1-cp312-cp312-win32.whl", hash = "sha256:da25dc3563bff5965356133435b757a795a17b17d01dbc0f42fb32447ddfd917"}, + {file = "tomli-2.4.1-cp312-cp312-win_amd64.whl", hash = "sha256:52c8ef851d9a240f11a88c003eacb03c31fc1c9c4ec64a99a0f922b93874fda9"}, + {file = "tomli-2.4.1-cp312-cp312-win_arm64.whl", hash = "sha256:f758f1b9299d059cc3f6546ae2af89670cb1c4d48ea29c3cacc4fe7de3058257"}, + {file = "tomli-2.4.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:36d2bd2ad5fb9eaddba5226aa02c8ec3fa4f192631e347b3ed28186d43be6b54"}, + {file = "tomli-2.4.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:eb0dc4e38e6a1fd579e5d50369aa2e10acfc9cace504579b2faabb478e76941a"}, + {file = "tomli-2.4.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c7f2c7f2b9ca6bdeef8f0fa897f8e05085923eb091721675170254cbc5b02897"}, + {file = "tomli-2.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f3c6818a1a86dd6dca7ddcaaf76947d5ba31aecc28cb1b67009a5877c9a64f3f"}, + {file = "tomli-2.4.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:d312ef37c91508b0ab2cee7da26ec0b3ed2f03ce12bd87a588d771ae15dcf82d"}, + {file = "tomli-2.4.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:51529d40e3ca50046d7606fa99ce3956a617f9b36380da3b7f0dd3dd28e68cb5"}, + {file = "tomli-2.4.1-cp313-cp313-win32.whl", hash = "sha256:2190f2e9dd7508d2a90ded5ed369255980a1bcdd58e52f7fe24b8162bf9fedbd"}, + {file = "tomli-2.4.1-cp313-cp313-win_amd64.whl", hash = "sha256:8d65a2fbf9d2f8352685bc1364177ee3923d6baf5e7f43ea4959d7d8bc326a36"}, + {file = "tomli-2.4.1-cp313-cp313-win_arm64.whl", hash = "sha256:4b605484e43cdc43f0954ddae319fb75f04cc10dd80d830540060ee7cd0243cd"}, + {file = "tomli-2.4.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:fd0409a3653af6c147209d267a0e4243f0ae46b011aa978b1080359fddc9b6cf"}, + {file = "tomli-2.4.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:a120733b01c45e9a0c34aeef92bf0cf1d56cfe81ed9d47d562f9ed591a9828ac"}, + {file = "tomli-2.4.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:559db847dc486944896521f68d8190be1c9e719fced785720d2216fe7022b662"}, + {file = "tomli-2.4.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:01f520d4f53ef97964a240a035ec2a869fe1a37dde002b57ebc4417a27ccd853"}, + {file = "tomli-2.4.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7f94b27a62cfad8496c8d2513e1a222dd446f095fca8987fceef261225538a15"}, + {file = "tomli-2.4.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:ede3e6487c5ef5d28634ba3f31f989030ad6af71edfb0055cbbd14189ff240ba"}, + {file = "tomli-2.4.1-cp314-cp314-win32.whl", hash = "sha256:3d48a93ee1c9b79c04bb38772ee1b64dcf18ff43085896ea460ca8dec96f35f6"}, + {file = "tomli-2.4.1-cp314-cp314-win_amd64.whl", hash = "sha256:88dceee75c2c63af144e456745e10101eb67361050196b0b6af5d717254dddf7"}, + {file = "tomli-2.4.1-cp314-cp314-win_arm64.whl", hash = "sha256:b8c198f8c1805dc42708689ed6864951fd2494f924149d3e4bce7710f8eb5232"}, + {file = "tomli-2.4.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:d4d8fe59808a54658fcc0160ecfb1b30f9089906c50b23bcb4c69eddc19ec2b4"}, + {file = "tomli-2.4.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:7008df2e7655c495dd12d2a4ad038ff878d4ca4b81fccaf82b714e07eae4402c"}, + {file = "tomli-2.4.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1d8591993e228b0c930c4bb0db464bdad97b3289fb981255d6c9a41aedc84b2d"}, + {file = "tomli-2.4.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:734e20b57ba95624ecf1841e72b53f6e186355e216e5412de414e3c51e5e3c41"}, + {file = "tomli-2.4.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:8a650c2dbafa08d42e51ba0b62740dae4ecb9338eefa093aa5c78ceb546fcd5c"}, + {file = "tomli-2.4.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:504aa796fe0569bb43171066009ead363de03675276d2d121ac1a4572397870f"}, + {file = "tomli-2.4.1-cp314-cp314t-win32.whl", hash = "sha256:b1d22e6e9387bf4739fbe23bfa80e93f6b0373a7f1b96c6227c32bef95a4d7a8"}, + {file = "tomli-2.4.1-cp314-cp314t-win_amd64.whl", hash = "sha256:2c1c351919aca02858f740c6d33adea0c5deea37f9ecca1cc1ef9e884a619d26"}, + {file = "tomli-2.4.1-cp314-cp314t-win_arm64.whl", hash = "sha256:eab21f45c7f66c13f2a9e0e1535309cee140182a9cdae1e041d02e47291e8396"}, + {file = "tomli-2.4.1-py3-none-any.whl", hash = "sha256:0d85819802132122da43cb86656f8d1f8c6587d54ae7dcaf30e90533028b49fe"}, + {file = "tomli-2.4.1.tar.gz", hash = "sha256:7c7e1a961a0b2f2472c1ac5b69affa0ae1132c39adcb67aba98568702b9cc23f"}, ] [[package]] @@ -555,4 +596,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "6f6c191c1028d17a97fdfa84cedfd3cef94b5d63d98b8c1d333b3398eeea9055" +content-hash = "bcf31a142c86d9e556553c8c260a93b563ac64a043076dbd48b26111d422c26e" diff --git a/pyproject.toml b/pyproject.toml index 45c15a6..2aa97dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,10 @@ [project] name = "polytomic" +dynamic = ["version"] [tool.poetry] name = "polytomic" -version = "1.16.1" +version = "0.0.0" description = "" readme = "README.md" authors = [] @@ -18,6 +19,9 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: 3.15", "Operating System :: OS Independent", "Operating System :: POSIX", "Operating System :: MacOS", @@ -31,23 +35,24 @@ packages = [ { include = "polytomic", from = "src"} ] -[project.urls] +[tool.poetry.urls] Repository = 'https://github.com/polytomic/polytomic-python' [tool.poetry.dependencies] python = "^3.8" httpx = ">=0.21.2" pydantic = ">= 1.9.2" -pydantic-core = "^2.18.2" +pydantic-core = ">=2.18.2" typing_extensions = ">= 4.0.0" -[tool.poetry.dev-dependencies] -mypy = "1.0.1" +[tool.poetry.group.dev.dependencies] +mypy = "==1.13.0" pytest = "^7.4.0" pytest-asyncio = "^0.23.5" +pytest-xdist = "^3.6.1" python-dateutil = "^2.9.0" types-python-dateutil = "^2.9.0.20240316" -ruff = "^0.5.6" +ruff = "==0.11.5" [tool.pytest.ini_options] testpaths = [ "tests" ] @@ -59,6 +64,26 @@ plugins = ["pydantic.mypy"] [tool.ruff] line-length = 120 +[tool.ruff.lint] +select = [ + "E", # pycodestyle errors + "F", # pyflakes + "I", # isort +] +ignore = [ + "E402", # Module level import not at top of file + "E501", # Line too long + "E711", # Comparison to `None` should be `cond is not None` + "E712", # Avoid equality comparisons to `True`; use `if ...:` checks + "E721", # Use `is` and `is not` for type comparisons, or `isinstance()` for insinstance checks + "E722", # Do not use bare `except` + "E731", # Do not assign a `lambda` expression, use a `def` + "F821", # Undefined name + "F841" # Local variable ... is assigned to but never used +] + +[tool.ruff.lint.isort] +section-order = ["future", "standard-library", "third-party", "first-party"] [build-system] requires = ["poetry-core"] diff --git a/reference.md b/reference.md index 4a96a24..c8ab667 100644 --- a/reference.md +++ b/reference.md @@ -1,6 +1,6 @@ # Reference ## BulkSync -
client.bulk_sync.list(...) +
client.bulk_sync.list(...) -> BulkSyncListEnvelope
@@ -14,11 +14,14 @@ ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.list( active=True, ) @@ -57,7 +60,7 @@ client.bulk_sync.list(
-
client.bulk_sync.create(...) +
client.bulk_sync.create(...) -> BulkSyncResponseEnvelope
@@ -109,14 +112,19 @@ to see configurations for particular integrations (for example, [here](https://a
```python -from polytomic import BulkSchedule, Polytomic +from polytomic import Polytomic, BulkSchedule +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.create( - destination_configuration={"schema": "my_schema"}, + destination_configuration={ + "schema": "my_schema" + }, destination_connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", name="My Bulk Sync", schedule=BulkSchedule( @@ -139,7 +147,7 @@ client.bulk_sync.create(
-**destination_configuration:** `typing.Dict[str, typing.Optional[typing.Any]]` +**destination_configuration:** `typing.Dict[str, typing.Any]`
@@ -211,7 +219,7 @@ client.bulk_sync.create(
-**data_cutoff_timestamp:** `typing.Optional[dt.datetime]` +**data_cutoff_timestamp:** `typing.Optional[datetime.datetime]`
@@ -259,7 +267,7 @@ client.bulk_sync.create(
-**policies:** `typing.Optional[typing.Sequence[str]]` +**policies:** `typing.Optional[typing.List[str]]`
@@ -275,7 +283,7 @@ client.bulk_sync.create(
-**schemas:** `typing.Optional[typing.Sequence[V2CreateBulkSyncRequestSchemasItem]]` — List of schemas to sync; if omitted, all schemas will be selected for syncing. +**schemas:** `typing.Optional[typing.List[V2CreateBulkSyncRequestSchemasItem]]` — List of schemas to sync; if omitted, all schemas will be selected for syncing.
@@ -283,7 +291,7 @@ client.bulk_sync.create(
-**source_configuration:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` +**source_configuration:** `typing.Optional[typing.Dict[str, typing.Any]]`
@@ -303,7 +311,7 @@ client.bulk_sync.create(
-
client.bulk_sync.get(...) +
client.bulk_sync.get(...) -> BulkSyncResponseEnvelope
@@ -317,11 +325,14 @@ client.bulk_sync.create( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.get( id="248df4b7-aa70-47b8-a036-33ac447e668d", refresh_schemas=True, @@ -369,7 +380,7 @@ client.bulk_sync.get(
-
client.bulk_sync.update(...) +
client.bulk_sync.update(...) -> BulkSyncResponseEnvelope
@@ -398,15 +409,20 @@ client.bulk_sync.get(
```python -from polytomic import BulkSchedule, Polytomic +from polytomic import Polytomic, BulkSchedule +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.update( id="248df4b7-aa70-47b8-a036-33ac447e668d", - destination_configuration={"schema": "my_schema"}, + destination_configuration={ + "schema": "my_schema" + }, destination_connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", name="My Bulk Sync", schedule=BulkSchedule( @@ -437,7 +453,7 @@ client.bulk_sync.update(
-**destination_configuration:** `typing.Dict[str, typing.Optional[typing.Any]]` +**destination_configuration:** `typing.Dict[str, typing.Any]`
@@ -509,7 +525,7 @@ client.bulk_sync.update(
-**data_cutoff_timestamp:** `typing.Optional[dt.datetime]` +**data_cutoff_timestamp:** `typing.Optional[datetime.datetime]`
@@ -557,7 +573,7 @@ client.bulk_sync.update(
-**policies:** `typing.Optional[typing.Sequence[str]]` +**policies:** `typing.Optional[typing.List[str]]`
@@ -573,7 +589,7 @@ client.bulk_sync.update(
-**schemas:** `typing.Optional[typing.Sequence[V2UpdateBulkSyncRequestSchemasItem]]` — List of schemas to sync; if omitted, all schemas will be selected for syncing. +**schemas:** `typing.Optional[typing.List[V2UpdateBulkSyncRequestSchemasItem]]` — List of schemas to sync; if omitted, all schemas will be selected for syncing.
@@ -581,7 +597,7 @@ client.bulk_sync.update(
-**source_configuration:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` +**source_configuration:** `typing.Optional[typing.Dict[str, typing.Any]]`
@@ -615,11 +631,14 @@ client.bulk_sync.update( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.remove( id="248df4b7-aa70-47b8-a036-33ac447e668d", refresh_schemas=True, @@ -667,7 +686,7 @@ client.bulk_sync.remove(
-
client.bulk_sync.activate(...) +
client.bulk_sync.activate(...) -> ActivateSyncEnvelope
@@ -681,11 +700,14 @@ client.bulk_sync.remove( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.activate( id="248df4b7-aa70-47b8-a036-33ac447e668d", active=True, @@ -713,7 +735,7 @@ client.bulk_sync.activate(
-**active:** `bool` +**request:** `ActivateSyncInput`
@@ -733,7 +755,7 @@ client.bulk_sync.activate(
-
client.bulk_sync.cancel(...) +
client.bulk_sync.cancel(...) -> CancelBulkSyncResponseEnvelope
@@ -747,11 +769,14 @@ client.bulk_sync.activate( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.cancel( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -790,7 +815,7 @@ client.bulk_sync.cancel(
-
client.bulk_sync.start(...) +
client.bulk_sync.start(...) -> BulkSyncExecutionEnvelope
@@ -804,11 +829,14 @@ client.bulk_sync.cancel( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.start( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -851,7 +879,7 @@ client.bulk_sync.start(
-**schemas:** `typing.Optional[typing.Sequence[str]]` +**schemas:** `typing.Optional[typing.List[str]]`
@@ -879,7 +907,7 @@ client.bulk_sync.start(
-
client.bulk_sync.get_status(...) +
client.bulk_sync.get_status(...) -> BulkSyncStatusEnvelope
@@ -893,11 +921,14 @@ client.bulk_sync.start( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.get_status( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -936,7 +967,7 @@ client.bulk_sync.get_status(
-
client.bulk_sync.get_source(...) +
client.bulk_sync.get_source(...) -> BulkSyncSourceEnvelope
@@ -950,11 +981,14 @@ client.bulk_sync.get_status( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.get_source( id="248df4b7-aa70-47b8-a036-33ac447e668d", include_fields=True, @@ -1002,7 +1036,7 @@ client.bulk_sync.get_source(
-
client.bulk_sync.get_destination(...) +
client.bulk_sync.get_destination(...) -> BulkSyncDestEnvelope
@@ -1016,11 +1050,14 @@ client.bulk_sync.get_source( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.get_destination( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -1060,7 +1097,7 @@ client.bulk_sync.get_destination(
## Connections -
client.connections.get_types() +
client.connections.get_types() -> ConnectionTypeResponseEnvelope
@@ -1074,11 +1111,14 @@ client.bulk_sync.get_destination( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.connections.get_types() ``` @@ -1107,7 +1147,7 @@ client.connections.get_types()
-
client.connections.get_connection_type_schema(...) +
client.connections.get_connection_type_schema(...) -> JsonschemaSchema
@@ -1121,11 +1161,14 @@ client.connections.get_types() ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.connections.get_connection_type_schema( id="postgresql", ) @@ -1164,7 +1207,7 @@ client.connections.get_connection_type_schema(
-
client.connections.get_type_parameter_values(...) +
client.connections.get_type_parameter_values(...) -> ConnectionParameterValuesResponseEnvelope
@@ -1178,11 +1221,14 @@ client.connections.get_connection_type_schema( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.connections.get_type_parameter_values( type="type", field="field", @@ -1226,7 +1272,7 @@ client.connections.get_type_parameter_values(
-**parameters:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` +**parameters:** `typing.Optional[typing.Dict[str, typing.Any]]`
@@ -1254,7 +1300,7 @@ client.connections.get_type_parameter_values(
-
client.connections.list() +
client.connections.list() -> ConnectionListResponseEnvelope
@@ -1268,11 +1314,14 @@ client.connections.get_type_parameter_values( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.connections.list() ``` @@ -1301,7 +1350,7 @@ client.connections.list()
-
client.connections.create(...) +
client.connections.create(...) -> CreateConnectionResponseEnvelope
@@ -1315,18 +1364,21 @@ client.connections.list() ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.connections.create( configuration={ "database": "example", "hostname": "postgres.example.com", "password": "********", "port": 5432, - "username": "user", + "username": "user" }, name="My Postgres Connection", type="postgresql", @@ -1346,7 +1398,7 @@ client.connections.create(
-**configuration:** `typing.Dict[str, typing.Optional[typing.Any]]` +**configuration:** `typing.Dict[str, typing.Any]`
@@ -1386,7 +1438,7 @@ client.connections.create(
-**policies:** `typing.Optional[typing.Sequence[str]]` +**policies:** `typing.Optional[typing.List[str]]`
@@ -1422,7 +1474,7 @@ client.connections.create(
-
client.connections.connect(...) +
client.connections.connect(...) -> ConnectCardResponseEnvelope
@@ -1458,11 +1510,14 @@ See also: ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.connections.connect( name="Salesforce Connection", redirect_url="redirect_url", @@ -1530,7 +1585,7 @@ client.connections.connect(
-**whitelist:** `typing.Optional[typing.Sequence[str]]` — List of connection types which are allowed to be created. Ignored if type is set. +**whitelist:** `typing.Optional[typing.List[str]]` — List of connection types which are allowed to be created. Ignored if type is set.
@@ -1578,18 +1633,21 @@ Tests a connection configuration. ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.connections.test_connection( configuration={ "database": "example", "hostname": "postgres.example.com", "password": "password", "port": 5432, - "username": "user", + "username": "user" }, type="postgresql", ) @@ -1608,7 +1666,7 @@ client.connections.test_connection(
-**configuration:** `typing.Dict[str, typing.Optional[typing.Any]]` — Connection configuration to test. +**configuration:** `typing.Dict[str, typing.Any]` — Connection configuration to test.
@@ -1644,7 +1702,7 @@ client.connections.test_connection(
-
client.connections.get(...) +
client.connections.get(...) -> ConnectionResponseEnvelope
@@ -1658,11 +1716,14 @@ client.connections.test_connection( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.connections.get( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -1701,7 +1762,7 @@ client.connections.get(
-
client.connections.update(...) +
client.connections.update(...) -> CreateConnectionResponseEnvelope
@@ -1715,11 +1776,14 @@ client.connections.get( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.connections.update( id="248df4b7-aa70-47b8-a036-33ac447e668d", configuration={ @@ -1727,7 +1791,7 @@ client.connections.update( "hostname": "postgres.example.com", "password": "********", "port": 5432, - "username": "user", + "username": "user" }, name="My Postgres Connection", ) @@ -1754,7 +1818,7 @@ client.connections.update(
-**configuration:** `typing.Dict[str, typing.Optional[typing.Any]]` +**configuration:** `typing.Dict[str, typing.Any]`
@@ -1786,7 +1850,7 @@ client.connections.update(
-**policies:** `typing.Optional[typing.Sequence[str]]` +**policies:** `typing.Optional[typing.List[str]]`
@@ -1844,11 +1908,14 @@ client.connections.update( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.connections.remove( id="248df4b7-aa70-47b8-a036-33ac447e668d", force=True, @@ -1896,7 +1963,7 @@ client.connections.remove(
-
client.connections.get_parameter_values(...) +
client.connections.get_parameter_values(...) -> ConnectionParameterValuesResponseEnvelope
@@ -1910,11 +1977,14 @@ client.connections.remove( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.connections.get_parameter_values( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -1953,10 +2023,26 @@ client.connections.get_parameter_values(
-
client.connections.api_v_2_create_shared_connection(...) +
client.connections.create_shared_connection(...) -> V2CreateSharedConnectionResponseEnvelope +
+
+ +#### 📝 Description +
+
+
+ +> 🚧 Requires partner key +> +> Shared connections can only be created by using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). +
+
+
+
+ #### 🔌 Usage
@@ -1967,14 +2053,17 @@ client.connections.get_parameter_values( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) -client.connections.api_v_2_create_shared_connection( - id="248df4b7-aa70-47b8-a036-33ac447e668d", - organization_id="248df4b7-aa70-47b8-a036-33ac447e668d", + +client.connections.create_shared_connection( + parent_connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", + child_organization_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) ``` @@ -1991,7 +2080,7 @@ client.connections.api_v_2_create_shared_connection(
-**id:** `str` +**parent_connection_id:** `str`
@@ -1999,7 +2088,7 @@ client.connections.api_v_2_create_shared_connection(
-**organization_id:** `str` +**child_organization_id:** `str`
@@ -2023,15 +2112,89 @@ client.connections.api_v_2_create_shared_connection(
+
+
+
+ +
client.connections.list_shared_connections(...) -> ConnectionListResponseEnvelope +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment + +client = Polytomic( + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, +) + +client.connections.list_shared_connections( + parent_connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**parent_connection_id:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
## QueryRunner -
client.query_runner.run_query(...) +
client.query_runner.run_query(...) -> V4RunQueryEnvelope +
+
+ +#### 📝 Description + +
+
+
+Submit a query for asynchronous execution against the connection. The initial response may only contain the query task id and status. Poll GET /api/queries/{id} with the returned id to retrieve completion status, fields, and results. +
+
+
+
+ #### 🔌 Usage
@@ -2042,11 +2205,14 @@ client.connections.api_v_2_create_shared_connection( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.query_runner.run_query( connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", query="SELECT * FROM table", @@ -2094,10 +2260,24 @@ client.query_runner.run_query(
-
client.query_runner.get_query(...) +
client.query_runner.get_query(...) -> V4QueryResultsEnvelope +
+
+ +#### 📝 Description + +
+
+
+Fetch the latest status for a submitted query and, once complete, return fields and paginated results. Use the query id returned by POST /api/connections/{connection_id}/query. +
+
+
+
+ #### 🔌 Usage
@@ -2108,11 +2288,14 @@ client.query_runner.run_query( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.query_runner.get_query( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -2174,11 +2357,14 @@ client.query_runner.get_query( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.schemas.upsert_field( connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", schema_id="public.users", @@ -2214,7 +2400,7 @@ client.schemas.upsert_field(
-**fields:** `typing.Optional[typing.Sequence[V4UserFieldRequest]]` +**fields:** `typing.Optional[typing.List[V4UserFieldRequest]]`
@@ -2248,11 +2434,14 @@ client.schemas.upsert_field( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.schemas.delete_field( connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", schema_id="public.users", @@ -2323,11 +2512,14 @@ client.schemas.delete_field( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.schemas.set_primary_keys( connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", schema_id="public.users", @@ -2363,7 +2555,7 @@ client.schemas.set_primary_keys(
-**fields:** `typing.Optional[typing.Sequence[SchemaPrimaryKeyOverrideInput]]` +**fields:** `typing.Optional[typing.List[SchemaPrimaryKeyOverrideInput]]`
@@ -2411,11 +2603,14 @@ Delete all primary key overrides for a schema. After this call the schema will u ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.schemas.reset_primary_keys( connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", schema_id="public.users", @@ -2477,11 +2672,14 @@ client.schemas.reset_primary_keys( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.schemas.refresh( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -2520,7 +2718,7 @@ client.schemas.refresh(
-
client.schemas.get_status(...) +
client.schemas.get_status(...) -> BulkSyncSourceStatusEnvelope
@@ -2548,11 +2746,14 @@ Polytomic periodically inspects the schemas for connections to discover new fiel ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.schemas.get_status( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -2591,7 +2792,7 @@ client.schemas.get_status(
-
client.schemas.get(...) +
client.schemas.get(...) -> BulkSyncSourceSchemaEnvelope
@@ -2605,11 +2806,14 @@ client.schemas.get_status( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.schemas.get( id="248df4b7-aa70-47b8-a036-33ac447e668d", schema_id="public.users", @@ -2657,7 +2861,7 @@ client.schemas.get(
-
client.schemas.get_records(...) +
client.schemas.get_records(...) -> SchemaRecordsResponseEnvelope
@@ -2671,11 +2875,14 @@ client.schemas.get( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.schemas.get_records( id="248df4b7-aa70-47b8-a036-33ac447e668d", schema_id="public.users", @@ -2724,7 +2931,7 @@ client.schemas.get_records(
## Models -
client.models.get_enrichment_source(...) +
client.models.get_enrichment_source(...) -> GetModelSyncSourceMetaEnvelope
@@ -2738,11 +2945,14 @@ client.schemas.get_records( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.models.get_enrichment_source( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -2769,7 +2979,7 @@ client.models.get_enrichment_source(
-**params:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]]` +**params:** `typing.Optional[typing.Dict[str, typing.List[str]]]`
@@ -2789,7 +2999,7 @@ client.models.get_enrichment_source(
-
client.models.post(...) +
client.models.post(...) -> V2GetEnrichmentInputFieldsResponseEnvelope
@@ -2817,11 +3027,14 @@ For a given connection and enrichment configuration, provides the valid sets of ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.models.post( connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -2868,7 +3081,7 @@ client.models.post(
-
client.models.preview(...) +
client.models.preview(...) -> ModelResponseEnvelope
@@ -2882,13 +3095,18 @@ client.models.post( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.models.preview( - configuration={"table": "public.users"}, + configuration={ + "table": "public.users" + }, connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", name="Users", ) @@ -2907,95 +3125,7 @@ client.models.preview(
-**configuration:** `typing.Dict[str, typing.Optional[typing.Any]]` - -
-
- -
-
- -**connection_id:** `str` - -
-
- -
-
- -**name:** `str` - -
-
- -
-
- -**async_:** `typing.Optional[bool]` - -
-
- -
-
- -**additional_fields:** `typing.Optional[typing.Sequence[ModelModelFieldRequest]]` - -
-
- -
-
- -**enricher:** `typing.Optional[Enrichment]` - -
-
- -
-
- -**fields:** `typing.Optional[typing.Sequence[str]]` - -
-
- -
-
- -**identifier:** `typing.Optional[str]` - -
-
- -
-
- -**labels:** `typing.Optional[typing.Sequence[str]]` - -
-
- -
-
- -**organization_id:** `typing.Optional[str]` - -
-
- -
-
- -**policies:** `typing.Optional[typing.Sequence[str]]` - -
-
- -
-
- -**relations:** `typing.Optional[typing.Sequence[ModelRelation]]` +**request:** `CreateModelRequest`
@@ -3003,7 +3133,7 @@ client.models.preview(
-**tracking_columns:** `typing.Optional[typing.Sequence[str]]` +**async:** `typing.Optional[bool]`
@@ -3023,7 +3153,7 @@ client.models.preview(
-
client.models.list() +
client.models.list() -> ModelListResponseEnvelope
@@ -3037,11 +3167,14 @@ client.models.preview( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.models.list() ``` @@ -3070,7 +3203,7 @@ client.models.list()
-
client.models.create(...) +
client.models.create(...) -> ModelResponseEnvelope
@@ -3084,13 +3217,18 @@ client.models.list() ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.models.create( - configuration={"table": "public.users"}, + configuration={ + "table": "public.users" + }, connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", name="Users", ) @@ -3109,39 +3247,7 @@ client.models.create(
-**configuration:** `typing.Dict[str, typing.Optional[typing.Any]]` - -
-
- -
-
- -**connection_id:** `str` - -
-
- -
-
- -**name:** `str` - -
-
- -
-
- -**async_:** `typing.Optional[bool]` - -
-
- -
-
- -**additional_fields:** `typing.Optional[typing.Sequence[ModelModelFieldRequest]]` +**request:** `CreateModelRequest`
@@ -3149,63 +3255,7 @@ client.models.create(
-**enricher:** `typing.Optional[Enrichment]` - -
-
- -
-
- -**fields:** `typing.Optional[typing.Sequence[str]]` - -
-
- -
-
- -**identifier:** `typing.Optional[str]` - -
-
- -
-
- -**labels:** `typing.Optional[typing.Sequence[str]]` - -
-
- -
-
- -**organization_id:** `typing.Optional[str]` - -
-
- -
-
- -**policies:** `typing.Optional[typing.Sequence[str]]` - -
-
- -
-
- -**relations:** `typing.Optional[typing.Sequence[ModelRelation]]` - -
-
- -
-
- -**tracking_columns:** `typing.Optional[typing.Sequence[str]]` +**async:** `typing.Optional[bool]`
@@ -3225,7 +3275,7 @@ client.models.create(
-
client.models.get(...) +
client.models.get(...) -> ModelResponseEnvelope
@@ -3239,11 +3289,14 @@ client.models.create( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.models.get( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -3270,7 +3323,7 @@ client.models.get(
-**async_:** `typing.Optional[bool]` +**async:** `typing.Optional[bool]`
@@ -3290,7 +3343,7 @@ client.models.get(
-
client.models.update(...) +
client.models.update(...) -> ModelResponseEnvelope
@@ -3304,15 +3357,20 @@ client.models.get( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.models.update( id="248df4b7-aa70-47b8-a036-33ac447e668d", async_=False, - configuration={"table": "public.users"}, + configuration={ + "table": "public.users" + }, connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", name="Users", ) @@ -3339,7 +3397,7 @@ client.models.update(
-**configuration:** `typing.Dict[str, typing.Optional[typing.Any]]` +**configuration:** `typing.Dict[str, typing.Any]`
@@ -3363,7 +3421,7 @@ client.models.update(
-**async_:** `typing.Optional[bool]` +**async:** `typing.Optional[bool]`
@@ -3371,7 +3429,7 @@ client.models.update(
-**additional_fields:** `typing.Optional[typing.Sequence[ModelModelFieldRequest]]` +**additional_fields:** `typing.Optional[typing.List[ModelModelFieldRequest]]`
@@ -3387,7 +3445,7 @@ client.models.update(
-**fields:** `typing.Optional[typing.Sequence[str]]` +**fields:** `typing.Optional[typing.List[str]]`
@@ -3403,7 +3461,7 @@ client.models.update(
-**labels:** `typing.Optional[typing.Sequence[str]]` +**labels:** `typing.Optional[typing.List[str]]`
@@ -3419,7 +3477,7 @@ client.models.update(
-**policies:** `typing.Optional[typing.Sequence[str]]` +**policies:** `typing.Optional[typing.List[str]]`
@@ -3435,7 +3493,7 @@ client.models.update(
-**relations:** `typing.Optional[typing.Sequence[ModelRelation]]` +**relations:** `typing.Optional[typing.List[ModelRelation]]`
@@ -3443,7 +3501,7 @@ client.models.update(
-**tracking_columns:** `typing.Optional[typing.Sequence[str]]` +**tracking_columns:** `typing.Optional[typing.List[str]]`
@@ -3477,11 +3535,14 @@ client.models.update( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.models.remove( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -3508,7 +3569,7 @@ client.models.remove(
-**async_:** `typing.Optional[bool]` +**async:** `typing.Optional[bool]`
@@ -3528,7 +3589,7 @@ client.models.remove(
-
client.models.sample(...) +
client.models.sample(...) -> ModelSampleResponseEnvelope
@@ -3556,11 +3617,14 @@ Returns sample records from the model. The first ten records that the source pro ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.models.sample( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -3587,7 +3651,7 @@ client.models.sample(
-**async_:** `typing.Optional[bool]` +**async:** `typing.Optional[bool]`
@@ -3608,7 +3672,7 @@ client.models.sample(
## ModelSync -
client.model_sync.get_source(...) +
client.model_sync.get_source(...) -> GetModelSyncSourceMetaEnvelope
@@ -3622,11 +3686,14 @@ client.models.sample( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.get_source( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -3653,7 +3720,7 @@ client.model_sync.get_source(
-**params:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]]` +**params:** `typing.Optional[typing.Dict[str, typing.List[str]]]`
@@ -3673,7 +3740,7 @@ client.model_sync.get_source(
-
client.model_sync.get_source_fields(...) +
client.model_sync.get_source_fields(...) -> ModelFieldResponse
@@ -3687,11 +3754,14 @@ client.model_sync.get_source( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.get_source_fields( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -3718,7 +3788,7 @@ client.model_sync.get_source_fields(
-**params:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]]` +**params:** `typing.Optional[typing.Dict[str, typing.List[str]]]`
@@ -3738,7 +3808,7 @@ client.model_sync.get_source_fields(
-
client.model_sync.list(...) +
client.model_sync.list(...) -> ListModelSyncResponseEnvelope
@@ -3752,11 +3822,14 @@ client.model_sync.get_source_fields( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.list( active=True, target_connection_id="0b155265-c537-44c9-9359-a3ceb468a4da", @@ -3812,7 +3885,7 @@ client.model_sync.list(
-
client.model_sync.create(...) +
client.model_sync.create(...) -> ModelSyncResponseEnvelope
@@ -3894,12 +3967,15 @@ a connection supports target creation.
```python -from polytomic import ModelSyncField, Polytomic, Schedule, Target +from polytomic import Polytomic, ModelSyncField, Schedule, Target +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.create( fields=[ ModelSyncField( @@ -3928,7 +4004,7 @@ client.model_sync.create(
-**fields:** `typing.Sequence[ModelSyncField]` — Fields to sync from source to destination. +**fields:** `typing.List[ModelSyncField]` — Fields to sync from source to destination.
@@ -3992,7 +4068,7 @@ client.model_sync.create(
-**filters:** `typing.Optional[typing.Sequence[Filter]]` — Filters to apply to the source data. +**filters:** `typing.Optional[typing.List[Filter]]` — Filters to apply to the source data.
@@ -4024,7 +4100,7 @@ client.model_sync.create(
-**override_fields:** `typing.Optional[typing.Sequence[ModelSyncField]]` — Values to set in the target unconditionally. +**override_fields:** `typing.Optional[typing.List[ModelSyncField]]` — Values to set in the target unconditionally.
@@ -4032,7 +4108,7 @@ client.model_sync.create(
-**overrides:** `typing.Optional[typing.Sequence[Override]]` — Conditional value replacement for fields. +**overrides:** `typing.Optional[typing.List[Override]]` — Conditional value replacement for fields.
@@ -4040,7 +4116,7 @@ client.model_sync.create(
-**policies:** `typing.Optional[typing.Sequence[str]]` +**policies:** `typing.Optional[typing.List[str]]`
@@ -4076,7 +4152,7 @@ client.model_sync.create(
-
client.model_sync.get_schedule_options() +
client.model_sync.get_schedule_options() -> ScheduleOptionResponseEnvelope
@@ -4090,11 +4166,14 @@ client.model_sync.create( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.get_schedule_options() ``` @@ -4123,7 +4202,7 @@ client.model_sync.get_schedule_options()
-
client.model_sync.get(...) +
client.model_sync.get(...) -> ModelSyncResponseEnvelope
@@ -4137,11 +4216,14 @@ client.model_sync.get_schedule_options() ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.get( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -4180,7 +4262,7 @@ client.model_sync.get(
-
client.model_sync.update(...) +
client.model_sync.update(...) -> ModelSyncResponseEnvelope
@@ -4193,12 +4275,15 @@ client.model_sync.get(
```python -from polytomic import ModelSyncField, Polytomic, Schedule, Target +from polytomic import Polytomic, ModelSyncField, Schedule, Target +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.update( id="248df4b7-aa70-47b8-a036-33ac447e668d", fields=[ @@ -4236,7 +4321,7 @@ client.model_sync.update(
-**fields:** `typing.Sequence[ModelSyncField]` — Fields to sync from source to destination. +**fields:** `typing.List[ModelSyncField]` — Fields to sync from source to destination.
@@ -4300,7 +4385,7 @@ client.model_sync.update(
-**filters:** `typing.Optional[typing.Sequence[Filter]]` — Filters to apply to the source data. +**filters:** `typing.Optional[typing.List[Filter]]` — Filters to apply to the source data.
@@ -4332,7 +4417,7 @@ client.model_sync.update(
-**override_fields:** `typing.Optional[typing.Sequence[ModelSyncField]]` — Values to set in the target unconditionally. +**override_fields:** `typing.Optional[typing.List[ModelSyncField]]` — Values to set in the target unconditionally.
@@ -4340,7 +4425,7 @@ client.model_sync.update(
-**overrides:** `typing.Optional[typing.Sequence[Override]]` — Conditional value replacement for fields. +**overrides:** `typing.Optional[typing.List[Override]]` — Conditional value replacement for fields.
@@ -4348,7 +4433,7 @@ client.model_sync.update(
-**policies:** `typing.Optional[typing.Sequence[str]]` +**policies:** `typing.Optional[typing.List[str]]`
@@ -4398,11 +4483,14 @@ client.model_sync.update( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.remove( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -4441,7 +4529,7 @@ client.model_sync.remove(
-
client.model_sync.activate(...) +
client.model_sync.activate(...) -> ActivateSyncEnvelope
@@ -4455,11 +4543,14 @@ client.model_sync.remove( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.activate( id="248df4b7-aa70-47b8-a036-33ac447e668d", active=True, @@ -4487,7 +4578,7 @@ client.model_sync.activate(
-**active:** `bool` +**request:** `ActivateSyncInput`
@@ -4507,7 +4598,7 @@ client.model_sync.activate(
-
client.model_sync.cancel(...) +
client.model_sync.cancel(...) -> CancelModelSyncResponseEnvelope
@@ -4521,11 +4612,14 @@ client.model_sync.activate( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.cancel( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -4564,7 +4658,7 @@ client.model_sync.cancel(
-
client.model_sync.start(...) +
client.model_sync.start(...) -> StartModelSyncResponseEnvelope
@@ -4594,11 +4688,14 @@ client.model_sync.cancel( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.start( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -4625,7 +4722,7 @@ client.model_sync.start(
-**identities:** `typing.Optional[typing.Sequence[str]]` +**identities:** `typing.Optional[typing.List[str]]`
@@ -4661,7 +4758,7 @@ client.model_sync.start(
-
client.model_sync.get_status(...) +
client.model_sync.get_status(...) -> SyncStatusEnvelope
@@ -4675,11 +4772,14 @@ client.model_sync.start( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.get_status( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -4719,7 +4819,7 @@ client.model_sync.get_status(
## Events -
client.events.list(...) +
client.events.list(...) -> EventsEnvelope
@@ -4732,22 +4832,20 @@ client.model_sync.get_status(
```python -import datetime - from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment +import datetime client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.events.list( organization_id="248df4b7-aa70-47b8-a036-33ac447e668d", - starting_after=datetime.datetime.fromisoformat( - "2020-01-01 00:00:00+00:00", - ), - ending_before=datetime.datetime.fromisoformat( - "2020-01-01 00:00:00+00:00", - ), + starting_after=datetime.datetime.fromisoformat("2020-01-01T00:00:00+00:00"), + ending_before=datetime.datetime.fromisoformat("2020-01-01T00:00:00+00:00"), ) ``` @@ -4780,7 +4878,7 @@ client.events.list(
-**starting_after:** `typing.Optional[dt.datetime]` +**starting_after:** `typing.Optional[datetime.datetime]`
@@ -4788,7 +4886,7 @@ client.events.list(
-**ending_before:** `typing.Optional[dt.datetime]` +**ending_before:** `typing.Optional[datetime.datetime]`
@@ -4816,7 +4914,7 @@ client.events.list(
-
client.events.get_types() +
client.events.get_types() -> EventTypesEnvelope
@@ -4830,11 +4928,14 @@ client.events.list( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.events.get_types() ``` @@ -4864,7 +4965,7 @@ client.events.get_types()
## Jobs -
client.jobs.get(...) +
client.jobs.get(...) -> JobResponseEnvelope
@@ -4878,14 +4979,17 @@ client.events.get_types() ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.jobs.get( - id="248df4b7-aa70-47b8-a036-33ac447e668d", type="createmodel", + id="248df4b7-aa70-47b8-a036-33ac447e668d", ) ``` @@ -4902,7 +5006,7 @@ client.jobs.get(
-**id:** `str` +**type:** `str`
@@ -4910,7 +5014,7 @@ client.jobs.get(
-**type:** `str` +**id:** `str`
@@ -4931,7 +5035,7 @@ client.jobs.get(
## Identity -
client.identity.get() +
client.identity.get() -> GetIdentityResponseEnvelope
@@ -4959,11 +5063,14 @@ Returns information about the caller's identity. ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.identity.get() ``` @@ -4993,7 +5100,7 @@ client.identity.get()
## Notifications -
client.notifications.get_global_error_subscribers() +
client.notifications.get_global_error_subscribers() -> V4GlobalErrorSubscribersResponse
@@ -5007,11 +5114,14 @@ client.identity.get() ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.notifications.get_global_error_subscribers() ``` @@ -5040,7 +5150,7 @@ client.notifications.get_global_error_subscribers()
-
client.notifications.set_global_error_subscribers(...) +
client.notifications.set_global_error_subscribers(...) -> V4GlobalErrorSubscribersResponse
@@ -5054,11 +5164,14 @@ client.notifications.get_global_error_subscribers() ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.notifications.set_global_error_subscribers() ``` @@ -5075,7 +5188,7 @@ client.notifications.set_global_error_subscribers()
-**emails:** `typing.Optional[typing.Sequence[str]]` +**emails:** `typing.Optional[typing.List[str]]`
@@ -5096,7 +5209,7 @@ client.notifications.set_global_error_subscribers()
## Organization -
client.organization.list() +
client.organization.list() -> OrganizationsEnvelope
@@ -5126,11 +5239,14 @@ client.notifications.set_global_error_subscribers() ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.organization.list() ``` @@ -5159,7 +5275,7 @@ client.organization.list()
-
client.organization.create(...) +
client.organization.create(...) -> OrganizationEnvelope
@@ -5189,11 +5305,14 @@ client.organization.list() ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.organization.create( name="My Organization", ) @@ -5272,7 +5391,7 @@ client.organization.create(
-
client.organization.get(...) +
client.organization.get(...) -> OrganizationEnvelope
@@ -5302,11 +5421,14 @@ client.organization.create( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.organization.get( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -5345,7 +5467,7 @@ client.organization.get(
-
client.organization.update(...) +
client.organization.update(...) -> OrganizationEnvelope
@@ -5375,11 +5497,14 @@ client.organization.get( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.organization.update( id="248df4b7-aa70-47b8-a036-33ac447e668d", name="My Organization", @@ -5497,11 +5622,14 @@ client.organization.update( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.organization.remove( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -5541,7 +5669,7 @@ client.organization.remove(
## Users -
client.users.list(...) +
client.users.list(...) -> ListUsersEnvelope
@@ -5555,11 +5683,14 @@ client.organization.remove( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.users.list( org_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -5598,7 +5729,7 @@ client.users.list(
-
client.users.create(...) +
client.users.create(...) -> UserEnvelope
@@ -5612,11 +5743,14 @@ client.users.list( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.users.create( org_id="248df4b7-aa70-47b8-a036-33ac447e668d", email="mail@example.com", @@ -5660,7 +5794,7 @@ client.users.create(
-**role_ids:** `typing.Optional[typing.Sequence[str]]` +**role_ids:** `typing.Optional[typing.List[str]]`
@@ -5680,7 +5814,7 @@ client.users.create(
-
client.users.get(...) +
client.users.get(...) -> UserEnvelope
@@ -5694,14 +5828,17 @@ client.users.create( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.users.get( - id="248df4b7-aa70-47b8-a036-33ac447e668d", org_id="248df4b7-aa70-47b8-a036-33ac447e668d", + id="248df4b7-aa70-47b8-a036-33ac447e668d", ) ``` @@ -5718,7 +5855,7 @@ client.users.get(
-**id:** `str` +**org_id:** `str`
@@ -5726,7 +5863,7 @@ client.users.get(
-**org_id:** `str` +**id:** `str`
@@ -5746,7 +5883,7 @@ client.users.get(
-
client.users.update(...) +
client.users.update(...) -> UserEnvelope
@@ -5760,14 +5897,17 @@ client.users.get( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.users.update( - id="248df4b7-aa70-47b8-a036-33ac447e668d", org_id="248df4b7-aa70-47b8-a036-33ac447e668d", + id="248df4b7-aa70-47b8-a036-33ac447e668d", email="mail@example.com", ) @@ -5785,7 +5925,7 @@ client.users.update(
-**id:** `str` +**org_id:** `str`
@@ -5793,7 +5933,7 @@ client.users.update(
-**org_id:** `str` +**id:** `str`
@@ -5817,7 +5957,7 @@ client.users.update(
-**role_ids:** `typing.Optional[typing.Sequence[str]]` +**role_ids:** `typing.Optional[typing.List[str]]`
@@ -5837,7 +5977,7 @@ client.users.update(
-
client.users.remove(...) +
client.users.remove(...) -> UserEnvelope
@@ -5851,14 +5991,17 @@ client.users.update( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.users.remove( - id="248df4b7-aa70-47b8-a036-33ac447e668d", org_id="248df4b7-aa70-47b8-a036-33ac447e668d", + id="248df4b7-aa70-47b8-a036-33ac447e668d", ) ``` @@ -5875,7 +6018,7 @@ client.users.remove(
-**id:** `str` +**org_id:** `str`
@@ -5883,7 +6026,7 @@ client.users.remove(
-**org_id:** `str` +**id:** `str`
@@ -5903,7 +6046,7 @@ client.users.remove(
-
client.users.create_api_key(...) +
client.users.create_api_key(...) -> ApiKeyResponseEnvelope
@@ -5933,11 +6076,14 @@ client.users.remove( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.users.create_api_key( org_id="248df4b7-aa70-47b8-a036-33ac447e668d", id="248df4b7-aa70-47b8-a036-33ac447e668d", @@ -5995,7 +6141,7 @@ client.users.create_api_key(
## Webhooks -
client.webhooks.list() +
client.webhooks.list() -> WebhookListEnvelope
@@ -6027,11 +6173,14 @@ Consult the [Events documentation](https://apidocs.polytomic.com/guides/events) ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.webhooks.list() ``` @@ -6060,7 +6209,7 @@ client.webhooks.list()
-
client.webhooks.create(...) +
client.webhooks.create(...) -> WebhookEnvelope
@@ -6092,11 +6241,14 @@ Consult the [Events documentation](https://apidocs.polytomic.com/guides/events) ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.webhooks.create( endpoint="https://example.com/webhook", secret="secret", @@ -6152,7 +6304,7 @@ client.webhooks.create(
-
client.webhooks.get(...) +
client.webhooks.get(...) -> WebhookEnvelope
@@ -6184,11 +6336,14 @@ Consult the [Events documentation](https://apidocs.polytomic.com/guides/events) ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.webhooks.get( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -6227,7 +6382,7 @@ client.webhooks.get(
-
client.webhooks.update(...) +
client.webhooks.update(...) -> WebhookEnvelope
@@ -6259,11 +6414,14 @@ Consult the [Events documentation](https://apidocs.polytomic.com/guides/events) ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.webhooks.update( id="248df4b7-aa70-47b8-a036-33ac447e668d", endpoint="https://example.com/webhook", @@ -6342,11 +6500,14 @@ client.webhooks.update( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.webhooks.remove( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -6385,7 +6546,7 @@ client.webhooks.remove(
-
client.webhooks.disable(...) +
client.webhooks.disable(...) -> WebhookEnvelope
@@ -6399,11 +6560,14 @@ client.webhooks.remove( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.webhooks.disable( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -6442,7 +6606,7 @@ client.webhooks.disable(
-
client.webhooks.enable(...) +
client.webhooks.enable(...) -> WebhookEnvelope
@@ -6456,11 +6620,14 @@ client.webhooks.disable( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.webhooks.enable( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -6500,7 +6667,7 @@ client.webhooks.enable(
## BulkSync Executions -
client.bulk_sync.executions.list_status(...) +
client.bulk_sync.executions.list_status(...) -> ListBulkSyncExecutionStatusEnvelope
@@ -6514,11 +6681,14 @@ client.webhooks.enable( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.executions.list_status( all_=True, active=True, @@ -6538,7 +6708,7 @@ client.bulk_sync.executions.list_status(
-**all_:** `typing.Optional[bool]` — Return the execution status of all syncs in the organization +**all:** `typing.Optional[bool]` — Return the execution status of all syncs in the organization
@@ -6574,7 +6744,7 @@ client.bulk_sync.executions.list_status(
-
client.bulk_sync.executions.list(...) +
client.bulk_sync.executions.list(...) -> ListBulkSyncExecutionsEnvelope
@@ -6588,11 +6758,14 @@ client.bulk_sync.executions.list_status( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.executions.list( id="248df4b7-aa70-47b8-a036-33ac447e668d", page_token="AmkYh8v0jR5B3kls2Qcc9y8MjrPmvR4CvaK7H0F4rEwqvg76K==", @@ -6667,7 +6840,7 @@ client.bulk_sync.executions.list(
-
client.bulk_sync.executions.get(...) +
client.bulk_sync.executions.get(...) -> BulkSyncExecutionEnvelope
@@ -6681,11 +6854,14 @@ client.bulk_sync.executions.list( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.executions.get( id="248df4b7-aa70-47b8-a036-33ac447e668d", exec_id="248df4b7-aa70-47b8-a036-33ac447e668d", @@ -6733,7 +6909,7 @@ client.bulk_sync.executions.get(
-
client.bulk_sync.executions.cancel(...) +
client.bulk_sync.executions.cancel(...) -> CancelBulkSyncResponseEnvelope
@@ -6747,11 +6923,14 @@ client.bulk_sync.executions.get( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.executions.cancel( id="248df4b7-aa70-47b8-a036-33ac447e668d", exec_id="248df4b7-aa70-47b8-a036-33ac447e668d", @@ -6799,7 +6978,7 @@ client.bulk_sync.executions.cancel(
-
client.bulk_sync.executions.get_logs(...) +
client.bulk_sync.executions.get_logs(...) -> V4BulkSyncExecutionLogsEnvelope
@@ -6813,11 +6992,14 @@ client.bulk_sync.executions.cancel( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.executions.get_logs( sync_id="248df4b7-aa70-47b8-a036-33ac447e668d", execution_id="248df4b7-aa70-47b8-a036-33ac447e668d", @@ -6865,7 +7047,7 @@ client.bulk_sync.executions.get_logs(
-
client.bulk_sync.executions.export_logs(...) +
client.bulk_sync.executions.export_logs(...) -> V4ExportSyncLogsEnvelope
@@ -6879,11 +7061,14 @@ client.bulk_sync.executions.get_logs( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.executions.export_logs( sync_id="248df4b7-aa70-47b8-a036-33ac447e668d", execution_id="248df4b7-aa70-47b8-a036-33ac447e668d", @@ -6940,7 +7125,7 @@ client.bulk_sync.executions.export_logs(
## BulkSync Schemas -
client.bulk_sync.schemas.list(...) +
client.bulk_sync.schemas.list(...) -> ListBulkSchema
@@ -6954,11 +7139,14 @@ client.bulk_sync.executions.export_logs( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.schemas.list( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -6985,7 +7173,7 @@ client.bulk_sync.schemas.list(
-**filters:** `typing.Optional[typing.Dict[str, typing.Optional[str]]]` +**filters:** `typing.Optional[typing.Dict[str, str]]`
@@ -7005,7 +7193,7 @@ client.bulk_sync.schemas.list(
-
client.bulk_sync.schemas.patch(...) +
client.bulk_sync.schemas.patch(...) -> ListBulkSchema
@@ -7019,11 +7207,14 @@ client.bulk_sync.schemas.list( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.schemas.patch( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -7050,7 +7241,7 @@ client.bulk_sync.schemas.patch(
-**schemas:** `typing.Optional[typing.Sequence[BulkSchema]]` +**schemas:** `typing.Optional[typing.List[BulkSchema]]`
@@ -7070,7 +7261,7 @@ client.bulk_sync.schemas.patch(
-
client.bulk_sync.schemas.get(...) +
client.bulk_sync.schemas.get(...) -> BulkSchemaEnvelope
@@ -7084,11 +7275,14 @@ client.bulk_sync.schemas.patch( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.schemas.get( id="248df4b7-aa70-47b8-a036-33ac447e668d", schema_id="Contact", @@ -7136,7 +7330,7 @@ client.bulk_sync.schemas.get(
-
client.bulk_sync.schemas.update(...) +
client.bulk_sync.schemas.update(...) -> BulkSchemaEnvelope
@@ -7150,11 +7344,14 @@ client.bulk_sync.schemas.get( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.schemas.update( id="248df4b7-aa70-47b8-a036-33ac447e668d", schema_id="contact", @@ -7190,7 +7387,7 @@ client.bulk_sync.schemas.update(
-**data_cutoff_timestamp:** `typing.Optional[dt.datetime]` +**data_cutoff_timestamp:** `typing.Optional[datetime.datetime]`
@@ -7214,7 +7411,7 @@ client.bulk_sync.schemas.update(
-**fields:** `typing.Optional[typing.Sequence[UpdateBulkField]]` +**fields:** `typing.Optional[typing.List[UpdateBulkField]]`
@@ -7222,7 +7419,7 @@ client.bulk_sync.schemas.update(
-**filters:** `typing.Optional[typing.Sequence[BulkFilter]]` +**filters:** `typing.Optional[typing.List[BulkFilter2]]`
@@ -7266,7 +7463,7 @@ client.bulk_sync.schemas.update(
-
client.bulk_sync.schemas.cancel(...) +
client.bulk_sync.schemas.cancel(...) -> CancelBulkSyncResponseEnvelope
@@ -7280,11 +7477,14 @@ client.bulk_sync.schemas.update( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.schemas.cancel( id="248df4b7-aa70-47b8-a036-33ac447e668d", schema_id="schema_id", @@ -7333,7 +7533,7 @@ client.bulk_sync.schemas.cancel(
## BulkSync Schedules -
client.bulk_sync.schedules.list(...) +
client.bulk_sync.schedules.list(...) -> SchedulesEnvelope
@@ -7347,11 +7547,14 @@ client.bulk_sync.schemas.cancel( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.schedules.list( sync_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -7390,7 +7593,7 @@ client.bulk_sync.schedules.list(
-
client.bulk_sync.schedules.create(...) +
client.bulk_sync.schedules.create(...) -> ScheduleEnvelope
@@ -7404,11 +7607,14 @@ client.bulk_sync.schedules.list( ```python from polytomic import Polytomic, V4BulkSyncScheduleApi +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.schedules.create( sync_id="248df4b7-aa70-47b8-a036-33ac447e668d", schedule=V4BulkSyncScheduleApi( @@ -7458,7 +7664,7 @@ client.bulk_sync.schedules.create(
-
client.bulk_sync.schedules.get(...) +
client.bulk_sync.schedules.get(...) -> ScheduleEnvelope
@@ -7472,11 +7678,14 @@ client.bulk_sync.schedules.create( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.schedules.get( sync_id="248df4b7-aa70-47b8-a036-33ac447e668d", schedule_id="248df4b7-aa70-47b8-a036-33ac447e668d", @@ -7524,7 +7733,7 @@ client.bulk_sync.schedules.get(
-
client.bulk_sync.schedules.update(...) +
client.bulk_sync.schedules.update(...) -> ScheduleEnvelope
@@ -7538,11 +7747,14 @@ client.bulk_sync.schedules.get( ```python from polytomic import Polytomic, V4BulkSyncScheduleApi +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.schedules.update( sync_id="248df4b7-aa70-47b8-a036-33ac447e668d", schedule_id="248df4b7-aa70-47b8-a036-33ac447e668d", @@ -7615,11 +7827,14 @@ client.bulk_sync.schedules.update( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.bulk_sync.schedules.delete( sync_id="248df4b7-aa70-47b8-a036-33ac447e668d", schedule_id="248df4b7-aa70-47b8-a036-33ac447e668d", @@ -7668,7 +7883,7 @@ client.bulk_sync.schedules.delete(
## ModelSync Targets -
client.model_sync.targets.get_target(...) +
client.model_sync.targets.get_target(...) -> GetConnectionMetaEnvelope
@@ -7682,11 +7897,14 @@ client.bulk_sync.schedules.delete( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.targets.get_target( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -7741,7 +7959,7 @@ client.model_sync.targets.get_target(
-
client.model_sync.targets.get_target_fields(...) +
client.model_sync.targets.get_target_fields(...) -> TargetResponseEnvelope
@@ -7755,11 +7973,14 @@ client.model_sync.targets.get_target( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.targets.get_target_fields( id="248df4b7-aa70-47b8-a036-33ac447e668d", target="database.table", @@ -7816,7 +8037,7 @@ client.model_sync.targets.get_target_fields(
-
client.model_sync.targets.list(...) +
client.model_sync.targets.list(...) -> V4TargetObjectsResponseEnvelope
@@ -7860,11 +8081,14 @@ what operations the mode supports. ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.targets.list( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -7903,7 +8127,7 @@ client.model_sync.targets.list(
-
client.model_sync.targets.get_create_property(...) +
client.model_sync.targets.get_create_property(...) -> V4TargetPropertyValuesEnvelope
@@ -7960,11 +8184,14 @@ sync](https://apidocs.polytomic.com/2024-02-08/api-reference/model-sync/create). ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.targets.get_create_property( id="248df4b7-aa70-47b8-a036-33ac447e668d", property="property", @@ -8013,7 +8240,7 @@ client.model_sync.targets.get_create_property(
## ModelSync Executions -
client.model_sync.executions.list(...) +
client.model_sync.executions.list(...) -> ListExecutionResponseEnvelope
@@ -8027,11 +8254,14 @@ client.model_sync.targets.get_create_property( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.executions.list( sync_id="248df4b7-aa70-47b8-a036-33ac447e668d", page_token="AmkYh8v0jR5B3kls2Qcc9y8MjrPmvR4CvaK7H0F4rEwqvg76K==", @@ -8097,7 +8327,7 @@ client.model_sync.executions.list(
-
client.model_sync.executions.get(...) +
client.model_sync.executions.get(...) -> GetExecutionResponseEnvelope
@@ -8111,11 +8341,14 @@ client.model_sync.executions.list( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.executions.get( sync_id="248df4b7-aa70-47b8-a036-33ac447e668d", id="248df4b7-aa70-47b8-a036-33ac447e668d", @@ -8163,7 +8396,7 @@ client.model_sync.executions.get(
-
client.model_sync.executions.update(...) +
client.model_sync.executions.update(...) -> GetExecutionResponseEnvelope
@@ -8177,11 +8410,14 @@ client.model_sync.executions.get( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.executions.update( sync_id="248df4b7-aa70-47b8-a036-33ac447e668d", id="248df4b7-aa70-47b8-a036-33ac447e668d", @@ -8238,7 +8474,7 @@ client.model_sync.executions.update(
-
client.model_sync.executions.get_log_urls(...) +
client.model_sync.executions.get_log_urls(...) -> ExecutionLogsResponseEnvelope
@@ -8252,11 +8488,14 @@ client.model_sync.executions.update( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.executions.get_log_urls( sync_id="248df4b7-aa70-47b8-a036-33ac447e668d", id="248df4b7-aa70-47b8-a036-33ac447e668d", @@ -8327,11 +8566,14 @@ client.model_sync.executions.get_log_urls( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.model_sync.executions.get_logs( sync_id="248df4b7-aa70-47b8-a036-33ac447e668d", id="0ecd09c1-b901-4d27-9053-f0367c427254", @@ -8398,7 +8640,7 @@ client.model_sync.executions.get_logs(
## Permissions Policies -
client.permissions.policies.list() +
client.permissions.policies.list() -> ListPoliciesResponseEnvelope
@@ -8412,11 +8654,14 @@ client.model_sync.executions.get_logs( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.permissions.policies.list() ``` @@ -8445,7 +8690,7 @@ client.permissions.policies.list()
-
client.permissions.policies.create(...) +
client.permissions.policies.create(...) -> PolicyResponseEnvelope
@@ -8459,11 +8704,14 @@ client.permissions.policies.list() ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.permissions.policies.create( name="Custom", ) @@ -8498,7 +8746,7 @@ client.permissions.policies.create(
-**policy_actions:** `typing.Optional[typing.Sequence[PolicyAction]]` +**policy_actions:** `typing.Optional[typing.List[PolicyAction]]`
@@ -8518,7 +8766,7 @@ client.permissions.policies.create(
-
client.permissions.policies.get(...) +
client.permissions.policies.get(...) -> PolicyResponseEnvelope
@@ -8532,11 +8780,14 @@ client.permissions.policies.create( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.permissions.policies.get( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -8575,7 +8826,7 @@ client.permissions.policies.get(
-
client.permissions.policies.update(...) +
client.permissions.policies.update(...) -> PolicyResponseEnvelope
@@ -8589,11 +8840,14 @@ client.permissions.policies.get( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.permissions.policies.update( id="248df4b7-aa70-47b8-a036-33ac447e668d", name="Custom", @@ -8637,7 +8891,7 @@ client.permissions.policies.update(
-**policy_actions:** `typing.Optional[typing.Sequence[PolicyAction]]` +**policy_actions:** `typing.Optional[typing.List[PolicyAction]]`
@@ -8671,11 +8925,14 @@ client.permissions.policies.update( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.permissions.policies.remove( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -8715,7 +8972,7 @@ client.permissions.policies.remove(
## Permissions Roles -
client.permissions.roles.list() +
client.permissions.roles.list() -> RoleListResponseEnvelope
@@ -8729,11 +8986,14 @@ client.permissions.policies.remove( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.permissions.roles.list() ``` @@ -8762,7 +9022,7 @@ client.permissions.roles.list()
-
client.permissions.roles.create(...) +
client.permissions.roles.create(...) -> RoleResponseEnvelope
@@ -8776,11 +9036,14 @@ client.permissions.roles.list() ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.permissions.roles.create( name="Custom", ) @@ -8827,7 +9090,7 @@ client.permissions.roles.create(
-
client.permissions.roles.get(...) +
client.permissions.roles.get(...) -> RoleResponseEnvelope
@@ -8841,11 +9104,14 @@ client.permissions.roles.create( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.permissions.roles.get( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) @@ -8884,7 +9150,7 @@ client.permissions.roles.get(
-
client.permissions.roles.update(...) +
client.permissions.roles.update(...) -> RoleResponseEnvelope
@@ -8898,11 +9164,14 @@ client.permissions.roles.get( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.permissions.roles.update( id="248df4b7-aa70-47b8-a036-33ac447e668d", name="Custom", @@ -8972,11 +9241,14 @@ client.permissions.roles.update( ```python from polytomic import Polytomic +from polytomic.environment import PolytomicEnvironment client = Polytomic( - version="YOUR_VERSION", - token="YOUR_TOKEN", + token="", + version="", + environment=PolytomicEnvironment.DEFAULT, ) + client.permissions.roles.remove( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) diff --git a/requirements.txt b/requirements.txt index f502f1b..e80f640 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ httpx>=0.21.2 pydantic>= 1.9.2 -pydantic-core==^2.18.2 +pydantic-core>=2.18.2 typing_extensions>= 4.0.0 diff --git a/src/polytomic/__init__.py b/src/polytomic/__init__.py index 4b4bd97..8cc408d 100644 --- a/src/polytomic/__init__.py +++ b/src/polytomic/__init__.py @@ -1,239 +1,509 @@ # This file was auto-generated by Fern from our API Definition. -from .types import ( - ActivateSyncEnvelope, - ActivateSyncInput, - ActivateSyncOutput, - ApiError, - ApiKeyResponse, - ApiKeyResponseEnvelope, - BackendConnectionCapabilities, - BackendOAuthPrompt, - BulkBulkSyncSchedule, - BulkDiscover, - BulkExecutionStatus, - BulkFetchMode, - BulkField, - BulkFilter, - BulkItemizedSchedule, - BulkMultiScheduleConfiguration, - BulkNormalizeNames, - BulkSchedule, - BulkScheduleSyncMode, - BulkSchema, - BulkSchemaEnvelope, - BulkSchemaExecutionStatus, - BulkSelectiveMode, - BulkSyncCanceledEvent, - BulkSyncCompletedEvent, - BulkSyncCompletedWithErrorEvent, - BulkSyncDest, - BulkSyncDestEnvelope, - BulkSyncExecution, - BulkSyncExecutionEnvelope, - BulkSyncExecutionStatus, - BulkSyncFailedEvent, - BulkSyncListEnvelope, - BulkSyncMode, - BulkSyncResponse, - BulkSyncResponseEnvelope, - BulkSyncRunningEvent, - BulkSyncSchemaExecution, - BulkSyncSchemaExecutionStatus, - BulkSyncSource, - BulkSyncSourceEnvelope, - BulkSyncSourceSchemaEnvelope, - BulkSyncSourceStatus, - BulkSyncSourceStatusEnvelope, - BulkSyncStatusEnvelope, - BulkSyncStatusResponse, - CancelBulkSyncResponse, - CancelBulkSyncResponseEnvelope, - CancelModelSyncResponse, - CancelModelSyncResponseEnvelope, - CommonOutputActor, - ConfigurationValue, - ConnectCardResponse, - ConnectCardResponseEnvelope, - ConnectionListResponseEnvelope, - ConnectionMeta, - ConnectionMetaResponse, - ConnectionParameterValue, - ConnectionParameterValuesResp, - ConnectionParameterValuesResponseEnvelope, - ConnectionResponseEnvelope, - ConnectionResponseSchema, - ConnectionType, - ConnectionTypeResponseEnvelope, - ConnectionTypeSchema, - CreateConnectionResponseEnvelope, - CreateConnectionResponseSchema, - CreateModelRequest, - CreateSharedConnectionResponseSchema, - Enrichment, - Event, - EventBody, - EventTypesEnvelope, - EventsEnvelope, - ExecutionCounts, - ExecutionLogResponse, - ExecutionLogsResponseEnvelope, - ExecutionStatus, - FieldConfiguration, - Filter, - FilterFieldReferenceType, - FilterFunction, - GetConnectionMetaEnvelope, - GetExecutionResponseEnvelope, - GetExecutionResponseSchema, - GetIdentityResponseEnvelope, - GetIdentityResponseSchema, - GetModelSyncSourceMetaEnvelope, - Identity, - IdentityFunction, - JobResponse, - JobResponseEnvelope, - JsonschemaDefinitions, - JsonschemaForm, - JsonschemaSchema, - LabelLabel, - ListBulkSchema, - ListBulkSyncExecutionStatusEnvelope, - ListBulkSyncExecutionsEnvelope, - ListExecutionResponseEnvelope, - ListModelSyncResponseEnvelope, - ListPoliciesResponseEnvelope, - ListUsersEnvelope, - Mode, - ModelField, - ModelFieldResponse, - ModelListResponseEnvelope, - ModelModelFieldRequest, - ModelRelation, - ModelRelationTo, - ModelResponse, - ModelResponseEnvelope, - ModelSample, - ModelSampleResponseEnvelope, - ModelSyncField, - ModelSyncMode, - ModelSyncResponse, - ModelSyncResponseEnvelope, - ModelSyncSourceMetaResponse, - Organization, - OrganizationEnvelope, - OrganizationsEnvelope, - Override, - Pagination, - PaginationDetails, - PickValue, - PolicyAction, - PolicyResponse, - PolicyResponseEnvelope, - Relation, - RelationTo, - RestErrResponse, - RoleListResponseEnvelope, - RoleResponse, - RoleResponseEnvelope, - RunAfter, - Schedule, - ScheduleEnvelope, - ScheduleFrequency, - ScheduleOptionResponse, - ScheduleOptionResponseEnvelope, - ScheduleScheduleOption, - SchedulesEnvelope, - Schema, - SchemaAssociation, - SchemaConfiguration, - SchemaField, - SchemaIdentityFunction, - SchemaPrimaryKeyOverrideInput, - SchemaRecordsResponseEnvelope, - Source, - SourceMeta, - StartModelSyncResponseEnvelope, - StartModelSyncResponseSchema, - SupportedBulkMode, - SupportedMode, - SyncCanceledEvent, - SyncCompletedEvent, - SyncCompletedWithErrorsEvent, - SyncDestinationProperties, - SyncFailedEvent, - SyncRunningEvent, - SyncStatusEnvelope, - SyncStatusResponse, - Target, - TargetCreateInput, - TargetField, - TargetObject, - TargetResponse, - TargetResponseEnvelope, - TypesType, - UpdateBulkField, - User, - UserEnvelope, - UtilEnumValue, - UtilFieldType, - V2ConnectionForm, - V2CreateSharedConnectionResponseEnvelope, - V2EnricherConfiguration, - V2EnricherMapping, - V2ExecutionLogType, - V2GetEnrichmentInputFieldsResponseEnvelope, - V2OrderedMapStringGithubComInvopopJsonschemaSchema, - V2SampleRecord, - V2SchemaConfigurationFieldsItem, - V4BulkSyncExecutionLogs, - V4BulkSyncExecutionLogsEnvelope, - V4BulkSyncScheduleApi, - V4ExportSyncLogsEnvelope, - V4ExportSyncLogsResponse, - V4GlobalErrorSubscribersResponse, - V4QueryResultsEnvelope, - V4RunQueryEnvelope, - V4RunQueryResult, - V4TargetCreator, - V4TargetObjectsResponseEnvelope, - V4TargetPropertyValues, - V4TargetPropertyValuesEnvelope, - V4UserFieldRequest, - Webhook, - WebhookEnvelope, - WebhookListEnvelope, - WorkTaskStatus, -) -from .errors import ( - BadRequestError, - ConflictError, - ForbiddenError, - InternalServerError, - NotFoundError, - UnauthorizedError, - UnprocessableEntityError, -) -from . import ( - bulk_sync, - connections, - events, - identity, - jobs, - model_sync, - models, - notifications, - organization, - permissions, - query_runner, - schemas, - users, - webhooks, -) -from .bulk_sync import V2CreateBulkSyncRequestSchemasItem, V2UpdateBulkSyncRequestSchemasItem -from .client import AsyncPolytomic, Polytomic -from .environment import PolytomicEnvironment -from .version import __version__ +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from .types import ( + ActivateSyncEnvelope, + ActivateSyncInput, + ActivateSyncOutput, + ApiError, + ApiKeyResponse, + ApiKeyResponseEnvelope, + BackendConnectionCapabilities, + BackendOAuthPrompt, + BulkBulkSyncSchedule, + BulkDiscover, + BulkExecutionStatus, + BulkFetchMode, + BulkField, + BulkFilter, + BulkFilter2, + BulkItemizedSchedule, + BulkMultiScheduleConfiguration, + BulkNormalizeNames, + BulkSchedule, + BulkScheduleSyncMode, + BulkSchema, + BulkSchemaEnvelope, + BulkSchemaExecutionStatus, + BulkSelectiveMode, + BulkSyncCanceledEvent, + BulkSyncCompletedEvent, + BulkSyncCompletedWithErrorEvent, + BulkSyncDest, + BulkSyncDestEnvelope, + BulkSyncExecution, + BulkSyncExecutionEnvelope, + BulkSyncExecutionStatus, + BulkSyncFailedEvent, + BulkSyncIngestionStatus, + BulkSyncListEnvelope, + BulkSyncMode, + BulkSyncResponse, + BulkSyncResponseEnvelope, + BulkSyncRunningEvent, + BulkSyncSchemaExecution, + BulkSyncSchemaExecutionStatus, + BulkSyncSource, + BulkSyncSourceEnvelope, + BulkSyncSourceSchemaEnvelope, + BulkSyncSourceStatus, + BulkSyncSourceStatusEnvelope, + BulkSyncStatusEnvelope, + BulkSyncStatusResponse, + CancelBulkSyncResponse, + CancelBulkSyncResponseEnvelope, + CancelModelSyncResponse, + CancelModelSyncResponseEnvelope, + CommonOutputActor, + ConfigurationValue, + ConfigurationValue2, + ConnectCardResponse, + ConnectCardResponseEnvelope, + ConnectionListResponseEnvelope, + ConnectionMeta, + ConnectionMetaResponse, + ConnectionParameterValue, + ConnectionParameterValuesResp, + ConnectionParameterValuesResponseEnvelope, + ConnectionResponseEnvelope, + ConnectionResponseSchema, + ConnectionType, + ConnectionTypeResponseEnvelope, + ConnectionTypeSchema, + CreateConnectionResponseEnvelope, + CreateConnectionResponseSchema, + CreateModelRequest, + CreateSharedConnectionResponseSchema, + Enrichment, + Event, + EventBody, + EventTypesEnvelope, + EventsEnvelope, + ExecutionCounts, + ExecutionLogResponse, + ExecutionLogsResponseEnvelope, + ExecutionStatus, + FieldConfiguration, + Filter, + FilterFieldReferenceType, + FilterFunction, + GetConnectionMetaEnvelope, + GetExecutionResponseEnvelope, + GetExecutionResponseSchema, + GetIdentityResponseEnvelope, + GetIdentityResponseSchema, + GetModelSyncSourceMetaEnvelope, + Identity, + IdentityFunction, + IngestionStatusLevel, + JobResponse, + JobResponseEnvelope, + JsonschemaDefinitions, + JsonschemaForm, + JsonschemaSchema, + LabelLabel, + ListBulkSchema, + ListBulkSyncExecutionStatusEnvelope, + ListBulkSyncExecutionsEnvelope, + ListExecutionResponseEnvelope, + ListModelSyncResponseEnvelope, + ListPoliciesResponseEnvelope, + ListUsersEnvelope, + Mode, + ModelField, + ModelFieldResponse, + ModelListResponseEnvelope, + ModelModelFieldRequest, + ModelRelation, + ModelRelationTo, + ModelResponse, + ModelResponseEnvelope, + ModelSample, + ModelSampleResponseEnvelope, + ModelSyncField, + ModelSyncMode, + ModelSyncResponse, + ModelSyncResponseEnvelope, + ModelSyncSourceMetaResponse, + Organization, + OrganizationEnvelope, + OrganizationsEnvelope, + Override, + Pagination, + PaginationDetails, + PaginationDetails2, + PickValue, + PolicyAction, + PolicyResponse, + PolicyResponseEnvelope, + Relation, + RelationTo, + RestErrResponse, + RoleListResponseEnvelope, + RoleResponse, + RoleResponseEnvelope, + RunAfter, + Schedule, + ScheduleEnvelope, + ScheduleFrequency, + ScheduleOptionResponse, + ScheduleOptionResponseEnvelope, + ScheduleScheduleOption, + SchedulesEnvelope, + Schema, + SchemaAssociation, + SchemaConfiguration, + SchemaField, + SchemaIdentityFunction, + SchemaPrimaryKeyOverrideInput, + SchemaRecordsResponseEnvelope, + Source, + SourceMeta, + StartModelSyncResponseEnvelope, + StartModelSyncResponseSchema, + SupportedBulkMode, + SupportedMode, + SyncCanceledEvent, + SyncCompletedEvent, + SyncCompletedWithErrorsEvent, + SyncDestinationProperties, + SyncFailedEvent, + SyncRunningEvent, + SyncStatusEnvelope, + SyncStatusResponse, + Target, + TargetCreateInput, + TargetField, + TargetObject, + TargetResponse, + TargetResponseEnvelope, + TypesType, + UpdateBulkField, + User, + UserEnvelope, + UtilEnumValue, + UtilFieldType, + V2ConnectionForm, + V2CreateSharedConnectionResponseEnvelope, + V2EnricherConfiguration, + V2EnricherMapping, + V2ExecutionLogType, + V2GetEnrichmentInputFieldsResponseEnvelope, + V2OrderedMapStringGithubComInvopopJsonschemaSchema, + V2SampleRecord, + V2SchemaConfigurationFieldsItem, + V4BulkSyncExecutionLogs, + V4BulkSyncExecutionLogsEnvelope, + V4BulkSyncScheduleApi, + V4ExportSyncLogsEnvelope, + V4ExportSyncLogsResponse, + V4GlobalErrorSubscribersResponse, + V4QueryResultsEnvelope, + V4RunQueryEnvelope, + V4RunQueryResult, + V4TargetCreator, + V4TargetObjectsResponseEnvelope, + V4TargetPropertyValues, + V4TargetPropertyValuesEnvelope, + V4UserFieldRequest, + Webhook, + WebhookEnvelope, + WebhookListEnvelope, + WorkTaskStatus, + ) + from .errors import ( + BadRequestError, + ConflictError, + ForbiddenError, + InternalServerError, + NotFoundError, + UnauthorizedError, + UnprocessableEntityError, + ) + from . import ( + bulk_sync, + connections, + events, + identity, + jobs, + model_sync, + models, + notifications, + organization, + permissions, + query_runner, + schemas, + users, + webhooks, + ) + from .bulk_sync import V2CreateBulkSyncRequestSchemasItem, V2UpdateBulkSyncRequestSchemasItem + from .client import AsyncPolytomic, Polytomic + from .environment import PolytomicEnvironment + from .version import __version__ +_dynamic_imports: typing.Dict[str, str] = { + "ActivateSyncEnvelope": ".types", + "ActivateSyncInput": ".types", + "ActivateSyncOutput": ".types", + "ApiError": ".types", + "ApiKeyResponse": ".types", + "ApiKeyResponseEnvelope": ".types", + "AsyncPolytomic": ".client", + "BackendConnectionCapabilities": ".types", + "BackendOAuthPrompt": ".types", + "BadRequestError": ".errors", + "BulkBulkSyncSchedule": ".types", + "BulkDiscover": ".types", + "BulkExecutionStatus": ".types", + "BulkFetchMode": ".types", + "BulkField": ".types", + "BulkFilter": ".types", + "BulkFilter2": ".types", + "BulkItemizedSchedule": ".types", + "BulkMultiScheduleConfiguration": ".types", + "BulkNormalizeNames": ".types", + "BulkSchedule": ".types", + "BulkScheduleSyncMode": ".types", + "BulkSchema": ".types", + "BulkSchemaEnvelope": ".types", + "BulkSchemaExecutionStatus": ".types", + "BulkSelectiveMode": ".types", + "BulkSyncCanceledEvent": ".types", + "BulkSyncCompletedEvent": ".types", + "BulkSyncCompletedWithErrorEvent": ".types", + "BulkSyncDest": ".types", + "BulkSyncDestEnvelope": ".types", + "BulkSyncExecution": ".types", + "BulkSyncExecutionEnvelope": ".types", + "BulkSyncExecutionStatus": ".types", + "BulkSyncFailedEvent": ".types", + "BulkSyncIngestionStatus": ".types", + "BulkSyncListEnvelope": ".types", + "BulkSyncMode": ".types", + "BulkSyncResponse": ".types", + "BulkSyncResponseEnvelope": ".types", + "BulkSyncRunningEvent": ".types", + "BulkSyncSchemaExecution": ".types", + "BulkSyncSchemaExecutionStatus": ".types", + "BulkSyncSource": ".types", + "BulkSyncSourceEnvelope": ".types", + "BulkSyncSourceSchemaEnvelope": ".types", + "BulkSyncSourceStatus": ".types", + "BulkSyncSourceStatusEnvelope": ".types", + "BulkSyncStatusEnvelope": ".types", + "BulkSyncStatusResponse": ".types", + "CancelBulkSyncResponse": ".types", + "CancelBulkSyncResponseEnvelope": ".types", + "CancelModelSyncResponse": ".types", + "CancelModelSyncResponseEnvelope": ".types", + "CommonOutputActor": ".types", + "ConfigurationValue": ".types", + "ConfigurationValue2": ".types", + "ConflictError": ".errors", + "ConnectCardResponse": ".types", + "ConnectCardResponseEnvelope": ".types", + "ConnectionListResponseEnvelope": ".types", + "ConnectionMeta": ".types", + "ConnectionMetaResponse": ".types", + "ConnectionParameterValue": ".types", + "ConnectionParameterValuesResp": ".types", + "ConnectionParameterValuesResponseEnvelope": ".types", + "ConnectionResponseEnvelope": ".types", + "ConnectionResponseSchema": ".types", + "ConnectionType": ".types", + "ConnectionTypeResponseEnvelope": ".types", + "ConnectionTypeSchema": ".types", + "CreateConnectionResponseEnvelope": ".types", + "CreateConnectionResponseSchema": ".types", + "CreateModelRequest": ".types", + "CreateSharedConnectionResponseSchema": ".types", + "Enrichment": ".types", + "Event": ".types", + "EventBody": ".types", + "EventTypesEnvelope": ".types", + "EventsEnvelope": ".types", + "ExecutionCounts": ".types", + "ExecutionLogResponse": ".types", + "ExecutionLogsResponseEnvelope": ".types", + "ExecutionStatus": ".types", + "FieldConfiguration": ".types", + "Filter": ".types", + "FilterFieldReferenceType": ".types", + "FilterFunction": ".types", + "ForbiddenError": ".errors", + "GetConnectionMetaEnvelope": ".types", + "GetExecutionResponseEnvelope": ".types", + "GetExecutionResponseSchema": ".types", + "GetIdentityResponseEnvelope": ".types", + "GetIdentityResponseSchema": ".types", + "GetModelSyncSourceMetaEnvelope": ".types", + "Identity": ".types", + "IdentityFunction": ".types", + "IngestionStatusLevel": ".types", + "InternalServerError": ".errors", + "JobResponse": ".types", + "JobResponseEnvelope": ".types", + "JsonschemaDefinitions": ".types", + "JsonschemaForm": ".types", + "JsonschemaSchema": ".types", + "LabelLabel": ".types", + "ListBulkSchema": ".types", + "ListBulkSyncExecutionStatusEnvelope": ".types", + "ListBulkSyncExecutionsEnvelope": ".types", + "ListExecutionResponseEnvelope": ".types", + "ListModelSyncResponseEnvelope": ".types", + "ListPoliciesResponseEnvelope": ".types", + "ListUsersEnvelope": ".types", + "Mode": ".types", + "ModelField": ".types", + "ModelFieldResponse": ".types", + "ModelListResponseEnvelope": ".types", + "ModelModelFieldRequest": ".types", + "ModelRelation": ".types", + "ModelRelationTo": ".types", + "ModelResponse": ".types", + "ModelResponseEnvelope": ".types", + "ModelSample": ".types", + "ModelSampleResponseEnvelope": ".types", + "ModelSyncField": ".types", + "ModelSyncMode": ".types", + "ModelSyncResponse": ".types", + "ModelSyncResponseEnvelope": ".types", + "ModelSyncSourceMetaResponse": ".types", + "NotFoundError": ".errors", + "Organization": ".types", + "OrganizationEnvelope": ".types", + "OrganizationsEnvelope": ".types", + "Override": ".types", + "Pagination": ".types", + "PaginationDetails": ".types", + "PaginationDetails2": ".types", + "PickValue": ".types", + "PolicyAction": ".types", + "PolicyResponse": ".types", + "PolicyResponseEnvelope": ".types", + "Polytomic": ".client", + "PolytomicEnvironment": ".environment", + "Relation": ".types", + "RelationTo": ".types", + "RestErrResponse": ".types", + "RoleListResponseEnvelope": ".types", + "RoleResponse": ".types", + "RoleResponseEnvelope": ".types", + "RunAfter": ".types", + "Schedule": ".types", + "ScheduleEnvelope": ".types", + "ScheduleFrequency": ".types", + "ScheduleOptionResponse": ".types", + "ScheduleOptionResponseEnvelope": ".types", + "ScheduleScheduleOption": ".types", + "SchedulesEnvelope": ".types", + "Schema": ".types", + "SchemaAssociation": ".types", + "SchemaConfiguration": ".types", + "SchemaField": ".types", + "SchemaIdentityFunction": ".types", + "SchemaPrimaryKeyOverrideInput": ".types", + "SchemaRecordsResponseEnvelope": ".types", + "Source": ".types", + "SourceMeta": ".types", + "StartModelSyncResponseEnvelope": ".types", + "StartModelSyncResponseSchema": ".types", + "SupportedBulkMode": ".types", + "SupportedMode": ".types", + "SyncCanceledEvent": ".types", + "SyncCompletedEvent": ".types", + "SyncCompletedWithErrorsEvent": ".types", + "SyncDestinationProperties": ".types", + "SyncFailedEvent": ".types", + "SyncRunningEvent": ".types", + "SyncStatusEnvelope": ".types", + "SyncStatusResponse": ".types", + "Target": ".types", + "TargetCreateInput": ".types", + "TargetField": ".types", + "TargetObject": ".types", + "TargetResponse": ".types", + "TargetResponseEnvelope": ".types", + "TypesType": ".types", + "UnauthorizedError": ".errors", + "UnprocessableEntityError": ".errors", + "UpdateBulkField": ".types", + "User": ".types", + "UserEnvelope": ".types", + "UtilEnumValue": ".types", + "UtilFieldType": ".types", + "V2ConnectionForm": ".types", + "V2CreateBulkSyncRequestSchemasItem": ".bulk_sync", + "V2CreateSharedConnectionResponseEnvelope": ".types", + "V2EnricherConfiguration": ".types", + "V2EnricherMapping": ".types", + "V2ExecutionLogType": ".types", + "V2GetEnrichmentInputFieldsResponseEnvelope": ".types", + "V2OrderedMapStringGithubComInvopopJsonschemaSchema": ".types", + "V2SampleRecord": ".types", + "V2SchemaConfigurationFieldsItem": ".types", + "V2UpdateBulkSyncRequestSchemasItem": ".bulk_sync", + "V4BulkSyncExecutionLogs": ".types", + "V4BulkSyncExecutionLogsEnvelope": ".types", + "V4BulkSyncScheduleApi": ".types", + "V4ExportSyncLogsEnvelope": ".types", + "V4ExportSyncLogsResponse": ".types", + "V4GlobalErrorSubscribersResponse": ".types", + "V4QueryResultsEnvelope": ".types", + "V4RunQueryEnvelope": ".types", + "V4RunQueryResult": ".types", + "V4TargetCreator": ".types", + "V4TargetObjectsResponseEnvelope": ".types", + "V4TargetPropertyValues": ".types", + "V4TargetPropertyValuesEnvelope": ".types", + "V4UserFieldRequest": ".types", + "Webhook": ".types", + "WebhookEnvelope": ".types", + "WebhookListEnvelope": ".types", + "WorkTaskStatus": ".types", + "__version__": ".version", + "bulk_sync": ".bulk_sync", + "connections": ".connections", + "events": ".events", + "identity": ".identity", + "jobs": ".jobs", + "model_sync": ".model_sync", + "models": ".models", + "notifications": ".notifications", + "organization": ".organization", + "permissions": ".permissions", + "query_runner": ".query_runner", + "schemas": ".schemas", + "users": ".users", + "webhooks": ".webhooks", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = [ "ActivateSyncEnvelope", @@ -252,6 +522,7 @@ "BulkFetchMode", "BulkField", "BulkFilter", + "BulkFilter2", "BulkItemizedSchedule", "BulkMultiScheduleConfiguration", "BulkNormalizeNames", @@ -270,6 +541,7 @@ "BulkSyncExecutionEnvelope", "BulkSyncExecutionStatus", "BulkSyncFailedEvent", + "BulkSyncIngestionStatus", "BulkSyncListEnvelope", "BulkSyncMode", "BulkSyncResponse", @@ -290,6 +562,7 @@ "CancelModelSyncResponseEnvelope", "CommonOutputActor", "ConfigurationValue", + "ConfigurationValue2", "ConflictError", "ConnectCardResponse", "ConnectCardResponseEnvelope", @@ -330,6 +603,7 @@ "GetModelSyncSourceMetaEnvelope", "Identity", "IdentityFunction", + "IngestionStatusLevel", "InternalServerError", "JobResponse", "JobResponseEnvelope", @@ -367,6 +641,7 @@ "Override", "Pagination", "PaginationDetails", + "PaginationDetails2", "PickValue", "PolicyAction", "PolicyResponse", diff --git a/src/polytomic/bulk_sync/__init__.py b/src/polytomic/bulk_sync/__init__.py index 13ec86b..89d5ead 100644 --- a/src/polytomic/bulk_sync/__init__.py +++ b/src/polytomic/bulk_sync/__init__.py @@ -1,7 +1,42 @@ # This file was auto-generated by Fern from our API Definition. -from .types import V2CreateBulkSyncRequestSchemasItem, V2UpdateBulkSyncRequestSchemasItem -from . import executions, schedules, schemas +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from .types import V2CreateBulkSyncRequestSchemasItem, V2UpdateBulkSyncRequestSchemasItem + from . import executions, schedules, schemas +_dynamic_imports: typing.Dict[str, str] = { + "V2CreateBulkSyncRequestSchemasItem": ".types", + "V2UpdateBulkSyncRequestSchemasItem": ".types", + "executions": ".executions", + "schedules": ".schedules", + "schemas": ".schemas", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = [ "V2CreateBulkSyncRequestSchemasItem", diff --git a/src/polytomic/bulk_sync/client.py b/src/polytomic/bulk_sync/client.py index 564a555..53f8e39 100644 --- a/src/polytomic/bulk_sync/client.py +++ b/src/polytomic/bulk_sync/client.py @@ -1,56 +1,55 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + +import datetime as dt import typing -from ..core.client_wrapper import SyncClientWrapper -from .executions.client import ExecutionsClient -from .schemas.client import SchemasClient -from .schedules.client import SchedulesClient + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions -from ..types.bulk_sync_list_envelope import BulkSyncListEnvelope -from ..core.pydantic_utilities import parse_obj_as -from ..errors.unauthorized_error import UnauthorizedError -from ..types.rest_err_response import RestErrResponse -from ..errors.internal_server_error import InternalServerError -from ..types.api_error import ApiError as types_api_error_ApiError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError as core_api_error_ApiError -from ..types.bulk_schedule import BulkSchedule -from ..types.bulk_discover import BulkDiscover -import datetime as dt -from ..types.bulk_sync_mode import BulkSyncMode -from ..types.bulk_normalize_names import BulkNormalizeNames -from .types.v_2_create_bulk_sync_request_schemas_item import V2CreateBulkSyncRequestSchemasItem -from ..types.bulk_sync_response_envelope import BulkSyncResponseEnvelope -from ..core.serialization import convert_and_respect_annotation_metadata -from ..errors.bad_request_error import BadRequestError -from ..errors.forbidden_error import ForbiddenError -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..core.jsonable_encoder import jsonable_encoder -from ..errors.not_found_error import NotFoundError -from .types.v_2_update_bulk_sync_request_schemas_item import V2UpdateBulkSyncRequestSchemasItem from ..types.activate_sync_envelope import ActivateSyncEnvelope -from ..types.cancel_bulk_sync_response_envelope import CancelBulkSyncResponseEnvelope +from ..types.bulk_discover import BulkDiscover from ..types.bulk_fetch_mode import BulkFetchMode +from ..types.bulk_normalize_names import BulkNormalizeNames +from ..types.bulk_schedule import BulkSchedule +from ..types.bulk_sync_dest_envelope import BulkSyncDestEnvelope from ..types.bulk_sync_execution_envelope import BulkSyncExecutionEnvelope -from ..errors.conflict_error import ConflictError -from ..types.bulk_sync_status_envelope import BulkSyncStatusEnvelope +from ..types.bulk_sync_list_envelope import BulkSyncListEnvelope +from ..types.bulk_sync_mode import BulkSyncMode +from ..types.bulk_sync_response_envelope import BulkSyncResponseEnvelope from ..types.bulk_sync_source_envelope import BulkSyncSourceEnvelope -from ..types.bulk_sync_dest_envelope import BulkSyncDestEnvelope -from ..core.client_wrapper import AsyncClientWrapper -from .executions.client import AsyncExecutionsClient -from .schemas.client import AsyncSchemasClient -from .schedules.client import AsyncSchedulesClient +from ..types.bulk_sync_status_envelope import BulkSyncStatusEnvelope +from ..types.cancel_bulk_sync_response_envelope import CancelBulkSyncResponseEnvelope +from .raw_client import AsyncRawBulkSyncClient, RawBulkSyncClient +from .types.v_2_create_bulk_sync_request_schemas_item import V2CreateBulkSyncRequestSchemasItem +from .types.v_2_update_bulk_sync_request_schemas_item import V2UpdateBulkSyncRequestSchemasItem +if typing.TYPE_CHECKING: + from .executions.client import AsyncExecutionsClient, ExecutionsClient + from .schedules.client import AsyncSchedulesClient, SchedulesClient + from .schemas.client import AsyncSchemasClient, SchemasClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) class BulkSyncClient: def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawBulkSyncClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper - self.executions = ExecutionsClient(client_wrapper=self._client_wrapper) - self.schemas = SchemasClient(client_wrapper=self._client_wrapper) - self.schedules = SchedulesClient(client_wrapper=self._client_wrapper) + self._executions: typing.Optional[ExecutionsClient] = None + self._schemas: typing.Optional[SchemasClient] = None + self._schedules: typing.Optional[SchedulesClient] = None + + @property + def with_raw_response(self) -> RawBulkSyncClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawBulkSyncClient + """ + return self._raw_client def list( self, *, active: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None @@ -80,52 +79,13 @@ def list( active=True, ) """ - _response = self._client_wrapper.httpx_client.request( - "api/bulk/syncs", - method="GET", - params={ - "active": active, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncListEnvelope, - parse_obj_as( - type_=BulkSyncListEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.list(active=active, request_options=request_options) + return _response.data def create( self, *, - destination_configuration: typing.Dict[str, typing.Optional[typing.Any]], + destination_configuration: typing.Dict[str, typing.Any], destination_connection_id: str, name: str, schedule: BulkSchedule, @@ -143,7 +103,7 @@ def create( policies: typing.Optional[typing.Sequence[str]] = OMIT, resync_concurrency_limit: typing.Optional[int] = OMIT, schemas: typing.Optional[typing.Sequence[V2CreateBulkSyncRequestSchemasItem]] = OMIT, - source_configuration: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, + source_configuration: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> BulkSyncResponseEnvelope: """ @@ -176,7 +136,7 @@ def create( Parameters ---------- - destination_configuration : typing.Dict[str, typing.Optional[typing.Any]] + destination_configuration : typing.Dict[str, typing.Any] destination_connection_id : str @@ -216,7 +176,7 @@ def create( schemas : typing.Optional[typing.Sequence[V2CreateBulkSyncRequestSchemasItem]] List of schemas to sync; if omitted, all schemas will be selected for syncing. - source_configuration : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] + source_configuration : typing.Optional[typing.Dict[str, typing.Any]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -244,103 +204,29 @@ def create( source_connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - "api/bulk/syncs", - method="POST", - json={ - "active": active, - "automatically_add_new_fields": automatically_add_new_fields, - "automatically_add_new_objects": automatically_add_new_objects, - "concurrency_limit": concurrency_limit, - "data_cutoff_timestamp": data_cutoff_timestamp, - "destination_configuration": destination_configuration, - "destination_connection_id": destination_connection_id, - "disable_record_timestamps": disable_record_timestamps, - "discover": discover, - "mode": mode, - "name": name, - "normalize_names": normalize_names, - "organization_id": organization_id, - "policies": policies, - "resync_concurrency_limit": resync_concurrency_limit, - "schedule": convert_and_respect_annotation_metadata( - object_=schedule, annotation=BulkSchedule, direction="write" - ), - "schemas": convert_and_respect_annotation_metadata( - object_=schemas, annotation=typing.Sequence[V2CreateBulkSyncRequestSchemasItem], direction="write" - ), - "source_configuration": source_configuration, - "source_connection_id": source_connection_id, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.create( + destination_configuration=destination_configuration, + destination_connection_id=destination_connection_id, + name=name, + schedule=schedule, + source_connection_id=source_connection_id, + active=active, + automatically_add_new_fields=automatically_add_new_fields, + automatically_add_new_objects=automatically_add_new_objects, + concurrency_limit=concurrency_limit, + data_cutoff_timestamp=data_cutoff_timestamp, + disable_record_timestamps=disable_record_timestamps, + discover=discover, + mode=mode, + normalize_names=normalize_names, + organization_id=organization_id, + policies=policies, + resync_concurrency_limit=resync_concurrency_limit, + schemas=schemas, + source_configuration=source_configuration, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncResponseEnvelope, - parse_obj_as( - type_=BulkSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get( self, @@ -377,53 +263,14 @@ def get( refresh_schemas=True, ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}", - method="GET", - params={ - "refresh_schemas": refresh_schemas, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncResponseEnvelope, - parse_obj_as( - type_=BulkSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(id, refresh_schemas=refresh_schemas, request_options=request_options) + return _response.data def update( self, id: str, *, - destination_configuration: typing.Dict[str, typing.Optional[typing.Any]], + destination_configuration: typing.Dict[str, typing.Any], destination_connection_id: str, name: str, schedule: BulkSchedule, @@ -441,7 +288,7 @@ def update( policies: typing.Optional[typing.Sequence[str]] = OMIT, resync_concurrency_limit: typing.Optional[int] = OMIT, schemas: typing.Optional[typing.Sequence[V2UpdateBulkSyncRequestSchemasItem]] = OMIT, - source_configuration: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, + source_configuration: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> BulkSyncResponseEnvelope: """ @@ -453,7 +300,7 @@ def update( ---------- id : str - destination_configuration : typing.Dict[str, typing.Optional[typing.Any]] + destination_configuration : typing.Dict[str, typing.Any] destination_connection_id : str @@ -493,7 +340,7 @@ def update( schemas : typing.Optional[typing.Sequence[V2UpdateBulkSyncRequestSchemasItem]] List of schemas to sync; if omitted, all schemas will be selected for syncing. - source_configuration : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] + source_configuration : typing.Optional[typing.Dict[str, typing.Any]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -522,103 +369,30 @@ def update( source_connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}", - method="PUT", - json={ - "active": active, - "automatically_add_new_fields": automatically_add_new_fields, - "automatically_add_new_objects": automatically_add_new_objects, - "concurrency_limit": concurrency_limit, - "data_cutoff_timestamp": data_cutoff_timestamp, - "destination_configuration": destination_configuration, - "destination_connection_id": destination_connection_id, - "disable_record_timestamps": disable_record_timestamps, - "discover": discover, - "mode": mode, - "name": name, - "normalize_names": normalize_names, - "organization_id": organization_id, - "policies": policies, - "resync_concurrency_limit": resync_concurrency_limit, - "schedule": convert_and_respect_annotation_metadata( - object_=schedule, annotation=BulkSchedule, direction="write" - ), - "schemas": convert_and_respect_annotation_metadata( - object_=schemas, annotation=typing.Sequence[V2UpdateBulkSyncRequestSchemasItem], direction="write" - ), - "source_configuration": source_configuration, - "source_connection_id": source_connection_id, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.update( + id, + destination_configuration=destination_configuration, + destination_connection_id=destination_connection_id, + name=name, + schedule=schedule, + source_connection_id=source_connection_id, + active=active, + automatically_add_new_fields=automatically_add_new_fields, + automatically_add_new_objects=automatically_add_new_objects, + concurrency_limit=concurrency_limit, + data_cutoff_timestamp=data_cutoff_timestamp, + disable_record_timestamps=disable_record_timestamps, + discover=discover, + mode=mode, + normalize_names=normalize_names, + organization_id=organization_id, + policies=policies, + resync_concurrency_limit=resync_concurrency_limit, + schemas=schemas, + source_configuration=source_configuration, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncResponseEnvelope, - parse_obj_as( - type_=BulkSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def remove( self, @@ -654,61 +428,8 @@ def remove( refresh_schemas=True, ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}", - method="DELETE", - params={ - "refresh_schemas": refresh_schemas, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.remove(id, refresh_schemas=refresh_schemas, request_options=request_options) + return _response.data def activate( self, id: str, *, active: bool, request_options: typing.Optional[RequestOptions] = None @@ -741,68 +462,8 @@ def activate( active=True, ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/activate", - method="POST", - json={ - "active": active, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ActivateSyncEnvelope, - parse_obj_as( - type_=ActivateSyncEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.activate(id, active=active, request_options=request_options) + return _response.data def cancel( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -833,64 +494,8 @@ def cancel( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/cancel", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CancelBulkSyncResponseEnvelope, - parse_obj_as( - type_=CancelBulkSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.cancel(id, request_options=request_options) + return _response.data def start( self, @@ -935,64 +540,10 @@ def start( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/executions", - method="POST", - json={ - "fetch_mode": fetch_mode, - "resync": resync, - "schemas": schemas, - "test": test, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.start( + id, fetch_mode=fetch_mode, resync=resync, schemas=schemas, test=test, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncExecutionEnvelope, - parse_obj_as( - type_=BulkSyncExecutionEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 409: - raise ConflictError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get_status(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> BulkSyncStatusEnvelope: """ @@ -1020,54 +571,8 @@ def get_status(self, id: str, *, request_options: typing.Optional[RequestOptions id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/status", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncStatusEnvelope, - parse_obj_as( - type_=BulkSyncStatusEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_status(id, request_options=request_options) + return _response.data def get_source( self, @@ -1104,67 +609,8 @@ def get_source( include_fields=True, ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/bulksync/source", - method="GET", - params={ - "include_fields": include_fields, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncSourceEnvelope, - parse_obj_as( - type_=BulkSyncSourceEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_source(id, include_fields=include_fields, request_options=request_options) + return _response.data def get_destination( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -1194,72 +640,52 @@ def get_destination( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/bulksync/target", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncDestEnvelope, - parse_obj_as( - type_=BulkSyncDestEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_destination(id, request_options=request_options) + return _response.data + + @property + def executions(self): + if self._executions is None: + from .executions.client import ExecutionsClient # noqa: E402 + + self._executions = ExecutionsClient(client_wrapper=self._client_wrapper) + return self._executions + + @property + def schemas(self): + if self._schemas is None: + from .schemas.client import SchemasClient # noqa: E402 + + self._schemas = SchemasClient(client_wrapper=self._client_wrapper) + return self._schemas + + @property + def schedules(self): + if self._schedules is None: + from .schedules.client import SchedulesClient # noqa: E402 + + self._schedules = SchedulesClient(client_wrapper=self._client_wrapper) + return self._schedules class AsyncBulkSyncClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawBulkSyncClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper - self.executions = AsyncExecutionsClient(client_wrapper=self._client_wrapper) - self.schemas = AsyncSchemasClient(client_wrapper=self._client_wrapper) - self.schedules = AsyncSchedulesClient(client_wrapper=self._client_wrapper) + self._executions: typing.Optional[AsyncExecutionsClient] = None + self._schemas: typing.Optional[AsyncSchemasClient] = None + self._schedules: typing.Optional[AsyncSchedulesClient] = None + + @property + def with_raw_response(self) -> AsyncRawBulkSyncClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawBulkSyncClient + """ + return self._raw_client async def list( self, *, active: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None @@ -1297,52 +723,13 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/bulk/syncs", - method="GET", - params={ - "active": active, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncListEnvelope, - parse_obj_as( - type_=BulkSyncListEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.list(active=active, request_options=request_options) + return _response.data async def create( self, *, - destination_configuration: typing.Dict[str, typing.Optional[typing.Any]], + destination_configuration: typing.Dict[str, typing.Any], destination_connection_id: str, name: str, schedule: BulkSchedule, @@ -1360,7 +747,7 @@ async def create( policies: typing.Optional[typing.Sequence[str]] = OMIT, resync_concurrency_limit: typing.Optional[int] = OMIT, schemas: typing.Optional[typing.Sequence[V2CreateBulkSyncRequestSchemasItem]] = OMIT, - source_configuration: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, + source_configuration: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> BulkSyncResponseEnvelope: """ @@ -1393,7 +780,7 @@ async def create( Parameters ---------- - destination_configuration : typing.Dict[str, typing.Optional[typing.Any]] + destination_configuration : typing.Dict[str, typing.Any] destination_connection_id : str @@ -1433,7 +820,7 @@ async def create( schemas : typing.Optional[typing.Sequence[V2CreateBulkSyncRequestSchemasItem]] List of schemas to sync; if omitted, all schemas will be selected for syncing. - source_configuration : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] + source_configuration : typing.Optional[typing.Dict[str, typing.Any]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1469,103 +856,29 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/bulk/syncs", - method="POST", - json={ - "active": active, - "automatically_add_new_fields": automatically_add_new_fields, - "automatically_add_new_objects": automatically_add_new_objects, - "concurrency_limit": concurrency_limit, - "data_cutoff_timestamp": data_cutoff_timestamp, - "destination_configuration": destination_configuration, - "destination_connection_id": destination_connection_id, - "disable_record_timestamps": disable_record_timestamps, - "discover": discover, - "mode": mode, - "name": name, - "normalize_names": normalize_names, - "organization_id": organization_id, - "policies": policies, - "resync_concurrency_limit": resync_concurrency_limit, - "schedule": convert_and_respect_annotation_metadata( - object_=schedule, annotation=BulkSchedule, direction="write" - ), - "schemas": convert_and_respect_annotation_metadata( - object_=schemas, annotation=typing.Sequence[V2CreateBulkSyncRequestSchemasItem], direction="write" - ), - "source_configuration": source_configuration, - "source_connection_id": source_connection_id, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.create( + destination_configuration=destination_configuration, + destination_connection_id=destination_connection_id, + name=name, + schedule=schedule, + source_connection_id=source_connection_id, + active=active, + automatically_add_new_fields=automatically_add_new_fields, + automatically_add_new_objects=automatically_add_new_objects, + concurrency_limit=concurrency_limit, + data_cutoff_timestamp=data_cutoff_timestamp, + disable_record_timestamps=disable_record_timestamps, + discover=discover, + mode=mode, + normalize_names=normalize_names, + organization_id=organization_id, + policies=policies, + resync_concurrency_limit=resync_concurrency_limit, + schemas=schemas, + source_configuration=source_configuration, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncResponseEnvelope, - parse_obj_as( - type_=BulkSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get( self, @@ -1610,53 +923,14 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}", - method="GET", - params={ - "refresh_schemas": refresh_schemas, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncResponseEnvelope, - parse_obj_as( - type_=BulkSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(id, refresh_schemas=refresh_schemas, request_options=request_options) + return _response.data async def update( self, id: str, *, - destination_configuration: typing.Dict[str, typing.Optional[typing.Any]], + destination_configuration: typing.Dict[str, typing.Any], destination_connection_id: str, name: str, schedule: BulkSchedule, @@ -1674,7 +948,7 @@ async def update( policies: typing.Optional[typing.Sequence[str]] = OMIT, resync_concurrency_limit: typing.Optional[int] = OMIT, schemas: typing.Optional[typing.Sequence[V2UpdateBulkSyncRequestSchemasItem]] = OMIT, - source_configuration: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, + source_configuration: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> BulkSyncResponseEnvelope: """ @@ -1686,7 +960,7 @@ async def update( ---------- id : str - destination_configuration : typing.Dict[str, typing.Optional[typing.Any]] + destination_configuration : typing.Dict[str, typing.Any] destination_connection_id : str @@ -1726,7 +1000,7 @@ async def update( schemas : typing.Optional[typing.Sequence[V2UpdateBulkSyncRequestSchemasItem]] List of schemas to sync; if omitted, all schemas will be selected for syncing. - source_configuration : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] + source_configuration : typing.Optional[typing.Dict[str, typing.Any]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1763,103 +1037,30 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}", - method="PUT", - json={ - "active": active, - "automatically_add_new_fields": automatically_add_new_fields, - "automatically_add_new_objects": automatically_add_new_objects, - "concurrency_limit": concurrency_limit, - "data_cutoff_timestamp": data_cutoff_timestamp, - "destination_configuration": destination_configuration, - "destination_connection_id": destination_connection_id, - "disable_record_timestamps": disable_record_timestamps, - "discover": discover, - "mode": mode, - "name": name, - "normalize_names": normalize_names, - "organization_id": organization_id, - "policies": policies, - "resync_concurrency_limit": resync_concurrency_limit, - "schedule": convert_and_respect_annotation_metadata( - object_=schedule, annotation=BulkSchedule, direction="write" - ), - "schemas": convert_and_respect_annotation_metadata( - object_=schemas, annotation=typing.Sequence[V2UpdateBulkSyncRequestSchemasItem], direction="write" - ), - "source_configuration": source_configuration, - "source_connection_id": source_connection_id, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.update( + id, + destination_configuration=destination_configuration, + destination_connection_id=destination_connection_id, + name=name, + schedule=schedule, + source_connection_id=source_connection_id, + active=active, + automatically_add_new_fields=automatically_add_new_fields, + automatically_add_new_objects=automatically_add_new_objects, + concurrency_limit=concurrency_limit, + data_cutoff_timestamp=data_cutoff_timestamp, + disable_record_timestamps=disable_record_timestamps, + discover=discover, + mode=mode, + normalize_names=normalize_names, + organization_id=organization_id, + policies=policies, + resync_concurrency_limit=resync_concurrency_limit, + schemas=schemas, + source_configuration=source_configuration, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncResponseEnvelope, - parse_obj_as( - type_=BulkSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def remove( self, @@ -1903,61 +1104,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}", - method="DELETE", - params={ - "refresh_schemas": refresh_schemas, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.remove(id, refresh_schemas=refresh_schemas, request_options=request_options) + return _response.data async def activate( self, id: str, *, active: bool, request_options: typing.Optional[RequestOptions] = None @@ -1998,68 +1146,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/activate", - method="POST", - json={ - "active": active, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ActivateSyncEnvelope, - parse_obj_as( - type_=ActivateSyncEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.activate(id, active=active, request_options=request_options) + return _response.data async def cancel( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -2098,64 +1186,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/cancel", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CancelBulkSyncResponseEnvelope, - parse_obj_as( - type_=CancelBulkSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.cancel(id, request_options=request_options) + return _response.data async def start( self, @@ -2208,64 +1240,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/executions", - method="POST", - json={ - "fetch_mode": fetch_mode, - "resync": resync, - "schemas": schemas, - "test": test, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.start( + id, fetch_mode=fetch_mode, resync=resync, schemas=schemas, test=test, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncExecutionEnvelope, - parse_obj_as( - type_=BulkSyncExecutionEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 409: - raise ConflictError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get_status( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -2303,54 +1281,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/status", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncStatusEnvelope, - parse_obj_as( - type_=BulkSyncStatusEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_status(id, request_options=request_options) + return _response.data async def get_source( self, @@ -2395,67 +1327,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/bulksync/source", - method="GET", - params={ - "include_fields": include_fields, - }, - request_options=request_options, + _response = await self._raw_client.get_source( + id, include_fields=include_fields, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncSourceEnvelope, - parse_obj_as( - type_=BulkSyncSourceEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get_destination( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -2493,61 +1368,29 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/bulksync/target", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncDestEnvelope, - parse_obj_as( - type_=BulkSyncDestEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_destination(id, request_options=request_options) + return _response.data + + @property + def executions(self): + if self._executions is None: + from .executions.client import AsyncExecutionsClient # noqa: E402 + + self._executions = AsyncExecutionsClient(client_wrapper=self._client_wrapper) + return self._executions + + @property + def schemas(self): + if self._schemas is None: + from .schemas.client import AsyncSchemasClient # noqa: E402 + + self._schemas = AsyncSchemasClient(client_wrapper=self._client_wrapper) + return self._schemas + + @property + def schedules(self): + if self._schedules is None: + from .schedules.client import AsyncSchedulesClient # noqa: E402 + + self._schedules = AsyncSchedulesClient(client_wrapper=self._client_wrapper) + return self._schedules diff --git a/src/polytomic/bulk_sync/executions/__init__.py b/src/polytomic/bulk_sync/executions/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/bulk_sync/executions/__init__.py +++ b/src/polytomic/bulk_sync/executions/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/bulk_sync/executions/client.py b/src/polytomic/bulk_sync/executions/client.py index 5396342..1de36ce 100644 --- a/src/polytomic/bulk_sync/executions/client.py +++ b/src/polytomic/bulk_sync/executions/client.py @@ -1,31 +1,32 @@ # This file was auto-generated by Fern from our API Definition. -from ...core.client_wrapper import SyncClientWrapper import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.request_options import RequestOptions -from ...types.list_bulk_sync_execution_status_envelope import ListBulkSyncExecutionStatusEnvelope -from ...core.pydantic_utilities import parse_obj_as -from ...errors.unauthorized_error import UnauthorizedError -from ...types.rest_err_response import RestErrResponse -from ...errors.not_found_error import NotFoundError -from ...types.api_error import ApiError as types_api_error_ApiError -from json.decoder import JSONDecodeError -from ...core.api_error import ApiError as core_api_error_ApiError -from ...types.list_bulk_sync_executions_envelope import ListBulkSyncExecutionsEnvelope -from ...core.jsonable_encoder import jsonable_encoder from ...types.bulk_sync_execution_envelope import BulkSyncExecutionEnvelope from ...types.cancel_bulk_sync_response_envelope import CancelBulkSyncResponseEnvelope -from ...errors.forbidden_error import ForbiddenError -from ...errors.internal_server_error import InternalServerError +from ...types.list_bulk_sync_execution_status_envelope import ListBulkSyncExecutionStatusEnvelope +from ...types.list_bulk_sync_executions_envelope import ListBulkSyncExecutionsEnvelope from ...types.v_4_bulk_sync_execution_logs_envelope import V4BulkSyncExecutionLogsEnvelope from ...types.v_4_export_sync_logs_envelope import V4ExportSyncLogsEnvelope -from ...errors.bad_request_error import BadRequestError -from ...core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawExecutionsClient, RawExecutionsClient class ExecutionsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawExecutionsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawExecutionsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawExecutionsClient + """ + return self._raw_client def list_status( self, @@ -68,49 +69,10 @@ def list_status( active=True, ) """ - _response = self._client_wrapper.httpx_client.request( - "api/bulk/syncs/status", - method="GET", - params={ - "all": all_, - "active": active, - "sync_id": sync_id, - }, - request_options=request_options, + _response = self._raw_client.list_status( + all_=all_, active=active, sync_id=sync_id, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListBulkSyncExecutionStatusEnvelope, - parse_obj_as( - type_=ListBulkSyncExecutionStatusEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def list( self, @@ -159,50 +121,15 @@ def list( limit=100, ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/executions", - method="GET", - params={ - "page_token": page_token, - "only_terminal": only_terminal, - "ascending": ascending, - "limit": limit, - }, + _response = self._raw_client.list( + id, + page_token=page_token, + only_terminal=only_terminal, + ascending=ascending, + limit=limit, request_options=request_options, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListBulkSyncExecutionsEnvelope, - parse_obj_as( - type_=ListBulkSyncExecutionsEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get( self, id: str, exec_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -235,44 +162,8 @@ def get( exec_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/executions/{jsonable_encoder(exec_id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncExecutionEnvelope, - parse_obj_as( - type_=BulkSyncExecutionEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(id, exec_id, request_options=request_options) + return _response.data def cancel( self, id: str, exec_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -307,64 +198,8 @@ def cancel( exec_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/executions/{jsonable_encoder(exec_id)}/cancel", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CancelBulkSyncResponseEnvelope, - parse_obj_as( - type_=CancelBulkSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.cancel(id, exec_id, request_options=request_options) + return _response.data def get_logs( self, sync_id: str, execution_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -397,44 +232,8 @@ def get_logs( execution_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(execution_id)}/logs", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4BulkSyncExecutionLogsEnvelope, - parse_obj_as( - type_=V4BulkSyncExecutionLogsEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_logs(sync_id, execution_id, request_options=request_options) + return _response.data def export_logs( self, @@ -475,72 +274,24 @@ def export_logs( execution_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(execution_id)}/logs/export", - method="POST", - params={ - "notify": notify, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4ExportSyncLogsEnvelope, - parse_obj_as( - type_=V4ExportSyncLogsEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.export_logs(sync_id, execution_id, notify=notify, request_options=request_options) + return _response.data class AsyncExecutionsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawExecutionsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawExecutionsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawExecutionsClient + """ + return self._raw_client async def list_status( self, @@ -591,49 +342,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/bulk/syncs/status", - method="GET", - params={ - "all": all_, - "active": active, - "sync_id": sync_id, - }, - request_options=request_options, + _response = await self._raw_client.list_status( + all_=all_, active=active, sync_id=sync_id, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListBulkSyncExecutionStatusEnvelope, - parse_obj_as( - type_=ListBulkSyncExecutionStatusEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def list( self, @@ -690,50 +402,15 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/executions", - method="GET", - params={ - "page_token": page_token, - "only_terminal": only_terminal, - "ascending": ascending, - "limit": limit, - }, + _response = await self._raw_client.list( + id, + page_token=page_token, + only_terminal=only_terminal, + ascending=ascending, + limit=limit, request_options=request_options, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListBulkSyncExecutionsEnvelope, - parse_obj_as( - type_=ListBulkSyncExecutionsEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get( self, id: str, exec_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -774,44 +451,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/executions/{jsonable_encoder(exec_id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncExecutionEnvelope, - parse_obj_as( - type_=BulkSyncExecutionEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(id, exec_id, request_options=request_options) + return _response.data async def cancel( self, id: str, exec_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -854,64 +495,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/executions/{jsonable_encoder(exec_id)}/cancel", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CancelBulkSyncResponseEnvelope, - parse_obj_as( - type_=CancelBulkSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.cancel(id, exec_id, request_options=request_options) + return _response.data async def get_logs( self, sync_id: str, execution_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -952,44 +537,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(execution_id)}/logs", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4BulkSyncExecutionLogsEnvelope, - parse_obj_as( - type_=V4BulkSyncExecutionLogsEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_logs(sync_id, execution_id, request_options=request_options) + return _response.data async def export_logs( self, @@ -1038,64 +587,7 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(execution_id)}/logs/export", - method="POST", - params={ - "notify": notify, - }, - request_options=request_options, + _response = await self._raw_client.export_logs( + sync_id, execution_id, notify=notify, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4ExportSyncLogsEnvelope, - parse_obj_as( - type_=V4ExportSyncLogsEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data diff --git a/src/polytomic/bulk_sync/executions/raw_client.py b/src/polytomic/bulk_sync/executions/raw_client.py new file mode 100644 index 0000000..f9ae749 --- /dev/null +++ b/src/polytomic/bulk_sync/executions/raw_client.py @@ -0,0 +1,1034 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError as core_api_error_ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.parse_error import ParsingError +from ...core.pydantic_utilities import parse_obj_as +from ...core.request_options import RequestOptions +from ...errors.bad_request_error import BadRequestError +from ...errors.forbidden_error import ForbiddenError +from ...errors.internal_server_error import InternalServerError +from ...errors.not_found_error import NotFoundError +from ...errors.unauthorized_error import UnauthorizedError +from ...types.api_error import ApiError as types_api_error_ApiError +from ...types.bulk_sync_execution_envelope import BulkSyncExecutionEnvelope +from ...types.cancel_bulk_sync_response_envelope import CancelBulkSyncResponseEnvelope +from ...types.list_bulk_sync_execution_status_envelope import ListBulkSyncExecutionStatusEnvelope +from ...types.list_bulk_sync_executions_envelope import ListBulkSyncExecutionsEnvelope +from ...types.rest_err_response import RestErrResponse +from ...types.v_4_bulk_sync_execution_logs_envelope import V4BulkSyncExecutionLogsEnvelope +from ...types.v_4_export_sync_logs_envelope import V4ExportSyncLogsEnvelope +from pydantic import ValidationError + + +class RawExecutionsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list_status( + self, + *, + all_: typing.Optional[bool] = None, + active: typing.Optional[bool] = None, + sync_id: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ListBulkSyncExecutionStatusEnvelope]: + """ + Parameters + ---------- + all_ : typing.Optional[bool] + Return the execution status of all syncs in the organization + + active : typing.Optional[bool] + Return the execution status of all active syncs in the organization + + sync_id : typing.Optional[typing.Union[str, typing.Sequence[str]]] + Return the execution status of the specified sync; this may be supplied multiple times. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ListBulkSyncExecutionStatusEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/bulk/syncs/status", + method="GET", + params={ + "all": all_, + "active": active, + "sync_id": sync_id, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListBulkSyncExecutionStatusEnvelope, + parse_obj_as( + type_=ListBulkSyncExecutionStatusEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def list( + self, + id: str, + *, + page_token: typing.Optional[str] = None, + only_terminal: typing.Optional[bool] = None, + ascending: typing.Optional[bool] = None, + limit: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ListBulkSyncExecutionsEnvelope]: + """ + Parameters + ---------- + id : str + + page_token : typing.Optional[str] + + only_terminal : typing.Optional[bool] + + ascending : typing.Optional[bool] + + limit : typing.Optional[int] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ListBulkSyncExecutionsEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/executions", + method="GET", + params={ + "page_token": page_token, + "only_terminal": only_terminal, + "ascending": ascending, + "limit": limit, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListBulkSyncExecutionsEnvelope, + parse_obj_as( + type_=ListBulkSyncExecutionsEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get( + self, id: str, exec_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[BulkSyncExecutionEnvelope]: + """ + Parameters + ---------- + id : str + + exec_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BulkSyncExecutionEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/executions/{jsonable_encoder(exec_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncExecutionEnvelope, + parse_obj_as( + type_=BulkSyncExecutionEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def cancel( + self, id: str, exec_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[CancelBulkSyncResponseEnvelope]: + """ + Parameters + ---------- + id : str + The bulk sync ID. + + exec_id : str + The execution ID to cancel. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CancelBulkSyncResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/executions/{jsonable_encoder(exec_id)}/cancel", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CancelBulkSyncResponseEnvelope, + parse_obj_as( + type_=CancelBulkSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_logs( + self, sync_id: str, execution_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[V4BulkSyncExecutionLogsEnvelope]: + """ + Parameters + ---------- + sync_id : str + + execution_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[V4BulkSyncExecutionLogsEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(execution_id)}/logs", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4BulkSyncExecutionLogsEnvelope, + parse_obj_as( + type_=V4BulkSyncExecutionLogsEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def export_logs( + self, + sync_id: str, + execution_id: str, + *, + notify: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[V4ExportSyncLogsEnvelope]: + """ + Parameters + ---------- + sync_id : str + + execution_id : str + + notify : typing.Optional[bool] + Send a notification to the user when the logs are ready for download. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[V4ExportSyncLogsEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(execution_id)}/logs/export", + method="POST", + params={ + "notify": notify, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4ExportSyncLogsEnvelope, + parse_obj_as( + type_=V4ExportSyncLogsEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawExecutionsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list_status( + self, + *, + all_: typing.Optional[bool] = None, + active: typing.Optional[bool] = None, + sync_id: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ListBulkSyncExecutionStatusEnvelope]: + """ + Parameters + ---------- + all_ : typing.Optional[bool] + Return the execution status of all syncs in the organization + + active : typing.Optional[bool] + Return the execution status of all active syncs in the organization + + sync_id : typing.Optional[typing.Union[str, typing.Sequence[str]]] + Return the execution status of the specified sync; this may be supplied multiple times. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ListBulkSyncExecutionStatusEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/bulk/syncs/status", + method="GET", + params={ + "all": all_, + "active": active, + "sync_id": sync_id, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListBulkSyncExecutionStatusEnvelope, + parse_obj_as( + type_=ListBulkSyncExecutionStatusEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def list( + self, + id: str, + *, + page_token: typing.Optional[str] = None, + only_terminal: typing.Optional[bool] = None, + ascending: typing.Optional[bool] = None, + limit: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ListBulkSyncExecutionsEnvelope]: + """ + Parameters + ---------- + id : str + + page_token : typing.Optional[str] + + only_terminal : typing.Optional[bool] + + ascending : typing.Optional[bool] + + limit : typing.Optional[int] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ListBulkSyncExecutionsEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/executions", + method="GET", + params={ + "page_token": page_token, + "only_terminal": only_terminal, + "ascending": ascending, + "limit": limit, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListBulkSyncExecutionsEnvelope, + parse_obj_as( + type_=ListBulkSyncExecutionsEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, id: str, exec_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[BulkSyncExecutionEnvelope]: + """ + Parameters + ---------- + id : str + + exec_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BulkSyncExecutionEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/executions/{jsonable_encoder(exec_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncExecutionEnvelope, + parse_obj_as( + type_=BulkSyncExecutionEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def cancel( + self, id: str, exec_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[CancelBulkSyncResponseEnvelope]: + """ + Parameters + ---------- + id : str + The bulk sync ID. + + exec_id : str + The execution ID to cancel. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CancelBulkSyncResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/executions/{jsonable_encoder(exec_id)}/cancel", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CancelBulkSyncResponseEnvelope, + parse_obj_as( + type_=CancelBulkSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_logs( + self, sync_id: str, execution_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[V4BulkSyncExecutionLogsEnvelope]: + """ + Parameters + ---------- + sync_id : str + + execution_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[V4BulkSyncExecutionLogsEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(execution_id)}/logs", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4BulkSyncExecutionLogsEnvelope, + parse_obj_as( + type_=V4BulkSyncExecutionLogsEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def export_logs( + self, + sync_id: str, + execution_id: str, + *, + notify: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[V4ExportSyncLogsEnvelope]: + """ + Parameters + ---------- + sync_id : str + + execution_id : str + + notify : typing.Optional[bool] + Send a notification to the user when the logs are ready for download. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[V4ExportSyncLogsEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(execution_id)}/logs/export", + method="POST", + params={ + "notify": notify, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4ExportSyncLogsEnvelope, + parse_obj_as( + type_=V4ExportSyncLogsEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/bulk_sync/raw_client.py b/src/polytomic/bulk_sync/raw_client.py new file mode 100644 index 0000000..00fc437 --- /dev/null +++ b/src/polytomic/bulk_sync/raw_client.py @@ -0,0 +1,2450 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError as core_api_error_ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..core.serialization import convert_and_respect_annotation_metadata +from ..errors.bad_request_error import BadRequestError +from ..errors.conflict_error import ConflictError +from ..errors.forbidden_error import ForbiddenError +from ..errors.internal_server_error import InternalServerError +from ..errors.not_found_error import NotFoundError +from ..errors.unauthorized_error import UnauthorizedError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.activate_sync_envelope import ActivateSyncEnvelope +from ..types.api_error import ApiError as types_api_error_ApiError +from ..types.bulk_discover import BulkDiscover +from ..types.bulk_fetch_mode import BulkFetchMode +from ..types.bulk_normalize_names import BulkNormalizeNames +from ..types.bulk_schedule import BulkSchedule +from ..types.bulk_sync_dest_envelope import BulkSyncDestEnvelope +from ..types.bulk_sync_execution_envelope import BulkSyncExecutionEnvelope +from ..types.bulk_sync_list_envelope import BulkSyncListEnvelope +from ..types.bulk_sync_mode import BulkSyncMode +from ..types.bulk_sync_response_envelope import BulkSyncResponseEnvelope +from ..types.bulk_sync_source_envelope import BulkSyncSourceEnvelope +from ..types.bulk_sync_status_envelope import BulkSyncStatusEnvelope +from ..types.cancel_bulk_sync_response_envelope import CancelBulkSyncResponseEnvelope +from ..types.rest_err_response import RestErrResponse +from .types.v_2_create_bulk_sync_request_schemas_item import V2CreateBulkSyncRequestSchemasItem +from .types.v_2_update_bulk_sync_request_schemas_item import V2UpdateBulkSyncRequestSchemasItem +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawBulkSyncClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, *, active: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[BulkSyncListEnvelope]: + """ + Parameters + ---------- + active : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BulkSyncListEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/bulk/syncs", + method="GET", + params={ + "active": active, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncListEnvelope, + parse_obj_as( + type_=BulkSyncListEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def create( + self, + *, + destination_configuration: typing.Dict[str, typing.Any], + destination_connection_id: str, + name: str, + schedule: BulkSchedule, + source_connection_id: str, + active: typing.Optional[bool] = OMIT, + automatically_add_new_fields: typing.Optional[BulkDiscover] = OMIT, + automatically_add_new_objects: typing.Optional[BulkDiscover] = OMIT, + concurrency_limit: typing.Optional[int] = OMIT, + data_cutoff_timestamp: typing.Optional[dt.datetime] = OMIT, + disable_record_timestamps: typing.Optional[bool] = OMIT, + discover: typing.Optional[bool] = OMIT, + mode: typing.Optional[BulkSyncMode] = OMIT, + normalize_names: typing.Optional[BulkNormalizeNames] = OMIT, + organization_id: typing.Optional[str] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + resync_concurrency_limit: typing.Optional[int] = OMIT, + schemas: typing.Optional[typing.Sequence[V2CreateBulkSyncRequestSchemasItem]] = OMIT, + source_configuration: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[BulkSyncResponseEnvelope]: + """ + Create a new Bulk Sync from a source to a destination (data warehouse, database, or cloud storage bucket like S3). + + Bulk Syncs are used for the ELT pattern (Extract, Load, and Transform), where you want to sync un-transformed data to your data warehouses, databases, or cloud storage buckets like S3. + + All of the functionality described in [the product + documentation](https://docs.polytomic.com/docs/bulk-syncs) is configurable via + the API. + + Sample code examples: + + - [Bulk sync (ELT) from Salesforce to S3](https://apidocs.polytomic.com/guides/code-examples/bulk-sync-elt-from-salesforce-to-s-3) + - [Bulk sync (ELT) from Salesforce to Snowflake](https://apidocs.polytomic.com/guides/code-examples/bulk-sync-elt-from-salesforce-to-snowflake) + - [Bulk sync (ELT) from HubSpot to PostgreSQL](https://apidocs.polytomic.com/guides/code-examples/bulk-sync-elt-from-hub-spot-to-postgre-sql) + + ## Connection specific configuration + + The `destination_configuration` is integration-specific configuration for the + selected bulk sync destination. This includes settings such as the output schema + and is required when creating a new sync. + + The `source_configuration` is optional. It allows configuration for how + Polytomic reads data from the source connection. This will not be available for + integrations that do not support additional configuration. + + Consult the [connection configurations](https://apidocs.polytomic.com/2024-02-08/guides/configuring-your-connections/overview) + to see configurations for particular integrations (for example, [here](https://apidocs.polytomic.com/2024-02-08/guides/configuring-your-connections/connections/postgre-sql#source-1) is the available source configuration for the PostgreSQL bulk sync source). + + Parameters + ---------- + destination_configuration : typing.Dict[str, typing.Any] + + destination_connection_id : str + + name : str + + schedule : BulkSchedule + + source_connection_id : str + + active : typing.Optional[bool] + + automatically_add_new_fields : typing.Optional[BulkDiscover] + + automatically_add_new_objects : typing.Optional[BulkDiscover] + + concurrency_limit : typing.Optional[int] + Override the default concurrency limit for this sync. + + data_cutoff_timestamp : typing.Optional[dt.datetime] + + disable_record_timestamps : typing.Optional[bool] + + discover : typing.Optional[bool] + DEPRECATED: Use automatically_add_new_objects/automatically_add_new_fields instead + + mode : typing.Optional[BulkSyncMode] + + normalize_names : typing.Optional[BulkNormalizeNames] + + organization_id : typing.Optional[str] + + policies : typing.Optional[typing.Sequence[str]] + + resync_concurrency_limit : typing.Optional[int] + Override the default resync concurrency limit for this sync. + + schemas : typing.Optional[typing.Sequence[V2CreateBulkSyncRequestSchemasItem]] + List of schemas to sync; if omitted, all schemas will be selected for syncing. + + source_configuration : typing.Optional[typing.Dict[str, typing.Any]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BulkSyncResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/bulk/syncs", + method="POST", + json={ + "active": active, + "automatically_add_new_fields": automatically_add_new_fields, + "automatically_add_new_objects": automatically_add_new_objects, + "concurrency_limit": concurrency_limit, + "data_cutoff_timestamp": data_cutoff_timestamp, + "destination_configuration": destination_configuration, + "destination_connection_id": destination_connection_id, + "disable_record_timestamps": disable_record_timestamps, + "discover": discover, + "mode": mode, + "name": name, + "normalize_names": normalize_names, + "organization_id": organization_id, + "policies": policies, + "resync_concurrency_limit": resync_concurrency_limit, + "schedule": convert_and_respect_annotation_metadata( + object_=schedule, annotation=BulkSchedule, direction="write" + ), + "schemas": convert_and_respect_annotation_metadata( + object_=schemas, + annotation=typing.Optional[typing.Sequence[V2CreateBulkSyncRequestSchemasItem]], + direction="write", + ), + "source_configuration": source_configuration, + "source_connection_id": source_connection_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncResponseEnvelope, + parse_obj_as( + type_=BulkSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get( + self, + id: str, + *, + refresh_schemas: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[BulkSyncResponseEnvelope]: + """ + Parameters + ---------- + id : str + + refresh_schemas : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BulkSyncResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}", + method="GET", + params={ + "refresh_schemas": refresh_schemas, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncResponseEnvelope, + parse_obj_as( + type_=BulkSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def update( + self, + id: str, + *, + destination_configuration: typing.Dict[str, typing.Any], + destination_connection_id: str, + name: str, + schedule: BulkSchedule, + source_connection_id: str, + active: typing.Optional[bool] = OMIT, + automatically_add_new_fields: typing.Optional[BulkDiscover] = OMIT, + automatically_add_new_objects: typing.Optional[BulkDiscover] = OMIT, + concurrency_limit: typing.Optional[int] = OMIT, + data_cutoff_timestamp: typing.Optional[dt.datetime] = OMIT, + disable_record_timestamps: typing.Optional[bool] = OMIT, + discover: typing.Optional[bool] = OMIT, + mode: typing.Optional[BulkSyncMode] = OMIT, + normalize_names: typing.Optional[BulkNormalizeNames] = OMIT, + organization_id: typing.Optional[str] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + resync_concurrency_limit: typing.Optional[int] = OMIT, + schemas: typing.Optional[typing.Sequence[V2UpdateBulkSyncRequestSchemasItem]] = OMIT, + source_configuration: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[BulkSyncResponseEnvelope]: + """ + > 📘 Updating schemas + > + > Schema updates can be performed using the [Update Bulk Sync Schemas](https://apidocs.polytomic.com/api-reference/bulk-sync/schemas/patch) endpoint. + + Parameters + ---------- + id : str + + destination_configuration : typing.Dict[str, typing.Any] + + destination_connection_id : str + + name : str + + schedule : BulkSchedule + + source_connection_id : str + + active : typing.Optional[bool] + + automatically_add_new_fields : typing.Optional[BulkDiscover] + + automatically_add_new_objects : typing.Optional[BulkDiscover] + + concurrency_limit : typing.Optional[int] + Override the default concurrency limit for this sync. + + data_cutoff_timestamp : typing.Optional[dt.datetime] + + disable_record_timestamps : typing.Optional[bool] + + discover : typing.Optional[bool] + DEPRECATED: Use automatically_add_new_objects/automatically_add_new_fields instead + + mode : typing.Optional[BulkSyncMode] + + normalize_names : typing.Optional[BulkNormalizeNames] + + organization_id : typing.Optional[str] + + policies : typing.Optional[typing.Sequence[str]] + + resync_concurrency_limit : typing.Optional[int] + Override the default resync concurrency limit for this sync. + + schemas : typing.Optional[typing.Sequence[V2UpdateBulkSyncRequestSchemasItem]] + List of schemas to sync; if omitted, all schemas will be selected for syncing. + + source_configuration : typing.Optional[typing.Dict[str, typing.Any]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BulkSyncResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}", + method="PUT", + json={ + "active": active, + "automatically_add_new_fields": automatically_add_new_fields, + "automatically_add_new_objects": automatically_add_new_objects, + "concurrency_limit": concurrency_limit, + "data_cutoff_timestamp": data_cutoff_timestamp, + "destination_configuration": destination_configuration, + "destination_connection_id": destination_connection_id, + "disable_record_timestamps": disable_record_timestamps, + "discover": discover, + "mode": mode, + "name": name, + "normalize_names": normalize_names, + "organization_id": organization_id, + "policies": policies, + "resync_concurrency_limit": resync_concurrency_limit, + "schedule": convert_and_respect_annotation_metadata( + object_=schedule, annotation=BulkSchedule, direction="write" + ), + "schemas": convert_and_respect_annotation_metadata( + object_=schemas, + annotation=typing.Optional[typing.Sequence[V2UpdateBulkSyncRequestSchemasItem]], + direction="write", + ), + "source_configuration": source_configuration, + "source_connection_id": source_connection_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncResponseEnvelope, + parse_obj_as( + type_=BulkSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def remove( + self, + id: str, + *, + refresh_schemas: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[None]: + """ + Parameters + ---------- + id : str + + refresh_schemas : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}", + method="DELETE", + params={ + "refresh_schemas": refresh_schemas, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def activate( + self, id: str, *, active: bool, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ActivateSyncEnvelope]: + """ + Parameters + ---------- + id : str + + active : bool + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ActivateSyncEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/activate", + method="POST", + json={ + "active": active, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ActivateSyncEnvelope, + parse_obj_as( + type_=ActivateSyncEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def cancel( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[CancelBulkSyncResponseEnvelope]: + """ + Parameters + ---------- + id : str + The active execution of this bulk sync ID will be cancelled. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CancelBulkSyncResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/cancel", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CancelBulkSyncResponseEnvelope, + parse_obj_as( + type_=CancelBulkSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def start( + self, + id: str, + *, + fetch_mode: typing.Optional[BulkFetchMode] = OMIT, + resync: typing.Optional[bool] = OMIT, + schemas: typing.Optional[typing.Sequence[str]] = OMIT, + test: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[BulkSyncExecutionEnvelope]: + """ + Parameters + ---------- + id : str + + fetch_mode : typing.Optional[BulkFetchMode] + + resync : typing.Optional[bool] + + schemas : typing.Optional[typing.Sequence[str]] + + test : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BulkSyncExecutionEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/executions", + method="POST", + json={ + "fetch_mode": fetch_mode, + "resync": resync, + "schemas": schemas, + "test": test, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncExecutionEnvelope, + parse_obj_as( + type_=BulkSyncExecutionEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_status( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[BulkSyncStatusEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BulkSyncStatusEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/status", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncStatusEnvelope, + parse_obj_as( + type_=BulkSyncStatusEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_source( + self, + id: str, + *, + include_fields: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[BulkSyncSourceEnvelope]: + """ + Parameters + ---------- + id : str + + include_fields : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BulkSyncSourceEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/bulksync/source", + method="GET", + params={ + "include_fields": include_fields, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncSourceEnvelope, + parse_obj_as( + type_=BulkSyncSourceEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_destination( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[BulkSyncDestEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BulkSyncDestEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/bulksync/target", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncDestEnvelope, + parse_obj_as( + type_=BulkSyncDestEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawBulkSyncClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, *, active: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[BulkSyncListEnvelope]: + """ + Parameters + ---------- + active : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BulkSyncListEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/bulk/syncs", + method="GET", + params={ + "active": active, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncListEnvelope, + parse_obj_as( + type_=BulkSyncListEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def create( + self, + *, + destination_configuration: typing.Dict[str, typing.Any], + destination_connection_id: str, + name: str, + schedule: BulkSchedule, + source_connection_id: str, + active: typing.Optional[bool] = OMIT, + automatically_add_new_fields: typing.Optional[BulkDiscover] = OMIT, + automatically_add_new_objects: typing.Optional[BulkDiscover] = OMIT, + concurrency_limit: typing.Optional[int] = OMIT, + data_cutoff_timestamp: typing.Optional[dt.datetime] = OMIT, + disable_record_timestamps: typing.Optional[bool] = OMIT, + discover: typing.Optional[bool] = OMIT, + mode: typing.Optional[BulkSyncMode] = OMIT, + normalize_names: typing.Optional[BulkNormalizeNames] = OMIT, + organization_id: typing.Optional[str] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + resync_concurrency_limit: typing.Optional[int] = OMIT, + schemas: typing.Optional[typing.Sequence[V2CreateBulkSyncRequestSchemasItem]] = OMIT, + source_configuration: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[BulkSyncResponseEnvelope]: + """ + Create a new Bulk Sync from a source to a destination (data warehouse, database, or cloud storage bucket like S3). + + Bulk Syncs are used for the ELT pattern (Extract, Load, and Transform), where you want to sync un-transformed data to your data warehouses, databases, or cloud storage buckets like S3. + + All of the functionality described in [the product + documentation](https://docs.polytomic.com/docs/bulk-syncs) is configurable via + the API. + + Sample code examples: + + - [Bulk sync (ELT) from Salesforce to S3](https://apidocs.polytomic.com/guides/code-examples/bulk-sync-elt-from-salesforce-to-s-3) + - [Bulk sync (ELT) from Salesforce to Snowflake](https://apidocs.polytomic.com/guides/code-examples/bulk-sync-elt-from-salesforce-to-snowflake) + - [Bulk sync (ELT) from HubSpot to PostgreSQL](https://apidocs.polytomic.com/guides/code-examples/bulk-sync-elt-from-hub-spot-to-postgre-sql) + + ## Connection specific configuration + + The `destination_configuration` is integration-specific configuration for the + selected bulk sync destination. This includes settings such as the output schema + and is required when creating a new sync. + + The `source_configuration` is optional. It allows configuration for how + Polytomic reads data from the source connection. This will not be available for + integrations that do not support additional configuration. + + Consult the [connection configurations](https://apidocs.polytomic.com/2024-02-08/guides/configuring-your-connections/overview) + to see configurations for particular integrations (for example, [here](https://apidocs.polytomic.com/2024-02-08/guides/configuring-your-connections/connections/postgre-sql#source-1) is the available source configuration for the PostgreSQL bulk sync source). + + Parameters + ---------- + destination_configuration : typing.Dict[str, typing.Any] + + destination_connection_id : str + + name : str + + schedule : BulkSchedule + + source_connection_id : str + + active : typing.Optional[bool] + + automatically_add_new_fields : typing.Optional[BulkDiscover] + + automatically_add_new_objects : typing.Optional[BulkDiscover] + + concurrency_limit : typing.Optional[int] + Override the default concurrency limit for this sync. + + data_cutoff_timestamp : typing.Optional[dt.datetime] + + disable_record_timestamps : typing.Optional[bool] + + discover : typing.Optional[bool] + DEPRECATED: Use automatically_add_new_objects/automatically_add_new_fields instead + + mode : typing.Optional[BulkSyncMode] + + normalize_names : typing.Optional[BulkNormalizeNames] + + organization_id : typing.Optional[str] + + policies : typing.Optional[typing.Sequence[str]] + + resync_concurrency_limit : typing.Optional[int] + Override the default resync concurrency limit for this sync. + + schemas : typing.Optional[typing.Sequence[V2CreateBulkSyncRequestSchemasItem]] + List of schemas to sync; if omitted, all schemas will be selected for syncing. + + source_configuration : typing.Optional[typing.Dict[str, typing.Any]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BulkSyncResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/bulk/syncs", + method="POST", + json={ + "active": active, + "automatically_add_new_fields": automatically_add_new_fields, + "automatically_add_new_objects": automatically_add_new_objects, + "concurrency_limit": concurrency_limit, + "data_cutoff_timestamp": data_cutoff_timestamp, + "destination_configuration": destination_configuration, + "destination_connection_id": destination_connection_id, + "disable_record_timestamps": disable_record_timestamps, + "discover": discover, + "mode": mode, + "name": name, + "normalize_names": normalize_names, + "organization_id": organization_id, + "policies": policies, + "resync_concurrency_limit": resync_concurrency_limit, + "schedule": convert_and_respect_annotation_metadata( + object_=schedule, annotation=BulkSchedule, direction="write" + ), + "schemas": convert_and_respect_annotation_metadata( + object_=schemas, + annotation=typing.Optional[typing.Sequence[V2CreateBulkSyncRequestSchemasItem]], + direction="write", + ), + "source_configuration": source_configuration, + "source_connection_id": source_connection_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncResponseEnvelope, + parse_obj_as( + type_=BulkSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, + id: str, + *, + refresh_schemas: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[BulkSyncResponseEnvelope]: + """ + Parameters + ---------- + id : str + + refresh_schemas : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BulkSyncResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}", + method="GET", + params={ + "refresh_schemas": refresh_schemas, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncResponseEnvelope, + parse_obj_as( + type_=BulkSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def update( + self, + id: str, + *, + destination_configuration: typing.Dict[str, typing.Any], + destination_connection_id: str, + name: str, + schedule: BulkSchedule, + source_connection_id: str, + active: typing.Optional[bool] = OMIT, + automatically_add_new_fields: typing.Optional[BulkDiscover] = OMIT, + automatically_add_new_objects: typing.Optional[BulkDiscover] = OMIT, + concurrency_limit: typing.Optional[int] = OMIT, + data_cutoff_timestamp: typing.Optional[dt.datetime] = OMIT, + disable_record_timestamps: typing.Optional[bool] = OMIT, + discover: typing.Optional[bool] = OMIT, + mode: typing.Optional[BulkSyncMode] = OMIT, + normalize_names: typing.Optional[BulkNormalizeNames] = OMIT, + organization_id: typing.Optional[str] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + resync_concurrency_limit: typing.Optional[int] = OMIT, + schemas: typing.Optional[typing.Sequence[V2UpdateBulkSyncRequestSchemasItem]] = OMIT, + source_configuration: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[BulkSyncResponseEnvelope]: + """ + > 📘 Updating schemas + > + > Schema updates can be performed using the [Update Bulk Sync Schemas](https://apidocs.polytomic.com/api-reference/bulk-sync/schemas/patch) endpoint. + + Parameters + ---------- + id : str + + destination_configuration : typing.Dict[str, typing.Any] + + destination_connection_id : str + + name : str + + schedule : BulkSchedule + + source_connection_id : str + + active : typing.Optional[bool] + + automatically_add_new_fields : typing.Optional[BulkDiscover] + + automatically_add_new_objects : typing.Optional[BulkDiscover] + + concurrency_limit : typing.Optional[int] + Override the default concurrency limit for this sync. + + data_cutoff_timestamp : typing.Optional[dt.datetime] + + disable_record_timestamps : typing.Optional[bool] + + discover : typing.Optional[bool] + DEPRECATED: Use automatically_add_new_objects/automatically_add_new_fields instead + + mode : typing.Optional[BulkSyncMode] + + normalize_names : typing.Optional[BulkNormalizeNames] + + organization_id : typing.Optional[str] + + policies : typing.Optional[typing.Sequence[str]] + + resync_concurrency_limit : typing.Optional[int] + Override the default resync concurrency limit for this sync. + + schemas : typing.Optional[typing.Sequence[V2UpdateBulkSyncRequestSchemasItem]] + List of schemas to sync; if omitted, all schemas will be selected for syncing. + + source_configuration : typing.Optional[typing.Dict[str, typing.Any]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BulkSyncResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}", + method="PUT", + json={ + "active": active, + "automatically_add_new_fields": automatically_add_new_fields, + "automatically_add_new_objects": automatically_add_new_objects, + "concurrency_limit": concurrency_limit, + "data_cutoff_timestamp": data_cutoff_timestamp, + "destination_configuration": destination_configuration, + "destination_connection_id": destination_connection_id, + "disable_record_timestamps": disable_record_timestamps, + "discover": discover, + "mode": mode, + "name": name, + "normalize_names": normalize_names, + "organization_id": organization_id, + "policies": policies, + "resync_concurrency_limit": resync_concurrency_limit, + "schedule": convert_and_respect_annotation_metadata( + object_=schedule, annotation=BulkSchedule, direction="write" + ), + "schemas": convert_and_respect_annotation_metadata( + object_=schemas, + annotation=typing.Optional[typing.Sequence[V2UpdateBulkSyncRequestSchemasItem]], + direction="write", + ), + "source_configuration": source_configuration, + "source_connection_id": source_connection_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncResponseEnvelope, + parse_obj_as( + type_=BulkSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def remove( + self, + id: str, + *, + refresh_schemas: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + id : str + + refresh_schemas : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}", + method="DELETE", + params={ + "refresh_schemas": refresh_schemas, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def activate( + self, id: str, *, active: bool, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ActivateSyncEnvelope]: + """ + Parameters + ---------- + id : str + + active : bool + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ActivateSyncEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/activate", + method="POST", + json={ + "active": active, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ActivateSyncEnvelope, + parse_obj_as( + type_=ActivateSyncEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def cancel( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[CancelBulkSyncResponseEnvelope]: + """ + Parameters + ---------- + id : str + The active execution of this bulk sync ID will be cancelled. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CancelBulkSyncResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/cancel", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CancelBulkSyncResponseEnvelope, + parse_obj_as( + type_=CancelBulkSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def start( + self, + id: str, + *, + fetch_mode: typing.Optional[BulkFetchMode] = OMIT, + resync: typing.Optional[bool] = OMIT, + schemas: typing.Optional[typing.Sequence[str]] = OMIT, + test: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[BulkSyncExecutionEnvelope]: + """ + Parameters + ---------- + id : str + + fetch_mode : typing.Optional[BulkFetchMode] + + resync : typing.Optional[bool] + + schemas : typing.Optional[typing.Sequence[str]] + + test : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BulkSyncExecutionEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/executions", + method="POST", + json={ + "fetch_mode": fetch_mode, + "resync": resync, + "schemas": schemas, + "test": test, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncExecutionEnvelope, + parse_obj_as( + type_=BulkSyncExecutionEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_status( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[BulkSyncStatusEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BulkSyncStatusEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/status", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncStatusEnvelope, + parse_obj_as( + type_=BulkSyncStatusEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_source( + self, + id: str, + *, + include_fields: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[BulkSyncSourceEnvelope]: + """ + Parameters + ---------- + id : str + + include_fields : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BulkSyncSourceEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/bulksync/source", + method="GET", + params={ + "include_fields": include_fields, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncSourceEnvelope, + parse_obj_as( + type_=BulkSyncSourceEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_destination( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[BulkSyncDestEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BulkSyncDestEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/bulksync/target", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncDestEnvelope, + parse_obj_as( + type_=BulkSyncDestEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/bulk_sync/schedules/__init__.py b/src/polytomic/bulk_sync/schedules/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/bulk_sync/schedules/__init__.py +++ b/src/polytomic/bulk_sync/schedules/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/bulk_sync/schedules/client.py b/src/polytomic/bulk_sync/schedules/client.py index 2d941ad..c4df37c 100644 --- a/src/polytomic/bulk_sync/schedules/client.py +++ b/src/polytomic/bulk_sync/schedules/client.py @@ -1,24 +1,13 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ...core.client_wrapper import SyncClientWrapper + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.request_options import RequestOptions +from ...types.schedule_envelope import ScheduleEnvelope from ...types.schedules_envelope import SchedulesEnvelope -from ...core.jsonable_encoder import jsonable_encoder -from ...core.pydantic_utilities import parse_obj_as -from ...errors.unauthorized_error import UnauthorizedError -from ...types.rest_err_response import RestErrResponse -from ...errors.forbidden_error import ForbiddenError -from ...types.api_error import ApiError as types_api_error_ApiError -from ...errors.not_found_error import NotFoundError -from ...errors.internal_server_error import InternalServerError -from json.decoder import JSONDecodeError -from ...core.api_error import ApiError as core_api_error_ApiError from ...types.v_4_bulk_sync_schedule_api import V4BulkSyncScheduleApi -from ...types.schedule_envelope import ScheduleEnvelope -from ...core.serialization import convert_and_respect_annotation_metadata -from ...errors.bad_request_error import BadRequestError -from ...core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawSchedulesClient, RawSchedulesClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -26,7 +15,18 @@ class SchedulesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawSchedulesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSchedulesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSchedulesClient + """ + return self._raw_client def list(self, sync_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> SchedulesEnvelope: """ @@ -54,64 +54,8 @@ def list(self, sync_id: str, *, request_options: typing.Optional[RequestOptions] sync_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SchedulesEnvelope, - parse_obj_as( - type_=SchedulesEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.list(sync_id, request_options=request_options) + return _response.data def create( self, sync_id: str, *, schedule: V4BulkSyncScheduleApi, request_options: typing.Optional[RequestOptions] = None @@ -146,83 +90,8 @@ def create( ), ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules", - method="POST", - json={ - "schedule": convert_and_respect_annotation_metadata( - object_=schedule, annotation=V4BulkSyncScheduleApi, direction="write" - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ScheduleEnvelope, - parse_obj_as( - type_=ScheduleEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.create(sync_id, schedule=schedule, request_options=request_options) + return _response.data def get( self, sync_id: str, schedule_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -255,64 +124,8 @@ def get( schedule_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules/{jsonable_encoder(schedule_id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ScheduleEnvelope, - parse_obj_as( - type_=ScheduleEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(sync_id, schedule_id, request_options=request_options) + return _response.data def update( self, @@ -355,83 +168,8 @@ def update( ), ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules/{jsonable_encoder(schedule_id)}", - method="PUT", - json={ - "schedule": convert_and_respect_annotation_metadata( - object_=schedule, annotation=V4BulkSyncScheduleApi, direction="write" - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ScheduleEnvelope, - parse_obj_as( - type_=ScheduleEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.update(sync_id, schedule_id, schedule=schedule, request_options=request_options) + return _response.data def delete( self, sync_id: str, schedule_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -463,63 +201,24 @@ def delete( schedule_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules/{jsonable_encoder(schedule_id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.delete(sync_id, schedule_id, request_options=request_options) + return _response.data class AsyncSchedulesClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawSchedulesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSchedulesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSchedulesClient + """ + return self._raw_client async def list(self, sync_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> SchedulesEnvelope: """ @@ -555,64 +254,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SchedulesEnvelope, - parse_obj_as( - type_=SchedulesEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.list(sync_id, request_options=request_options) + return _response.data async def create( self, sync_id: str, *, schedule: V4BulkSyncScheduleApi, request_options: typing.Optional[RequestOptions] = None @@ -655,83 +298,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules", - method="POST", - json={ - "schedule": convert_and_respect_annotation_metadata( - object_=schedule, annotation=V4BulkSyncScheduleApi, direction="write" - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ScheduleEnvelope, - parse_obj_as( - type_=ScheduleEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.create(sync_id, schedule=schedule, request_options=request_options) + return _response.data async def get( self, sync_id: str, schedule_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -772,64 +340,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules/{jsonable_encoder(schedule_id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ScheduleEnvelope, - parse_obj_as( - type_=ScheduleEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(sync_id, schedule_id, request_options=request_options) + return _response.data async def update( self, @@ -880,83 +392,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules/{jsonable_encoder(schedule_id)}", - method="PUT", - json={ - "schedule": convert_and_respect_annotation_metadata( - object_=schedule, annotation=V4BulkSyncScheduleApi, direction="write" - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.update( + sync_id, schedule_id, schedule=schedule, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ScheduleEnvelope, - parse_obj_as( - type_=ScheduleEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def delete( self, sync_id: str, schedule_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -996,55 +435,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules/{jsonable_encoder(schedule_id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.delete(sync_id, schedule_id, request_options=request_options) + return _response.data diff --git a/src/polytomic/bulk_sync/schedules/raw_client.py b/src/polytomic/bulk_sync/schedules/raw_client.py new file mode 100644 index 0000000..23dea2f --- /dev/null +++ b/src/polytomic/bulk_sync/schedules/raw_client.py @@ -0,0 +1,1011 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError as core_api_error_ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.parse_error import ParsingError +from ...core.pydantic_utilities import parse_obj_as +from ...core.request_options import RequestOptions +from ...core.serialization import convert_and_respect_annotation_metadata +from ...errors.bad_request_error import BadRequestError +from ...errors.forbidden_error import ForbiddenError +from ...errors.internal_server_error import InternalServerError +from ...errors.not_found_error import NotFoundError +from ...errors.unauthorized_error import UnauthorizedError +from ...types.api_error import ApiError as types_api_error_ApiError +from ...types.rest_err_response import RestErrResponse +from ...types.schedule_envelope import ScheduleEnvelope +from ...types.schedules_envelope import SchedulesEnvelope +from ...types.v_4_bulk_sync_schedule_api import V4BulkSyncScheduleApi +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawSchedulesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, sync_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[SchedulesEnvelope]: + """ + Parameters + ---------- + sync_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SchedulesEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SchedulesEnvelope, + parse_obj_as( + type_=SchedulesEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def create( + self, sync_id: str, *, schedule: V4BulkSyncScheduleApi, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ScheduleEnvelope]: + """ + Parameters + ---------- + sync_id : str + + schedule : V4BulkSyncScheduleApi + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ScheduleEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules", + method="POST", + json={ + "schedule": convert_and_respect_annotation_metadata( + object_=schedule, annotation=V4BulkSyncScheduleApi, direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ScheduleEnvelope, + parse_obj_as( + type_=ScheduleEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get( + self, sync_id: str, schedule_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ScheduleEnvelope]: + """ + Parameters + ---------- + sync_id : str + + schedule_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ScheduleEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules/{jsonable_encoder(schedule_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ScheduleEnvelope, + parse_obj_as( + type_=ScheduleEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def update( + self, + sync_id: str, + schedule_id: str, + *, + schedule: V4BulkSyncScheduleApi, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ScheduleEnvelope]: + """ + Parameters + ---------- + sync_id : str + + schedule_id : str + + schedule : V4BulkSyncScheduleApi + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ScheduleEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules/{jsonable_encoder(schedule_id)}", + method="PUT", + json={ + "schedule": convert_and_respect_annotation_metadata( + object_=schedule, annotation=V4BulkSyncScheduleApi, direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ScheduleEnvelope, + parse_obj_as( + type_=ScheduleEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def delete( + self, sync_id: str, schedule_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[None]: + """ + Parameters + ---------- + sync_id : str + + schedule_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules/{jsonable_encoder(schedule_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawSchedulesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, sync_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[SchedulesEnvelope]: + """ + Parameters + ---------- + sync_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SchedulesEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SchedulesEnvelope, + parse_obj_as( + type_=SchedulesEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def create( + self, sync_id: str, *, schedule: V4BulkSyncScheduleApi, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ScheduleEnvelope]: + """ + Parameters + ---------- + sync_id : str + + schedule : V4BulkSyncScheduleApi + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ScheduleEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules", + method="POST", + json={ + "schedule": convert_and_respect_annotation_metadata( + object_=schedule, annotation=V4BulkSyncScheduleApi, direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ScheduleEnvelope, + parse_obj_as( + type_=ScheduleEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, sync_id: str, schedule_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ScheduleEnvelope]: + """ + Parameters + ---------- + sync_id : str + + schedule_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ScheduleEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules/{jsonable_encoder(schedule_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ScheduleEnvelope, + parse_obj_as( + type_=ScheduleEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def update( + self, + sync_id: str, + schedule_id: str, + *, + schedule: V4BulkSyncScheduleApi, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ScheduleEnvelope]: + """ + Parameters + ---------- + sync_id : str + + schedule_id : str + + schedule : V4BulkSyncScheduleApi + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ScheduleEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules/{jsonable_encoder(schedule_id)}", + method="PUT", + json={ + "schedule": convert_and_respect_annotation_metadata( + object_=schedule, annotation=V4BulkSyncScheduleApi, direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ScheduleEnvelope, + parse_obj_as( + type_=ScheduleEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def delete( + self, sync_id: str, schedule_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + sync_id : str + + schedule_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(sync_id)}/schedules/{jsonable_encoder(schedule_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/bulk_sync/schemas/__init__.py b/src/polytomic/bulk_sync/schemas/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/bulk_sync/schemas/__init__.py +++ b/src/polytomic/bulk_sync/schemas/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/bulk_sync/schemas/client.py b/src/polytomic/bulk_sync/schemas/client.py index ae15878..c701004 100644 --- a/src/polytomic/bulk_sync/schemas/client.py +++ b/src/polytomic/bulk_sync/schemas/client.py @@ -1,28 +1,17 @@ # This file was auto-generated by Fern from our API Definition. +import datetime as dt import typing -from ...core.client_wrapper import SyncClientWrapper + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.request_options import RequestOptions -from ...types.list_bulk_schema import ListBulkSchema -from ...core.jsonable_encoder import jsonable_encoder -from ...core.pydantic_utilities import parse_obj_as -from ...errors.unauthorized_error import UnauthorizedError -from ...types.rest_err_response import RestErrResponse -from ...errors.not_found_error import NotFoundError -from ...types.api_error import ApiError as types_api_error_ApiError -from json.decoder import JSONDecodeError -from ...core.api_error import ApiError as core_api_error_ApiError +from ...types.bulk_filter_2 import BulkFilter2 from ...types.bulk_schema import BulkSchema -from ...core.serialization import convert_and_respect_annotation_metadata -from ...errors.bad_request_error import BadRequestError -from ...errors.forbidden_error import ForbiddenError -from ...errors.internal_server_error import InternalServerError from ...types.bulk_schema_envelope import BulkSchemaEnvelope -import datetime as dt -from ...types.update_bulk_field import UpdateBulkField -from ...types.bulk_filter import BulkFilter from ...types.cancel_bulk_sync_response_envelope import CancelBulkSyncResponseEnvelope -from ...core.client_wrapper import AsyncClientWrapper +from ...types.list_bulk_schema import ListBulkSchema +from ...types.update_bulk_field import UpdateBulkField +from .raw_client import AsyncRawSchemasClient, RawSchemasClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -30,13 +19,24 @@ class SchemasClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawSchemasClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSchemasClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSchemasClient + """ + return self._raw_client def list( self, id: str, *, - filters: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None, + filters: typing.Optional[typing.Dict[str, str]] = None, request_options: typing.Optional[RequestOptions] = None, ) -> ListBulkSchema: """ @@ -44,7 +44,7 @@ def list( ---------- id : str - filters : typing.Optional[typing.Dict[str, typing.Optional[str]]] + filters : typing.Optional[typing.Dict[str, str]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -66,47 +66,8 @@ def list( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/schemas", - method="GET", - params={ - "filters": filters, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListBulkSchema, - parse_obj_as( - type_=ListBulkSchema, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.list(id, filters=filters, request_options=request_options) + return _response.data def patch( self, @@ -142,83 +103,8 @@ def patch( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/schemas", - method="PATCH", - json={ - "schemas": convert_and_respect_annotation_metadata( - object_=schemas, annotation=typing.Sequence[BulkSchema], direction="write" - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListBulkSchema, - parse_obj_as( - type_=ListBulkSchema, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.patch(id, schemas=schemas, request_options=request_options) + return _response.data def get( self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -251,44 +137,8 @@ def get( schema_id="Contact", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSchemaEnvelope, - parse_obj_as( - type_=BulkSchemaEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(id, schema_id, request_options=request_options) + return _response.data def update( self, @@ -299,7 +149,7 @@ def update( disable_data_cutoff: typing.Optional[bool] = OMIT, enabled: typing.Optional[bool] = OMIT, fields: typing.Optional[typing.Sequence[UpdateBulkField]] = OMIT, - filters: typing.Optional[typing.Sequence[BulkFilter]] = OMIT, + filters: typing.Optional[typing.Sequence[BulkFilter2]] = OMIT, partition_key: typing.Optional[str] = OMIT, tracking_field: typing.Optional[str] = OMIT, user_output_name: typing.Optional[str] = OMIT, @@ -320,7 +170,7 @@ def update( fields : typing.Optional[typing.Sequence[UpdateBulkField]] - filters : typing.Optional[typing.Sequence[BulkFilter]] + filters : typing.Optional[typing.Sequence[BulkFilter2]] partition_key : typing.Optional[str] @@ -349,82 +199,20 @@ def update( schema_id="contact", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}", - method="PUT", - json={ - "data_cutoff_timestamp": data_cutoff_timestamp, - "disable_data_cutoff": disable_data_cutoff, - "enabled": enabled, - "fields": convert_and_respect_annotation_metadata( - object_=fields, annotation=typing.Sequence[UpdateBulkField], direction="write" - ), - "filters": convert_and_respect_annotation_metadata( - object_=filters, annotation=typing.Sequence[BulkFilter], direction="write" - ), - "partition_key": partition_key, - "tracking_field": tracking_field, - "user_output_name": user_output_name, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.update( + id, + schema_id, + data_cutoff_timestamp=data_cutoff_timestamp, + disable_data_cutoff=disable_data_cutoff, + enabled=enabled, + fields=fields, + filters=filters, + partition_key=partition_key, + tracking_field=tracking_field, + user_output_name=user_output_name, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSchemaEnvelope, - parse_obj_as( - type_=BulkSchemaEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def cancel( self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -459,75 +247,30 @@ def cancel( schema_id="schema_id", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}/cancel", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CancelBulkSyncResponseEnvelope, - parse_obj_as( - type_=CancelBulkSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.cancel(id, schema_id, request_options=request_options) + return _response.data class AsyncSchemasClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawSchemasClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSchemasClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSchemasClient + """ + return self._raw_client async def list( self, id: str, *, - filters: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None, + filters: typing.Optional[typing.Dict[str, str]] = None, request_options: typing.Optional[RequestOptions] = None, ) -> ListBulkSchema: """ @@ -535,7 +278,7 @@ async def list( ---------- id : str - filters : typing.Optional[typing.Dict[str, typing.Optional[str]]] + filters : typing.Optional[typing.Dict[str, str]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -565,47 +308,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/schemas", - method="GET", - params={ - "filters": filters, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListBulkSchema, - parse_obj_as( - type_=ListBulkSchema, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.list(id, filters=filters, request_options=request_options) + return _response.data async def patch( self, @@ -649,83 +353,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/schemas", - method="PATCH", - json={ - "schemas": convert_and_respect_annotation_metadata( - object_=schemas, annotation=typing.Sequence[BulkSchema], direction="write" - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListBulkSchema, - parse_obj_as( - type_=ListBulkSchema, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.patch(id, schemas=schemas, request_options=request_options) + return _response.data async def get( self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -766,44 +395,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSchemaEnvelope, - parse_obj_as( - type_=BulkSchemaEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(id, schema_id, request_options=request_options) + return _response.data async def update( self, @@ -814,7 +407,7 @@ async def update( disable_data_cutoff: typing.Optional[bool] = OMIT, enabled: typing.Optional[bool] = OMIT, fields: typing.Optional[typing.Sequence[UpdateBulkField]] = OMIT, - filters: typing.Optional[typing.Sequence[BulkFilter]] = OMIT, + filters: typing.Optional[typing.Sequence[BulkFilter2]] = OMIT, partition_key: typing.Optional[str] = OMIT, tracking_field: typing.Optional[str] = OMIT, user_output_name: typing.Optional[str] = OMIT, @@ -835,7 +428,7 @@ async def update( fields : typing.Optional[typing.Sequence[UpdateBulkField]] - filters : typing.Optional[typing.Sequence[BulkFilter]] + filters : typing.Optional[typing.Sequence[BulkFilter2]] partition_key : typing.Optional[str] @@ -872,82 +465,20 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}", - method="PUT", - json={ - "data_cutoff_timestamp": data_cutoff_timestamp, - "disable_data_cutoff": disable_data_cutoff, - "enabled": enabled, - "fields": convert_and_respect_annotation_metadata( - object_=fields, annotation=typing.Sequence[UpdateBulkField], direction="write" - ), - "filters": convert_and_respect_annotation_metadata( - object_=filters, annotation=typing.Sequence[BulkFilter], direction="write" - ), - "partition_key": partition_key, - "tracking_field": tracking_field, - "user_output_name": user_output_name, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.update( + id, + schema_id, + data_cutoff_timestamp=data_cutoff_timestamp, + disable_data_cutoff=disable_data_cutoff, + enabled=enabled, + fields=fields, + filters=filters, + partition_key=partition_key, + tracking_field=tracking_field, + user_output_name=user_output_name, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSchemaEnvelope, - parse_obj_as( - type_=BulkSchemaEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def cancel( self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -990,61 +521,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/bulk/syncs/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}/cancel", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CancelBulkSyncResponseEnvelope, - parse_obj_as( - type_=CancelBulkSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.cancel(id, schema_id, request_options=request_options) + return _response.data diff --git a/src/polytomic/bulk_sync/schemas/raw_client.py b/src/polytomic/bulk_sync/schemas/raw_client.py new file mode 100644 index 0000000..b4fbe04 --- /dev/null +++ b/src/polytomic/bulk_sync/schemas/raw_client.py @@ -0,0 +1,1011 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError as core_api_error_ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.parse_error import ParsingError +from ...core.pydantic_utilities import parse_obj_as +from ...core.request_options import RequestOptions +from ...core.serialization import convert_and_respect_annotation_metadata +from ...errors.bad_request_error import BadRequestError +from ...errors.forbidden_error import ForbiddenError +from ...errors.internal_server_error import InternalServerError +from ...errors.not_found_error import NotFoundError +from ...errors.unauthorized_error import UnauthorizedError +from ...types.api_error import ApiError as types_api_error_ApiError +from ...types.bulk_filter_2 import BulkFilter2 +from ...types.bulk_schema import BulkSchema +from ...types.bulk_schema_envelope import BulkSchemaEnvelope +from ...types.cancel_bulk_sync_response_envelope import CancelBulkSyncResponseEnvelope +from ...types.list_bulk_schema import ListBulkSchema +from ...types.rest_err_response import RestErrResponse +from ...types.update_bulk_field import UpdateBulkField +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawSchemasClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + id: str, + *, + filters: typing.Optional[typing.Dict[str, str]] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ListBulkSchema]: + """ + Parameters + ---------- + id : str + + filters : typing.Optional[typing.Dict[str, str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ListBulkSchema] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/schemas", + method="GET", + params={ + "filters": filters, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListBulkSchema, + parse_obj_as( + type_=ListBulkSchema, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def patch( + self, + id: str, + *, + schemas: typing.Optional[typing.Sequence[BulkSchema]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ListBulkSchema]: + """ + Parameters + ---------- + id : str + + schemas : typing.Optional[typing.Sequence[BulkSchema]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ListBulkSchema] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/schemas", + method="PATCH", + json={ + "schemas": convert_and_respect_annotation_metadata( + object_=schemas, annotation=typing.Optional[typing.Sequence[BulkSchema]], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListBulkSchema, + parse_obj_as( + type_=ListBulkSchema, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get( + self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[BulkSchemaEnvelope]: + """ + Parameters + ---------- + id : str + + schema_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BulkSchemaEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSchemaEnvelope, + parse_obj_as( + type_=BulkSchemaEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def update( + self, + id: str, + schema_id: str, + *, + data_cutoff_timestamp: typing.Optional[dt.datetime] = OMIT, + disable_data_cutoff: typing.Optional[bool] = OMIT, + enabled: typing.Optional[bool] = OMIT, + fields: typing.Optional[typing.Sequence[UpdateBulkField]] = OMIT, + filters: typing.Optional[typing.Sequence[BulkFilter2]] = OMIT, + partition_key: typing.Optional[str] = OMIT, + tracking_field: typing.Optional[str] = OMIT, + user_output_name: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[BulkSchemaEnvelope]: + """ + Parameters + ---------- + id : str + + schema_id : str + + data_cutoff_timestamp : typing.Optional[dt.datetime] + + disable_data_cutoff : typing.Optional[bool] + + enabled : typing.Optional[bool] + + fields : typing.Optional[typing.Sequence[UpdateBulkField]] + + filters : typing.Optional[typing.Sequence[BulkFilter2]] + + partition_key : typing.Optional[str] + + tracking_field : typing.Optional[str] + + user_output_name : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BulkSchemaEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}", + method="PUT", + json={ + "data_cutoff_timestamp": data_cutoff_timestamp, + "disable_data_cutoff": disable_data_cutoff, + "enabled": enabled, + "fields": convert_and_respect_annotation_metadata( + object_=fields, annotation=typing.Optional[typing.Sequence[UpdateBulkField]], direction="write" + ), + "filters": convert_and_respect_annotation_metadata( + object_=filters, annotation=typing.Optional[typing.Sequence[BulkFilter2]], direction="write" + ), + "partition_key": partition_key, + "tracking_field": tracking_field, + "user_output_name": user_output_name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSchemaEnvelope, + parse_obj_as( + type_=BulkSchemaEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def cancel( + self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[CancelBulkSyncResponseEnvelope]: + """ + Parameters + ---------- + id : str + The bulk sync ID. + + schema_id : str + The schema ID to cancel for the bulk sync. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CancelBulkSyncResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}/cancel", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CancelBulkSyncResponseEnvelope, + parse_obj_as( + type_=CancelBulkSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawSchemasClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + id: str, + *, + filters: typing.Optional[typing.Dict[str, str]] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ListBulkSchema]: + """ + Parameters + ---------- + id : str + + filters : typing.Optional[typing.Dict[str, str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ListBulkSchema] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/schemas", + method="GET", + params={ + "filters": filters, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListBulkSchema, + parse_obj_as( + type_=ListBulkSchema, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def patch( + self, + id: str, + *, + schemas: typing.Optional[typing.Sequence[BulkSchema]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ListBulkSchema]: + """ + Parameters + ---------- + id : str + + schemas : typing.Optional[typing.Sequence[BulkSchema]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ListBulkSchema] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/schemas", + method="PATCH", + json={ + "schemas": convert_and_respect_annotation_metadata( + object_=schemas, annotation=typing.Optional[typing.Sequence[BulkSchema]], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListBulkSchema, + parse_obj_as( + type_=ListBulkSchema, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[BulkSchemaEnvelope]: + """ + Parameters + ---------- + id : str + + schema_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BulkSchemaEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSchemaEnvelope, + parse_obj_as( + type_=BulkSchemaEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def update( + self, + id: str, + schema_id: str, + *, + data_cutoff_timestamp: typing.Optional[dt.datetime] = OMIT, + disable_data_cutoff: typing.Optional[bool] = OMIT, + enabled: typing.Optional[bool] = OMIT, + fields: typing.Optional[typing.Sequence[UpdateBulkField]] = OMIT, + filters: typing.Optional[typing.Sequence[BulkFilter2]] = OMIT, + partition_key: typing.Optional[str] = OMIT, + tracking_field: typing.Optional[str] = OMIT, + user_output_name: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[BulkSchemaEnvelope]: + """ + Parameters + ---------- + id : str + + schema_id : str + + data_cutoff_timestamp : typing.Optional[dt.datetime] + + disable_data_cutoff : typing.Optional[bool] + + enabled : typing.Optional[bool] + + fields : typing.Optional[typing.Sequence[UpdateBulkField]] + + filters : typing.Optional[typing.Sequence[BulkFilter2]] + + partition_key : typing.Optional[str] + + tracking_field : typing.Optional[str] + + user_output_name : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BulkSchemaEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}", + method="PUT", + json={ + "data_cutoff_timestamp": data_cutoff_timestamp, + "disable_data_cutoff": disable_data_cutoff, + "enabled": enabled, + "fields": convert_and_respect_annotation_metadata( + object_=fields, annotation=typing.Optional[typing.Sequence[UpdateBulkField]], direction="write" + ), + "filters": convert_and_respect_annotation_metadata( + object_=filters, annotation=typing.Optional[typing.Sequence[BulkFilter2]], direction="write" + ), + "partition_key": partition_key, + "tracking_field": tracking_field, + "user_output_name": user_output_name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSchemaEnvelope, + parse_obj_as( + type_=BulkSchemaEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def cancel( + self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[CancelBulkSyncResponseEnvelope]: + """ + Parameters + ---------- + id : str + The bulk sync ID. + + schema_id : str + The schema ID to cancel for the bulk sync. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CancelBulkSyncResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/bulk/syncs/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}/cancel", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CancelBulkSyncResponseEnvelope, + parse_obj_as( + type_=CancelBulkSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/bulk_sync/types/__init__.py b/src/polytomic/bulk_sync/types/__init__.py index 09a2010..1374c9d 100644 --- a/src/polytomic/bulk_sync/types/__init__.py +++ b/src/polytomic/bulk_sync/types/__init__.py @@ -1,6 +1,38 @@ # This file was auto-generated by Fern from our API Definition. -from .v_2_create_bulk_sync_request_schemas_item import V2CreateBulkSyncRequestSchemasItem -from .v_2_update_bulk_sync_request_schemas_item import V2UpdateBulkSyncRequestSchemasItem +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from .v_2_create_bulk_sync_request_schemas_item import V2CreateBulkSyncRequestSchemasItem + from .v_2_update_bulk_sync_request_schemas_item import V2UpdateBulkSyncRequestSchemasItem +_dynamic_imports: typing.Dict[str, str] = { + "V2CreateBulkSyncRequestSchemasItem": ".v_2_create_bulk_sync_request_schemas_item", + "V2UpdateBulkSyncRequestSchemasItem": ".v_2_update_bulk_sync_request_schemas_item", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["V2CreateBulkSyncRequestSchemasItem", "V2UpdateBulkSyncRequestSchemasItem"] diff --git a/src/polytomic/bulk_sync/types/v_2_create_bulk_sync_request_schemas_item.py b/src/polytomic/bulk_sync/types/v_2_create_bulk_sync_request_schemas_item.py index 5808811..0f598fd 100644 --- a/src/polytomic/bulk_sync/types/v_2_create_bulk_sync_request_schemas_item.py +++ b/src/polytomic/bulk_sync/types/v_2_create_bulk_sync_request_schemas_item.py @@ -1,6 +1,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from ...types.schema_configuration import SchemaConfiguration V2CreateBulkSyncRequestSchemasItem = typing.Union[str, SchemaConfiguration] diff --git a/src/polytomic/bulk_sync/types/v_2_update_bulk_sync_request_schemas_item.py b/src/polytomic/bulk_sync/types/v_2_update_bulk_sync_request_schemas_item.py index ea51f93..8d56582 100644 --- a/src/polytomic/bulk_sync/types/v_2_update_bulk_sync_request_schemas_item.py +++ b/src/polytomic/bulk_sync/types/v_2_update_bulk_sync_request_schemas_item.py @@ -1,6 +1,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from ...types.schema_configuration import SchemaConfiguration V2UpdateBulkSyncRequestSchemasItem = typing.Union[str, SchemaConfiguration] diff --git a/src/polytomic/client.py b/src/polytomic/client.py index f0762a7..1c989ff 100644 --- a/src/polytomic/client.py +++ b/src/polytomic/client.py @@ -1,38 +1,29 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing -from .environment import PolytomicEnvironment + import httpx -from .core.client_wrapper import SyncClientWrapper -from .bulk_sync.client import BulkSyncClient -from .connections.client import ConnectionsClient -from .query_runner.client import QueryRunnerClient -from .schemas.client import SchemasClient -from .models.client import ModelsClient -from .model_sync.client import ModelSyncClient -from .events.client import EventsClient -from .jobs.client import JobsClient -from .identity.client import IdentityClient -from .notifications.client import NotificationsClient -from .organization.client import OrganizationClient -from .users.client import UsersClient -from .webhooks.client import WebhooksClient -from .permissions.client import PermissionsClient -from .core.client_wrapper import AsyncClientWrapper -from .bulk_sync.client import AsyncBulkSyncClient -from .connections.client import AsyncConnectionsClient -from .query_runner.client import AsyncQueryRunnerClient -from .schemas.client import AsyncSchemasClient -from .models.client import AsyncModelsClient -from .model_sync.client import AsyncModelSyncClient -from .events.client import AsyncEventsClient -from .jobs.client import AsyncJobsClient -from .identity.client import AsyncIdentityClient -from .notifications.client import AsyncNotificationsClient -from .organization.client import AsyncOrganizationClient -from .users.client import AsyncUsersClient -from .webhooks.client import AsyncWebhooksClient -from .permissions.client import AsyncPermissionsClient +from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .core.logging import LogConfig, Logger +from .environment import PolytomicEnvironment + +if typing.TYPE_CHECKING: + from .bulk_sync.client import AsyncBulkSyncClient, BulkSyncClient + from .connections.client import AsyncConnectionsClient, ConnectionsClient + from .events.client import AsyncEventsClient, EventsClient + from .identity.client import AsyncIdentityClient, IdentityClient + from .jobs.client import AsyncJobsClient, JobsClient + from .model_sync.client import AsyncModelSyncClient, ModelSyncClient + from .models.client import AsyncModelsClient, ModelsClient + from .notifications.client import AsyncNotificationsClient, NotificationsClient + from .organization.client import AsyncOrganizationClient, OrganizationClient + from .permissions.client import AsyncPermissionsClient, PermissionsClient + from .query_runner.client import AsyncQueryRunnerClient, QueryRunnerClient + from .schemas.client import AsyncSchemasClient, SchemasClient + from .users.client import AsyncUsersClient, UsersClient + from .webhooks.client import AsyncWebhooksClient, WebhooksClient class Polytomic: @@ -53,8 +44,11 @@ class Polytomic: - version : typing.Optional[str] + version : typing.Any token : typing.Union[str, typing.Callable[[], str]] + headers : typing.Optional[typing.Dict[str, str]] + Additional headers to send with every request. + timeout : typing.Optional[float] The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced. @@ -64,6 +58,9 @@ class Polytomic: httpx_client : typing.Optional[httpx.Client] The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration. + logging : typing.Optional[typing.Union[LogConfig, Logger]] + Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance. + Examples -------- from polytomic import Polytomic @@ -79,38 +76,156 @@ def __init__( *, base_url: typing.Optional[str] = None, environment: PolytomicEnvironment = PolytomicEnvironment.DEFAULT, - version: typing.Optional[str] = None, + version: typing.Any, token: typing.Union[str, typing.Callable[[], str]], + headers: typing.Optional[typing.Dict[str, str]] = None, timeout: typing.Optional[float] = None, follow_redirects: typing.Optional[bool] = True, httpx_client: typing.Optional[httpx.Client] = None, + logging: typing.Optional[typing.Union[LogConfig, Logger]] = None, ): - _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None + _defaulted_timeout = ( + timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read + ) self._client_wrapper = SyncClientWrapper( base_url=_get_base_url(base_url=base_url, environment=environment), version=version, token=token, + headers=headers, httpx_client=httpx_client if httpx_client is not None else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects) if follow_redirects is not None else httpx.Client(timeout=_defaulted_timeout), timeout=_defaulted_timeout, + logging=logging, ) - self.bulk_sync = BulkSyncClient(client_wrapper=self._client_wrapper) - self.connections = ConnectionsClient(client_wrapper=self._client_wrapper) - self.query_runner = QueryRunnerClient(client_wrapper=self._client_wrapper) - self.schemas = SchemasClient(client_wrapper=self._client_wrapper) - self.models = ModelsClient(client_wrapper=self._client_wrapper) - self.model_sync = ModelSyncClient(client_wrapper=self._client_wrapper) - self.events = EventsClient(client_wrapper=self._client_wrapper) - self.jobs = JobsClient(client_wrapper=self._client_wrapper) - self.identity = IdentityClient(client_wrapper=self._client_wrapper) - self.notifications = NotificationsClient(client_wrapper=self._client_wrapper) - self.organization = OrganizationClient(client_wrapper=self._client_wrapper) - self.users = UsersClient(client_wrapper=self._client_wrapper) - self.webhooks = WebhooksClient(client_wrapper=self._client_wrapper) - self.permissions = PermissionsClient(client_wrapper=self._client_wrapper) + self._bulk_sync: typing.Optional[BulkSyncClient] = None + self._connections: typing.Optional[ConnectionsClient] = None + self._query_runner: typing.Optional[QueryRunnerClient] = None + self._schemas: typing.Optional[SchemasClient] = None + self._models: typing.Optional[ModelsClient] = None + self._model_sync: typing.Optional[ModelSyncClient] = None + self._events: typing.Optional[EventsClient] = None + self._jobs: typing.Optional[JobsClient] = None + self._identity: typing.Optional[IdentityClient] = None + self._notifications: typing.Optional[NotificationsClient] = None + self._organization: typing.Optional[OrganizationClient] = None + self._users: typing.Optional[UsersClient] = None + self._webhooks: typing.Optional[WebhooksClient] = None + self._permissions: typing.Optional[PermissionsClient] = None + + @property + def bulk_sync(self): + if self._bulk_sync is None: + from .bulk_sync.client import BulkSyncClient # noqa: E402 + + self._bulk_sync = BulkSyncClient(client_wrapper=self._client_wrapper) + return self._bulk_sync + + @property + def connections(self): + if self._connections is None: + from .connections.client import ConnectionsClient # noqa: E402 + + self._connections = ConnectionsClient(client_wrapper=self._client_wrapper) + return self._connections + + @property + def query_runner(self): + if self._query_runner is None: + from .query_runner.client import QueryRunnerClient # noqa: E402 + + self._query_runner = QueryRunnerClient(client_wrapper=self._client_wrapper) + return self._query_runner + + @property + def schemas(self): + if self._schemas is None: + from .schemas.client import SchemasClient # noqa: E402 + + self._schemas = SchemasClient(client_wrapper=self._client_wrapper) + return self._schemas + + @property + def models(self): + if self._models is None: + from .models.client import ModelsClient # noqa: E402 + + self._models = ModelsClient(client_wrapper=self._client_wrapper) + return self._models + + @property + def model_sync(self): + if self._model_sync is None: + from .model_sync.client import ModelSyncClient # noqa: E402 + + self._model_sync = ModelSyncClient(client_wrapper=self._client_wrapper) + return self._model_sync + + @property + def events(self): + if self._events is None: + from .events.client import EventsClient # noqa: E402 + + self._events = EventsClient(client_wrapper=self._client_wrapper) + return self._events + + @property + def jobs(self): + if self._jobs is None: + from .jobs.client import JobsClient # noqa: E402 + + self._jobs = JobsClient(client_wrapper=self._client_wrapper) + return self._jobs + + @property + def identity(self): + if self._identity is None: + from .identity.client import IdentityClient # noqa: E402 + + self._identity = IdentityClient(client_wrapper=self._client_wrapper) + return self._identity + + @property + def notifications(self): + if self._notifications is None: + from .notifications.client import NotificationsClient # noqa: E402 + + self._notifications = NotificationsClient(client_wrapper=self._client_wrapper) + return self._notifications + + @property + def organization(self): + if self._organization is None: + from .organization.client import OrganizationClient # noqa: E402 + + self._organization = OrganizationClient(client_wrapper=self._client_wrapper) + return self._organization + + @property + def users(self): + if self._users is None: + from .users.client import UsersClient # noqa: E402 + + self._users = UsersClient(client_wrapper=self._client_wrapper) + return self._users + + @property + def webhooks(self): + if self._webhooks is None: + from .webhooks.client import WebhooksClient # noqa: E402 + + self._webhooks = WebhooksClient(client_wrapper=self._client_wrapper) + return self._webhooks + + @property + def permissions(self): + if self._permissions is None: + from .permissions.client import PermissionsClient # noqa: E402 + + self._permissions = PermissionsClient(client_wrapper=self._client_wrapper) + return self._permissions class AsyncPolytomic: @@ -131,8 +246,11 @@ class AsyncPolytomic: - version : typing.Optional[str] + version : typing.Any token : typing.Union[str, typing.Callable[[], str]] + headers : typing.Optional[typing.Dict[str, str]] + Additional headers to send with every request. + timeout : typing.Optional[float] The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced. @@ -142,6 +260,9 @@ class AsyncPolytomic: httpx_client : typing.Optional[httpx.AsyncClient] The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration. + logging : typing.Optional[typing.Union[LogConfig, Logger]] + Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance. + Examples -------- from polytomic import AsyncPolytomic @@ -157,38 +278,156 @@ def __init__( *, base_url: typing.Optional[str] = None, environment: PolytomicEnvironment = PolytomicEnvironment.DEFAULT, - version: typing.Optional[str] = None, + version: typing.Any, token: typing.Union[str, typing.Callable[[], str]], + headers: typing.Optional[typing.Dict[str, str]] = None, timeout: typing.Optional[float] = None, follow_redirects: typing.Optional[bool] = True, httpx_client: typing.Optional[httpx.AsyncClient] = None, + logging: typing.Optional[typing.Union[LogConfig, Logger]] = None, ): - _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None + _defaulted_timeout = ( + timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read + ) self._client_wrapper = AsyncClientWrapper( base_url=_get_base_url(base_url=base_url, environment=environment), version=version, token=token, + headers=headers, httpx_client=httpx_client if httpx_client is not None else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects) if follow_redirects is not None else httpx.AsyncClient(timeout=_defaulted_timeout), timeout=_defaulted_timeout, + logging=logging, ) - self.bulk_sync = AsyncBulkSyncClient(client_wrapper=self._client_wrapper) - self.connections = AsyncConnectionsClient(client_wrapper=self._client_wrapper) - self.query_runner = AsyncQueryRunnerClient(client_wrapper=self._client_wrapper) - self.schemas = AsyncSchemasClient(client_wrapper=self._client_wrapper) - self.models = AsyncModelsClient(client_wrapper=self._client_wrapper) - self.model_sync = AsyncModelSyncClient(client_wrapper=self._client_wrapper) - self.events = AsyncEventsClient(client_wrapper=self._client_wrapper) - self.jobs = AsyncJobsClient(client_wrapper=self._client_wrapper) - self.identity = AsyncIdentityClient(client_wrapper=self._client_wrapper) - self.notifications = AsyncNotificationsClient(client_wrapper=self._client_wrapper) - self.organization = AsyncOrganizationClient(client_wrapper=self._client_wrapper) - self.users = AsyncUsersClient(client_wrapper=self._client_wrapper) - self.webhooks = AsyncWebhooksClient(client_wrapper=self._client_wrapper) - self.permissions = AsyncPermissionsClient(client_wrapper=self._client_wrapper) + self._bulk_sync: typing.Optional[AsyncBulkSyncClient] = None + self._connections: typing.Optional[AsyncConnectionsClient] = None + self._query_runner: typing.Optional[AsyncQueryRunnerClient] = None + self._schemas: typing.Optional[AsyncSchemasClient] = None + self._models: typing.Optional[AsyncModelsClient] = None + self._model_sync: typing.Optional[AsyncModelSyncClient] = None + self._events: typing.Optional[AsyncEventsClient] = None + self._jobs: typing.Optional[AsyncJobsClient] = None + self._identity: typing.Optional[AsyncIdentityClient] = None + self._notifications: typing.Optional[AsyncNotificationsClient] = None + self._organization: typing.Optional[AsyncOrganizationClient] = None + self._users: typing.Optional[AsyncUsersClient] = None + self._webhooks: typing.Optional[AsyncWebhooksClient] = None + self._permissions: typing.Optional[AsyncPermissionsClient] = None + + @property + def bulk_sync(self): + if self._bulk_sync is None: + from .bulk_sync.client import AsyncBulkSyncClient # noqa: E402 + + self._bulk_sync = AsyncBulkSyncClient(client_wrapper=self._client_wrapper) + return self._bulk_sync + + @property + def connections(self): + if self._connections is None: + from .connections.client import AsyncConnectionsClient # noqa: E402 + + self._connections = AsyncConnectionsClient(client_wrapper=self._client_wrapper) + return self._connections + + @property + def query_runner(self): + if self._query_runner is None: + from .query_runner.client import AsyncQueryRunnerClient # noqa: E402 + + self._query_runner = AsyncQueryRunnerClient(client_wrapper=self._client_wrapper) + return self._query_runner + + @property + def schemas(self): + if self._schemas is None: + from .schemas.client import AsyncSchemasClient # noqa: E402 + + self._schemas = AsyncSchemasClient(client_wrapper=self._client_wrapper) + return self._schemas + + @property + def models(self): + if self._models is None: + from .models.client import AsyncModelsClient # noqa: E402 + + self._models = AsyncModelsClient(client_wrapper=self._client_wrapper) + return self._models + + @property + def model_sync(self): + if self._model_sync is None: + from .model_sync.client import AsyncModelSyncClient # noqa: E402 + + self._model_sync = AsyncModelSyncClient(client_wrapper=self._client_wrapper) + return self._model_sync + + @property + def events(self): + if self._events is None: + from .events.client import AsyncEventsClient # noqa: E402 + + self._events = AsyncEventsClient(client_wrapper=self._client_wrapper) + return self._events + + @property + def jobs(self): + if self._jobs is None: + from .jobs.client import AsyncJobsClient # noqa: E402 + + self._jobs = AsyncJobsClient(client_wrapper=self._client_wrapper) + return self._jobs + + @property + def identity(self): + if self._identity is None: + from .identity.client import AsyncIdentityClient # noqa: E402 + + self._identity = AsyncIdentityClient(client_wrapper=self._client_wrapper) + return self._identity + + @property + def notifications(self): + if self._notifications is None: + from .notifications.client import AsyncNotificationsClient # noqa: E402 + + self._notifications = AsyncNotificationsClient(client_wrapper=self._client_wrapper) + return self._notifications + + @property + def organization(self): + if self._organization is None: + from .organization.client import AsyncOrganizationClient # noqa: E402 + + self._organization = AsyncOrganizationClient(client_wrapper=self._client_wrapper) + return self._organization + + @property + def users(self): + if self._users is None: + from .users.client import AsyncUsersClient # noqa: E402 + + self._users = AsyncUsersClient(client_wrapper=self._client_wrapper) + return self._users + + @property + def webhooks(self): + if self._webhooks is None: + from .webhooks.client import AsyncWebhooksClient # noqa: E402 + + self._webhooks = AsyncWebhooksClient(client_wrapper=self._client_wrapper) + return self._webhooks + + @property + def permissions(self): + if self._permissions is None: + from .permissions.client import AsyncPermissionsClient # noqa: E402 + + self._permissions = AsyncPermissionsClient(client_wrapper=self._client_wrapper) + return self._permissions def _get_base_url(*, base_url: typing.Optional[str] = None, environment: PolytomicEnvironment) -> str: diff --git a/src/polytomic/connections/__init__.py b/src/polytomic/connections/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/connections/__init__.py +++ b/src/polytomic/connections/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/connections/client.py b/src/polytomic/connections/client.py index 37a3eba..cc8b9fe 100644 --- a/src/polytomic/connections/client.py +++ b/src/polytomic/connections/client.py @@ -1,29 +1,18 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions -from ..types.connection_type_response_envelope import ConnectionTypeResponseEnvelope -from ..core.pydantic_utilities import parse_obj_as -from ..errors.unauthorized_error import UnauthorizedError -from ..types.rest_err_response import RestErrResponse -from ..errors.internal_server_error import InternalServerError -from ..types.api_error import ApiError as types_api_error_ApiError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError as core_api_error_ApiError -from ..types.jsonschema_schema import JsonschemaSchema -from ..core.jsonable_encoder import jsonable_encoder -from ..errors.not_found_error import NotFoundError -from ..types.connection_parameter_values_response_envelope import ConnectionParameterValuesResponseEnvelope -from ..errors.bad_request_error import BadRequestError -from ..types.connection_list_response_envelope import ConnectionListResponseEnvelope -from ..types.create_connection_response_envelope import CreateConnectionResponseEnvelope -from ..errors.forbidden_error import ForbiddenError -from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.connect_card_response_envelope import ConnectCardResponseEnvelope +from ..types.connection_list_response_envelope import ConnectionListResponseEnvelope +from ..types.connection_parameter_values_response_envelope import ConnectionParameterValuesResponseEnvelope from ..types.connection_response_envelope import ConnectionResponseEnvelope +from ..types.connection_type_response_envelope import ConnectionTypeResponseEnvelope +from ..types.create_connection_response_envelope import CreateConnectionResponseEnvelope +from ..types.jsonschema_schema import JsonschemaSchema from ..types.v_2_create_shared_connection_response_envelope import V2CreateSharedConnectionResponseEnvelope -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawConnectionsClient, RawConnectionsClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -31,7 +20,18 @@ class ConnectionsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawConnectionsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawConnectionsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawConnectionsClient + """ + return self._raw_client def get_types(self, *, request_options: typing.Optional[RequestOptions] = None) -> ConnectionTypeResponseEnvelope: """ @@ -55,44 +55,8 @@ def get_types(self, *, request_options: typing.Optional[RequestOptions] = None) ) client.connections.get_types() """ - _response = self._client_wrapper.httpx_client.request( - "api/connection_types", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConnectionTypeResponseEnvelope, - parse_obj_as( - type_=ConnectionTypeResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_types(request_options=request_options) + return _response.data def get_connection_type_schema( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -122,54 +86,8 @@ def get_connection_type_schema( id="postgresql", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connection_types/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - JsonschemaSchema, - parse_obj_as( - type_=JsonschemaSchema, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_connection_type_schema(id, request_options=request_options) + return _response.data def get_type_parameter_values( self, @@ -177,7 +95,7 @@ def get_type_parameter_values( *, field: str, connection_id: typing.Optional[str] = OMIT, - parameters: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, + parameters: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, query: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> ConnectionParameterValuesResponseEnvelope: @@ -190,7 +108,7 @@ def get_type_parameter_values( connection_id : typing.Optional[str] - parameters : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] + parameters : typing.Optional[typing.Dict[str, typing.Any]] query : typing.Optional[str] @@ -215,74 +133,15 @@ def get_type_parameter_values( field="field", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connection_types/{jsonable_encoder(type)}/parameter_values", - method="POST", - json={ - "connection_id": connection_id, - "field": field, - "parameters": parameters, - "query": query, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.get_type_parameter_values( + type, + field=field, + connection_id=connection_id, + parameters=parameters, + query=query, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConnectionParameterValuesResponseEnvelope, - parse_obj_as( - type_=ConnectionParameterValuesResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> ConnectionListResponseEnvelope: """ @@ -306,49 +165,13 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Co ) client.connections.list() """ - _response = self._client_wrapper.httpx_client.request( - "api/connections", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConnectionListResponseEnvelope, - parse_obj_as( - type_=ConnectionListResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.list(request_options=request_options) + return _response.data def create( self, *, - configuration: typing.Dict[str, typing.Optional[typing.Any]], + configuration: typing.Dict[str, typing.Any], name: str, type: str, healthcheck_interval: typing.Optional[str] = OMIT, @@ -361,7 +184,7 @@ def create( """ Parameters ---------- - configuration : typing.Dict[str, typing.Optional[typing.Any]] + configuration : typing.Dict[str, typing.Any] name : str @@ -408,88 +231,18 @@ def create( type="postgresql", ) """ - _response = self._client_wrapper.httpx_client.request( - "api/connections", - method="POST", - json={ - "configuration": configuration, - "healthcheck_interval": healthcheck_interval, - "name": name, - "organization_id": organization_id, - "policies": policies, - "redirect_url": redirect_url, - "type": type, - "validate": validate, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.create( + configuration=configuration, + name=name, + type=type, + healthcheck_interval=healthcheck_interval, + organization_id=organization_id, + policies=policies, + redirect_url=redirect_url, + validate=validate, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CreateConnectionResponseEnvelope, - parse_obj_as( - type_=CreateConnectionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def connect( self, @@ -557,82 +310,22 @@ def connect( redirect_url="redirect_url", ) """ - _response = self._client_wrapper.httpx_client.request( - "api/connections/connect/", - method="POST", - json={ - "connection": connection, - "dark": dark, - "name": name, - "organization_id": organization_id, - "redirect_url": redirect_url, - "type": type, - "whitelist": whitelist, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.connect( + name=name, + redirect_url=redirect_url, + connection=connection, + dark=dark, + organization_id=organization_id, + type=type, + whitelist=whitelist, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConnectCardResponseEnvelope, - parse_obj_as( - type_=ConnectCardResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def test_connection( self, *, - configuration: typing.Dict[str, typing.Optional[typing.Any]], + configuration: typing.Dict[str, typing.Any], type: str, connection_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, @@ -642,7 +335,7 @@ def test_connection( Parameters ---------- - configuration : typing.Dict[str, typing.Optional[typing.Any]] + configuration : typing.Dict[str, typing.Any] Connection configuration to test. type : str @@ -677,67 +370,10 @@ def test_connection( type="postgresql", ) """ - _response = self._client_wrapper.httpx_client.request( - "api/connections/test", - method="POST", - json={ - "configuration": configuration, - "connection_id": connection_id, - "type": type, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.test_connection( + configuration=configuration, type=type, connection_id=connection_id, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ConnectionResponseEnvelope: """ @@ -765,60 +401,14 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConnectionResponseEnvelope, - parse_obj_as( - type_=ConnectionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(id, request_options=request_options) + return _response.data def update( self, id: str, *, - configuration: typing.Dict[str, typing.Optional[typing.Any]], + configuration: typing.Dict[str, typing.Any], name: str, healthcheck_interval: typing.Optional[str] = OMIT, organization_id: typing.Optional[str] = OMIT, @@ -833,7 +423,7 @@ def update( ---------- id : str - configuration : typing.Dict[str, typing.Optional[typing.Any]] + configuration : typing.Dict[str, typing.Any] name : str @@ -879,98 +469,19 @@ def update( name="My Postgres Connection", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}", - method="PUT", - json={ - "configuration": configuration, - "healthcheck_interval": healthcheck_interval, - "name": name, - "organization_id": organization_id, - "policies": policies, - "reconnect": reconnect, - "type": type, - "validate": validate, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.update( + id, + configuration=configuration, + name=name, + healthcheck_interval=healthcheck_interval, + organization_id=organization_id, + policies=policies, + reconnect=reconnect, + type=type, + validate=validate, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CreateConnectionResponseEnvelope, - parse_obj_as( - type_=CreateConnectionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def remove( self, id: str, *, force: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None @@ -1002,71 +513,8 @@ def remove( force=True, ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}", - method="DELETE", - params={ - "force": force, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.remove(id, force=force, request_options=request_options) + return _response.data def get_parameter_values( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -1096,69 +544,27 @@ def get_parameter_values( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/parameter_values", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConnectionParameterValuesResponseEnvelope, - parse_obj_as( - type_=ConnectionParameterValuesResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) - - def api_v_2_create_shared_connection( + _response = self._raw_client.get_parameter_values(id, request_options=request_options) + return _response.data + + def create_shared_connection( self, - id: str, + parent_connection_id: str, *, - organization_id: str, + child_organization_id: str, name: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> V2CreateSharedConnectionResponseEnvelope: """ + > 🚧 Requires partner key + > + > Shared connections can only be created by using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + Parameters ---------- - id : str + parent_connection_id : str - organization_id : str + child_organization_id : str name : typing.Optional[str] @@ -1178,82 +584,65 @@ def api_v_2_create_shared_connection( version="YOUR_VERSION", token="YOUR_TOKEN", ) - client.connections.api_v_2_create_shared_connection( - id="248df4b7-aa70-47b8-a036-33ac447e668d", - organization_id="248df4b7-aa70-47b8-a036-33ac447e668d", + client.connections.create_shared_connection( + parent_connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", + child_organization_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/share", - method="POST", - json={ - "name": name, - "organization_id": organization_id, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.create_shared_connection( + parent_connection_id, + child_organization_id=child_organization_id, + name=name, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V2CreateSharedConnectionResponseEnvelope, - parse_obj_as( - type_=V2CreateSharedConnectionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data + + def list_shared_connections( + self, parent_connection_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ConnectionListResponseEnvelope: + """ + Parameters + ---------- + parent_connection_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ConnectionListResponseEnvelope + OK + + Examples + -------- + from polytomic import Polytomic + + client = Polytomic( + version="YOUR_VERSION", + token="YOUR_TOKEN", + ) + client.connections.list_shared_connections( + parent_connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", + ) + """ + _response = self._raw_client.list_shared_connections(parent_connection_id, request_options=request_options) + return _response.data class AsyncConnectionsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawConnectionsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawConnectionsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawConnectionsClient + """ + return self._raw_client async def get_types( self, *, request_options: typing.Optional[RequestOptions] = None @@ -1287,44 +676,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/connection_types", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConnectionTypeResponseEnvelope, - parse_obj_as( - type_=ConnectionTypeResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_types(request_options=request_options) + return _response.data async def get_connection_type_schema( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -1362,54 +715,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connection_types/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - JsonschemaSchema, - parse_obj_as( - type_=JsonschemaSchema, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_connection_type_schema(id, request_options=request_options) + return _response.data async def get_type_parameter_values( self, @@ -1417,7 +724,7 @@ async def get_type_parameter_values( *, field: str, connection_id: typing.Optional[str] = OMIT, - parameters: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, + parameters: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, query: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> ConnectionParameterValuesResponseEnvelope: @@ -1430,7 +737,7 @@ async def get_type_parameter_values( connection_id : typing.Optional[str] - parameters : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] + parameters : typing.Optional[typing.Dict[str, typing.Any]] query : typing.Optional[str] @@ -1463,74 +770,15 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connection_types/{jsonable_encoder(type)}/parameter_values", - method="POST", - json={ - "connection_id": connection_id, - "field": field, - "parameters": parameters, - "query": query, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.get_type_parameter_values( + type, + field=field, + connection_id=connection_id, + parameters=parameters, + query=query, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConnectionParameterValuesResponseEnvelope, - parse_obj_as( - type_=ConnectionParameterValuesResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> ConnectionListResponseEnvelope: """ @@ -1562,49 +810,13 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/connections", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConnectionListResponseEnvelope, - parse_obj_as( - type_=ConnectionListResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.list(request_options=request_options) + return _response.data async def create( self, *, - configuration: typing.Dict[str, typing.Optional[typing.Any]], + configuration: typing.Dict[str, typing.Any], name: str, type: str, healthcheck_interval: typing.Optional[str] = OMIT, @@ -1617,7 +829,7 @@ async def create( """ Parameters ---------- - configuration : typing.Dict[str, typing.Optional[typing.Any]] + configuration : typing.Dict[str, typing.Any] name : str @@ -1672,88 +884,18 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/connections", - method="POST", - json={ - "configuration": configuration, - "healthcheck_interval": healthcheck_interval, - "name": name, - "organization_id": organization_id, - "policies": policies, - "redirect_url": redirect_url, - "type": type, - "validate": validate, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.create( + configuration=configuration, + name=name, + type=type, + healthcheck_interval=healthcheck_interval, + organization_id=organization_id, + policies=policies, + redirect_url=redirect_url, + validate=validate, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CreateConnectionResponseEnvelope, - parse_obj_as( - type_=CreateConnectionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def connect( self, @@ -1829,82 +971,22 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/connections/connect/", - method="POST", - json={ - "connection": connection, - "dark": dark, - "name": name, - "organization_id": organization_id, - "redirect_url": redirect_url, - "type": type, - "whitelist": whitelist, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.connect( + name=name, + redirect_url=redirect_url, + connection=connection, + dark=dark, + organization_id=organization_id, + type=type, + whitelist=whitelist, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConnectCardResponseEnvelope, - parse_obj_as( - type_=ConnectCardResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def test_connection( self, *, - configuration: typing.Dict[str, typing.Optional[typing.Any]], + configuration: typing.Dict[str, typing.Any], type: str, connection_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, @@ -1914,7 +996,7 @@ async def test_connection( Parameters ---------- - configuration : typing.Dict[str, typing.Optional[typing.Any]] + configuration : typing.Dict[str, typing.Any] Connection configuration to test. type : str @@ -1957,67 +1039,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/connections/test", - method="POST", - json={ - "configuration": configuration, - "connection_id": connection_id, - "type": type, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.test_connection( + configuration=configuration, type=type, connection_id=connection_id, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -2055,60 +1080,14 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConnectionResponseEnvelope, - parse_obj_as( - type_=ConnectionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(id, request_options=request_options) + return _response.data async def update( self, id: str, *, - configuration: typing.Dict[str, typing.Optional[typing.Any]], + configuration: typing.Dict[str, typing.Any], name: str, healthcheck_interval: typing.Optional[str] = OMIT, organization_id: typing.Optional[str] = OMIT, @@ -2123,7 +1102,7 @@ async def update( ---------- id : str - configuration : typing.Dict[str, typing.Optional[typing.Any]] + configuration : typing.Dict[str, typing.Any] name : str @@ -2177,98 +1156,19 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}", - method="PUT", - json={ - "configuration": configuration, - "healthcheck_interval": healthcheck_interval, - "name": name, - "organization_id": organization_id, - "policies": policies, - "reconnect": reconnect, - "type": type, - "validate": validate, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.update( + id, + configuration=configuration, + name=name, + healthcheck_interval=healthcheck_interval, + organization_id=organization_id, + policies=policies, + reconnect=reconnect, + type=type, + validate=validate, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CreateConnectionResponseEnvelope, - parse_obj_as( - type_=CreateConnectionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def remove( self, id: str, *, force: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None @@ -2308,71 +1208,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}", - method="DELETE", - params={ - "force": force, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.remove(id, force=force, request_options=request_options) + return _response.data async def get_parameter_values( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -2410,69 +1247,27 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/parameter_values", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConnectionParameterValuesResponseEnvelope, - parse_obj_as( - type_=ConnectionParameterValuesResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) - - async def api_v_2_create_shared_connection( + _response = await self._raw_client.get_parameter_values(id, request_options=request_options) + return _response.data + + async def create_shared_connection( self, - id: str, + parent_connection_id: str, *, - organization_id: str, + child_organization_id: str, name: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> V2CreateSharedConnectionResponseEnvelope: """ + > 🚧 Requires partner key + > + > Shared connections can only be created by using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + Parameters ---------- - id : str + parent_connection_id : str - organization_id : str + child_organization_id : str name : typing.Optional[str] @@ -2497,77 +1292,59 @@ async def api_v_2_create_shared_connection( async def main() -> None: - await client.connections.api_v_2_create_shared_connection( - id="248df4b7-aa70-47b8-a036-33ac447e668d", - organization_id="248df4b7-aa70-47b8-a036-33ac447e668d", + await client.connections.create_shared_connection( + parent_connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", + child_organization_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/share", - method="POST", - json={ - "name": name, - "organization_id": organization_id, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.create_shared_connection( + parent_connection_id, + child_organization_id=child_organization_id, + name=name, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V2CreateSharedConnectionResponseEnvelope, - parse_obj_as( - type_=V2CreateSharedConnectionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data + + async def list_shared_connections( + self, parent_connection_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ConnectionListResponseEnvelope: + """ + Parameters + ---------- + parent_connection_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ConnectionListResponseEnvelope + OK + + Examples + -------- + import asyncio + + from polytomic import AsyncPolytomic + + client = AsyncPolytomic( + version="YOUR_VERSION", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.connections.list_shared_connections( + parent_connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.list_shared_connections( + parent_connection_id, request_options=request_options + ) + return _response.data diff --git a/src/polytomic/connections/raw_client.py b/src/polytomic/connections/raw_client.py new file mode 100644 index 0000000..dd86bd4 --- /dev/null +++ b/src/polytomic/connections/raw_client.py @@ -0,0 +1,2684 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError as core_api_error_ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..errors.bad_request_error import BadRequestError +from ..errors.forbidden_error import ForbiddenError +from ..errors.internal_server_error import InternalServerError +from ..errors.not_found_error import NotFoundError +from ..errors.unauthorized_error import UnauthorizedError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.api_error import ApiError as types_api_error_ApiError +from ..types.connect_card_response_envelope import ConnectCardResponseEnvelope +from ..types.connection_list_response_envelope import ConnectionListResponseEnvelope +from ..types.connection_parameter_values_response_envelope import ConnectionParameterValuesResponseEnvelope +from ..types.connection_response_envelope import ConnectionResponseEnvelope +from ..types.connection_type_response_envelope import ConnectionTypeResponseEnvelope +from ..types.create_connection_response_envelope import CreateConnectionResponseEnvelope +from ..types.jsonschema_schema import JsonschemaSchema +from ..types.rest_err_response import RestErrResponse +from ..types.v_2_create_shared_connection_response_envelope import V2CreateSharedConnectionResponseEnvelope +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawConnectionsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_types( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ConnectionTypeResponseEnvelope]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ConnectionTypeResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/connection_types", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConnectionTypeResponseEnvelope, + parse_obj_as( + type_=ConnectionTypeResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_connection_type_schema( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[JsonschemaSchema]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[JsonschemaSchema] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connection_types/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + JsonschemaSchema, + parse_obj_as( + type_=JsonschemaSchema, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_type_parameter_values( + self, + type: str, + *, + field: str, + connection_id: typing.Optional[str] = OMIT, + parameters: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + query: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ConnectionParameterValuesResponseEnvelope]: + """ + Parameters + ---------- + type : str + + field : str + + connection_id : typing.Optional[str] + + parameters : typing.Optional[typing.Dict[str, typing.Any]] + + query : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ConnectionParameterValuesResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connection_types/{jsonable_encoder(type)}/parameter_values", + method="POST", + json={ + "connection_id": connection_id, + "field": field, + "parameters": parameters, + "query": query, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConnectionParameterValuesResponseEnvelope, + parse_obj_as( + type_=ConnectionParameterValuesResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ConnectionListResponseEnvelope]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ConnectionListResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/connections", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConnectionListResponseEnvelope, + parse_obj_as( + type_=ConnectionListResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def create( + self, + *, + configuration: typing.Dict[str, typing.Any], + name: str, + type: str, + healthcheck_interval: typing.Optional[str] = OMIT, + organization_id: typing.Optional[str] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + redirect_url: typing.Optional[str] = OMIT, + validate: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[CreateConnectionResponseEnvelope]: + """ + Parameters + ---------- + configuration : typing.Dict[str, typing.Any] + + name : str + + type : str + + healthcheck_interval : typing.Optional[str] + Override interval for connection health checking. + + organization_id : typing.Optional[str] + + policies : typing.Optional[typing.Sequence[str]] + + redirect_url : typing.Optional[str] + URL to redirect to after completing OAuth flow. + + validate : typing.Optional[bool] + Validate connection configuration. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CreateConnectionResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/connections", + method="POST", + json={ + "configuration": configuration, + "healthcheck_interval": healthcheck_interval, + "name": name, + "organization_id": organization_id, + "policies": policies, + "redirect_url": redirect_url, + "type": type, + "validate": validate, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreateConnectionResponseEnvelope, + parse_obj_as( + type_=CreateConnectionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def connect( + self, + *, + name: str, + redirect_url: str, + connection: typing.Optional[str] = OMIT, + dark: typing.Optional[bool] = OMIT, + organization_id: typing.Optional[str] = OMIT, + type: typing.Optional[str] = OMIT, + whitelist: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ConnectCardResponseEnvelope]: + """ + Creates a new request for [Polytomic Connect](https://www.polytomic.com/connect). + + This endpoint configures a Polytomic Connect request and returns the URL to + redirect users to. This allows embedding Polytomic connection authorization in + other applications. + + See also: + + - [Embedding authentication](https://apidocs.polytomic.com/2024-02-08/guides/embedding-authentication), a guide to using Polytomic Connect. + + Parameters + ---------- + name : str + Name of the new connection. Must be unique per organization. + + redirect_url : str + URL to redirect to after connection is created. + + connection : typing.Optional[str] + The id of an existing connection to update. + + dark : typing.Optional[bool] + Whether to use the dark theme for the Connect modal. + + organization_id : typing.Optional[str] + + type : typing.Optional[str] + Connection type to create. + + whitelist : typing.Optional[typing.Sequence[str]] + List of connection types which are allowed to be created. Ignored if type is set. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ConnectCardResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/connections/connect/", + method="POST", + json={ + "connection": connection, + "dark": dark, + "name": name, + "organization_id": organization_id, + "redirect_url": redirect_url, + "type": type, + "whitelist": whitelist, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConnectCardResponseEnvelope, + parse_obj_as( + type_=ConnectCardResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def test_connection( + self, + *, + configuration: typing.Dict[str, typing.Any], + type: str, + connection_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[None]: + """ + Tests a connection configuration. + + Parameters + ---------- + configuration : typing.Dict[str, typing.Any] + Connection configuration to test. + + type : str + The type of connection to test. + + connection_id : typing.Optional[str] + Optional existing connection ID to use as a base for testing. The provided configuration will be merged over the stored configuration for this connection before testing. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + "api/connections/test", + method="POST", + json={ + "configuration": configuration, + "connection_id": connection_id, + "type": type, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ConnectionResponseEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ConnectionResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConnectionResponseEnvelope, + parse_obj_as( + type_=ConnectionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def update( + self, + id: str, + *, + configuration: typing.Dict[str, typing.Any], + name: str, + healthcheck_interval: typing.Optional[str] = OMIT, + organization_id: typing.Optional[str] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + reconnect: typing.Optional[bool] = OMIT, + type: typing.Optional[str] = OMIT, + validate: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[CreateConnectionResponseEnvelope]: + """ + Parameters + ---------- + id : str + + configuration : typing.Dict[str, typing.Any] + + name : str + + healthcheck_interval : typing.Optional[str] + Override interval for connection health checking. + + organization_id : typing.Optional[str] + + policies : typing.Optional[typing.Sequence[str]] + + reconnect : typing.Optional[bool] + + type : typing.Optional[str] + + validate : typing.Optional[bool] + Validate connection configuration. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CreateConnectionResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}", + method="PUT", + json={ + "configuration": configuration, + "healthcheck_interval": healthcheck_interval, + "name": name, + "organization_id": organization_id, + "policies": policies, + "reconnect": reconnect, + "type": type, + "validate": validate, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreateConnectionResponseEnvelope, + parse_obj_as( + type_=CreateConnectionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def remove( + self, id: str, *, force: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[None]: + """ + Parameters + ---------- + id : str + + force : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}", + method="DELETE", + params={ + "force": force, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_parameter_values( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ConnectionParameterValuesResponseEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ConnectionParameterValuesResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/parameter_values", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConnectionParameterValuesResponseEnvelope, + parse_obj_as( + type_=ConnectionParameterValuesResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def create_shared_connection( + self, + parent_connection_id: str, + *, + child_organization_id: str, + name: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[V2CreateSharedConnectionResponseEnvelope]: + """ + > 🚧 Requires partner key + > + > Shared connections can only be created by using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + + Parameters + ---------- + parent_connection_id : str + + child_organization_id : str + + name : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[V2CreateSharedConnectionResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(parent_connection_id)}/share", + method="POST", + json={ + "child_organization_id": child_organization_id, + "name": name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V2CreateSharedConnectionResponseEnvelope, + parse_obj_as( + type_=V2CreateSharedConnectionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def list_shared_connections( + self, parent_connection_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ConnectionListResponseEnvelope]: + """ + Parameters + ---------- + parent_connection_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ConnectionListResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(parent_connection_id)}/shared", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConnectionListResponseEnvelope, + parse_obj_as( + type_=ConnectionListResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawConnectionsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_types( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ConnectionTypeResponseEnvelope]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ConnectionTypeResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/connection_types", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConnectionTypeResponseEnvelope, + parse_obj_as( + type_=ConnectionTypeResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_connection_type_schema( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[JsonschemaSchema]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[JsonschemaSchema] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connection_types/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + JsonschemaSchema, + parse_obj_as( + type_=JsonschemaSchema, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_type_parameter_values( + self, + type: str, + *, + field: str, + connection_id: typing.Optional[str] = OMIT, + parameters: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + query: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ConnectionParameterValuesResponseEnvelope]: + """ + Parameters + ---------- + type : str + + field : str + + connection_id : typing.Optional[str] + + parameters : typing.Optional[typing.Dict[str, typing.Any]] + + query : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ConnectionParameterValuesResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connection_types/{jsonable_encoder(type)}/parameter_values", + method="POST", + json={ + "connection_id": connection_id, + "field": field, + "parameters": parameters, + "query": query, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConnectionParameterValuesResponseEnvelope, + parse_obj_as( + type_=ConnectionParameterValuesResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ConnectionListResponseEnvelope]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ConnectionListResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/connections", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConnectionListResponseEnvelope, + parse_obj_as( + type_=ConnectionListResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def create( + self, + *, + configuration: typing.Dict[str, typing.Any], + name: str, + type: str, + healthcheck_interval: typing.Optional[str] = OMIT, + organization_id: typing.Optional[str] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + redirect_url: typing.Optional[str] = OMIT, + validate: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[CreateConnectionResponseEnvelope]: + """ + Parameters + ---------- + configuration : typing.Dict[str, typing.Any] + + name : str + + type : str + + healthcheck_interval : typing.Optional[str] + Override interval for connection health checking. + + organization_id : typing.Optional[str] + + policies : typing.Optional[typing.Sequence[str]] + + redirect_url : typing.Optional[str] + URL to redirect to after completing OAuth flow. + + validate : typing.Optional[bool] + Validate connection configuration. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CreateConnectionResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/connections", + method="POST", + json={ + "configuration": configuration, + "healthcheck_interval": healthcheck_interval, + "name": name, + "organization_id": organization_id, + "policies": policies, + "redirect_url": redirect_url, + "type": type, + "validate": validate, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreateConnectionResponseEnvelope, + parse_obj_as( + type_=CreateConnectionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def connect( + self, + *, + name: str, + redirect_url: str, + connection: typing.Optional[str] = OMIT, + dark: typing.Optional[bool] = OMIT, + organization_id: typing.Optional[str] = OMIT, + type: typing.Optional[str] = OMIT, + whitelist: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ConnectCardResponseEnvelope]: + """ + Creates a new request for [Polytomic Connect](https://www.polytomic.com/connect). + + This endpoint configures a Polytomic Connect request and returns the URL to + redirect users to. This allows embedding Polytomic connection authorization in + other applications. + + See also: + + - [Embedding authentication](https://apidocs.polytomic.com/2024-02-08/guides/embedding-authentication), a guide to using Polytomic Connect. + + Parameters + ---------- + name : str + Name of the new connection. Must be unique per organization. + + redirect_url : str + URL to redirect to after connection is created. + + connection : typing.Optional[str] + The id of an existing connection to update. + + dark : typing.Optional[bool] + Whether to use the dark theme for the Connect modal. + + organization_id : typing.Optional[str] + + type : typing.Optional[str] + Connection type to create. + + whitelist : typing.Optional[typing.Sequence[str]] + List of connection types which are allowed to be created. Ignored if type is set. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ConnectCardResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/connections/connect/", + method="POST", + json={ + "connection": connection, + "dark": dark, + "name": name, + "organization_id": organization_id, + "redirect_url": redirect_url, + "type": type, + "whitelist": whitelist, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConnectCardResponseEnvelope, + parse_obj_as( + type_=ConnectCardResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def test_connection( + self, + *, + configuration: typing.Dict[str, typing.Any], + type: str, + connection_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[None]: + """ + Tests a connection configuration. + + Parameters + ---------- + configuration : typing.Dict[str, typing.Any] + Connection configuration to test. + + type : str + The type of connection to test. + + connection_id : typing.Optional[str] + Optional existing connection ID to use as a base for testing. The provided configuration will be merged over the stored configuration for this connection before testing. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + "api/connections/test", + method="POST", + json={ + "configuration": configuration, + "connection_id": connection_id, + "type": type, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ConnectionResponseEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ConnectionResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConnectionResponseEnvelope, + parse_obj_as( + type_=ConnectionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def update( + self, + id: str, + *, + configuration: typing.Dict[str, typing.Any], + name: str, + healthcheck_interval: typing.Optional[str] = OMIT, + organization_id: typing.Optional[str] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + reconnect: typing.Optional[bool] = OMIT, + type: typing.Optional[str] = OMIT, + validate: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[CreateConnectionResponseEnvelope]: + """ + Parameters + ---------- + id : str + + configuration : typing.Dict[str, typing.Any] + + name : str + + healthcheck_interval : typing.Optional[str] + Override interval for connection health checking. + + organization_id : typing.Optional[str] + + policies : typing.Optional[typing.Sequence[str]] + + reconnect : typing.Optional[bool] + + type : typing.Optional[str] + + validate : typing.Optional[bool] + Validate connection configuration. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CreateConnectionResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}", + method="PUT", + json={ + "configuration": configuration, + "healthcheck_interval": healthcheck_interval, + "name": name, + "organization_id": organization_id, + "policies": policies, + "reconnect": reconnect, + "type": type, + "validate": validate, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreateConnectionResponseEnvelope, + parse_obj_as( + type_=CreateConnectionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def remove( + self, id: str, *, force: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + id : str + + force : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}", + method="DELETE", + params={ + "force": force, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_parameter_values( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ConnectionParameterValuesResponseEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ConnectionParameterValuesResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/parameter_values", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConnectionParameterValuesResponseEnvelope, + parse_obj_as( + type_=ConnectionParameterValuesResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def create_shared_connection( + self, + parent_connection_id: str, + *, + child_organization_id: str, + name: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[V2CreateSharedConnectionResponseEnvelope]: + """ + > 🚧 Requires partner key + > + > Shared connections can only be created by using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + + Parameters + ---------- + parent_connection_id : str + + child_organization_id : str + + name : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[V2CreateSharedConnectionResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(parent_connection_id)}/share", + method="POST", + json={ + "child_organization_id": child_organization_id, + "name": name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V2CreateSharedConnectionResponseEnvelope, + parse_obj_as( + type_=V2CreateSharedConnectionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def list_shared_connections( + self, parent_connection_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ConnectionListResponseEnvelope]: + """ + Parameters + ---------- + parent_connection_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ConnectionListResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(parent_connection_id)}/shared", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConnectionListResponseEnvelope, + parse_obj_as( + type_=ConnectionListResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/core/__init__.py b/src/polytomic/core/__init__.py index f03aecb..4fb6e12 100644 --- a/src/polytomic/core/__init__.py +++ b/src/polytomic/core/__init__.py @@ -1,43 +1,121 @@ # This file was auto-generated by Fern from our API Definition. -from .api_error import ApiError -from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper -from .datetime_utils import serialize_datetime -from .file import File, convert_file_dict_to_httpx_tuples, with_content_type -from .http_client import AsyncHttpClient, HttpClient -from .jsonable_encoder import jsonable_encoder -from .pydantic_utilities import ( - IS_PYDANTIC_V2, - UniversalBaseModel, - UniversalRootModel, - parse_obj_as, - universal_field_validator, - universal_root_validator, - update_forward_refs, -) -from .query_encoder import encode_query -from .remove_none_from_dict import remove_none_from_dict -from .request_options import RequestOptions -from .serialization import FieldMetadata, convert_and_respect_annotation_metadata +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from .api_error import ApiError + from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper + from .datetime_utils import Rfc2822DateTime, parse_rfc2822_datetime, serialize_datetime + from .file import File, convert_file_dict_to_httpx_tuples, with_content_type + from .http_client import AsyncHttpClient, HttpClient + from .http_response import AsyncHttpResponse, HttpResponse + from .jsonable_encoder import jsonable_encoder + from .logging import ConsoleLogger, ILogger, LogConfig, LogLevel, Logger, create_logger + from .parse_error import ParsingError + from .pydantic_utilities import ( + IS_PYDANTIC_V2, + UniversalBaseModel, + UniversalRootModel, + parse_obj_as, + universal_field_validator, + universal_root_validator, + update_forward_refs, + ) + from .query_encoder import encode_query + from .remove_none_from_dict import remove_none_from_dict + from .request_options import RequestOptions + from .serialization import FieldMetadata, convert_and_respect_annotation_metadata +_dynamic_imports: typing.Dict[str, str] = { + "ApiError": ".api_error", + "AsyncClientWrapper": ".client_wrapper", + "AsyncHttpClient": ".http_client", + "AsyncHttpResponse": ".http_response", + "BaseClientWrapper": ".client_wrapper", + "ConsoleLogger": ".logging", + "FieldMetadata": ".serialization", + "File": ".file", + "HttpClient": ".http_client", + "HttpResponse": ".http_response", + "ILogger": ".logging", + "IS_PYDANTIC_V2": ".pydantic_utilities", + "LogConfig": ".logging", + "LogLevel": ".logging", + "Logger": ".logging", + "ParsingError": ".parse_error", + "RequestOptions": ".request_options", + "Rfc2822DateTime": ".datetime_utils", + "SyncClientWrapper": ".client_wrapper", + "UniversalBaseModel": ".pydantic_utilities", + "UniversalRootModel": ".pydantic_utilities", + "convert_and_respect_annotation_metadata": ".serialization", + "convert_file_dict_to_httpx_tuples": ".file", + "create_logger": ".logging", + "encode_query": ".query_encoder", + "jsonable_encoder": ".jsonable_encoder", + "parse_obj_as": ".pydantic_utilities", + "parse_rfc2822_datetime": ".datetime_utils", + "remove_none_from_dict": ".remove_none_from_dict", + "serialize_datetime": ".datetime_utils", + "universal_field_validator": ".pydantic_utilities", + "universal_root_validator": ".pydantic_utilities", + "update_forward_refs": ".pydantic_utilities", + "with_content_type": ".file", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = [ "ApiError", "AsyncClientWrapper", "AsyncHttpClient", + "AsyncHttpResponse", "BaseClientWrapper", + "ConsoleLogger", "FieldMetadata", "File", "HttpClient", + "HttpResponse", + "ILogger", "IS_PYDANTIC_V2", + "LogConfig", + "LogLevel", + "Logger", + "ParsingError", "RequestOptions", + "Rfc2822DateTime", "SyncClientWrapper", "UniversalBaseModel", "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "create_logger", "encode_query", "jsonable_encoder", "parse_obj_as", + "parse_rfc2822_datetime", "remove_none_from_dict", "serialize_datetime", "universal_field_validator", diff --git a/src/polytomic/core/api_error.py b/src/polytomic/core/api_error.py index 2e9fc54..6f850a6 100644 --- a/src/polytomic/core/api_error.py +++ b/src/polytomic/core/api_error.py @@ -1,15 +1,23 @@ # This file was auto-generated by Fern from our API Definition. -import typing +from typing import Any, Dict, Optional class ApiError(Exception): - status_code: typing.Optional[int] - body: typing.Any + headers: Optional[Dict[str, str]] + status_code: Optional[int] + body: Any - def __init__(self, *, status_code: typing.Optional[int] = None, body: typing.Any = None): + def __init__( + self, + *, + headers: Optional[Dict[str, str]] = None, + status_code: Optional[int] = None, + body: Any = None, + ) -> None: + self.headers = headers self.status_code = status_code self.body = body def __str__(self) -> str: - return f"status_code: {self.status_code}, body: {self.body}" + return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}" diff --git a/src/polytomic/core/client_wrapper.py b/src/polytomic/core/client_wrapper.py index 2d15ba6..8e092bf 100644 --- a/src/polytomic/core/client_wrapper.py +++ b/src/polytomic/core/client_wrapper.py @@ -1,33 +1,42 @@ # This file was auto-generated by Fern from our API Definition. import typing + import httpx -from .http_client import HttpClient -from .http_client import AsyncHttpClient +from .http_client import AsyncHttpClient, HttpClient +from .logging import LogConfig, Logger class BaseClientWrapper: def __init__( self, *, - version: typing.Optional[str] = None, + version: typing.Any, token: typing.Union[str, typing.Callable[[], str]], + headers: typing.Optional[typing.Dict[str, str]] = None, base_url: str, timeout: typing.Optional[float] = None, + logging: typing.Optional[typing.Union[LogConfig, Logger]] = None, ): self._version = version self._token = token + self._headers = headers self._base_url = base_url self._timeout = timeout + self._logging = logging def get_headers(self) -> typing.Dict[str, str]: + import platform + headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", + "X-Fern-Runtime": f"python/{platform.python_version()}", + "X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}", "X-Fern-SDK-Name": "polytomic", - "X-Fern-SDK-Version": "1.16.1", + "X-Fern-SDK-Version": "0.0.0", + **(self.get_custom_headers() or {}), } - if self._version is not None: - headers["X-Polytomic-Version"] = self._version + headers["X-Polytomic-Version"] = self._version headers["Authorization"] = f"Bearer {self._get_token()}" return headers @@ -37,6 +46,9 @@ def _get_token(self) -> str: else: return self._token() + def get_custom_headers(self) -> typing.Optional[typing.Dict[str, str]]: + return self._headers + def get_base_url(self) -> str: return self._base_url @@ -48,18 +60,23 @@ class SyncClientWrapper(BaseClientWrapper): def __init__( self, *, - version: typing.Optional[str] = None, + version: typing.Any, token: typing.Union[str, typing.Callable[[], str]], + headers: typing.Optional[typing.Dict[str, str]] = None, base_url: str, timeout: typing.Optional[float] = None, + logging: typing.Optional[typing.Union[LogConfig, Logger]] = None, httpx_client: httpx.Client, ): - super().__init__(version=version, token=token, base_url=base_url, timeout=timeout) + super().__init__( + version=version, token=token, headers=headers, base_url=base_url, timeout=timeout, logging=logging + ) self.httpx_client = HttpClient( httpx_client=httpx_client, base_headers=self.get_headers, base_timeout=self.get_timeout, base_url=self.get_base_url, + logging_config=self._logging, ) @@ -67,16 +84,31 @@ class AsyncClientWrapper(BaseClientWrapper): def __init__( self, *, - version: typing.Optional[str] = None, + version: typing.Any, token: typing.Union[str, typing.Callable[[], str]], + headers: typing.Optional[typing.Dict[str, str]] = None, base_url: str, timeout: typing.Optional[float] = None, + logging: typing.Optional[typing.Union[LogConfig, Logger]] = None, + async_token: typing.Optional[typing.Callable[[], typing.Awaitable[str]]] = None, httpx_client: httpx.AsyncClient, ): - super().__init__(version=version, token=token, base_url=base_url, timeout=timeout) + super().__init__( + version=version, token=token, headers=headers, base_url=base_url, timeout=timeout, logging=logging + ) + self._async_token = async_token self.httpx_client = AsyncHttpClient( httpx_client=httpx_client, base_headers=self.get_headers, base_timeout=self.get_timeout, base_url=self.get_base_url, + async_base_headers=self.async_get_headers, + logging_config=self._logging, ) + + async def async_get_headers(self) -> typing.Dict[str, str]: + headers = self.get_headers() + if self._async_token is not None: + token = await self._async_token() + headers["Authorization"] = f"Bearer {token}" + return headers diff --git a/src/polytomic/core/datetime_utils.py b/src/polytomic/core/datetime_utils.py index 7c9864a..a12b2ad 100644 --- a/src/polytomic/core/datetime_utils.py +++ b/src/polytomic/core/datetime_utils.py @@ -1,6 +1,48 @@ # This file was auto-generated by Fern from our API Definition. import datetime as dt +from email.utils import parsedate_to_datetime +from typing import Any + +import pydantic + +IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.") + + +def parse_rfc2822_datetime(v: Any) -> dt.datetime: + """ + Parse an RFC 2822 datetime string (e.g., "Wed, 02 Oct 2002 13:00:00 GMT") + into a datetime object. If the value is already a datetime, return it as-is. + Falls back to ISO 8601 parsing if RFC 2822 parsing fails. + """ + if isinstance(v, dt.datetime): + return v + if isinstance(v, str): + try: + return parsedate_to_datetime(v) + except Exception: + pass + # Fallback to ISO 8601 parsing + return dt.datetime.fromisoformat(v.replace("Z", "+00:00")) + raise ValueError(f"Expected str or datetime, got {type(v)}") + + +class Rfc2822DateTime(dt.datetime): + """A datetime subclass that parses RFC 2822 date strings. + + On Pydantic V1, uses __get_validators__ for pre-validation. + On Pydantic V2, uses __get_pydantic_core_schema__ for BeforeValidator-style parsing. + """ + + @classmethod + def __get_validators__(cls): # type: ignore[no-untyped-def] + yield parse_rfc2822_datetime + + @classmethod + def __get_pydantic_core_schema__(cls, _source_type: Any, _handler: Any) -> Any: # type: ignore[override] + from pydantic_core import core_schema + + return core_schema.no_info_before_validator_function(parse_rfc2822_datetime, core_schema.datetime_schema()) def serialize_datetime(v: dt.datetime) -> str: diff --git a/src/polytomic/core/force_multipart.py b/src/polytomic/core/force_multipart.py new file mode 100644 index 0000000..5440913 --- /dev/null +++ b/src/polytomic/core/force_multipart.py @@ -0,0 +1,18 @@ +# This file was auto-generated by Fern from our API Definition. + +from typing import Any, Dict + + +class ForceMultipartDict(Dict[str, Any]): + """ + A dictionary subclass that always evaluates to True in boolean contexts. + + This is used to force multipart/form-data encoding in HTTP requests even when + the dictionary is empty, which would normally evaluate to False. + """ + + def __bool__(self) -> bool: + return True + + +FORCE_MULTIPART = ForceMultipartDict() diff --git a/src/polytomic/core/http_client.py b/src/polytomic/core/http_client.py index 275a54c..ee93758 100644 --- a/src/polytomic/core/http_client.py +++ b/src/polytomic/core/http_client.py @@ -2,25 +2,25 @@ import asyncio import email.utils -import json import re import time import typing -import urllib.parse from contextlib import asynccontextmanager, contextmanager from random import random import httpx - from .file import File, convert_file_dict_to_httpx_tuples +from .force_multipart import FORCE_MULTIPART from .jsonable_encoder import jsonable_encoder +from .logging import LogConfig, Logger, create_logger from .query_encoder import encode_query -from .remove_none_from_dict import remove_none_from_dict +from .remove_none_from_dict import remove_none_from_dict as remove_none_from_dict from .request_options import RequestOptions +from httpx._types import RequestFiles -INITIAL_RETRY_DELAY_SECONDS = 0.5 -MAX_RETRY_DELAY_SECONDS = 10 -MAX_RETRY_DELAY_SECONDS_FROM_HEADER = 30 +INITIAL_RETRY_DELAY_SECONDS = 1.0 +MAX_RETRY_DELAY_SECONDS = 60.0 +JITTER_FACTOR = 0.2 # 20% random jitter def _parse_retry_after(response_headers: httpx.Headers) -> typing.Optional[float]: @@ -64,6 +64,38 @@ def _parse_retry_after(response_headers: httpx.Headers) -> typing.Optional[float return seconds +def _add_positive_jitter(delay: float) -> float: + """Add positive jitter (0-20%) to prevent thundering herd.""" + jitter_multiplier = 1 + random() * JITTER_FACTOR + return delay * jitter_multiplier + + +def _add_symmetric_jitter(delay: float) -> float: + """Add symmetric jitter (±10%) for exponential backoff.""" + jitter_multiplier = 1 + (random() - 0.5) * JITTER_FACTOR + return delay * jitter_multiplier + + +def _parse_x_ratelimit_reset(response_headers: httpx.Headers) -> typing.Optional[float]: + """ + Parse the X-RateLimit-Reset header (Unix timestamp in seconds). + Returns seconds to wait, or None if header is missing/invalid. + """ + reset_time_str = response_headers.get("x-ratelimit-reset") + if reset_time_str is None: + return None + + try: + reset_time = int(reset_time_str) + delay = reset_time - time.time() + if delay > 0: + return delay + except (ValueError, TypeError): + pass + + return None + + def _retry_timeout(response: httpx.Response, retries: int) -> float: """ Determine the amount of time to wait before retrying a request. @@ -71,17 +103,19 @@ def _retry_timeout(response: httpx.Response, retries: int) -> float: with a jitter to determine the number of seconds to wait. """ - # If the API asks us to wait a certain amount of time (and it's a reasonable amount), just do what it says. + # 1. Check Retry-After header first retry_after = _parse_retry_after(response.headers) - if retry_after is not None and retry_after <= MAX_RETRY_DELAY_SECONDS_FROM_HEADER: - return retry_after + if retry_after is not None and retry_after > 0: + return min(retry_after, MAX_RETRY_DELAY_SECONDS) - # Apply exponential backoff, capped at MAX_RETRY_DELAY_SECONDS. - retry_delay = min(INITIAL_RETRY_DELAY_SECONDS * pow(2.0, retries), MAX_RETRY_DELAY_SECONDS) + # 2. Check X-RateLimit-Reset header (with positive jitter) + ratelimit_reset = _parse_x_ratelimit_reset(response.headers) + if ratelimit_reset is not None: + return _add_positive_jitter(min(ratelimit_reset, MAX_RETRY_DELAY_SECONDS)) - # Add a randomness / jitter to the retry delay to avoid overwhelming the server with retries. - timeout = retry_delay * (1 - 0.25 * random()) - return timeout if timeout >= 0 else 0 + # 3. Fall back to exponential backoff (with symmetric jitter) + backoff = min(INITIAL_RETRY_DELAY_SECONDS * pow(2.0, retries), MAX_RETRY_DELAY_SECONDS) + return _add_symmetric_jitter(backoff) def _should_retry(response: httpx.Response) -> bool: @@ -89,6 +123,71 @@ def _should_retry(response: httpx.Response) -> bool: return response.status_code >= 500 or response.status_code in retryable_400s +_SENSITIVE_HEADERS = frozenset( + { + "authorization", + "www-authenticate", + "x-api-key", + "api-key", + "apikey", + "x-api-token", + "x-auth-token", + "auth-token", + "cookie", + "set-cookie", + "proxy-authorization", + "proxy-authenticate", + "x-csrf-token", + "x-xsrf-token", + "x-session-token", + "x-access-token", + } +) + + +def _redact_headers(headers: typing.Dict[str, str]) -> typing.Dict[str, str]: + return {k: ("[REDACTED]" if k.lower() in _SENSITIVE_HEADERS else v) for k, v in headers.items()} + + +def _build_url(base_url: str, path: typing.Optional[str]) -> str: + """ + Build a full URL by joining a base URL with a path. + + This function correctly handles base URLs that contain path prefixes (e.g., tenant-based URLs) + by using string concatenation instead of urllib.parse.urljoin(), which would incorrectly + strip path components when the path starts with '/'. + + Example: + >>> _build_url("https://cloud.example.com/org/tenant/api", "/users") + 'https://cloud.example.com/org/tenant/api/users' + + Args: + base_url: The base URL, which may contain path prefixes. + path: The path to append. Can be None or empty string. + + Returns: + The full URL with base_url and path properly joined. + """ + if not path: + return base_url + return f"{base_url.rstrip('/')}/{path.lstrip('/')}" + + +def _maybe_filter_none_from_multipart_data( + data: typing.Optional[typing.Any], + request_files: typing.Optional[RequestFiles], + force_multipart: typing.Optional[bool], +) -> typing.Optional[typing.Any]: + """ + Filter None values from data body for multipart/form requests. + This prevents httpx from converting None to empty strings in multipart encoding. + Only applies when files are present or force_multipart is True. + """ + if data is not None and isinstance(data, typing.Mapping) and (request_files or force_multipart): + return remove_none_from_dict(data) + return data + + def remove_omit_from_dict( original: typing.Dict[str, typing.Optional[typing.Any]], omit: typing.Optional[typing.Any], @@ -143,8 +242,19 @@ def get_request_body( # If both data and json are None, we send json data in the event extra properties are specified json_body = maybe_filter_request_body(json, request_options, omit) - # If you have an empty JSON body, you should just send None - return (json_body if json_body != {} else None), data_body if data_body != {} else None + has_additional_body_parameters = bool( + request_options is not None and request_options.get("additional_body_parameters") + ) + + # Only collapse empty dict to None when the body was not explicitly provided + # and there are no additional body parameters. This preserves explicit empty + # bodies (e.g., when an endpoint has a request body type but all fields are optional). + if json_body == {} and json is None and not has_additional_body_parameters: + json_body = None + if data_body == {} and data is None and not has_additional_body_parameters: + data_body = None + + return json_body, data_body class HttpClient: @@ -155,11 +265,13 @@ def __init__( base_timeout: typing.Callable[[], typing.Optional[float]], base_headers: typing.Callable[[], typing.Dict[str, str]], base_url: typing.Optional[typing.Callable[[], str]] = None, + logging_config: typing.Optional[typing.Union[LogConfig, Logger]] = None, ): self.base_url = base_url self.base_timeout = base_timeout self.base_headers = base_headers self.httpx_client = httpx_client + self.logger = create_logger(logging_config) def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str: base_url = maybe_base_url @@ -180,11 +292,17 @@ def request( json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, - files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + files: typing.Optional[ + typing.Union[ + typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]], + typing.List[typing.Tuple[str, File]], + ] + ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, - retries: int = 2, + retries: int = 0, omit: typing.Optional[typing.Any] = None, + force_multipart: typing.Optional[bool] = None, ) -> httpx.Response: base_url = self.get_base_url(base_url) timeout = ( @@ -195,49 +313,72 @@ def request( json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) - response = self.httpx_client.request( - method=method, - url=urllib.parse.urljoin(f"{base_url}/", path), - headers=jsonable_encoder( + request_files: typing.Optional[RequestFiles] = ( + convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) + if (files is not None and files is not omit and isinstance(files, dict)) + else None + ) + + if (request_files is None or len(request_files) == 0) and force_multipart: + request_files = FORCE_MULTIPART + + data_body = _maybe_filter_none_from_multipart_data(data_body, request_files, force_multipart) + + # Compute encoded params separately to avoid passing empty list to httpx + # (httpx strips existing query params from URL when params=[] is passed) + _encoded_params = encode_query( + jsonable_encoder( remove_none_from_dict( - { - **self.base_headers(), - **(headers if headers is not None else {}), - **(request_options.get("additional_headers", {}) or {} if request_options is not None else {}), - } - ) - ), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - remove_omit_from_dict( - { - **(params if params is not None else {}), - **( - request_options.get("additional_query_parameters", {}) or {} - if request_options is not None - else {} - ), - }, - omit, - ) + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) or {} + if request_options is not None + else {} + ), + }, + omit, ) ) - ), + ) + ) + + _request_url = _build_url(base_url, path) + _request_headers = jsonable_encoder( + remove_none_from_dict( + { + **self.base_headers(), + **(headers if headers is not None else {}), + **(request_options.get("additional_headers", {}) or {} if request_options is not None else {}), + } + ) + ) + + if self.logger.is_debug(): + self.logger.debug( + "Making HTTP request", + method=method, + url=_request_url, + headers=_redact_headers(_request_headers), + has_body=json_body is not None or data_body is not None, + ) + + response = self.httpx_client.request( + method=method, + url=_request_url, + headers=_request_headers, + params=_encoded_params if _encoded_params else None, json=json_body, data=data_body, content=content, - files=( - convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) - if (files is not None and files is not omit) - else None - ), + files=request_files, timeout=timeout, ) - max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0 + max_retries: int = request_options.get("max_retries", 2) if request_options is not None else 2 if _should_retry(response=response): - if max_retries > retries: + if retries < max_retries: time.sleep(_retry_timeout(response=response, retries=retries)) return self.request( path=path, @@ -253,6 +394,24 @@ def request( omit=omit, ) + if self.logger.is_debug(): + if 200 <= response.status_code < 400: + self.logger.debug( + "HTTP request succeeded", + method=method, + url=_request_url, + status_code=response.status_code, + ) + + if self.logger.is_error(): + if response.status_code >= 400: + self.logger.error( + "HTTP request failed with error status", + method=method, + url=_request_url, + status_code=response.status_code, + ) + return response @contextmanager @@ -266,11 +425,17 @@ def stream( json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, - files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + files: typing.Optional[ + typing.Union[ + typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]], + typing.List[typing.Tuple[str, File]], + ] + ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, - retries: int = 2, + retries: int = 0, omit: typing.Optional[typing.Any] = None, + force_multipart: typing.Optional[bool] = None, ) -> typing.Iterator[httpx.Response]: base_url = self.get_base_url(base_url) timeout = ( @@ -279,45 +444,67 @@ def stream( else self.base_timeout() ) + request_files: typing.Optional[RequestFiles] = ( + convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) + if (files is not None and files is not omit and isinstance(files, dict)) + else None + ) + + if (request_files is None or len(request_files) == 0) and force_multipart: + request_files = FORCE_MULTIPART + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) - with self.httpx_client.stream( - method=method, - url=urllib.parse.urljoin(f"{base_url}/", path), - headers=jsonable_encoder( + data_body = _maybe_filter_none_from_multipart_data(data_body, request_files, force_multipart) + + # Compute encoded params separately to avoid passing empty list to httpx + # (httpx strips existing query params from URL when params=[] is passed) + _encoded_params = encode_query( + jsonable_encoder( remove_none_from_dict( - { - **self.base_headers(), - **(headers if headers is not None else {}), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - remove_omit_from_dict( - { - **(params if params is not None else {}), - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - }, - omit, - ) + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + }, + omit, ) ) - ), + ) + ) + + _request_url = _build_url(base_url, path) + _request_headers = jsonable_encoder( + remove_none_from_dict( + { + **self.base_headers(), + **(headers if headers is not None else {}), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ) + + if self.logger.is_debug(): + self.logger.debug( + "Making streaming HTTP request", + method=method, + url=_request_url, + headers=_redact_headers(_request_headers), + ) + + with self.httpx_client.stream( + method=method, + url=_request_url, + headers=_request_headers, + params=_encoded_params if _encoded_params else None, json=json_body, data=data_body, content=content, - files=( - convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) - if (files is not None and files is not omit) - else None - ), + files=request_files, timeout=timeout, ) as stream: yield stream @@ -331,11 +518,20 @@ def __init__( base_timeout: typing.Callable[[], typing.Optional[float]], base_headers: typing.Callable[[], typing.Dict[str, str]], base_url: typing.Optional[typing.Callable[[], str]] = None, + async_base_headers: typing.Optional[typing.Callable[[], typing.Awaitable[typing.Dict[str, str]]]] = None, + logging_config: typing.Optional[typing.Union[LogConfig, Logger]] = None, ): self.base_url = base_url self.base_timeout = base_timeout self.base_headers = base_headers + self.async_base_headers = async_base_headers self.httpx_client = httpx_client + self.logger = create_logger(logging_config) + + async def _get_headers(self) -> typing.Dict[str, str]: + if self.async_base_headers is not None: + return await self.async_base_headers() + return self.base_headers() def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str: base_url = maybe_base_url @@ -356,11 +552,17 @@ async def request( json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, - files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + files: typing.Optional[ + typing.Union[ + typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]], + typing.List[typing.Tuple[str, File]], + ] + ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, - retries: int = 2, + retries: int = 0, omit: typing.Optional[typing.Any] = None, + force_multipart: typing.Optional[bool] = None, ) -> httpx.Response: base_url = self.get_base_url(base_url) timeout = ( @@ -369,52 +571,77 @@ async def request( else self.base_timeout() ) + request_files: typing.Optional[RequestFiles] = ( + convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) + if (files is not None and files is not omit and isinstance(files, dict)) + else None + ) + + if (request_files is None or len(request_files) == 0) and force_multipart: + request_files = FORCE_MULTIPART + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) - # Add the input to each of these and do None-safety checks - response = await self.httpx_client.request( - method=method, - url=urllib.parse.urljoin(f"{base_url}/", path), - headers=jsonable_encoder( + data_body = _maybe_filter_none_from_multipart_data(data_body, request_files, force_multipart) + + # Get headers (supports async token providers) + _headers = await self._get_headers() + + # Compute encoded params separately to avoid passing empty list to httpx + # (httpx strips existing query params from URL when params=[] is passed) + _encoded_params = encode_query( + jsonable_encoder( remove_none_from_dict( - { - **self.base_headers(), - **(headers if headers is not None else {}), - **(request_options.get("additional_headers", {}) or {} if request_options is not None else {}), - } - ) - ), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - remove_omit_from_dict( - { - **(params if params is not None else {}), - **( - request_options.get("additional_query_parameters", {}) or {} - if request_options is not None - else {} - ), - }, - omit, - ) + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) or {} + if request_options is not None + else {} + ), + }, + omit, ) ) - ), + ) + ) + + _request_url = _build_url(base_url, path) + _request_headers = jsonable_encoder( + remove_none_from_dict( + { + **_headers, + **(headers if headers is not None else {}), + **(request_options.get("additional_headers", {}) or {} if request_options is not None else {}), + } + ) + ) + + if self.logger.is_debug(): + self.logger.debug( + "Making HTTP request", + method=method, + url=_request_url, + headers=_redact_headers(_request_headers), + has_body=json_body is not None or data_body is not None, + ) + + response = await self.httpx_client.request( + method=method, + url=_request_url, + headers=_request_headers, + params=_encoded_params if _encoded_params else None, json=json_body, data=data_body, content=content, - files=( - convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) - if files is not None - else None - ), + files=request_files, timeout=timeout, ) - max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0 + max_retries: int = request_options.get("max_retries", 2) if request_options is not None else 2 if _should_retry(response=response): - if max_retries > retries: + if retries < max_retries: await asyncio.sleep(_retry_timeout(response=response, retries=retries)) return await self.request( path=path, @@ -429,6 +656,25 @@ async def request( retries=retries + 1, omit=omit, ) + + if self.logger.is_debug(): + if 200 <= response.status_code < 400: + self.logger.debug( + "HTTP request succeeded", + method=method, + url=_request_url, + status_code=response.status_code, + ) + + if self.logger.is_error(): + if response.status_code >= 400: + self.logger.error( + "HTTP request failed with error status", + method=method, + url=_request_url, + status_code=response.status_code, + ) + return response @asynccontextmanager @@ -442,11 +688,17 @@ async def stream( json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, - files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + files: typing.Optional[ + typing.Union[ + typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]], + typing.List[typing.Tuple[str, File]], + ] + ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, - retries: int = 2, + retries: int = 0, omit: typing.Optional[typing.Any] = None, + force_multipart: typing.Optional[bool] = None, ) -> typing.AsyncIterator[httpx.Response]: base_url = self.get_base_url(base_url) timeout = ( @@ -455,45 +707,70 @@ async def stream( else self.base_timeout() ) + request_files: typing.Optional[RequestFiles] = ( + convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) + if (files is not None and files is not omit and isinstance(files, dict)) + else None + ) + + if (request_files is None or len(request_files) == 0) and force_multipart: + request_files = FORCE_MULTIPART + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) - async with self.httpx_client.stream( - method=method, - url=urllib.parse.urljoin(f"{base_url}/", path), - headers=jsonable_encoder( + data_body = _maybe_filter_none_from_multipart_data(data_body, request_files, force_multipart) + + # Get headers (supports async token providers) + _headers = await self._get_headers() + + # Compute encoded params separately to avoid passing empty list to httpx + # (httpx strips existing query params from URL when params=[] is passed) + _encoded_params = encode_query( + jsonable_encoder( remove_none_from_dict( - { - **self.base_headers(), - **(headers if headers is not None else {}), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - remove_omit_from_dict( - { - **(params if params is not None else {}), - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - }, - omit=omit, - ) + remove_omit_from_dict( + { + **(params if params is not None else {}), + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + }, + omit=omit, ) ) - ), + ) + ) + + _request_url = _build_url(base_url, path) + _request_headers = jsonable_encoder( + remove_none_from_dict( + { + **_headers, + **(headers if headers is not None else {}), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ) + + if self.logger.is_debug(): + self.logger.debug( + "Making streaming HTTP request", + method=method, + url=_request_url, + headers=_redact_headers(_request_headers), + ) + + async with self.httpx_client.stream( + method=method, + url=_request_url, + headers=_request_headers, + params=_encoded_params if _encoded_params else None, json=json_body, data=data_body, content=content, - files=( - convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) - if files is not None - else None - ), + files=request_files, timeout=timeout, ) as stream: yield stream diff --git a/src/polytomic/core/http_response.py b/src/polytomic/core/http_response.py new file mode 100644 index 0000000..00bb109 --- /dev/null +++ b/src/polytomic/core/http_response.py @@ -0,0 +1,59 @@ +# This file was auto-generated by Fern from our API Definition. + +from typing import Dict, Generic, TypeVar + +import httpx + +# Generic to represent the underlying type of the data wrapped by the HTTP response. +T = TypeVar("T") + + +class BaseHttpResponse: + """Minimalist HTTP response wrapper that exposes response headers and status code.""" + + _response: httpx.Response + + def __init__(self, response: httpx.Response): + self._response = response + + @property + def headers(self) -> Dict[str, str]: + return dict(self._response.headers) + + @property + def status_code(self) -> int: + return self._response.status_code + + +class HttpResponse(Generic[T], BaseHttpResponse): + """HTTP response wrapper that exposes response headers and data.""" + + _data: T + + def __init__(self, response: httpx.Response, data: T): + super().__init__(response) + self._data = data + + @property + def data(self) -> T: + return self._data + + def close(self) -> None: + self._response.close() + + +class AsyncHttpResponse(Generic[T], BaseHttpResponse): + """HTTP response wrapper that exposes response headers and data.""" + + _data: T + + def __init__(self, response: httpx.Response, data: T): + super().__init__(response) + self._data = data + + @property + def data(self) -> T: + return self._data + + async def close(self) -> None: + await self._response.aclose() diff --git a/src/polytomic/core/http_sse/__init__.py b/src/polytomic/core/http_sse/__init__.py new file mode 100644 index 0000000..730e5a3 --- /dev/null +++ b/src/polytomic/core/http_sse/__init__.py @@ -0,0 +1,42 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from ._api import EventSource, aconnect_sse, connect_sse + from ._exceptions import SSEError + from ._models import ServerSentEvent +_dynamic_imports: typing.Dict[str, str] = { + "EventSource": "._api", + "SSEError": "._exceptions", + "ServerSentEvent": "._models", + "aconnect_sse": "._api", + "connect_sse": "._api", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + + +__all__ = ["EventSource", "SSEError", "ServerSentEvent", "aconnect_sse", "connect_sse"] diff --git a/src/polytomic/core/http_sse/_api.py b/src/polytomic/core/http_sse/_api.py new file mode 100644 index 0000000..f900b3b --- /dev/null +++ b/src/polytomic/core/http_sse/_api.py @@ -0,0 +1,112 @@ +# This file was auto-generated by Fern from our API Definition. + +import re +from contextlib import asynccontextmanager, contextmanager +from typing import Any, AsyncGenerator, AsyncIterator, Iterator, cast + +import httpx +from ._decoders import SSEDecoder +from ._exceptions import SSEError +from ._models import ServerSentEvent + + +class EventSource: + def __init__(self, response: httpx.Response) -> None: + self._response = response + + def _check_content_type(self) -> None: + content_type = self._response.headers.get("content-type", "").partition(";")[0] + if "text/event-stream" not in content_type: + raise SSEError( + f"Expected response header Content-Type to contain 'text/event-stream', got {content_type!r}" + ) + + def _get_charset(self) -> str: + """Extract charset from Content-Type header, fallback to UTF-8.""" + content_type = self._response.headers.get("content-type", "") + + # Parse charset parameter using regex + charset_match = re.search(r"charset=([^;\s]+)", content_type, re.IGNORECASE) + if charset_match: + charset = charset_match.group(1).strip("\"'") + # Validate that it's a known encoding + try: + # Test if the charset is valid by trying to encode/decode + "test".encode(charset).decode(charset) + return charset + except (LookupError, UnicodeError): + # If charset is invalid, fall back to UTF-8 + pass + + # Default to UTF-8 if no charset specified or invalid charset + return "utf-8" + + @property + def response(self) -> httpx.Response: + return self._response + + def iter_sse(self) -> Iterator[ServerSentEvent]: + self._check_content_type() + decoder = SSEDecoder() + charset = self._get_charset() + + buffer = "" + for chunk in self._response.iter_bytes(): + # Decode chunk using detected charset + text_chunk = chunk.decode(charset, errors="replace") + buffer += text_chunk + + # Process complete lines + while "\n" in buffer: + line, buffer = buffer.split("\n", 1) + line = line.rstrip("\r") + sse = decoder.decode(line) + # when we reach a "\n\n" => line = '' + # => decoder will attempt to return an SSE Event + if sse is not None: + yield sse + + # Process any remaining data in buffer + if buffer.strip(): + line = buffer.rstrip("\r") + sse = decoder.decode(line) + if sse is not None: + yield sse + + async def aiter_sse(self) -> AsyncGenerator[ServerSentEvent, None]: + self._check_content_type() + decoder = SSEDecoder() + lines = cast(AsyncGenerator[str, None], self._response.aiter_lines()) + try: + async for line in lines: + line = line.rstrip("\n") + sse = decoder.decode(line) + if sse is not None: + yield sse + finally: + await lines.aclose() + + +@contextmanager +def connect_sse(client: httpx.Client, method: str, url: str, **kwargs: Any) -> Iterator[EventSource]: + headers = kwargs.pop("headers", {}) + headers["Accept"] = "text/event-stream" + headers["Cache-Control"] = "no-store" + + with client.stream(method, url, headers=headers, **kwargs) as response: + yield EventSource(response) + + +@asynccontextmanager +async def aconnect_sse( + client: httpx.AsyncClient, + method: str, + url: str, + **kwargs: Any, +) -> AsyncIterator[EventSource]: + headers = kwargs.pop("headers", {}) + headers["Accept"] = "text/event-stream" + headers["Cache-Control"] = "no-store" + + async with client.stream(method, url, headers=headers, **kwargs) as response: + yield EventSource(response) diff --git a/src/polytomic/core/http_sse/_decoders.py b/src/polytomic/core/http_sse/_decoders.py new file mode 100644 index 0000000..339b089 --- /dev/null +++ b/src/polytomic/core/http_sse/_decoders.py @@ -0,0 +1,61 @@ +# This file was auto-generated by Fern from our API Definition. + +from typing import List, Optional + +from ._models import ServerSentEvent + + +class SSEDecoder: + def __init__(self) -> None: + self._event = "" + self._data: List[str] = [] + self._last_event_id = "" + self._retry: Optional[int] = None + + def decode(self, line: str) -> Optional[ServerSentEvent]: + # See: https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation # noqa: E501 + + if not line: + if not self._event and not self._data and not self._last_event_id and self._retry is None: + return None + + sse = ServerSentEvent( + event=self._event, + data="\n".join(self._data), + id=self._last_event_id, + retry=self._retry, + ) + + # NOTE: as per the SSE spec, do not reset last_event_id. + self._event = "" + self._data = [] + self._retry = None + + return sse + + if line.startswith(":"): + return None + + fieldname, _, value = line.partition(":") + + if value.startswith(" "): + value = value[1:] + + if fieldname == "event": + self._event = value + elif fieldname == "data": + self._data.append(value) + elif fieldname == "id": + if "\0" in value: + pass + else: + self._last_event_id = value + elif fieldname == "retry": + try: + self._retry = int(value) + except (TypeError, ValueError): + pass + else: + pass # Field is ignored. + + return None diff --git a/src/polytomic/core/http_sse/_exceptions.py b/src/polytomic/core/http_sse/_exceptions.py new file mode 100644 index 0000000..81605a8 --- /dev/null +++ b/src/polytomic/core/http_sse/_exceptions.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +import httpx + + +class SSEError(httpx.TransportError): + pass diff --git a/src/polytomic/core/http_sse/_models.py b/src/polytomic/core/http_sse/_models.py new file mode 100644 index 0000000..1af57f8 --- /dev/null +++ b/src/polytomic/core/http_sse/_models.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import json +from dataclasses import dataclass +from typing import Any, Optional + + +@dataclass(frozen=True) +class ServerSentEvent: + event: str = "message" + data: str = "" + id: str = "" + retry: Optional[int] = None + + def json(self) -> Any: + """Parse the data field as JSON.""" + return json.loads(self.data) diff --git a/src/polytomic/core/jsonable_encoder.py b/src/polytomic/core/jsonable_encoder.py index 1b631e9..f8beaea 100644 --- a/src/polytomic/core/jsonable_encoder.py +++ b/src/polytomic/core/jsonable_encoder.py @@ -17,7 +17,6 @@ from typing import Any, Callable, Dict, List, Optional, Set, Union import pydantic - from .datetime_utils import serialize_datetime from .pydantic_utilities import ( IS_PYDANTIC_V2, @@ -31,6 +30,10 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any: custom_encoder = custom_encoder or {} + # Generated SDKs use Ellipsis (`...`) as the sentinel value for "OMIT". + # OMIT values should be excluded from serialized payloads. + if obj is Ellipsis: + return None if custom_encoder: if type(obj) in custom_encoder: return custom_encoder[type(obj)](obj) @@ -71,6 +74,8 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any] allowed_keys = set(obj.keys()) for key, value in obj.items(): if key in allowed_keys: + if value is Ellipsis: + continue encoded_key = jsonable_encoder(key, custom_encoder=custom_encoder) encoded_value = jsonable_encoder(value, custom_encoder=custom_encoder) encoded_dict[encoded_key] = encoded_value @@ -78,6 +83,8 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any] if isinstance(obj, (list, set, frozenset, GeneratorType, tuple)): encoded_list = [] for item in obj: + if item is Ellipsis: + continue encoded_list.append(jsonable_encoder(item, custom_encoder=custom_encoder)) return encoded_list diff --git a/src/polytomic/core/logging.py b/src/polytomic/core/logging.py new file mode 100644 index 0000000..e5e5724 --- /dev/null +++ b/src/polytomic/core/logging.py @@ -0,0 +1,107 @@ +# This file was auto-generated by Fern from our API Definition. + +import logging +import typing + +LogLevel = typing.Literal["debug", "info", "warn", "error"] + +_LOG_LEVEL_MAP: typing.Dict[LogLevel, int] = { + "debug": 1, + "info": 2, + "warn": 3, + "error": 4, +} + + +class ILogger(typing.Protocol): + def debug(self, message: str, **kwargs: typing.Any) -> None: ... + def info(self, message: str, **kwargs: typing.Any) -> None: ... + def warn(self, message: str, **kwargs: typing.Any) -> None: ... + def error(self, message: str, **kwargs: typing.Any) -> None: ... + + +class ConsoleLogger: + _logger: logging.Logger + + def __init__(self) -> None: + self._logger = logging.getLogger("fern") + if not self._logger.handlers: + handler = logging.StreamHandler() + handler.setFormatter(logging.Formatter("%(levelname)s - %(message)s")) + self._logger.addHandler(handler) + self._logger.setLevel(logging.DEBUG) + + def debug(self, message: str, **kwargs: typing.Any) -> None: + self._logger.debug(message, extra=kwargs) + + def info(self, message: str, **kwargs: typing.Any) -> None: + self._logger.info(message, extra=kwargs) + + def warn(self, message: str, **kwargs: typing.Any) -> None: + self._logger.warning(message, extra=kwargs) + + def error(self, message: str, **kwargs: typing.Any) -> None: + self._logger.error(message, extra=kwargs) + + +class LogConfig(typing.TypedDict, total=False): + level: LogLevel + logger: ILogger + silent: bool + + +class Logger: + _level: int + _logger: ILogger + _silent: bool + + def __init__(self, *, level: LogLevel, logger: ILogger, silent: bool) -> None: + self._level = _LOG_LEVEL_MAP[level] + self._logger = logger + self._silent = silent + + def _should_log(self, level: LogLevel) -> bool: + return not self._silent and self._level <= _LOG_LEVEL_MAP[level] + + def is_debug(self) -> bool: + return self._should_log("debug") + + def is_info(self) -> bool: + return self._should_log("info") + + def is_warn(self) -> bool: + return self._should_log("warn") + + def is_error(self) -> bool: + return self._should_log("error") + + def debug(self, message: str, **kwargs: typing.Any) -> None: + if self.is_debug(): + self._logger.debug(message, **kwargs) + + def info(self, message: str, **kwargs: typing.Any) -> None: + if self.is_info(): + self._logger.info(message, **kwargs) + + def warn(self, message: str, **kwargs: typing.Any) -> None: + if self.is_warn(): + self._logger.warn(message, **kwargs) + + def error(self, message: str, **kwargs: typing.Any) -> None: + if self.is_error(): + self._logger.error(message, **kwargs) + + +_default_logger: Logger = Logger(level="info", logger=ConsoleLogger(), silent=True) + + +def create_logger(config: typing.Optional[typing.Union[LogConfig, Logger]] = None) -> Logger: + if config is None: + return _default_logger + if isinstance(config, Logger): + return config + return Logger( + level=config.get("level", "info"), + logger=config.get("logger", ConsoleLogger()), + silent=config.get("silent", True), + ) diff --git a/src/polytomic/core/parse_error.py b/src/polytomic/core/parse_error.py new file mode 100644 index 0000000..4527c6a --- /dev/null +++ b/src/polytomic/core/parse_error.py @@ -0,0 +1,36 @@ +# This file was auto-generated by Fern from our API Definition. + +from typing import Any, Dict, Optional + + +class ParsingError(Exception): + """ + Raised when the SDK fails to parse/validate a response from the server. + This typically indicates that the server returned a response whose shape + does not match the expected schema. + """ + + headers: Optional[Dict[str, str]] + status_code: Optional[int] + body: Any + cause: Optional[Exception] + + def __init__( + self, + *, + headers: Optional[Dict[str, str]] = None, + status_code: Optional[int] = None, + body: Any = None, + cause: Optional[Exception] = None, + ) -> None: + self.headers = headers + self.status_code = status_code + self.body = body + self.cause = cause + super().__init__() + if cause is not None: + self.__cause__ = cause + + def __str__(self) -> str: + cause_str = f", cause: {self.cause}" if self.cause is not None else "" + return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}{cause_str}" diff --git a/src/polytomic/core/pydantic_utilities.py b/src/polytomic/core/pydantic_utilities.py index ca1f479..fea3a08 100644 --- a/src/polytomic/core/pydantic_utilities.py +++ b/src/polytomic/core/pydantic_utilities.py @@ -2,90 +2,406 @@ # nopycln: file import datetime as dt -import typing +import inspect +import json +import logging from collections import defaultdict +from dataclasses import asdict +from typing import ( + TYPE_CHECKING, + Any, + Callable, + ClassVar, + Dict, + List, + Mapping, + Optional, + Set, + Tuple, + Type, + TypeVar, + Union, + cast, +) +import pydantic import typing_extensions +from pydantic.fields import FieldInfo as _FieldInfo -import pydantic +_logger = logging.getLogger(__name__) -from .datetime_utils import serialize_datetime -from .serialization import convert_and_respect_annotation_metadata +if TYPE_CHECKING: + from .http_sse._models import ServerSentEvent IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.") if IS_PYDANTIC_V2: - # isort will try to reformat the comments on these imports, which breaks mypy - # isort: off - from pydantic.v1.datetime_parse import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 - parse_date as parse_date, + _datetime_adapter = pydantic.TypeAdapter(dt.datetime) # type: ignore[attr-defined] + _date_adapter = pydantic.TypeAdapter(dt.date) # type: ignore[attr-defined] + + def parse_datetime(value: Any) -> dt.datetime: # type: ignore[misc] + if isinstance(value, dt.datetime): + return value + return _datetime_adapter.validate_python(value) + + def parse_date(value: Any) -> dt.date: # type: ignore[misc] + if isinstance(value, dt.datetime): + return value.date() + if isinstance(value, dt.date): + return value + return _date_adapter.validate_python(value) + + # Avoid importing from pydantic.v1 to maintain Python 3.14 compatibility. + from typing import get_args as get_args # type: ignore[assignment] + from typing import get_origin as get_origin # type: ignore[assignment] + + def is_literal_type(tp: Optional[Type[Any]]) -> bool: # type: ignore[misc] + return typing_extensions.get_origin(tp) is typing_extensions.Literal + + def is_union(tp: Optional[Type[Any]]) -> bool: # type: ignore[misc] + return tp is Union or typing_extensions.get_origin(tp) is Union # type: ignore[comparison-overlap] + + # Inline encoders_by_type to avoid importing from pydantic.v1.json + import re as _re + from collections import deque as _deque + from decimal import Decimal as _Decimal + from enum import Enum as _Enum + from ipaddress import ( + IPv4Address as _IPv4Address, ) - from pydantic.v1.datetime_parse import ( # pyright: ignore[reportMissingImports] # Pydantic v2 - parse_datetime as parse_datetime, + from ipaddress import ( + IPv4Interface as _IPv4Interface, ) - from pydantic.v1.json import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 - ENCODERS_BY_TYPE as encoders_by_type, + from ipaddress import ( + IPv4Network as _IPv4Network, ) - from pydantic.v1.typing import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 - get_args as get_args, + from ipaddress import ( + IPv6Address as _IPv6Address, ) - from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 - get_origin as get_origin, + from ipaddress import ( + IPv6Interface as _IPv6Interface, ) - from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 - is_literal_type as is_literal_type, + from ipaddress import ( + IPv6Network as _IPv6Network, ) - from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 - is_union as is_union, - ) - from pydantic.v1.fields import ModelField as ModelField # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 + from pathlib import Path as _Path + from types import GeneratorType as _GeneratorType + from uuid import UUID as _UUID + + from pydantic.fields import FieldInfo as ModelField # type: ignore[no-redef, assignment] + + def _decimal_encoder(dec_value: Any) -> Any: + if dec_value.as_tuple().exponent >= 0: + return int(dec_value) + return float(dec_value) + + encoders_by_type: Dict[Type[Any], Callable[[Any], Any]] = { # type: ignore[no-redef] + bytes: lambda o: o.decode(), + dt.date: lambda o: o.isoformat(), + dt.datetime: lambda o: o.isoformat(), + dt.time: lambda o: o.isoformat(), + dt.timedelta: lambda td: td.total_seconds(), + _Decimal: _decimal_encoder, + _Enum: lambda o: o.value, + frozenset: list, + _deque: list, + _GeneratorType: list, + _IPv4Address: str, + _IPv4Interface: str, + _IPv4Network: str, + _IPv6Address: str, + _IPv6Interface: str, + _IPv6Network: str, + _Path: str, + _re.Pattern: lambda o: o.pattern, + set: list, + _UUID: str, + } else: - from pydantic.datetime_parse import parse_date as parse_date # type: ignore # Pydantic v1 - from pydantic.datetime_parse import parse_datetime as parse_datetime # type: ignore # Pydantic v1 - from pydantic.fields import ModelField as ModelField # type: ignore # Pydantic v1 - from pydantic.json import ENCODERS_BY_TYPE as encoders_by_type # type: ignore # Pydantic v1 - from pydantic.typing import get_args as get_args # type: ignore # Pydantic v1 - from pydantic.typing import get_origin as get_origin # type: ignore # Pydantic v1 - from pydantic.typing import is_literal_type as is_literal_type # type: ignore # Pydantic v1 - from pydantic.typing import is_union as is_union # type: ignore # Pydantic v1 - - # isort: on - - -T = typing.TypeVar("T") -Model = typing.TypeVar("Model", bound=pydantic.BaseModel) + from pydantic.datetime_parse import parse_date as parse_date # type: ignore[no-redef] + from pydantic.datetime_parse import parse_datetime as parse_datetime # type: ignore[no-redef] + from pydantic.fields import ModelField as ModelField # type: ignore[attr-defined, no-redef, assignment] + from pydantic.json import ENCODERS_BY_TYPE as encoders_by_type # type: ignore[no-redef] + from pydantic.typing import get_args as get_args # type: ignore[no-redef] + from pydantic.typing import get_origin as get_origin # type: ignore[no-redef] + from pydantic.typing import is_literal_type as is_literal_type # type: ignore[no-redef, assignment] + from pydantic.typing import is_union as is_union # type: ignore[no-redef] +from .datetime_utils import serialize_datetime +from .serialization import convert_and_respect_annotation_metadata +from typing_extensions import TypeAlias + +T = TypeVar("T") +Model = TypeVar("Model", bound=pydantic.BaseModel) + + +def _get_discriminator_and_variants(type_: Type[Any]) -> Tuple[Optional[str], Optional[List[Type[Any]]]]: + """ + Extract the discriminator field name and union variants from a discriminated union type. + Supports Annotated[Union[...], Field(discriminator=...)] patterns. + Returns (discriminator, variants) or (None, None) if not a discriminated union. + """ + origin = typing_extensions.get_origin(type_) + + if origin is typing_extensions.Annotated: + args = typing_extensions.get_args(type_) + if len(args) >= 2: + inner_type = args[0] + # Check annotations for discriminator + discriminator = None + for annotation in args[1:]: + if hasattr(annotation, "discriminator"): + discriminator = getattr(annotation, "discriminator", None) + break + + if discriminator: + inner_origin = typing_extensions.get_origin(inner_type) + if inner_origin is Union: + variants = list(typing_extensions.get_args(inner_type)) + return discriminator, variants + return None, None + + +def _get_field_annotation(model: Type[Any], field_name: str) -> Optional[Type[Any]]: + """Get the type annotation of a field from a Pydantic model.""" + if IS_PYDANTIC_V2: + fields = getattr(model, "model_fields", {}) + field_info = fields.get(field_name) + if field_info: + return cast(Optional[Type[Any]], field_info.annotation) + else: + fields = getattr(model, "__fields__", {}) + field_info = fields.get(field_name) + if field_info: + return cast(Optional[Type[Any]], field_info.outer_type_) + return None + + +def _find_variant_by_discriminator( + variants: List[Type[Any]], + discriminator: str, + discriminator_value: Any, +) -> Optional[Type[Any]]: + """Find the union variant that matches the discriminator value.""" + for variant in variants: + if not (inspect.isclass(variant) and issubclass(variant, pydantic.BaseModel)): + continue + + disc_annotation = _get_field_annotation(variant, discriminator) + if disc_annotation and is_literal_type(disc_annotation): + literal_args = get_args(disc_annotation) + if literal_args and literal_args[0] == discriminator_value: + return variant + return None + + +def _is_string_type(type_: Type[Any]) -> bool: + """Check if a type is str or Optional[str].""" + if type_ is str: + return True + + origin = typing_extensions.get_origin(type_) + if origin is Union: + args = typing_extensions.get_args(type_) + # Optional[str] = Union[str, None] + non_none_args = [a for a in args if a is not type(None)] + if len(non_none_args) == 1 and non_none_args[0] is str: + return True + + return False + + +def parse_sse_obj(sse: "ServerSentEvent", type_: Type[T]) -> T: + """ + Parse a ServerSentEvent into the appropriate type. + + Handles two scenarios based on where the discriminator field is located: + + 1. Data-level discrimination: The discriminator (e.g., 'type') is inside the 'data' payload. + The union describes the data content, not the SSE envelope. + -> Returns: json.loads(data) parsed into the type + + Example: ChatStreamResponse with discriminator='type' + Input: ServerSentEvent(event="message", data='{"type": "content-delta", ...}', id="") + Output: ContentDeltaEvent (parsed from data, SSE envelope stripped) + + 2. Event-level discrimination: The discriminator (e.g., 'event') is at the SSE event level. + The union describes the full SSE event structure. + -> Returns: SSE envelope with 'data' field JSON-parsed only if the variant expects non-string + + Example: JobStreamResponse with discriminator='event' + Input: ServerSentEvent(event="ERROR", data='{"code": "FAILED", ...}', id="123") + Output: JobStreamResponse_Error with data as ErrorData object + + But for variants where data is str (like STATUS_UPDATE): + Input: ServerSentEvent(event="STATUS_UPDATE", data='{"status": "processing"}', id="1") + Output: JobStreamResponse_StatusUpdate with data as string (not parsed) + + Args: + sse: The ServerSentEvent object to parse + type_: The target discriminated union type + + Returns: + The parsed object of type T + + Note: + This function is only available in SDK contexts where http_sse module exists. + """ + sse_event = asdict(sse) + discriminator, variants = _get_discriminator_and_variants(type_) + + if discriminator is None or variants is None: + # Not a discriminated union - parse the data field as JSON + data_value = sse_event.get("data") + if isinstance(data_value, str) and data_value: + try: + parsed_data = json.loads(data_value) + return parse_obj_as(type_, parsed_data) + except json.JSONDecodeError as e: + _logger.warning( + "Failed to parse SSE data field as JSON: %s, data: %s", + e, + data_value[:100] if len(data_value) > 100 else data_value, + ) + return parse_obj_as(type_, sse_event) + + data_value = sse_event.get("data") + + # Check if discriminator is at the top level (event-level discrimination) + if discriminator in sse_event: + # Case 2: Event-level discrimination + # Find the matching variant to check if 'data' field needs JSON parsing + disc_value = sse_event.get(discriminator) + matching_variant = _find_variant_by_discriminator(variants, discriminator, disc_value) + + if matching_variant is not None: + # Check what type the variant expects for 'data' + data_type = _get_field_annotation(matching_variant, "data") + if data_type is not None and not _is_string_type(data_type): + # Variant expects non-string data - parse JSON + if isinstance(data_value, str) and data_value: + try: + parsed_data = json.loads(data_value) + new_object = dict(sse_event) + new_object["data"] = parsed_data + return parse_obj_as(type_, new_object) + except json.JSONDecodeError as e: + _logger.warning( + "Failed to parse SSE data field as JSON for event-level discrimination: %s, data: %s", + e, + data_value[:100] if len(data_value) > 100 else data_value, + ) + # Either no matching variant, data is string type, or JSON parse failed + return parse_obj_as(type_, sse_event) -def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: - dealiased_object = convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read") + else: + # Case 1: Data-level discrimination + # The discriminator is inside the data payload - extract and parse data only + if isinstance(data_value, str) and data_value: + try: + parsed_data = json.loads(data_value) + return parse_obj_as(type_, parsed_data) + except json.JSONDecodeError as e: + _logger.warning( + "Failed to parse SSE data field as JSON for data-level discrimination: %s, data: %s", + e, + data_value[:100] if len(data_value) > 100 else data_value, + ) + return parse_obj_as(type_, sse_event) + + +def parse_obj_as(type_: Type[T], object_: Any) -> T: + # convert_and_respect_annotation_metadata is required for TypedDict aliasing. + # + # For Pydantic models, whether we should pre-dealias depends on how the model encodes aliasing: + # - If the model uses real Pydantic aliases (pydantic.Field(alias=...)), then we must pass wire keys through + # unchanged so Pydantic can validate them. + # - If the model encodes aliasing only via FieldMetadata annotations, then we MUST pre-dealias because Pydantic + # will not recognize those aliases during validation. + if inspect.isclass(type_) and issubclass(type_, pydantic.BaseModel): + has_pydantic_aliases = False + if IS_PYDANTIC_V2: + for field_name, field_info in getattr(type_, "model_fields", {}).items(): # type: ignore[attr-defined] + alias = getattr(field_info, "alias", None) + if alias is not None and alias != field_name: + has_pydantic_aliases = True + break + else: + for field in getattr(type_, "__fields__", {}).values(): + alias = getattr(field, "alias", None) + name = getattr(field, "name", None) + if alias is not None and name is not None and alias != name: + has_pydantic_aliases = True + break + + dealiased_object = ( + object_ + if has_pydantic_aliases + else convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read") + ) + else: + dealiased_object = convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read") if IS_PYDANTIC_V2: - adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 + adapter = pydantic.TypeAdapter(type_) # type: ignore[attr-defined] return adapter.validate_python(dealiased_object) - else: - return pydantic.parse_obj_as(type_, dealiased_object) + return pydantic.parse_obj_as(type_, dealiased_object) -def to_jsonable_with_fallback( - obj: typing.Any, fallback_serializer: typing.Callable[[typing.Any], typing.Any] -) -> typing.Any: +def to_jsonable_with_fallback(obj: Any, fallback_serializer: Callable[[Any], Any]) -> Any: if IS_PYDANTIC_V2: from pydantic_core import to_jsonable_python return to_jsonable_python(obj, fallback=fallback_serializer) - else: - return fallback_serializer(obj) + return fallback_serializer(obj) class UniversalBaseModel(pydantic.BaseModel): if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + model_config: ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( # type: ignore[typeddict-unknown-key] # Allow fields beginning with `model_` to be used in the model protected_namespaces=(), - ) # type: ignore # Pydantic v2 - - @pydantic.model_serializer(mode="wrap", when_used="json") # type: ignore # Pydantic v2 - def serialize_model(self, handler: pydantic.SerializerFunctionWrapHandler) -> typing.Any: # type: ignore # Pydantic v2 - serialized = handler(self) + ) + + @pydantic.model_validator(mode="before") # type: ignore[attr-defined] + @classmethod + def _coerce_field_names_to_aliases(cls, data: Any) -> Any: + """ + Accept Python field names in input by rewriting them to their Pydantic aliases, + while avoiding silent collisions when a key could refer to multiple fields. + """ + if not isinstance(data, Mapping): + return data + + fields = getattr(cls, "model_fields", {}) # type: ignore[attr-defined] + name_to_alias: Dict[str, str] = {} + alias_to_name: Dict[str, str] = {} + + for name, field_info in fields.items(): + alias = getattr(field_info, "alias", None) or name + name_to_alias[name] = alias + if alias != name: + alias_to_name[alias] = name + + # Detect ambiguous keys: a key that is an alias for one field and a name for another. + ambiguous_keys = set(alias_to_name.keys()).intersection(set(name_to_alias.keys())) + for key in ambiguous_keys: + if key in data and name_to_alias[key] not in data: + raise ValueError( + f"Ambiguous input key '{key}': it is both a field name and an alias. " + "Provide the explicit alias key to disambiguate." + ) + + original_keys = set(data.keys()) + rewritten: Dict[str, Any] = dict(data) + for name, alias in name_to_alias.items(): + if alias != name and name in original_keys and alias not in rewritten: + rewritten[alias] = rewritten.pop(name) + + return rewritten + + @pydantic.model_serializer(mode="plain", when_used="json") # type: ignore[attr-defined] + def serialize_model(self) -> Any: # type: ignore[name-defined] + serialized = self.dict() # type: ignore[attr-defined] data = {k: serialize_datetime(v) if isinstance(v, dt.datetime) else v for k, v in serialized.items()} return data @@ -95,35 +411,63 @@ class Config: smart_union = True json_encoders = {dt.datetime: serialize_datetime} + @pydantic.root_validator(pre=True) + def _coerce_field_names_to_aliases(cls, values: Any) -> Any: + """ + Pydantic v1 equivalent of _coerce_field_names_to_aliases. + """ + if not isinstance(values, Mapping): + return values + + fields = getattr(cls, "__fields__", {}) + name_to_alias: Dict[str, str] = {} + alias_to_name: Dict[str, str] = {} + + for name, field in fields.items(): + alias = getattr(field, "alias", None) or name + name_to_alias[name] = alias + if alias != name: + alias_to_name[alias] = name + + ambiguous_keys = set(alias_to_name.keys()).intersection(set(name_to_alias.keys())) + for key in ambiguous_keys: + if key in values and name_to_alias[key] not in values: + raise ValueError( + f"Ambiguous input key '{key}': it is both a field name and an alias. " + "Provide the explicit alias key to disambiguate." + ) + + original_keys = set(values.keys()) + rewritten: Dict[str, Any] = dict(values) + for name, alias in name_to_alias.items(): + if alias != name and name in original_keys and alias not in rewritten: + rewritten[alias] = rewritten.pop(name) + + return rewritten + @classmethod - def model_construct( - cls: typing.Type["Model"], _fields_set: typing.Optional[typing.Set[str]] = None, **values: typing.Any - ) -> "Model": + def model_construct(cls: Type["Model"], _fields_set: Optional[Set[str]] = None, **values: Any) -> "Model": dealiased_object = convert_and_respect_annotation_metadata(object_=values, annotation=cls, direction="read") return cls.construct(_fields_set, **dealiased_object) @classmethod - def construct( - cls: typing.Type["Model"], _fields_set: typing.Optional[typing.Set[str]] = None, **values: typing.Any - ) -> "Model": + def construct(cls: Type["Model"], _fields_set: Optional[Set[str]] = None, **values: Any) -> "Model": dealiased_object = convert_and_respect_annotation_metadata(object_=values, annotation=cls, direction="read") if IS_PYDANTIC_V2: - return super().model_construct(_fields_set, **dealiased_object) # type: ignore # Pydantic v2 - else: - return super().construct(_fields_set, **dealiased_object) + return super().model_construct(_fields_set, **dealiased_object) # type: ignore[misc] + return super().construct(_fields_set, **dealiased_object) - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { + def json(self, **kwargs: Any) -> str: + kwargs_with_defaults = { "by_alias": True, "exclude_unset": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump_json(**kwargs_with_defaults) # type: ignore # Pydantic v2 - else: - return super().json(**kwargs_with_defaults) + return super().model_dump_json(**kwargs_with_defaults) # type: ignore[misc] + return super().json(**kwargs_with_defaults) - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + def dict(self, **kwargs: Any) -> Dict[str, Any]: """ Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. @@ -134,21 +478,21 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset = { **kwargs, "by_alias": True, "exclude_unset": True, "exclude_none": False, } - kwargs_with_defaults_exclude_none: typing.Any = { + kwargs_with_defaults_exclude_none = { **kwargs, "by_alias": True, "exclude_none": True, "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore[misc] + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore[misc] ) else: @@ -168,7 +512,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default is not None: self.__fields_set__.add(name) - kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields = { "by_alias": True, "exclude_unset": True, "include": _fields_set, @@ -177,15 +521,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return cast( + Dict[str, Any], + convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write"), + ) -def _union_list_of_pydantic_dicts( - source: typing.List[typing.Any], destination: typing.List[typing.Any] -) -> typing.List[typing.Any]: - converted_list: typing.List[typing.Any] = [] +def _union_list_of_pydantic_dicts(source: List[Any], destination: List[Any]) -> List[Any]: + converted_list: List[Any] = [] for i, item in enumerate(source): - destination_value = destination[i] # type: ignore + destination_value = destination[i] if isinstance(item, dict): converted_list.append(deep_union_pydantic_dicts(item, destination_value)) elif isinstance(item, list): @@ -195,9 +540,7 @@ def _union_list_of_pydantic_dicts( return converted_list -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: +def deep_union_pydantic_dicts(source: Dict[str, Any], destination: Dict[str, Any]) -> Dict[str, Any]: for key, value in source.items(): node = destination.setdefault(key, {}) if isinstance(value, dict): @@ -215,18 +558,16 @@ def deep_union_pydantic_dicts( if IS_PYDANTIC_V2: - class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 + class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore[misc, name-defined, type-arg] pass - UniversalRootModel: typing_extensions.TypeAlias = V2RootModel # type: ignore + UniversalRootModel: TypeAlias = V2RootModel # type: ignore[misc] else: - UniversalRootModel: typing_extensions.TypeAlias = UniversalBaseModel # type: ignore + UniversalRootModel: TypeAlias = UniversalBaseModel # type: ignore[misc, no-redef] -def encode_by_type(o: typing.Any) -> typing.Any: - encoders_by_class_tuples: typing.Dict[typing.Callable[[typing.Any], typing.Any], typing.Tuple[typing.Any, ...]] = ( - defaultdict(tuple) - ) +def encode_by_type(o: Any) -> Any: + encoders_by_class_tuples: Dict[Callable[[Any], Any], Tuple[Any, ...]] = defaultdict(tuple) for type_, encoder in encoders_by_type.items(): encoders_by_class_tuples[encoder] += (type_,) @@ -237,54 +578,51 @@ def encode_by_type(o: typing.Any) -> typing.Any: return encoder(o) -def update_forward_refs(model: typing.Type["Model"], **localns: typing.Any) -> None: +def update_forward_refs(model: Type["Model"], **localns: Any) -> None: if IS_PYDANTIC_V2: - model.model_rebuild(raise_errors=False) # type: ignore # Pydantic v2 + model.model_rebuild(raise_errors=False) # type: ignore[attr-defined] else: model.update_forward_refs(**localns) # Mirrors Pydantic's internal typing -AnyCallable = typing.Callable[..., typing.Any] +AnyCallable = Callable[..., Any] def universal_root_validator( pre: bool = False, -) -> typing.Callable[[AnyCallable], AnyCallable]: +) -> Callable[[AnyCallable], AnyCallable]: def decorator(func: AnyCallable) -> AnyCallable: if IS_PYDANTIC_V2: - return pydantic.model_validator(mode="before" if pre else "after")(func) # type: ignore # Pydantic v2 - else: - return pydantic.root_validator(pre=pre)(func) # type: ignore # Pydantic v1 + # In Pydantic v2, for RootModel we always use "before" mode + # The custom validators transform the input value before the model is created + return cast(AnyCallable, pydantic.model_validator(mode="before")(func)) # type: ignore[attr-defined] + return cast(AnyCallable, pydantic.root_validator(pre=pre)(func)) # type: ignore[call-overload] return decorator -def universal_field_validator(field_name: str, pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]: +def universal_field_validator(field_name: str, pre: bool = False) -> Callable[[AnyCallable], AnyCallable]: def decorator(func: AnyCallable) -> AnyCallable: if IS_PYDANTIC_V2: - return pydantic.field_validator(field_name, mode="before" if pre else "after")(func) # type: ignore # Pydantic v2 - else: - return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 + return cast(AnyCallable, pydantic.field_validator(field_name, mode="before" if pre else "after")(func)) # type: ignore[attr-defined] + return cast(AnyCallable, pydantic.validator(field_name, pre=pre)(func)) return decorator -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] +PydanticField = Union[ModelField, _FieldInfo] -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: +def _get_model_fields(model: Type["Model"]) -> Mapping[str, PydanticField]: if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 + return cast(Mapping[str, PydanticField], model.model_fields) # type: ignore[attr-defined] + return cast(Mapping[str, PydanticField], model.__fields__) -def _get_field_default(field: PydanticField) -> typing.Any: +def _get_field_default(field: PydanticField) -> Any: try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 + value = field.get_default() # type: ignore[union-attr] except: value = field.default if IS_PYDANTIC_V2: diff --git a/src/polytomic/core/serialization.py b/src/polytomic/core/serialization.py index cb5dcbf..c36e865 100644 --- a/src/polytomic/core/serialization.py +++ b/src/polytomic/core/serialization.py @@ -4,9 +4,8 @@ import inspect import typing -import typing_extensions - import pydantic +import typing_extensions class FieldMetadata: @@ -161,7 +160,12 @@ def _convert_mapping( direction: typing.Literal["read", "write"], ) -> typing.Mapping[str, object]: converted_object: typing.Dict[str, object] = {} - annotations = typing_extensions.get_type_hints(expected_type, include_extras=True) + try: + annotations = typing_extensions.get_type_hints(expected_type, include_extras=True) + except NameError: + # The TypedDict contains a circular reference, so + # we use the __annotations__ attribute directly. + annotations = getattr(expected_type, "__annotations__", {}) aliases_to_field_names = _get_alias_to_field_name(annotations) for key, value in object_.items(): if direction == "read" and key in aliases_to_field_names: diff --git a/src/polytomic/errors/__init__.py b/src/polytomic/errors/__init__.py index 5776dbf..f1133b0 100644 --- a/src/polytomic/errors/__init__.py +++ b/src/polytomic/errors/__init__.py @@ -1,12 +1,49 @@ # This file was auto-generated by Fern from our API Definition. -from .bad_request_error import BadRequestError -from .conflict_error import ConflictError -from .forbidden_error import ForbiddenError -from .internal_server_error import InternalServerError -from .not_found_error import NotFoundError -from .unauthorized_error import UnauthorizedError -from .unprocessable_entity_error import UnprocessableEntityError +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from .bad_request_error import BadRequestError + from .conflict_error import ConflictError + from .forbidden_error import ForbiddenError + from .internal_server_error import InternalServerError + from .not_found_error import NotFoundError + from .unauthorized_error import UnauthorizedError + from .unprocessable_entity_error import UnprocessableEntityError +_dynamic_imports: typing.Dict[str, str] = { + "BadRequestError": ".bad_request_error", + "ConflictError": ".conflict_error", + "ForbiddenError": ".forbidden_error", + "InternalServerError": ".internal_server_error", + "NotFoundError": ".not_found_error", + "UnauthorizedError": ".unauthorized_error", + "UnprocessableEntityError": ".unprocessable_entity_error", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = [ "BadRequestError", diff --git a/src/polytomic/errors/bad_request_error.py b/src/polytomic/errors/bad_request_error.py index 1510c59..3cf1d9c 100644 --- a/src/polytomic/errors/bad_request_error.py +++ b/src/polytomic/errors/bad_request_error.py @@ -1,9 +1,11 @@ # This file was auto-generated by Fern from our API Definition. +import typing + from ..core.api_error import ApiError as core_api_error_ApiError from ..types.api_error import ApiError as types_api_error_ApiError class BadRequestError(core_api_error_ApiError): - def __init__(self, body: types_api_error_ApiError): - super().__init__(status_code=400, body=body) + def __init__(self, body: types_api_error_ApiError, headers: typing.Optional[typing.Dict[str, str]] = None): + super().__init__(status_code=400, headers=headers, body=body) diff --git a/src/polytomic/errors/conflict_error.py b/src/polytomic/errors/conflict_error.py index 27943d6..a195458 100644 --- a/src/polytomic/errors/conflict_error.py +++ b/src/polytomic/errors/conflict_error.py @@ -1,9 +1,11 @@ # This file was auto-generated by Fern from our API Definition. +import typing + from ..core.api_error import ApiError as core_api_error_ApiError from ..types.api_error import ApiError as types_api_error_ApiError class ConflictError(core_api_error_ApiError): - def __init__(self, body: types_api_error_ApiError): - super().__init__(status_code=409, body=body) + def __init__(self, body: types_api_error_ApiError, headers: typing.Optional[typing.Dict[str, str]] = None): + super().__init__(status_code=409, headers=headers, body=body) diff --git a/src/polytomic/errors/forbidden_error.py b/src/polytomic/errors/forbidden_error.py index 76acfcb..80e15e0 100644 --- a/src/polytomic/errors/forbidden_error.py +++ b/src/polytomic/errors/forbidden_error.py @@ -1,9 +1,11 @@ # This file was auto-generated by Fern from our API Definition. +import typing + from ..core.api_error import ApiError as core_api_error_ApiError from ..types.api_error import ApiError as types_api_error_ApiError class ForbiddenError(core_api_error_ApiError): - def __init__(self, body: types_api_error_ApiError): - super().__init__(status_code=403, body=body) + def __init__(self, body: types_api_error_ApiError, headers: typing.Optional[typing.Dict[str, str]] = None): + super().__init__(status_code=403, headers=headers, body=body) diff --git a/src/polytomic/errors/internal_server_error.py b/src/polytomic/errors/internal_server_error.py index 2e45ae3..42082d1 100644 --- a/src/polytomic/errors/internal_server_error.py +++ b/src/polytomic/errors/internal_server_error.py @@ -1,9 +1,11 @@ # This file was auto-generated by Fern from our API Definition. +import typing + from ..core.api_error import ApiError as core_api_error_ApiError from ..types.api_error import ApiError as types_api_error_ApiError class InternalServerError(core_api_error_ApiError): - def __init__(self, body: types_api_error_ApiError): - super().__init__(status_code=500, body=body) + def __init__(self, body: types_api_error_ApiError, headers: typing.Optional[typing.Dict[str, str]] = None): + super().__init__(status_code=500, headers=headers, body=body) diff --git a/src/polytomic/errors/not_found_error.py b/src/polytomic/errors/not_found_error.py index e6ba82e..b453b65 100644 --- a/src/polytomic/errors/not_found_error.py +++ b/src/polytomic/errors/not_found_error.py @@ -1,9 +1,11 @@ # This file was auto-generated by Fern from our API Definition. +import typing + from ..core.api_error import ApiError as core_api_error_ApiError from ..types.api_error import ApiError as types_api_error_ApiError class NotFoundError(core_api_error_ApiError): - def __init__(self, body: types_api_error_ApiError): - super().__init__(status_code=404, body=body) + def __init__(self, body: types_api_error_ApiError, headers: typing.Optional[typing.Dict[str, str]] = None): + super().__init__(status_code=404, headers=headers, body=body) diff --git a/src/polytomic/errors/unauthorized_error.py b/src/polytomic/errors/unauthorized_error.py index 6934f0f..a735b43 100644 --- a/src/polytomic/errors/unauthorized_error.py +++ b/src/polytomic/errors/unauthorized_error.py @@ -1,9 +1,11 @@ # This file was auto-generated by Fern from our API Definition. +import typing + from ..core.api_error import ApiError from ..types.rest_err_response import RestErrResponse class UnauthorizedError(ApiError): - def __init__(self, body: RestErrResponse): - super().__init__(status_code=401, body=body) + def __init__(self, body: RestErrResponse, headers: typing.Optional[typing.Dict[str, str]] = None): + super().__init__(status_code=401, headers=headers, body=body) diff --git a/src/polytomic/errors/unprocessable_entity_error.py b/src/polytomic/errors/unprocessable_entity_error.py index f4e457b..5f95f96 100644 --- a/src/polytomic/errors/unprocessable_entity_error.py +++ b/src/polytomic/errors/unprocessable_entity_error.py @@ -1,9 +1,11 @@ # This file was auto-generated by Fern from our API Definition. +import typing + from ..core.api_error import ApiError as core_api_error_ApiError from ..types.api_error import ApiError as types_api_error_ApiError class UnprocessableEntityError(core_api_error_ApiError): - def __init__(self, body: types_api_error_ApiError): - super().__init__(status_code=422, body=body) + def __init__(self, body: types_api_error_ApiError, headers: typing.Optional[typing.Dict[str, str]] = None): + super().__init__(status_code=422, headers=headers, body=body) diff --git a/src/polytomic/events/__init__.py b/src/polytomic/events/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/events/__init__.py +++ b/src/polytomic/events/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/events/client.py b/src/polytomic/events/client.py index 01d4d77..b02c017 100644 --- a/src/polytomic/events/client.py +++ b/src/polytomic/events/client.py @@ -1,26 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.client_wrapper import SyncClientWrapper -import typing import datetime as dt +import typing + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions -from ..types.events_envelope import EventsEnvelope -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import parse_obj_as -from ..errors.unauthorized_error import UnauthorizedError -from ..types.rest_err_response import RestErrResponse -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.api_error import ApiError as types_api_error_ApiError -from ..errors.internal_server_error import InternalServerError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError as core_api_error_ApiError from ..types.event_types_envelope import EventTypesEnvelope -from ..core.client_wrapper import AsyncClientWrapper +from ..types.events_envelope import EventsEnvelope +from .raw_client import AsyncRawEventsClient, RawEventsClient class EventsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawEventsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawEventsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawEventsClient + """ + return self._raw_client def list( self, @@ -73,61 +76,15 @@ def list( ), ) """ - _response = self._client_wrapper.httpx_client.request( - "api/events", - method="GET", - params={ - "organization_id": organization_id, - "type": type, - "starting_after": serialize_datetime(starting_after) if starting_after is not None else None, - "ending_before": serialize_datetime(ending_before) if ending_before is not None else None, - "limit": limit, - }, + _response = self._raw_client.list( + organization_id=organization_id, + type=type, + starting_after=starting_after, + ending_before=ending_before, + limit=limit, request_options=request_options, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - EventsEnvelope, - parse_obj_as( - type_=EventsEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get_types(self, *, request_options: typing.Optional[RequestOptions] = None) -> EventTypesEnvelope: """ @@ -151,39 +108,24 @@ def get_types(self, *, request_options: typing.Optional[RequestOptions] = None) ) client.events.get_types() """ - _response = self._client_wrapper.httpx_client.request( - "api/events_types", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - EventTypesEnvelope, - parse_obj_as( - type_=EventTypesEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_types(request_options=request_options) + return _response.data class AsyncEventsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawEventsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawEventsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawEventsClient + """ + return self._raw_client async def list( self, @@ -243,61 +185,15 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/events", - method="GET", - params={ - "organization_id": organization_id, - "type": type, - "starting_after": serialize_datetime(starting_after) if starting_after is not None else None, - "ending_before": serialize_datetime(ending_before) if ending_before is not None else None, - "limit": limit, - }, + _response = await self._raw_client.list( + organization_id=organization_id, + type=type, + starting_after=starting_after, + ending_before=ending_before, + limit=limit, request_options=request_options, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - EventsEnvelope, - parse_obj_as( - type_=EventsEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get_types(self, *, request_options: typing.Optional[RequestOptions] = None) -> EventTypesEnvelope: """ @@ -329,31 +225,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/events_types", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - EventTypesEnvelope, - parse_obj_as( - type_=EventTypesEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_types(request_options=request_options) + return _response.data diff --git a/src/polytomic/events/raw_client.py b/src/polytomic/events/raw_client.py new file mode 100644 index 0000000..3d6580a --- /dev/null +++ b/src/polytomic/events/raw_client.py @@ -0,0 +1,333 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError as core_api_error_ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.datetime_utils import serialize_datetime +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.parse_error import ParsingError +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..errors.internal_server_error import InternalServerError +from ..errors.unauthorized_error import UnauthorizedError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.api_error import ApiError as types_api_error_ApiError +from ..types.event_types_envelope import EventTypesEnvelope +from ..types.events_envelope import EventsEnvelope +from ..types.rest_err_response import RestErrResponse +from pydantic import ValidationError + + +class RawEventsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + *, + organization_id: typing.Optional[str] = None, + type: typing.Optional[str] = None, + starting_after: typing.Optional[dt.datetime] = None, + ending_before: typing.Optional[dt.datetime] = None, + limit: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[EventsEnvelope]: + """ + Parameters + ---------- + organization_id : typing.Optional[str] + + type : typing.Optional[str] + + starting_after : typing.Optional[dt.datetime] + + ending_before : typing.Optional[dt.datetime] + + limit : typing.Optional[int] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[EventsEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/events", + method="GET", + params={ + "organization_id": organization_id, + "type": type, + "starting_after": serialize_datetime(starting_after) if starting_after is not None else None, + "ending_before": serialize_datetime(ending_before) if ending_before is not None else None, + "limit": limit, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + EventsEnvelope, + parse_obj_as( + type_=EventsEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_types(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[EventTypesEnvelope]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[EventTypesEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/events_types", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + EventTypesEnvelope, + parse_obj_as( + type_=EventTypesEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawEventsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + *, + organization_id: typing.Optional[str] = None, + type: typing.Optional[str] = None, + starting_after: typing.Optional[dt.datetime] = None, + ending_before: typing.Optional[dt.datetime] = None, + limit: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[EventsEnvelope]: + """ + Parameters + ---------- + organization_id : typing.Optional[str] + + type : typing.Optional[str] + + starting_after : typing.Optional[dt.datetime] + + ending_before : typing.Optional[dt.datetime] + + limit : typing.Optional[int] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[EventsEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/events", + method="GET", + params={ + "organization_id": organization_id, + "type": type, + "starting_after": serialize_datetime(starting_after) if starting_after is not None else None, + "ending_before": serialize_datetime(ending_before) if ending_before is not None else None, + "limit": limit, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + EventsEnvelope, + parse_obj_as( + type_=EventsEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_types( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[EventTypesEnvelope]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[EventTypesEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/events_types", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + EventTypesEnvelope, + parse_obj_as( + type_=EventTypesEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/identity/__init__.py b/src/polytomic/identity/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/identity/__init__.py +++ b/src/polytomic/identity/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/identity/client.py b/src/polytomic/identity/client.py index ff5375d..3533f02 100644 --- a/src/polytomic/identity/client.py +++ b/src/polytomic/identity/client.py @@ -1,22 +1,27 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.client_wrapper import SyncClientWrapper import typing + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions from ..types.get_identity_response_envelope import GetIdentityResponseEnvelope -from ..core.pydantic_utilities import parse_obj_as -from ..errors.unauthorized_error import UnauthorizedError -from ..types.rest_err_response import RestErrResponse -from ..errors.internal_server_error import InternalServerError -from ..types.api_error import ApiError as types_api_error_ApiError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError as core_api_error_ApiError -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawIdentityClient, RawIdentityClient class IdentityClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawIdentityClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawIdentityClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawIdentityClient + """ + return self._raw_client def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> GetIdentityResponseEnvelope: """ @@ -42,49 +47,24 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Get ) client.identity.get() """ - _response = self._client_wrapper.httpx_client.request( - "api/me", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetIdentityResponseEnvelope, - parse_obj_as( - type_=GetIdentityResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(request_options=request_options) + return _response.data class AsyncIdentityClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawIdentityClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawIdentityClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawIdentityClient + """ + return self._raw_client async def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> GetIdentityResponseEnvelope: """ @@ -118,41 +98,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/me", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetIdentityResponseEnvelope, - parse_obj_as( - type_=GetIdentityResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(request_options=request_options) + return _response.data diff --git a/src/polytomic/identity/raw_client.py b/src/polytomic/identity/raw_client.py new file mode 100644 index 0000000..3e8fe7a --- /dev/null +++ b/src/polytomic/identity/raw_client.py @@ -0,0 +1,159 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError as core_api_error_ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.parse_error import ParsingError +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..errors.internal_server_error import InternalServerError +from ..errors.unauthorized_error import UnauthorizedError +from ..types.api_error import ApiError as types_api_error_ApiError +from ..types.get_identity_response_envelope import GetIdentityResponseEnvelope +from ..types.rest_err_response import RestErrResponse +from pydantic import ValidationError + + +class RawIdentityClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetIdentityResponseEnvelope]: + """ + Returns information about the caller's identity. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetIdentityResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/me", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetIdentityResponseEnvelope, + parse_obj_as( + type_=GetIdentityResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawIdentityClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetIdentityResponseEnvelope]: + """ + Returns information about the caller's identity. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetIdentityResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/me", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetIdentityResponseEnvelope, + parse_obj_as( + type_=GetIdentityResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/jobs/__init__.py b/src/polytomic/jobs/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/jobs/__init__.py +++ b/src/polytomic/jobs/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/jobs/client.py b/src/polytomic/jobs/client.py index 32ba6b8..801bed5 100644 --- a/src/polytomic/jobs/client.py +++ b/src/polytomic/jobs/client.py @@ -1,36 +1,38 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.client_wrapper import SyncClientWrapper import typing + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions from ..types.job_response_envelope import JobResponseEnvelope -from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import parse_obj_as -from ..errors.bad_request_error import BadRequestError -from ..types.api_error import ApiError as types_api_error_ApiError -from ..errors.unauthorized_error import UnauthorizedError -from ..types.rest_err_response import RestErrResponse -from ..errors.not_found_error import NotFoundError -from ..errors.internal_server_error import InternalServerError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError as core_api_error_ApiError -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawJobsClient, RawJobsClient class JobsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawJobsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawJobsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawJobsClient + """ + return self._raw_client def get( - self, id: str, type: str, *, request_options: typing.Optional[RequestOptions] = None + self, type: str, id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> JobResponseEnvelope: """ Parameters ---------- - id : str - type : str + id : str + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -48,84 +50,39 @@ def get( token="YOUR_TOKEN", ) client.jobs.get( - id="248df4b7-aa70-47b8-a036-33ac447e668d", type="createmodel", + id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/jobs/{jsonable_encoder(type)}/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - JobResponseEnvelope, - parse_obj_as( - type_=JobResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(type, id, request_options=request_options) + return _response.data class AsyncJobsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawJobsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawJobsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawJobsClient + """ + return self._raw_client async def get( - self, id: str, type: str, *, request_options: typing.Optional[RequestOptions] = None + self, type: str, id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> JobResponseEnvelope: """ Parameters ---------- - id : str - type : str + id : str + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -148,68 +105,12 @@ async def get( async def main() -> None: await client.jobs.get( - id="248df4b7-aa70-47b8-a036-33ac447e668d", type="createmodel", + id="248df4b7-aa70-47b8-a036-33ac447e668d", ) asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/jobs/{jsonable_encoder(type)}/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - JobResponseEnvelope, - parse_obj_as( - type_=JobResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(type, id, request_options=request_options) + return _response.data diff --git a/src/polytomic/jobs/raw_client.py b/src/polytomic/jobs/raw_client.py new file mode 100644 index 0000000..e7092bb --- /dev/null +++ b/src/polytomic/jobs/raw_client.py @@ -0,0 +1,210 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError as core_api_error_ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..errors.bad_request_error import BadRequestError +from ..errors.internal_server_error import InternalServerError +from ..errors.not_found_error import NotFoundError +from ..errors.unauthorized_error import UnauthorizedError +from ..types.api_error import ApiError as types_api_error_ApiError +from ..types.job_response_envelope import JobResponseEnvelope +from ..types.rest_err_response import RestErrResponse +from pydantic import ValidationError + + +class RawJobsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, type: str, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[JobResponseEnvelope]: + """ + Parameters + ---------- + type : str + + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[JobResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/jobs/{jsonable_encoder(type)}/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + JobResponseEnvelope, + parse_obj_as( + type_=JobResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawJobsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, type: str, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[JobResponseEnvelope]: + """ + Parameters + ---------- + type : str + + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[JobResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/jobs/{jsonable_encoder(type)}/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + JobResponseEnvelope, + parse_obj_as( + type_=JobResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/model_sync/__init__.py b/src/polytomic/model_sync/__init__.py index 1fb686e..ae8aa17 100644 --- a/src/polytomic/model_sync/__init__.py +++ b/src/polytomic/model_sync/__init__.py @@ -1,5 +1,34 @@ # This file was auto-generated by Fern from our API Definition. -from . import executions, targets +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import executions, targets +_dynamic_imports: typing.Dict[str, str] = {"executions": ".executions", "targets": ".targets"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["executions", "targets"] diff --git a/src/polytomic/model_sync/client.py b/src/polytomic/model_sync/client.py index b5a0048..8ae9d67 100644 --- a/src/polytomic/model_sync/client.py +++ b/src/polytomic/model_sync/client.py @@ -1,59 +1,59 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + import typing -from ..core.client_wrapper import SyncClientWrapper -from .targets.client import TargetsClient -from .executions.client import ExecutionsClient + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.activate_sync_envelope import ActivateSyncEnvelope +from ..types.cancel_model_sync_response_envelope import CancelModelSyncResponseEnvelope +from ..types.filter import Filter from ..types.get_model_sync_source_meta_envelope import GetModelSyncSourceMetaEnvelope -from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import parse_obj_as -from ..errors.bad_request_error import BadRequestError -from ..types.api_error import ApiError as types_api_error_ApiError -from ..errors.unauthorized_error import UnauthorizedError -from ..types.rest_err_response import RestErrResponse -from ..errors.forbidden_error import ForbiddenError -from ..errors.not_found_error import NotFoundError -from ..errors.internal_server_error import InternalServerError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError as core_api_error_ApiError -from ..types.model_field_response import ModelFieldResponse -from ..types.model_sync_mode import ModelSyncMode +from ..types.identity import Identity from ..types.list_model_sync_response_envelope import ListModelSyncResponseEnvelope +from ..types.model_field_response import ModelFieldResponse from ..types.model_sync_field import ModelSyncField -from ..types.schedule import Schedule -from ..types.target import Target -from ..types.filter import Filter -from ..types.identity import Identity -from ..types.override import Override +from ..types.model_sync_mode import ModelSyncMode from ..types.model_sync_response_envelope import ModelSyncResponseEnvelope -from ..core.serialization import convert_and_respect_annotation_metadata -from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.override import Override +from ..types.schedule import Schedule from ..types.schedule_option_response_envelope import ScheduleOptionResponseEnvelope -from ..errors.conflict_error import ConflictError -from ..types.activate_sync_envelope import ActivateSyncEnvelope -from ..types.cancel_model_sync_response_envelope import CancelModelSyncResponseEnvelope from ..types.start_model_sync_response_envelope import StartModelSyncResponseEnvelope from ..types.sync_status_envelope import SyncStatusEnvelope -from ..core.client_wrapper import AsyncClientWrapper -from .targets.client import AsyncTargetsClient -from .executions.client import AsyncExecutionsClient +from ..types.target import Target +from .raw_client import AsyncRawModelSyncClient, RawModelSyncClient +if typing.TYPE_CHECKING: + from .executions.client import AsyncExecutionsClient, ExecutionsClient + from .targets.client import AsyncTargetsClient, TargetsClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) class ModelSyncClient: def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawModelSyncClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper - self.targets = TargetsClient(client_wrapper=self._client_wrapper) - self.executions = ExecutionsClient(client_wrapper=self._client_wrapper) + self._targets: typing.Optional[TargetsClient] = None + self._executions: typing.Optional[ExecutionsClient] = None + + @property + def with_raw_response(self) -> RawModelSyncClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawModelSyncClient + """ + return self._raw_client def get_source( self, id: str, *, - params: typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]] = None, + params: typing.Optional[typing.Dict[str, typing.Sequence[str]]] = None, request_options: typing.Optional[RequestOptions] = None, ) -> GetModelSyncSourceMetaEnvelope: """ @@ -61,7 +61,7 @@ def get_source( ---------- id : str - params : typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]] + params : typing.Optional[typing.Dict[str, typing.Sequence[str]]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -83,83 +83,14 @@ def get_source( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/modelsync/source", - method="GET", - params={ - "params": params, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetModelSyncSourceMetaEnvelope, - parse_obj_as( - type_=GetModelSyncSourceMetaEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_source(id, params=params, request_options=request_options) + return _response.data def get_source_fields( self, id: str, *, - params: typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]] = None, + params: typing.Optional[typing.Dict[str, typing.Sequence[str]]] = None, request_options: typing.Optional[RequestOptions] = None, ) -> ModelFieldResponse: """ @@ -167,7 +98,7 @@ def get_source_fields( ---------- id : str - params : typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]] + params : typing.Optional[typing.Dict[str, typing.Sequence[str]]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -189,77 +120,8 @@ def get_source_fields( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/modelsync/source/fields", - method="GET", - params={ - "params": params, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelFieldResponse, - parse_obj_as( - type_=ModelFieldResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_source_fields(id, params=params, request_options=request_options) + return _response.data def list( self, @@ -299,69 +161,10 @@ def list( target_connection_id="0b155265-c537-44c9-9359-a3ceb468a4da", ) """ - _response = self._client_wrapper.httpx_client.request( - "api/syncs", - method="GET", - params={ - "active": active, - "mode": mode, - "target_connection_id": target_connection_id, - }, - request_options=request_options, + _response = self._raw_client.list( + active=active, mode=mode, target_connection_id=target_connection_id, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListModelSyncResponseEnvelope, - parse_obj_as( - type_=ListModelSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def create( self, @@ -520,109 +323,27 @@ def create( ), ) """ - _response = self._client_wrapper.httpx_client.request( - "api/syncs", - method="POST", - json={ - "active": active, - "encryption_passphrase": encryption_passphrase, - "fields": convert_and_respect_annotation_metadata( - object_=fields, annotation=typing.Sequence[ModelSyncField], direction="write" - ), - "filter_logic": filter_logic, - "filters": convert_and_respect_annotation_metadata( - object_=filters, annotation=typing.Sequence[Filter], direction="write" - ), - "identity": convert_and_respect_annotation_metadata( - object_=identity, annotation=Identity, direction="write" - ), - "mode": mode, - "name": name, - "only_enrich_updates": only_enrich_updates, - "organization_id": organization_id, - "override_fields": convert_and_respect_annotation_metadata( - object_=override_fields, annotation=typing.Sequence[ModelSyncField], direction="write" - ), - "overrides": convert_and_respect_annotation_metadata( - object_=overrides, annotation=typing.Sequence[Override], direction="write" - ), - "policies": policies, - "schedule": convert_and_respect_annotation_metadata( - object_=schedule, annotation=Schedule, direction="write" - ), - "skip_initial_backfill": skip_initial_backfill, - "sync_all_records": sync_all_records, - "target": convert_and_respect_annotation_metadata(object_=target, annotation=Target, direction="write"), - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.create( + fields=fields, + mode=mode, + name=name, + schedule=schedule, + target=target, + active=active, + encryption_passphrase=encryption_passphrase, + filter_logic=filter_logic, + filters=filters, + identity=identity, + only_enrich_updates=only_enrich_updates, + organization_id=organization_id, + override_fields=override_fields, + overrides=overrides, + policies=policies, + skip_initial_backfill=skip_initial_backfill, + sync_all_records=sync_all_records, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelSyncResponseEnvelope, - parse_obj_as( - type_=ModelSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get_schedule_options( self, *, request_options: typing.Optional[RequestOptions] = None @@ -648,44 +369,8 @@ def get_schedule_options( ) client.model_sync.get_schedule_options() """ - _response = self._client_wrapper.httpx_client.request( - "api/syncs/schedules", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ScheduleOptionResponseEnvelope, - parse_obj_as( - type_=ScheduleOptionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_schedule_options(request_options=request_options) + return _response.data def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ModelSyncResponseEnvelope: """ @@ -713,54 +398,8 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelSyncResponseEnvelope, - parse_obj_as( - type_=ModelSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(id, request_options=request_options) + return _response.data def update( self, @@ -866,119 +505,28 @@ def update( ), ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(id)}", - method="PUT", - json={ - "active": active, - "encryption_passphrase": encryption_passphrase, - "fields": convert_and_respect_annotation_metadata( - object_=fields, annotation=typing.Sequence[ModelSyncField], direction="write" - ), - "filter_logic": filter_logic, - "filters": convert_and_respect_annotation_metadata( - object_=filters, annotation=typing.Sequence[Filter], direction="write" - ), - "identity": convert_and_respect_annotation_metadata( - object_=identity, annotation=Identity, direction="write" - ), - "mode": mode, - "name": name, - "only_enrich_updates": only_enrich_updates, - "organization_id": organization_id, - "override_fields": convert_and_respect_annotation_metadata( - object_=override_fields, annotation=typing.Sequence[ModelSyncField], direction="write" - ), - "overrides": convert_and_respect_annotation_metadata( - object_=overrides, annotation=typing.Sequence[Override], direction="write" - ), - "policies": policies, - "schedule": convert_and_respect_annotation_metadata( - object_=schedule, annotation=Schedule, direction="write" - ), - "skip_initial_backfill": skip_initial_backfill, - "sync_all_records": sync_all_records, - "target": convert_and_respect_annotation_metadata(object_=target, annotation=Target, direction="write"), - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.update( + id, + fields=fields, + mode=mode, + name=name, + schedule=schedule, + target=target, + active=active, + encryption_passphrase=encryption_passphrase, + filter_logic=filter_logic, + filters=filters, + identity=identity, + only_enrich_updates=only_enrich_updates, + organization_id=organization_id, + override_fields=override_fields, + overrides=overrides, + policies=policies, + skip_initial_backfill=skip_initial_backfill, + sync_all_records=sync_all_records, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelSyncResponseEnvelope, - parse_obj_as( - type_=ModelSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ @@ -1005,68 +553,8 @@ def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 409: - raise ConflictError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.remove(id, request_options=request_options) + return _response.data def activate( self, id: str, *, active: bool, request_options: typing.Optional[RequestOptions] = None @@ -1099,68 +587,8 @@ def activate( active=True, ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(id)}/activate", - method="POST", - json={ - "active": active, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ActivateSyncEnvelope, - parse_obj_as( - type_=ActivateSyncEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.activate(id, active=active, request_options=request_options) + return _response.data def cancel( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -1191,64 +619,8 @@ def cancel( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(id)}/cancel", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CancelModelSyncResponseEnvelope, - parse_obj_as( - type_=CancelModelSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.cancel(id, request_options=request_options) + return _response.data def start( self, @@ -1294,93 +666,10 @@ def start( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(id)}/executions", - method="POST", - json={ - "identities": identities, - "resync": resync, - "test": test, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.start( + id, identities=identities, resync=resync, test=test, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - StartModelSyncResponseEnvelope, - parse_obj_as( - type_=StartModelSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 409: - raise ConflictError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get_status(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> SyncStatusEnvelope: """ @@ -1408,67 +697,49 @@ def get_status(self, id: str, *, request_options: typing.Optional[RequestOptions id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(id)}/status", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SyncStatusEnvelope, - parse_obj_as( - type_=SyncStatusEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_status(id, request_options=request_options) + return _response.data + + @property + def targets(self): + if self._targets is None: + from .targets.client import TargetsClient # noqa: E402 + + self._targets = TargetsClient(client_wrapper=self._client_wrapper) + return self._targets + + @property + def executions(self): + if self._executions is None: + from .executions.client import ExecutionsClient # noqa: E402 + + self._executions = ExecutionsClient(client_wrapper=self._client_wrapper) + return self._executions class AsyncModelSyncClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawModelSyncClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper - self.targets = AsyncTargetsClient(client_wrapper=self._client_wrapper) - self.executions = AsyncExecutionsClient(client_wrapper=self._client_wrapper) + self._targets: typing.Optional[AsyncTargetsClient] = None + self._executions: typing.Optional[AsyncExecutionsClient] = None + + @property + def with_raw_response(self) -> AsyncRawModelSyncClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawModelSyncClient + """ + return self._raw_client async def get_source( self, id: str, *, - params: typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]] = None, + params: typing.Optional[typing.Dict[str, typing.Sequence[str]]] = None, request_options: typing.Optional[RequestOptions] = None, ) -> GetModelSyncSourceMetaEnvelope: """ @@ -1476,7 +747,7 @@ async def get_source( ---------- id : str - params : typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]] + params : typing.Optional[typing.Dict[str, typing.Sequence[str]]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1506,83 +777,14 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/modelsync/source", - method="GET", - params={ - "params": params, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetModelSyncSourceMetaEnvelope, - parse_obj_as( - type_=GetModelSyncSourceMetaEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_source(id, params=params, request_options=request_options) + return _response.data async def get_source_fields( self, id: str, *, - params: typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]] = None, + params: typing.Optional[typing.Dict[str, typing.Sequence[str]]] = None, request_options: typing.Optional[RequestOptions] = None, ) -> ModelFieldResponse: """ @@ -1590,7 +792,7 @@ async def get_source_fields( ---------- id : str - params : typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]] + params : typing.Optional[typing.Dict[str, typing.Sequence[str]]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1620,77 +822,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/modelsync/source/fields", - method="GET", - params={ - "params": params, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelFieldResponse, - parse_obj_as( - type_=ModelFieldResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_source_fields(id, params=params, request_options=request_options) + return _response.data async def list( self, @@ -1738,69 +871,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/syncs", - method="GET", - params={ - "active": active, - "mode": mode, - "target_connection_id": target_connection_id, - }, - request_options=request_options, + _response = await self._raw_client.list( + active=active, mode=mode, target_connection_id=target_connection_id, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListModelSyncResponseEnvelope, - parse_obj_as( - type_=ListModelSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def create( self, @@ -1967,109 +1041,27 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/syncs", - method="POST", - json={ - "active": active, - "encryption_passphrase": encryption_passphrase, - "fields": convert_and_respect_annotation_metadata( - object_=fields, annotation=typing.Sequence[ModelSyncField], direction="write" - ), - "filter_logic": filter_logic, - "filters": convert_and_respect_annotation_metadata( - object_=filters, annotation=typing.Sequence[Filter], direction="write" - ), - "identity": convert_and_respect_annotation_metadata( - object_=identity, annotation=Identity, direction="write" - ), - "mode": mode, - "name": name, - "only_enrich_updates": only_enrich_updates, - "organization_id": organization_id, - "override_fields": convert_and_respect_annotation_metadata( - object_=override_fields, annotation=typing.Sequence[ModelSyncField], direction="write" - ), - "overrides": convert_and_respect_annotation_metadata( - object_=overrides, annotation=typing.Sequence[Override], direction="write" - ), - "policies": policies, - "schedule": convert_and_respect_annotation_metadata( - object_=schedule, annotation=Schedule, direction="write" - ), - "skip_initial_backfill": skip_initial_backfill, - "sync_all_records": sync_all_records, - "target": convert_and_respect_annotation_metadata(object_=target, annotation=Target, direction="write"), - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.create( + fields=fields, + mode=mode, + name=name, + schedule=schedule, + target=target, + active=active, + encryption_passphrase=encryption_passphrase, + filter_logic=filter_logic, + filters=filters, + identity=identity, + only_enrich_updates=only_enrich_updates, + organization_id=organization_id, + override_fields=override_fields, + overrides=overrides, + policies=policies, + skip_initial_backfill=skip_initial_backfill, + sync_all_records=sync_all_records, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelSyncResponseEnvelope, - parse_obj_as( - type_=ModelSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get_schedule_options( self, *, request_options: typing.Optional[RequestOptions] = None @@ -2103,44 +1095,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/syncs/schedules", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ScheduleOptionResponseEnvelope, - parse_obj_as( - type_=ScheduleOptionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_schedule_options(request_options=request_options) + return _response.data async def get( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -2178,54 +1134,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelSyncResponseEnvelope, - parse_obj_as( - type_=ModelSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(id, request_options=request_options) + return _response.data async def update( self, @@ -2339,119 +1249,28 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(id)}", - method="PUT", - json={ - "active": active, - "encryption_passphrase": encryption_passphrase, - "fields": convert_and_respect_annotation_metadata( - object_=fields, annotation=typing.Sequence[ModelSyncField], direction="write" - ), - "filter_logic": filter_logic, - "filters": convert_and_respect_annotation_metadata( - object_=filters, annotation=typing.Sequence[Filter], direction="write" - ), - "identity": convert_and_respect_annotation_metadata( - object_=identity, annotation=Identity, direction="write" - ), - "mode": mode, - "name": name, - "only_enrich_updates": only_enrich_updates, - "organization_id": organization_id, - "override_fields": convert_and_respect_annotation_metadata( - object_=override_fields, annotation=typing.Sequence[ModelSyncField], direction="write" - ), - "overrides": convert_and_respect_annotation_metadata( - object_=overrides, annotation=typing.Sequence[Override], direction="write" - ), - "policies": policies, - "schedule": convert_and_respect_annotation_metadata( - object_=schedule, annotation=Schedule, direction="write" - ), - "skip_initial_backfill": skip_initial_backfill, - "sync_all_records": sync_all_records, - "target": convert_and_respect_annotation_metadata(object_=target, annotation=Target, direction="write"), - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.update( + id, + fields=fields, + mode=mode, + name=name, + schedule=schedule, + target=target, + active=active, + encryption_passphrase=encryption_passphrase, + filter_logic=filter_logic, + filters=filters, + identity=identity, + only_enrich_updates=only_enrich_updates, + organization_id=organization_id, + override_fields=override_fields, + overrides=overrides, + policies=policies, + skip_initial_backfill=skip_initial_backfill, + sync_all_records=sync_all_records, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelSyncResponseEnvelope, - parse_obj_as( - type_=ModelSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ @@ -2486,68 +1305,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 409: - raise ConflictError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.remove(id, request_options=request_options) + return _response.data async def activate( self, id: str, *, active: bool, request_options: typing.Optional[RequestOptions] = None @@ -2588,68 +1347,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(id)}/activate", - method="POST", - json={ - "active": active, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ActivateSyncEnvelope, - parse_obj_as( - type_=ActivateSyncEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.activate(id, active=active, request_options=request_options) + return _response.data async def cancel( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -2688,64 +1387,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(id)}/cancel", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CancelModelSyncResponseEnvelope, - parse_obj_as( - type_=CancelModelSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.cancel(id, request_options=request_options) + return _response.data async def start( self, @@ -2799,93 +1442,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(id)}/executions", - method="POST", - json={ - "identities": identities, - "resync": resync, - "test": test, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.start( + id, identities=identities, resync=resync, test=test, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - StartModelSyncResponseEnvelope, - parse_obj_as( - type_=StartModelSyncResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 409: - raise ConflictError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get_status( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -2923,51 +1483,21 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(id)}/status", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SyncStatusEnvelope, - parse_obj_as( - type_=SyncStatusEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_status(id, request_options=request_options) + return _response.data + + @property + def targets(self): + if self._targets is None: + from .targets.client import AsyncTargetsClient # noqa: E402 + + self._targets = AsyncTargetsClient(client_wrapper=self._client_wrapper) + return self._targets + + @property + def executions(self): + if self._executions is None: + from .executions.client import AsyncExecutionsClient # noqa: E402 + + self._executions = AsyncExecutionsClient(client_wrapper=self._client_wrapper) + return self._executions diff --git a/src/polytomic/model_sync/executions/__init__.py b/src/polytomic/model_sync/executions/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/model_sync/executions/__init__.py +++ b/src/polytomic/model_sync/executions/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/model_sync/executions/client.py b/src/polytomic/model_sync/executions/client.py index a1e1140..dbd7d26 100644 --- a/src/polytomic/model_sync/executions/client.py +++ b/src/polytomic/model_sync/executions/client.py @@ -1,25 +1,15 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ...core.client_wrapper import SyncClientWrapper + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.request_options import RequestOptions -from ...types.list_execution_response_envelope import ListExecutionResponseEnvelope -from ...core.jsonable_encoder import jsonable_encoder -from ...core.pydantic_utilities import parse_obj_as -from ...errors.unauthorized_error import UnauthorizedError -from ...types.rest_err_response import RestErrResponse -from ...errors.not_found_error import NotFoundError -from ...types.api_error import ApiError as types_api_error_ApiError -from json.decoder import JSONDecodeError -from ...core.api_error import ApiError as core_api_error_ApiError -from ...types.get_execution_response_envelope import GetExecutionResponseEnvelope -from ...errors.internal_server_error import InternalServerError +from ...types.execution_logs_response_envelope import ExecutionLogsResponseEnvelope from ...types.execution_status import ExecutionStatus -from ...errors.bad_request_error import BadRequestError -from ...errors.forbidden_error import ForbiddenError +from ...types.get_execution_response_envelope import GetExecutionResponseEnvelope +from ...types.list_execution_response_envelope import ListExecutionResponseEnvelope from ...types.v_2_execution_log_type import V2ExecutionLogType -from ...types.execution_logs_response_envelope import ExecutionLogsResponseEnvelope -from ...core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawExecutionsClient, RawExecutionsClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -27,7 +17,18 @@ class ExecutionsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawExecutionsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawExecutionsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawExecutionsClient + """ + return self._raw_client def list( self, @@ -72,49 +73,14 @@ def list( ascending=True, ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(sync_id)}/executions", - method="GET", - params={ - "page_token": page_token, - "only_completed": only_completed, - "ascending": ascending, - }, + _response = self._raw_client.list( + sync_id, + page_token=page_token, + only_completed=only_completed, + ascending=ascending, request_options=request_options, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListExecutionResponseEnvelope, - parse_obj_as( - type_=ListExecutionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get( self, sync_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -147,54 +113,8 @@ def get( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetExecutionResponseEnvelope, - parse_obj_as( - type_=GetExecutionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(sync_id, id, request_options=request_options) + return _response.data def update( self, sync_id: str, id: str, *, status: ExecutionStatus, request_options: typing.Optional[RequestOptions] = None @@ -231,81 +151,8 @@ def update( status="created", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}", - method="PUT", - json={ - "status": status, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetExecutionResponseEnvelope, - parse_obj_as( - type_=GetExecutionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.update(sync_id, id, status=status, request_options=request_options) + return _response.data def get_log_urls( self, @@ -346,64 +193,8 @@ def get_log_urls( type="records", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}/{jsonable_encoder(type)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ExecutionLogsResponseEnvelope, - parse_obj_as( - type_=ExecutionLogsResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_log_urls(sync_id, id, type, request_options=request_options) + return _response.data def get_logs( self, @@ -447,63 +238,24 @@ def get_logs( filename="path/to/file.json", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}/{jsonable_encoder(type)}/{jsonable_encoder(filename)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_logs(sync_id, id, type, filename, request_options=request_options) + return _response.data class AsyncExecutionsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawExecutionsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawExecutionsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawExecutionsClient + """ + return self._raw_client async def list( self, @@ -556,49 +308,14 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(sync_id)}/executions", - method="GET", - params={ - "page_token": page_token, - "only_completed": only_completed, - "ascending": ascending, - }, + _response = await self._raw_client.list( + sync_id, + page_token=page_token, + only_completed=only_completed, + ascending=ascending, request_options=request_options, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListExecutionResponseEnvelope, - parse_obj_as( - type_=ListExecutionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get( self, sync_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -639,54 +356,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetExecutionResponseEnvelope, - parse_obj_as( - type_=GetExecutionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(sync_id, id, request_options=request_options) + return _response.data async def update( self, sync_id: str, id: str, *, status: ExecutionStatus, request_options: typing.Optional[RequestOptions] = None @@ -731,81 +402,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}", - method="PUT", - json={ - "status": status, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetExecutionResponseEnvelope, - parse_obj_as( - type_=GetExecutionResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.update(sync_id, id, status=status, request_options=request_options) + return _response.data async def get_log_urls( self, @@ -854,64 +452,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}/{jsonable_encoder(type)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ExecutionLogsResponseEnvelope, - parse_obj_as( - type_=ExecutionLogsResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_log_urls(sync_id, id, type, request_options=request_options) + return _response.data async def get_logs( self, @@ -963,55 +505,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}/{jsonable_encoder(type)}/{jsonable_encoder(filename)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_logs(sync_id, id, type, filename, request_options=request_options) + return _response.data diff --git a/src/polytomic/model_sync/executions/raw_client.py b/src/polytomic/model_sync/executions/raw_client.py new file mode 100644 index 0000000..6068f43 --- /dev/null +++ b/src/polytomic/model_sync/executions/raw_client.py @@ -0,0 +1,962 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError as core_api_error_ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.parse_error import ParsingError +from ...core.pydantic_utilities import parse_obj_as +from ...core.request_options import RequestOptions +from ...errors.bad_request_error import BadRequestError +from ...errors.forbidden_error import ForbiddenError +from ...errors.internal_server_error import InternalServerError +from ...errors.not_found_error import NotFoundError +from ...errors.unauthorized_error import UnauthorizedError +from ...types.api_error import ApiError as types_api_error_ApiError +from ...types.execution_logs_response_envelope import ExecutionLogsResponseEnvelope +from ...types.execution_status import ExecutionStatus +from ...types.get_execution_response_envelope import GetExecutionResponseEnvelope +from ...types.list_execution_response_envelope import ListExecutionResponseEnvelope +from ...types.rest_err_response import RestErrResponse +from ...types.v_2_execution_log_type import V2ExecutionLogType +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawExecutionsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + sync_id: str, + *, + page_token: typing.Optional[str] = None, + only_completed: typing.Optional[bool] = None, + ascending: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ListExecutionResponseEnvelope]: + """ + Parameters + ---------- + sync_id : str + + page_token : typing.Optional[str] + + only_completed : typing.Optional[bool] + + ascending : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ListExecutionResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(sync_id)}/executions", + method="GET", + params={ + "page_token": page_token, + "only_completed": only_completed, + "ascending": ascending, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListExecutionResponseEnvelope, + parse_obj_as( + type_=ListExecutionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get( + self, sync_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetExecutionResponseEnvelope]: + """ + Parameters + ---------- + sync_id : str + + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetExecutionResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetExecutionResponseEnvelope, + parse_obj_as( + type_=GetExecutionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def update( + self, sync_id: str, id: str, *, status: ExecutionStatus, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetExecutionResponseEnvelope]: + """ + Parameters + ---------- + sync_id : str + + id : str + The ID of the execution to update. + + status : ExecutionStatus + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetExecutionResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}", + method="PUT", + json={ + "status": status, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetExecutionResponseEnvelope, + parse_obj_as( + type_=GetExecutionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_log_urls( + self, + sync_id: str, + id: str, + type: V2ExecutionLogType, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ExecutionLogsResponseEnvelope]: + """ + Parameters + ---------- + sync_id : str + + id : str + + type : V2ExecutionLogType + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ExecutionLogsResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}/{jsonable_encoder(type)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ExecutionLogsResponseEnvelope, + parse_obj_as( + type_=ExecutionLogsResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_logs( + self, + sync_id: str, + id: str, + type: V2ExecutionLogType, + filename: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[None]: + """ + Parameters + ---------- + sync_id : str + + id : str + + type : V2ExecutionLogType + + filename : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}/{jsonable_encoder(type)}/{jsonable_encoder(filename)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawExecutionsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + sync_id: str, + *, + page_token: typing.Optional[str] = None, + only_completed: typing.Optional[bool] = None, + ascending: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ListExecutionResponseEnvelope]: + """ + Parameters + ---------- + sync_id : str + + page_token : typing.Optional[str] + + only_completed : typing.Optional[bool] + + ascending : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ListExecutionResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(sync_id)}/executions", + method="GET", + params={ + "page_token": page_token, + "only_completed": only_completed, + "ascending": ascending, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListExecutionResponseEnvelope, + parse_obj_as( + type_=ListExecutionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, sync_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetExecutionResponseEnvelope]: + """ + Parameters + ---------- + sync_id : str + + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetExecutionResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetExecutionResponseEnvelope, + parse_obj_as( + type_=GetExecutionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def update( + self, sync_id: str, id: str, *, status: ExecutionStatus, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetExecutionResponseEnvelope]: + """ + Parameters + ---------- + sync_id : str + + id : str + The ID of the execution to update. + + status : ExecutionStatus + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetExecutionResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}", + method="PUT", + json={ + "status": status, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetExecutionResponseEnvelope, + parse_obj_as( + type_=GetExecutionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_log_urls( + self, + sync_id: str, + id: str, + type: V2ExecutionLogType, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ExecutionLogsResponseEnvelope]: + """ + Parameters + ---------- + sync_id : str + + id : str + + type : V2ExecutionLogType + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ExecutionLogsResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}/{jsonable_encoder(type)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ExecutionLogsResponseEnvelope, + parse_obj_as( + type_=ExecutionLogsResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_logs( + self, + sync_id: str, + id: str, + type: V2ExecutionLogType, + filename: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + sync_id : str + + id : str + + type : V2ExecutionLogType + + filename : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(sync_id)}/executions/{jsonable_encoder(id)}/{jsonable_encoder(type)}/{jsonable_encoder(filename)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/model_sync/raw_client.py b/src/polytomic/model_sync/raw_client.py new file mode 100644 index 0000000..3cc08c0 --- /dev/null +++ b/src/polytomic/model_sync/raw_client.py @@ -0,0 +1,2880 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError as core_api_error_ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..core.serialization import convert_and_respect_annotation_metadata +from ..errors.bad_request_error import BadRequestError +from ..errors.conflict_error import ConflictError +from ..errors.forbidden_error import ForbiddenError +from ..errors.internal_server_error import InternalServerError +from ..errors.not_found_error import NotFoundError +from ..errors.unauthorized_error import UnauthorizedError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.activate_sync_envelope import ActivateSyncEnvelope +from ..types.api_error import ApiError as types_api_error_ApiError +from ..types.cancel_model_sync_response_envelope import CancelModelSyncResponseEnvelope +from ..types.filter import Filter +from ..types.get_model_sync_source_meta_envelope import GetModelSyncSourceMetaEnvelope +from ..types.identity import Identity +from ..types.list_model_sync_response_envelope import ListModelSyncResponseEnvelope +from ..types.model_field_response import ModelFieldResponse +from ..types.model_sync_field import ModelSyncField +from ..types.model_sync_mode import ModelSyncMode +from ..types.model_sync_response_envelope import ModelSyncResponseEnvelope +from ..types.override import Override +from ..types.rest_err_response import RestErrResponse +from ..types.schedule import Schedule +from ..types.schedule_option_response_envelope import ScheduleOptionResponseEnvelope +from ..types.start_model_sync_response_envelope import StartModelSyncResponseEnvelope +from ..types.sync_status_envelope import SyncStatusEnvelope +from ..types.target import Target +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawModelSyncClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_source( + self, + id: str, + *, + params: typing.Optional[typing.Dict[str, typing.Sequence[str]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetModelSyncSourceMetaEnvelope]: + """ + Parameters + ---------- + id : str + + params : typing.Optional[typing.Dict[str, typing.Sequence[str]]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetModelSyncSourceMetaEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/modelsync/source", + method="GET", + params={ + "params": params, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetModelSyncSourceMetaEnvelope, + parse_obj_as( + type_=GetModelSyncSourceMetaEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_source_fields( + self, + id: str, + *, + params: typing.Optional[typing.Dict[str, typing.Sequence[str]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ModelFieldResponse]: + """ + Parameters + ---------- + id : str + + params : typing.Optional[typing.Dict[str, typing.Sequence[str]]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ModelFieldResponse] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/modelsync/source/fields", + method="GET", + params={ + "params": params, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelFieldResponse, + parse_obj_as( + type_=ModelFieldResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def list( + self, + *, + active: typing.Optional[bool] = None, + mode: typing.Optional[ModelSyncMode] = None, + target_connection_id: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ListModelSyncResponseEnvelope]: + """ + Parameters + ---------- + active : typing.Optional[bool] + + mode : typing.Optional[ModelSyncMode] + + target_connection_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ListModelSyncResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/syncs", + method="GET", + params={ + "active": active, + "mode": mode, + "target_connection_id": target_connection_id, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListModelSyncResponseEnvelope, + parse_obj_as( + type_=ListModelSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def create( + self, + *, + fields: typing.Sequence[ModelSyncField], + mode: ModelSyncMode, + name: str, + schedule: Schedule, + target: Target, + active: typing.Optional[bool] = OMIT, + encryption_passphrase: typing.Optional[str] = OMIT, + filter_logic: typing.Optional[str] = OMIT, + filters: typing.Optional[typing.Sequence[Filter]] = OMIT, + identity: typing.Optional[Identity] = OMIT, + only_enrich_updates: typing.Optional[bool] = OMIT, + organization_id: typing.Optional[str] = OMIT, + override_fields: typing.Optional[typing.Sequence[ModelSyncField]] = OMIT, + overrides: typing.Optional[typing.Sequence[Override]] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + skip_initial_backfill: typing.Optional[bool] = OMIT, + sync_all_records: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ModelSyncResponseEnvelope]: + """ + Create a new sync from one or more models to a destination. + + All of the functionality described in [the product + documentation](https://docs.polytomic.com/docs/sync-destinations) is + configurable via the API. + + Guides: + + - [Model sync (Reverse ETL) from Snowflake query to Salesforce](https://apidocs.polytomic.com/2024-02-08/guides/code-examples/model-sync-reverse-etl-from-snowflake-query-to-salesforce) + - [Joined model sync from Postgres, Airtable, and Stripe to Hubspot](https://apidocs.polytomic.com/2024-02-08/guides/code-examples/joined-model-sync-from-postgres-airtable-and-stripe-to-hubspot) + + ## Targets (Destinations) + + Polytomic refers to a model sync's destination as the "target object", or + target. Target objects are identified by a connection ID and an object ID. You + can retrieve a list of all target objects for a connection using the [Get Target + Objects](./targets/list) endpoint. + + The `target` object in the request specifies information about the sync destination. + + ```json + "target": { + "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d", + "object": "Users", + }, + ``` + + Some connections support additional configuration for targets. For example, + [Salesforce + connections](https://apidocs.polytomic.com/2024-02-08/guides/configuring-your-connections/connections/salesforce#target) + support optionally specifying the ingestion API to use. The target specific + options are passed as `configuration`; consult the [integration + guides](https://apidocs.polytomic.com/2024-02-08/guides/configuring-your-connections/overview) + for details about specific connection configurations. + + ### Creating a new target + + Some integrations support creating a new target when creating a model sync. For + example, an ad audience or database table. + + When creating a new target, `object` is omitted and `create` is specified + instead. The `create` property is an object containing integration specific + configuration for the new target. + + ```json + "target": { + "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d", + "create": { + "name": "New audience", + "type": "user_audience" + } + }, + ``` + + The [Get Target List](./targets/list) endpoint returns information about whether + a connection supports target creation. + + Parameters + ---------- + fields : typing.Sequence[ModelSyncField] + Fields to sync from source to destination. + + mode : ModelSyncMode + + name : str + + schedule : Schedule + + target : Target + + active : typing.Optional[bool] + Whether the sync is enabled and scheduled. + + encryption_passphrase : typing.Optional[str] + Passphrase for encrypting the sync data. + + filter_logic : typing.Optional[str] + Logical expression to combine filters. + + filters : typing.Optional[typing.Sequence[Filter]] + Filters to apply to the source data. + + identity : typing.Optional[Identity] + + only_enrich_updates : typing.Optional[bool] + Whether to use enrichment models as a source of possible changes to sync. If true, only changes to the base models will cause a record to sync. + + organization_id : typing.Optional[str] + Organization ID for the sync; read-only with a partner key. + + override_fields : typing.Optional[typing.Sequence[ModelSyncField]] + Values to set in the target unconditionally. + + overrides : typing.Optional[typing.Sequence[Override]] + Conditional value replacement for fields. + + policies : typing.Optional[typing.Sequence[str]] + + skip_initial_backfill : typing.Optional[bool] + Whether to skip the initial backfill of records; if true only records seen after the sync is enabled will be synced. + + sync_all_records : typing.Optional[bool] + Whether to sync all records from the source, regardless of whether they've changed since the previous execution. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ModelSyncResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/syncs", + method="POST", + json={ + "active": active, + "encryption_passphrase": encryption_passphrase, + "fields": convert_and_respect_annotation_metadata( + object_=fields, annotation=typing.Sequence[ModelSyncField], direction="write" + ), + "filter_logic": filter_logic, + "filters": convert_and_respect_annotation_metadata( + object_=filters, annotation=typing.Optional[typing.Sequence[Filter]], direction="write" + ), + "identity": convert_and_respect_annotation_metadata( + object_=identity, annotation=Identity, direction="write" + ), + "mode": mode, + "name": name, + "only_enrich_updates": only_enrich_updates, + "organization_id": organization_id, + "override_fields": convert_and_respect_annotation_metadata( + object_=override_fields, + annotation=typing.Optional[typing.Sequence[ModelSyncField]], + direction="write", + ), + "overrides": convert_and_respect_annotation_metadata( + object_=overrides, annotation=typing.Optional[typing.Sequence[Override]], direction="write" + ), + "policies": policies, + "schedule": convert_and_respect_annotation_metadata( + object_=schedule, annotation=Schedule, direction="write" + ), + "skip_initial_backfill": skip_initial_backfill, + "sync_all_records": sync_all_records, + "target": convert_and_respect_annotation_metadata(object_=target, annotation=Target, direction="write"), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelSyncResponseEnvelope, + parse_obj_as( + type_=ModelSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_schedule_options( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ScheduleOptionResponseEnvelope]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ScheduleOptionResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/syncs/schedules", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ScheduleOptionResponseEnvelope, + parse_obj_as( + type_=ScheduleOptionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ModelSyncResponseEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ModelSyncResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelSyncResponseEnvelope, + parse_obj_as( + type_=ModelSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def update( + self, + id: str, + *, + fields: typing.Sequence[ModelSyncField], + mode: ModelSyncMode, + name: str, + schedule: Schedule, + target: Target, + active: typing.Optional[bool] = OMIT, + encryption_passphrase: typing.Optional[str] = OMIT, + filter_logic: typing.Optional[str] = OMIT, + filters: typing.Optional[typing.Sequence[Filter]] = OMIT, + identity: typing.Optional[Identity] = OMIT, + only_enrich_updates: typing.Optional[bool] = OMIT, + organization_id: typing.Optional[str] = OMIT, + override_fields: typing.Optional[typing.Sequence[ModelSyncField]] = OMIT, + overrides: typing.Optional[typing.Sequence[Override]] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + skip_initial_backfill: typing.Optional[bool] = OMIT, + sync_all_records: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ModelSyncResponseEnvelope]: + """ + Parameters + ---------- + id : str + + fields : typing.Sequence[ModelSyncField] + Fields to sync from source to destination. + + mode : ModelSyncMode + + name : str + + schedule : Schedule + + target : Target + + active : typing.Optional[bool] + Whether the sync is enabled and scheduled. + + encryption_passphrase : typing.Optional[str] + Passphrase for encrypting the sync data. + + filter_logic : typing.Optional[str] + Logical expression to combine filters. + + filters : typing.Optional[typing.Sequence[Filter]] + Filters to apply to the source data. + + identity : typing.Optional[Identity] + + only_enrich_updates : typing.Optional[bool] + Whether to use enrichment models as a source of possible changes to sync. If true, only changes to the base models will cause a record to sync. + + organization_id : typing.Optional[str] + Organization ID for the sync; read-only with a partner key. + + override_fields : typing.Optional[typing.Sequence[ModelSyncField]] + Values to set in the target unconditionally. + + overrides : typing.Optional[typing.Sequence[Override]] + Conditional value replacement for fields. + + policies : typing.Optional[typing.Sequence[str]] + + skip_initial_backfill : typing.Optional[bool] + Whether to skip the initial backfill of records; if true only records seen after the sync is enabled will be synced. + + sync_all_records : typing.Optional[bool] + Whether to sync all records from the source, regardless of whether they've changed since the previous execution. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ModelSyncResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(id)}", + method="PUT", + json={ + "active": active, + "encryption_passphrase": encryption_passphrase, + "fields": convert_and_respect_annotation_metadata( + object_=fields, annotation=typing.Sequence[ModelSyncField], direction="write" + ), + "filter_logic": filter_logic, + "filters": convert_and_respect_annotation_metadata( + object_=filters, annotation=typing.Optional[typing.Sequence[Filter]], direction="write" + ), + "identity": convert_and_respect_annotation_metadata( + object_=identity, annotation=Identity, direction="write" + ), + "mode": mode, + "name": name, + "only_enrich_updates": only_enrich_updates, + "organization_id": organization_id, + "override_fields": convert_and_respect_annotation_metadata( + object_=override_fields, + annotation=typing.Optional[typing.Sequence[ModelSyncField]], + direction="write", + ), + "overrides": convert_and_respect_annotation_metadata( + object_=overrides, annotation=typing.Optional[typing.Sequence[Override]], direction="write" + ), + "policies": policies, + "schedule": convert_and_respect_annotation_metadata( + object_=schedule, annotation=Schedule, direction="write" + ), + "skip_initial_backfill": skip_initial_backfill, + "sync_all_records": sync_all_records, + "target": convert_and_respect_annotation_metadata(object_=target, annotation=Target, direction="write"), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelSyncResponseEnvelope, + parse_obj_as( + type_=ModelSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def activate( + self, id: str, *, active: bool, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ActivateSyncEnvelope]: + """ + Parameters + ---------- + id : str + + active : bool + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ActivateSyncEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(id)}/activate", + method="POST", + json={ + "active": active, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ActivateSyncEnvelope, + parse_obj_as( + type_=ActivateSyncEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def cancel( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[CancelModelSyncResponseEnvelope]: + """ + Parameters + ---------- + id : str + The active execution of this sync ID will be cancelled. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CancelModelSyncResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(id)}/cancel", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CancelModelSyncResponseEnvelope, + parse_obj_as( + type_=CancelModelSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def start( + self, + id: str, + *, + identities: typing.Optional[typing.Sequence[str]] = OMIT, + resync: typing.Optional[bool] = OMIT, + test: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[StartModelSyncResponseEnvelope]: + """ + > 🚧 Force full resync + > + > Use caution when setting the `resync` parameter to `true`. This will force a full resync of the data from the source system. This can be a time-consuming operation and may impact the performance of the source system. It is recommended to only use this option when necessary. + + Parameters + ---------- + id : str + + identities : typing.Optional[typing.Sequence[str]] + + resync : typing.Optional[bool] + + test : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[StartModelSyncResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(id)}/executions", + method="POST", + json={ + "identities": identities, + "resync": resync, + "test": test, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + StartModelSyncResponseEnvelope, + parse_obj_as( + type_=StartModelSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_status( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[SyncStatusEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SyncStatusEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(id)}/status", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SyncStatusEnvelope, + parse_obj_as( + type_=SyncStatusEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawModelSyncClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_source( + self, + id: str, + *, + params: typing.Optional[typing.Dict[str, typing.Sequence[str]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetModelSyncSourceMetaEnvelope]: + """ + Parameters + ---------- + id : str + + params : typing.Optional[typing.Dict[str, typing.Sequence[str]]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetModelSyncSourceMetaEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/modelsync/source", + method="GET", + params={ + "params": params, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetModelSyncSourceMetaEnvelope, + parse_obj_as( + type_=GetModelSyncSourceMetaEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_source_fields( + self, + id: str, + *, + params: typing.Optional[typing.Dict[str, typing.Sequence[str]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ModelFieldResponse]: + """ + Parameters + ---------- + id : str + + params : typing.Optional[typing.Dict[str, typing.Sequence[str]]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ModelFieldResponse] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/modelsync/source/fields", + method="GET", + params={ + "params": params, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelFieldResponse, + parse_obj_as( + type_=ModelFieldResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def list( + self, + *, + active: typing.Optional[bool] = None, + mode: typing.Optional[ModelSyncMode] = None, + target_connection_id: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ListModelSyncResponseEnvelope]: + """ + Parameters + ---------- + active : typing.Optional[bool] + + mode : typing.Optional[ModelSyncMode] + + target_connection_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ListModelSyncResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/syncs", + method="GET", + params={ + "active": active, + "mode": mode, + "target_connection_id": target_connection_id, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListModelSyncResponseEnvelope, + parse_obj_as( + type_=ListModelSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def create( + self, + *, + fields: typing.Sequence[ModelSyncField], + mode: ModelSyncMode, + name: str, + schedule: Schedule, + target: Target, + active: typing.Optional[bool] = OMIT, + encryption_passphrase: typing.Optional[str] = OMIT, + filter_logic: typing.Optional[str] = OMIT, + filters: typing.Optional[typing.Sequence[Filter]] = OMIT, + identity: typing.Optional[Identity] = OMIT, + only_enrich_updates: typing.Optional[bool] = OMIT, + organization_id: typing.Optional[str] = OMIT, + override_fields: typing.Optional[typing.Sequence[ModelSyncField]] = OMIT, + overrides: typing.Optional[typing.Sequence[Override]] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + skip_initial_backfill: typing.Optional[bool] = OMIT, + sync_all_records: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ModelSyncResponseEnvelope]: + """ + Create a new sync from one or more models to a destination. + + All of the functionality described in [the product + documentation](https://docs.polytomic.com/docs/sync-destinations) is + configurable via the API. + + Guides: + + - [Model sync (Reverse ETL) from Snowflake query to Salesforce](https://apidocs.polytomic.com/2024-02-08/guides/code-examples/model-sync-reverse-etl-from-snowflake-query-to-salesforce) + - [Joined model sync from Postgres, Airtable, and Stripe to Hubspot](https://apidocs.polytomic.com/2024-02-08/guides/code-examples/joined-model-sync-from-postgres-airtable-and-stripe-to-hubspot) + + ## Targets (Destinations) + + Polytomic refers to a model sync's destination as the "target object", or + target. Target objects are identified by a connection ID and an object ID. You + can retrieve a list of all target objects for a connection using the [Get Target + Objects](./targets/list) endpoint. + + The `target` object in the request specifies information about the sync destination. + + ```json + "target": { + "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d", + "object": "Users", + }, + ``` + + Some connections support additional configuration for targets. For example, + [Salesforce + connections](https://apidocs.polytomic.com/2024-02-08/guides/configuring-your-connections/connections/salesforce#target) + support optionally specifying the ingestion API to use. The target specific + options are passed as `configuration`; consult the [integration + guides](https://apidocs.polytomic.com/2024-02-08/guides/configuring-your-connections/overview) + for details about specific connection configurations. + + ### Creating a new target + + Some integrations support creating a new target when creating a model sync. For + example, an ad audience or database table. + + When creating a new target, `object` is omitted and `create` is specified + instead. The `create` property is an object containing integration specific + configuration for the new target. + + ```json + "target": { + "connection_id": "248df4b7-aa70-47b8-a036-33ac447e668d", + "create": { + "name": "New audience", + "type": "user_audience" + } + }, + ``` + + The [Get Target List](./targets/list) endpoint returns information about whether + a connection supports target creation. + + Parameters + ---------- + fields : typing.Sequence[ModelSyncField] + Fields to sync from source to destination. + + mode : ModelSyncMode + + name : str + + schedule : Schedule + + target : Target + + active : typing.Optional[bool] + Whether the sync is enabled and scheduled. + + encryption_passphrase : typing.Optional[str] + Passphrase for encrypting the sync data. + + filter_logic : typing.Optional[str] + Logical expression to combine filters. + + filters : typing.Optional[typing.Sequence[Filter]] + Filters to apply to the source data. + + identity : typing.Optional[Identity] + + only_enrich_updates : typing.Optional[bool] + Whether to use enrichment models as a source of possible changes to sync. If true, only changes to the base models will cause a record to sync. + + organization_id : typing.Optional[str] + Organization ID for the sync; read-only with a partner key. + + override_fields : typing.Optional[typing.Sequence[ModelSyncField]] + Values to set in the target unconditionally. + + overrides : typing.Optional[typing.Sequence[Override]] + Conditional value replacement for fields. + + policies : typing.Optional[typing.Sequence[str]] + + skip_initial_backfill : typing.Optional[bool] + Whether to skip the initial backfill of records; if true only records seen after the sync is enabled will be synced. + + sync_all_records : typing.Optional[bool] + Whether to sync all records from the source, regardless of whether they've changed since the previous execution. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ModelSyncResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/syncs", + method="POST", + json={ + "active": active, + "encryption_passphrase": encryption_passphrase, + "fields": convert_and_respect_annotation_metadata( + object_=fields, annotation=typing.Sequence[ModelSyncField], direction="write" + ), + "filter_logic": filter_logic, + "filters": convert_and_respect_annotation_metadata( + object_=filters, annotation=typing.Optional[typing.Sequence[Filter]], direction="write" + ), + "identity": convert_and_respect_annotation_metadata( + object_=identity, annotation=Identity, direction="write" + ), + "mode": mode, + "name": name, + "only_enrich_updates": only_enrich_updates, + "organization_id": organization_id, + "override_fields": convert_and_respect_annotation_metadata( + object_=override_fields, + annotation=typing.Optional[typing.Sequence[ModelSyncField]], + direction="write", + ), + "overrides": convert_and_respect_annotation_metadata( + object_=overrides, annotation=typing.Optional[typing.Sequence[Override]], direction="write" + ), + "policies": policies, + "schedule": convert_and_respect_annotation_metadata( + object_=schedule, annotation=Schedule, direction="write" + ), + "skip_initial_backfill": skip_initial_backfill, + "sync_all_records": sync_all_records, + "target": convert_and_respect_annotation_metadata(object_=target, annotation=Target, direction="write"), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelSyncResponseEnvelope, + parse_obj_as( + type_=ModelSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_schedule_options( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ScheduleOptionResponseEnvelope]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ScheduleOptionResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/syncs/schedules", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ScheduleOptionResponseEnvelope, + parse_obj_as( + type_=ScheduleOptionResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ModelSyncResponseEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ModelSyncResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelSyncResponseEnvelope, + parse_obj_as( + type_=ModelSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def update( + self, + id: str, + *, + fields: typing.Sequence[ModelSyncField], + mode: ModelSyncMode, + name: str, + schedule: Schedule, + target: Target, + active: typing.Optional[bool] = OMIT, + encryption_passphrase: typing.Optional[str] = OMIT, + filter_logic: typing.Optional[str] = OMIT, + filters: typing.Optional[typing.Sequence[Filter]] = OMIT, + identity: typing.Optional[Identity] = OMIT, + only_enrich_updates: typing.Optional[bool] = OMIT, + organization_id: typing.Optional[str] = OMIT, + override_fields: typing.Optional[typing.Sequence[ModelSyncField]] = OMIT, + overrides: typing.Optional[typing.Sequence[Override]] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + skip_initial_backfill: typing.Optional[bool] = OMIT, + sync_all_records: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ModelSyncResponseEnvelope]: + """ + Parameters + ---------- + id : str + + fields : typing.Sequence[ModelSyncField] + Fields to sync from source to destination. + + mode : ModelSyncMode + + name : str + + schedule : Schedule + + target : Target + + active : typing.Optional[bool] + Whether the sync is enabled and scheduled. + + encryption_passphrase : typing.Optional[str] + Passphrase for encrypting the sync data. + + filter_logic : typing.Optional[str] + Logical expression to combine filters. + + filters : typing.Optional[typing.Sequence[Filter]] + Filters to apply to the source data. + + identity : typing.Optional[Identity] + + only_enrich_updates : typing.Optional[bool] + Whether to use enrichment models as a source of possible changes to sync. If true, only changes to the base models will cause a record to sync. + + organization_id : typing.Optional[str] + Organization ID for the sync; read-only with a partner key. + + override_fields : typing.Optional[typing.Sequence[ModelSyncField]] + Values to set in the target unconditionally. + + overrides : typing.Optional[typing.Sequence[Override]] + Conditional value replacement for fields. + + policies : typing.Optional[typing.Sequence[str]] + + skip_initial_backfill : typing.Optional[bool] + Whether to skip the initial backfill of records; if true only records seen after the sync is enabled will be synced. + + sync_all_records : typing.Optional[bool] + Whether to sync all records from the source, regardless of whether they've changed since the previous execution. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ModelSyncResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(id)}", + method="PUT", + json={ + "active": active, + "encryption_passphrase": encryption_passphrase, + "fields": convert_and_respect_annotation_metadata( + object_=fields, annotation=typing.Sequence[ModelSyncField], direction="write" + ), + "filter_logic": filter_logic, + "filters": convert_and_respect_annotation_metadata( + object_=filters, annotation=typing.Optional[typing.Sequence[Filter]], direction="write" + ), + "identity": convert_and_respect_annotation_metadata( + object_=identity, annotation=Identity, direction="write" + ), + "mode": mode, + "name": name, + "only_enrich_updates": only_enrich_updates, + "organization_id": organization_id, + "override_fields": convert_and_respect_annotation_metadata( + object_=override_fields, + annotation=typing.Optional[typing.Sequence[ModelSyncField]], + direction="write", + ), + "overrides": convert_and_respect_annotation_metadata( + object_=overrides, annotation=typing.Optional[typing.Sequence[Override]], direction="write" + ), + "policies": policies, + "schedule": convert_and_respect_annotation_metadata( + object_=schedule, annotation=Schedule, direction="write" + ), + "skip_initial_backfill": skip_initial_backfill, + "sync_all_records": sync_all_records, + "target": convert_and_respect_annotation_metadata(object_=target, annotation=Target, direction="write"), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelSyncResponseEnvelope, + parse_obj_as( + type_=ModelSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def remove( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def activate( + self, id: str, *, active: bool, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ActivateSyncEnvelope]: + """ + Parameters + ---------- + id : str + + active : bool + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ActivateSyncEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(id)}/activate", + method="POST", + json={ + "active": active, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ActivateSyncEnvelope, + parse_obj_as( + type_=ActivateSyncEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def cancel( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[CancelModelSyncResponseEnvelope]: + """ + Parameters + ---------- + id : str + The active execution of this sync ID will be cancelled. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CancelModelSyncResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(id)}/cancel", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CancelModelSyncResponseEnvelope, + parse_obj_as( + type_=CancelModelSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def start( + self, + id: str, + *, + identities: typing.Optional[typing.Sequence[str]] = OMIT, + resync: typing.Optional[bool] = OMIT, + test: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[StartModelSyncResponseEnvelope]: + """ + > 🚧 Force full resync + > + > Use caution when setting the `resync` parameter to `true`. This will force a full resync of the data from the source system. This can be a time-consuming operation and may impact the performance of the source system. It is recommended to only use this option when necessary. + + Parameters + ---------- + id : str + + identities : typing.Optional[typing.Sequence[str]] + + resync : typing.Optional[bool] + + test : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[StartModelSyncResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(id)}/executions", + method="POST", + json={ + "identities": identities, + "resync": resync, + "test": test, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + StartModelSyncResponseEnvelope, + parse_obj_as( + type_=StartModelSyncResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_status( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[SyncStatusEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SyncStatusEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/syncs/{jsonable_encoder(id)}/status", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SyncStatusEnvelope, + parse_obj_as( + type_=SyncStatusEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/model_sync/targets/__init__.py b/src/polytomic/model_sync/targets/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/model_sync/targets/__init__.py +++ b/src/polytomic/model_sync/targets/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/model_sync/targets/client.py b/src/polytomic/model_sync/targets/client.py index 59dcf67..fda60a3 100644 --- a/src/polytomic/model_sync/targets/client.py +++ b/src/polytomic/model_sync/targets/client.py @@ -1,29 +1,30 @@ # This file was auto-generated by Fern from our API Definition. -from ...core.client_wrapper import SyncClientWrapper import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.request_options import RequestOptions from ...types.get_connection_meta_envelope import GetConnectionMetaEnvelope -from ...core.jsonable_encoder import jsonable_encoder -from ...core.pydantic_utilities import parse_obj_as -from ...errors.bad_request_error import BadRequestError -from ...types.api_error import ApiError as types_api_error_ApiError -from ...errors.unauthorized_error import UnauthorizedError -from ...types.rest_err_response import RestErrResponse -from ...errors.forbidden_error import ForbiddenError -from ...errors.not_found_error import NotFoundError -from ...errors.internal_server_error import InternalServerError -from json.decoder import JSONDecodeError -from ...core.api_error import ApiError as core_api_error_ApiError from ...types.target_response_envelope import TargetResponseEnvelope from ...types.v_4_target_objects_response_envelope import V4TargetObjectsResponseEnvelope from ...types.v_4_target_property_values_envelope import V4TargetPropertyValuesEnvelope -from ...core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawTargetsClient, RawTargetsClient class TargetsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawTargetsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawTargetsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawTargetsClient + """ + return self._raw_client def get_target( self, @@ -62,78 +63,8 @@ def get_target( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/modelsync/target", - method="GET", - params={ - "type": type, - "search": search, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetConnectionMetaEnvelope, - parse_obj_as( - type_=GetConnectionMetaEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_target(id, type=type, search=search, request_options=request_options) + return _response.data def get_target_fields( self, @@ -174,68 +105,10 @@ def get_target_fields( refresh=False, ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/modelsync/target/fields", - method="GET", - params={ - "target": target, - "refresh": refresh, - }, - request_options=request_options, + _response = self._raw_client.get_target_fields( + id, target=target, refresh=refresh, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - TargetResponseEnvelope, - parse_obj_as( - type_=TargetResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def list( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -283,74 +156,8 @@ def list( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/modelsync/targetobjects", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4TargetObjectsResponseEnvelope, - parse_obj_as( - type_=V4TargetObjectsResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.list(id, request_options=request_options) + return _response.data def get_create_property( self, id: str, property: str, *, request_options: typing.Optional[RequestOptions] = None @@ -414,79 +221,24 @@ def get_create_property( property="property", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/modelsync/targetobjects/properties/{jsonable_encoder(property)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4TargetPropertyValuesEnvelope, - parse_obj_as( - type_=V4TargetPropertyValuesEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_create_property(id, property, request_options=request_options) + return _response.data class AsyncTargetsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawTargetsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawTargetsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawTargetsClient + """ + return self._raw_client async def get_target( self, @@ -533,78 +285,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/modelsync/target", - method="GET", - params={ - "type": type, - "search": search, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetConnectionMetaEnvelope, - parse_obj_as( - type_=GetConnectionMetaEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_target(id, type=type, search=search, request_options=request_options) + return _response.data async def get_target_fields( self, @@ -653,68 +335,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/modelsync/target/fields", - method="GET", - params={ - "target": target, - "refresh": refresh, - }, - request_options=request_options, + _response = await self._raw_client.get_target_fields( + id, target=target, refresh=refresh, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - TargetResponseEnvelope, - parse_obj_as( - type_=TargetResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def list( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -770,74 +394,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/modelsync/targetobjects", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4TargetObjectsResponseEnvelope, - parse_obj_as( - type_=V4TargetObjectsResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.list(id, request_options=request_options) + return _response.data async def get_create_property( self, id: str, property: str, *, request_options: typing.Optional[RequestOptions] = None @@ -909,71 +467,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/modelsync/targetobjects/properties/{jsonable_encoder(property)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4TargetPropertyValuesEnvelope, - parse_obj_as( - type_=V4TargetPropertyValuesEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_create_property(id, property, request_options=request_options) + return _response.data diff --git a/src/polytomic/model_sync/targets/raw_client.py b/src/polytomic/model_sync/targets/raw_client.py new file mode 100644 index 0000000..12ecbcc --- /dev/null +++ b/src/polytomic/model_sync/targets/raw_client.py @@ -0,0 +1,958 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError as core_api_error_ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.parse_error import ParsingError +from ...core.pydantic_utilities import parse_obj_as +from ...core.request_options import RequestOptions +from ...errors.bad_request_error import BadRequestError +from ...errors.forbidden_error import ForbiddenError +from ...errors.internal_server_error import InternalServerError +from ...errors.not_found_error import NotFoundError +from ...errors.unauthorized_error import UnauthorizedError +from ...types.api_error import ApiError as types_api_error_ApiError +from ...types.get_connection_meta_envelope import GetConnectionMetaEnvelope +from ...types.rest_err_response import RestErrResponse +from ...types.target_response_envelope import TargetResponseEnvelope +from ...types.v_4_target_objects_response_envelope import V4TargetObjectsResponseEnvelope +from ...types.v_4_target_property_values_envelope import V4TargetPropertyValuesEnvelope +from pydantic import ValidationError + + +class RawTargetsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_target( + self, + id: str, + *, + type: typing.Optional[str] = None, + search: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetConnectionMetaEnvelope]: + """ + Parameters + ---------- + id : str + + type : typing.Optional[str] + + search : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetConnectionMetaEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/modelsync/target", + method="GET", + params={ + "type": type, + "search": search, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetConnectionMetaEnvelope, + parse_obj_as( + type_=GetConnectionMetaEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_target_fields( + self, + id: str, + *, + target: str, + refresh: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[TargetResponseEnvelope]: + """ + Parameters + ---------- + id : str + + target : str + + refresh : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[TargetResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/modelsync/target/fields", + method="GET", + params={ + "target": target, + "refresh": refresh, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + TargetResponseEnvelope, + parse_obj_as( + type_=TargetResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def list( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[V4TargetObjectsResponseEnvelope]: + """ + Returns available model sync destinations for a connection. + + If the connection supports creating new destinations, the `target_creation` + object will contain information on what properties are required to create the + target. + + Target creation properties are all string values; the `enum` flag indicates if + the property has a fixed set of valid values. When `enum` is `true`, the [Target + Creation Property + Values](https://apidocs.polytomic.com/2024-02-08/api-reference/model-sync/targets/get-create-property) + endpoint can be used to retrieve the valid values. + + ## Sync modes + + The sync mode determines which records are written to the destination for a + model sync. The `modes` array for a target object defines the `id` along with + what operations the mode supports. + + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[V4TargetObjectsResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/modelsync/targetobjects", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4TargetObjectsResponseEnvelope, + parse_obj_as( + type_=V4TargetObjectsResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_create_property( + self, id: str, property: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[V4TargetPropertyValuesEnvelope]: + """ + Connections which support creating new sync target objects (destinations) will + return `target_creation` with their [target object list](./list). This endpoint + will return possible values for properties where `enum` is `true`. + + If the connection does not support creating new target objects, an HTTP 404 will + be returned. + + The `values` array lists the valid options (and labels) for the property. Each + member of the `values` array has a `label` and `value`. For exaample, + + ```json + { + "data": [ + { + "id": "account", + "title": "Account ID", + "enum": true, + "values": [ + { + "value": "1234567::urn:li:organization:987654", + "label": "Polytomic Inc. (1234567)" + } + ] + } + ] + } + ``` + + The `value` for the selected option should be passed when [creating a + sync](https://apidocs.polytomic.com/2024-02-08/api-reference/model-sync/create). + + Parameters + ---------- + id : str + + property : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[V4TargetPropertyValuesEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/modelsync/targetobjects/properties/{jsonable_encoder(property)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4TargetPropertyValuesEnvelope, + parse_obj_as( + type_=V4TargetPropertyValuesEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawTargetsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_target( + self, + id: str, + *, + type: typing.Optional[str] = None, + search: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetConnectionMetaEnvelope]: + """ + Parameters + ---------- + id : str + + type : typing.Optional[str] + + search : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetConnectionMetaEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/modelsync/target", + method="GET", + params={ + "type": type, + "search": search, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetConnectionMetaEnvelope, + parse_obj_as( + type_=GetConnectionMetaEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_target_fields( + self, + id: str, + *, + target: str, + refresh: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[TargetResponseEnvelope]: + """ + Parameters + ---------- + id : str + + target : str + + refresh : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[TargetResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/modelsync/target/fields", + method="GET", + params={ + "target": target, + "refresh": refresh, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + TargetResponseEnvelope, + parse_obj_as( + type_=TargetResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def list( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[V4TargetObjectsResponseEnvelope]: + """ + Returns available model sync destinations for a connection. + + If the connection supports creating new destinations, the `target_creation` + object will contain information on what properties are required to create the + target. + + Target creation properties are all string values; the `enum` flag indicates if + the property has a fixed set of valid values. When `enum` is `true`, the [Target + Creation Property + Values](https://apidocs.polytomic.com/2024-02-08/api-reference/model-sync/targets/get-create-property) + endpoint can be used to retrieve the valid values. + + ## Sync modes + + The sync mode determines which records are written to the destination for a + model sync. The `modes` array for a target object defines the `id` along with + what operations the mode supports. + + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[V4TargetObjectsResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/modelsync/targetobjects", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4TargetObjectsResponseEnvelope, + parse_obj_as( + type_=V4TargetObjectsResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_create_property( + self, id: str, property: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[V4TargetPropertyValuesEnvelope]: + """ + Connections which support creating new sync target objects (destinations) will + return `target_creation` with their [target object list](./list). This endpoint + will return possible values for properties where `enum` is `true`. + + If the connection does not support creating new target objects, an HTTP 404 will + be returned. + + The `values` array lists the valid options (and labels) for the property. Each + member of the `values` array has a `label` and `value`. For exaample, + + ```json + { + "data": [ + { + "id": "account", + "title": "Account ID", + "enum": true, + "values": [ + { + "value": "1234567::urn:li:organization:987654", + "label": "Polytomic Inc. (1234567)" + } + ] + } + ] + } + ``` + + The `value` for the selected option should be passed when [creating a + sync](https://apidocs.polytomic.com/2024-02-08/api-reference/model-sync/create). + + Parameters + ---------- + id : str + + property : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[V4TargetPropertyValuesEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/modelsync/targetobjects/properties/{jsonable_encoder(property)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4TargetPropertyValuesEnvelope, + parse_obj_as( + type_=V4TargetPropertyValuesEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/models/__init__.py b/src/polytomic/models/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/models/__init__.py +++ b/src/polytomic/models/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/models/client.py b/src/polytomic/models/client.py index 45efe7f..dc85420 100644 --- a/src/polytomic/models/client.py +++ b/src/polytomic/models/client.py @@ -1,30 +1,19 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.enrichment import Enrichment from ..types.get_model_sync_source_meta_envelope import GetModelSyncSourceMetaEnvelope -from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import parse_obj_as -from ..errors.bad_request_error import BadRequestError -from ..types.api_error import ApiError as types_api_error_ApiError -from ..errors.unauthorized_error import UnauthorizedError -from ..types.rest_err_response import RestErrResponse -from ..errors.forbidden_error import ForbiddenError -from ..errors.not_found_error import NotFoundError -from ..errors.internal_server_error import InternalServerError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError as core_api_error_ApiError -from ..types.v_2_enricher_configuration import V2EnricherConfiguration -from ..types.v_2_get_enrichment_input_fields_response_envelope import V2GetEnrichmentInputFieldsResponseEnvelope +from ..types.model_list_response_envelope import ModelListResponseEnvelope from ..types.model_model_field_request import ModelModelFieldRequest -from ..types.enrichment import Enrichment from ..types.model_relation import ModelRelation from ..types.model_response_envelope import ModelResponseEnvelope -from ..core.serialization import convert_and_respect_annotation_metadata -from ..types.model_list_response_envelope import ModelListResponseEnvelope from ..types.model_sample_response_envelope import ModelSampleResponseEnvelope -from ..core.client_wrapper import AsyncClientWrapper +from ..types.v_2_enricher_configuration import V2EnricherConfiguration +from ..types.v_2_get_enrichment_input_fields_response_envelope import V2GetEnrichmentInputFieldsResponseEnvelope +from .raw_client import AsyncRawModelsClient, RawModelsClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -32,13 +21,24 @@ class ModelsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawModelsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawModelsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawModelsClient + """ + return self._raw_client def get_enrichment_source( self, id: str, *, - params: typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]] = None, + params: typing.Optional[typing.Dict[str, typing.Sequence[str]]] = None, request_options: typing.Optional[RequestOptions] = None, ) -> GetModelSyncSourceMetaEnvelope: """ @@ -46,7 +46,7 @@ def get_enrichment_source( ---------- id : str - params : typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]] + params : typing.Optional[typing.Dict[str, typing.Sequence[str]]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -68,77 +68,8 @@ def get_enrichment_source( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/modelsync/enrichment-source", - method="GET", - params={ - "params": params, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetModelSyncSourceMetaEnvelope, - parse_obj_as( - type_=GetModelSyncSourceMetaEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_enrichment_source(id, params=params, request_options=request_options) + return _response.data def post( self, @@ -176,76 +107,13 @@ def post( connection_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/enrichment/{jsonable_encoder(connection_id)}/inputfields", - method="POST", - json={ - "configuration": configuration, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V2GetEnrichmentInputFieldsResponseEnvelope, - parse_obj_as( - type_=V2GetEnrichmentInputFieldsResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.post(connection_id, configuration=configuration, request_options=request_options) + return _response.data def preview( self, *, - configuration: typing.Dict[str, typing.Optional[typing.Any]], + configuration: typing.Dict[str, typing.Any], connection_id: str, name: str, async_: typing.Optional[bool] = None, @@ -263,7 +131,7 @@ def preview( """ Parameters ---------- - configuration : typing.Dict[str, typing.Optional[typing.Any]] + configuration : typing.Dict[str, typing.Any] connection_id : str @@ -311,88 +179,23 @@ def preview( name="Users", ) """ - _response = self._client_wrapper.httpx_client.request( - "api/model-preview", - method="POST", - params={ - "async": async_, - }, - json={ - "additional_fields": convert_and_respect_annotation_metadata( - object_=additional_fields, annotation=typing.Sequence[ModelModelFieldRequest], direction="write" - ), - "configuration": configuration, - "connection_id": connection_id, - "enricher": convert_and_respect_annotation_metadata( - object_=enricher, annotation=Enrichment, direction="write" - ), - "fields": fields, - "identifier": identifier, - "labels": labels, - "name": name, - "organization_id": organization_id, - "policies": policies, - "relations": convert_and_respect_annotation_metadata( - object_=relations, annotation=typing.Sequence[ModelRelation], direction="write" - ), - "tracking_columns": tracking_columns, - }, + _response = self._raw_client.preview( + configuration=configuration, + connection_id=connection_id, + name=name, + async_=async_, + additional_fields=additional_fields, + enricher=enricher, + fields=fields, + identifier=identifier, + labels=labels, + organization_id=organization_id, + policies=policies, + relations=relations, + tracking_columns=tracking_columns, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelResponseEnvelope, - parse_obj_as( - type_=ModelResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> ModelListResponseEnvelope: """ @@ -416,49 +219,13 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Mo ) client.models.list() """ - _response = self._client_wrapper.httpx_client.request( - "api/models", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelListResponseEnvelope, - parse_obj_as( - type_=ModelListResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.list(request_options=request_options) + return _response.data def create( self, *, - configuration: typing.Dict[str, typing.Optional[typing.Any]], + configuration: typing.Dict[str, typing.Any], connection_id: str, name: str, async_: typing.Optional[bool] = None, @@ -476,7 +243,7 @@ def create( """ Parameters ---------- - configuration : typing.Dict[str, typing.Optional[typing.Any]] + configuration : typing.Dict[str, typing.Any] connection_id : str @@ -524,88 +291,23 @@ def create( name="Users", ) """ - _response = self._client_wrapper.httpx_client.request( - "api/models", - method="POST", - params={ - "async": async_, - }, - json={ - "additional_fields": convert_and_respect_annotation_metadata( - object_=additional_fields, annotation=typing.Sequence[ModelModelFieldRequest], direction="write" - ), - "configuration": configuration, - "connection_id": connection_id, - "enricher": convert_and_respect_annotation_metadata( - object_=enricher, annotation=Enrichment, direction="write" - ), - "fields": fields, - "identifier": identifier, - "labels": labels, - "name": name, - "organization_id": organization_id, - "policies": policies, - "relations": convert_and_respect_annotation_metadata( - object_=relations, annotation=typing.Sequence[ModelRelation], direction="write" - ), - "tracking_columns": tracking_columns, - }, + _response = self._raw_client.create( + configuration=configuration, + connection_id=connection_id, + name=name, + async_=async_, + additional_fields=additional_fields, + enricher=enricher, + fields=fields, + identifier=identifier, + labels=labels, + organization_id=organization_id, + policies=policies, + relations=relations, + tracking_columns=tracking_columns, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelResponseEnvelope, - parse_obj_as( - type_=ModelResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get( self, id: str, *, async_: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None @@ -637,63 +339,14 @@ def get( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/models/{jsonable_encoder(id)}", - method="GET", - params={ - "async": async_, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelResponseEnvelope, - parse_obj_as( - type_=ModelResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(id, async_=async_, request_options=request_options) + return _response.data def update( self, id: str, *, - configuration: typing.Dict[str, typing.Optional[typing.Any]], + configuration: typing.Dict[str, typing.Any], connection_id: str, name: str, async_: typing.Optional[bool] = None, @@ -714,7 +367,7 @@ def update( ---------- id : str - configuration : typing.Dict[str, typing.Optional[typing.Any]] + configuration : typing.Dict[str, typing.Any] connection_id : str @@ -766,92 +419,25 @@ def update( name="Users", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/models/{jsonable_encoder(id)}", - method="PUT", - params={ - "async": async_, - }, - json={ - "additional_fields": convert_and_respect_annotation_metadata( - object_=additional_fields, annotation=typing.Sequence[ModelModelFieldRequest], direction="write" - ), - "configuration": configuration, - "connection_id": connection_id, - "enricher": convert_and_respect_annotation_metadata( - object_=enricher, annotation=Enrichment, direction="write" - ), - "fields": fields, - "identifier": identifier, - "labels": labels, - "name": name, - "organization_id": organization_id, - "policies": policies, - "refresh": refresh, - "relations": convert_and_respect_annotation_metadata( - object_=relations, annotation=typing.Sequence[ModelRelation], direction="write" - ), - "tracking_columns": tracking_columns, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.update( + id, + configuration=configuration, + connection_id=connection_id, + name=name, + async_=async_, + additional_fields=additional_fields, + enricher=enricher, + fields=fields, + identifier=identifier, + labels=labels, + organization_id=organization_id, + policies=policies, + refresh=refresh, + relations=relations, + tracking_columns=tracking_columns, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelResponseEnvelope, - parse_obj_as( - type_=ModelResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def remove( self, id: str, *, async_: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None @@ -882,61 +468,8 @@ def remove( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/models/{jsonable_encoder(id)}", - method="DELETE", - params={ - "async": async_, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.remove(id, async_=async_, request_options=request_options) + return _response.data def sample( self, id: str, *, async_: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None @@ -970,78 +503,30 @@ def sample( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/models/{jsonable_encoder(id)}/sample", - method="GET", - params={ - "async": async_, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelSampleResponseEnvelope, - parse_obj_as( - type_=ModelSampleResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.sample(id, async_=async_, request_options=request_options) + return _response.data class AsyncModelsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawModelsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawModelsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawModelsClient + """ + return self._raw_client async def get_enrichment_source( self, id: str, *, - params: typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]] = None, + params: typing.Optional[typing.Dict[str, typing.Sequence[str]]] = None, request_options: typing.Optional[RequestOptions] = None, ) -> GetModelSyncSourceMetaEnvelope: """ @@ -1049,7 +534,7 @@ async def get_enrichment_source( ---------- id : str - params : typing.Optional[typing.Dict[str, typing.Optional[typing.Sequence[str]]]] + params : typing.Optional[typing.Dict[str, typing.Sequence[str]]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1079,77 +564,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/modelsync/enrichment-source", - method="GET", - params={ - "params": params, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetModelSyncSourceMetaEnvelope, - parse_obj_as( - type_=GetModelSyncSourceMetaEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_enrichment_source(id, params=params, request_options=request_options) + return _response.data async def post( self, @@ -1195,76 +611,15 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/enrichment/{jsonable_encoder(connection_id)}/inputfields", - method="POST", - json={ - "configuration": configuration, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.post( + connection_id, configuration=configuration, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V2GetEnrichmentInputFieldsResponseEnvelope, - parse_obj_as( - type_=V2GetEnrichmentInputFieldsResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def preview( self, *, - configuration: typing.Dict[str, typing.Optional[typing.Any]], + configuration: typing.Dict[str, typing.Any], connection_id: str, name: str, async_: typing.Optional[bool] = None, @@ -1282,7 +637,7 @@ async def preview( """ Parameters ---------- - configuration : typing.Dict[str, typing.Optional[typing.Any]] + configuration : typing.Dict[str, typing.Any] connection_id : str @@ -1338,88 +693,23 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/model-preview", - method="POST", - params={ - "async": async_, - }, - json={ - "additional_fields": convert_and_respect_annotation_metadata( - object_=additional_fields, annotation=typing.Sequence[ModelModelFieldRequest], direction="write" - ), - "configuration": configuration, - "connection_id": connection_id, - "enricher": convert_and_respect_annotation_metadata( - object_=enricher, annotation=Enrichment, direction="write" - ), - "fields": fields, - "identifier": identifier, - "labels": labels, - "name": name, - "organization_id": organization_id, - "policies": policies, - "relations": convert_and_respect_annotation_metadata( - object_=relations, annotation=typing.Sequence[ModelRelation], direction="write" - ), - "tracking_columns": tracking_columns, - }, + _response = await self._raw_client.preview( + configuration=configuration, + connection_id=connection_id, + name=name, + async_=async_, + additional_fields=additional_fields, + enricher=enricher, + fields=fields, + identifier=identifier, + labels=labels, + organization_id=organization_id, + policies=policies, + relations=relations, + tracking_columns=tracking_columns, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelResponseEnvelope, - parse_obj_as( - type_=ModelResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> ModelListResponseEnvelope: """ @@ -1451,49 +741,13 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/models", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelListResponseEnvelope, - parse_obj_as( - type_=ModelListResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.list(request_options=request_options) + return _response.data async def create( self, *, - configuration: typing.Dict[str, typing.Optional[typing.Any]], + configuration: typing.Dict[str, typing.Any], connection_id: str, name: str, async_: typing.Optional[bool] = None, @@ -1511,7 +765,7 @@ async def create( """ Parameters ---------- - configuration : typing.Dict[str, typing.Optional[typing.Any]] + configuration : typing.Dict[str, typing.Any] connection_id : str @@ -1567,88 +821,23 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/models", - method="POST", - params={ - "async": async_, - }, - json={ - "additional_fields": convert_and_respect_annotation_metadata( - object_=additional_fields, annotation=typing.Sequence[ModelModelFieldRequest], direction="write" - ), - "configuration": configuration, - "connection_id": connection_id, - "enricher": convert_and_respect_annotation_metadata( - object_=enricher, annotation=Enrichment, direction="write" - ), - "fields": fields, - "identifier": identifier, - "labels": labels, - "name": name, - "organization_id": organization_id, - "policies": policies, - "relations": convert_and_respect_annotation_metadata( - object_=relations, annotation=typing.Sequence[ModelRelation], direction="write" - ), - "tracking_columns": tracking_columns, - }, + _response = await self._raw_client.create( + configuration=configuration, + connection_id=connection_id, + name=name, + async_=async_, + additional_fields=additional_fields, + enricher=enricher, + fields=fields, + identifier=identifier, + labels=labels, + organization_id=organization_id, + policies=policies, + relations=relations, + tracking_columns=tracking_columns, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelResponseEnvelope, - parse_obj_as( - type_=ModelResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get( self, id: str, *, async_: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None @@ -1688,63 +877,14 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/models/{jsonable_encoder(id)}", - method="GET", - params={ - "async": async_, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelResponseEnvelope, - parse_obj_as( - type_=ModelResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(id, async_=async_, request_options=request_options) + return _response.data async def update( self, id: str, *, - configuration: typing.Dict[str, typing.Optional[typing.Any]], + configuration: typing.Dict[str, typing.Any], connection_id: str, name: str, async_: typing.Optional[bool] = None, @@ -1765,7 +905,7 @@ async def update( ---------- id : str - configuration : typing.Dict[str, typing.Optional[typing.Any]] + configuration : typing.Dict[str, typing.Any] connection_id : str @@ -1825,92 +965,25 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/models/{jsonable_encoder(id)}", - method="PUT", - params={ - "async": async_, - }, - json={ - "additional_fields": convert_and_respect_annotation_metadata( - object_=additional_fields, annotation=typing.Sequence[ModelModelFieldRequest], direction="write" - ), - "configuration": configuration, - "connection_id": connection_id, - "enricher": convert_and_respect_annotation_metadata( - object_=enricher, annotation=Enrichment, direction="write" - ), - "fields": fields, - "identifier": identifier, - "labels": labels, - "name": name, - "organization_id": organization_id, - "policies": policies, - "refresh": refresh, - "relations": convert_and_respect_annotation_metadata( - object_=relations, annotation=typing.Sequence[ModelRelation], direction="write" - ), - "tracking_columns": tracking_columns, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.update( + id, + configuration=configuration, + connection_id=connection_id, + name=name, + async_=async_, + additional_fields=additional_fields, + enricher=enricher, + fields=fields, + identifier=identifier, + labels=labels, + organization_id=organization_id, + policies=policies, + refresh=refresh, + relations=relations, + tracking_columns=tracking_columns, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelResponseEnvelope, - parse_obj_as( - type_=ModelResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def remove( self, id: str, *, async_: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None @@ -1949,61 +1022,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/models/{jsonable_encoder(id)}", - method="DELETE", - params={ - "async": async_, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.remove(id, async_=async_, request_options=request_options) + return _response.data async def sample( self, id: str, *, async_: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None @@ -2045,64 +1065,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/models/{jsonable_encoder(id)}/sample", - method="GET", - params={ - "async": async_, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ModelSampleResponseEnvelope, - parse_obj_as( - type_=ModelSampleResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.sample(id, async_=async_, request_options=request_options) + return _response.data diff --git a/src/polytomic/models/raw_client.py b/src/polytomic/models/raw_client.py new file mode 100644 index 0000000..4cfcd4f --- /dev/null +++ b/src/polytomic/models/raw_client.py @@ -0,0 +1,2067 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError as core_api_error_ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..core.serialization import convert_and_respect_annotation_metadata +from ..errors.bad_request_error import BadRequestError +from ..errors.forbidden_error import ForbiddenError +from ..errors.internal_server_error import InternalServerError +from ..errors.not_found_error import NotFoundError +from ..errors.unauthorized_error import UnauthorizedError +from ..types.api_error import ApiError as types_api_error_ApiError +from ..types.enrichment import Enrichment +from ..types.get_model_sync_source_meta_envelope import GetModelSyncSourceMetaEnvelope +from ..types.model_list_response_envelope import ModelListResponseEnvelope +from ..types.model_model_field_request import ModelModelFieldRequest +from ..types.model_relation import ModelRelation +from ..types.model_response_envelope import ModelResponseEnvelope +from ..types.model_sample_response_envelope import ModelSampleResponseEnvelope +from ..types.rest_err_response import RestErrResponse +from ..types.v_2_enricher_configuration import V2EnricherConfiguration +from ..types.v_2_get_enrichment_input_fields_response_envelope import V2GetEnrichmentInputFieldsResponseEnvelope +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawModelsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_enrichment_source( + self, + id: str, + *, + params: typing.Optional[typing.Dict[str, typing.Sequence[str]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetModelSyncSourceMetaEnvelope]: + """ + Parameters + ---------- + id : str + + params : typing.Optional[typing.Dict[str, typing.Sequence[str]]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetModelSyncSourceMetaEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/modelsync/enrichment-source", + method="GET", + params={ + "params": params, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetModelSyncSourceMetaEnvelope, + parse_obj_as( + type_=GetModelSyncSourceMetaEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def post( + self, + connection_id: str, + *, + configuration: typing.Optional[V2EnricherConfiguration] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[V2GetEnrichmentInputFieldsResponseEnvelope]: + """ + For a given connection and enrichment configuration, provides the valid sets of input fields. + + Parameters + ---------- + connection_id : str + + configuration : typing.Optional[V2EnricherConfiguration] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[V2GetEnrichmentInputFieldsResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/enrichment/{jsonable_encoder(connection_id)}/inputfields", + method="POST", + json={ + "configuration": configuration, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V2GetEnrichmentInputFieldsResponseEnvelope, + parse_obj_as( + type_=V2GetEnrichmentInputFieldsResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def preview( + self, + *, + configuration: typing.Dict[str, typing.Any], + connection_id: str, + name: str, + async_: typing.Optional[bool] = None, + additional_fields: typing.Optional[typing.Sequence[ModelModelFieldRequest]] = OMIT, + enricher: typing.Optional[Enrichment] = OMIT, + fields: typing.Optional[typing.Sequence[str]] = OMIT, + identifier: typing.Optional[str] = OMIT, + labels: typing.Optional[typing.Sequence[str]] = OMIT, + organization_id: typing.Optional[str] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + relations: typing.Optional[typing.Sequence[ModelRelation]] = OMIT, + tracking_columns: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ModelResponseEnvelope]: + """ + Parameters + ---------- + configuration : typing.Dict[str, typing.Any] + + connection_id : str + + name : str + + async_ : typing.Optional[bool] + + additional_fields : typing.Optional[typing.Sequence[ModelModelFieldRequest]] + + enricher : typing.Optional[Enrichment] + + fields : typing.Optional[typing.Sequence[str]] + + identifier : typing.Optional[str] + + labels : typing.Optional[typing.Sequence[str]] + + organization_id : typing.Optional[str] + + policies : typing.Optional[typing.Sequence[str]] + + relations : typing.Optional[typing.Sequence[ModelRelation]] + + tracking_columns : typing.Optional[typing.Sequence[str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ModelResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/model-preview", + method="POST", + params={ + "async": async_, + }, + json={ + "additional_fields": convert_and_respect_annotation_metadata( + object_=additional_fields, + annotation=typing.Optional[typing.Sequence[ModelModelFieldRequest]], + direction="write", + ), + "configuration": configuration, + "connection_id": connection_id, + "enricher": convert_and_respect_annotation_metadata( + object_=enricher, annotation=Enrichment, direction="write" + ), + "fields": fields, + "identifier": identifier, + "labels": labels, + "name": name, + "organization_id": organization_id, + "policies": policies, + "relations": convert_and_respect_annotation_metadata( + object_=relations, annotation=typing.Optional[typing.Sequence[ModelRelation]], direction="write" + ), + "tracking_columns": tracking_columns, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelResponseEnvelope, + parse_obj_as( + type_=ModelResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ModelListResponseEnvelope]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ModelListResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/models", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelListResponseEnvelope, + parse_obj_as( + type_=ModelListResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def create( + self, + *, + configuration: typing.Dict[str, typing.Any], + connection_id: str, + name: str, + async_: typing.Optional[bool] = None, + additional_fields: typing.Optional[typing.Sequence[ModelModelFieldRequest]] = OMIT, + enricher: typing.Optional[Enrichment] = OMIT, + fields: typing.Optional[typing.Sequence[str]] = OMIT, + identifier: typing.Optional[str] = OMIT, + labels: typing.Optional[typing.Sequence[str]] = OMIT, + organization_id: typing.Optional[str] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + relations: typing.Optional[typing.Sequence[ModelRelation]] = OMIT, + tracking_columns: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ModelResponseEnvelope]: + """ + Parameters + ---------- + configuration : typing.Dict[str, typing.Any] + + connection_id : str + + name : str + + async_ : typing.Optional[bool] + + additional_fields : typing.Optional[typing.Sequence[ModelModelFieldRequest]] + + enricher : typing.Optional[Enrichment] + + fields : typing.Optional[typing.Sequence[str]] + + identifier : typing.Optional[str] + + labels : typing.Optional[typing.Sequence[str]] + + organization_id : typing.Optional[str] + + policies : typing.Optional[typing.Sequence[str]] + + relations : typing.Optional[typing.Sequence[ModelRelation]] + + tracking_columns : typing.Optional[typing.Sequence[str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ModelResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/models", + method="POST", + params={ + "async": async_, + }, + json={ + "additional_fields": convert_and_respect_annotation_metadata( + object_=additional_fields, + annotation=typing.Optional[typing.Sequence[ModelModelFieldRequest]], + direction="write", + ), + "configuration": configuration, + "connection_id": connection_id, + "enricher": convert_and_respect_annotation_metadata( + object_=enricher, annotation=Enrichment, direction="write" + ), + "fields": fields, + "identifier": identifier, + "labels": labels, + "name": name, + "organization_id": organization_id, + "policies": policies, + "relations": convert_and_respect_annotation_metadata( + object_=relations, annotation=typing.Optional[typing.Sequence[ModelRelation]], direction="write" + ), + "tracking_columns": tracking_columns, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelResponseEnvelope, + parse_obj_as( + type_=ModelResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get( + self, id: str, *, async_: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ModelResponseEnvelope]: + """ + Parameters + ---------- + id : str + + async_ : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ModelResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/models/{jsonable_encoder(id)}", + method="GET", + params={ + "async": async_, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelResponseEnvelope, + parse_obj_as( + type_=ModelResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def update( + self, + id: str, + *, + configuration: typing.Dict[str, typing.Any], + connection_id: str, + name: str, + async_: typing.Optional[bool] = None, + additional_fields: typing.Optional[typing.Sequence[ModelModelFieldRequest]] = OMIT, + enricher: typing.Optional[Enrichment] = OMIT, + fields: typing.Optional[typing.Sequence[str]] = OMIT, + identifier: typing.Optional[str] = OMIT, + labels: typing.Optional[typing.Sequence[str]] = OMIT, + organization_id: typing.Optional[str] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + refresh: typing.Optional[bool] = OMIT, + relations: typing.Optional[typing.Sequence[ModelRelation]] = OMIT, + tracking_columns: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ModelResponseEnvelope]: + """ + Parameters + ---------- + id : str + + configuration : typing.Dict[str, typing.Any] + + connection_id : str + + name : str + + async_ : typing.Optional[bool] + + additional_fields : typing.Optional[typing.Sequence[ModelModelFieldRequest]] + + enricher : typing.Optional[Enrichment] + + fields : typing.Optional[typing.Sequence[str]] + + identifier : typing.Optional[str] + + labels : typing.Optional[typing.Sequence[str]] + + organization_id : typing.Optional[str] + + policies : typing.Optional[typing.Sequence[str]] + + refresh : typing.Optional[bool] + + relations : typing.Optional[typing.Sequence[ModelRelation]] + + tracking_columns : typing.Optional[typing.Sequence[str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ModelResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/models/{jsonable_encoder(id)}", + method="PUT", + params={ + "async": async_, + }, + json={ + "additional_fields": convert_and_respect_annotation_metadata( + object_=additional_fields, + annotation=typing.Optional[typing.Sequence[ModelModelFieldRequest]], + direction="write", + ), + "configuration": configuration, + "connection_id": connection_id, + "enricher": convert_and_respect_annotation_metadata( + object_=enricher, annotation=Enrichment, direction="write" + ), + "fields": fields, + "identifier": identifier, + "labels": labels, + "name": name, + "organization_id": organization_id, + "policies": policies, + "refresh": refresh, + "relations": convert_and_respect_annotation_metadata( + object_=relations, annotation=typing.Optional[typing.Sequence[ModelRelation]], direction="write" + ), + "tracking_columns": tracking_columns, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelResponseEnvelope, + parse_obj_as( + type_=ModelResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def remove( + self, id: str, *, async_: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[None]: + """ + Parameters + ---------- + id : str + + async_ : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/models/{jsonable_encoder(id)}", + method="DELETE", + params={ + "async": async_, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def sample( + self, id: str, *, async_: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ModelSampleResponseEnvelope]: + """ + Returns sample records from the model. The first ten records that the source provides will be returned after being enriched (if applicable). Synchronous requests must complete within 10s. If either querying or enrichment exceeds 10s, please use the async option. + + Parameters + ---------- + id : str + + async_ : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ModelSampleResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/models/{jsonable_encoder(id)}/sample", + method="GET", + params={ + "async": async_, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelSampleResponseEnvelope, + parse_obj_as( + type_=ModelSampleResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawModelsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_enrichment_source( + self, + id: str, + *, + params: typing.Optional[typing.Dict[str, typing.Sequence[str]]] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetModelSyncSourceMetaEnvelope]: + """ + Parameters + ---------- + id : str + + params : typing.Optional[typing.Dict[str, typing.Sequence[str]]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetModelSyncSourceMetaEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/modelsync/enrichment-source", + method="GET", + params={ + "params": params, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetModelSyncSourceMetaEnvelope, + parse_obj_as( + type_=GetModelSyncSourceMetaEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def post( + self, + connection_id: str, + *, + configuration: typing.Optional[V2EnricherConfiguration] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[V2GetEnrichmentInputFieldsResponseEnvelope]: + """ + For a given connection and enrichment configuration, provides the valid sets of input fields. + + Parameters + ---------- + connection_id : str + + configuration : typing.Optional[V2EnricherConfiguration] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[V2GetEnrichmentInputFieldsResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/enrichment/{jsonable_encoder(connection_id)}/inputfields", + method="POST", + json={ + "configuration": configuration, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V2GetEnrichmentInputFieldsResponseEnvelope, + parse_obj_as( + type_=V2GetEnrichmentInputFieldsResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def preview( + self, + *, + configuration: typing.Dict[str, typing.Any], + connection_id: str, + name: str, + async_: typing.Optional[bool] = None, + additional_fields: typing.Optional[typing.Sequence[ModelModelFieldRequest]] = OMIT, + enricher: typing.Optional[Enrichment] = OMIT, + fields: typing.Optional[typing.Sequence[str]] = OMIT, + identifier: typing.Optional[str] = OMIT, + labels: typing.Optional[typing.Sequence[str]] = OMIT, + organization_id: typing.Optional[str] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + relations: typing.Optional[typing.Sequence[ModelRelation]] = OMIT, + tracking_columns: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ModelResponseEnvelope]: + """ + Parameters + ---------- + configuration : typing.Dict[str, typing.Any] + + connection_id : str + + name : str + + async_ : typing.Optional[bool] + + additional_fields : typing.Optional[typing.Sequence[ModelModelFieldRequest]] + + enricher : typing.Optional[Enrichment] + + fields : typing.Optional[typing.Sequence[str]] + + identifier : typing.Optional[str] + + labels : typing.Optional[typing.Sequence[str]] + + organization_id : typing.Optional[str] + + policies : typing.Optional[typing.Sequence[str]] + + relations : typing.Optional[typing.Sequence[ModelRelation]] + + tracking_columns : typing.Optional[typing.Sequence[str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ModelResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/model-preview", + method="POST", + params={ + "async": async_, + }, + json={ + "additional_fields": convert_and_respect_annotation_metadata( + object_=additional_fields, + annotation=typing.Optional[typing.Sequence[ModelModelFieldRequest]], + direction="write", + ), + "configuration": configuration, + "connection_id": connection_id, + "enricher": convert_and_respect_annotation_metadata( + object_=enricher, annotation=Enrichment, direction="write" + ), + "fields": fields, + "identifier": identifier, + "labels": labels, + "name": name, + "organization_id": organization_id, + "policies": policies, + "relations": convert_and_respect_annotation_metadata( + object_=relations, annotation=typing.Optional[typing.Sequence[ModelRelation]], direction="write" + ), + "tracking_columns": tracking_columns, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelResponseEnvelope, + parse_obj_as( + type_=ModelResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ModelListResponseEnvelope]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ModelListResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/models", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelListResponseEnvelope, + parse_obj_as( + type_=ModelListResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def create( + self, + *, + configuration: typing.Dict[str, typing.Any], + connection_id: str, + name: str, + async_: typing.Optional[bool] = None, + additional_fields: typing.Optional[typing.Sequence[ModelModelFieldRequest]] = OMIT, + enricher: typing.Optional[Enrichment] = OMIT, + fields: typing.Optional[typing.Sequence[str]] = OMIT, + identifier: typing.Optional[str] = OMIT, + labels: typing.Optional[typing.Sequence[str]] = OMIT, + organization_id: typing.Optional[str] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + relations: typing.Optional[typing.Sequence[ModelRelation]] = OMIT, + tracking_columns: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ModelResponseEnvelope]: + """ + Parameters + ---------- + configuration : typing.Dict[str, typing.Any] + + connection_id : str + + name : str + + async_ : typing.Optional[bool] + + additional_fields : typing.Optional[typing.Sequence[ModelModelFieldRequest]] + + enricher : typing.Optional[Enrichment] + + fields : typing.Optional[typing.Sequence[str]] + + identifier : typing.Optional[str] + + labels : typing.Optional[typing.Sequence[str]] + + organization_id : typing.Optional[str] + + policies : typing.Optional[typing.Sequence[str]] + + relations : typing.Optional[typing.Sequence[ModelRelation]] + + tracking_columns : typing.Optional[typing.Sequence[str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ModelResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/models", + method="POST", + params={ + "async": async_, + }, + json={ + "additional_fields": convert_and_respect_annotation_metadata( + object_=additional_fields, + annotation=typing.Optional[typing.Sequence[ModelModelFieldRequest]], + direction="write", + ), + "configuration": configuration, + "connection_id": connection_id, + "enricher": convert_and_respect_annotation_metadata( + object_=enricher, annotation=Enrichment, direction="write" + ), + "fields": fields, + "identifier": identifier, + "labels": labels, + "name": name, + "organization_id": organization_id, + "policies": policies, + "relations": convert_and_respect_annotation_metadata( + object_=relations, annotation=typing.Optional[typing.Sequence[ModelRelation]], direction="write" + ), + "tracking_columns": tracking_columns, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelResponseEnvelope, + parse_obj_as( + type_=ModelResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, id: str, *, async_: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ModelResponseEnvelope]: + """ + Parameters + ---------- + id : str + + async_ : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ModelResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/models/{jsonable_encoder(id)}", + method="GET", + params={ + "async": async_, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelResponseEnvelope, + parse_obj_as( + type_=ModelResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def update( + self, + id: str, + *, + configuration: typing.Dict[str, typing.Any], + connection_id: str, + name: str, + async_: typing.Optional[bool] = None, + additional_fields: typing.Optional[typing.Sequence[ModelModelFieldRequest]] = OMIT, + enricher: typing.Optional[Enrichment] = OMIT, + fields: typing.Optional[typing.Sequence[str]] = OMIT, + identifier: typing.Optional[str] = OMIT, + labels: typing.Optional[typing.Sequence[str]] = OMIT, + organization_id: typing.Optional[str] = OMIT, + policies: typing.Optional[typing.Sequence[str]] = OMIT, + refresh: typing.Optional[bool] = OMIT, + relations: typing.Optional[typing.Sequence[ModelRelation]] = OMIT, + tracking_columns: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ModelResponseEnvelope]: + """ + Parameters + ---------- + id : str + + configuration : typing.Dict[str, typing.Any] + + connection_id : str + + name : str + + async_ : typing.Optional[bool] + + additional_fields : typing.Optional[typing.Sequence[ModelModelFieldRequest]] + + enricher : typing.Optional[Enrichment] + + fields : typing.Optional[typing.Sequence[str]] + + identifier : typing.Optional[str] + + labels : typing.Optional[typing.Sequence[str]] + + organization_id : typing.Optional[str] + + policies : typing.Optional[typing.Sequence[str]] + + refresh : typing.Optional[bool] + + relations : typing.Optional[typing.Sequence[ModelRelation]] + + tracking_columns : typing.Optional[typing.Sequence[str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ModelResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/models/{jsonable_encoder(id)}", + method="PUT", + params={ + "async": async_, + }, + json={ + "additional_fields": convert_and_respect_annotation_metadata( + object_=additional_fields, + annotation=typing.Optional[typing.Sequence[ModelModelFieldRequest]], + direction="write", + ), + "configuration": configuration, + "connection_id": connection_id, + "enricher": convert_and_respect_annotation_metadata( + object_=enricher, annotation=Enrichment, direction="write" + ), + "fields": fields, + "identifier": identifier, + "labels": labels, + "name": name, + "organization_id": organization_id, + "policies": policies, + "refresh": refresh, + "relations": convert_and_respect_annotation_metadata( + object_=relations, annotation=typing.Optional[typing.Sequence[ModelRelation]], direction="write" + ), + "tracking_columns": tracking_columns, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelResponseEnvelope, + parse_obj_as( + type_=ModelResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def remove( + self, id: str, *, async_: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + id : str + + async_ : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/models/{jsonable_encoder(id)}", + method="DELETE", + params={ + "async": async_, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def sample( + self, id: str, *, async_: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ModelSampleResponseEnvelope]: + """ + Returns sample records from the model. The first ten records that the source provides will be returned after being enriched (if applicable). Synchronous requests must complete within 10s. If either querying or enrichment exceeds 10s, please use the async option. + + Parameters + ---------- + id : str + + async_ : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ModelSampleResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/models/{jsonable_encoder(id)}/sample", + method="GET", + params={ + "async": async_, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ModelSampleResponseEnvelope, + parse_obj_as( + type_=ModelSampleResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/notifications/__init__.py b/src/polytomic/notifications/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/notifications/__init__.py +++ b/src/polytomic/notifications/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/notifications/client.py b/src/polytomic/notifications/client.py index aed56ee..f4ea9e2 100644 --- a/src/polytomic/notifications/client.py +++ b/src/polytomic/notifications/client.py @@ -1,18 +1,11 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions from ..types.v_4_global_error_subscribers_response import V4GlobalErrorSubscribersResponse -from ..core.pydantic_utilities import parse_obj_as -from ..errors.unauthorized_error import UnauthorizedError -from ..types.rest_err_response import RestErrResponse -from ..errors.internal_server_error import InternalServerError -from ..types.api_error import ApiError as types_api_error_ApiError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError as core_api_error_ApiError -from ..errors.bad_request_error import BadRequestError -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawNotificationsClient, RawNotificationsClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -20,7 +13,18 @@ class NotificationsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawNotificationsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawNotificationsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawNotificationsClient + """ + return self._raw_client def get_global_error_subscribers( self, *, request_options: typing.Optional[RequestOptions] = None @@ -46,44 +50,8 @@ def get_global_error_subscribers( ) client.notifications.get_global_error_subscribers() """ - _response = self._client_wrapper.httpx_client.request( - "api/notifications/global-error-subscribers", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4GlobalErrorSubscribersResponse, - parse_obj_as( - type_=V4GlobalErrorSubscribersResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_global_error_subscribers(request_options=request_options) + return _response.data def set_global_error_subscribers( self, @@ -114,66 +82,24 @@ def set_global_error_subscribers( ) client.notifications.set_global_error_subscribers() """ - _response = self._client_wrapper.httpx_client.request( - "api/notifications/global-error-subscribers", - method="PUT", - json={ - "emails": emails, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4GlobalErrorSubscribersResponse, - parse_obj_as( - type_=V4GlobalErrorSubscribersResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.set_global_error_subscribers(emails=emails, request_options=request_options) + return _response.data class AsyncNotificationsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawNotificationsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawNotificationsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawNotificationsClient + """ + return self._raw_client async def get_global_error_subscribers( self, *, request_options: typing.Optional[RequestOptions] = None @@ -207,44 +133,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/notifications/global-error-subscribers", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4GlobalErrorSubscribersResponse, - parse_obj_as( - type_=V4GlobalErrorSubscribersResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_global_error_subscribers(request_options=request_options) + return _response.data async def set_global_error_subscribers( self, @@ -283,58 +173,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/notifications/global-error-subscribers", - method="PUT", - json={ - "emails": emails, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4GlobalErrorSubscribersResponse, - parse_obj_as( - type_=V4GlobalErrorSubscribersResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.set_global_error_subscribers(emails=emails, request_options=request_options) + return _response.data diff --git a/src/polytomic/notifications/raw_client.py b/src/polytomic/notifications/raw_client.py new file mode 100644 index 0000000..abb403f --- /dev/null +++ b/src/polytomic/notifications/raw_client.py @@ -0,0 +1,333 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError as core_api_error_ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.parse_error import ParsingError +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..errors.bad_request_error import BadRequestError +from ..errors.internal_server_error import InternalServerError +from ..errors.unauthorized_error import UnauthorizedError +from ..types.api_error import ApiError as types_api_error_ApiError +from ..types.rest_err_response import RestErrResponse +from ..types.v_4_global_error_subscribers_response import V4GlobalErrorSubscribersResponse +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawNotificationsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_global_error_subscribers( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[V4GlobalErrorSubscribersResponse]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[V4GlobalErrorSubscribersResponse] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/notifications/global-error-subscribers", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4GlobalErrorSubscribersResponse, + parse_obj_as( + type_=V4GlobalErrorSubscribersResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def set_global_error_subscribers( + self, + *, + emails: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[V4GlobalErrorSubscribersResponse]: + """ + Parameters + ---------- + emails : typing.Optional[typing.Sequence[str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[V4GlobalErrorSubscribersResponse] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/notifications/global-error-subscribers", + method="PUT", + json={ + "emails": emails, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4GlobalErrorSubscribersResponse, + parse_obj_as( + type_=V4GlobalErrorSubscribersResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawNotificationsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_global_error_subscribers( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[V4GlobalErrorSubscribersResponse]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[V4GlobalErrorSubscribersResponse] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/notifications/global-error-subscribers", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4GlobalErrorSubscribersResponse, + parse_obj_as( + type_=V4GlobalErrorSubscribersResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def set_global_error_subscribers( + self, + *, + emails: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[V4GlobalErrorSubscribersResponse]: + """ + Parameters + ---------- + emails : typing.Optional[typing.Sequence[str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[V4GlobalErrorSubscribersResponse] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/notifications/global-error-subscribers", + method="PUT", + json={ + "emails": emails, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4GlobalErrorSubscribersResponse, + parse_obj_as( + type_=V4GlobalErrorSubscribersResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/organization/__init__.py b/src/polytomic/organization/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/organization/__init__.py +++ b/src/polytomic/organization/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/organization/client.py b/src/polytomic/organization/client.py index 8929e07..fa2e971 100644 --- a/src/polytomic/organization/client.py +++ b/src/polytomic/organization/client.py @@ -1,22 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions -from ..types.organizations_envelope import OrganizationsEnvelope -from ..core.pydantic_utilities import parse_obj_as -from ..errors.unauthorized_error import UnauthorizedError -from ..types.rest_err_response import RestErrResponse -from ..errors.internal_server_error import InternalServerError -from ..types.api_error import ApiError as types_api_error_ApiError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError as core_api_error_ApiError from ..types.organization_envelope import OrganizationEnvelope -from ..errors.conflict_error import ConflictError -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..core.jsonable_encoder import jsonable_encoder -from ..errors.not_found_error import NotFoundError -from ..core.client_wrapper import AsyncClientWrapper +from ..types.organizations_envelope import OrganizationsEnvelope +from .raw_client import AsyncRawOrganizationClient, RawOrganizationClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -24,7 +14,18 @@ class OrganizationClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawOrganizationClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawOrganizationClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawOrganizationClient + """ + return self._raw_client def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> OrganizationsEnvelope: """ @@ -52,44 +53,8 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Or ) client.organization.list() """ - _response = self._client_wrapper.httpx_client.request( - "api/organizations", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - OrganizationsEnvelope, - parse_obj_as( - type_=OrganizationsEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.list(request_options=request_options) + return _response.data def create( self, @@ -141,76 +106,16 @@ def create( name="My Organization", ) """ - _response = self._client_wrapper.httpx_client.request( - "api/organizations", - method="POST", - json={ - "client_id": client_id, - "client_secret": client_secret, - "issuer": issuer, - "name": name, - "sso_domain": sso_domain, - "sso_org_id": sso_org_id, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.create( + name=name, + client_id=client_id, + client_secret=client_secret, + issuer=issuer, + sso_domain=sso_domain, + sso_org_id=sso_org_id, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - OrganizationEnvelope, - parse_obj_as( - type_=OrganizationEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 409: - raise ConflictError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> OrganizationEnvelope: """ @@ -242,44 +147,8 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - OrganizationEnvelope, - parse_obj_as( - type_=OrganizationEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(id, request_options=request_options) + return _response.data def update( self, @@ -335,76 +204,17 @@ def update( name="My Organization", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(id)}", - method="PUT", - json={ - "client_id": client_id, - "client_secret": client_secret, - "issuer": issuer, - "name": name, - "sso_domain": sso_domain, - "sso_org_id": sso_org_id, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.update( + id, + name=name, + client_id=client_id, + client_secret=client_secret, + issuer=issuer, + sso_domain=sso_domain, + sso_org_id=sso_org_id, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - OrganizationEnvelope, - parse_obj_as( - type_=OrganizationEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 409: - raise ConflictError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ @@ -435,53 +245,24 @@ def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.remove(id, request_options=request_options) + return _response.data class AsyncOrganizationClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawOrganizationClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawOrganizationClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawOrganizationClient + """ + return self._raw_client async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> OrganizationsEnvelope: """ @@ -517,44 +298,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/organizations", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - OrganizationsEnvelope, - parse_obj_as( - type_=OrganizationsEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.list(request_options=request_options) + return _response.data async def create( self, @@ -614,76 +359,16 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/organizations", - method="POST", - json={ - "client_id": client_id, - "client_secret": client_secret, - "issuer": issuer, - "name": name, - "sso_domain": sso_domain, - "sso_org_id": sso_org_id, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.create( + name=name, + client_id=client_id, + client_secret=client_secret, + issuer=issuer, + sso_domain=sso_domain, + sso_org_id=sso_org_id, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - OrganizationEnvelope, - parse_obj_as( - type_=OrganizationEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 409: - raise ConflictError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> OrganizationEnvelope: """ @@ -723,44 +408,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - OrganizationEnvelope, - parse_obj_as( - type_=OrganizationEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(id, request_options=request_options) + return _response.data async def update( self, @@ -824,76 +473,17 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(id)}", - method="PUT", - json={ - "client_id": client_id, - "client_secret": client_secret, - "issuer": issuer, - "name": name, - "sso_domain": sso_domain, - "sso_org_id": sso_org_id, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.update( + id, + name=name, + client_id=client_id, + client_secret=client_secret, + issuer=issuer, + sso_domain=sso_domain, + sso_org_id=sso_org_id, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - OrganizationEnvelope, - parse_obj_as( - type_=OrganizationEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 409: - raise ConflictError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ @@ -932,45 +522,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.remove(id, request_options=request_options) + return _response.data diff --git a/src/polytomic/organization/raw_client.py b/src/polytomic/organization/raw_client.py new file mode 100644 index 0000000..57bc35a --- /dev/null +++ b/src/polytomic/organization/raw_client.py @@ -0,0 +1,1014 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError as core_api_error_ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..errors.conflict_error import ConflictError +from ..errors.forbidden_error import ForbiddenError +from ..errors.internal_server_error import InternalServerError +from ..errors.not_found_error import NotFoundError +from ..errors.unauthorized_error import UnauthorizedError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.api_error import ApiError as types_api_error_ApiError +from ..types.organization_envelope import OrganizationEnvelope +from ..types.organizations_envelope import OrganizationsEnvelope +from ..types.rest_err_response import RestErrResponse +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawOrganizationClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[OrganizationsEnvelope]: + """ + > 🚧 Requires partner key + > + > Organization endpoints are only accessible using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[OrganizationsEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/organizations", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + OrganizationsEnvelope, + parse_obj_as( + type_=OrganizationsEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def create( + self, + *, + name: str, + client_id: typing.Optional[str] = OMIT, + client_secret: typing.Optional[str] = OMIT, + issuer: typing.Optional[str] = OMIT, + sso_domain: typing.Optional[str] = OMIT, + sso_org_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[OrganizationEnvelope]: + """ + > 🚧 Requires partner key + > + > Organization endpoints are only accessible using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + + Parameters + ---------- + name : str + + client_id : typing.Optional[str] + + client_secret : typing.Optional[str] + + issuer : typing.Optional[str] + + sso_domain : typing.Optional[str] + + sso_org_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[OrganizationEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/organizations", + method="POST", + json={ + "client_id": client_id, + "client_secret": client_secret, + "issuer": issuer, + "name": name, + "sso_domain": sso_domain, + "sso_org_id": sso_org_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + OrganizationEnvelope, + parse_obj_as( + type_=OrganizationEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[OrganizationEnvelope]: + """ + > 🚧 Requires partner key + > + > Organization endpoints are only accessible using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[OrganizationEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + OrganizationEnvelope, + parse_obj_as( + type_=OrganizationEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def update( + self, + id: str, + *, + name: str, + client_id: typing.Optional[str] = OMIT, + client_secret: typing.Optional[str] = OMIT, + issuer: typing.Optional[str] = OMIT, + sso_domain: typing.Optional[str] = OMIT, + sso_org_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[OrganizationEnvelope]: + """ + > 🚧 Requires partner key + > + > Organization endpoints are only accessible using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + + Parameters + ---------- + id : str + + name : str + + client_id : typing.Optional[str] + + client_secret : typing.Optional[str] + + issuer : typing.Optional[str] + + sso_domain : typing.Optional[str] + + sso_org_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[OrganizationEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(id)}", + method="PUT", + json={ + "client_id": client_id, + "client_secret": client_secret, + "issuer": issuer, + "name": name, + "sso_domain": sso_domain, + "sso_org_id": sso_org_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + OrganizationEnvelope, + parse_obj_as( + type_=OrganizationEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: + """ + > 🚧 Requires partner key + > + > Organization endpoints are only accessible using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawOrganizationClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[OrganizationsEnvelope]: + """ + > 🚧 Requires partner key + > + > Organization endpoints are only accessible using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[OrganizationsEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/organizations", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + OrganizationsEnvelope, + parse_obj_as( + type_=OrganizationsEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def create( + self, + *, + name: str, + client_id: typing.Optional[str] = OMIT, + client_secret: typing.Optional[str] = OMIT, + issuer: typing.Optional[str] = OMIT, + sso_domain: typing.Optional[str] = OMIT, + sso_org_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[OrganizationEnvelope]: + """ + > 🚧 Requires partner key + > + > Organization endpoints are only accessible using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + + Parameters + ---------- + name : str + + client_id : typing.Optional[str] + + client_secret : typing.Optional[str] + + issuer : typing.Optional[str] + + sso_domain : typing.Optional[str] + + sso_org_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[OrganizationEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/organizations", + method="POST", + json={ + "client_id": client_id, + "client_secret": client_secret, + "issuer": issuer, + "name": name, + "sso_domain": sso_domain, + "sso_org_id": sso_org_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + OrganizationEnvelope, + parse_obj_as( + type_=OrganizationEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[OrganizationEnvelope]: + """ + > 🚧 Requires partner key + > + > Organization endpoints are only accessible using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[OrganizationEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + OrganizationEnvelope, + parse_obj_as( + type_=OrganizationEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def update( + self, + id: str, + *, + name: str, + client_id: typing.Optional[str] = OMIT, + client_secret: typing.Optional[str] = OMIT, + issuer: typing.Optional[str] = OMIT, + sso_domain: typing.Optional[str] = OMIT, + sso_org_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[OrganizationEnvelope]: + """ + > 🚧 Requires partner key + > + > Organization endpoints are only accessible using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + + Parameters + ---------- + id : str + + name : str + + client_id : typing.Optional[str] + + client_secret : typing.Optional[str] + + issuer : typing.Optional[str] + + sso_domain : typing.Optional[str] + + sso_org_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[OrganizationEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(id)}", + method="PUT", + json={ + "client_id": client_id, + "client_secret": client_secret, + "issuer": issuer, + "name": name, + "sso_domain": sso_domain, + "sso_org_id": sso_org_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + OrganizationEnvelope, + parse_obj_as( + type_=OrganizationEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 409: + raise ConflictError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def remove( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + > 🚧 Requires partner key + > + > Organization endpoints are only accessible using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/permissions/__init__.py b/src/polytomic/permissions/__init__.py index af9669d..41d8186 100644 --- a/src/polytomic/permissions/__init__.py +++ b/src/polytomic/permissions/__init__.py @@ -1,5 +1,34 @@ # This file was auto-generated by Fern from our API Definition. -from . import policies, roles +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from . import policies, roles +_dynamic_imports: typing.Dict[str, str] = {"policies": ".policies", "roles": ".roles"} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = ["policies", "roles"] diff --git a/src/polytomic/permissions/client.py b/src/polytomic/permissions/client.py index ba89074..361577a 100644 --- a/src/polytomic/permissions/client.py +++ b/src/polytomic/permissions/client.py @@ -1,22 +1,82 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.client_wrapper import SyncClientWrapper -from .policies.client import PoliciesClient -from .roles.client import RolesClient -from ..core.client_wrapper import AsyncClientWrapper -from .policies.client import AsyncPoliciesClient -from .roles.client import AsyncRolesClient +from __future__ import annotations + +import typing + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .raw_client import AsyncRawPermissionsClient, RawPermissionsClient + +if typing.TYPE_CHECKING: + from .policies.client import AsyncPoliciesClient, PoliciesClient + from .roles.client import AsyncRolesClient, RolesClient class PermissionsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawPermissionsClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper - self.policies = PoliciesClient(client_wrapper=self._client_wrapper) - self.roles = RolesClient(client_wrapper=self._client_wrapper) + self._policies: typing.Optional[PoliciesClient] = None + self._roles: typing.Optional[RolesClient] = None + + @property + def with_raw_response(self) -> RawPermissionsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawPermissionsClient + """ + return self._raw_client + + @property + def policies(self): + if self._policies is None: + from .policies.client import PoliciesClient # noqa: E402 + + self._policies = PoliciesClient(client_wrapper=self._client_wrapper) + return self._policies + + @property + def roles(self): + if self._roles is None: + from .roles.client import RolesClient # noqa: E402 + + self._roles = RolesClient(client_wrapper=self._client_wrapper) + return self._roles class AsyncPermissionsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawPermissionsClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper - self.policies = AsyncPoliciesClient(client_wrapper=self._client_wrapper) - self.roles = AsyncRolesClient(client_wrapper=self._client_wrapper) + self._policies: typing.Optional[AsyncPoliciesClient] = None + self._roles: typing.Optional[AsyncRolesClient] = None + + @property + def with_raw_response(self) -> AsyncRawPermissionsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawPermissionsClient + """ + return self._raw_client + + @property + def policies(self): + if self._policies is None: + from .policies.client import AsyncPoliciesClient # noqa: E402 + + self._policies = AsyncPoliciesClient(client_wrapper=self._client_wrapper) + return self._policies + + @property + def roles(self): + if self._roles is None: + from .roles.client import AsyncRolesClient # noqa: E402 + + self._roles = AsyncRolesClient(client_wrapper=self._client_wrapper) + return self._roles diff --git a/src/polytomic/permissions/policies/__init__.py b/src/polytomic/permissions/policies/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/permissions/policies/__init__.py +++ b/src/polytomic/permissions/policies/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/permissions/policies/client.py b/src/polytomic/permissions/policies/client.py index a0fc74a..2b0d4f8 100644 --- a/src/polytomic/permissions/policies/client.py +++ b/src/polytomic/permissions/policies/client.py @@ -1,24 +1,13 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ...core.client_wrapper import SyncClientWrapper + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.request_options import RequestOptions from ...types.list_policies_response_envelope import ListPoliciesResponseEnvelope -from ...core.pydantic_utilities import parse_obj_as -from ...errors.unauthorized_error import UnauthorizedError -from ...types.rest_err_response import RestErrResponse -from ...errors.internal_server_error import InternalServerError -from ...types.api_error import ApiError as types_api_error_ApiError -from json.decoder import JSONDecodeError -from ...core.api_error import ApiError as core_api_error_ApiError from ...types.policy_action import PolicyAction from ...types.policy_response_envelope import PolicyResponseEnvelope -from ...core.serialization import convert_and_respect_annotation_metadata -from ...errors.bad_request_error import BadRequestError -from ...errors.forbidden_error import ForbiddenError -from ...errors.not_found_error import NotFoundError -from ...core.jsonable_encoder import jsonable_encoder -from ...core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawPoliciesClient, RawPoliciesClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -26,7 +15,18 @@ class PoliciesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawPoliciesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawPoliciesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawPoliciesClient + """ + return self._raw_client def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> ListPoliciesResponseEnvelope: """ @@ -50,44 +50,8 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Li ) client.permissions.policies.list() """ - _response = self._client_wrapper.httpx_client.request( - "api/permissions/policies", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListPoliciesResponseEnvelope, - parse_obj_as( - type_=ListPoliciesResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.list(request_options=request_options) + return _response.data def create( self, @@ -126,85 +90,10 @@ def create( name="Custom", ) """ - _response = self._client_wrapper.httpx_client.request( - "api/permissions/policies", - method="POST", - json={ - "name": name, - "organization_id": organization_id, - "policy_actions": convert_and_respect_annotation_metadata( - object_=policy_actions, annotation=typing.Sequence[PolicyAction], direction="write" - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.create( + name=name, organization_id=organization_id, policy_actions=policy_actions, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PolicyResponseEnvelope, - parse_obj_as( - type_=PolicyResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> PolicyResponseEnvelope: """ @@ -232,54 +121,8 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/permissions/policies/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PolicyResponseEnvelope, - parse_obj_as( - type_=PolicyResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(id, request_options=request_options) + return _response.data def update( self, @@ -322,85 +165,14 @@ def update( name="Custom", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/permissions/policies/{jsonable_encoder(id)}", - method="PUT", - json={ - "name": name, - "organization_id": organization_id, - "policy_actions": convert_and_respect_annotation_metadata( - object_=policy_actions, annotation=typing.Sequence[PolicyAction], direction="write" - ), - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.update( + id, + name=name, + organization_id=organization_id, + policy_actions=policy_actions, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PolicyResponseEnvelope, - parse_obj_as( - type_=PolicyResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ @@ -427,63 +199,24 @@ def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/permissions/policies/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.remove(id, request_options=request_options) + return _response.data class AsyncPoliciesClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawPoliciesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawPoliciesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawPoliciesClient + """ + return self._raw_client async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> ListPoliciesResponseEnvelope: """ @@ -515,44 +248,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/permissions/policies", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListPoliciesResponseEnvelope, - parse_obj_as( - type_=ListPoliciesResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.list(request_options=request_options) + return _response.data async def create( self, @@ -599,85 +296,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/permissions/policies", - method="POST", - json={ - "name": name, - "organization_id": organization_id, - "policy_actions": convert_and_respect_annotation_metadata( - object_=policy_actions, annotation=typing.Sequence[PolicyAction], direction="write" - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.create( + name=name, organization_id=organization_id, policy_actions=policy_actions, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PolicyResponseEnvelope, - parse_obj_as( - type_=PolicyResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> PolicyResponseEnvelope: """ @@ -713,54 +335,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/permissions/policies/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PolicyResponseEnvelope, - parse_obj_as( - type_=PolicyResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(id, request_options=request_options) + return _response.data async def update( self, @@ -811,85 +387,14 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/permissions/policies/{jsonable_encoder(id)}", - method="PUT", - json={ - "name": name, - "organization_id": organization_id, - "policy_actions": convert_and_respect_annotation_metadata( - object_=policy_actions, annotation=typing.Sequence[PolicyAction], direction="write" - ), - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.update( + id, + name=name, + organization_id=organization_id, + policy_actions=policy_actions, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PolicyResponseEnvelope, - parse_obj_as( - type_=PolicyResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ @@ -924,55 +429,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/permissions/policies/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.remove(id, request_options=request_options) + return _response.data diff --git a/src/polytomic/permissions/policies/raw_client.py b/src/polytomic/permissions/policies/raw_client.py new file mode 100644 index 0000000..9712d1e --- /dev/null +++ b/src/polytomic/permissions/policies/raw_client.py @@ -0,0 +1,959 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError as core_api_error_ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.parse_error import ParsingError +from ...core.pydantic_utilities import parse_obj_as +from ...core.request_options import RequestOptions +from ...core.serialization import convert_and_respect_annotation_metadata +from ...errors.bad_request_error import BadRequestError +from ...errors.forbidden_error import ForbiddenError +from ...errors.internal_server_error import InternalServerError +from ...errors.not_found_error import NotFoundError +from ...errors.unauthorized_error import UnauthorizedError +from ...types.api_error import ApiError as types_api_error_ApiError +from ...types.list_policies_response_envelope import ListPoliciesResponseEnvelope +from ...types.policy_action import PolicyAction +from ...types.policy_response_envelope import PolicyResponseEnvelope +from ...types.rest_err_response import RestErrResponse +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawPoliciesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ListPoliciesResponseEnvelope]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ListPoliciesResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/permissions/policies", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListPoliciesResponseEnvelope, + parse_obj_as( + type_=ListPoliciesResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def create( + self, + *, + name: str, + organization_id: typing.Optional[str] = OMIT, + policy_actions: typing.Optional[typing.Sequence[PolicyAction]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[PolicyResponseEnvelope]: + """ + Parameters + ---------- + name : str + + organization_id : typing.Optional[str] + + policy_actions : typing.Optional[typing.Sequence[PolicyAction]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[PolicyResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/permissions/policies", + method="POST", + json={ + "name": name, + "organization_id": organization_id, + "policy_actions": convert_and_respect_annotation_metadata( + object_=policy_actions, annotation=typing.Optional[typing.Sequence[PolicyAction]], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PolicyResponseEnvelope, + parse_obj_as( + type_=PolicyResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[PolicyResponseEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[PolicyResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/permissions/policies/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PolicyResponseEnvelope, + parse_obj_as( + type_=PolicyResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def update( + self, + id: str, + *, + name: str, + organization_id: typing.Optional[str] = OMIT, + policy_actions: typing.Optional[typing.Sequence[PolicyAction]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[PolicyResponseEnvelope]: + """ + Parameters + ---------- + id : str + + name : str + + organization_id : typing.Optional[str] + + policy_actions : typing.Optional[typing.Sequence[PolicyAction]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[PolicyResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/permissions/policies/{jsonable_encoder(id)}", + method="PUT", + json={ + "name": name, + "organization_id": organization_id, + "policy_actions": convert_and_respect_annotation_metadata( + object_=policy_actions, annotation=typing.Optional[typing.Sequence[PolicyAction]], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PolicyResponseEnvelope, + parse_obj_as( + type_=PolicyResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/permissions/policies/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawPoliciesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ListPoliciesResponseEnvelope]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ListPoliciesResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/permissions/policies", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListPoliciesResponseEnvelope, + parse_obj_as( + type_=ListPoliciesResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def create( + self, + *, + name: str, + organization_id: typing.Optional[str] = OMIT, + policy_actions: typing.Optional[typing.Sequence[PolicyAction]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[PolicyResponseEnvelope]: + """ + Parameters + ---------- + name : str + + organization_id : typing.Optional[str] + + policy_actions : typing.Optional[typing.Sequence[PolicyAction]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[PolicyResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/permissions/policies", + method="POST", + json={ + "name": name, + "organization_id": organization_id, + "policy_actions": convert_and_respect_annotation_metadata( + object_=policy_actions, annotation=typing.Optional[typing.Sequence[PolicyAction]], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PolicyResponseEnvelope, + parse_obj_as( + type_=PolicyResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[PolicyResponseEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[PolicyResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/permissions/policies/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PolicyResponseEnvelope, + parse_obj_as( + type_=PolicyResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def update( + self, + id: str, + *, + name: str, + organization_id: typing.Optional[str] = OMIT, + policy_actions: typing.Optional[typing.Sequence[PolicyAction]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[PolicyResponseEnvelope]: + """ + Parameters + ---------- + id : str + + name : str + + organization_id : typing.Optional[str] + + policy_actions : typing.Optional[typing.Sequence[PolicyAction]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[PolicyResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/permissions/policies/{jsonable_encoder(id)}", + method="PUT", + json={ + "name": name, + "organization_id": organization_id, + "policy_actions": convert_and_respect_annotation_metadata( + object_=policy_actions, annotation=typing.Optional[typing.Sequence[PolicyAction]], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PolicyResponseEnvelope, + parse_obj_as( + type_=PolicyResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def remove( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/permissions/policies/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/permissions/raw_client.py b/src/polytomic/permissions/raw_client.py new file mode 100644 index 0000000..110e57a --- /dev/null +++ b/src/polytomic/permissions/raw_client.py @@ -0,0 +1,13 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper + + +class RawPermissionsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + +class AsyncRawPermissionsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper diff --git a/src/polytomic/permissions/roles/__init__.py b/src/polytomic/permissions/roles/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/permissions/roles/__init__.py +++ b/src/polytomic/permissions/roles/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/permissions/roles/client.py b/src/polytomic/permissions/roles/client.py index b7a80bc..7178f57 100644 --- a/src/polytomic/permissions/roles/client.py +++ b/src/polytomic/permissions/roles/client.py @@ -1,22 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ...core.client_wrapper import SyncClientWrapper + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.request_options import RequestOptions from ...types.role_list_response_envelope import RoleListResponseEnvelope -from ...core.pydantic_utilities import parse_obj_as -from ...errors.unauthorized_error import UnauthorizedError -from ...types.rest_err_response import RestErrResponse -from ...errors.internal_server_error import InternalServerError -from ...types.api_error import ApiError as types_api_error_ApiError -from json.decoder import JSONDecodeError -from ...core.api_error import ApiError as core_api_error_ApiError from ...types.role_response_envelope import RoleResponseEnvelope -from ...errors.bad_request_error import BadRequestError -from ...errors.forbidden_error import ForbiddenError -from ...errors.not_found_error import NotFoundError -from ...core.jsonable_encoder import jsonable_encoder -from ...core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawRolesClient, RawRolesClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -24,7 +14,18 @@ class RolesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawRolesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawRolesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawRolesClient + """ + return self._raw_client def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> RoleListResponseEnvelope: """ @@ -48,44 +49,8 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Ro ) client.permissions.roles.list() """ - _response = self._client_wrapper.httpx_client.request( - "api/permissions/roles", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - RoleListResponseEnvelope, - parse_obj_as( - type_=RoleListResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.list(request_options=request_options) + return _response.data def create( self, @@ -121,82 +86,8 @@ def create( name="Custom", ) """ - _response = self._client_wrapper.httpx_client.request( - "api/permissions/roles", - method="POST", - json={ - "name": name, - "organization_id": organization_id, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - RoleResponseEnvelope, - parse_obj_as( - type_=RoleResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.create(name=name, organization_id=organization_id, request_options=request_options) + return _response.data def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> RoleResponseEnvelope: """ @@ -224,44 +115,8 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/permissions/roles/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - RoleResponseEnvelope, - parse_obj_as( - type_=RoleResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(id, request_options=request_options) + return _response.data def update( self, @@ -301,82 +156,10 @@ def update( name="Custom", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/permissions/roles/{jsonable_encoder(id)}", - method="PUT", - json={ - "name": name, - "organization_id": organization_id, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.update( + id, name=name, organization_id=organization_id, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - RoleResponseEnvelope, - parse_obj_as( - type_=RoleResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ @@ -403,63 +186,24 @@ def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/permissions/roles/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.remove(id, request_options=request_options) + return _response.data class AsyncRolesClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawRolesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawRolesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawRolesClient + """ + return self._raw_client async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> RoleListResponseEnvelope: """ @@ -491,44 +235,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/permissions/roles", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - RoleListResponseEnvelope, - parse_obj_as( - type_=RoleListResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.list(request_options=request_options) + return _response.data async def create( self, @@ -572,82 +280,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/permissions/roles", - method="POST", - json={ - "name": name, - "organization_id": organization_id, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.create( + name=name, organization_id=organization_id, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - RoleResponseEnvelope, - parse_obj_as( - type_=RoleResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> RoleResponseEnvelope: """ @@ -683,44 +319,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/permissions/roles/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - RoleResponseEnvelope, - parse_obj_as( - type_=RoleResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(id, request_options=request_options) + return _response.data async def update( self, @@ -768,82 +368,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/permissions/roles/{jsonable_encoder(id)}", - method="PUT", - json={ - "name": name, - "organization_id": organization_id, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.update( + id, name=name, organization_id=organization_id, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - RoleResponseEnvelope, - parse_obj_as( - type_=RoleResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ @@ -878,55 +406,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/permissions/roles/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.remove(id, request_options=request_options) + return _response.data diff --git a/src/polytomic/permissions/roles/raw_client.py b/src/polytomic/permissions/roles/raw_client.py new file mode 100644 index 0000000..2e8c84c --- /dev/null +++ b/src/polytomic/permissions/roles/raw_client.py @@ -0,0 +1,911 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError as core_api_error_ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.parse_error import ParsingError +from ...core.pydantic_utilities import parse_obj_as +from ...core.request_options import RequestOptions +from ...errors.bad_request_error import BadRequestError +from ...errors.forbidden_error import ForbiddenError +from ...errors.internal_server_error import InternalServerError +from ...errors.not_found_error import NotFoundError +from ...errors.unauthorized_error import UnauthorizedError +from ...types.api_error import ApiError as types_api_error_ApiError +from ...types.rest_err_response import RestErrResponse +from ...types.role_list_response_envelope import RoleListResponseEnvelope +from ...types.role_response_envelope import RoleResponseEnvelope +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawRolesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[RoleListResponseEnvelope]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[RoleListResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/permissions/roles", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RoleListResponseEnvelope, + parse_obj_as( + type_=RoleListResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def create( + self, + *, + name: str, + organization_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[RoleResponseEnvelope]: + """ + Parameters + ---------- + name : str + + organization_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[RoleResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/permissions/roles", + method="POST", + json={ + "name": name, + "organization_id": organization_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RoleResponseEnvelope, + parse_obj_as( + type_=RoleResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[RoleResponseEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[RoleResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/permissions/roles/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RoleResponseEnvelope, + parse_obj_as( + type_=RoleResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def update( + self, + id: str, + *, + name: str, + organization_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[RoleResponseEnvelope]: + """ + Parameters + ---------- + id : str + + name : str + + organization_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[RoleResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/permissions/roles/{jsonable_encoder(id)}", + method="PUT", + json={ + "name": name, + "organization_id": organization_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RoleResponseEnvelope, + parse_obj_as( + type_=RoleResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/permissions/roles/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawRolesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[RoleListResponseEnvelope]: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[RoleListResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/permissions/roles", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RoleListResponseEnvelope, + parse_obj_as( + type_=RoleListResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def create( + self, + *, + name: str, + organization_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[RoleResponseEnvelope]: + """ + Parameters + ---------- + name : str + + organization_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[RoleResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/permissions/roles", + method="POST", + json={ + "name": name, + "organization_id": organization_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RoleResponseEnvelope, + parse_obj_as( + type_=RoleResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[RoleResponseEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[RoleResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/permissions/roles/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RoleResponseEnvelope, + parse_obj_as( + type_=RoleResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def update( + self, + id: str, + *, + name: str, + organization_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[RoleResponseEnvelope]: + """ + Parameters + ---------- + id : str + + name : str + + organization_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[RoleResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/permissions/roles/{jsonable_encoder(id)}", + method="PUT", + json={ + "name": name, + "organization_id": organization_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RoleResponseEnvelope, + parse_obj_as( + type_=RoleResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def remove( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/permissions/roles/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/query_runner/__init__.py b/src/polytomic/query_runner/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/query_runner/__init__.py +++ b/src/polytomic/query_runner/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/query_runner/client.py b/src/polytomic/query_runner/client.py index cd5fc5b..4f5f9a6 100644 --- a/src/polytomic/query_runner/client.py +++ b/src/polytomic/query_runner/client.py @@ -1,21 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions -from ..types.v_4_run_query_envelope import V4RunQueryEnvelope -from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import parse_obj_as -from ..errors.bad_request_error import BadRequestError -from ..types.api_error import ApiError as types_api_error_ApiError -from ..errors.unauthorized_error import UnauthorizedError -from ..types.rest_err_response import RestErrResponse -from ..errors.not_found_error import NotFoundError -from ..errors.internal_server_error import InternalServerError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError as core_api_error_ApiError from ..types.v_4_query_results_envelope import V4QueryResultsEnvelope -from ..core.client_wrapper import AsyncClientWrapper +from ..types.v_4_run_query_envelope import V4RunQueryEnvelope +from .raw_client import AsyncRawQueryRunnerClient, RawQueryRunnerClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -23,7 +14,18 @@ class QueryRunnerClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawQueryRunnerClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawQueryRunnerClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawQueryRunnerClient + """ + return self._raw_client def run_query( self, @@ -33,6 +35,8 @@ def run_query( request_options: typing.Optional[RequestOptions] = None, ) -> V4RunQueryEnvelope: """ + Submit a query for asynchronous execution against the connection. The initial response may only contain the query task id and status. Poll GET /api/queries/{id} with the returned id to retrieve completion status, fields, and results. + Parameters ---------- connection_id : str @@ -61,77 +65,15 @@ def run_query( query="SELECT * FROM table", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(connection_id)}/query", - method="POST", - params={ - "query": query, - }, - json={}, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4RunQueryEnvelope, - parse_obj_as( - type_=V4RunQueryEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.run_query(connection_id, query=query, request_options=request_options) + return _response.data def get_query( self, id: str, *, page: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None ) -> V4QueryResultsEnvelope: """ + Fetch the latest status for a submitted query and, once complete, return fields and paginated results. Use the query id returned by POST /api/connections/{connection_id}/query. + Parameters ---------- id : str @@ -158,72 +100,24 @@ def get_query( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/queries/{jsonable_encoder(id)}", - method="GET", - params={ - "page": page, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4QueryResultsEnvelope, - parse_obj_as( - type_=V4QueryResultsEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_query(id, page=page, request_options=request_options) + return _response.data class AsyncQueryRunnerClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawQueryRunnerClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawQueryRunnerClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawQueryRunnerClient + """ + return self._raw_client async def run_query( self, @@ -233,6 +127,8 @@ async def run_query( request_options: typing.Optional[RequestOptions] = None, ) -> V4RunQueryEnvelope: """ + Submit a query for asynchronous execution against the connection. The initial response may only contain the query task id and status. Poll GET /api/queries/{id} with the returned id to retrieve completion status, fields, and results. + Parameters ---------- connection_id : str @@ -269,77 +165,15 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(connection_id)}/query", - method="POST", - params={ - "query": query, - }, - json={}, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4RunQueryEnvelope, - parse_obj_as( - type_=V4RunQueryEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.run_query(connection_id, query=query, request_options=request_options) + return _response.data async def get_query( self, id: str, *, page: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None ) -> V4QueryResultsEnvelope: """ + Fetch the latest status for a submitted query and, once complete, return fields and paginated results. Use the query id returned by POST /api/connections/{connection_id}/query. + Parameters ---------- id : str @@ -374,64 +208,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/queries/{jsonable_encoder(id)}", - method="GET", - params={ - "page": page, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - V4QueryResultsEnvelope, - parse_obj_as( - type_=V4QueryResultsEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_query(id, page=page, request_options=request_options) + return _response.data diff --git a/src/polytomic/query_runner/raw_client.py b/src/polytomic/query_runner/raw_client.py new file mode 100644 index 0000000..ecf4a40 --- /dev/null +++ b/src/polytomic/query_runner/raw_client.py @@ -0,0 +1,434 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError as core_api_error_ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..errors.bad_request_error import BadRequestError +from ..errors.internal_server_error import InternalServerError +from ..errors.not_found_error import NotFoundError +from ..errors.unauthorized_error import UnauthorizedError +from ..types.api_error import ApiError as types_api_error_ApiError +from ..types.rest_err_response import RestErrResponse +from ..types.v_4_query_results_envelope import V4QueryResultsEnvelope +from ..types.v_4_run_query_envelope import V4RunQueryEnvelope +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawQueryRunnerClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def run_query( + self, + connection_id: str, + *, + query: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[V4RunQueryEnvelope]: + """ + Submit a query for asynchronous execution against the connection. The initial response may only contain the query task id and status. Poll GET /api/queries/{id} with the returned id to retrieve completion status, fields, and results. + + Parameters + ---------- + connection_id : str + + query : typing.Optional[str] + The query to execute against the connection. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[V4RunQueryEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(connection_id)}/query", + method="POST", + params={ + "query": query, + }, + json={}, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4RunQueryEnvelope, + parse_obj_as( + type_=V4RunQueryEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_query( + self, id: str, *, page: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[V4QueryResultsEnvelope]: + """ + Fetch the latest status for a submitted query and, once complete, return fields and paginated results. Use the query id returned by POST /api/connections/{connection_id}/query. + + Parameters + ---------- + id : str + + page : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[V4QueryResultsEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/queries/{jsonable_encoder(id)}", + method="GET", + params={ + "page": page, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4QueryResultsEnvelope, + parse_obj_as( + type_=V4QueryResultsEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawQueryRunnerClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def run_query( + self, + connection_id: str, + *, + query: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[V4RunQueryEnvelope]: + """ + Submit a query for asynchronous execution against the connection. The initial response may only contain the query task id and status. Poll GET /api/queries/{id} with the returned id to retrieve completion status, fields, and results. + + Parameters + ---------- + connection_id : str + + query : typing.Optional[str] + The query to execute against the connection. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[V4RunQueryEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(connection_id)}/query", + method="POST", + params={ + "query": query, + }, + json={}, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4RunQueryEnvelope, + parse_obj_as( + type_=V4RunQueryEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_query( + self, id: str, *, page: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[V4QueryResultsEnvelope]: + """ + Fetch the latest status for a submitted query and, once complete, return fields and paginated results. Use the query id returned by POST /api/connections/{connection_id}/query. + + Parameters + ---------- + id : str + + page : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[V4QueryResultsEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/queries/{jsonable_encoder(id)}", + method="GET", + params={ + "page": page, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + V4QueryResultsEnvelope, + parse_obj_as( + type_=V4QueryResultsEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/schemas/__init__.py b/src/polytomic/schemas/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/schemas/__init__.py +++ b/src/polytomic/schemas/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/schemas/client.py b/src/polytomic/schemas/client.py index 04edb01..579e0e5 100644 --- a/src/polytomic/schemas/client.py +++ b/src/polytomic/schemas/client.py @@ -1,26 +1,15 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper -from ..types.v_4_user_field_request import V4UserFieldRequest + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions -from ..core.jsonable_encoder import jsonable_encoder -from ..core.serialization import convert_and_respect_annotation_metadata -from ..errors.bad_request_error import BadRequestError -from ..types.api_error import ApiError as types_api_error_ApiError -from ..core.pydantic_utilities import parse_obj_as -from ..errors.unauthorized_error import UnauthorizedError -from ..types.rest_err_response import RestErrResponse -from ..errors.not_found_error import NotFoundError -from ..errors.internal_server_error import InternalServerError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError as core_api_error_ApiError -from ..types.schema_primary_key_override_input import SchemaPrimaryKeyOverrideInput -from ..types.bulk_sync_source_status_envelope import BulkSyncSourceStatusEnvelope from ..types.bulk_sync_source_schema_envelope import BulkSyncSourceSchemaEnvelope +from ..types.bulk_sync_source_status_envelope import BulkSyncSourceStatusEnvelope +from ..types.schema_primary_key_override_input import SchemaPrimaryKeyOverrideInput from ..types.schema_records_response_envelope import SchemaRecordsResponseEnvelope -from ..errors.forbidden_error import ForbiddenError -from ..core.client_wrapper import AsyncClientWrapper +from ..types.v_4_user_field_request import V4UserFieldRequest +from .raw_client import AsyncRawSchemasClient, RawSchemasClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -28,7 +17,18 @@ class SchemasClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawSchemasClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSchemasClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSchemasClient + """ + return self._raw_client def upsert_field( self, @@ -67,67 +67,10 @@ def upsert_field( schema_id="public.users", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/fields", - method="POST", - json={ - "fields": convert_and_respect_annotation_metadata( - object_=fields, annotation=typing.Sequence[V4UserFieldRequest], direction="write" - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.upsert_field( + connection_id, schema_id, fields=fields, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def delete_field( self, @@ -167,58 +110,8 @@ def delete_field( field_id="first_name", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/fields/{jsonable_encoder(field_id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.delete_field(connection_id, schema_id, field_id, request_options=request_options) + return _response.data def set_primary_keys( self, @@ -257,67 +150,10 @@ def set_primary_keys( schema_id="public.users", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/primary_keys", - method="PUT", - json={ - "fields": convert_and_respect_annotation_metadata( - object_=fields, annotation=typing.Sequence[SchemaPrimaryKeyOverrideInput], direction="write" - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.set_primary_keys( + connection_id, schema_id, fields=fields, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def reset_primary_keys( self, connection_id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -351,58 +187,8 @@ def reset_primary_keys( schema_id="public.users", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/primary_keys", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.reset_primary_keys(connection_id, schema_id, request_options=request_options) + return _response.data def refresh(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ @@ -429,58 +215,8 @@ def refresh(self, id: str, *, request_options: typing.Optional[RequestOptions] = id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/schemas/refresh", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.refresh(id, request_options=request_options) + return _response.data def get_status( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -512,64 +248,8 @@ def get_status( id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/schemas/status", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncSourceStatusEnvelope, - parse_obj_as( - type_=BulkSyncSourceStatusEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_status(id, request_options=request_options) + return _response.data def get( self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -602,64 +282,8 @@ def get( schema_id="public.users", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncSourceSchemaEnvelope, - parse_obj_as( - type_=BulkSyncSourceSchemaEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(id, schema_id, request_options=request_options) + return _response.data def get_records( self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -692,79 +316,24 @@ def get_records( schema_id="public.users", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}/records", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SchemaRecordsResponseEnvelope, - parse_obj_as( - type_=SchemaRecordsResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_records(id, schema_id, request_options=request_options) + return _response.data class AsyncSchemasClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawSchemasClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSchemasClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSchemasClient + """ + return self._raw_client async def upsert_field( self, @@ -811,67 +380,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/fields", - method="POST", - json={ - "fields": convert_and_respect_annotation_metadata( - object_=fields, annotation=typing.Sequence[V4UserFieldRequest], direction="write" - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.upsert_field( + connection_id, schema_id, fields=fields, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def delete_field( self, @@ -919,58 +431,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/fields/{jsonable_encoder(field_id)}", - method="DELETE", - request_options=request_options, + _response = await self._raw_client.delete_field( + connection_id, schema_id, field_id, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def set_primary_keys( self, @@ -1017,67 +481,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/primary_keys", - method="PUT", - json={ - "fields": convert_and_respect_annotation_metadata( - object_=fields, annotation=typing.Sequence[SchemaPrimaryKeyOverrideInput], direction="write" - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.set_primary_keys( + connection_id, schema_id, fields=fields, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def reset_primary_keys( self, connection_id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -1119,58 +526,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/primary_keys", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.reset_primary_keys(connection_id, schema_id, request_options=request_options) + return _response.data async def refresh(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ @@ -1205,58 +562,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/schemas/refresh", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.refresh(id, request_options=request_options) + return _response.data async def get_status( self, id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -1296,64 +603,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/schemas/status", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncSourceStatusEnvelope, - parse_obj_as( - type_=BulkSyncSourceStatusEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_status(id, request_options=request_options) + return _response.data async def get( self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -1394,64 +645,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BulkSyncSourceSchemaEnvelope, - parse_obj_as( - type_=BulkSyncSourceSchemaEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(id, schema_id, request_options=request_options) + return _response.data async def get_records( self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -1492,71 +687,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/connections/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}/records", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SchemaRecordsResponseEnvelope, - parse_obj_as( - type_=SchemaRecordsResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_records(id, schema_id, request_options=request_options) + return _response.data diff --git a/src/polytomic/schemas/raw_client.py b/src/polytomic/schemas/raw_client.py new file mode 100644 index 0000000..3fdd10f --- /dev/null +++ b/src/polytomic/schemas/raw_client.py @@ -0,0 +1,1501 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError as core_api_error_ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..core.serialization import convert_and_respect_annotation_metadata +from ..errors.bad_request_error import BadRequestError +from ..errors.forbidden_error import ForbiddenError +from ..errors.internal_server_error import InternalServerError +from ..errors.not_found_error import NotFoundError +from ..errors.unauthorized_error import UnauthorizedError +from ..types.api_error import ApiError as types_api_error_ApiError +from ..types.bulk_sync_source_schema_envelope import BulkSyncSourceSchemaEnvelope +from ..types.bulk_sync_source_status_envelope import BulkSyncSourceStatusEnvelope +from ..types.rest_err_response import RestErrResponse +from ..types.schema_primary_key_override_input import SchemaPrimaryKeyOverrideInput +from ..types.schema_records_response_envelope import SchemaRecordsResponseEnvelope +from ..types.v_4_user_field_request import V4UserFieldRequest +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawSchemasClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def upsert_field( + self, + connection_id: str, + schema_id: str, + *, + fields: typing.Optional[typing.Sequence[V4UserFieldRequest]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[None]: + """ + Parameters + ---------- + connection_id : str + + schema_id : str + + fields : typing.Optional[typing.Sequence[V4UserFieldRequest]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/fields", + method="POST", + json={ + "fields": convert_and_respect_annotation_metadata( + object_=fields, annotation=typing.Optional[typing.Sequence[V4UserFieldRequest]], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def delete_field( + self, + connection_id: str, + schema_id: str, + field_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[None]: + """ + Parameters + ---------- + connection_id : str + + schema_id : str + + field_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/fields/{jsonable_encoder(field_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def set_primary_keys( + self, + connection_id: str, + schema_id: str, + *, + fields: typing.Optional[typing.Sequence[SchemaPrimaryKeyOverrideInput]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[None]: + """ + Parameters + ---------- + connection_id : str + + schema_id : str + + fields : typing.Optional[typing.Sequence[SchemaPrimaryKeyOverrideInput]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/primary_keys", + method="PUT", + json={ + "fields": convert_and_respect_annotation_metadata( + object_=fields, + annotation=typing.Optional[typing.Sequence[SchemaPrimaryKeyOverrideInput]], + direction="write", + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def reset_primary_keys( + self, connection_id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[None]: + """ + Delete all primary key overrides for a schema. After this call the schema will use the primary keys detected from the source connection, if any. + + Parameters + ---------- + connection_id : str + + schema_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/primary_keys", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def refresh(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/schemas/refresh", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_status( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[BulkSyncSourceStatusEnvelope]: + """ + Polytomic periodically inspects the schemas for connections to discover new fields and update metadata. This endpoint returns the current inspection status. + + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BulkSyncSourceStatusEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/schemas/status", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncSourceStatusEnvelope, + parse_obj_as( + type_=BulkSyncSourceStatusEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get( + self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[BulkSyncSourceSchemaEnvelope]: + """ + Parameters + ---------- + id : str + + schema_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BulkSyncSourceSchemaEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncSourceSchemaEnvelope, + parse_obj_as( + type_=BulkSyncSourceSchemaEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get_records( + self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[SchemaRecordsResponseEnvelope]: + """ + Parameters + ---------- + id : str + + schema_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SchemaRecordsResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}/records", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SchemaRecordsResponseEnvelope, + parse_obj_as( + type_=SchemaRecordsResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawSchemasClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def upsert_field( + self, + connection_id: str, + schema_id: str, + *, + fields: typing.Optional[typing.Sequence[V4UserFieldRequest]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + connection_id : str + + schema_id : str + + fields : typing.Optional[typing.Sequence[V4UserFieldRequest]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/fields", + method="POST", + json={ + "fields": convert_and_respect_annotation_metadata( + object_=fields, annotation=typing.Optional[typing.Sequence[V4UserFieldRequest]], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def delete_field( + self, + connection_id: str, + schema_id: str, + field_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + connection_id : str + + schema_id : str + + field_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/fields/{jsonable_encoder(field_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def set_primary_keys( + self, + connection_id: str, + schema_id: str, + *, + fields: typing.Optional[typing.Sequence[SchemaPrimaryKeyOverrideInput]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + connection_id : str + + schema_id : str + + fields : typing.Optional[typing.Sequence[SchemaPrimaryKeyOverrideInput]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/primary_keys", + method="PUT", + json={ + "fields": convert_and_respect_annotation_metadata( + object_=fields, + annotation=typing.Optional[typing.Sequence[SchemaPrimaryKeyOverrideInput]], + direction="write", + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def reset_primary_keys( + self, connection_id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Delete all primary key overrides for a schema. After this call the schema will use the primary keys detected from the source connection, if any. + + Parameters + ---------- + connection_id : str + + schema_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(connection_id)}/schemas/{jsonable_encoder(schema_id)}/primary_keys", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def refresh( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/schemas/refresh", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_status( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[BulkSyncSourceStatusEnvelope]: + """ + Polytomic periodically inspects the schemas for connections to discover new fields and update metadata. This endpoint returns the current inspection status. + + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BulkSyncSourceStatusEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/schemas/status", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncSourceStatusEnvelope, + parse_obj_as( + type_=BulkSyncSourceStatusEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[BulkSyncSourceSchemaEnvelope]: + """ + Parameters + ---------- + id : str + + schema_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BulkSyncSourceSchemaEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BulkSyncSourceSchemaEnvelope, + parse_obj_as( + type_=BulkSyncSourceSchemaEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get_records( + self, id: str, schema_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[SchemaRecordsResponseEnvelope]: + """ + Parameters + ---------- + id : str + + schema_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SchemaRecordsResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/connections/{jsonable_encoder(id)}/schemas/{jsonable_encoder(schema_id)}/records", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SchemaRecordsResponseEnvelope, + parse_obj_as( + type_=SchemaRecordsResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/types/__init__.py b/src/polytomic/types/__init__.py index 149f3e1..689e3b0 100644 --- a/src/polytomic/types/__init__.py +++ b/src/polytomic/types/__init__.py @@ -1,210 +1,453 @@ # This file was auto-generated by Fern from our API Definition. -from .types_type import TypesType -from .activate_sync_envelope import ActivateSyncEnvelope -from .activate_sync_input import ActivateSyncInput -from .activate_sync_output import ActivateSyncOutput -from .api_error import ApiError -from .api_key_response import ApiKeyResponse -from .api_key_response_envelope import ApiKeyResponseEnvelope -from .backend_connection_capabilities import BackendConnectionCapabilities -from .backend_o_auth_prompt import BackendOAuthPrompt -from .bulk_bulk_sync_schedule import BulkBulkSyncSchedule -from .bulk_discover import BulkDiscover -from .bulk_execution_status import BulkExecutionStatus -from .bulk_fetch_mode import BulkFetchMode -from .bulk_field import BulkField -from .bulk_filter import BulkFilter -from .bulk_itemized_schedule import BulkItemizedSchedule -from .bulk_multi_schedule_configuration import BulkMultiScheduleConfiguration -from .bulk_normalize_names import BulkNormalizeNames -from .bulk_schedule import BulkSchedule -from .bulk_schedule_sync_mode import BulkScheduleSyncMode -from .bulk_schema import BulkSchema -from .bulk_schema_envelope import BulkSchemaEnvelope -from .bulk_schema_execution_status import BulkSchemaExecutionStatus -from .bulk_selective_mode import BulkSelectiveMode -from .bulk_sync_canceled_event import BulkSyncCanceledEvent -from .bulk_sync_completed_event import BulkSyncCompletedEvent -from .bulk_sync_completed_with_error_event import BulkSyncCompletedWithErrorEvent -from .bulk_sync_dest import BulkSyncDest -from .bulk_sync_dest_envelope import BulkSyncDestEnvelope -from .bulk_sync_execution import BulkSyncExecution -from .bulk_sync_execution_envelope import BulkSyncExecutionEnvelope -from .bulk_sync_execution_status import BulkSyncExecutionStatus -from .bulk_sync_failed_event import BulkSyncFailedEvent -from .bulk_sync_list_envelope import BulkSyncListEnvelope -from .bulk_sync_mode import BulkSyncMode -from .bulk_sync_response import BulkSyncResponse -from .bulk_sync_response_envelope import BulkSyncResponseEnvelope -from .bulk_sync_running_event import BulkSyncRunningEvent -from .bulk_sync_schema_execution import BulkSyncSchemaExecution -from .bulk_sync_schema_execution_status import BulkSyncSchemaExecutionStatus -from .bulk_sync_source import BulkSyncSource -from .bulk_sync_source_envelope import BulkSyncSourceEnvelope -from .bulk_sync_source_schema_envelope import BulkSyncSourceSchemaEnvelope -from .bulk_sync_source_status import BulkSyncSourceStatus -from .bulk_sync_source_status_envelope import BulkSyncSourceStatusEnvelope -from .bulk_sync_status_envelope import BulkSyncStatusEnvelope -from .bulk_sync_status_response import BulkSyncStatusResponse -from .cancel_bulk_sync_response import CancelBulkSyncResponse -from .cancel_bulk_sync_response_envelope import CancelBulkSyncResponseEnvelope -from .cancel_model_sync_response import CancelModelSyncResponse -from .cancel_model_sync_response_envelope import CancelModelSyncResponseEnvelope -from .common_output_actor import CommonOutputActor -from .configuration_value import ConfigurationValue -from .connect_card_response import ConnectCardResponse -from .connect_card_response_envelope import ConnectCardResponseEnvelope -from .connection_list_response_envelope import ConnectionListResponseEnvelope -from .connection_meta import ConnectionMeta -from .connection_meta_response import ConnectionMetaResponse -from .connection_parameter_value import ConnectionParameterValue -from .connection_parameter_values_resp import ConnectionParameterValuesResp -from .connection_parameter_values_response_envelope import ConnectionParameterValuesResponseEnvelope -from .connection_response_envelope import ConnectionResponseEnvelope -from .connection_response_schema import ConnectionResponseSchema -from .connection_type import ConnectionType -from .connection_type_response_envelope import ConnectionTypeResponseEnvelope -from .connection_type_schema import ConnectionTypeSchema -from .create_connection_response_envelope import CreateConnectionResponseEnvelope -from .create_connection_response_schema import CreateConnectionResponseSchema -from .create_model_request import CreateModelRequest -from .create_shared_connection_response_schema import CreateSharedConnectionResponseSchema -from .enrichment import Enrichment -from .event import Event -from .event_body import EventBody -from .event_types_envelope import EventTypesEnvelope -from .events_envelope import EventsEnvelope -from .execution_counts import ExecutionCounts -from .execution_log_response import ExecutionLogResponse -from .execution_logs_response_envelope import ExecutionLogsResponseEnvelope -from .execution_status import ExecutionStatus -from .field_configuration import FieldConfiguration -from .filter import Filter -from .filter_field_reference_type import FilterFieldReferenceType -from .filter_function import FilterFunction -from .get_connection_meta_envelope import GetConnectionMetaEnvelope -from .get_execution_response_envelope import GetExecutionResponseEnvelope -from .get_execution_response_schema import GetExecutionResponseSchema -from .get_identity_response_envelope import GetIdentityResponseEnvelope -from .get_identity_response_schema import GetIdentityResponseSchema -from .get_model_sync_source_meta_envelope import GetModelSyncSourceMetaEnvelope -from .identity import Identity -from .identity_function import IdentityFunction -from .job_response import JobResponse -from .job_response_envelope import JobResponseEnvelope -from .jsonschema_definitions import JsonschemaDefinitions -from .jsonschema_form import JsonschemaForm -from .jsonschema_schema import JsonschemaSchema -from .label_label import LabelLabel -from .list_bulk_schema import ListBulkSchema -from .list_bulk_sync_execution_status_envelope import ListBulkSyncExecutionStatusEnvelope -from .list_bulk_sync_executions_envelope import ListBulkSyncExecutionsEnvelope -from .list_execution_response_envelope import ListExecutionResponseEnvelope -from .list_model_sync_response_envelope import ListModelSyncResponseEnvelope -from .list_policies_response_envelope import ListPoliciesResponseEnvelope -from .list_users_envelope import ListUsersEnvelope -from .mode import Mode -from .model_field import ModelField -from .model_field_response import ModelFieldResponse -from .model_list_response_envelope import ModelListResponseEnvelope -from .model_model_field_request import ModelModelFieldRequest -from .model_relation import ModelRelation -from .model_relation_to import ModelRelationTo -from .model_response import ModelResponse -from .model_response_envelope import ModelResponseEnvelope -from .model_sample import ModelSample -from .model_sample_response_envelope import ModelSampleResponseEnvelope -from .model_sync_field import ModelSyncField -from .model_sync_mode import ModelSyncMode -from .model_sync_response import ModelSyncResponse -from .model_sync_response_envelope import ModelSyncResponseEnvelope -from .model_sync_source_meta_response import ModelSyncSourceMetaResponse -from .organization import Organization -from .organization_envelope import OrganizationEnvelope -from .organizations_envelope import OrganizationsEnvelope -from .override import Override -from .pagination import Pagination -from .pagination_details import PaginationDetails -from .pick_value import PickValue -from .policy_action import PolicyAction -from .policy_response import PolicyResponse -from .policy_response_envelope import PolicyResponseEnvelope -from .relation import Relation -from .relation_to import RelationTo -from .rest_err_response import RestErrResponse -from .role_list_response_envelope import RoleListResponseEnvelope -from .role_response import RoleResponse -from .role_response_envelope import RoleResponseEnvelope -from .run_after import RunAfter -from .schedule import Schedule -from .schedule_envelope import ScheduleEnvelope -from .schedule_frequency import ScheduleFrequency -from .schedule_option_response import ScheduleOptionResponse -from .schedule_option_response_envelope import ScheduleOptionResponseEnvelope -from .schedule_schedule_option import ScheduleScheduleOption -from .schedules_envelope import SchedulesEnvelope -from .schema import Schema -from .schema_association import SchemaAssociation -from .schema_configuration import SchemaConfiguration -from .schema_field import SchemaField -from .schema_identity_function import SchemaIdentityFunction -from .schema_primary_key_override_input import SchemaPrimaryKeyOverrideInput -from .schema_records_response_envelope import SchemaRecordsResponseEnvelope -from .source import Source -from .source_meta import SourceMeta -from .start_model_sync_response_envelope import StartModelSyncResponseEnvelope -from .start_model_sync_response_schema import StartModelSyncResponseSchema -from .supported_bulk_mode import SupportedBulkMode -from .supported_mode import SupportedMode -from .sync_canceled_event import SyncCanceledEvent -from .sync_completed_event import SyncCompletedEvent -from .sync_completed_with_errors_event import SyncCompletedWithErrorsEvent -from .sync_destination_properties import SyncDestinationProperties -from .sync_failed_event import SyncFailedEvent -from .sync_running_event import SyncRunningEvent -from .sync_status_envelope import SyncStatusEnvelope -from .sync_status_response import SyncStatusResponse -from .target import Target -from .target_create_input import TargetCreateInput -from .target_field import TargetField -from .target_object import TargetObject -from .target_response import TargetResponse -from .target_response_envelope import TargetResponseEnvelope -from .update_bulk_field import UpdateBulkField -from .user import User -from .user_envelope import UserEnvelope -from .util_enum_value import UtilEnumValue -from .util_field_type import UtilFieldType -from .v_2_connection_form import V2ConnectionForm -from .v_2_create_shared_connection_response_envelope import V2CreateSharedConnectionResponseEnvelope -from .v_2_enricher_configuration import V2EnricherConfiguration -from .v_2_enricher_mapping import V2EnricherMapping -from .v_2_execution_log_type import V2ExecutionLogType -from .v_2_get_enrichment_input_fields_response_envelope import V2GetEnrichmentInputFieldsResponseEnvelope -from .v_2_ordered_map_string_github_com_invopop_jsonschema_schema import ( - V2OrderedMapStringGithubComInvopopJsonschemaSchema, -) -from .v_2_sample_record import V2SampleRecord -from .v_2_schema_configuration_fields_item import V2SchemaConfigurationFieldsItem -from .v_4_bulk_sync_execution_logs import V4BulkSyncExecutionLogs -from .v_4_bulk_sync_execution_logs_envelope import V4BulkSyncExecutionLogsEnvelope -from .v_4_bulk_sync_schedule_api import V4BulkSyncScheduleApi -from .v_4_export_sync_logs_envelope import V4ExportSyncLogsEnvelope -from .v_4_export_sync_logs_response import V4ExportSyncLogsResponse -from .v_4_global_error_subscribers_response import V4GlobalErrorSubscribersResponse -from .v_4_query_results_envelope import V4QueryResultsEnvelope -from .v_4_run_query_envelope import V4RunQueryEnvelope -from .v_4_run_query_result import V4RunQueryResult -from .v_4_target_creator import V4TargetCreator -from .v_4_target_objects_response_envelope import V4TargetObjectsResponseEnvelope -from .v_4_target_property_values import V4TargetPropertyValues -from .v_4_target_property_values_envelope import V4TargetPropertyValuesEnvelope -from .v_4_user_field_request import V4UserFieldRequest -from .webhook import Webhook -from .webhook_envelope import WebhookEnvelope -from .webhook_list_envelope import WebhookListEnvelope -from .work_task_status import WorkTaskStatus +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from .types_type import TypesType + from .activate_sync_envelope import ActivateSyncEnvelope + from .activate_sync_input import ActivateSyncInput + from .activate_sync_output import ActivateSyncOutput + from .api_error import ApiError + from .api_key_response import ApiKeyResponse + from .api_key_response_envelope import ApiKeyResponseEnvelope + from .backend_connection_capabilities import BackendConnectionCapabilities + from .backend_o_auth_prompt import BackendOAuthPrompt + from .bulk_bulk_sync_schedule import BulkBulkSyncSchedule + from .bulk_discover import BulkDiscover + from .bulk_execution_status import BulkExecutionStatus + from .bulk_fetch_mode import BulkFetchMode + from .bulk_field import BulkField + from .bulk_filter import BulkFilter + from .bulk_filter_2 import BulkFilter2 + from .bulk_itemized_schedule import BulkItemizedSchedule + from .bulk_multi_schedule_configuration import BulkMultiScheduleConfiguration + from .bulk_normalize_names import BulkNormalizeNames + from .bulk_schedule import BulkSchedule + from .bulk_schedule_sync_mode import BulkScheduleSyncMode + from .bulk_schema import BulkSchema + from .bulk_schema_envelope import BulkSchemaEnvelope + from .bulk_schema_execution_status import BulkSchemaExecutionStatus + from .bulk_selective_mode import BulkSelectiveMode + from .bulk_sync_canceled_event import BulkSyncCanceledEvent + from .bulk_sync_completed_event import BulkSyncCompletedEvent + from .bulk_sync_completed_with_error_event import BulkSyncCompletedWithErrorEvent + from .bulk_sync_dest import BulkSyncDest + from .bulk_sync_dest_envelope import BulkSyncDestEnvelope + from .bulk_sync_execution import BulkSyncExecution + from .bulk_sync_execution_envelope import BulkSyncExecutionEnvelope + from .bulk_sync_execution_status import BulkSyncExecutionStatus + from .bulk_sync_failed_event import BulkSyncFailedEvent + from .bulk_sync_ingestion_status import BulkSyncIngestionStatus + from .bulk_sync_list_envelope import BulkSyncListEnvelope + from .bulk_sync_mode import BulkSyncMode + from .bulk_sync_response import BulkSyncResponse + from .bulk_sync_response_envelope import BulkSyncResponseEnvelope + from .bulk_sync_running_event import BulkSyncRunningEvent + from .bulk_sync_schema_execution import BulkSyncSchemaExecution + from .bulk_sync_schema_execution_status import BulkSyncSchemaExecutionStatus + from .bulk_sync_source import BulkSyncSource + from .bulk_sync_source_envelope import BulkSyncSourceEnvelope + from .bulk_sync_source_schema_envelope import BulkSyncSourceSchemaEnvelope + from .bulk_sync_source_status import BulkSyncSourceStatus + from .bulk_sync_source_status_envelope import BulkSyncSourceStatusEnvelope + from .bulk_sync_status_envelope import BulkSyncStatusEnvelope + from .bulk_sync_status_response import BulkSyncStatusResponse + from .cancel_bulk_sync_response import CancelBulkSyncResponse + from .cancel_bulk_sync_response_envelope import CancelBulkSyncResponseEnvelope + from .cancel_model_sync_response import CancelModelSyncResponse + from .cancel_model_sync_response_envelope import CancelModelSyncResponseEnvelope + from .common_output_actor import CommonOutputActor + from .configuration_value import ConfigurationValue + from .configuration_value_2 import ConfigurationValue2 + from .connect_card_response import ConnectCardResponse + from .connect_card_response_envelope import ConnectCardResponseEnvelope + from .connection_list_response_envelope import ConnectionListResponseEnvelope + from .connection_meta import ConnectionMeta + from .connection_meta_response import ConnectionMetaResponse + from .connection_parameter_value import ConnectionParameterValue + from .connection_parameter_values_resp import ConnectionParameterValuesResp + from .connection_parameter_values_response_envelope import ConnectionParameterValuesResponseEnvelope + from .connection_response_envelope import ConnectionResponseEnvelope + from .connection_response_schema import ConnectionResponseSchema + from .connection_type import ConnectionType + from .connection_type_response_envelope import ConnectionTypeResponseEnvelope + from .connection_type_schema import ConnectionTypeSchema + from .create_connection_response_envelope import CreateConnectionResponseEnvelope + from .create_connection_response_schema import CreateConnectionResponseSchema + from .create_model_request import CreateModelRequest + from .create_shared_connection_response_schema import CreateSharedConnectionResponseSchema + from .enrichment import Enrichment + from .event import Event + from .event_body import EventBody + from .event_types_envelope import EventTypesEnvelope + from .events_envelope import EventsEnvelope + from .execution_counts import ExecutionCounts + from .execution_log_response import ExecutionLogResponse + from .execution_logs_response_envelope import ExecutionLogsResponseEnvelope + from .execution_status import ExecutionStatus + from .field_configuration import FieldConfiguration + from .filter import Filter + from .filter_field_reference_type import FilterFieldReferenceType + from .filter_function import FilterFunction + from .get_connection_meta_envelope import GetConnectionMetaEnvelope + from .get_execution_response_envelope import GetExecutionResponseEnvelope + from .get_execution_response_schema import GetExecutionResponseSchema + from .get_identity_response_envelope import GetIdentityResponseEnvelope + from .get_identity_response_schema import GetIdentityResponseSchema + from .get_model_sync_source_meta_envelope import GetModelSyncSourceMetaEnvelope + from .identity import Identity + from .identity_function import IdentityFunction + from .ingestion_status_level import IngestionStatusLevel + from .job_response import JobResponse + from .job_response_envelope import JobResponseEnvelope + from .jsonschema_definitions import JsonschemaDefinitions + from .jsonschema_form import JsonschemaForm + from .jsonschema_schema import JsonschemaSchema + from .label_label import LabelLabel + from .list_bulk_schema import ListBulkSchema + from .list_bulk_sync_execution_status_envelope import ListBulkSyncExecutionStatusEnvelope + from .list_bulk_sync_executions_envelope import ListBulkSyncExecutionsEnvelope + from .list_execution_response_envelope import ListExecutionResponseEnvelope + from .list_model_sync_response_envelope import ListModelSyncResponseEnvelope + from .list_policies_response_envelope import ListPoliciesResponseEnvelope + from .list_users_envelope import ListUsersEnvelope + from .mode import Mode + from .model_field import ModelField + from .model_field_response import ModelFieldResponse + from .model_list_response_envelope import ModelListResponseEnvelope + from .model_model_field_request import ModelModelFieldRequest + from .model_relation import ModelRelation + from .model_relation_to import ModelRelationTo + from .model_response import ModelResponse + from .model_response_envelope import ModelResponseEnvelope + from .model_sample import ModelSample + from .model_sample_response_envelope import ModelSampleResponseEnvelope + from .model_sync_field import ModelSyncField + from .model_sync_mode import ModelSyncMode + from .model_sync_response import ModelSyncResponse + from .model_sync_response_envelope import ModelSyncResponseEnvelope + from .model_sync_source_meta_response import ModelSyncSourceMetaResponse + from .organization import Organization + from .organization_envelope import OrganizationEnvelope + from .organizations_envelope import OrganizationsEnvelope + from .override import Override + from .pagination import Pagination + from .pagination_details import PaginationDetails + from .pagination_details_2 import PaginationDetails2 + from .pick_value import PickValue + from .policy_action import PolicyAction + from .policy_response import PolicyResponse + from .policy_response_envelope import PolicyResponseEnvelope + from .relation import Relation + from .relation_to import RelationTo + from .rest_err_response import RestErrResponse + from .role_list_response_envelope import RoleListResponseEnvelope + from .role_response import RoleResponse + from .role_response_envelope import RoleResponseEnvelope + from .run_after import RunAfter + from .schedule import Schedule + from .schedule_envelope import ScheduleEnvelope + from .schedule_frequency import ScheduleFrequency + from .schedule_option_response import ScheduleOptionResponse + from .schedule_option_response_envelope import ScheduleOptionResponseEnvelope + from .schedule_schedule_option import ScheduleScheduleOption + from .schedules_envelope import SchedulesEnvelope + from .schema import Schema + from .schema_association import SchemaAssociation + from .schema_configuration import SchemaConfiguration + from .schema_field import SchemaField + from .schema_identity_function import SchemaIdentityFunction + from .schema_primary_key_override_input import SchemaPrimaryKeyOverrideInput + from .schema_records_response_envelope import SchemaRecordsResponseEnvelope + from .source import Source + from .source_meta import SourceMeta + from .start_model_sync_response_envelope import StartModelSyncResponseEnvelope + from .start_model_sync_response_schema import StartModelSyncResponseSchema + from .supported_bulk_mode import SupportedBulkMode + from .supported_mode import SupportedMode + from .sync_canceled_event import SyncCanceledEvent + from .sync_completed_event import SyncCompletedEvent + from .sync_completed_with_errors_event import SyncCompletedWithErrorsEvent + from .sync_destination_properties import SyncDestinationProperties + from .sync_failed_event import SyncFailedEvent + from .sync_running_event import SyncRunningEvent + from .sync_status_envelope import SyncStatusEnvelope + from .sync_status_response import SyncStatusResponse + from .target import Target + from .target_create_input import TargetCreateInput + from .target_field import TargetField + from .target_object import TargetObject + from .target_response import TargetResponse + from .target_response_envelope import TargetResponseEnvelope + from .update_bulk_field import UpdateBulkField + from .user import User + from .user_envelope import UserEnvelope + from .util_enum_value import UtilEnumValue + from .util_field_type import UtilFieldType + from .v_2_connection_form import V2ConnectionForm + from .v_2_create_shared_connection_response_envelope import V2CreateSharedConnectionResponseEnvelope + from .v_2_enricher_configuration import V2EnricherConfiguration + from .v_2_enricher_mapping import V2EnricherMapping + from .v_2_execution_log_type import V2ExecutionLogType + from .v_2_get_enrichment_input_fields_response_envelope import V2GetEnrichmentInputFieldsResponseEnvelope + from .v_2_ordered_map_string_github_com_invopop_jsonschema_schema import ( + V2OrderedMapStringGithubComInvopopJsonschemaSchema, + ) + from .v_2_sample_record import V2SampleRecord + from .v_2_schema_configuration_fields_item import V2SchemaConfigurationFieldsItem + from .v_4_bulk_sync_execution_logs import V4BulkSyncExecutionLogs + from .v_4_bulk_sync_execution_logs_envelope import V4BulkSyncExecutionLogsEnvelope + from .v_4_bulk_sync_schedule_api import V4BulkSyncScheduleApi + from .v_4_export_sync_logs_envelope import V4ExportSyncLogsEnvelope + from .v_4_export_sync_logs_response import V4ExportSyncLogsResponse + from .v_4_global_error_subscribers_response import V4GlobalErrorSubscribersResponse + from .v_4_query_results_envelope import V4QueryResultsEnvelope + from .v_4_run_query_envelope import V4RunQueryEnvelope + from .v_4_run_query_result import V4RunQueryResult + from .v_4_target_creator import V4TargetCreator + from .v_4_target_objects_response_envelope import V4TargetObjectsResponseEnvelope + from .v_4_target_property_values import V4TargetPropertyValues + from .v_4_target_property_values_envelope import V4TargetPropertyValuesEnvelope + from .v_4_user_field_request import V4UserFieldRequest + from .webhook import Webhook + from .webhook_envelope import WebhookEnvelope + from .webhook_list_envelope import WebhookListEnvelope + from .work_task_status import WorkTaskStatus +_dynamic_imports: typing.Dict[str, str] = { + "ActivateSyncEnvelope": ".activate_sync_envelope", + "ActivateSyncInput": ".activate_sync_input", + "ActivateSyncOutput": ".activate_sync_output", + "ApiError": ".api_error", + "ApiKeyResponse": ".api_key_response", + "ApiKeyResponseEnvelope": ".api_key_response_envelope", + "BackendConnectionCapabilities": ".backend_connection_capabilities", + "BackendOAuthPrompt": ".backend_o_auth_prompt", + "BulkBulkSyncSchedule": ".bulk_bulk_sync_schedule", + "BulkDiscover": ".bulk_discover", + "BulkExecutionStatus": ".bulk_execution_status", + "BulkFetchMode": ".bulk_fetch_mode", + "BulkField": ".bulk_field", + "BulkFilter": ".bulk_filter", + "BulkFilter2": ".bulk_filter_2", + "BulkItemizedSchedule": ".bulk_itemized_schedule", + "BulkMultiScheduleConfiguration": ".bulk_multi_schedule_configuration", + "BulkNormalizeNames": ".bulk_normalize_names", + "BulkSchedule": ".bulk_schedule", + "BulkScheduleSyncMode": ".bulk_schedule_sync_mode", + "BulkSchema": ".bulk_schema", + "BulkSchemaEnvelope": ".bulk_schema_envelope", + "BulkSchemaExecutionStatus": ".bulk_schema_execution_status", + "BulkSelectiveMode": ".bulk_selective_mode", + "BulkSyncCanceledEvent": ".bulk_sync_canceled_event", + "BulkSyncCompletedEvent": ".bulk_sync_completed_event", + "BulkSyncCompletedWithErrorEvent": ".bulk_sync_completed_with_error_event", + "BulkSyncDest": ".bulk_sync_dest", + "BulkSyncDestEnvelope": ".bulk_sync_dest_envelope", + "BulkSyncExecution": ".bulk_sync_execution", + "BulkSyncExecutionEnvelope": ".bulk_sync_execution_envelope", + "BulkSyncExecutionStatus": ".bulk_sync_execution_status", + "BulkSyncFailedEvent": ".bulk_sync_failed_event", + "BulkSyncIngestionStatus": ".bulk_sync_ingestion_status", + "BulkSyncListEnvelope": ".bulk_sync_list_envelope", + "BulkSyncMode": ".bulk_sync_mode", + "BulkSyncResponse": ".bulk_sync_response", + "BulkSyncResponseEnvelope": ".bulk_sync_response_envelope", + "BulkSyncRunningEvent": ".bulk_sync_running_event", + "BulkSyncSchemaExecution": ".bulk_sync_schema_execution", + "BulkSyncSchemaExecutionStatus": ".bulk_sync_schema_execution_status", + "BulkSyncSource": ".bulk_sync_source", + "BulkSyncSourceEnvelope": ".bulk_sync_source_envelope", + "BulkSyncSourceSchemaEnvelope": ".bulk_sync_source_schema_envelope", + "BulkSyncSourceStatus": ".bulk_sync_source_status", + "BulkSyncSourceStatusEnvelope": ".bulk_sync_source_status_envelope", + "BulkSyncStatusEnvelope": ".bulk_sync_status_envelope", + "BulkSyncStatusResponse": ".bulk_sync_status_response", + "CancelBulkSyncResponse": ".cancel_bulk_sync_response", + "CancelBulkSyncResponseEnvelope": ".cancel_bulk_sync_response_envelope", + "CancelModelSyncResponse": ".cancel_model_sync_response", + "CancelModelSyncResponseEnvelope": ".cancel_model_sync_response_envelope", + "CommonOutputActor": ".common_output_actor", + "ConfigurationValue": ".configuration_value", + "ConfigurationValue2": ".configuration_value_2", + "ConnectCardResponse": ".connect_card_response", + "ConnectCardResponseEnvelope": ".connect_card_response_envelope", + "ConnectionListResponseEnvelope": ".connection_list_response_envelope", + "ConnectionMeta": ".connection_meta", + "ConnectionMetaResponse": ".connection_meta_response", + "ConnectionParameterValue": ".connection_parameter_value", + "ConnectionParameterValuesResp": ".connection_parameter_values_resp", + "ConnectionParameterValuesResponseEnvelope": ".connection_parameter_values_response_envelope", + "ConnectionResponseEnvelope": ".connection_response_envelope", + "ConnectionResponseSchema": ".connection_response_schema", + "ConnectionType": ".connection_type", + "ConnectionTypeResponseEnvelope": ".connection_type_response_envelope", + "ConnectionTypeSchema": ".connection_type_schema", + "CreateConnectionResponseEnvelope": ".create_connection_response_envelope", + "CreateConnectionResponseSchema": ".create_connection_response_schema", + "CreateModelRequest": ".create_model_request", + "CreateSharedConnectionResponseSchema": ".create_shared_connection_response_schema", + "Enrichment": ".enrichment", + "Event": ".event", + "EventBody": ".event_body", + "EventTypesEnvelope": ".event_types_envelope", + "EventsEnvelope": ".events_envelope", + "ExecutionCounts": ".execution_counts", + "ExecutionLogResponse": ".execution_log_response", + "ExecutionLogsResponseEnvelope": ".execution_logs_response_envelope", + "ExecutionStatus": ".execution_status", + "FieldConfiguration": ".field_configuration", + "Filter": ".filter", + "FilterFieldReferenceType": ".filter_field_reference_type", + "FilterFunction": ".filter_function", + "GetConnectionMetaEnvelope": ".get_connection_meta_envelope", + "GetExecutionResponseEnvelope": ".get_execution_response_envelope", + "GetExecutionResponseSchema": ".get_execution_response_schema", + "GetIdentityResponseEnvelope": ".get_identity_response_envelope", + "GetIdentityResponseSchema": ".get_identity_response_schema", + "GetModelSyncSourceMetaEnvelope": ".get_model_sync_source_meta_envelope", + "Identity": ".identity", + "IdentityFunction": ".identity_function", + "IngestionStatusLevel": ".ingestion_status_level", + "JobResponse": ".job_response", + "JobResponseEnvelope": ".job_response_envelope", + "JsonschemaDefinitions": ".jsonschema_definitions", + "JsonschemaForm": ".jsonschema_form", + "JsonschemaSchema": ".jsonschema_schema", + "LabelLabel": ".label_label", + "ListBulkSchema": ".list_bulk_schema", + "ListBulkSyncExecutionStatusEnvelope": ".list_bulk_sync_execution_status_envelope", + "ListBulkSyncExecutionsEnvelope": ".list_bulk_sync_executions_envelope", + "ListExecutionResponseEnvelope": ".list_execution_response_envelope", + "ListModelSyncResponseEnvelope": ".list_model_sync_response_envelope", + "ListPoliciesResponseEnvelope": ".list_policies_response_envelope", + "ListUsersEnvelope": ".list_users_envelope", + "Mode": ".mode", + "ModelField": ".model_field", + "ModelFieldResponse": ".model_field_response", + "ModelListResponseEnvelope": ".model_list_response_envelope", + "ModelModelFieldRequest": ".model_model_field_request", + "ModelRelation": ".model_relation", + "ModelRelationTo": ".model_relation_to", + "ModelResponse": ".model_response", + "ModelResponseEnvelope": ".model_response_envelope", + "ModelSample": ".model_sample", + "ModelSampleResponseEnvelope": ".model_sample_response_envelope", + "ModelSyncField": ".model_sync_field", + "ModelSyncMode": ".model_sync_mode", + "ModelSyncResponse": ".model_sync_response", + "ModelSyncResponseEnvelope": ".model_sync_response_envelope", + "ModelSyncSourceMetaResponse": ".model_sync_source_meta_response", + "Organization": ".organization", + "OrganizationEnvelope": ".organization_envelope", + "OrganizationsEnvelope": ".organizations_envelope", + "Override": ".override", + "Pagination": ".pagination", + "PaginationDetails": ".pagination_details", + "PaginationDetails2": ".pagination_details_2", + "PickValue": ".pick_value", + "PolicyAction": ".policy_action", + "PolicyResponse": ".policy_response", + "PolicyResponseEnvelope": ".policy_response_envelope", + "Relation": ".relation", + "RelationTo": ".relation_to", + "RestErrResponse": ".rest_err_response", + "RoleListResponseEnvelope": ".role_list_response_envelope", + "RoleResponse": ".role_response", + "RoleResponseEnvelope": ".role_response_envelope", + "RunAfter": ".run_after", + "Schedule": ".schedule", + "ScheduleEnvelope": ".schedule_envelope", + "ScheduleFrequency": ".schedule_frequency", + "ScheduleOptionResponse": ".schedule_option_response", + "ScheduleOptionResponseEnvelope": ".schedule_option_response_envelope", + "ScheduleScheduleOption": ".schedule_schedule_option", + "SchedulesEnvelope": ".schedules_envelope", + "Schema": ".schema", + "SchemaAssociation": ".schema_association", + "SchemaConfiguration": ".schema_configuration", + "SchemaField": ".schema_field", + "SchemaIdentityFunction": ".schema_identity_function", + "SchemaPrimaryKeyOverrideInput": ".schema_primary_key_override_input", + "SchemaRecordsResponseEnvelope": ".schema_records_response_envelope", + "Source": ".source", + "SourceMeta": ".source_meta", + "StartModelSyncResponseEnvelope": ".start_model_sync_response_envelope", + "StartModelSyncResponseSchema": ".start_model_sync_response_schema", + "SupportedBulkMode": ".supported_bulk_mode", + "SupportedMode": ".supported_mode", + "SyncCanceledEvent": ".sync_canceled_event", + "SyncCompletedEvent": ".sync_completed_event", + "SyncCompletedWithErrorsEvent": ".sync_completed_with_errors_event", + "SyncDestinationProperties": ".sync_destination_properties", + "SyncFailedEvent": ".sync_failed_event", + "SyncRunningEvent": ".sync_running_event", + "SyncStatusEnvelope": ".sync_status_envelope", + "SyncStatusResponse": ".sync_status_response", + "Target": ".target", + "TargetCreateInput": ".target_create_input", + "TargetField": ".target_field", + "TargetObject": ".target_object", + "TargetResponse": ".target_response", + "TargetResponseEnvelope": ".target_response_envelope", + "TypesType": ".types_type", + "UpdateBulkField": ".update_bulk_field", + "User": ".user", + "UserEnvelope": ".user_envelope", + "UtilEnumValue": ".util_enum_value", + "UtilFieldType": ".util_field_type", + "V2ConnectionForm": ".v_2_connection_form", + "V2CreateSharedConnectionResponseEnvelope": ".v_2_create_shared_connection_response_envelope", + "V2EnricherConfiguration": ".v_2_enricher_configuration", + "V2EnricherMapping": ".v_2_enricher_mapping", + "V2ExecutionLogType": ".v_2_execution_log_type", + "V2GetEnrichmentInputFieldsResponseEnvelope": ".v_2_get_enrichment_input_fields_response_envelope", + "V2OrderedMapStringGithubComInvopopJsonschemaSchema": ".v_2_ordered_map_string_github_com_invopop_jsonschema_schema", + "V2SampleRecord": ".v_2_sample_record", + "V2SchemaConfigurationFieldsItem": ".v_2_schema_configuration_fields_item", + "V4BulkSyncExecutionLogs": ".v_4_bulk_sync_execution_logs", + "V4BulkSyncExecutionLogsEnvelope": ".v_4_bulk_sync_execution_logs_envelope", + "V4BulkSyncScheduleApi": ".v_4_bulk_sync_schedule_api", + "V4ExportSyncLogsEnvelope": ".v_4_export_sync_logs_envelope", + "V4ExportSyncLogsResponse": ".v_4_export_sync_logs_response", + "V4GlobalErrorSubscribersResponse": ".v_4_global_error_subscribers_response", + "V4QueryResultsEnvelope": ".v_4_query_results_envelope", + "V4RunQueryEnvelope": ".v_4_run_query_envelope", + "V4RunQueryResult": ".v_4_run_query_result", + "V4TargetCreator": ".v_4_target_creator", + "V4TargetObjectsResponseEnvelope": ".v_4_target_objects_response_envelope", + "V4TargetPropertyValues": ".v_4_target_property_values", + "V4TargetPropertyValuesEnvelope": ".v_4_target_property_values_envelope", + "V4UserFieldRequest": ".v_4_user_field_request", + "Webhook": ".webhook", + "WebhookEnvelope": ".webhook_envelope", + "WebhookListEnvelope": ".webhook_list_envelope", + "WorkTaskStatus": ".work_task_status", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e + except AttributeError as e: + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + __all__ = [ "ActivateSyncEnvelope", @@ -221,6 +464,7 @@ "BulkFetchMode", "BulkField", "BulkFilter", + "BulkFilter2", "BulkItemizedSchedule", "BulkMultiScheduleConfiguration", "BulkNormalizeNames", @@ -239,6 +483,7 @@ "BulkSyncExecutionEnvelope", "BulkSyncExecutionStatus", "BulkSyncFailedEvent", + "BulkSyncIngestionStatus", "BulkSyncListEnvelope", "BulkSyncMode", "BulkSyncResponse", @@ -259,6 +504,7 @@ "CancelModelSyncResponseEnvelope", "CommonOutputActor", "ConfigurationValue", + "ConfigurationValue2", "ConnectCardResponse", "ConnectCardResponseEnvelope", "ConnectionListResponseEnvelope", @@ -297,6 +543,7 @@ "GetModelSyncSourceMetaEnvelope", "Identity", "IdentityFunction", + "IngestionStatusLevel", "JobResponse", "JobResponseEnvelope", "JsonschemaDefinitions", @@ -332,6 +579,7 @@ "Override", "Pagination", "PaginationDetails", + "PaginationDetails2", "PickValue", "PolicyAction", "PolicyResponse", diff --git a/src/polytomic/types/activate_sync_envelope.py b/src/polytomic/types/activate_sync_envelope.py index 3c5646c..dec741b 100644 --- a/src/polytomic/types/activate_sync_envelope.py +++ b/src/polytomic/types/activate_sync_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .activate_sync_output import ActivateSyncOutput -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .activate_sync_output import ActivateSyncOutput class ActivateSyncEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/activate_sync_input.py b/src/polytomic/types/activate_sync_input.py index 3508640..f409847 100644 --- a/src/polytomic/types/activate_sync_input.py +++ b/src/polytomic/types/activate_sync_input.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class ActivateSyncInput(UniversalBaseModel): diff --git a/src/polytomic/types/activate_sync_output.py b/src/polytomic/types/activate_sync_output.py index bceaf9d..ca1353b 100644 --- a/src/polytomic/types/activate_sync_output.py +++ b/src/polytomic/types/activate_sync_output.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class ActivateSyncOutput(UniversalBaseModel): diff --git a/src/polytomic/types/api_error.py b/src/polytomic/types/api_error.py index 0767356..047f631 100644 --- a/src/polytomic/types/api_error.py +++ b/src/polytomic/types/api_error.py @@ -1,15 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class ApiError(UniversalBaseModel): key: typing.Optional[str] = None message: typing.Optional[str] = None - metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None + metadata: typing.Optional[typing.Dict[str, typing.Any]] = None status: typing.Optional[int] = None if IS_PYDANTIC_V2: diff --git a/src/polytomic/types/api_key_response.py b/src/polytomic/types/api_key_response.py index a8c634e..f551d3c 100644 --- a/src/polytomic/types/api_key_response.py +++ b/src/polytomic/types/api_key_response.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class ApiKeyResponse(UniversalBaseModel): diff --git a/src/polytomic/types/api_key_response_envelope.py b/src/polytomic/types/api_key_response_envelope.py index e4c0d18..eebc167 100644 --- a/src/polytomic/types/api_key_response_envelope.py +++ b/src/polytomic/types/api_key_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .api_key_response import ApiKeyResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .api_key_response import ApiKeyResponse class ApiKeyResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/backend_connection_capabilities.py b/src/polytomic/types/backend_connection_capabilities.py index 0f1e8c3..5a01950 100644 --- a/src/polytomic/types/backend_connection_capabilities.py +++ b/src/polytomic/types/backend_connection_capabilities.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class BackendConnectionCapabilities(UniversalBaseModel): diff --git a/src/polytomic/types/backend_o_auth_prompt.py b/src/polytomic/types/backend_o_auth_prompt.py index 67e0d64..a5b6b84 100644 --- a/src/polytomic/types/backend_o_auth_prompt.py +++ b/src/polytomic/types/backend_o_auth_prompt.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class BackendOAuthPrompt(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_bulk_sync_schedule.py b/src/polytomic/types/bulk_bulk_sync_schedule.py index 1d7b5af..f671d35 100644 --- a/src/polytomic/types/bulk_bulk_sync_schedule.py +++ b/src/polytomic/types/bulk_bulk_sync_schedule.py @@ -1,38 +1,56 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing_extensions -import typing import datetime as dt +import typing + +import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from ..core.serialization import FieldMetadata -from .schedule_frequency import ScheduleFrequency -from .bulk_selective_mode import BulkSelectiveMode from .bulk_schedule_sync_mode import BulkScheduleSyncMode -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic +from .bulk_selective_mode import BulkSelectiveMode +from .schedule_frequency import ScheduleFrequency class BulkBulkSyncSchedule(UniversalBaseModel): - created_at: typing_extensions.Annotated[typing.Optional[dt.datetime], FieldMetadata(alias="createdAt")] = None - created_by: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="createdBy")] = None - day_of_month: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="dayOfMonth")] = None - day_of_week: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="dayOfWeek")] = None - deleted_at: typing_extensions.Annotated[typing.Optional[dt.datetime], FieldMetadata(alias="deletedAt")] = None - deleted_by: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="deletedBy")] = None + created_at: typing_extensions.Annotated[ + typing.Optional[dt.datetime], FieldMetadata(alias="createdAt"), pydantic.Field(alias="createdAt") + ] = None + created_by: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="createdBy"), pydantic.Field(alias="createdBy") + ] = None + day_of_month: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="dayOfMonth"), pydantic.Field(alias="dayOfMonth") + ] = None + day_of_week: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="dayOfWeek"), pydantic.Field(alias="dayOfWeek") + ] = None + deleted_at: typing_extensions.Annotated[ + typing.Optional[dt.datetime], FieldMetadata(alias="deletedAt"), pydantic.Field(alias="deletedAt") + ] = None + deleted_by: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="deletedBy"), pydantic.Field(alias="deletedBy") + ] = None frequency: ScheduleFrequency hour: typing.Optional[str] = None minute: typing.Optional[str] = None month: typing.Optional[str] = None schemas: typing.Optional[typing.List[str]] = None selective_mode: typing_extensions.Annotated[ - typing.Optional[BulkSelectiveMode], FieldMetadata(alias="selectiveMode") - ] = None - sync_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="syncId")] = None - sync_mode: typing_extensions.Annotated[typing.Optional[BulkScheduleSyncMode], FieldMetadata(alias="syncMode")] = ( - None - ) - updated_at: typing_extensions.Annotated[typing.Optional[dt.datetime], FieldMetadata(alias="updatedAt")] = None - updated_by: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="updatedBy")] = None + typing.Optional[BulkSelectiveMode], FieldMetadata(alias="selectiveMode"), pydantic.Field(alias="selectiveMode") + ] = None + sync_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="syncId"), pydantic.Field(alias="syncId") + ] = None + sync_mode: typing_extensions.Annotated[ + typing.Optional[BulkScheduleSyncMode], FieldMetadata(alias="syncMode"), pydantic.Field(alias="syncMode") + ] = None + updated_at: typing_extensions.Annotated[ + typing.Optional[dt.datetime], FieldMetadata(alias="updatedAt"), pydantic.Field(alias="updatedAt") + ] = None + updated_by: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="updatedBy"), pydantic.Field(alias="updatedBy") + ] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/polytomic/types/bulk_field.py b/src/polytomic/types/bulk_field.py index 5648ab6..47319fc 100644 --- a/src/polytomic/types/bulk_field.py +++ b/src/polytomic/types/bulk_field.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class BulkField(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_filter.py b/src/polytomic/types/bulk_filter.py index 7651644..ebd4502 100644 --- a/src/polytomic/types/bulk_filter.py +++ b/src/polytomic/types/bulk_filter.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .filter_function import FilterFunction -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class BulkFilter(UniversalBaseModel): @@ -14,7 +14,7 @@ class BulkFilter(UniversalBaseModel): """ function: FilterFunction - value: typing.Optional[typing.Optional[typing.Any]] = None + value: typing.Optional[typing.Any] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/polytomic/types/bulk_filter_2.py b/src/polytomic/types/bulk_filter_2.py new file mode 100644 index 0000000..9bc37be --- /dev/null +++ b/src/polytomic/types/bulk_filter_2.py @@ -0,0 +1,26 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .filter_function import FilterFunction + + +class BulkFilter2(UniversalBaseModel): + field_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Schema field ID to filter on. + """ + + function: FilterFunction + value: typing.Optional[typing.Any] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/polytomic/types/bulk_itemized_schedule.py b/src/polytomic/types/bulk_itemized_schedule.py index 7454bec..e0e6181 100644 --- a/src/polytomic/types/bulk_itemized_schedule.py +++ b/src/polytomic/types/bulk_itemized_schedule.py @@ -1,12 +1,12 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.pydantic_utilities import UniversalBaseModel -from .bulk_selective_mode import BulkSelectiveMode -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import typing + import pydantic -from ..core.pydantic_utilities import update_forward_refs +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel, update_forward_refs +from .bulk_selective_mode import BulkSelectiveMode class BulkItemizedSchedule(UniversalBaseModel): @@ -23,7 +23,9 @@ class Config: extra = pydantic.Extra.allow -from .bulk_multi_schedule_configuration import BulkMultiScheduleConfiguration # noqa: E402 -from .bulk_schedule import BulkSchedule # noqa: E402 +from .bulk_multi_schedule_configuration import BulkMultiScheduleConfiguration # noqa: E402, I001 +from .bulk_schedule import BulkSchedule # noqa: E402, I001 -update_forward_refs(BulkItemizedSchedule) +update_forward_refs( + BulkItemizedSchedule, BulkMultiScheduleConfiguration=BulkMultiScheduleConfiguration, BulkSchedule=BulkSchedule +) diff --git a/src/polytomic/types/bulk_multi_schedule_configuration.py b/src/polytomic/types/bulk_multi_schedule_configuration.py index 7ec091b..bf5542c 100644 --- a/src/polytomic/types/bulk_multi_schedule_configuration.py +++ b/src/polytomic/types/bulk_multi_schedule_configuration.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.pydantic_utilities import UniversalBaseModel + import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic -from ..core.pydantic_utilities import update_forward_refs +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel, update_forward_refs class BulkMultiScheduleConfiguration(UniversalBaseModel): @@ -22,7 +22,9 @@ class Config: extra = pydantic.Extra.allow -from .bulk_itemized_schedule import BulkItemizedSchedule # noqa: E402 -from .bulk_schedule import BulkSchedule # noqa: E402 +from .bulk_itemized_schedule import BulkItemizedSchedule # noqa: E402, I001 +from .bulk_schedule import BulkSchedule # noqa: E402, I001 -update_forward_refs(BulkMultiScheduleConfiguration) +update_forward_refs( + BulkMultiScheduleConfiguration, BulkItemizedSchedule=BulkItemizedSchedule, BulkSchedule=BulkSchedule +) diff --git a/src/polytomic/types/bulk_schedule.py b/src/polytomic/types/bulk_schedule.py index 19dee15..a73d105 100644 --- a/src/polytomic/types/bulk_schedule.py +++ b/src/polytomic/types/bulk_schedule.py @@ -1,12 +1,12 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.pydantic_utilities import UniversalBaseModel + import typing -from .schedule_frequency import ScheduleFrequency -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic -from ..core.pydantic_utilities import update_forward_refs +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel, update_forward_refs +from .schedule_frequency import ScheduleFrequency class BulkSchedule(UniversalBaseModel): @@ -28,7 +28,11 @@ class Config: extra = pydantic.Extra.allow -from .bulk_itemized_schedule import BulkItemizedSchedule # noqa: E402 -from .bulk_multi_schedule_configuration import BulkMultiScheduleConfiguration # noqa: E402 +from .bulk_itemized_schedule import BulkItemizedSchedule # noqa: E402, I001 +from .bulk_multi_schedule_configuration import BulkMultiScheduleConfiguration # noqa: E402, I001 -update_forward_refs(BulkSchedule) +update_forward_refs( + BulkSchedule, + BulkItemizedSchedule=BulkItemizedSchedule, + BulkMultiScheduleConfiguration=BulkMultiScheduleConfiguration, +) diff --git a/src/polytomic/types/bulk_schema.py b/src/polytomic/types/bulk_schema.py index 22ce3f7..d01e953 100644 --- a/src/polytomic/types/bulk_schema.py +++ b/src/polytomic/types/bulk_schema.py @@ -1,20 +1,28 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing import datetime as dt -from .bulk_field import BulkField -from .bulk_filter import BulkFilter -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_field import BulkField +from .bulk_filter_2 import BulkFilter2 class BulkSchema(UniversalBaseModel): data_cutoff_timestamp: typing.Optional[dt.datetime] = None disable_data_cutoff: typing.Optional[bool] = None enabled: typing.Optional[bool] = None - fields: typing.Optional[typing.List[BulkField]] = None - filters: typing.Optional[typing.List[BulkFilter]] = None + fields: typing.Optional[typing.List[BulkField]] = pydantic.Field(default=None) + """ + fields is not populated on the list endpoint and will be removed in a future version; retrieve individual schemas for fields. + """ + + filters: typing.Optional[typing.List[BulkFilter2]] = pydantic.Field(default=None) + """ + filters is not populated on the list endpoint and will be removed in a future version; retrieve individual schemas for filters. + """ + id: typing.Optional[str] = None output_name: typing.Optional[str] = None partition_key: typing.Optional[str] = None diff --git a/src/polytomic/types/bulk_schema_envelope.py b/src/polytomic/types/bulk_schema_envelope.py index 7c42446..2aa0b4a 100644 --- a/src/polytomic/types/bulk_schema_envelope.py +++ b/src/polytomic/types/bulk_schema_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .bulk_schema import BulkSchema -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_schema import BulkSchema class BulkSchemaEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_schema_execution_status.py b/src/polytomic/types/bulk_schema_execution_status.py index 7e4a084..06153f9 100644 --- a/src/polytomic/types/bulk_schema_execution_status.py +++ b/src/polytomic/types/bulk_schema_execution_status.py @@ -3,6 +3,8 @@ import typing BulkSchemaExecutionStatus = typing.Union[ - typing.Literal["created", "scheduled", "running", "exporting", "canceled", "completed", "failed", "interrupted"], + typing.Literal[ + "created", "scheduled", "running", "exporting", "canceled", "completed", "failed", "interrupted", "processing" + ], typing.Any, ] diff --git a/src/polytomic/types/bulk_sync_canceled_event.py b/src/polytomic/types/bulk_sync_canceled_event.py index e6e4e69..2a2ebb2 100644 --- a/src/polytomic/types/bulk_sync_canceled_event.py +++ b/src/polytomic/types/bulk_sync_canceled_event.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class BulkSyncCanceledEvent(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_sync_completed_event.py b/src/polytomic/types/bulk_sync_completed_event.py index 904f8df..9b0b643 100644 --- a/src/polytomic/types/bulk_sync_completed_event.py +++ b/src/polytomic/types/bulk_sync_completed_event.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class BulkSyncCompletedEvent(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_sync_completed_with_error_event.py b/src/polytomic/types/bulk_sync_completed_with_error_event.py index 7b892a4..dc59180 100644 --- a/src/polytomic/types/bulk_sync_completed_with_error_event.py +++ b/src/polytomic/types/bulk_sync_completed_with_error_event.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class BulkSyncCompletedWithErrorEvent(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_sync_dest.py b/src/polytomic/types/bulk_sync_dest.py index 2a9540e..c9c8957 100644 --- a/src/polytomic/types/bulk_sync_dest.py +++ b/src/polytomic/types/bulk_sync_dest.py @@ -1,14 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .supported_bulk_mode import SupportedBulkMode -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .supported_bulk_mode import SupportedBulkMode class BulkSyncDest(UniversalBaseModel): - configuration: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None + configuration: typing.Optional[typing.Dict[str, typing.Any]] = None modes: typing.Optional[typing.List[SupportedBulkMode]] = None if IS_PYDANTIC_V2: diff --git a/src/polytomic/types/bulk_sync_dest_envelope.py b/src/polytomic/types/bulk_sync_dest_envelope.py index 1c193f4..3b23a9e 100644 --- a/src/polytomic/types/bulk_sync_dest_envelope.py +++ b/src/polytomic/types/bulk_sync_dest_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .bulk_sync_dest import BulkSyncDest -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_sync_dest import BulkSyncDest class BulkSyncDestEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_sync_execution.py b/src/polytomic/types/bulk_sync_execution.py index 40e2a4b..d2483a2 100644 --- a/src/polytomic/types/bulk_sync_execution.py +++ b/src/polytomic/types/bulk_sync_execution.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing import datetime as dt +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_execution_status import BulkExecutionStatus from .bulk_fetch_mode import BulkFetchMode from .bulk_sync_schema_execution import BulkSyncSchemaExecution -from .bulk_execution_status import BulkExecutionStatus -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class BulkSyncExecution(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_sync_execution_envelope.py b/src/polytomic/types/bulk_sync_execution_envelope.py index 65464e0..17bbe01 100644 --- a/src/polytomic/types/bulk_sync_execution_envelope.py +++ b/src/polytomic/types/bulk_sync_execution_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .bulk_sync_execution import BulkSyncExecution -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_sync_execution import BulkSyncExecution class BulkSyncExecutionEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_sync_execution_status.py b/src/polytomic/types/bulk_sync_execution_status.py index 08b1d4c..2f881de 100644 --- a/src/polytomic/types/bulk_sync_execution_status.py +++ b/src/polytomic/types/bulk_sync_execution_status.py @@ -1,19 +1,21 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing_extensions -import typing import datetime as dt +import typing + +import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from ..core.serialization import FieldMetadata -from .bulk_sync_schema_execution_status import BulkSyncSchemaExecutionStatus from .bulk_execution_status import BulkExecutionStatus -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic +from .bulk_sync_schema_execution_status import BulkSyncSchemaExecutionStatus class BulkSyncExecutionStatus(UniversalBaseModel): next_execution_time: typing_extensions.Annotated[ - typing.Optional[dt.datetime], FieldMetadata(alias="nextExecutionTime") + typing.Optional[dt.datetime], + FieldMetadata(alias="nextExecutionTime"), + pydantic.Field(alias="nextExecutionTime"), ] = None schemas: typing.Optional[typing.List[BulkSyncSchemaExecutionStatus]] = None status: typing.Optional[BulkExecutionStatus] = None diff --git a/src/polytomic/types/bulk_sync_failed_event.py b/src/polytomic/types/bulk_sync_failed_event.py index ae66b76..3b8988b 100644 --- a/src/polytomic/types/bulk_sync_failed_event.py +++ b/src/polytomic/types/bulk_sync_failed_event.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class BulkSyncFailedEvent(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_sync_ingestion_status.py b/src/polytomic/types/bulk_sync_ingestion_status.py new file mode 100644 index 0000000..41a2adf --- /dev/null +++ b/src/polytomic/types/bulk_sync_ingestion_status.py @@ -0,0 +1,28 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .ingestion_status_level import IngestionStatusLevel + + +class BulkSyncIngestionStatus(UniversalBaseModel): + enabled: typing.Optional[bool] = None + highwater_mark: typing.Optional[str] = None + is_running: typing.Optional[bool] = None + position: typing.Optional[str] = None + position_time: typing.Optional[dt.datetime] = None + status: typing.Optional[IngestionStatusLevel] = None + status_message: typing.Optional[str] = None + updated_at: typing.Optional[dt.datetime] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/polytomic/types/bulk_sync_list_envelope.py b/src/polytomic/types/bulk_sync_list_envelope.py index 4fb285b..526373c 100644 --- a/src/polytomic/types/bulk_sync_list_envelope.py +++ b/src/polytomic/types/bulk_sync_list_envelope.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -from .bulk_itemized_schedule import BulkItemizedSchedule -from .bulk_multi_schedule_configuration import BulkMultiScheduleConfiguration -from .bulk_schedule import BulkSchedule +from __future__ import annotations + import typing -from .bulk_sync_response import BulkSyncResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel, update_forward_refs +from .bulk_sync_response import BulkSyncResponse class BulkSyncListEnvelope(UniversalBaseModel): @@ -21,3 +20,6 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +update_forward_refs(BulkSyncListEnvelope) diff --git a/src/polytomic/types/bulk_sync_response.py b/src/polytomic/types/bulk_sync_response.py index 1331e4e..01a310a 100644 --- a/src/polytomic/types/bulk_sync_response.py +++ b/src/polytomic/types/bulk_sync_response.py @@ -1,17 +1,16 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -from .bulk_itemized_schedule import BulkItemizedSchedule -from .bulk_multi_schedule_configuration import BulkMultiScheduleConfiguration -from .bulk_schedule import BulkSchedule +from __future__ import annotations + +import datetime as dt import typing -from .bulk_discover import BulkDiscover + import pydantic -import datetime as dt -from .common_output_actor import CommonOutputActor -from .bulk_sync_mode import BulkSyncMode +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel, update_forward_refs +from .bulk_discover import BulkDiscover from .bulk_normalize_names import BulkNormalizeNames -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .bulk_sync_mode import BulkSyncMode +from .common_output_actor import CommonOutputActor class BulkSyncResponse(UniversalBaseModel): @@ -26,9 +25,7 @@ class BulkSyncResponse(UniversalBaseModel): created_at: typing.Optional[dt.datetime] = None created_by: typing.Optional[CommonOutputActor] = None data_cutoff_timestamp: typing.Optional[dt.datetime] = None - destination_configuration: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field( - default=None - ) + destination_configuration: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None) """ Destination-specific bulk sync configuration. e.g. output schema name, s3 file format, etc. """ @@ -59,8 +56,8 @@ class BulkSyncResponse(UniversalBaseModel): Per-sync resync concurrency limit override. """ - schedule: typing.Optional[BulkSchedule] = None - source_configuration: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) + schedule: typing.Optional["BulkSchedule"] = None + source_configuration: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None) """ Source-specific bulk sync configuration. e.g. replication slot name, sync lookback, etc. """ @@ -77,3 +74,15 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +from .bulk_itemized_schedule import BulkItemizedSchedule # noqa: E402, I001 +from .bulk_multi_schedule_configuration import BulkMultiScheduleConfiguration # noqa: E402, I001 +from .bulk_schedule import BulkSchedule # noqa: E402, I001 + +update_forward_refs( + BulkSyncResponse, + BulkItemizedSchedule=BulkItemizedSchedule, + BulkMultiScheduleConfiguration=BulkMultiScheduleConfiguration, + BulkSchedule=BulkSchedule, +) diff --git a/src/polytomic/types/bulk_sync_response_envelope.py b/src/polytomic/types/bulk_sync_response_envelope.py index 5a9db4c..d9b4139 100644 --- a/src/polytomic/types/bulk_sync_response_envelope.py +++ b/src/polytomic/types/bulk_sync_response_envelope.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -from .bulk_itemized_schedule import BulkItemizedSchedule -from .bulk_multi_schedule_configuration import BulkMultiScheduleConfiguration -from .bulk_schedule import BulkSchedule +from __future__ import annotations + import typing -from .bulk_sync_response import BulkSyncResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel, update_forward_refs +from .bulk_sync_response import BulkSyncResponse class BulkSyncResponseEnvelope(UniversalBaseModel): @@ -21,3 +20,6 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +update_forward_refs(BulkSyncResponseEnvelope) diff --git a/src/polytomic/types/bulk_sync_running_event.py b/src/polytomic/types/bulk_sync_running_event.py index adda8d7..522d31b 100644 --- a/src/polytomic/types/bulk_sync_running_event.py +++ b/src/polytomic/types/bulk_sync_running_event.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class BulkSyncRunningEvent(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_sync_schema_execution.py b/src/polytomic/types/bulk_sync_schema_execution.py index 3e9f0c5..db9a17d 100644 --- a/src/polytomic/types/bulk_sync_schema_execution.py +++ b/src/polytomic/types/bulk_sync_schema_execution.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing import datetime as dt +import typing + +import pydantic import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from ..core.serialization import FieldMetadata from .bulk_schema_execution_status import BulkSchemaExecutionStatus -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class BulkSyncSchemaExecution(UniversalBaseModel): @@ -16,7 +16,9 @@ class BulkSyncSchemaExecution(UniversalBaseModel): error_count: typing.Optional[int] = None output_name: typing.Optional[str] = None record_count: typing.Optional[int] = None - schema_: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="schema")] = None + schema_: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="schema"), pydantic.Field(alias="schema") + ] = None started_at: typing.Optional[dt.datetime] = None status: typing.Optional[BulkSchemaExecutionStatus] = None status_message: typing.Optional[str] = None diff --git a/src/polytomic/types/bulk_sync_schema_execution_status.py b/src/polytomic/types/bulk_sync_schema_execution_status.py index 338eea0..400b040 100644 --- a/src/polytomic/types/bulk_sync_schema_execution_status.py +++ b/src/polytomic/types/bulk_sync_schema_execution_status.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing import datetime as dt +import typing + import pydantic import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from ..core.serialization import FieldMetadata from .bulk_schema_execution_status import BulkSchemaExecutionStatus -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class BulkSyncSchemaExecutionStatus(UniversalBaseModel): @@ -19,7 +19,9 @@ class BulkSyncSchemaExecutionStatus(UniversalBaseModel): """ record_count: typing.Optional[int] = None - schema_: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="schema")] = None + schema_: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="schema"), pydantic.Field(alias="schema") + ] = None started_at: typing.Optional[dt.datetime] = None status: typing.Optional[BulkSchemaExecutionStatus] = None status_message: typing.Optional[str] = None diff --git a/src/polytomic/types/bulk_sync_source.py b/src/polytomic/types/bulk_sync_source.py index 969fc68..d0a8819 100644 --- a/src/polytomic/types/bulk_sync_source.py +++ b/src/polytomic/types/bulk_sync_source.py @@ -1,14 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .schema import Schema -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .schema import Schema class BulkSyncSource(UniversalBaseModel): - configuration: typing.Optional[typing.Optional[typing.Any]] = None + configuration: typing.Optional[typing.Any] = None schemas: typing.Optional[typing.List[Schema]] = None if IS_PYDANTIC_V2: diff --git a/src/polytomic/types/bulk_sync_source_envelope.py b/src/polytomic/types/bulk_sync_source_envelope.py index 9401ad8..3c82790 100644 --- a/src/polytomic/types/bulk_sync_source_envelope.py +++ b/src/polytomic/types/bulk_sync_source_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .bulk_sync_source import BulkSyncSource -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_sync_source import BulkSyncSource class BulkSyncSourceEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_sync_source_schema_envelope.py b/src/polytomic/types/bulk_sync_source_schema_envelope.py index 941b8a9..cc075ff 100644 --- a/src/polytomic/types/bulk_sync_source_schema_envelope.py +++ b/src/polytomic/types/bulk_sync_source_schema_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .schema import Schema -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .schema import Schema class BulkSyncSourceSchemaEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_sync_source_status.py b/src/polytomic/types/bulk_sync_source_status.py index 21e437a..a9bfe53 100644 --- a/src/polytomic/types/bulk_sync_source_status.py +++ b/src/polytomic/types/bulk_sync_source_status.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing import datetime as dt -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class BulkSyncSourceStatus(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_sync_source_status_envelope.py b/src/polytomic/types/bulk_sync_source_status_envelope.py index cfbf051..b833c27 100644 --- a/src/polytomic/types/bulk_sync_source_status_envelope.py +++ b/src/polytomic/types/bulk_sync_source_status_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .bulk_sync_source_status import BulkSyncSourceStatus -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_sync_source_status import BulkSyncSourceStatus class BulkSyncSourceStatusEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_sync_status_envelope.py b/src/polytomic/types/bulk_sync_status_envelope.py index 8f08427..eb3a8af 100644 --- a/src/polytomic/types/bulk_sync_status_envelope.py +++ b/src/polytomic/types/bulk_sync_status_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .bulk_sync_status_response import BulkSyncStatusResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_sync_status_response import BulkSyncStatusResponse class BulkSyncStatusEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/bulk_sync_status_response.py b/src/polytomic/types/bulk_sync_status_response.py index 680022f..9ff1864 100644 --- a/src/polytomic/types/bulk_sync_status_response.py +++ b/src/polytomic/types/bulk_sync_status_response.py @@ -1,15 +1,17 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing -from .bulk_sync_execution import BulkSyncExecution import datetime as dt -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_sync_execution import BulkSyncExecution +from .bulk_sync_ingestion_status import BulkSyncIngestionStatus class BulkSyncStatusResponse(UniversalBaseModel): current_execution: typing.Optional[BulkSyncExecution] = None + ingestion_status: typing.Optional[BulkSyncIngestionStatus] = None last_execution: typing.Optional[BulkSyncExecution] = None next_execution_time: typing.Optional[dt.datetime] = None diff --git a/src/polytomic/types/cancel_bulk_sync_response.py b/src/polytomic/types/cancel_bulk_sync_response.py index 8863746..d9c66d8 100644 --- a/src/polytomic/types/cancel_bulk_sync_response.py +++ b/src/polytomic/types/cancel_bulk_sync_response.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class CancelBulkSyncResponse(UniversalBaseModel): diff --git a/src/polytomic/types/cancel_bulk_sync_response_envelope.py b/src/polytomic/types/cancel_bulk_sync_response_envelope.py index e566e40..4a0e3c5 100644 --- a/src/polytomic/types/cancel_bulk_sync_response_envelope.py +++ b/src/polytomic/types/cancel_bulk_sync_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .cancel_bulk_sync_response import CancelBulkSyncResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .cancel_bulk_sync_response import CancelBulkSyncResponse class CancelBulkSyncResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/cancel_model_sync_response.py b/src/polytomic/types/cancel_model_sync_response.py index e827be1..a5cb6dc 100644 --- a/src/polytomic/types/cancel_model_sync_response.py +++ b/src/polytomic/types/cancel_model_sync_response.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class CancelModelSyncResponse(UniversalBaseModel): diff --git a/src/polytomic/types/cancel_model_sync_response_envelope.py b/src/polytomic/types/cancel_model_sync_response_envelope.py index 0e32aa2..456066e 100644 --- a/src/polytomic/types/cancel_model_sync_response_envelope.py +++ b/src/polytomic/types/cancel_model_sync_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .cancel_model_sync_response import CancelModelSyncResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .cancel_model_sync_response import CancelModelSyncResponse class CancelModelSyncResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/common_output_actor.py b/src/polytomic/types/common_output_actor.py index fc1b01c..78c79ee 100644 --- a/src/polytomic/types/common_output_actor.py +++ b/src/polytomic/types/common_output_actor.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class CommonOutputActor(UniversalBaseModel): diff --git a/src/polytomic/types/configuration_value.py b/src/polytomic/types/configuration_value.py index 02e7209..dc5cbde 100644 --- a/src/polytomic/types/configuration_value.py +++ b/src/polytomic/types/configuration_value.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class ConfigurationValue(UniversalBaseModel): - items: typing.Optional[typing.List[typing.Optional[typing.Any]]] = None + items: typing.Optional[typing.List[typing.Any]] = None type: typing.Optional[str] = None if IS_PYDANTIC_V2: diff --git a/src/polytomic/types/configuration_value_2.py b/src/polytomic/types/configuration_value_2.py new file mode 100644 index 0000000..5bf7393 --- /dev/null +++ b/src/polytomic/types/configuration_value_2.py @@ -0,0 +1,20 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel + + +class ConfigurationValue2(UniversalBaseModel): + items: typing.Optional[typing.List[typing.Any]] = None + type: typing.Optional[str] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/polytomic/types/connect_card_response.py b/src/polytomic/types/connect_card_response.py index bc4963d..a8a2b9d 100644 --- a/src/polytomic/types/connect_card_response.py +++ b/src/polytomic/types/connect_card_response.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class ConnectCardResponse(UniversalBaseModel): diff --git a/src/polytomic/types/connect_card_response_envelope.py b/src/polytomic/types/connect_card_response_envelope.py index 15129ac..eff3f8d 100644 --- a/src/polytomic/types/connect_card_response_envelope.py +++ b/src/polytomic/types/connect_card_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .connect_card_response import ConnectCardResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .connect_card_response import ConnectCardResponse class ConnectCardResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/connection_list_response_envelope.py b/src/polytomic/types/connection_list_response_envelope.py index 756361c..0e8ffd8 100644 --- a/src/polytomic/types/connection_list_response_envelope.py +++ b/src/polytomic/types/connection_list_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .connection_response_schema import ConnectionResponseSchema -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .connection_response_schema import ConnectionResponseSchema class ConnectionListResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/connection_meta.py b/src/polytomic/types/connection_meta.py index 67f1eca..7bc5db3 100644 --- a/src/polytomic/types/connection_meta.py +++ b/src/polytomic/types/connection_meta.py @@ -1,14 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class ConnectionMeta(UniversalBaseModel): has_items: typing.Optional[bool] = None - items: typing.Optional[typing.List[typing.Optional[typing.Any]]] = None + items: typing.Optional[typing.List[typing.Any]] = None requires_one_of: typing.Optional[typing.List[str]] = None if IS_PYDANTIC_V2: diff --git a/src/polytomic/types/connection_meta_response.py b/src/polytomic/types/connection_meta_response.py index 6811a25..3811cec 100644 --- a/src/polytomic/types/connection_meta_response.py +++ b/src/polytomic/types/connection_meta_response.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .configuration_value import ConfigurationValue from .connection_meta import ConnectionMeta -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class ConnectionMetaResponse(UniversalBaseModel): diff --git a/src/polytomic/types/connection_parameter_value.py b/src/polytomic/types/connection_parameter_value.py index c93bcc0..1e53a45 100644 --- a/src/polytomic/types/connection_parameter_value.py +++ b/src/polytomic/types/connection_parameter_value.py @@ -1,14 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class ConnectionParameterValue(UniversalBaseModel): label: typing.Optional[str] = None - value: typing.Optional[typing.Optional[typing.Any]] = None + value: typing.Optional[typing.Any] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/polytomic/types/connection_parameter_values_resp.py b/src/polytomic/types/connection_parameter_values_resp.py index a400205..fc02b89 100644 --- a/src/polytomic/types/connection_parameter_values_resp.py +++ b/src/polytomic/types/connection_parameter_values_resp.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .connection_parameter_value import ConnectionParameterValue -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .connection_parameter_value import ConnectionParameterValue class ConnectionParameterValuesResp(UniversalBaseModel): diff --git a/src/polytomic/types/connection_parameter_values_response_envelope.py b/src/polytomic/types/connection_parameter_values_response_envelope.py index 2668ab3..19fd4ce 100644 --- a/src/polytomic/types/connection_parameter_values_response_envelope.py +++ b/src/polytomic/types/connection_parameter_values_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .connection_parameter_values_resp import ConnectionParameterValuesResp -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .connection_parameter_values_resp import ConnectionParameterValuesResp class ConnectionParameterValuesResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/connection_response_envelope.py b/src/polytomic/types/connection_response_envelope.py index 8fde2d5..b31b2af 100644 --- a/src/polytomic/types/connection_response_envelope.py +++ b/src/polytomic/types/connection_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .connection_response_schema import ConnectionResponseSchema -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .connection_response_schema import ConnectionResponseSchema class ConnectionResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/connection_response_schema.py b/src/polytomic/types/connection_response_schema.py index c6400d4..959eaa3 100644 --- a/src/polytomic/types/connection_response_schema.py +++ b/src/polytomic/types/connection_response_schema.py @@ -1,12 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel +import datetime as dt import typing + import pydantic -import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .common_output_actor import CommonOutputActor from .connection_type_schema import ConnectionTypeSchema -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class ConnectionResponseSchema(UniversalBaseModel): @@ -15,7 +15,7 @@ class ConnectionResponseSchema(UniversalBaseModel): API calls made to service in the last 24h (supported integrations only). """ - configuration: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None + configuration: typing.Optional[typing.Dict[str, typing.Any]] = None created_at: typing.Optional[dt.datetime] = None created_by: typing.Optional[CommonOutputActor] = None id: typing.Optional[str] = None diff --git a/src/polytomic/types/connection_type.py b/src/polytomic/types/connection_type.py index fe2bd1f..be3af1c 100644 --- a/src/polytomic/types/connection_type.py +++ b/src/polytomic/types/connection_type.py @@ -1,27 +1,33 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -from .backend_connection_capabilities import BackendConnectionCapabilities -import typing_extensions import typing -from .v_2_connection_form import V2ConnectionForm + +import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from ..core.serialization import FieldMetadata +from .backend_connection_capabilities import BackendConnectionCapabilities from .backend_o_auth_prompt import BackendOAuthPrompt -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic +from .v_2_connection_form import V2ConnectionForm class ConnectionType(UniversalBaseModel): capabilities: BackendConnectionCapabilities configuration_form: typing_extensions.Annotated[ - typing.Optional[V2ConnectionForm], FieldMetadata(alias="configurationForm") + typing.Optional[V2ConnectionForm], + FieldMetadata(alias="configurationForm"), + pydantic.Field(alias="configurationForm"), ] = None env_config: typing_extensions.Annotated[ - typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]], FieldMetadata(alias="envConfig") + typing.Optional[typing.Dict[str, typing.Any]], + FieldMetadata(alias="envConfig"), + pydantic.Field(alias="envConfig"), ] = None id: typing.Optional[str] = None initial_configuration: typing_extensions.Annotated[ - typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]], FieldMetadata(alias="initialConfiguration") + typing.Optional[typing.Dict[str, typing.Any]], + FieldMetadata(alias="initialConfiguration"), + pydantic.Field(alias="initialConfiguration"), ] = None logo_url: typing.Optional[str] = None name: typing.Optional[str] = None diff --git a/src/polytomic/types/connection_type_response_envelope.py b/src/polytomic/types/connection_type_response_envelope.py index 2f17156..fe7ba6e 100644 --- a/src/polytomic/types/connection_type_response_envelope.py +++ b/src/polytomic/types/connection_type_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .connection_type import ConnectionType -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .connection_type import ConnectionType class ConnectionTypeResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/connection_type_schema.py b/src/polytomic/types/connection_type_schema.py index ad0aa37..8a3ce02 100644 --- a/src/polytomic/types/connection_type_schema.py +++ b/src/polytomic/types/connection_type_schema.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class ConnectionTypeSchema(UniversalBaseModel): diff --git a/src/polytomic/types/create_connection_response_envelope.py b/src/polytomic/types/create_connection_response_envelope.py index 0e944b6..425fa32 100644 --- a/src/polytomic/types/create_connection_response_envelope.py +++ b/src/polytomic/types/create_connection_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .create_connection_response_schema import CreateConnectionResponseSchema -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .create_connection_response_schema import CreateConnectionResponseSchema class CreateConnectionResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/create_connection_response_schema.py b/src/polytomic/types/create_connection_response_schema.py index 7502eea..906671e 100644 --- a/src/polytomic/types/create_connection_response_schema.py +++ b/src/polytomic/types/create_connection_response_schema.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .connection_type_schema import ConnectionTypeSchema -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class CreateConnectionResponseSchema(UniversalBaseModel): @@ -18,7 +18,7 @@ class CreateConnectionResponseSchema(UniversalBaseModel): URL to visit to complete connection authentication. """ - configuration: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None + configuration: typing.Optional[typing.Dict[str, typing.Any]] = None healthcheck_interval: typing.Optional[str] = pydantic.Field(default=None) """ Interval for connection health checking. diff --git a/src/polytomic/types/create_model_request.py b/src/polytomic/types/create_model_request.py index 6c50475..c99886a 100644 --- a/src/polytomic/types/create_model_request.py +++ b/src/polytomic/types/create_model_request.py @@ -1,17 +1,17 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .model_model_field_request import ModelModelFieldRequest + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .enrichment import Enrichment +from .model_model_field_request import ModelModelFieldRequest from .model_relation import ModelRelation -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class CreateModelRequest(UniversalBaseModel): additional_fields: typing.Optional[typing.List[ModelModelFieldRequest]] = None - configuration: typing.Dict[str, typing.Optional[typing.Any]] + configuration: typing.Dict[str, typing.Any] connection_id: str enricher: typing.Optional[Enrichment] = None fields: typing.Optional[typing.List[str]] = None diff --git a/src/polytomic/types/create_shared_connection_response_schema.py b/src/polytomic/types/create_shared_connection_response_schema.py index 4dbebef..fcffe5b 100644 --- a/src/polytomic/types/create_shared_connection_response_schema.py +++ b/src/polytomic/types/create_shared_connection_response_schema.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class CreateSharedConnectionResponseSchema(UniversalBaseModel): diff --git a/src/polytomic/types/enrichment.py b/src/polytomic/types/enrichment.py index 7def672..43e2639 100644 --- a/src/polytomic/types/enrichment.py +++ b/src/polytomic/types/enrichment.py @@ -1,12 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .v_2_enricher_configuration import V2EnricherConfiguration + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .model_field import ModelField +from .v_2_enricher_configuration import V2EnricherConfiguration from .v_2_enricher_mapping import V2EnricherMapping -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class Enrichment(UniversalBaseModel): diff --git a/src/polytomic/types/event.py b/src/polytomic/types/event.py index 963d107..bfc51af 100644 --- a/src/polytomic/types/event.py +++ b/src/polytomic/types/event.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing import datetime as dt -from .event_body import EventBody -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .event_body import EventBody class Event(UniversalBaseModel): diff --git a/src/polytomic/types/event_body.py b/src/polytomic/types/event_body.py index 6ea03e1..2d86f70 100644 --- a/src/polytomic/types/event_body.py +++ b/src/polytomic/types/event_body.py @@ -1,16 +1,17 @@ # This file was auto-generated by Fern from our API Definition. import typing -from .sync_running_event import SyncRunningEvent -from .sync_completed_event import SyncCompletedEvent -from .sync_failed_event import SyncFailedEvent -from .sync_canceled_event import SyncCanceledEvent -from .sync_completed_with_errors_event import SyncCompletedWithErrorsEvent -from .bulk_sync_running_event import BulkSyncRunningEvent -from .bulk_sync_completed_event import BulkSyncCompletedEvent + from .bulk_sync_canceled_event import BulkSyncCanceledEvent +from .bulk_sync_completed_event import BulkSyncCompletedEvent from .bulk_sync_completed_with_error_event import BulkSyncCompletedWithErrorEvent from .bulk_sync_failed_event import BulkSyncFailedEvent +from .bulk_sync_running_event import BulkSyncRunningEvent +from .sync_canceled_event import SyncCanceledEvent +from .sync_completed_event import SyncCompletedEvent +from .sync_completed_with_errors_event import SyncCompletedWithErrorsEvent +from .sync_failed_event import SyncFailedEvent +from .sync_running_event import SyncRunningEvent EventBody = typing.Union[ SyncRunningEvent, diff --git a/src/polytomic/types/event_types_envelope.py b/src/polytomic/types/event_types_envelope.py index 57c5088..b11eac5 100644 --- a/src/polytomic/types/event_types_envelope.py +++ b/src/polytomic/types/event_types_envelope.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class EventTypesEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/events_envelope.py b/src/polytomic/types/events_envelope.py index b540371..6fc8407 100644 --- a/src/polytomic/types/events_envelope.py +++ b/src/polytomic/types/events_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .event import Event -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .event import Event class EventsEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/execution_counts.py b/src/polytomic/types/execution_counts.py index efcb81f..44ac742 100644 --- a/src/polytomic/types/execution_counts.py +++ b/src/polytomic/types/execution_counts.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class ExecutionCounts(UniversalBaseModel): diff --git a/src/polytomic/types/execution_log_response.py b/src/polytomic/types/execution_log_response.py index bcef29e..8c6963b 100644 --- a/src/polytomic/types/execution_log_response.py +++ b/src/polytomic/types/execution_log_response.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing import datetime as dt -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class ExecutionLogResponse(UniversalBaseModel): diff --git a/src/polytomic/types/execution_logs_response_envelope.py b/src/polytomic/types/execution_logs_response_envelope.py index 63cbcd2..4a95848 100644 --- a/src/polytomic/types/execution_logs_response_envelope.py +++ b/src/polytomic/types/execution_logs_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .execution_log_response import ExecutionLogResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .execution_log_response import ExecutionLogResponse class ExecutionLogsResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/field_configuration.py b/src/polytomic/types/field_configuration.py index 07057de..4457614 100644 --- a/src/polytomic/types/field_configuration.py +++ b/src/polytomic/types/field_configuration.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class FieldConfiguration(UniversalBaseModel): diff --git a/src/polytomic/types/filter.py b/src/polytomic/types/filter.py index b95dbc9..bc83ee7 100644 --- a/src/polytomic/types/filter.py +++ b/src/polytomic/types/filter.py @@ -1,12 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .source import Source + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .filter_field_reference_type import FilterFieldReferenceType from .filter_function import FilterFunction -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .source import Source class Filter(UniversalBaseModel): @@ -23,7 +23,7 @@ class Filter(UniversalBaseModel): field_type: typing.Optional[FilterFieldReferenceType] = None function: FilterFunction label: typing.Optional[str] = None - value: typing.Optional[typing.Optional[typing.Any]] = None + value: typing.Optional[typing.Any] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/polytomic/types/get_connection_meta_envelope.py b/src/polytomic/types/get_connection_meta_envelope.py index e387173..e84bbbf 100644 --- a/src/polytomic/types/get_connection_meta_envelope.py +++ b/src/polytomic/types/get_connection_meta_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .connection_meta_response import ConnectionMetaResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .connection_meta_response import ConnectionMetaResponse class GetConnectionMetaEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/get_execution_response_envelope.py b/src/polytomic/types/get_execution_response_envelope.py index 4edb7db..6427cbe 100644 --- a/src/polytomic/types/get_execution_response_envelope.py +++ b/src/polytomic/types/get_execution_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .get_execution_response_schema import GetExecutionResponseSchema -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .get_execution_response_schema import GetExecutionResponseSchema class GetExecutionResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/get_execution_response_schema.py b/src/polytomic/types/get_execution_response_schema.py index 543548a..1dc3427 100644 --- a/src/polytomic/types/get_execution_response_schema.py +++ b/src/polytomic/types/get_execution_response_schema.py @@ -1,12 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing import datetime as dt +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .execution_counts import ExecutionCounts from .execution_status import ExecutionStatus -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class GetExecutionResponseSchema(UniversalBaseModel): diff --git a/src/polytomic/types/get_identity_response_envelope.py b/src/polytomic/types/get_identity_response_envelope.py index 306c001..fc86d26 100644 --- a/src/polytomic/types/get_identity_response_envelope.py +++ b/src/polytomic/types/get_identity_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .get_identity_response_schema import GetIdentityResponseSchema -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .get_identity_response_schema import GetIdentityResponseSchema class GetIdentityResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/get_identity_response_schema.py b/src/polytomic/types/get_identity_response_schema.py index 11b477f..4ab692d 100644 --- a/src/polytomic/types/get_identity_response_schema.py +++ b/src/polytomic/types/get_identity_response_schema.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class GetIdentityResponseSchema(UniversalBaseModel): diff --git a/src/polytomic/types/get_model_sync_source_meta_envelope.py b/src/polytomic/types/get_model_sync_source_meta_envelope.py index 731c14a..90d2d70 100644 --- a/src/polytomic/types/get_model_sync_source_meta_envelope.py +++ b/src/polytomic/types/get_model_sync_source_meta_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .model_sync_source_meta_response import ModelSyncSourceMetaResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .model_sync_source_meta_response import ModelSyncSourceMetaResponse class GetModelSyncSourceMetaEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/identity.py b/src/polytomic/types/identity.py index e34b270..9855eee 100644 --- a/src/polytomic/types/identity.py +++ b/src/polytomic/types/identity.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -from .schema_identity_function import SchemaIdentityFunction import typing -from .source import Source -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .schema_identity_function import SchemaIdentityFunction +from .source import Source class Identity(UniversalBaseModel): diff --git a/src/polytomic/types/identity_function.py b/src/polytomic/types/identity_function.py index 429e1ae..f502f04 100644 --- a/src/polytomic/types/identity_function.py +++ b/src/polytomic/types/identity_function.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class IdentityFunction(UniversalBaseModel): diff --git a/src/polytomic/types/ingestion_status_level.py b/src/polytomic/types/ingestion_status_level.py new file mode 100644 index 0000000..7f782a8 --- /dev/null +++ b/src/polytomic/types/ingestion_status_level.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +IngestionStatusLevel = typing.Union[typing.Literal["ok", "warning", "error"], typing.Any] diff --git a/src/polytomic/types/job_response.py b/src/polytomic/types/job_response.py index 7d601ad..c3fcc4b 100644 --- a/src/polytomic/types/job_response.py +++ b/src/polytomic/types/job_response.py @@ -1,16 +1,16 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .work_task_status import WorkTaskStatus -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .work_task_status import WorkTaskStatus class JobResponse(UniversalBaseModel): error: typing.Optional[str] = None job_id: typing.Optional[str] = None - result: typing.Optional[typing.Optional[typing.Any]] = None + result: typing.Optional[typing.Any] = None status: typing.Optional[WorkTaskStatus] = None type: typing.Optional[str] = None diff --git a/src/polytomic/types/job_response_envelope.py b/src/polytomic/types/job_response_envelope.py index 8097319..ed5a239 100644 --- a/src/polytomic/types/job_response_envelope.py +++ b/src/polytomic/types/job_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .job_response import JobResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .job_response import JobResponse class JobResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/jsonschema_form.py b/src/polytomic/types/jsonschema_form.py index 379bb56..3481808 100644 --- a/src/polytomic/types/jsonschema_form.py +++ b/src/polytomic/types/jsonschema_form.py @@ -2,4 +2,4 @@ import typing -JsonschemaForm = typing.Dict[str, typing.Optional[typing.Any]] +JsonschemaForm = typing.Dict[str, typing.Any] diff --git a/src/polytomic/types/jsonschema_schema.py b/src/polytomic/types/jsonschema_schema.py index cc657fb..80c5f2d 100644 --- a/src/polytomic/types/jsonschema_schema.py +++ b/src/polytomic/types/jsonschema_schema.py @@ -1,94 +1,154 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.pydantic_utilities import UniversalBaseModel -import typing_extensions + import typing + +import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel, update_forward_refs from ..core.serialization import FieldMetadata from .v_2_ordered_map_string_github_com_invopop_jsonschema_schema import ( V2OrderedMapStringGithubComInvopopJsonschemaSchema, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic -from ..core.pydantic_utilities import update_forward_refs class JsonschemaSchema(UniversalBaseModel): - anchor: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="$anchor")] = None - comment: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="$comment")] = None - defs: typing_extensions.Annotated[typing.Optional["JsonschemaDefinitions"], FieldMetadata(alias="$defs")] = None - dynamic_ref: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="$dynamicRef")] = None - id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="$id")] = None - ref: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="$ref")] = None - schema_: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="$schema")] = None + anchor: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="$anchor"), pydantic.Field(alias="$anchor") + ] = None + comment: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="$comment"), pydantic.Field(alias="$comment") + ] = None + defs: typing_extensions.Annotated[ + typing.Optional["JsonschemaDefinitions"], FieldMetadata(alias="$defs"), pydantic.Field(alias="$defs") + ] = None + dynamic_ref: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="$dynamicRef"), pydantic.Field(alias="$dynamicRef") + ] = None + id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="$id"), pydantic.Field(alias="$id")] = ( + None + ) + ref: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="$ref"), pydantic.Field(alias="$ref") + ] = None + schema_: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="$schema"), pydantic.Field(alias="$schema") + ] = None additional_properties: typing_extensions.Annotated[ - typing.Optional["JsonschemaSchema"], FieldMetadata(alias="additionalProperties") + typing.Optional["JsonschemaSchema"], + FieldMetadata(alias="additionalProperties"), + pydantic.Field(alias="additionalProperties"), ] = None all_of: typing_extensions.Annotated[ - typing.Optional[typing.List["JsonschemaSchema"]], FieldMetadata(alias="allOf") + typing.Optional[typing.List["JsonschemaSchema"]], FieldMetadata(alias="allOf"), pydantic.Field(alias="allOf") ] = None any_of: typing_extensions.Annotated[ - typing.Optional[typing.List["JsonschemaSchema"]], FieldMetadata(alias="anyOf") + typing.Optional[typing.List["JsonschemaSchema"]], FieldMetadata(alias="anyOf"), pydantic.Field(alias="anyOf") ] = None - const: typing.Optional[typing.Optional[typing.Any]] = None + const: typing.Optional[typing.Any] = None contains: typing.Optional["JsonschemaSchema"] = None - content_encoding: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="contentEncoding")] = None - content_media_type: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="contentMediaType")] = ( - None - ) + content_encoding: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="contentEncoding"), pydantic.Field(alias="contentEncoding") + ] = None + content_media_type: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="contentMediaType"), pydantic.Field(alias="contentMediaType") + ] = None content_schema: typing_extensions.Annotated[ - typing.Optional["JsonschemaSchema"], FieldMetadata(alias="contentSchema") + typing.Optional["JsonschemaSchema"], FieldMetadata(alias="contentSchema"), pydantic.Field(alias="contentSchema") ] = None - default: typing.Optional[typing.Optional[typing.Any]] = None + default: typing.Optional[typing.Any] = None dependent_required: typing_extensions.Annotated[ - typing.Optional[typing.Dict[str, typing.List[str]]], FieldMetadata(alias="dependentRequired") + typing.Optional[typing.Dict[str, typing.List[str]]], + FieldMetadata(alias="dependentRequired"), + pydantic.Field(alias="dependentRequired"), ] = None dependent_schemas: typing_extensions.Annotated[ - typing.Optional[typing.Dict[str, "JsonschemaSchema"]], FieldMetadata(alias="dependentSchemas") + typing.Optional[typing.Dict[str, "JsonschemaSchema"]], + FieldMetadata(alias="dependentSchemas"), + pydantic.Field(alias="dependentSchemas"), ] = None deprecated: typing.Optional[bool] = None description: typing.Optional[str] = None - else_: typing_extensions.Annotated[typing.Optional["JsonschemaSchema"], FieldMetadata(alias="else")] = None - enum: typing.Optional[typing.List[typing.Optional[typing.Any]]] = None - examples: typing.Optional[typing.List[typing.Optional[typing.Any]]] = None - exclusive_maximum: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="exclusiveMaximum")] = None - exclusive_minimum: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="exclusiveMinimum")] = None + else_: typing_extensions.Annotated[ + typing.Optional["JsonschemaSchema"], FieldMetadata(alias="else"), pydantic.Field(alias="else") + ] = None + enum: typing.Optional[typing.List[typing.Any]] = None + examples: typing.Optional[typing.List[typing.Any]] = None + exclusive_maximum: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="exclusiveMaximum"), pydantic.Field(alias="exclusiveMaximum") + ] = None + exclusive_minimum: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="exclusiveMinimum"), pydantic.Field(alias="exclusiveMinimum") + ] = None format: typing.Optional[str] = None - if_: typing_extensions.Annotated[typing.Optional["JsonschemaSchema"], FieldMetadata(alias="if")] = None + if_: typing_extensions.Annotated[ + typing.Optional["JsonschemaSchema"], FieldMetadata(alias="if"), pydantic.Field(alias="if") + ] = None items: typing.Optional["JsonschemaSchema"] = None - max_contains: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="maxContains")] = None - max_items: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="maxItems")] = None - max_length: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="maxLength")] = None - max_properties: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="maxProperties")] = None + max_contains: typing_extensions.Annotated[ + typing.Optional[int], FieldMetadata(alias="maxContains"), pydantic.Field(alias="maxContains") + ] = None + max_items: typing_extensions.Annotated[ + typing.Optional[int], FieldMetadata(alias="maxItems"), pydantic.Field(alias="maxItems") + ] = None + max_length: typing_extensions.Annotated[ + typing.Optional[int], FieldMetadata(alias="maxLength"), pydantic.Field(alias="maxLength") + ] = None + max_properties: typing_extensions.Annotated[ + typing.Optional[int], FieldMetadata(alias="maxProperties"), pydantic.Field(alias="maxProperties") + ] = None maximum: typing.Optional[str] = None - min_contains: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="minContains")] = None - min_items: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="minItems")] = None - min_length: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="minLength")] = None - min_properties: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="minProperties")] = None + min_contains: typing_extensions.Annotated[ + typing.Optional[int], FieldMetadata(alias="minContains"), pydantic.Field(alias="minContains") + ] = None + min_items: typing_extensions.Annotated[ + typing.Optional[int], FieldMetadata(alias="minItems"), pydantic.Field(alias="minItems") + ] = None + min_length: typing_extensions.Annotated[ + typing.Optional[int], FieldMetadata(alias="minLength"), pydantic.Field(alias="minLength") + ] = None + min_properties: typing_extensions.Annotated[ + typing.Optional[int], FieldMetadata(alias="minProperties"), pydantic.Field(alias="minProperties") + ] = None minimum: typing.Optional[str] = None - multiple_of: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="multipleOf")] = None - not_: typing_extensions.Annotated[typing.Optional["JsonschemaSchema"], FieldMetadata(alias="not")] = None + multiple_of: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="multipleOf"), pydantic.Field(alias="multipleOf") + ] = None + not_: typing_extensions.Annotated[ + typing.Optional["JsonschemaSchema"], FieldMetadata(alias="not"), pydantic.Field(alias="not") + ] = None one_of: typing_extensions.Annotated[ - typing.Optional[typing.List["JsonschemaSchema"]], FieldMetadata(alias="oneOf") + typing.Optional[typing.List["JsonschemaSchema"]], FieldMetadata(alias="oneOf"), pydantic.Field(alias="oneOf") ] = None pattern: typing.Optional[str] = None pattern_properties: typing_extensions.Annotated[ - typing.Optional[typing.Dict[str, "JsonschemaSchema"]], FieldMetadata(alias="patternProperties") + typing.Optional[typing.Dict[str, "JsonschemaSchema"]], + FieldMetadata(alias="patternProperties"), + pydantic.Field(alias="patternProperties"), ] = None prefix_items: typing_extensions.Annotated[ - typing.Optional[typing.List["JsonschemaSchema"]], FieldMetadata(alias="prefixItems") + typing.Optional[typing.List["JsonschemaSchema"]], + FieldMetadata(alias="prefixItems"), + pydantic.Field(alias="prefixItems"), ] = None properties: typing.Optional[V2OrderedMapStringGithubComInvopopJsonschemaSchema] = None property_names: typing_extensions.Annotated[ - typing.Optional["JsonschemaSchema"], FieldMetadata(alias="propertyNames") + typing.Optional["JsonschemaSchema"], FieldMetadata(alias="propertyNames"), pydantic.Field(alias="propertyNames") + ] = None + read_only: typing_extensions.Annotated[ + typing.Optional[bool], FieldMetadata(alias="readOnly"), pydantic.Field(alias="readOnly") ] = None - read_only: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="readOnly")] = None required: typing.Optional[typing.List[str]] = None then: typing.Optional["JsonschemaSchema"] = None title: typing.Optional[str] = None type: typing.Optional[str] = None - unique_items: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="uniqueItems")] = None - write_only: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="writeOnly")] = None + unique_items: typing_extensions.Annotated[ + typing.Optional[bool], FieldMetadata(alias="uniqueItems"), pydantic.Field(alias="uniqueItems") + ] = None + write_only: typing_extensions.Annotated[ + typing.Optional[bool], FieldMetadata(alias="writeOnly"), pydantic.Field(alias="writeOnly") + ] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 @@ -100,6 +160,6 @@ class Config: extra = pydantic.Extra.allow -from .jsonschema_definitions import JsonschemaDefinitions # noqa: E402 +from .jsonschema_definitions import JsonschemaDefinitions # noqa: E402, I001 -update_forward_refs(JsonschemaSchema) +update_forward_refs(JsonschemaSchema, JsonschemaDefinitions=JsonschemaDefinitions) diff --git a/src/polytomic/types/label_label.py b/src/polytomic/types/label_label.py index 2a919ae..9a15ec0 100644 --- a/src/polytomic/types/label_label.py +++ b/src/polytomic/types/label_label.py @@ -2,4 +2,4 @@ import typing -LabelLabel = typing.Dict[str, typing.Optional[typing.Any]] +LabelLabel = typing.Dict[str, typing.Any] diff --git a/src/polytomic/types/list_bulk_schema.py b/src/polytomic/types/list_bulk_schema.py index 6a6640b..61ea05d 100644 --- a/src/polytomic/types/list_bulk_schema.py +++ b/src/polytomic/types/list_bulk_schema.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .bulk_schema import BulkSchema -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_schema import BulkSchema class ListBulkSchema(UniversalBaseModel): diff --git a/src/polytomic/types/list_bulk_sync_execution_status_envelope.py b/src/polytomic/types/list_bulk_sync_execution_status_envelope.py index 92d9d14..96d76a5 100644 --- a/src/polytomic/types/list_bulk_sync_execution_status_envelope.py +++ b/src/polytomic/types/list_bulk_sync_execution_status_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .bulk_sync_execution_status import BulkSyncExecutionStatus -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_sync_execution_status import BulkSyncExecutionStatus class ListBulkSyncExecutionStatusEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/list_bulk_sync_executions_envelope.py b/src/polytomic/types/list_bulk_sync_executions_envelope.py index a63f897..650f865 100644 --- a/src/polytomic/types/list_bulk_sync_executions_envelope.py +++ b/src/polytomic/types/list_bulk_sync_executions_envelope.py @@ -1,16 +1,16 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .bulk_sync_execution import BulkSyncExecution -from .pagination_details import PaginationDetails -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_sync_execution import BulkSyncExecution +from .pagination_details_2 import PaginationDetails2 class ListBulkSyncExecutionsEnvelope(UniversalBaseModel): data: typing.Optional[typing.List[BulkSyncExecution]] = None - pagination: typing.Optional[PaginationDetails] = None + pagination: typing.Optional[PaginationDetails2] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/polytomic/types/list_execution_response_envelope.py b/src/polytomic/types/list_execution_response_envelope.py index 8705e5b..3957689 100644 --- a/src/polytomic/types/list_execution_response_envelope.py +++ b/src/polytomic/types/list_execution_response_envelope.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .get_execution_response_schema import GetExecutionResponseSchema from .pagination_details import PaginationDetails -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class ListExecutionResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/list_model_sync_response_envelope.py b/src/polytomic/types/list_model_sync_response_envelope.py index f4d9ade..f10972f 100644 --- a/src/polytomic/types/list_model_sync_response_envelope.py +++ b/src/polytomic/types/list_model_sync_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .model_sync_response import ModelSyncResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .model_sync_response import ModelSyncResponse class ListModelSyncResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/list_policies_response_envelope.py b/src/polytomic/types/list_policies_response_envelope.py index 06b5313..c00a53c 100644 --- a/src/polytomic/types/list_policies_response_envelope.py +++ b/src/polytomic/types/list_policies_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .policy_response import PolicyResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .policy_response import PolicyResponse class ListPoliciesResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/list_users_envelope.py b/src/polytomic/types/list_users_envelope.py index 3f0e8e7..3df1852 100644 --- a/src/polytomic/types/list_users_envelope.py +++ b/src/polytomic/types/list_users_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .user import User -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .user import User class ListUsersEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/mode.py b/src/polytomic/types/mode.py index 3792f02..0d8d771 100644 --- a/src/polytomic/types/mode.py +++ b/src/polytomic/types/mode.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class Mode(UniversalBaseModel): diff --git a/src/polytomic/types/model_field.py b/src/polytomic/types/model_field.py index aa4a1c9..ef0765c 100644 --- a/src/polytomic/types/model_field.py +++ b/src/polytomic/types/model_field.py @@ -1,18 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing import datetime as dt -from .common_output_actor import CommonOutputActor -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .common_output_actor import CommonOutputActor class ModelField(UniversalBaseModel): created_at: typing.Optional[dt.datetime] = None created_by: typing.Optional[CommonOutputActor] = None description: typing.Optional[str] = None - example: typing.Optional[typing.Optional[typing.Any]] = None + example: typing.Optional[typing.Any] = None id: typing.Optional[str] = None label: typing.Optional[str] = None name: typing.Optional[str] = None diff --git a/src/polytomic/types/model_field_response.py b/src/polytomic/types/model_field_response.py index 1fd1092..a5d0daf 100644 --- a/src/polytomic/types/model_field_response.py +++ b/src/polytomic/types/model_field_response.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .model_field import ModelField -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .model_field import ModelField class ModelFieldResponse(UniversalBaseModel): diff --git a/src/polytomic/types/model_list_response_envelope.py b/src/polytomic/types/model_list_response_envelope.py index 67be25f..9f5c19e 100644 --- a/src/polytomic/types/model_list_response_envelope.py +++ b/src/polytomic/types/model_list_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .model_response import ModelResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .model_response import ModelResponse class ModelListResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/model_model_field_request.py b/src/polytomic/types/model_model_field_request.py index c8aee31..ec4526a 100644 --- a/src/polytomic/types/model_model_field_request.py +++ b/src/polytomic/types/model_model_field_request.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class ModelModelFieldRequest(UniversalBaseModel): diff --git a/src/polytomic/types/model_relation.py b/src/polytomic/types/model_relation.py index 65c67ab..82507e0 100644 --- a/src/polytomic/types/model_relation.py +++ b/src/polytomic/types/model_relation.py @@ -1,16 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing_extensions import typing + +import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from ..core.serialization import FieldMetadata from .model_relation_to import ModelRelationTo -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class ModelRelation(UniversalBaseModel): - from_: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="from")] = None + from_: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="from"), pydantic.Field(alias="from") + ] = None to: typing.Optional[ModelRelationTo] = None if IS_PYDANTIC_V2: diff --git a/src/polytomic/types/model_relation_to.py b/src/polytomic/types/model_relation_to.py index fec6974..599632b 100644 --- a/src/polytomic/types/model_relation_to.py +++ b/src/polytomic/types/model_relation_to.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class ModelRelationTo(UniversalBaseModel): diff --git a/src/polytomic/types/model_response.py b/src/polytomic/types/model_response.py index d4e1f71..2cb3abb 100644 --- a/src/polytomic/types/model_response.py +++ b/src/polytomic/types/model_response.py @@ -1,19 +1,19 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing import datetime as dt +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .common_output_actor import CommonOutputActor from .enrichment import Enrichment -from .model_field import ModelField from .label_label import LabelLabel +from .model_field import ModelField from .relation import Relation -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class ModelResponse(UniversalBaseModel): - configuration: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None + configuration: typing.Optional[typing.Dict[str, typing.Any]] = None connection_id: typing.Optional[str] = None created_at: typing.Optional[dt.datetime] = None created_by: typing.Optional[CommonOutputActor] = None diff --git a/src/polytomic/types/model_response_envelope.py b/src/polytomic/types/model_response_envelope.py index 61df370..0a6975f 100644 --- a/src/polytomic/types/model_response_envelope.py +++ b/src/polytomic/types/model_response_envelope.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .model_response import ModelResponse -from .job_response import JobResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .job_response import JobResponse +from .model_response import ModelResponse class ModelResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/model_sample.py b/src/polytomic/types/model_sample.py index 10ce391..461a98d 100644 --- a/src/polytomic/types/model_sample.py +++ b/src/polytomic/types/model_sample.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .v_2_sample_record import V2SampleRecord -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .v_2_sample_record import V2SampleRecord class ModelSample(UniversalBaseModel): diff --git a/src/polytomic/types/model_sample_response_envelope.py b/src/polytomic/types/model_sample_response_envelope.py index 1889c54..0c080d7 100644 --- a/src/polytomic/types/model_sample_response_envelope.py +++ b/src/polytomic/types/model_sample_response_envelope.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .model_sample import ModelSample -from .job_response import JobResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .job_response import JobResponse +from .model_sample import ModelSample class ModelSampleResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/model_sync_field.py b/src/polytomic/types/model_sync_field.py index 6adc215..c10c1ac 100644 --- a/src/polytomic/types/model_sync_field.py +++ b/src/polytomic/types/model_sync_field.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .source import Source -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class ModelSyncField(UniversalBaseModel): diff --git a/src/polytomic/types/model_sync_mode.py b/src/polytomic/types/model_sync_mode.py index 7a21004..5836db1 100644 --- a/src/polytomic/types/model_sync_mode.py +++ b/src/polytomic/types/model_sync_mode.py @@ -3,5 +3,5 @@ import typing ModelSyncMode = typing.Union[ - typing.Literal["create", "update", "updateOrCreate", "replace", "append", "remove"], typing.Any + typing.Literal["create", "update", "updateOrCreate", "replace", "append", "remove", "snapshot"], typing.Any ] diff --git a/src/polytomic/types/model_sync_response.py b/src/polytomic/types/model_sync_response.py index 57e0e83..7b0a80a 100644 --- a/src/polytomic/types/model_sync_response.py +++ b/src/polytomic/types/model_sync_response.py @@ -1,18 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing import datetime as dt +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .common_output_actor import CommonOutputActor -from .model_sync_field import ModelSyncField from .filter import Filter from .identity import Identity +from .model_sync_field import ModelSyncField from .model_sync_mode import ModelSyncMode -import pydantic from .override import Override from .schedule import Schedule from .target import Target -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class ModelSyncResponse(UniversalBaseModel): diff --git a/src/polytomic/types/model_sync_response_envelope.py b/src/polytomic/types/model_sync_response_envelope.py index 7b4afe2..a8812eb 100644 --- a/src/polytomic/types/model_sync_response_envelope.py +++ b/src/polytomic/types/model_sync_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .model_sync_response import ModelSyncResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .model_sync_response import ModelSyncResponse class ModelSyncResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/model_sync_source_meta_response.py b/src/polytomic/types/model_sync_source_meta_response.py index 552befd..7d5744f 100644 --- a/src/polytomic/types/model_sync_source_meta_response.py +++ b/src/polytomic/types/model_sync_source_meta_response.py @@ -1,15 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .configuration_value import ConfigurationValue -from .source_meta import SourceMeta -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .configuration_value_2 import ConfigurationValue2 +from .source_meta import SourceMeta class ModelSyncSourceMetaResponse(UniversalBaseModel): - configuration: typing.Optional[typing.Dict[str, ConfigurationValue]] = None + configuration: typing.Optional[typing.Dict[str, ConfigurationValue2]] = None items: typing.Optional[typing.Dict[str, typing.Optional[SourceMeta]]] = None requires_one_of: typing.Optional[typing.List[str]] = None diff --git a/src/polytomic/types/organization.py b/src/polytomic/types/organization.py index 18977d0..4dafb5e 100644 --- a/src/polytomic/types/organization.py +++ b/src/polytomic/types/organization.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class Organization(UniversalBaseModel): diff --git a/src/polytomic/types/organization_envelope.py b/src/polytomic/types/organization_envelope.py index 11b776a..b9d553b 100644 --- a/src/polytomic/types/organization_envelope.py +++ b/src/polytomic/types/organization_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .organization import Organization -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .organization import Organization class OrganizationEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/organizations_envelope.py b/src/polytomic/types/organizations_envelope.py index 693c6e2..92c5f3d 100644 --- a/src/polytomic/types/organizations_envelope.py +++ b/src/polytomic/types/organizations_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .organization import Organization -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .organization import Organization class OrganizationsEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/override.py b/src/polytomic/types/override.py index b44a322..663c89c 100644 --- a/src/polytomic/types/override.py +++ b/src/polytomic/types/override.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .source import Source + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .filter_function import FilterFunction -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .source import Source class Override(UniversalBaseModel): @@ -20,8 +20,8 @@ class Override(UniversalBaseModel): """ function: typing.Optional[FilterFunction] = None - override: typing.Optional[typing.Optional[typing.Any]] = None - value: typing.Optional[typing.Optional[typing.Any]] = None + override: typing.Optional[typing.Any] = None + value: typing.Optional[typing.Any] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/polytomic/types/pagination.py b/src/polytomic/types/pagination.py index 518a988..9cb7746 100644 --- a/src/polytomic/types/pagination.py +++ b/src/polytomic/types/pagination.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class Pagination(UniversalBaseModel): diff --git a/src/polytomic/types/pagination_details.py b/src/polytomic/types/pagination_details.py index 72837f1..0ad515f 100644 --- a/src/polytomic/types/pagination_details.py +++ b/src/polytomic/types/pagination_details.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class PaginationDetails(UniversalBaseModel): diff --git a/src/polytomic/types/pagination_details_2.py b/src/polytomic/types/pagination_details_2.py new file mode 100644 index 0000000..3ff014a --- /dev/null +++ b/src/polytomic/types/pagination_details_2.py @@ -0,0 +1,19 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel + + +class PaginationDetails2(UniversalBaseModel): + next_page_token: typing.Optional[str] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/polytomic/types/pick_value.py b/src/polytomic/types/pick_value.py index 46e6fce..69ded4a 100644 --- a/src/polytomic/types/pick_value.py +++ b/src/polytomic/types/pick_value.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class PickValue(UniversalBaseModel): diff --git a/src/polytomic/types/policy_action.py b/src/polytomic/types/policy_action.py index b7a5614..93b7df2 100644 --- a/src/polytomic/types/policy_action.py +++ b/src/polytomic/types/policy_action.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class PolicyAction(UniversalBaseModel): diff --git a/src/polytomic/types/policy_response.py b/src/polytomic/types/policy_response.py index 91d3259..e29882e 100644 --- a/src/polytomic/types/policy_response.py +++ b/src/polytomic/types/policy_response.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .policy_action import PolicyAction -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .policy_action import PolicyAction class PolicyResponse(UniversalBaseModel): diff --git a/src/polytomic/types/policy_response_envelope.py b/src/polytomic/types/policy_response_envelope.py index a41c20c..b47df0a 100644 --- a/src/polytomic/types/policy_response_envelope.py +++ b/src/polytomic/types/policy_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .policy_response import PolicyResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .policy_response import PolicyResponse class PolicyResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/relation.py b/src/polytomic/types/relation.py index 2813968..0dd465e 100644 --- a/src/polytomic/types/relation.py +++ b/src/polytomic/types/relation.py @@ -1,16 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing_extensions import typing + +import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from ..core.serialization import FieldMetadata from .relation_to import RelationTo -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class Relation(UniversalBaseModel): - from_: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="from")] = None + from_: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="from"), pydantic.Field(alias="from") + ] = None to: typing.Optional[RelationTo] = None if IS_PYDANTIC_V2: diff --git a/src/polytomic/types/relation_to.py b/src/polytomic/types/relation_to.py index 4139bf1..64d1a67 100644 --- a/src/polytomic/types/relation_to.py +++ b/src/polytomic/types/relation_to.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class RelationTo(UniversalBaseModel): diff --git a/src/polytomic/types/rest_err_response.py b/src/polytomic/types/rest_err_response.py index 6cbc66f..9e7ec4c 100644 --- a/src/polytomic/types/rest_err_response.py +++ b/src/polytomic/types/rest_err_response.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class RestErrResponse(UniversalBaseModel): @@ -12,7 +12,7 @@ class RestErrResponse(UniversalBaseModel): Application-specific error code. """ - context: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) + context: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None) """ Application context. """ diff --git a/src/polytomic/types/role_list_response_envelope.py b/src/polytomic/types/role_list_response_envelope.py index 39f5468..3bc6487 100644 --- a/src/polytomic/types/role_list_response_envelope.py +++ b/src/polytomic/types/role_list_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .role_response import RoleResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .role_response import RoleResponse class RoleListResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/role_response.py b/src/polytomic/types/role_response.py index efd272c..534a596 100644 --- a/src/polytomic/types/role_response.py +++ b/src/polytomic/types/role_response.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class RoleResponse(UniversalBaseModel): diff --git a/src/polytomic/types/role_response_envelope.py b/src/polytomic/types/role_response_envelope.py index fee70d7..5ddab78 100644 --- a/src/polytomic/types/role_response_envelope.py +++ b/src/polytomic/types/role_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .role_response import RoleResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .role_response import RoleResponse class RoleResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/run_after.py b/src/polytomic/types/run_after.py index d3e5ea5..d59849a 100644 --- a/src/polytomic/types/run_after.py +++ b/src/polytomic/types/run_after.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class RunAfter(UniversalBaseModel): diff --git a/src/polytomic/types/schedule.py b/src/polytomic/types/schedule.py index c3525a2..2083b8a 100644 --- a/src/polytomic/types/schedule.py +++ b/src/polytomic/types/schedule.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .schedule_frequency import ScheduleFrequency -from .run_after import RunAfter + import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .run_after import RunAfter +from .schedule_frequency import ScheduleFrequency class Schedule(UniversalBaseModel): diff --git a/src/polytomic/types/schedule_envelope.py b/src/polytomic/types/schedule_envelope.py index e015142..c5769b7 100644 --- a/src/polytomic/types/schedule_envelope.py +++ b/src/polytomic/types/schedule_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .bulk_bulk_sync_schedule import BulkBulkSyncSchedule -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_bulk_sync_schedule import BulkBulkSyncSchedule class ScheduleEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/schedule_option_response.py b/src/polytomic/types/schedule_option_response.py index 1c7a29d..c9eaa02 100644 --- a/src/polytomic/types/schedule_option_response.py +++ b/src/polytomic/types/schedule_option_response.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .schedule_schedule_option import ScheduleScheduleOption -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .schedule_schedule_option import ScheduleScheduleOption class ScheduleOptionResponse(UniversalBaseModel): diff --git a/src/polytomic/types/schedule_option_response_envelope.py b/src/polytomic/types/schedule_option_response_envelope.py index 93f4e55..de35dc9 100644 --- a/src/polytomic/types/schedule_option_response_envelope.py +++ b/src/polytomic/types/schedule_option_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .schedule_option_response import ScheduleOptionResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .schedule_option_response import ScheduleOptionResponse class ScheduleOptionResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/schedule_schedule_option.py b/src/polytomic/types/schedule_schedule_option.py index cb8e768..ba4b121 100644 --- a/src/polytomic/types/schedule_schedule_option.py +++ b/src/polytomic/types/schedule_schedule_option.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .jsonschema_form import JsonschemaForm from .schedule_frequency import ScheduleFrequency -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class ScheduleScheduleOption(UniversalBaseModel): diff --git a/src/polytomic/types/schedules_envelope.py b/src/polytomic/types/schedules_envelope.py index 1e853d6..b7aed45 100644 --- a/src/polytomic/types/schedules_envelope.py +++ b/src/polytomic/types/schedules_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .bulk_bulk_sync_schedule import BulkBulkSyncSchedule -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_bulk_sync_schedule import BulkBulkSyncSchedule class SchedulesEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/schema.py b/src/polytomic/types/schema.py index ee95d24..d54646c 100644 --- a/src/polytomic/types/schema.py +++ b/src/polytomic/types/schema.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .schema_field import SchemaField -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .schema_field import SchemaField class Schema(UniversalBaseModel): diff --git a/src/polytomic/types/schema_association.py b/src/polytomic/types/schema_association.py index e87ed04..a2d62d1 100644 --- a/src/polytomic/types/schema_association.py +++ b/src/polytomic/types/schema_association.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class SchemaAssociation(UniversalBaseModel): diff --git a/src/polytomic/types/schema_configuration.py b/src/polytomic/types/schema_configuration.py index 530c3f4..9e0d61c 100644 --- a/src/polytomic/types/schema_configuration.py +++ b/src/polytomic/types/schema_configuration.py @@ -1,12 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing import datetime as dt +import typing + import pydantic -from .v_2_schema_configuration_fields_item import V2SchemaConfigurationFieldsItem +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .bulk_filter import BulkFilter -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .v_2_schema_configuration_fields_item import V2SchemaConfigurationFieldsItem class SchemaConfiguration(UniversalBaseModel): diff --git a/src/polytomic/types/schema_field.py b/src/polytomic/types/schema_field.py index 49a849e..8e4ae1c 100644 --- a/src/polytomic/types/schema_field.py +++ b/src/polytomic/types/schema_field.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .schema_association import SchemaAssociation + import pydantic -from .util_field_type import UtilFieldType -from .types_type import TypesType +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .pick_value import PickValue -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .schema_association import SchemaAssociation +from .types_type import TypesType +from .util_field_type import UtilFieldType class SchemaField(UniversalBaseModel): diff --git a/src/polytomic/types/schema_primary_key_override_input.py b/src/polytomic/types/schema_primary_key_override_input.py index 1965036..8e866a8 100644 --- a/src/polytomic/types/schema_primary_key_override_input.py +++ b/src/polytomic/types/schema_primary_key_override_input.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class SchemaPrimaryKeyOverrideInput(UniversalBaseModel): diff --git a/src/polytomic/types/schema_records_response_envelope.py b/src/polytomic/types/schema_records_response_envelope.py index 5131def..5378450 100644 --- a/src/polytomic/types/schema_records_response_envelope.py +++ b/src/polytomic/types/schema_records_response_envelope.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class SchemaRecordsResponseEnvelope(UniversalBaseModel): - data: typing.Optional[typing.List[typing.Dict[str, typing.Optional[typing.Any]]]] = None + data: typing.Optional[typing.List[typing.Dict[str, typing.Any]]] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/polytomic/types/source.py b/src/polytomic/types/source.py index f5e6def..5a6e3f4 100644 --- a/src/polytomic/types/source.py +++ b/src/polytomic/types/source.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class Source(UniversalBaseModel): diff --git a/src/polytomic/types/source_meta.py b/src/polytomic/types/source_meta.py index a447157..0d709de 100644 --- a/src/polytomic/types/source_meta.py +++ b/src/polytomic/types/source_meta.py @@ -1,14 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class SourceMeta(UniversalBaseModel): has_items: typing.Optional[bool] = None - items: typing.Optional[typing.List[typing.Optional[typing.Any]]] = None + items: typing.Optional[typing.List[typing.Any]] = None requires_one_of: typing.Optional[typing.List[str]] = None if IS_PYDANTIC_V2: diff --git a/src/polytomic/types/start_model_sync_response_envelope.py b/src/polytomic/types/start_model_sync_response_envelope.py index f6b46c2..37a0179 100644 --- a/src/polytomic/types/start_model_sync_response_envelope.py +++ b/src/polytomic/types/start_model_sync_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .start_model_sync_response_schema import StartModelSyncResponseSchema -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .start_model_sync_response_schema import StartModelSyncResponseSchema class StartModelSyncResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/start_model_sync_response_schema.py b/src/polytomic/types/start_model_sync_response_schema.py index e1be713..7949e55 100644 --- a/src/polytomic/types/start_model_sync_response_schema.py +++ b/src/polytomic/types/start_model_sync_response_schema.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing import datetime as dt +import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .execution_status import ExecutionStatus -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class StartModelSyncResponseSchema(UniversalBaseModel): diff --git a/src/polytomic/types/supported_bulk_mode.py b/src/polytomic/types/supported_bulk_mode.py index 04c9eac..f84bde9 100644 --- a/src/polytomic/types/supported_bulk_mode.py +++ b/src/polytomic/types/supported_bulk_mode.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .bulk_sync_mode import BulkSyncMode -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .bulk_sync_mode import BulkSyncMode class SupportedBulkMode(UniversalBaseModel): diff --git a/src/polytomic/types/supported_mode.py b/src/polytomic/types/supported_mode.py index ff34d79..8200dbb 100644 --- a/src/polytomic/types/supported_mode.py +++ b/src/polytomic/types/supported_mode.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .model_sync_mode import ModelSyncMode + import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .model_sync_mode import ModelSyncMode class SupportedMode(UniversalBaseModel): diff --git a/src/polytomic/types/sync_canceled_event.py b/src/polytomic/types/sync_canceled_event.py index caf552e..09e68fc 100644 --- a/src/polytomic/types/sync_canceled_event.py +++ b/src/polytomic/types/sync_canceled_event.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .execution_status import ExecutionStatus -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .execution_status import ExecutionStatus class SyncCanceledEvent(UniversalBaseModel): diff --git a/src/polytomic/types/sync_completed_event.py b/src/polytomic/types/sync_completed_event.py index 64e935c..68dd99d 100644 --- a/src/polytomic/types/sync_completed_event.py +++ b/src/polytomic/types/sync_completed_event.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .execution_status import ExecutionStatus -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .execution_status import ExecutionStatus class SyncCompletedEvent(UniversalBaseModel): diff --git a/src/polytomic/types/sync_completed_with_errors_event.py b/src/polytomic/types/sync_completed_with_errors_event.py index ad86808..6a0821c 100644 --- a/src/polytomic/types/sync_completed_with_errors_event.py +++ b/src/polytomic/types/sync_completed_with_errors_event.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class SyncCompletedWithErrorsEvent(UniversalBaseModel): diff --git a/src/polytomic/types/sync_destination_properties.py b/src/polytomic/types/sync_destination_properties.py index e11a17f..46a1560 100644 --- a/src/polytomic/types/sync_destination_properties.py +++ b/src/polytomic/types/sync_destination_properties.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class SyncDestinationProperties(UniversalBaseModel): diff --git a/src/polytomic/types/sync_failed_event.py b/src/polytomic/types/sync_failed_event.py index c345f09..f8b50da 100644 --- a/src/polytomic/types/sync_failed_event.py +++ b/src/polytomic/types/sync_failed_event.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class SyncFailedEvent(UniversalBaseModel): diff --git a/src/polytomic/types/sync_running_event.py b/src/polytomic/types/sync_running_event.py index a79fc2b..91c510a 100644 --- a/src/polytomic/types/sync_running_event.py +++ b/src/polytomic/types/sync_running_event.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class SyncRunningEvent(UniversalBaseModel): diff --git a/src/polytomic/types/sync_status_envelope.py b/src/polytomic/types/sync_status_envelope.py index 2e6ca0a..d86b066 100644 --- a/src/polytomic/types/sync_status_envelope.py +++ b/src/polytomic/types/sync_status_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .sync_status_response import SyncStatusResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .sync_status_response import SyncStatusResponse class SyncStatusEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/sync_status_response.py b/src/polytomic/types/sync_status_response.py index 0b48c5d..c52413f 100644 --- a/src/polytomic/types/sync_status_response.py +++ b/src/polytomic/types/sync_status_response.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing -from .get_execution_response_schema import GetExecutionResponseSchema import datetime as dt -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .get_execution_response_schema import GetExecutionResponseSchema class SyncStatusResponse(UniversalBaseModel): diff --git a/src/polytomic/types/target.py b/src/polytomic/types/target.py index a93eff5..032789b 100644 --- a/src/polytomic/types/target.py +++ b/src/polytomic/types/target.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class Target(UniversalBaseModel): - configuration: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None + configuration: typing.Optional[typing.Dict[str, typing.Any]] = None connection_id: str create: typing.Optional[typing.Dict[str, str]] = pydantic.Field(default=None) """ @@ -21,7 +21,7 @@ class Target(UniversalBaseModel): """ object: typing.Optional[str] = None - search_values: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None + search_values: typing.Optional[typing.Dict[str, typing.Any]] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/polytomic/types/target_create_input.py b/src/polytomic/types/target_create_input.py index 28d612c..b9b847c 100644 --- a/src/polytomic/types/target_create_input.py +++ b/src/polytomic/types/target_create_input.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class TargetCreateInput(UniversalBaseModel): diff --git a/src/polytomic/types/target_field.py b/src/polytomic/types/target_field.py index 3f7c044..2b702cd 100644 --- a/src/polytomic/types/target_field.py +++ b/src/polytomic/types/target_field.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .identity_function import IdentityFunction -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .identity_function import IdentityFunction class TargetField(UniversalBaseModel): diff --git a/src/polytomic/types/target_object.py b/src/polytomic/types/target_object.py index c0f677e..a501646 100644 --- a/src/polytomic/types/target_object.py +++ b/src/polytomic/types/target_object.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .supported_mode import SupportedMode -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class TargetObject(UniversalBaseModel): diff --git a/src/polytomic/types/target_response.py b/src/polytomic/types/target_response.py index 476b504..4c87111 100644 --- a/src/polytomic/types/target_response.py +++ b/src/polytomic/types/target_response.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel +import datetime as dt import typing -from .target_field import TargetField + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .mode import Mode from .sync_destination_properties import SyncDestinationProperties -import datetime as dt -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic +from .target_field import TargetField class TargetResponse(UniversalBaseModel): diff --git a/src/polytomic/types/target_response_envelope.py b/src/polytomic/types/target_response_envelope.py index c5659f6..ff3fae2 100644 --- a/src/polytomic/types/target_response_envelope.py +++ b/src/polytomic/types/target_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .target_response import TargetResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .target_response import TargetResponse class TargetResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/types_type.py b/src/polytomic/types/types_type.py index f6a5e97..80cee50 100644 --- a/src/polytomic/types/types_type.py +++ b/src/polytomic/types/types_type.py @@ -2,4 +2,4 @@ import typing -TypesType = typing.Optional[typing.Any] +TypesType = typing.Any diff --git a/src/polytomic/types/update_bulk_field.py b/src/polytomic/types/update_bulk_field.py index f2c7159..650391c 100644 --- a/src/polytomic/types/update_bulk_field.py +++ b/src/polytomic/types/update_bulk_field.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class UpdateBulkField(UniversalBaseModel): diff --git a/src/polytomic/types/user.py b/src/polytomic/types/user.py index 083f885..c93e837 100644 --- a/src/polytomic/types/user.py +++ b/src/polytomic/types/user.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class User(UniversalBaseModel): diff --git a/src/polytomic/types/user_envelope.py b/src/polytomic/types/user_envelope.py index ace238e..7b10bd2 100644 --- a/src/polytomic/types/user_envelope.py +++ b/src/polytomic/types/user_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .user import User -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .user import User class UserEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/util_enum_value.py b/src/polytomic/types/util_enum_value.py index 45f4a2f..96c593e 100644 --- a/src/polytomic/types/util_enum_value.py +++ b/src/polytomic/types/util_enum_value.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class UtilEnumValue(UniversalBaseModel): diff --git a/src/polytomic/types/v_2_connection_form.py b/src/polytomic/types/v_2_connection_form.py index 6367fb0..792b50f 100644 --- a/src/polytomic/types/v_2_connection_form.py +++ b/src/polytomic/types/v_2_connection_form.py @@ -1,14 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class V2ConnectionForm(UniversalBaseModel): - jsonschema: typing.Optional[typing.Optional[typing.Any]] = None - uischema: typing.Optional[typing.Optional[typing.Any]] = None + jsonschema: typing.Optional[typing.Any] = None + uischema: typing.Optional[typing.Any] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/polytomic/types/v_2_create_shared_connection_response_envelope.py b/src/polytomic/types/v_2_create_shared_connection_response_envelope.py index 95cb4fc..f6b4954 100644 --- a/src/polytomic/types/v_2_create_shared_connection_response_envelope.py +++ b/src/polytomic/types/v_2_create_shared_connection_response_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .create_shared_connection_response_schema import CreateSharedConnectionResponseSchema -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .create_shared_connection_response_schema import CreateSharedConnectionResponseSchema class V2CreateSharedConnectionResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/v_2_enricher_configuration.py b/src/polytomic/types/v_2_enricher_configuration.py index 1214385..cfa4286 100644 --- a/src/polytomic/types/v_2_enricher_configuration.py +++ b/src/polytomic/types/v_2_enricher_configuration.py @@ -2,4 +2,4 @@ import typing -V2EnricherConfiguration = typing.Dict[str, typing.Optional[typing.Any]] +V2EnricherConfiguration = typing.Dict[str, typing.Any] diff --git a/src/polytomic/types/v_2_get_enrichment_input_fields_response_envelope.py b/src/polytomic/types/v_2_get_enrichment_input_fields_response_envelope.py index dc92c55..74e9752 100644 --- a/src/polytomic/types/v_2_get_enrichment_input_fields_response_envelope.py +++ b/src/polytomic/types/v_2_get_enrichment_input_fields_response_envelope.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class V2GetEnrichmentInputFieldsResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/v_2_ordered_map_string_github_com_invopop_jsonschema_schema.py b/src/polytomic/types/v_2_ordered_map_string_github_com_invopop_jsonschema_schema.py index 89313f5..5858b2f 100644 --- a/src/polytomic/types/v_2_ordered_map_string_github_com_invopop_jsonschema_schema.py +++ b/src/polytomic/types/v_2_ordered_map_string_github_com_invopop_jsonschema_schema.py @@ -2,4 +2,4 @@ import typing -V2OrderedMapStringGithubComInvopopJsonschemaSchema = typing.Dict[str, typing.Optional[typing.Any]] +V2OrderedMapStringGithubComInvopopJsonschemaSchema = typing.Dict[str, typing.Any] diff --git a/src/polytomic/types/v_2_sample_record.py b/src/polytomic/types/v_2_sample_record.py index adffdae..15fcf2b 100644 --- a/src/polytomic/types/v_2_sample_record.py +++ b/src/polytomic/types/v_2_sample_record.py @@ -2,4 +2,4 @@ import typing -V2SampleRecord = typing.Dict[str, typing.Dict[str, typing.Optional[typing.Any]]] +V2SampleRecord = typing.Dict[str, typing.Dict[str, typing.Any]] diff --git a/src/polytomic/types/v_2_schema_configuration_fields_item.py b/src/polytomic/types/v_2_schema_configuration_fields_item.py index 6dd310f..c678f3f 100644 --- a/src/polytomic/types/v_2_schema_configuration_fields_item.py +++ b/src/polytomic/types/v_2_schema_configuration_fields_item.py @@ -1,6 +1,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .field_configuration import FieldConfiguration V2SchemaConfigurationFieldsItem = typing.Union[str, FieldConfiguration] diff --git a/src/polytomic/types/v_4_bulk_sync_execution_logs.py b/src/polytomic/types/v_4_bulk_sync_execution_logs.py index 1823436..1a498cf 100644 --- a/src/polytomic/types/v_4_bulk_sync_execution_logs.py +++ b/src/polytomic/types/v_4_bulk_sync_execution_logs.py @@ -2,4 +2,4 @@ import typing -V4BulkSyncExecutionLogs = typing.Dict[str, typing.Optional[typing.Any]] +V4BulkSyncExecutionLogs = typing.Dict[str, typing.Any] diff --git a/src/polytomic/types/v_4_bulk_sync_execution_logs_envelope.py b/src/polytomic/types/v_4_bulk_sync_execution_logs_envelope.py index dc1a325..acdf15e 100644 --- a/src/polytomic/types/v_4_bulk_sync_execution_logs_envelope.py +++ b/src/polytomic/types/v_4_bulk_sync_execution_logs_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .v_4_bulk_sync_execution_logs import V4BulkSyncExecutionLogs -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .v_4_bulk_sync_execution_logs import V4BulkSyncExecutionLogs class V4BulkSyncExecutionLogsEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/v_4_bulk_sync_schedule_api.py b/src/polytomic/types/v_4_bulk_sync_schedule_api.py index a27ff01..33402f5 100644 --- a/src/polytomic/types/v_4_bulk_sync_schedule_api.py +++ b/src/polytomic/types/v_4_bulk_sync_schedule_api.py @@ -1,24 +1,28 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing_extensions import typing + +import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from ..core.serialization import FieldMetadata -from .schedule_frequency import ScheduleFrequency from .bulk_selective_mode import BulkSelectiveMode -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic +from .schedule_frequency import ScheduleFrequency class V4BulkSyncScheduleApi(UniversalBaseModel): - day_of_month: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="dayOfMonth")] = None - day_of_week: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="dayOfWeek")] = None + day_of_month: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="dayOfMonth"), pydantic.Field(alias="dayOfMonth") + ] = None + day_of_week: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="dayOfWeek"), pydantic.Field(alias="dayOfWeek") + ] = None frequency: ScheduleFrequency hour: typing.Optional[str] = None minute: typing.Optional[str] = None month: typing.Optional[str] = None selective_mode: typing_extensions.Annotated[ - typing.Optional[BulkSelectiveMode], FieldMetadata(alias="selectiveMode") + typing.Optional[BulkSelectiveMode], FieldMetadata(alias="selectiveMode"), pydantic.Field(alias="selectiveMode") ] = None if IS_PYDANTIC_V2: diff --git a/src/polytomic/types/v_4_export_sync_logs_envelope.py b/src/polytomic/types/v_4_export_sync_logs_envelope.py index c4d35c0..b55f7d1 100644 --- a/src/polytomic/types/v_4_export_sync_logs_envelope.py +++ b/src/polytomic/types/v_4_export_sync_logs_envelope.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .v_4_export_sync_logs_response import V4ExportSyncLogsResponse -from .job_response import JobResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .job_response import JobResponse +from .v_4_export_sync_logs_response import V4ExportSyncLogsResponse class V4ExportSyncLogsEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/v_4_export_sync_logs_response.py b/src/polytomic/types/v_4_export_sync_logs_response.py index 340ce7c..d58f774 100644 --- a/src/polytomic/types/v_4_export_sync_logs_response.py +++ b/src/polytomic/types/v_4_export_sync_logs_response.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class V4ExportSyncLogsResponse(UniversalBaseModel): diff --git a/src/polytomic/types/v_4_global_error_subscribers_response.py b/src/polytomic/types/v_4_global_error_subscribers_response.py index ba58346..8de41cf 100644 --- a/src/polytomic/types/v_4_global_error_subscribers_response.py +++ b/src/polytomic/types/v_4_global_error_subscribers_response.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class V4GlobalErrorSubscribersResponse(UniversalBaseModel): diff --git a/src/polytomic/types/v_4_query_results_envelope.py b/src/polytomic/types/v_4_query_results_envelope.py index ddadfc2..bb7dcd3 100644 --- a/src/polytomic/types/v_4_query_results_envelope.py +++ b/src/polytomic/types/v_4_query_results_envelope.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .v_4_run_query_result import V4RunQueryResult -from .pagination import Pagination -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .pagination import Pagination +from .v_4_run_query_result import V4RunQueryResult class V4QueryResultsEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/v_4_run_query_envelope.py b/src/polytomic/types/v_4_run_query_envelope.py index 9e16f20..305d1ea 100644 --- a/src/polytomic/types/v_4_run_query_envelope.py +++ b/src/polytomic/types/v_4_run_query_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .v_4_run_query_result import V4RunQueryResult -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .v_4_run_query_result import V4RunQueryResult class V4RunQueryEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/v_4_run_query_result.py b/src/polytomic/types/v_4_run_query_result.py index f33eaae..baea0df 100644 --- a/src/polytomic/types/v_4_run_query_result.py +++ b/src/polytomic/types/v_4_run_query_result.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .work_task_status import WorkTaskStatus -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class V4RunQueryResult(UniversalBaseModel): @@ -26,10 +26,10 @@ class V4RunQueryResult(UniversalBaseModel): id: typing.Optional[str] = pydantic.Field(default=None) """ - The ID of the query task. + The ID of the query task. Poll GET /api/queries/{id} until the task reaches done or failed to retrieve results. """ - results: typing.Optional[typing.List[typing.Dict[str, typing.Optional[typing.Any]]]] = pydantic.Field(default=None) + results: typing.Optional[typing.List[typing.Dict[str, typing.Any]]] = pydantic.Field(default=None) """ The query results, returned as an array of objects. """ diff --git a/src/polytomic/types/v_4_target_creator.py b/src/polytomic/types/v_4_target_creator.py index 644dc2c..9c625ba 100644 --- a/src/polytomic/types/v_4_target_creator.py +++ b/src/polytomic/types/v_4_target_creator.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .target_create_input import TargetCreateInput + import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .target_create_input import TargetCreateInput class V4TargetCreator(UniversalBaseModel): diff --git a/src/polytomic/types/v_4_target_objects_response_envelope.py b/src/polytomic/types/v_4_target_objects_response_envelope.py index 178d0f9..80789a0 100644 --- a/src/polytomic/types/v_4_target_objects_response_envelope.py +++ b/src/polytomic/types/v_4_target_objects_response_envelope.py @@ -1,11 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .target_object import TargetObject from .v_4_target_creator import V4TargetCreator -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class V4TargetObjectsResponseEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/v_4_target_property_values.py b/src/polytomic/types/v_4_target_property_values.py index ff4173e..2668888 100644 --- a/src/polytomic/types/v_4_target_property_values.py +++ b/src/polytomic/types/v_4_target_property_values.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .util_enum_value import UtilEnumValue -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class V4TargetPropertyValues(UniversalBaseModel): diff --git a/src/polytomic/types/v_4_target_property_values_envelope.py b/src/polytomic/types/v_4_target_property_values_envelope.py index 1986743..480bfcc 100644 --- a/src/polytomic/types/v_4_target_property_values_envelope.py +++ b/src/polytomic/types/v_4_target_property_values_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .v_4_target_property_values import V4TargetPropertyValues -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .v_4_target_property_values import V4TargetPropertyValues class V4TargetPropertyValuesEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/v_4_user_field_request.py b/src/polytomic/types/v_4_user_field_request.py index 84ac40d..0979381 100644 --- a/src/polytomic/types/v_4_user_field_request.py +++ b/src/polytomic/types/v_4_user_field_request.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class V4UserFieldRequest(UniversalBaseModel): - example: typing.Optional[typing.Optional[typing.Any]] = None + example: typing.Optional[typing.Any] = None field_id: str label: str path: typing.Optional[str] = None diff --git a/src/polytomic/types/webhook.py b/src/polytomic/types/webhook.py index 0aaa250..7a28f28 100644 --- a/src/polytomic/types/webhook.py +++ b/src/polytomic/types/webhook.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel -import typing import datetime as dt -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel class Webhook(UniversalBaseModel): diff --git a/src/polytomic/types/webhook_envelope.py b/src/polytomic/types/webhook_envelope.py index 442d571..d98c9e7 100644 --- a/src/polytomic/types/webhook_envelope.py +++ b/src/polytomic/types/webhook_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .webhook import Webhook -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .webhook import Webhook class WebhookEnvelope(UniversalBaseModel): diff --git a/src/polytomic/types/webhook_list_envelope.py b/src/polytomic/types/webhook_list_envelope.py index 8e6c30d..e39c78e 100644 --- a/src/polytomic/types/webhook_list_envelope.py +++ b/src/polytomic/types/webhook_list_envelope.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.pydantic_utilities import UniversalBaseModel import typing -from .webhook import Webhook -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .webhook import Webhook class WebhookListEnvelope(UniversalBaseModel): diff --git a/src/polytomic/users/__init__.py b/src/polytomic/users/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/users/__init__.py +++ b/src/polytomic/users/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/users/client.py b/src/polytomic/users/client.py index a1cf052..2d5a7db 100644 --- a/src/polytomic/users/client.py +++ b/src/polytomic/users/client.py @@ -1,23 +1,13 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.api_key_response_envelope import ApiKeyResponseEnvelope from ..types.list_users_envelope import ListUsersEnvelope -from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import parse_obj_as -from ..errors.unauthorized_error import UnauthorizedError -from ..types.rest_err_response import RestErrResponse -from ..errors.forbidden_error import ForbiddenError -from ..types.api_error import ApiError as types_api_error_ApiError -from ..errors.not_found_error import NotFoundError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError as core_api_error_ApiError from ..types.user_envelope import UserEnvelope -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..errors.internal_server_error import InternalServerError -from ..types.api_key_response_envelope import ApiKeyResponseEnvelope -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawUsersClient, RawUsersClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -25,7 +15,18 @@ class UsersClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawUsersClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawUsersClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawUsersClient + """ + return self._raw_client def list(self, org_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ListUsersEnvelope: """ @@ -53,54 +54,8 @@ def list(self, org_id: str, *, request_options: typing.Optional[RequestOptions] org_id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(org_id)}/users", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListUsersEnvelope, - parse_obj_as( - type_=ListUsersEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.list(org_id, request_options=request_options) + return _response.data def create( self, @@ -143,82 +98,19 @@ def create( email="mail@example.com", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(org_id)}/users", - method="POST", - json={ - "email": email, - "role": role, - "role_ids": role_ids, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.create( + org_id, email=email, role=role, role_ids=role_ids, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - UserEnvelope, - parse_obj_as( - type_=UserEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) - - def get(self, id: str, org_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> UserEnvelope: + return _response.data + + def get(self, org_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> UserEnvelope: """ Parameters ---------- - id : str - org_id : str + id : str + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -236,73 +128,17 @@ def get(self, id: str, org_id: str, *, request_options: typing.Optional[RequestO token="YOUR_TOKEN", ) client.users.get( - id="248df4b7-aa70-47b8-a036-33ac447e668d", org_id="248df4b7-aa70-47b8-a036-33ac447e668d", + id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - UserEnvelope, - parse_obj_as( - type_=UserEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(org_id, id, request_options=request_options) + return _response.data def update( self, - id: str, org_id: str, + id: str, *, email: str, role: typing.Optional[str] = OMIT, @@ -312,10 +148,10 @@ def update( """ Parameters ---------- - id : str - org_id : str + id : str + email : str role : typing.Optional[str] @@ -339,87 +175,24 @@ def update( token="YOUR_TOKEN", ) client.users.update( - id="248df4b7-aa70-47b8-a036-33ac447e668d", org_id="248df4b7-aa70-47b8-a036-33ac447e668d", + id="248df4b7-aa70-47b8-a036-33ac447e668d", email="mail@example.com", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}", - method="PUT", - json={ - "email": email, - "role": role, - "role_ids": role_ids, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.update( + org_id, id, email=email, role=role, role_ids=role_ids, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - UserEnvelope, - parse_obj_as( - type_=UserEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) - - def remove(self, id: str, org_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> UserEnvelope: + return _response.data + + def remove(self, org_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> UserEnvelope: """ Parameters ---------- - id : str - org_id : str + id : str + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -437,68 +210,12 @@ def remove(self, id: str, org_id: str, *, request_options: typing.Optional[Reque token="YOUR_TOKEN", ) client.users.remove( - id="248df4b7-aa70-47b8-a036-33ac447e668d", org_id="248df4b7-aa70-47b8-a036-33ac447e668d", + id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - UserEnvelope, - parse_obj_as( - type_=UserEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.remove(org_id, id, request_options=request_options) + return _response.data def create_api_key( self, @@ -543,62 +260,24 @@ def create_api_key( force=True, ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}/keys", - method="POST", - params={ - "force": force, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ApiKeyResponseEnvelope, - parse_obj_as( - type_=ApiKeyResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.create_api_key(org_id, id, force=force, request_options=request_options) + return _response.data class AsyncUsersClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawUsersClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawUsersClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawUsersClient + """ + return self._raw_client async def list(self, org_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ListUsersEnvelope: """ @@ -634,54 +313,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(org_id)}/users", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ListUsersEnvelope, - parse_obj_as( - type_=ListUsersEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.list(org_id, request_options=request_options) + return _response.data async def create( self, @@ -732,84 +365,21 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(org_id)}/users", - method="POST", - json={ - "email": email, - "role": role, - "role_ids": role_ids, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.create( + org_id, email=email, role=role, role_ids=role_ids, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - UserEnvelope, - parse_obj_as( - type_=UserEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get( - self, id: str, org_id: str, *, request_options: typing.Optional[RequestOptions] = None + self, org_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> UserEnvelope: """ Parameters ---------- - id : str - org_id : str + id : str + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -832,76 +402,20 @@ async def get( async def main() -> None: await client.users.get( - id="248df4b7-aa70-47b8-a036-33ac447e668d", org_id="248df4b7-aa70-47b8-a036-33ac447e668d", + id="248df4b7-aa70-47b8-a036-33ac447e668d", ) asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - UserEnvelope, - parse_obj_as( - type_=UserEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(org_id, id, request_options=request_options) + return _response.data async def update( self, - id: str, org_id: str, + id: str, *, email: str, role: typing.Optional[str] = OMIT, @@ -911,10 +425,10 @@ async def update( """ Parameters ---------- - id : str - org_id : str + id : str + email : str role : typing.Optional[str] @@ -943,92 +457,29 @@ async def update( async def main() -> None: await client.users.update( - id="248df4b7-aa70-47b8-a036-33ac447e668d", org_id="248df4b7-aa70-47b8-a036-33ac447e668d", + id="248df4b7-aa70-47b8-a036-33ac447e668d", email="mail@example.com", ) asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}", - method="PUT", - json={ - "email": email, - "role": role, - "role_ids": role_ids, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.update( + org_id, id, email=email, role=role, role_ids=role_ids, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - UserEnvelope, - parse_obj_as( - type_=UserEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def remove( - self, id: str, org_id: str, *, request_options: typing.Optional[RequestOptions] = None + self, org_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> UserEnvelope: """ Parameters ---------- - id : str - org_id : str + id : str + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1051,71 +502,15 @@ async def remove( async def main() -> None: await client.users.remove( - id="248df4b7-aa70-47b8-a036-33ac447e668d", org_id="248df4b7-aa70-47b8-a036-33ac447e668d", + id="248df4b7-aa70-47b8-a036-33ac447e668d", ) asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - UserEnvelope, - parse_obj_as( - type_=UserEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.remove(org_id, id, request_options=request_options) + return _response.data async def create_api_key( self, @@ -1168,54 +563,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}/keys", - method="POST", - params={ - "force": force, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ApiKeyResponseEnvelope, - parse_obj_as( - type_=ApiKeyResponseEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.create_api_key(org_id, id, force=force, request_options=request_options) + return _response.data diff --git a/src/polytomic/users/raw_client.py b/src/polytomic/users/raw_client.py new file mode 100644 index 0000000..34f9e51 --- /dev/null +++ b/src/polytomic/users/raw_client.py @@ -0,0 +1,1200 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError as core_api_error_ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..errors.forbidden_error import ForbiddenError +from ..errors.internal_server_error import InternalServerError +from ..errors.not_found_error import NotFoundError +from ..errors.unauthorized_error import UnauthorizedError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.api_error import ApiError as types_api_error_ApiError +from ..types.api_key_response_envelope import ApiKeyResponseEnvelope +from ..types.list_users_envelope import ListUsersEnvelope +from ..types.rest_err_response import RestErrResponse +from ..types.user_envelope import UserEnvelope +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawUsersClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, org_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ListUsersEnvelope]: + """ + Parameters + ---------- + org_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ListUsersEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(org_id)}/users", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListUsersEnvelope, + parse_obj_as( + type_=ListUsersEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def create( + self, + org_id: str, + *, + email: str, + role: typing.Optional[str] = OMIT, + role_ids: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[UserEnvelope]: + """ + Parameters + ---------- + org_id : str + + email : str + + role : typing.Optional[str] + + role_ids : typing.Optional[typing.Sequence[str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[UserEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(org_id)}/users", + method="POST", + json={ + "email": email, + "role": role, + "role_ids": role_ids, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UserEnvelope, + parse_obj_as( + type_=UserEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get( + self, org_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[UserEnvelope]: + """ + Parameters + ---------- + org_id : str + + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[UserEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UserEnvelope, + parse_obj_as( + type_=UserEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def update( + self, + org_id: str, + id: str, + *, + email: str, + role: typing.Optional[str] = OMIT, + role_ids: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[UserEnvelope]: + """ + Parameters + ---------- + org_id : str + + id : str + + email : str + + role : typing.Optional[str] + + role_ids : typing.Optional[typing.Sequence[str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[UserEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}", + method="PUT", + json={ + "email": email, + "role": role, + "role_ids": role_ids, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UserEnvelope, + parse_obj_as( + type_=UserEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def remove( + self, org_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[UserEnvelope]: + """ + Parameters + ---------- + org_id : str + + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[UserEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UserEnvelope, + parse_obj_as( + type_=UserEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def create_api_key( + self, + org_id: str, + id: str, + *, + force: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ApiKeyResponseEnvelope]: + """ + > 🚧 Requires partner key + > + > User endpoints are only accessible using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + + Parameters + ---------- + org_id : str + + id : str + + force : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ApiKeyResponseEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}/keys", + method="POST", + params={ + "force": force, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ApiKeyResponseEnvelope, + parse_obj_as( + type_=ApiKeyResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawUsersClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, org_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ListUsersEnvelope]: + """ + Parameters + ---------- + org_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ListUsersEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(org_id)}/users", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ListUsersEnvelope, + parse_obj_as( + type_=ListUsersEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def create( + self, + org_id: str, + *, + email: str, + role: typing.Optional[str] = OMIT, + role_ids: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[UserEnvelope]: + """ + Parameters + ---------- + org_id : str + + email : str + + role : typing.Optional[str] + + role_ids : typing.Optional[typing.Sequence[str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[UserEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(org_id)}/users", + method="POST", + json={ + "email": email, + "role": role, + "role_ids": role_ids, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UserEnvelope, + parse_obj_as( + type_=UserEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, org_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[UserEnvelope]: + """ + Parameters + ---------- + org_id : str + + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[UserEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UserEnvelope, + parse_obj_as( + type_=UserEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def update( + self, + org_id: str, + id: str, + *, + email: str, + role: typing.Optional[str] = OMIT, + role_ids: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[UserEnvelope]: + """ + Parameters + ---------- + org_id : str + + id : str + + email : str + + role : typing.Optional[str] + + role_ids : typing.Optional[typing.Sequence[str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[UserEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}", + method="PUT", + json={ + "email": email, + "role": role, + "role_ids": role_ids, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UserEnvelope, + parse_obj_as( + type_=UserEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def remove( + self, org_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[UserEnvelope]: + """ + Parameters + ---------- + org_id : str + + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[UserEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UserEnvelope, + parse_obj_as( + type_=UserEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def create_api_key( + self, + org_id: str, + id: str, + *, + force: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ApiKeyResponseEnvelope]: + """ + > 🚧 Requires partner key + > + > User endpoints are only accessible using [partner keys](https://apidocs.polytomic.com/guides/obtaining-api-keys#partner-keys). + + Parameters + ---------- + org_id : str + + id : str + + force : typing.Optional[bool] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ApiKeyResponseEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/organizations/{jsonable_encoder(org_id)}/users/{jsonable_encoder(id)}/keys", + method="POST", + params={ + "force": force, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ApiKeyResponseEnvelope, + parse_obj_as( + type_=ApiKeyResponseEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/polytomic/webhooks/__init__.py b/src/polytomic/webhooks/__init__.py index f3ea265..5cde020 100644 --- a/src/polytomic/webhooks/__init__.py +++ b/src/polytomic/webhooks/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/polytomic/webhooks/client.py b/src/polytomic/webhooks/client.py index e50958d..b9aa45f 100644 --- a/src/polytomic/webhooks/client.py +++ b/src/polytomic/webhooks/client.py @@ -1,21 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions -from ..types.webhook_list_envelope import WebhookListEnvelope -from ..core.pydantic_utilities import parse_obj_as -from ..errors.unauthorized_error import UnauthorizedError -from ..types.rest_err_response import RestErrResponse -from ..errors.internal_server_error import InternalServerError -from ..types.api_error import ApiError as types_api_error_ApiError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError as core_api_error_ApiError from ..types.webhook_envelope import WebhookEnvelope -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..core.jsonable_encoder import jsonable_encoder -from ..errors.not_found_error import NotFoundError -from ..core.client_wrapper import AsyncClientWrapper +from ..types.webhook_list_envelope import WebhookListEnvelope +from .raw_client import AsyncRawWebhooksClient, RawWebhooksClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -23,7 +14,18 @@ class WebhooksClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawWebhooksClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawWebhooksClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawWebhooksClient + """ + return self._raw_client def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> WebhookListEnvelope: """ @@ -53,44 +55,8 @@ def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> We ) client.webhooks.list() """ - _response = self._client_wrapper.httpx_client.request( - "api/webhooks", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - WebhookListEnvelope, - parse_obj_as( - type_=WebhookListEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.list(request_options=request_options) + return _response.data def create( self, @@ -136,63 +102,10 @@ def create( secret="secret", ) """ - _response = self._client_wrapper.httpx_client.request( - "api/webhooks", - method="POST", - json={ - "endpoint": endpoint, - "organization_id": organization_id, - "secret": secret, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.create( + endpoint=endpoint, secret=secret, organization_id=organization_id, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - WebhookEnvelope, - parse_obj_as( - type_=WebhookEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> WebhookEnvelope: """ @@ -226,44 +139,8 @@ def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = Non id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/webhooks/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - WebhookEnvelope, - parse_obj_as( - type_=WebhookEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(id, request_options=request_options) + return _response.data def update( self, @@ -313,63 +190,10 @@ def update( secret="secret", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/webhooks/{jsonable_encoder(id)}", - method="PUT", - json={ - "endpoint": endpoint, - "organization_id": organization_id, - "secret": secret, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.update( + id, endpoint=endpoint, secret=secret, organization_id=organization_id, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - WebhookEnvelope, - parse_obj_as( - type_=WebhookEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ @@ -396,48 +220,8 @@ def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/webhooks/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.remove(id, request_options=request_options) + return _response.data def disable(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> WebhookEnvelope: """ @@ -465,54 +249,8 @@ def disable(self, id: str, *, request_options: typing.Optional[RequestOptions] = id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/webhooks/{jsonable_encoder(id)}/disable", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - WebhookEnvelope, - parse_obj_as( - type_=WebhookEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.disable(id, request_options=request_options) + return _response.data def enable(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> WebhookEnvelope: """ @@ -540,59 +278,24 @@ def enable(self, id: str, *, request_options: typing.Optional[RequestOptions] = id="248df4b7-aa70-47b8-a036-33ac447e668d", ) """ - _response = self._client_wrapper.httpx_client.request( - f"api/webhooks/{jsonable_encoder(id)}/enable", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - WebhookEnvelope, - parse_obj_as( - type_=WebhookEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.enable(id, request_options=request_options) + return _response.data class AsyncWebhooksClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawWebhooksClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawWebhooksClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawWebhooksClient + """ + return self._raw_client async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> WebhookListEnvelope: """ @@ -630,44 +333,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/webhooks", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - WebhookListEnvelope, - parse_obj_as( - type_=WebhookListEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.list(request_options=request_options) + return _response.data async def create( self, @@ -721,63 +388,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "api/webhooks", - method="POST", - json={ - "endpoint": endpoint, - "organization_id": organization_id, - "secret": secret, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.create( + endpoint=endpoint, secret=secret, organization_id=organization_id, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - WebhookEnvelope, - parse_obj_as( - type_=WebhookEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> WebhookEnvelope: """ @@ -819,44 +433,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/webhooks/{jsonable_encoder(id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - WebhookEnvelope, - parse_obj_as( - type_=WebhookEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(id, request_options=request_options) + return _response.data async def update( self, @@ -914,63 +492,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/webhooks/{jsonable_encoder(id)}", - method="PUT", - json={ - "endpoint": endpoint, - "organization_id": organization_id, - "secret": secret, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.update( + id, endpoint=endpoint, secret=secret, organization_id=organization_id, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - WebhookEnvelope, - parse_obj_as( - type_=WebhookEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ @@ -1005,48 +530,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/webhooks/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.remove(id, request_options=request_options) + return _response.data async def disable(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> WebhookEnvelope: """ @@ -1082,54 +567,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/webhooks/{jsonable_encoder(id)}/disable", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - WebhookEnvelope, - parse_obj_as( - type_=WebhookEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.disable(id, request_options=request_options) + return _response.data async def enable(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> WebhookEnvelope: """ @@ -1165,51 +604,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"api/webhooks/{jsonable_encoder(id)}/enable", - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - WebhookEnvelope, - parse_obj_as( - type_=WebhookEnvelope, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - typing.cast( - RestErrResponse, - parse_obj_as( - type_=RestErrResponse, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 500: - raise InternalServerError( - typing.cast( - types_api_error_ApiError, - parse_obj_as( - type_=types_api_error_ApiError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) - raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.enable(id, request_options=request_options) + return _response.data diff --git a/src/polytomic/webhooks/raw_client.py b/src/polytomic/webhooks/raw_client.py new file mode 100644 index 0000000..978390e --- /dev/null +++ b/src/polytomic/webhooks/raw_client.py @@ -0,0 +1,1168 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError as core_api_error_ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from ..errors.internal_server_error import InternalServerError +from ..errors.not_found_error import NotFoundError +from ..errors.unauthorized_error import UnauthorizedError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.api_error import ApiError as types_api_error_ApiError +from ..types.rest_err_response import RestErrResponse +from ..types.webhook_envelope import WebhookEnvelope +from ..types.webhook_list_envelope import WebhookListEnvelope +from pydantic import ValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawWebhooksClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[WebhookListEnvelope]: + """ + Webooks can be set up using the webhook API endpoints. Currently, only one + webhook may be created per organization. The webhook will be called for events + in that organization. + + Consult the [Events documentation](https://apidocs.polytomic.com/guides/events) for more information. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[WebhookListEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/webhooks", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + WebhookListEnvelope, + parse_obj_as( + type_=WebhookListEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def create( + self, + *, + endpoint: str, + secret: str, + organization_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[WebhookEnvelope]: + """ + Webooks can be set up using the webhook API endpoints. Currently, only one + webhook may be created per organization. The webhook will be called for events + in that organization. + + Consult the [Events documentation](https://apidocs.polytomic.com/guides/events) for more information. + + Parameters + ---------- + endpoint : str + + secret : str + + organization_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[WebhookEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + "api/webhooks", + method="POST", + json={ + "endpoint": endpoint, + "organization_id": organization_id, + "secret": secret, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + WebhookEnvelope, + parse_obj_as( + type_=WebhookEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[WebhookEnvelope]: + """ + Webooks can be set up using the webhook API endpoints. Currently, only one + webhook may be created per organization. The webhook will be called for events + in that organization. + + Consult the [Events documentation](https://apidocs.polytomic.com/guides/events) for more information. + + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[WebhookEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/webhooks/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + WebhookEnvelope, + parse_obj_as( + type_=WebhookEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def update( + self, + id: str, + *, + endpoint: str, + secret: str, + organization_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[WebhookEnvelope]: + """ + Webooks can be set up using the webhook API endpoints. Currently, only one + webhook may be created per organization. The webhook will be called for events + in that organization. + + Consult the [Events documentation](https://apidocs.polytomic.com/guides/events) for more information. + + Parameters + ---------- + id : str + + endpoint : str + + secret : str + + organization_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[WebhookEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/webhooks/{jsonable_encoder(id)}", + method="PUT", + json={ + "endpoint": endpoint, + "organization_id": organization_id, + "secret": secret, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + WebhookEnvelope, + parse_obj_as( + type_=WebhookEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def remove(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"api/webhooks/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def disable( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[WebhookEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[WebhookEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/webhooks/{jsonable_encoder(id)}/disable", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + WebhookEnvelope, + parse_obj_as( + type_=WebhookEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + def enable( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[WebhookEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[WebhookEnvelope] + OK + """ + _response = self._client_wrapper.httpx_client.request( + f"api/webhooks/{jsonable_encoder(id)}/enable", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + WebhookEnvelope, + parse_obj_as( + type_=WebhookEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + +class AsyncRawWebhooksClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[WebhookListEnvelope]: + """ + Webooks can be set up using the webhook API endpoints. Currently, only one + webhook may be created per organization. The webhook will be called for events + in that organization. + + Consult the [Events documentation](https://apidocs.polytomic.com/guides/events) for more information. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[WebhookListEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/webhooks", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + WebhookListEnvelope, + parse_obj_as( + type_=WebhookListEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def create( + self, + *, + endpoint: str, + secret: str, + organization_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[WebhookEnvelope]: + """ + Webooks can be set up using the webhook API endpoints. Currently, only one + webhook may be created per organization. The webhook will be called for events + in that organization. + + Consult the [Events documentation](https://apidocs.polytomic.com/guides/events) for more information. + + Parameters + ---------- + endpoint : str + + secret : str + + organization_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[WebhookEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + "api/webhooks", + method="POST", + json={ + "endpoint": endpoint, + "organization_id": organization_id, + "secret": secret, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + WebhookEnvelope, + parse_obj_as( + type_=WebhookEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def get( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[WebhookEnvelope]: + """ + Webooks can be set up using the webhook API endpoints. Currently, only one + webhook may be created per organization. The webhook will be called for events + in that organization. + + Consult the [Events documentation](https://apidocs.polytomic.com/guides/events) for more information. + + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[WebhookEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/webhooks/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + WebhookEnvelope, + parse_obj_as( + type_=WebhookEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def update( + self, + id: str, + *, + endpoint: str, + secret: str, + organization_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[WebhookEnvelope]: + """ + Webooks can be set up using the webhook API endpoints. Currently, only one + webhook may be created per organization. The webhook will be called for events + in that organization. + + Consult the [Events documentation](https://apidocs.polytomic.com/guides/events) for more information. + + Parameters + ---------- + id : str + + endpoint : str + + secret : str + + organization_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[WebhookEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/webhooks/{jsonable_encoder(id)}", + method="PUT", + json={ + "endpoint": endpoint, + "organization_id": organization_id, + "secret": secret, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + WebhookEnvelope, + parse_obj_as( + type_=WebhookEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def remove( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/webhooks/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def disable( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[WebhookEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[WebhookEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/webhooks/{jsonable_encoder(id)}/disable", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + WebhookEnvelope, + parse_obj_as( + type_=WebhookEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + + async def enable( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[WebhookEnvelope]: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[WebhookEnvelope] + OK + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/webhooks/{jsonable_encoder(id)}/enable", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + WebhookEnvelope, + parse_obj_as( + type_=WebhookEnvelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + RestErrResponse, + parse_obj_as( + type_=RestErrResponse, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/tests/custom/test_client.py b/tests/custom/test_client.py index 73f811f..ab04ce6 100644 --- a/tests/custom/test_client.py +++ b/tests/custom/test_client.py @@ -4,4 +4,4 @@ # Get started with writing tests with pytest at https://docs.pytest.org @pytest.mark.skip(reason="Unimplemented") def test_client() -> None: - assert True == True + assert True diff --git a/tests/utils/assets/models/__init__.py b/tests/utils/assets/models/__init__.py index 3a1c852..2cf0126 100644 --- a/tests/utils/assets/models/__init__.py +++ b/tests/utils/assets/models/__init__.py @@ -5,7 +5,7 @@ from .circle import CircleParams from .object_with_defaults import ObjectWithDefaultsParams from .object_with_optional_field import ObjectWithOptionalFieldParams -from .shape import ShapeParams, Shape_CircleParams, Shape_SquareParams +from .shape import Shape_CircleParams, Shape_SquareParams, ShapeParams from .square import SquareParams from .undiscriminated_shape import UndiscriminatedShapeParams diff --git a/tests/utils/assets/models/circle.py b/tests/utils/assets/models/circle.py index 201874e..c4afba4 100644 --- a/tests/utils/assets/models/circle.py +++ b/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from polytomic.core.serialization import FieldMetadata diff --git a/tests/utils/assets/models/object_with_defaults.py b/tests/utils/assets/models/object_with_defaults.py index ef14f7b..a977b1d 100644 --- a/tests/utils/assets/models/object_with_defaults.py +++ b/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/tests/utils/assets/models/object_with_optional_field.py b/tests/utils/assets/models/object_with_optional_field.py index c683f20..6765af6 100644 --- a/tests/utils/assets/models/object_with_optional_field.py +++ b/tests/utils/assets/models/object_with_optional_field.py @@ -2,16 +2,17 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions -import typing -import typing_extensions -from polytomic.core.serialization import FieldMetadata import datetime as dt +import typing import uuid + +import typing_extensions from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams +from polytomic.core.serialization import FieldMetadata + class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): literal: typing.Literal["lit_one"] diff --git a/tests/utils/assets/models/shape.py b/tests/utils/assets/models/shape.py index cae0a16..ee34280 100644 --- a/tests/utils/assets/models/shape.py +++ b/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from polytomic.core.serialization import FieldMetadata diff --git a/tests/utils/assets/models/square.py b/tests/utils/assets/models/square.py index 6f4ce73..f41e2ea 100644 --- a/tests/utils/assets/models/square.py +++ b/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from polytomic.core.serialization import FieldMetadata diff --git a/tests/utils/assets/models/undiscriminated_shape.py b/tests/utils/assets/models/undiscriminated_shape.py index 68876a2..99f12b3 100644 --- a/tests/utils/assets/models/undiscriminated_shape.py +++ b/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/tests/utils/test_http_client.py b/tests/utils/test_http_client.py index 5726bfa..1cc15b4 100644 --- a/tests/utils/test_http_client.py +++ b/tests/utils/test_http_client.py @@ -1,13 +1,57 @@ # This file was auto-generated by Fern from our API Definition. -from polytomic.core.http_client import get_request_body +from typing import Any, Dict + +import pytest + +from polytomic.core.http_client import ( + AsyncHttpClient, + HttpClient, + _build_url, + get_request_body, + remove_none_from_dict, +) from polytomic.core.request_options import RequestOptions +# Stub clients for testing HttpClient and AsyncHttpClient +class _DummySyncClient: + """A minimal stub for httpx.Client that records request arguments.""" + + def __init__(self) -> None: + self.last_request_kwargs: Dict[str, Any] = {} + + def request(self, **kwargs: Any) -> "_DummyResponse": + self.last_request_kwargs = kwargs + return _DummyResponse() + + +class _DummyAsyncClient: + """A minimal stub for httpx.AsyncClient that records request arguments.""" + + def __init__(self) -> None: + self.last_request_kwargs: Dict[str, Any] = {} + + async def request(self, **kwargs: Any) -> "_DummyResponse": + self.last_request_kwargs = kwargs + return _DummyResponse() + + +class _DummyResponse: + """A minimal stub for httpx.Response.""" + + status_code = 200 + headers: Dict[str, str] = {} + + def get_request_options() -> RequestOptions: return {"additional_body_parameters": {"see you": "later"}} +def get_request_options_with_none() -> RequestOptions: + return {"additional_body_parameters": {"see you": "later", "optional": None}} + + def test_get_json_request_body() -> None: json_body, data_body = get_request_body(json={"hello": "world"}, data=None, request_options=None, omit=None) assert json_body == {"hello": "world"} @@ -48,14 +92,209 @@ def test_get_none_request_body() -> None: def test_get_empty_json_request_body() -> None: + """Test that implicit empty bodies (json=None) are collapsed to None.""" unrelated_request_options: RequestOptions = {"max_retries": 3} json_body, data_body = get_request_body(json=None, data=None, request_options=unrelated_request_options, omit=None) assert json_body is None assert data_body is None - json_body_extras, data_body_extras = get_request_body( - json={}, data=None, request_options=unrelated_request_options, omit=None + +def test_explicit_empty_json_body_is_preserved() -> None: + """Test that explicit empty bodies (json={}) are preserved and sent as {}. + + This is important for endpoints where the request body is required but all + fields are optional. The server expects valid JSON ({}) not an empty body. + """ + unrelated_request_options: RequestOptions = {"max_retries": 3} + + # Explicit json={} should be preserved + json_body, data_body = get_request_body(json={}, data=None, request_options=unrelated_request_options, omit=None) + assert json_body == {} + assert data_body is None + + # Explicit data={} should also be preserved + json_body2, data_body2 = get_request_body(json=None, data={}, request_options=unrelated_request_options, omit=None) + assert json_body2 is None + assert data_body2 == {} + + +def test_json_body_preserves_none_values() -> None: + """Test that JSON bodies preserve None values (they become JSON null).""" + json_body, data_body = get_request_body( + json={"hello": "world", "optional": None}, data=None, request_options=None, omit=None ) + # JSON bodies should preserve None values + assert json_body == {"hello": "world", "optional": None} + assert data_body is None - assert json_body_extras is None - assert data_body_extras is None + +def test_data_body_preserves_none_values_without_multipart() -> None: + """Test that data bodies preserve None values when not using multipart. + + The filtering of None values happens in HttpClient.request/stream methods, + not in get_request_body. This test verifies get_request_body doesn't filter None. + """ + json_body, data_body = get_request_body( + json=None, data={"hello": "world", "optional": None}, request_options=None, omit=None + ) + # get_request_body should preserve None values in data body + # The filtering happens later in HttpClient.request when multipart is detected + assert data_body == {"hello": "world", "optional": None} + assert json_body is None + + +def test_remove_none_from_dict_filters_none_values() -> None: + """Test that remove_none_from_dict correctly filters out None values.""" + original = {"hello": "world", "optional": None, "another": "value", "also_none": None} + filtered = remove_none_from_dict(original) + assert filtered == {"hello": "world", "another": "value"} + # Original should not be modified + assert original == {"hello": "world", "optional": None, "another": "value", "also_none": None} + + +def test_remove_none_from_dict_empty_dict() -> None: + """Test that remove_none_from_dict handles empty dict.""" + assert remove_none_from_dict({}) == {} + + +def test_remove_none_from_dict_all_none() -> None: + """Test that remove_none_from_dict handles dict with all None values.""" + assert remove_none_from_dict({"a": None, "b": None}) == {} + + +def test_http_client_does_not_pass_empty_params_list() -> None: + """Test that HttpClient passes params=None when params are empty. + + This prevents httpx from stripping existing query parameters from the URL, + which happens when params=[] or params={} is passed. + """ + dummy_client = _DummySyncClient() + http_client = HttpClient( + httpx_client=dummy_client, # type: ignore[arg-type] + base_timeout=lambda: None, + base_headers=lambda: {}, + base_url=lambda: "https://example.com", + ) + + # Use a path with query params (e.g., pagination cursor URL) + http_client.request( + path="resource?after=123", + method="GET", + params=None, + request_options=None, + ) + + # We care that httpx receives params=None, not [] or {} + assert "params" in dummy_client.last_request_kwargs + assert dummy_client.last_request_kwargs["params"] is None + + # Verify the query string in the URL is preserved + url = str(dummy_client.last_request_kwargs["url"]) + assert "after=123" in url, f"Expected query param 'after=123' in URL, got: {url}" + + +def test_http_client_passes_encoded_params_when_present() -> None: + """Test that HttpClient passes encoded params when params are provided.""" + dummy_client = _DummySyncClient() + http_client = HttpClient( + httpx_client=dummy_client, # type: ignore[arg-type] + base_timeout=lambda: None, + base_headers=lambda: {}, + base_url=lambda: "https://example.com/resource", + ) + + http_client.request( + path="", + method="GET", + params={"after": "456"}, + request_options=None, + ) + + params = dummy_client.last_request_kwargs["params"] + # For a simple dict, encode_query should give a single (key, value) tuple + assert params == [("after", "456")] + + +@pytest.mark.asyncio +async def test_async_http_client_does_not_pass_empty_params_list() -> None: + """Test that AsyncHttpClient passes params=None when params are empty. + + This prevents httpx from stripping existing query parameters from the URL, + which happens when params=[] or params={} is passed. + """ + dummy_client = _DummyAsyncClient() + http_client = AsyncHttpClient( + httpx_client=dummy_client, # type: ignore[arg-type] + base_timeout=lambda: None, + base_headers=lambda: {}, + base_url=lambda: "https://example.com", + async_base_headers=None, + ) + + # Use a path with query params (e.g., pagination cursor URL) + await http_client.request( + path="resource?after=123", + method="GET", + params=None, + request_options=None, + ) + + # We care that httpx receives params=None, not [] or {} + assert "params" in dummy_client.last_request_kwargs + assert dummy_client.last_request_kwargs["params"] is None + + # Verify the query string in the URL is preserved + url = str(dummy_client.last_request_kwargs["url"]) + assert "after=123" in url, f"Expected query param 'after=123' in URL, got: {url}" + + +@pytest.mark.asyncio +async def test_async_http_client_passes_encoded_params_when_present() -> None: + """Test that AsyncHttpClient passes encoded params when params are provided.""" + dummy_client = _DummyAsyncClient() + http_client = AsyncHttpClient( + httpx_client=dummy_client, # type: ignore[arg-type] + base_timeout=lambda: None, + base_headers=lambda: {}, + base_url=lambda: "https://example.com/resource", + async_base_headers=None, + ) + + await http_client.request( + path="", + method="GET", + params={"after": "456"}, + request_options=None, + ) + + params = dummy_client.last_request_kwargs["params"] + # For a simple dict, encode_query should give a single (key, value) tuple + assert params == [("after", "456")] + + +def test_basic_url_joining() -> None: + """Test basic URL joining with a simple base URL and path.""" + result = _build_url("https://api.example.com", "/users") + assert result == "https://api.example.com/users" + + +def test_basic_url_joining_trailing_slash() -> None: + """Test basic URL joining with a simple base URL and path.""" + result = _build_url("https://api.example.com/", "/users") + assert result == "https://api.example.com/users" + + +def test_preserves_base_url_path_prefix() -> None: + """Test that path prefixes in base URL are preserved. + + This is the critical bug fix - urllib.parse.urljoin() would strip + the path prefix when the path starts with '/'. + """ + result = _build_url("https://cloud.example.com/org/tenant/api", "/users") + assert result == "https://cloud.example.com/org/tenant/api/users" + + +def test_preserves_base_url_path_prefix_trailing_slash() -> None: + """Test that path prefixes in base URL are preserved.""" + result = _build_url("https://cloud.example.com/org/tenant/api/", "/users") + assert result == "https://cloud.example.com/org/tenant/api/users" diff --git a/tests/utils/test_query_encoding.py b/tests/utils/test_query_encoding.py index 29e922f..d19d67f 100644 --- a/tests/utils/test_query_encoding.py +++ b/tests/utils/test_query_encoding.py @@ -1,6 +1,5 @@ # This file was auto-generated by Fern from our API Definition. - from polytomic.core.query_encoder import encode_query @@ -34,4 +33,4 @@ def test_query_encoding_deep_object_arrays() -> None: def test_encode_query_with_none() -> None: encoded = encode_query(None) - assert encoded == None + assert encoded is None diff --git a/tests/utils/test_serialization.py b/tests/utils/test_serialization.py index 8432841..b2b12ea 100644 --- a/tests/utils/test_serialization.py +++ b/tests/utils/test_serialization.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from typing import List, Any +from typing import Any, List -from polytomic.core.serialization import convert_and_respect_annotation_metadata -from .assets.models import ShapeParams, ObjectWithOptionalFieldParams +from .assets.models import ObjectWithOptionalFieldParams, ShapeParams +from polytomic.core.serialization import convert_and_respect_annotation_metadata UNION_TEST: ShapeParams = {"radius_measurement": 1.0, "shape_type": "circle", "id": "1"} UNION_TEST_CONVERTED = {"shapeType": "circle", "radiusMeasurement": 1.0, "id": "1"}