From a001033bb009ff23e7ba677a8bcf02688cffb0dc Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 17:28:12 +0000 Subject: [PATCH 1/2] SDK regeneration --- .github/workflows/ci.yml | 3 +- .gitignore | 1 + poetry.lock | 337 +- pyproject.toml | 10 +- reference.md | 11324 ++++++++++++++++ src/schematic/__init__.py | 182 +- src/schematic/accesstokens/__init__.py | 5 + src/schematic/accesstokens/client.py | 232 + src/schematic/accesstokens/types/__init__.py | 5 + .../issue_temporary_access_token_response.py | 24 + src/schematic/accounts/client.py | 3023 +++-- .../accounts/types/count_api_keys_params.py | 36 +- .../accounts/types/count_api_keys_response.py | 36 +- .../types/count_api_requests_params.py | 36 +- .../types/count_api_requests_response.py | 36 +- .../accounts/types/create_api_key_response.py | 36 +- .../types/create_environment_response.py | 36 +- .../accounts/types/delete_api_key_response.py | 36 +- .../types/delete_environment_response.py | 36 +- .../accounts/types/get_api_key_response.py | 36 +- .../types/get_api_request_response.py | 36 +- .../types/get_environment_response.py | 36 +- .../accounts/types/list_api_keys_params.py | 36 +- .../accounts/types/list_api_keys_response.py | 36 +- .../types/list_api_requests_params.py | 36 +- .../types/list_api_requests_response.py | 36 +- .../types/list_environments_params.py | 36 +- .../types/list_environments_response.py | 36 +- .../accounts/types/update_api_key_response.py | 36 +- .../types/update_environment_response.py | 36 +- src/schematic/base_client.py | 139 +- src/schematic/billing/__init__.py | 40 +- src/schematic/billing/client.py | 3277 ++++- src/schematic/billing/types/__init__.py | 40 +- .../types/count_billing_products_params.py | 35 + .../types/count_billing_products_response.py | 25 + .../billing/types/count_customers_params.py | 35 + .../billing/types/count_customers_response.py | 25 + .../types/list_billing_products_params.py | 35 + .../types/list_billing_products_response.py | 29 + .../billing/types/list_customers_params.py | 35 + .../billing/types/list_customers_response.py | 29 + .../billing/types/list_invoices_params.py | 35 + .../billing/types/list_invoices_response.py | 29 + .../types/list_payment_methods_params.py | 35 + .../types/list_payment_methods_response.py | 29 + .../types/list_product_prices_params.py | 35 + .../types/list_product_prices_response.py | 29 + .../billing/types/list_products_params.py | 43 - .../billing/types/list_products_response.py | 39 - .../types/upsert_billing_customer_response.py | 24 + .../types/upsert_billing_price_response.py | 24 + .../types/upsert_billing_product_response.py | 36 +- .../upsert_billing_subscription_response.py | 36 +- .../billing/types/upsert_invoice_response.py | 24 + .../types/upsert_payment_method_response.py | 24 + src/schematic/companies/__init__.py | 4 - src/schematic/companies/client.py | 7212 +++++----- src/schematic/companies/types/__init__.py | 4 - .../companies/types/count_companies_params.py | 43 +- .../types/count_companies_response.py | 36 +- .../count_entity_key_definitions_params.py | 37 +- .../count_entity_key_definitions_response.py | 36 +- .../count_entity_trait_definitions_params.py | 36 +- ...count_entity_trait_definitions_response.py | 36 +- .../companies/types/count_users_params.py | 38 +- .../companies/types/count_users_response.py | 36 +- .../types/create_company_response.py | 36 +- .../companies/types/create_user_response.py | 36 +- .../types/delete_company_by_keys_response.py | 36 +- .../delete_company_membership_response.py | 36 +- .../types/delete_company_response.py | 36 +- .../types/delete_user_by_keys_response.py | 36 +- .../companies/types/delete_user_response.py | 36 +- .../get_active_company_subscription_params.py | 36 +- ...et_active_company_subscription_response.py | 36 +- .../types/get_active_deals_params.py | 36 +- .../types/get_active_deals_response.py | 36 +- .../companies/types/get_company_response.py | 36 +- .../get_entity_trait_definition_response.py | 36 +- .../types/get_entity_trait_values_params.py | 36 +- .../types/get_entity_trait_values_response.py | 36 +- ...t_or_create_company_membership_response.py | 36 +- ...create_entity_trait_definition_response.py | 36 +- .../companies/types/get_user_response.py | 36 +- .../companies/types/list_companies_params.py | 43 +- .../types/list_companies_response.py | 36 +- .../types/list_company_memberships_params.py | 36 +- .../list_company_memberships_response.py | 36 +- .../types/list_company_plans_params.py | 44 - .../types/list_company_plans_response.py | 39 - .../list_entity_key_definitions_params.py | 37 +- .../list_entity_key_definitions_response.py | 36 +- .../list_entity_trait_definitions_params.py | 36 +- .../list_entity_trait_definitions_response.py | 36 +- .../companies/types/list_users_params.py | 38 +- .../companies/types/list_users_response.py | 36 +- .../companies/types/lookup_company_params.py | 34 +- .../types/lookup_company_response.py | 36 +- .../companies/types/lookup_user_params.py | 34 +- .../companies/types/lookup_user_response.py | 36 +- ...update_entity_trait_definition_response.py | 36 +- .../types/upsert_company_response.py | 36 +- .../types/upsert_company_trait_response.py | 36 +- .../companies/types/upsert_user_response.py | 36 +- .../types/upsert_user_trait_response.py | 36 +- src/schematic/components/__init__.py | 33 + src/schematic/components/client.py | 1473 ++ src/schematic/components/types/__init__.py | 31 + .../types/count_components_params.py | 33 + .../types/count_components_response.py | 25 + ...eate_component_request_body_entity_type.py | 5 + .../types/create_component_response.py | 24 + .../types/delete_component_response.py | 24 + .../types/get_component_response.py | 24 + .../types/list_components_params.py | 33 + .../types/list_components_response.py | 29 + .../types/preview_component_data_params.py | 24 + .../types/preview_component_data_response.py | 25 + ...date_component_request_body_entity_type.py | 5 + .../update_component_request_body_state.py | 5 + .../types/update_component_response.py | 24 + src/schematic/core/__init__.py | 25 +- src/schematic/core/client_wrapper.py | 21 +- src/schematic/core/file.py | 40 +- src/schematic/core/http_client.py | 397 +- src/schematic/core/jsonable_encoder.py | 64 +- src/schematic/core/pydantic_utilities.py | 276 +- src/schematic/core/query_encoder.py | 51 +- src/schematic/core/remove_none_from_dict.py | 4 +- src/schematic/core/request_options.py | 4 +- src/schematic/core/serialization.py | 272 + src/schematic/crm/client.py | 1222 +- .../crm/types/list_crm_products_params.py | 36 +- .../crm/types/list_crm_products_response.py | 36 +- .../crm/types/upsert_crm_deal_response.py | 36 +- .../crm/types/upsert_crm_product_response.py | 36 +- ...ert_deal_line_item_association_response.py | 36 +- .../crm/types/upsert_line_item_response.py | 36 +- src/schematic/entitlements/client.py | 4415 +++--- .../types/count_company_overrides_params.py | 36 +- .../types/count_company_overrides_response.py | 36 +- .../types/count_feature_companies_params.py | 36 +- .../types/count_feature_companies_response.py | 36 +- .../types/count_feature_usage_params.py | 36 +- .../types/count_feature_usage_response.py | 36 +- .../types/count_feature_users_params.py | 36 +- .../types/count_feature_users_response.py | 36 +- .../types/count_plan_entitlements_params.py | 36 +- .../types/count_plan_entitlements_response.py | 36 +- ...ompany_override_request_body_value_type.py | 2 +- .../types/create_company_override_response.py | 36 +- ...lan_entitlement_request_body_value_type.py | 2 +- .../types/create_plan_entitlement_response.py | 36 +- .../types/delete_company_override_response.py | 36 +- .../types/delete_plan_entitlement_response.py | 36 +- .../types/get_company_override_response.py | 36 +- .../get_feature_usage_by_company_params.py | 34 +- .../get_feature_usage_by_company_response.py | 36 +- .../types/get_plan_entitlement_response.py | 36 +- .../types/list_company_overrides_params.py | 36 +- .../types/list_company_overrides_response.py | 36 +- .../types/list_feature_companies_params.py | 36 +- .../types/list_feature_companies_response.py | 36 +- .../types/list_feature_usage_params.py | 36 +- .../types/list_feature_usage_response.py | 36 +- .../types/list_feature_users_params.py | 36 +- .../types/list_feature_users_response.py | 36 +- .../types/list_plan_entitlements_params.py | 36 +- .../types/list_plan_entitlements_response.py | 36 +- ...ompany_override_request_body_value_type.py | 2 +- .../types/update_company_override_response.py | 36 +- ...lan_entitlement_request_body_value_type.py | 2 +- .../types/update_plan_entitlement_response.py | 36 +- src/schematic/events/client.py | 1716 ++- .../types/create_event_batch_response.py | 36 +- .../events/types/create_event_response.py | 36 +- .../events/types/get_event_response.py | 36 +- .../types/get_event_summaries_params.py | 36 +- .../types/get_event_summaries_response.py | 36 +- .../get_event_summary_by_subtype_response.py | 36 +- ...get_segment_integration_status_response.py | 36 +- .../events/types/list_events_params.py | 38 +- .../events/types/list_events_response.py | 36 +- .../events/types/list_metric_counts_params.py | 37 +- .../types/list_metric_counts_response.py | 36 +- src/schematic/features/__init__.py | 14 - src/schematic/features/client.py | 5470 ++++---- src/schematic/features/types/__init__.py | 14 - .../features/types/check_flag_response.py | 36 +- .../features/types/check_flags_response.py | 36 +- .../count_audience_companies_response.py | 36 +- .../types/count_audience_users_response.py | 36 +- .../features/types/count_features_params.py | 40 +- .../features/types/count_features_response.py | 36 +- .../types/count_flag_checks_params.py | 44 - .../types/count_flag_checks_response.py | 35 - .../features/types/count_flags_params.py | 36 +- .../features/types/count_flags_response.py | 36 +- .../features/types/create_feature_response.py | 36 +- .../features/types/create_flag_response.py | 36 +- .../features/types/delete_feature_response.py | 36 +- .../features/types/delete_flag_response.py | 36 +- .../features/types/get_feature_response.py | 36 +- .../features/types/get_flag_check_response.py | 34 - .../features/types/get_flag_response.py | 36 +- .../types/get_latest_flag_checks_params.py | 44 - .../types/get_latest_flag_checks_response.py | 39 - .../types/list_audience_companies_response.py | 36 +- .../types/list_audience_users_response.py | 36 +- .../features/types/list_features_params.py | 40 +- .../features/types/list_features_response.py | 36 +- .../features/types/list_flag_checks_params.py | 44 - .../types/list_flag_checks_response.py | 39 - .../features/types/list_flags_params.py | 36 +- .../features/types/list_flags_response.py | 36 +- .../features/types/update_feature_response.py | 36 +- .../features/types/update_flag_response.py | 36 +- .../types/update_flag_rules_response.py | 36 +- src/schematic/plangroups/__init__.py | 5 + src/schematic/plangroups/client.py | 634 + src/schematic/plangroups/types/__init__.py | 7 + .../types/create_plan_group_response.py | 24 + .../types/get_plan_group_response.py | 24 + .../types/update_plan_group_response.py | 24 + src/schematic/plans/__init__.py | 12 +- src/schematic/plans/client.py | 2262 +-- src/schematic/plans/types/__init__.py | 12 +- .../plans/types/count_plans_params.py | 49 +- .../types/count_plans_request_plan_type.py | 5 + .../plans/types/count_plans_response.py | 36 +- .../count_plans_response_params_plan_type.py | 5 + .../create_plan_request_body_plan_type.py | 4 +- .../plans/types/create_plan_response.py | 36 +- .../plans/types/delete_audience_response.py | 36 +- .../plans/types/delete_plan_response.py | 36 +- .../plans/types/get_audience_response.py | 36 +- .../plans/types/get_plan_response.py | 36 +- .../plans/types/list_plans_params.py | 49 +- .../types/list_plans_request_plan_type.py | 5 + .../plans/types/list_plans_response.py | 36 +- .../list_plans_response_params_plan_type.py | 5 + .../plans/types/update_audience_response.py | 36 +- .../update_plan_request_body_plan_type.py | 7 - .../plans/types/update_plan_response.py | 36 +- .../upsert_billing_product_plan_response.py | 24 + src/schematic/types/__init__.py | 58 +- src/schematic/types/api_error.py | 34 +- .../types/api_key_create_response_data.py | 31 +- .../api_key_request_list_response_data.py | 33 +- .../types/api_key_request_response_data.py | 33 +- src/schematic/types/api_key_response_data.py | 31 +- src/schematic/types/audience_request_body.py | 36 +- .../types/billing_customer_response_data.py | 31 + .../types/billing_customer_subscription.py | 21 + ...stomer_with_subscriptions_response_data.py | 29 + src/schematic/types/billing_plan.py | 24 + .../types/billing_price_response_data.py | 22 + .../billing_product_detail_response_data.py | 33 + ..._product_for_subscription_response_data.py | 31 + .../billing_product_plan_response_data.py | 28 + .../types/billing_product_pricing.py | 22 + .../types/billing_product_response_data.py | 32 +- .../billing_subscription_response_data.py | 34 +- .../types/check_flag_output_with_flag_key.py | 32 +- .../types/check_flag_request_body.py | 36 +- .../types/check_flag_response_data.py | 32 +- .../types/check_flags_response_data.py | 32 +- .../types/company_crm_deals_response_data.py | 32 +- .../types/company_detail_response_data.py | 40 +- ...company_membership_detail_response_data.py | 33 +- .../types/company_membership_response_data.py | 31 +- .../types/company_override_response_data.py | 35 +- .../company_plan_detail_response_data.py | 39 + .../types/company_plan_response_data.py | 34 - src/schematic/types/company_response_data.py | 31 +- .../company_subscription_response_data.py | 42 +- .../types/component_hydrate_response_data.py | 36 + .../types/component_response_data.py | 30 + src/schematic/types/count_response.py | 32 +- .../types/create_event_request_body.py | 39 +- .../create_event_request_body_event_type.py | 2 +- .../types/create_flag_request_body.py | 33 +- ..._or_update_condition_group_request_body.py | 32 +- ...create_or_update_condition_request_body.py | 46 +- .../create_or_update_flag_request_body.py | 33 +- .../create_or_update_rule_request_body.py | 32 +- src/schematic/types/create_req_common.py | 32 +- .../types/create_req_common_value_type.py | 2 +- src/schematic/types/crm_deal_line_item.py | 32 +- src/schematic/types/crm_deal_response_data.py | 34 +- .../types/crm_line_item_response_data.py | 32 +- .../types/crm_product_response_data.py | 32 +- src/schematic/types/decimal.py | 2 +- src/schematic/types/delete_response.py | 34 +- .../entity_key_definition_response_data.py | 31 +- .../types/entity_key_detail_response_data.py | 31 +- .../types/entity_key_response_data.py | 31 +- .../entity_trait_definition_response_data.py | 31 +- .../entity_trait_detail_response_data.py | 31 +- .../types/entity_trait_response_data.py | 31 +- src/schematic/types/entity_trait_value.py | 32 +- .../types/environment_detail_response_data.py | 33 +- .../types/environment_response_data.py | 33 +- src/schematic/types/event_body.py | 6 +- src/schematic/types/event_body_flag_check.py | 67 + src/schematic/types/event_body_identify.py | 40 +- .../types/event_body_identify_company.py | 38 +- src/schematic/types/event_body_track.py | 40 +- .../types/event_detail_response_data.py | 35 +- src/schematic/types/event_response_data.py | 35 +- .../types/event_summary_response_data.py | 33 +- .../types/feature_company_response_data.py | 46 +- ...e_company_response_data_allocation_type.py | 7 + .../feature_company_user_response_data.py | 46 +- ...pany_user_response_data_allocation_type.py | 7 + .../types/feature_detail_response_data.py | 35 +- src/schematic/types/feature_response_data.py | 33 +- .../feature_usage_detail_response_data.py | 36 +- .../types/feature_usage_response_data.py | 46 +- ...ure_usage_response_data_allocation_type.py | 7 + .../flag_check_log_detail_response_data.py | 53 - .../types/flag_check_log_response_data.py | 43 - .../types/flag_detail_response_data.py | 35 +- src/schematic/types/flag_response_data.py | 32 +- src/schematic/types/invoice_request_body.py | 29 + src/schematic/types/invoice_response_data.py | 35 + ...ue_temporary_access_token_response_data.py | 31 + src/schematic/types/keys_request_body.py | 32 +- .../metric_counts_hourly_response_data.py | 33 +- src/schematic/types/pagination_filter.py | 36 +- .../types/payment_method_request_body.py | 27 + .../types/payment_method_response_data.py | 34 + .../plan_audience_detail_response_data.py | 35 +- .../types/plan_audience_response_data.py | 31 +- .../types/plan_detail_response_data.py | 44 +- .../types/plan_entitlement_response_data.py | 37 +- .../types/plan_group_detail_response_data.py | 27 + .../plan_group_plan_detail_response_data.py | 38 + .../types/plan_group_response_data.py | 25 + src/schematic/types/plan_response_data.py | 35 +- src/schematic/types/preview_object.py | 33 +- .../types/raw_event_batch_response_data.py | 32 +- .../types/raw_event_response_data.py | 31 +- .../rule_condition_detail_response_data.py | 35 +- ...le_condition_group_detail_response_data.py | 33 +- .../rule_condition_group_response_data.py | 31 +- .../rule_condition_resource_response_data.py | 32 +- .../types/rule_condition_response_data.py | 35 +- .../types/rule_detail_response_data.py | 35 +- src/schematic/types/rule_response_data.py | 31 +- .../types/rules_detail_response_data.py | 38 +- src/schematic/types/segment_status_resp.py | 33 +- src/schematic/types/stripe_embed_info.py | 21 + .../temporary_access_token_response_data.py | 26 + src/schematic/types/update_req_common.py | 32 +- .../types/update_req_common_value_type.py | 2 +- .../types/update_rule_request_body.py | 32 +- .../types/upsert_company_request_body.py | 39 +- .../types/upsert_trait_request_body.py | 46 +- .../types/upsert_user_request_body.py | 44 +- .../types/upsert_user_sub_request_body.py | 42 +- .../types/user_detail_response_data.py | 37 +- src/schematic/types/user_response_data.py | 31 +- .../webhook_event_detail_response_data.py | 32 +- .../types/webhook_event_response_data.py | 32 +- src/schematic/types/webhook_response_data.py | 31 +- src/schematic/version.py | 1 - src/schematic/webhooks/__init__.py | 2 + src/schematic/webhooks/client.py | 1920 +-- src/schematic/webhooks/types/__init__.py | 2 + .../types/count_webhook_events_params.py | 36 +- .../types/count_webhook_events_response.py | 36 +- .../webhooks/types/count_webhooks_params.py | 36 +- .../webhooks/types/count_webhooks_response.py | 36 +- .../webhooks/types/create_webhook_response.py | 36 +- .../webhooks/types/delete_webhook_response.py | 36 +- .../types/get_webhook_event_response.py | 36 +- .../webhooks/types/get_webhook_response.py | 36 +- .../types/list_webhook_events_params.py | 36 +- .../types/list_webhook_events_response.py | 36 +- .../webhooks/types/list_webhooks_params.py | 36 +- .../webhooks/types/list_webhooks_response.py | 36 +- .../update_webhook_request_body_status.py | 5 + .../webhooks/types/update_webhook_response.py | 36 +- tests/utils/__init__.py | 2 + tests/utils/assets/models/__init__.py | 21 + tests/utils/assets/models/circle.py | 11 + tests/utils/assets/models/color.py | 7 + .../assets/models/object_with_defaults.py | 16 + .../models/object_with_optional_field.py | 34 + tests/utils/assets/models/shape.py | 26 + tests/utils/assets/models/square.py | 11 + .../assets/models/undiscriminated_shape.py | 9 + tests/utils/test_http_client.py | 61 + tests/utils/test_query_encoding.py | 37 + tests/utils/test_serialization.py | 72 + 397 files changed, 38896 insertions(+), 18789 deletions(-) create mode 100644 reference.md create mode 100644 src/schematic/accesstokens/__init__.py create mode 100644 src/schematic/accesstokens/client.py create mode 100644 src/schematic/accesstokens/types/__init__.py create mode 100644 src/schematic/accesstokens/types/issue_temporary_access_token_response.py create mode 100644 src/schematic/billing/types/count_billing_products_params.py create mode 100644 src/schematic/billing/types/count_billing_products_response.py create mode 100644 src/schematic/billing/types/count_customers_params.py create mode 100644 src/schematic/billing/types/count_customers_response.py create mode 100644 src/schematic/billing/types/list_billing_products_params.py create mode 100644 src/schematic/billing/types/list_billing_products_response.py create mode 100644 src/schematic/billing/types/list_customers_params.py create mode 100644 src/schematic/billing/types/list_customers_response.py create mode 100644 src/schematic/billing/types/list_invoices_params.py create mode 100644 src/schematic/billing/types/list_invoices_response.py create mode 100644 src/schematic/billing/types/list_payment_methods_params.py create mode 100644 src/schematic/billing/types/list_payment_methods_response.py create mode 100644 src/schematic/billing/types/list_product_prices_params.py create mode 100644 src/schematic/billing/types/list_product_prices_response.py delete mode 100644 src/schematic/billing/types/list_products_params.py delete mode 100644 src/schematic/billing/types/list_products_response.py create mode 100644 src/schematic/billing/types/upsert_billing_customer_response.py create mode 100644 src/schematic/billing/types/upsert_billing_price_response.py create mode 100644 src/schematic/billing/types/upsert_invoice_response.py create mode 100644 src/schematic/billing/types/upsert_payment_method_response.py delete mode 100644 src/schematic/companies/types/list_company_plans_params.py delete mode 100644 src/schematic/companies/types/list_company_plans_response.py create mode 100644 src/schematic/components/__init__.py create mode 100644 src/schematic/components/client.py create mode 100644 src/schematic/components/types/__init__.py create mode 100644 src/schematic/components/types/count_components_params.py create mode 100644 src/schematic/components/types/count_components_response.py create mode 100644 src/schematic/components/types/create_component_request_body_entity_type.py create mode 100644 src/schematic/components/types/create_component_response.py create mode 100644 src/schematic/components/types/delete_component_response.py create mode 100644 src/schematic/components/types/get_component_response.py create mode 100644 src/schematic/components/types/list_components_params.py create mode 100644 src/schematic/components/types/list_components_response.py create mode 100644 src/schematic/components/types/preview_component_data_params.py create mode 100644 src/schematic/components/types/preview_component_data_response.py create mode 100644 src/schematic/components/types/update_component_request_body_entity_type.py create mode 100644 src/schematic/components/types/update_component_request_body_state.py create mode 100644 src/schematic/components/types/update_component_response.py create mode 100644 src/schematic/core/serialization.py delete mode 100644 src/schematic/features/types/count_flag_checks_params.py delete mode 100644 src/schematic/features/types/count_flag_checks_response.py delete mode 100644 src/schematic/features/types/get_flag_check_response.py delete mode 100644 src/schematic/features/types/get_latest_flag_checks_params.py delete mode 100644 src/schematic/features/types/get_latest_flag_checks_response.py delete mode 100644 src/schematic/features/types/list_flag_checks_params.py delete mode 100644 src/schematic/features/types/list_flag_checks_response.py create mode 100644 src/schematic/plangroups/__init__.py create mode 100644 src/schematic/plangroups/client.py create mode 100644 src/schematic/plangroups/types/__init__.py create mode 100644 src/schematic/plangroups/types/create_plan_group_response.py create mode 100644 src/schematic/plangroups/types/get_plan_group_response.py create mode 100644 src/schematic/plangroups/types/update_plan_group_response.py create mode 100644 src/schematic/plans/types/count_plans_request_plan_type.py create mode 100644 src/schematic/plans/types/count_plans_response_params_plan_type.py create mode 100644 src/schematic/plans/types/list_plans_request_plan_type.py create mode 100644 src/schematic/plans/types/list_plans_response_params_plan_type.py delete mode 100644 src/schematic/plans/types/update_plan_request_body_plan_type.py create mode 100644 src/schematic/plans/types/upsert_billing_product_plan_response.py create mode 100644 src/schematic/types/billing_customer_response_data.py create mode 100644 src/schematic/types/billing_customer_subscription.py create mode 100644 src/schematic/types/billing_customer_with_subscriptions_response_data.py create mode 100644 src/schematic/types/billing_plan.py create mode 100644 src/schematic/types/billing_price_response_data.py create mode 100644 src/schematic/types/billing_product_detail_response_data.py create mode 100644 src/schematic/types/billing_product_for_subscription_response_data.py create mode 100644 src/schematic/types/billing_product_plan_response_data.py create mode 100644 src/schematic/types/billing_product_pricing.py create mode 100644 src/schematic/types/company_plan_detail_response_data.py delete mode 100644 src/schematic/types/company_plan_response_data.py create mode 100644 src/schematic/types/component_hydrate_response_data.py create mode 100644 src/schematic/types/component_response_data.py create mode 100644 src/schematic/types/event_body_flag_check.py create mode 100644 src/schematic/types/feature_company_response_data_allocation_type.py create mode 100644 src/schematic/types/feature_company_user_response_data_allocation_type.py create mode 100644 src/schematic/types/feature_usage_response_data_allocation_type.py delete mode 100644 src/schematic/types/flag_check_log_detail_response_data.py delete mode 100644 src/schematic/types/flag_check_log_response_data.py create mode 100644 src/schematic/types/invoice_request_body.py create mode 100644 src/schematic/types/invoice_response_data.py create mode 100644 src/schematic/types/issue_temporary_access_token_response_data.py create mode 100644 src/schematic/types/payment_method_request_body.py create mode 100644 src/schematic/types/payment_method_response_data.py create mode 100644 src/schematic/types/plan_group_detail_response_data.py create mode 100644 src/schematic/types/plan_group_plan_detail_response_data.py create mode 100644 src/schematic/types/plan_group_response_data.py create mode 100644 src/schematic/types/stripe_embed_info.py create mode 100644 src/schematic/types/temporary_access_token_response_data.py create mode 100644 src/schematic/webhooks/types/update_webhook_request_body_status.py create mode 100644 tests/utils/__init__.py create mode 100644 tests/utils/assets/models/__init__.py create mode 100644 tests/utils/assets/models/circle.py create mode 100644 tests/utils/assets/models/color.py create mode 100644 tests/utils/assets/models/object_with_defaults.py create mode 100644 tests/utils/assets/models/object_with_optional_field.py create mode 100644 tests/utils/assets/models/shape.py create mode 100644 tests/utils/assets/models/square.py create mode 100644 tests/utils/assets/models/undiscriminated_shape.py create mode 100644 tests/utils/test_http_client.py create mode 100644 tests/utils/test_query_encoding.py create mode 100644 tests/utils/test_serialization.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b26bf2..fa41c1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,8 +32,9 @@ jobs: curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1 - name: Install dependencies run: poetry install + - name: Test - run: poetry run pytest . + run: poetry run pytest -rP . publish: needs: [compile, test] diff --git a/.gitignore b/.gitignore index 42cb863..0da665f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ dist/ .mypy_cache/ __pycache__/ poetry.toml +.ruff_cache/ diff --git a/poetry.lock b/poetry.lock index 6d676cf..f43ded4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -16,13 +16,13 @@ typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} [[package]] name = "anyio" -version = "4.4.0" +version = "4.5.0" description = "High level compatibility layer for multiple asynchronous event loop implementations" optional = false python-versions = ">=3.8" files = [ - {file = "anyio-4.4.0-py3-none-any.whl", hash = "sha256:c1b2d8f46a8a812513012e1107cb0e68c17159a7a594208005a57dc776e1bdc7"}, - {file = "anyio-4.4.0.tar.gz", hash = "sha256:5aadc6a1bbb7cdb0bede386cac5e2940f5e2ff3aa20277e991cf028e0585ce94"}, + {file = "anyio-4.5.0-py3-none-any.whl", hash = "sha256:fdeb095b7cc5a5563175eedd926ec4ae55413bb4be5770c424af0ba46ccb4a78"}, + {file = "anyio-4.5.0.tar.gz", hash = "sha256:c5a275fe5ca0afd788001f58fca1e69e29ce706d746e317d660e21f70c530ef9"}, ] [package.dependencies] @@ -32,19 +32,19 @@ sniffio = ">=1.1" typing-extensions = {version = ">=4.1", markers = "python_version < \"3.11\""} [package.extras] -doc = ["Sphinx (>=7)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] -test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.17)"] -trio = ["trio (>=0.23)"] +doc = ["Sphinx (>=7.4,<8.0)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] +test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.21.0b1)"] +trio = ["trio (>=0.26.1)"] [[package]] name = "certifi" -version = "2024.6.2" +version = "2024.8.30" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2024.6.2-py3-none-any.whl", hash = "sha256:ddc6c8ce995e6987e7faf5e3f1b02b302836a0e5d98ece18392cb1a36c72ad56"}, - {file = "certifi-2024.6.2.tar.gz", hash = "sha256:3cd43f1c6fa7dedc5899d69d3ad0398fd018ad1a17fba83ddaf78aa46c747516"}, + {file = "certifi-2024.8.30-py3-none-any.whl", hash = "sha256:922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8"}, + {file = "certifi-2024.8.30.tar.gz", hash = "sha256:bec941d2aa8195e248a60b31ff9f0558284cf01a52591ceda73ea9afffd69fd9"}, ] [[package]] @@ -60,13 +60,13 @@ files = [ [[package]] name = "exceptiongroup" -version = "1.2.1" +version = "1.2.2" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" files = [ - {file = "exceptiongroup-1.2.1-py3-none-any.whl", hash = "sha256:5258b9ed329c5bbdd31a309f53cbfb0b155341807f6ff7606a1e801a891b29ad"}, - {file = "exceptiongroup-1.2.1.tar.gz", hash = "sha256:a4785e48b045528f5bfe627b6ad554ff32def154f42372786903b7abcfe1aa16"}, + {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, + {file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"}, ] [package.extras] @@ -106,13 +106,13 @@ trio = ["trio (>=0.22.0,<0.26.0)"] [[package]] name = "httpx" -version = "0.27.0" +version = "0.27.2" description = "The next generation HTTP client." optional = false python-versions = ">=3.8" files = [ - {file = "httpx-0.27.0-py3-none-any.whl", hash = "sha256:71d5465162c13681bff01ad59b2cc68dd838ea1f10e51574bac27103f00c91a5"}, - {file = "httpx-0.27.0.tar.gz", hash = "sha256:a0cb88a46f32dc874e04ee956e4c2764aba2aa228f650b06788ba6bda2962ab5"}, + {file = "httpx-0.27.2-py3-none-any.whl", hash = "sha256:7bb2708e112d8fdd7829cd4243970f0c223274051cb35ee80c03301ee29a3df0"}, + {file = "httpx-0.27.2.tar.gz", hash = "sha256:f7c2be1d2f3c3c3160d441802406b206c2b76f5947b11115e6df10c6c65e66c2"}, ] [package.dependencies] @@ -127,18 +127,22 @@ brotli = ["brotli", "brotlicffi"] cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"] http2 = ["h2 (>=3,<5)"] socks = ["socksio (==1.*)"] +zstd = ["zstandard (>=0.18.0)"] [[package]] name = "idna" -version = "3.7" +version = "3.10" description = "Internationalized Domain Names in Applications (IDNA)" optional = false -python-versions = ">=3.5" +python-versions = ">=3.6" files = [ - {file = "idna-3.7-py3-none-any.whl", hash = "sha256:82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0"}, - {file = "idna-3.7.tar.gz", hash = "sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc"}, + {file = "idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3"}, + {file = "idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9"}, ] +[package.extras] +all = ["flake8 (>=7.1.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.6.2)"] + [[package]] name = "iniconfig" version = "2.0.0" @@ -152,49 +156,48 @@ files = [ [[package]] name = "mypy" -version = "1.9.0" +version = "1.0.1" description = "Optional static typing for Python" optional = false -python-versions = ">=3.8" +python-versions = ">=3.7" files = [ - {file = "mypy-1.9.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f8a67616990062232ee4c3952f41c779afac41405806042a8126fe96e098419f"}, - {file = "mypy-1.9.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d357423fa57a489e8c47b7c85dfb96698caba13d66e086b412298a1a0ea3b0ed"}, - {file = "mypy-1.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:49c87c15aed320de9b438ae7b00c1ac91cd393c1b854c2ce538e2a72d55df150"}, - {file = "mypy-1.9.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:48533cdd345c3c2e5ef48ba3b0d3880b257b423e7995dada04248725c6f77374"}, - {file = "mypy-1.9.0-cp310-cp310-win_amd64.whl", hash = "sha256:4d3dbd346cfec7cb98e6cbb6e0f3c23618af826316188d587d1c1bc34f0ede03"}, - {file = "mypy-1.9.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:653265f9a2784db65bfca694d1edd23093ce49740b2244cde583aeb134c008f3"}, - {file = "mypy-1.9.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3a3c007ff3ee90f69cf0a15cbcdf0995749569b86b6d2f327af01fd1b8aee9dc"}, - {file = "mypy-1.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2418488264eb41f69cc64a69a745fad4a8f86649af4b1041a4c64ee61fc61129"}, - {file = "mypy-1.9.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:68edad3dc7d70f2f17ae4c6c1b9471a56138ca22722487eebacfd1eb5321d612"}, - {file = "mypy-1.9.0-cp311-cp311-win_amd64.whl", hash = "sha256:85ca5fcc24f0b4aeedc1d02f93707bccc04733f21d41c88334c5482219b1ccb3"}, - {file = "mypy-1.9.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aceb1db093b04db5cd390821464504111b8ec3e351eb85afd1433490163d60cd"}, - {file = "mypy-1.9.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0235391f1c6f6ce487b23b9dbd1327b4ec33bb93934aa986efe8a9563d9349e6"}, - {file = "mypy-1.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d4d5ddc13421ba3e2e082a6c2d74c2ddb3979c39b582dacd53dd5d9431237185"}, - {file = "mypy-1.9.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:190da1ee69b427d7efa8aa0d5e5ccd67a4fb04038c380237a0d96829cb157913"}, - {file = "mypy-1.9.0-cp312-cp312-win_amd64.whl", hash = "sha256:fe28657de3bfec596bbeef01cb219833ad9d38dd5393fc649f4b366840baefe6"}, - {file = "mypy-1.9.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e54396d70be04b34f31d2edf3362c1edd023246c82f1730bbf8768c28db5361b"}, - {file = "mypy-1.9.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:5e6061f44f2313b94f920e91b204ec600982961e07a17e0f6cd83371cb23f5c2"}, - {file = "mypy-1.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:81a10926e5473c5fc3da8abb04119a1f5811a236dc3a38d92015cb1e6ba4cb9e"}, - {file = "mypy-1.9.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:b685154e22e4e9199fc95f298661deea28aaede5ae16ccc8cbb1045e716b3e04"}, - {file = "mypy-1.9.0-cp38-cp38-win_amd64.whl", hash = "sha256:5d741d3fc7c4da608764073089e5f58ef6352bedc223ff58f2f038c2c4698a89"}, - {file = "mypy-1.9.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:587ce887f75dd9700252a3abbc9c97bbe165a4a630597845c61279cf32dfbf02"}, - {file = "mypy-1.9.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f88566144752999351725ac623471661c9d1cd8caa0134ff98cceeea181789f4"}, - {file = "mypy-1.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61758fabd58ce4b0720ae1e2fea5cfd4431591d6d590b197775329264f86311d"}, - {file = "mypy-1.9.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:e49499be624dead83927e70c756970a0bc8240e9f769389cdf5714b0784ca6bf"}, - {file = "mypy-1.9.0-cp39-cp39-win_amd64.whl", hash = "sha256:571741dc4194b4f82d344b15e8837e8c5fcc462d66d076748142327626a1b6e9"}, - {file = "mypy-1.9.0-py3-none-any.whl", hash = "sha256:a260627a570559181a9ea5de61ac6297aa5af202f06fd7ab093ce74e7181e43e"}, - {file = "mypy-1.9.0.tar.gz", hash = "sha256:3cc5da0127e6a478cddd906068496a97a7618a21ce9b54bde5bf7e539c7af974"}, + {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"}, ] [package.dependencies] -mypy-extensions = ">=1.0.0" +mypy-extensions = ">=0.4.3" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = ">=4.1.0" +typing-extensions = ">=3.10" [package.extras] dmypy = ["psutil (>=4.0)"] install-types = ["pip"] -mypyc = ["setuptools (>=50)"] +python2 = ["typed-ast (>=1.4.0,<2)"] reports = ["lxml"] [[package]] @@ -236,109 +239,123 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pydantic" -version = "2.7.4" +version = "2.9.2" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic-2.7.4-py3-none-any.whl", hash = "sha256:ee8538d41ccb9c0a9ad3e0e5f07bf15ed8015b481ced539a1759d8cc89ae90d0"}, - {file = "pydantic-2.7.4.tar.gz", hash = "sha256:0c84efd9548d545f63ac0060c1e4d39bb9b14db8b3c0652338aecc07b5adec52"}, + {file = "pydantic-2.9.2-py3-none-any.whl", hash = "sha256:f048cec7b26778210e28a0459867920654d48e5e62db0958433636cde4254f12"}, + {file = "pydantic-2.9.2.tar.gz", hash = "sha256:d155cef71265d1e9807ed1c32b4c8deec042a44a50a4188b25ac67ecd81a9c0f"}, ] [package.dependencies] -annotated-types = ">=0.4.0" -pydantic-core = "2.18.4" -typing-extensions = ">=4.6.1" +annotated-types = ">=0.6.0" +pydantic-core = "2.23.4" +typing-extensions = [ + {version = ">=4.12.2", markers = "python_version >= \"3.13\""}, + {version = ">=4.6.1", markers = "python_version < \"3.13\""}, +] [package.extras] email = ["email-validator (>=2.0.0)"] +timezone = ["tzdata"] [[package]] name = "pydantic-core" -version = "2.18.4" +version = "2.23.4" description = "Core functionality for Pydantic validation and serialization" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic_core-2.18.4-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:f76d0ad001edd426b92233d45c746fd08f467d56100fd8f30e9ace4b005266e4"}, - {file = "pydantic_core-2.18.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:59ff3e89f4eaf14050c8022011862df275b552caef8082e37b542b066ce1ff26"}, - {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a55b5b16c839df1070bc113c1f7f94a0af4433fcfa1b41799ce7606e5c79ce0a"}, - {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4d0dcc59664fcb8974b356fe0a18a672d6d7cf9f54746c05f43275fc48636851"}, - {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8951eee36c57cd128f779e641e21eb40bc5073eb28b2d23f33eb0ef14ffb3f5d"}, - {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4701b19f7e3a06ea655513f7938de6f108123bf7c86bbebb1196eb9bd35cf724"}, - {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e00a3f196329e08e43d99b79b286d60ce46bed10f2280d25a1718399457e06be"}, - {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:97736815b9cc893b2b7f663628e63f436018b75f44854c8027040e05230eeddb"}, - {file = "pydantic_core-2.18.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:6891a2ae0e8692679c07728819b6e2b822fb30ca7445f67bbf6509b25a96332c"}, - {file = "pydantic_core-2.18.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:bc4ff9805858bd54d1a20efff925ccd89c9d2e7cf4986144b30802bf78091c3e"}, - {file = "pydantic_core-2.18.4-cp310-none-win32.whl", hash = "sha256:1b4de2e51bbcb61fdebd0ab86ef28062704f62c82bbf4addc4e37fa4b00b7cbc"}, - {file = "pydantic_core-2.18.4-cp310-none-win_amd64.whl", hash = "sha256:6a750aec7bf431517a9fd78cb93c97b9b0c496090fee84a47a0d23668976b4b0"}, - {file = "pydantic_core-2.18.4-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:942ba11e7dfb66dc70f9ae66b33452f51ac7bb90676da39a7345e99ffb55402d"}, - {file = "pydantic_core-2.18.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b2ebef0e0b4454320274f5e83a41844c63438fdc874ea40a8b5b4ecb7693f1c4"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a642295cd0c8df1b86fc3dced1d067874c353a188dc8e0f744626d49e9aa51c4"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5f09baa656c904807e832cf9cce799c6460c450c4ad80803517032da0cd062e2"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:98906207f29bc2c459ff64fa007afd10a8c8ac080f7e4d5beff4c97086a3dabd"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:19894b95aacfa98e7cb093cd7881a0c76f55731efad31073db4521e2b6ff5b7d"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0fbbdc827fe5e42e4d196c746b890b3d72876bdbf160b0eafe9f0334525119c8"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f85d05aa0918283cf29a30b547b4df2fbb56b45b135f9e35b6807cb28bc47951"}, - {file = "pydantic_core-2.18.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e85637bc8fe81ddb73fda9e56bab24560bdddfa98aa64f87aaa4e4b6730c23d2"}, - {file = "pydantic_core-2.18.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:2f5966897e5461f818e136b8451d0551a2e77259eb0f73a837027b47dc95dab9"}, - {file = "pydantic_core-2.18.4-cp311-none-win32.whl", hash = "sha256:44c7486a4228413c317952e9d89598bcdfb06399735e49e0f8df643e1ccd0558"}, - {file = "pydantic_core-2.18.4-cp311-none-win_amd64.whl", hash = "sha256:8a7164fe2005d03c64fd3b85649891cd4953a8de53107940bf272500ba8a788b"}, - {file = "pydantic_core-2.18.4-cp311-none-win_arm64.whl", hash = "sha256:4e99bc050fe65c450344421017f98298a97cefc18c53bb2f7b3531eb39bc7805"}, - {file = "pydantic_core-2.18.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:6f5c4d41b2771c730ea1c34e458e781b18cc668d194958e0112455fff4e402b2"}, - {file = "pydantic_core-2.18.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2fdf2156aa3d017fddf8aea5adfba9f777db1d6022d392b682d2a8329e087cef"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4748321b5078216070b151d5271ef3e7cc905ab170bbfd27d5c83ee3ec436695"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:847a35c4d58721c5dc3dba599878ebbdfd96784f3fb8bb2c356e123bdcd73f34"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c40d4eaad41f78e3bbda31b89edc46a3f3dc6e171bf0ecf097ff7a0ffff7cb1"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:21a5e440dbe315ab9825fcd459b8814bb92b27c974cbc23c3e8baa2b76890077"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:01dd777215e2aa86dfd664daed5957704b769e726626393438f9c87690ce78c3"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4b06beb3b3f1479d32befd1f3079cc47b34fa2da62457cdf6c963393340b56e9"}, - {file = "pydantic_core-2.18.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:564d7922e4b13a16b98772441879fcdcbe82ff50daa622d681dd682175ea918c"}, - {file = "pydantic_core-2.18.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:0eb2a4f660fcd8e2b1c90ad566db2b98d7f3f4717c64fe0a83e0adb39766d5b8"}, - {file = "pydantic_core-2.18.4-cp312-none-win32.whl", hash = "sha256:8b8bab4c97248095ae0c4455b5a1cd1cdd96e4e4769306ab19dda135ea4cdb07"}, - {file = "pydantic_core-2.18.4-cp312-none-win_amd64.whl", hash = "sha256:14601cdb733d741b8958224030e2bfe21a4a881fb3dd6fbb21f071cabd48fa0a"}, - {file = "pydantic_core-2.18.4-cp312-none-win_arm64.whl", hash = "sha256:c1322d7dd74713dcc157a2b7898a564ab091ca6c58302d5c7b4c07296e3fd00f"}, - {file = "pydantic_core-2.18.4-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:823be1deb01793da05ecb0484d6c9e20baebb39bd42b5d72636ae9cf8350dbd2"}, - {file = "pydantic_core-2.18.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ebef0dd9bf9b812bf75bda96743f2a6c5734a02092ae7f721c048d156d5fabae"}, - {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ae1d6df168efb88d7d522664693607b80b4080be6750c913eefb77e34c12c71a"}, - {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f9899c94762343f2cc2fc64c13e7cae4c3cc65cdfc87dd810a31654c9b7358cc"}, - {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:99457f184ad90235cfe8461c4d70ab7dd2680e28821c29eca00252ba90308c78"}, - {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:18f469a3d2a2fdafe99296a87e8a4c37748b5080a26b806a707f25a902c040a8"}, - {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b7cdf28938ac6b8b49ae5e92f2735056a7ba99c9b110a474473fd71185c1af5d"}, - {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:938cb21650855054dc54dfd9120a851c974f95450f00683399006aa6e8abb057"}, - {file = "pydantic_core-2.18.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:44cd83ab6a51da80fb5adbd9560e26018e2ac7826f9626bc06ca3dc074cd198b"}, - {file = "pydantic_core-2.18.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:972658f4a72d02b8abfa2581d92d59f59897d2e9f7e708fdabe922f9087773af"}, - {file = "pydantic_core-2.18.4-cp38-none-win32.whl", hash = "sha256:1d886dc848e60cb7666f771e406acae54ab279b9f1e4143babc9c2258213daa2"}, - {file = "pydantic_core-2.18.4-cp38-none-win_amd64.whl", hash = "sha256:bb4462bd43c2460774914b8525f79b00f8f407c945d50881568f294c1d9b4443"}, - {file = "pydantic_core-2.18.4-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:44a688331d4a4e2129140a8118479443bd6f1905231138971372fcde37e43528"}, - {file = "pydantic_core-2.18.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a2fdd81edd64342c85ac7cf2753ccae0b79bf2dfa063785503cb85a7d3593223"}, - {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:86110d7e1907ab36691f80b33eb2da87d780f4739ae773e5fc83fb272f88825f"}, - {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:46387e38bd641b3ee5ce247563b60c5ca098da9c56c75c157a05eaa0933ed154"}, - {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:123c3cec203e3f5ac7b000bd82235f1a3eced8665b63d18be751f115588fea30"}, - {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dc1803ac5c32ec324c5261c7209e8f8ce88e83254c4e1aebdc8b0a39f9ddb443"}, - {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:53db086f9f6ab2b4061958d9c276d1dbe3690e8dd727d6abf2321d6cce37fa94"}, - {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:abc267fa9837245cc28ea6929f19fa335f3dc330a35d2e45509b6566dc18be23"}, - {file = "pydantic_core-2.18.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:a0d829524aaefdebccb869eed855e2d04c21d2d7479b6cada7ace5448416597b"}, - {file = "pydantic_core-2.18.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:509daade3b8649f80d4e5ff21aa5673e4ebe58590b25fe42fac5f0f52c6f034a"}, - {file = "pydantic_core-2.18.4-cp39-none-win32.whl", hash = "sha256:ca26a1e73c48cfc54c4a76ff78df3727b9d9f4ccc8dbee4ae3f73306a591676d"}, - {file = "pydantic_core-2.18.4-cp39-none-win_amd64.whl", hash = "sha256:c67598100338d5d985db1b3d21f3619ef392e185e71b8d52bceacc4a7771ea7e"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:574d92eac874f7f4db0ca653514d823a0d22e2354359d0759e3f6a406db5d55d"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:1f4d26ceb5eb9eed4af91bebeae4b06c3fb28966ca3a8fb765208cf6b51102ab"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77450e6d20016ec41f43ca4a6c63e9fdde03f0ae3fe90e7c27bdbeaece8b1ed4"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d323a01da91851a4f17bf592faf46149c9169d68430b3146dcba2bb5e5719abc"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43d447dd2ae072a0065389092a231283f62d960030ecd27565672bd40746c507"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:578e24f761f3b425834f297b9935e1ce2e30f51400964ce4801002435a1b41ef"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:81b5efb2f126454586d0f40c4d834010979cb80785173d1586df845a632e4e6d"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:ab86ce7c8f9bea87b9d12c7f0af71102acbf5ecbc66c17796cff45dae54ef9a5"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:90afc12421df2b1b4dcc975f814e21bc1754640d502a2fbcc6d41e77af5ec312"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:51991a89639a912c17bef4b45c87bd83593aee0437d8102556af4885811d59f5"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:293afe532740370aba8c060882f7d26cfd00c94cae32fd2e212a3a6e3b7bc15e"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b48ece5bde2e768197a2d0f6e925f9d7e3e826f0ad2271120f8144a9db18d5c8"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:eae237477a873ab46e8dd748e515c72c0c804fb380fbe6c85533c7de51f23a8f"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:834b5230b5dfc0c1ec37b2fda433b271cbbc0e507560b5d1588e2cc1148cf1ce"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e858ac0a25074ba4bce653f9b5d0a85b7456eaddadc0ce82d3878c22489fa4ee"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2fd41f6eff4c20778d717af1cc50eca52f5afe7805ee530a4fbd0bae284f16e9"}, - {file = "pydantic_core-2.18.4.tar.gz", hash = "sha256:ec3beeada09ff865c344ff3bc2f427f5e6c26401cc6113d77e372c3fdac73864"}, + {file = "pydantic_core-2.23.4-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:b10bd51f823d891193d4717448fab065733958bdb6a6b351967bd349d48d5c9b"}, + {file = "pydantic_core-2.23.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4fc714bdbfb534f94034efaa6eadd74e5b93c8fa6315565a222f7b6f42ca1166"}, + {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:63e46b3169866bd62849936de036f901a9356e36376079b05efa83caeaa02ceb"}, + {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ed1a53de42fbe34853ba90513cea21673481cd81ed1be739f7f2efb931b24916"}, + {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:cfdd16ab5e59fc31b5e906d1a3f666571abc367598e3e02c83403acabc092e07"}, + {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:255a8ef062cbf6674450e668482456abac99a5583bbafb73f9ad469540a3a232"}, + {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4a7cd62e831afe623fbb7aabbb4fe583212115b3ef38a9f6b71869ba644624a2"}, + {file = "pydantic_core-2.23.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f09e2ff1f17c2b51f2bc76d1cc33da96298f0a036a137f5440ab3ec5360b624f"}, + {file = "pydantic_core-2.23.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:e38e63e6f3d1cec5a27e0afe90a085af8b6806ee208b33030e65b6516353f1a3"}, + {file = "pydantic_core-2.23.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:0dbd8dbed2085ed23b5c04afa29d8fd2771674223135dc9bc937f3c09284d071"}, + {file = "pydantic_core-2.23.4-cp310-none-win32.whl", hash = "sha256:6531b7ca5f951d663c339002e91aaebda765ec7d61b7d1e3991051906ddde119"}, + {file = "pydantic_core-2.23.4-cp310-none-win_amd64.whl", hash = "sha256:7c9129eb40958b3d4500fa2467e6a83356b3b61bfff1b414c7361d9220f9ae8f"}, + {file = "pydantic_core-2.23.4-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:77733e3892bb0a7fa797826361ce8a9184d25c8dffaec60b7ffe928153680ba8"}, + {file = "pydantic_core-2.23.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1b84d168f6c48fabd1f2027a3d1bdfe62f92cade1fb273a5d68e621da0e44e6d"}, + {file = "pydantic_core-2.23.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:df49e7a0861a8c36d089c1ed57d308623d60416dab2647a4a17fe050ba85de0e"}, + {file = "pydantic_core-2.23.4-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ff02b6d461a6de369f07ec15e465a88895f3223eb75073ffea56b84d9331f607"}, + {file = "pydantic_core-2.23.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:996a38a83508c54c78a5f41456b0103c30508fed9abcad0a59b876d7398f25fd"}, + {file = "pydantic_core-2.23.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d97683ddee4723ae8c95d1eddac7c192e8c552da0c73a925a89fa8649bf13eea"}, + {file = "pydantic_core-2.23.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:216f9b2d7713eb98cb83c80b9c794de1f6b7e3145eef40400c62e86cee5f4e1e"}, + {file = "pydantic_core-2.23.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:6f783e0ec4803c787bcea93e13e9932edab72068f68ecffdf86a99fd5918878b"}, + {file = "pydantic_core-2.23.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:d0776dea117cf5272382634bd2a5c1b6eb16767c223c6a5317cd3e2a757c61a0"}, + {file = "pydantic_core-2.23.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:d5f7a395a8cf1621939692dba2a6b6a830efa6b3cee787d82c7de1ad2930de64"}, + {file = "pydantic_core-2.23.4-cp311-none-win32.whl", hash = "sha256:74b9127ffea03643e998e0c5ad9bd3811d3dac8c676e47db17b0ee7c3c3bf35f"}, + {file = "pydantic_core-2.23.4-cp311-none-win_amd64.whl", hash = "sha256:98d134c954828488b153d88ba1f34e14259284f256180ce659e8d83e9c05eaa3"}, + {file = "pydantic_core-2.23.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:f3e0da4ebaef65158d4dfd7d3678aad692f7666877df0002b8a522cdf088f231"}, + {file = "pydantic_core-2.23.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f69a8e0b033b747bb3e36a44e7732f0c99f7edd5cea723d45bc0d6e95377ffee"}, + {file = "pydantic_core-2.23.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:723314c1d51722ab28bfcd5240d858512ffd3116449c557a1336cbe3919beb87"}, + {file = "pydantic_core-2.23.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:bb2802e667b7051a1bebbfe93684841cc9351004e2badbd6411bf357ab8d5ac8"}, + {file = "pydantic_core-2.23.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d18ca8148bebe1b0a382a27a8ee60350091a6ddaf475fa05ef50dc35b5df6327"}, + {file = "pydantic_core-2.23.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:33e3d65a85a2a4a0dc3b092b938a4062b1a05f3a9abde65ea93b233bca0e03f2"}, + {file = "pydantic_core-2.23.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:128585782e5bfa515c590ccee4b727fb76925dd04a98864182b22e89a4e6ed36"}, + {file = "pydantic_core-2.23.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:68665f4c17edcceecc112dfed5dbe6f92261fb9d6054b47d01bf6371a6196126"}, + {file = "pydantic_core-2.23.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:20152074317d9bed6b7a95ade3b7d6054845d70584216160860425f4fbd5ee9e"}, + {file = "pydantic_core-2.23.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:9261d3ce84fa1d38ed649c3638feefeae23d32ba9182963e465d58d62203bd24"}, + {file = "pydantic_core-2.23.4-cp312-none-win32.whl", hash = "sha256:4ba762ed58e8d68657fc1281e9bb72e1c3e79cc5d464be146e260c541ec12d84"}, + {file = "pydantic_core-2.23.4-cp312-none-win_amd64.whl", hash = "sha256:97df63000f4fea395b2824da80e169731088656d1818a11b95f3b173747b6cd9"}, + {file = "pydantic_core-2.23.4-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:7530e201d10d7d14abce4fb54cfe5b94a0aefc87da539d0346a484ead376c3cc"}, + {file = "pydantic_core-2.23.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:df933278128ea1cd77772673c73954e53a1c95a4fdf41eef97c2b779271bd0bd"}, + {file = "pydantic_core-2.23.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0cb3da3fd1b6a5d0279a01877713dbda118a2a4fc6f0d821a57da2e464793f05"}, + {file = "pydantic_core-2.23.4-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:42c6dcb030aefb668a2b7009c85b27f90e51e6a3b4d5c9bc4c57631292015b0d"}, + {file = "pydantic_core-2.23.4-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:696dd8d674d6ce621ab9d45b205df149399e4bb9aa34102c970b721554828510"}, + {file = "pydantic_core-2.23.4-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2971bb5ffe72cc0f555c13e19b23c85b654dd2a8f7ab493c262071377bfce9f6"}, + {file = "pydantic_core-2.23.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8394d940e5d400d04cad4f75c0598665cbb81aecefaca82ca85bd28264af7f9b"}, + {file = "pydantic_core-2.23.4-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:0dff76e0602ca7d4cdaacc1ac4c005e0ce0dcfe095d5b5259163a80d3a10d327"}, + {file = "pydantic_core-2.23.4-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:7d32706badfe136888bdea71c0def994644e09fff0bfe47441deaed8e96fdbc6"}, + {file = "pydantic_core-2.23.4-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:ed541d70698978a20eb63d8c5d72f2cc6d7079d9d90f6b50bad07826f1320f5f"}, + {file = "pydantic_core-2.23.4-cp313-none-win32.whl", hash = "sha256:3d5639516376dce1940ea36edf408c554475369f5da2abd45d44621cb616f769"}, + {file = "pydantic_core-2.23.4-cp313-none-win_amd64.whl", hash = "sha256:5a1504ad17ba4210df3a045132a7baeeba5a200e930f57512ee02909fc5c4cb5"}, + {file = "pydantic_core-2.23.4-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:d4488a93b071c04dc20f5cecc3631fc78b9789dd72483ba15d423b5b3689b555"}, + {file = "pydantic_core-2.23.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:81965a16b675b35e1d09dd14df53f190f9129c0202356ed44ab2728b1c905658"}, + {file = "pydantic_core-2.23.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4ffa2ebd4c8530079140dd2d7f794a9d9a73cbb8e9d59ffe24c63436efa8f271"}, + {file = "pydantic_core-2.23.4-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:61817945f2fe7d166e75fbfb28004034b48e44878177fc54d81688e7b85a3665"}, + {file = "pydantic_core-2.23.4-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:29d2c342c4bc01b88402d60189f3df065fb0dda3654744d5a165a5288a657368"}, + {file = "pydantic_core-2.23.4-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5e11661ce0fd30a6790e8bcdf263b9ec5988e95e63cf901972107efc49218b13"}, + {file = "pydantic_core-2.23.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9d18368b137c6295db49ce7218b1a9ba15c5bc254c96d7c9f9e924a9bc7825ad"}, + {file = "pydantic_core-2.23.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:ec4e55f79b1c4ffb2eecd8a0cfba9955a2588497d96851f4c8f99aa4a1d39b12"}, + {file = "pydantic_core-2.23.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:374a5e5049eda9e0a44c696c7ade3ff355f06b1fe0bb945ea3cac2bc336478a2"}, + {file = "pydantic_core-2.23.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:5c364564d17da23db1106787675fc7af45f2f7b58b4173bfdd105564e132e6fb"}, + {file = "pydantic_core-2.23.4-cp38-none-win32.whl", hash = "sha256:d7a80d21d613eec45e3d41eb22f8f94ddc758a6c4720842dc74c0581f54993d6"}, + {file = "pydantic_core-2.23.4-cp38-none-win_amd64.whl", hash = "sha256:5f5ff8d839f4566a474a969508fe1c5e59c31c80d9e140566f9a37bba7b8d556"}, + {file = "pydantic_core-2.23.4-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:a4fa4fc04dff799089689f4fd502ce7d59de529fc2f40a2c8836886c03e0175a"}, + {file = "pydantic_core-2.23.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:0a7df63886be5e270da67e0966cf4afbae86069501d35c8c1b3b6c168f42cb36"}, + {file = "pydantic_core-2.23.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dcedcd19a557e182628afa1d553c3895a9f825b936415d0dbd3cd0bbcfd29b4b"}, + {file = "pydantic_core-2.23.4-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5f54b118ce5de9ac21c363d9b3caa6c800341e8c47a508787e5868c6b79c9323"}, + {file = "pydantic_core-2.23.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:86d2f57d3e1379a9525c5ab067b27dbb8a0642fb5d454e17a9ac434f9ce523e3"}, + {file = "pydantic_core-2.23.4-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:de6d1d1b9e5101508cb37ab0d972357cac5235f5c6533d1071964c47139257df"}, + {file = "pydantic_core-2.23.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1278e0d324f6908e872730c9102b0112477a7f7cf88b308e4fc36ce1bdb6d58c"}, + {file = "pydantic_core-2.23.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:9a6b5099eeec78827553827f4c6b8615978bb4b6a88e5d9b93eddf8bb6790f55"}, + {file = "pydantic_core-2.23.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:e55541f756f9b3ee346b840103f32779c695a19826a4c442b7954550a0972040"}, + {file = "pydantic_core-2.23.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:a5c7ba8ffb6d6f8f2ab08743be203654bb1aaa8c9dcb09f82ddd34eadb695605"}, + {file = "pydantic_core-2.23.4-cp39-none-win32.whl", hash = "sha256:37b0fe330e4a58d3c58b24d91d1eb102aeec675a3db4c292ec3928ecd892a9a6"}, + {file = "pydantic_core-2.23.4-cp39-none-win_amd64.whl", hash = "sha256:1498bec4c05c9c787bde9125cfdcc63a41004ff167f495063191b863399b1a29"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:f455ee30a9d61d3e1a15abd5068827773d6e4dc513e795f380cdd59932c782d5"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:1e90d2e3bd2c3863d48525d297cd143fe541be8bbf6f579504b9712cb6b643ec"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2e203fdf807ac7e12ab59ca2bfcabb38c7cf0b33c41efeb00f8e5da1d86af480"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e08277a400de01bc72436a0ccd02bdf596631411f592ad985dcee21445bd0068"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f220b0eea5965dec25480b6333c788fb72ce5f9129e8759ef876a1d805d00801"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:d06b0c8da4f16d1d1e352134427cb194a0a6e19ad5db9161bf32b2113409e728"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:ba1a0996f6c2773bd83e63f18914c1de3c9dd26d55f4ac302a7efe93fb8e7433"}, + {file = "pydantic_core-2.23.4-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:9a5bce9d23aac8f0cf0836ecfc033896aa8443b501c58d0602dbfd5bd5b37753"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:78ddaaa81421a29574a682b3179d4cf9e6d405a09b99d93ddcf7e5239c742e21"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:883a91b5dd7d26492ff2f04f40fbb652de40fcc0afe07e8129e8ae779c2110eb"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:88ad334a15b32a791ea935af224b9de1bf99bcd62fabf745d5f3442199d86d59"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:233710f069d251feb12a56da21e14cca67994eab08362207785cf8c598e74577"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:19442362866a753485ba5e4be408964644dd6a09123d9416c54cd49171f50744"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:624e278a7d29b6445e4e813af92af37820fafb6dcc55c012c834f9e26f9aaaef"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f5ef8f42bec47f21d07668a043f077d507e5bf4e668d5c6dfe6aaba89de1a5b8"}, + {file = "pydantic_core-2.23.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:aea443fffa9fbe3af1a9ba721a87f926fe548d32cab71d188a6ede77d0ff244e"}, + {file = "pydantic_core-2.23.4.tar.gz", hash = "sha256:2584f7cf844ac4d970fba483a717dbe10c1c1c96a969bf65d61ffe94df1b2863"}, ] [package.dependencies] @@ -368,13 +385,13 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no [[package]] name = "pytest-asyncio" -version = "0.23.7" +version = "0.23.8" description = "Pytest support for asyncio" optional = false python-versions = ">=3.8" files = [ - {file = "pytest_asyncio-0.23.7-py3-none-any.whl", hash = "sha256:009b48127fbe44518a547bddd25611551b0e43ccdbf1e67d12479f569832c20b"}, - {file = "pytest_asyncio-0.23.7.tar.gz", hash = "sha256:5f5c72948f4c49e7db4f29f2521d4031f1c27f86e57b046126654083d4770268"}, + {file = "pytest_asyncio-0.23.8-py3-none-any.whl", hash = "sha256:50265d892689a5faefb84df80819d1ecef566eb3549cf915dfb33569359d1ce2"}, + {file = "pytest_asyncio-0.23.8.tar.gz", hash = "sha256:759b10b33a6dc61cce40a8bd5205e302978bbbcc00e279a8b61d9a6a3c82e4d3"}, ] [package.dependencies] @@ -398,6 +415,33 @@ files = [ [package.dependencies] six = ">=1.5" +[[package]] +name = "ruff" +version = "0.5.7" +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"}, +] + [[package]] name = "six" version = "1.16.0" @@ -431,6 +475,17 @@ files = [ {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] +[[package]] +name = "types-python-dateutil" +version = "2.9.0.20240906" +description = "Typing stubs for python-dateutil" +optional = false +python-versions = ">=3.8" +files = [ + {file = "types-python-dateutil-2.9.0.20240906.tar.gz", hash = "sha256:9706c3b68284c25adffc47319ecc7947e5bb86b3773f843c73906fd598bc176e"}, + {file = "types_python_dateutil-2.9.0.20240906-py3-none-any.whl", hash = "sha256:27c8cc2d058ccb14946eebcaaa503088f4f6dbc4fb6093d3d456a49aef2753f6"}, +] + [[package]] name = "typing-extensions" version = "4.12.2" @@ -445,4 +500,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "6f0b8d5044d8d4461b9850fcdfd7c382335fc9481fcfd5bd42e760121c1e1450" +content-hash = "6f6c191c1028d17a97fdfa84cedfd3cef94b5d63d98b8c1d333b3398eeea9055" diff --git a/pyproject.toml b/pyproject.toml index 577c1ae..fc34594 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "schematichq" -version = "1.0.4" +version = "1.0.5" description = "" readme = "README.md" authors = [] @@ -34,13 +34,16 @@ Repository = 'https://github.com/schematichq/schematic-python' python = "^3.8" httpx = ">=0.21.2" pydantic = ">= 1.9.2" +pydantic-core = "^2.18.2" typing_extensions = ">= 4.0.0" [tool.poetry.dev-dependencies] -mypy = "1.9.0" +mypy = "1.0.1" pytest = "^7.4.0" pytest-asyncio = "^0.23.5" python-dateutil = "^2.9.0" +types-python-dateutil = "^2.9.0.20240316" +ruff = "^0.5.6" [tool.pytest.ini_options] testpaths = [ "tests" ] @@ -49,6 +52,9 @@ asyncio_mode = "auto" [tool.mypy] plugins = ["pydantic.mypy"] +[tool.ruff] +line-length = 120 + [build-system] requires = ["poetry-core"] diff --git a/reference.md b/reference.md new file mode 100644 index 0000000..6fc5c00 --- /dev/null +++ b/reference.md @@ -0,0 +1,11324 @@ +# Reference +
client.get_company_plans() +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.get_company_plans() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## accounts +
client.accounts.list_api_keys(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accounts.list_api_keys( + require_environment=True, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**require_environment:** `bool` + +
+
+ +
+
+ +**environment_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.accounts.create_api_key(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accounts.create_api_key( + name="name", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**name:** `str` + +
+
+ +
+
+ +**description:** `typing.Optional[str]` + +
+
+ +
+
+ +**environment_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.accounts.get_api_key(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accounts.get_api_key( + api_key_id="api_key_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**api_key_id:** `str` — api_key_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.accounts.update_api_key(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accounts.update_api_key( + api_key_id="api_key_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**api_key_id:** `str` — api_key_id + +
+
+ +
+
+ +**description:** `typing.Optional[str]` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.accounts.delete_api_key(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accounts.delete_api_key( + api_key_id="api_key_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**api_key_id:** `str` — api_key_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.accounts.count_api_keys(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accounts.count_api_keys( + require_environment=True, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**require_environment:** `bool` + +
+
+ +
+
+ +**environment_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.accounts.list_api_requests(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accounts.list_api_requests() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_type:** `typing.Optional[str]` + +
+
+ +
+
+ +**environment_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.accounts.get_api_request(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accounts.get_api_request( + api_request_id="api_request_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**api_request_id:** `str` — api_request_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.accounts.count_api_requests(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accounts.count_api_requests() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_type:** `typing.Optional[str]` + +
+
+ +
+
+ +**environment_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.accounts.list_environments(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accounts.list_environments() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.accounts.create_environment(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accounts.create_environment( + environment_type="development", + name="name", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**environment_type:** `CreateEnvironmentRequestBodyEnvironmentType` + +
+
+ +
+
+ +**name:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.accounts.get_environment(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accounts.get_environment( + environment_id="environment_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**environment_id:** `str` — environment_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.accounts.update_environment(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accounts.update_environment( + environment_id="environment_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**environment_id:** `str` — environment_id + +
+
+ +
+
+ +**environment_type:** `typing.Optional[UpdateEnvironmentRequestBodyEnvironmentType]` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.accounts.delete_environment(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accounts.delete_environment( + environment_id="environment_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**environment_id:** `str` — environment_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## features +
client.features.count_audience_companies(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import ( + CreateOrUpdateConditionGroupRequestBody, + CreateOrUpdateConditionRequestBody, + Schematic, +) + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.count_audience_companies( + condition_groups=[ + CreateOrUpdateConditionGroupRequestBody( + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + ], + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**condition_groups:** `typing.Sequence[CreateOrUpdateConditionGroupRequestBody]` + +
+
+ +
+
+ +**conditions:** `typing.Sequence[CreateOrUpdateConditionRequestBody]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.count_audience_users(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import ( + CreateOrUpdateConditionGroupRequestBody, + CreateOrUpdateConditionRequestBody, + Schematic, +) + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.count_audience_users( + condition_groups=[ + CreateOrUpdateConditionGroupRequestBody( + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + ], + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**condition_groups:** `typing.Sequence[CreateOrUpdateConditionGroupRequestBody]` + +
+
+ +
+
+ +**conditions:** `typing.Sequence[CreateOrUpdateConditionRequestBody]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.list_audience_companies(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import ( + CreateOrUpdateConditionGroupRequestBody, + CreateOrUpdateConditionRequestBody, + Schematic, +) + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.list_audience_companies( + condition_groups=[ + CreateOrUpdateConditionGroupRequestBody( + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + ], + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**condition_groups:** `typing.Sequence[CreateOrUpdateConditionGroupRequestBody]` + +
+
+ +
+
+ +**conditions:** `typing.Sequence[CreateOrUpdateConditionRequestBody]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.list_audience_users(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import ( + CreateOrUpdateConditionGroupRequestBody, + CreateOrUpdateConditionRequestBody, + Schematic, +) + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.list_audience_users( + condition_groups=[ + CreateOrUpdateConditionGroupRequestBody( + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + ], + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**condition_groups:** `typing.Sequence[CreateOrUpdateConditionGroupRequestBody]` + +
+
+ +
+
+ +**conditions:** `typing.Sequence[CreateOrUpdateConditionRequestBody]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.list_features(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.list_features() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**without_company_override_for:** `typing.Optional[str]` — Filter out features that already have a company override for the specified company ID + +
+
+ +
+
+ +**without_plan_entitlement_for:** `typing.Optional[str]` — Filter out features that already have a plan entitlement for the specified plan ID + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.create_feature(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.create_feature( + description="description", + feature_type="boolean", + name="name", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**description:** `str` + +
+
+ +
+
+ +**feature_type:** `CreateFeatureRequestBodyFeatureType` + +
+
+ +
+
+ +**name:** `str` + +
+
+ +
+
+ +**event_subtype:** `typing.Optional[str]` + +
+
+ +
+
+ +**flag:** `typing.Optional[CreateOrUpdateFlagRequestBody]` + +
+
+ +
+
+ +**icon:** `typing.Optional[str]` + +
+
+ +
+
+ +**lifecycle_phase:** `typing.Optional[str]` + +
+
+ +
+
+ +**maintainer_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**trait_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.get_feature(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.get_feature( + feature_id="feature_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**feature_id:** `str` — feature_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.update_feature(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.update_feature( + feature_id="feature_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**feature_id:** `str` — feature_id + +
+
+ +
+
+ +**description:** `typing.Optional[str]` + +
+
+ +
+
+ +**event_subtype:** `typing.Optional[str]` + +
+
+ +
+
+ +**feature_type:** `typing.Optional[UpdateFeatureRequestBodyFeatureType]` + +
+
+ +
+
+ +**flag:** `typing.Optional[CreateOrUpdateFlagRequestBody]` + +
+
+ +
+
+ +**icon:** `typing.Optional[str]` + +
+
+ +
+
+ +**lifecycle_phase:** `typing.Optional[str]` + +
+
+ +
+
+ +**maintainer_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**trait_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.delete_feature(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.delete_feature( + feature_id="feature_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**feature_id:** `str` — feature_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.count_features(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.count_features() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**without_company_override_for:** `typing.Optional[str]` — Filter out features that already have a company override for the specified company ID + +
+
+ +
+
+ +**without_plan_entitlement_for:** `typing.Optional[str]` — Filter out features that already have a plan entitlement for the specified plan ID + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.list_flags(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.list_flags() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**feature_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.create_flag(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.create_flag( + default_value=True, + description="description", + flag_type="flag_type", + key="key", + name="name", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**default_value:** `bool` + +
+
+ +
+
+ +**description:** `str` + +
+
+ +
+
+ +**flag_type:** `str` + +
+
+ +
+
+ +**key:** `str` + +
+
+ +
+
+ +**name:** `str` + +
+
+ +
+
+ +**feature_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**maintainer_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.get_flag(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.get_flag( + flag_id="flag_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**flag_id:** `str` — flag_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.update_flag(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.update_flag( + flag_id="flag_id", + default_value=True, + description="description", + flag_type="flag_type", + key="key", + name="name", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**flag_id:** `str` — flag_id + +
+
+ +
+
+ +**default_value:** `bool` + +
+
+ +
+
+ +**description:** `str` + +
+
+ +
+
+ +**flag_type:** `str` + +
+
+ +
+
+ +**key:** `str` + +
+
+ +
+
+ +**name:** `str` + +
+
+ +
+
+ +**feature_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**maintainer_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.delete_flag(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.delete_flag( + flag_id="flag_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**flag_id:** `str` — flag_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.update_flag_rules(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import ( + CreateOrUpdateConditionGroupRequestBody, + CreateOrUpdateConditionRequestBody, + CreateOrUpdateRuleRequestBody, + Schematic, +) + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.update_flag_rules( + flag_id="flag_id", + rules=[ + CreateOrUpdateRuleRequestBody( + condition_groups=[ + CreateOrUpdateConditionGroupRequestBody( + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + ], + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + name="name", + priority=1, + value=True, + ) + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**flag_id:** `str` — flag_id + +
+
+ +
+
+ +**rules:** `typing.Sequence[CreateOrUpdateRuleRequestBody]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.check_flag(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.check_flag( + key="key", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**key:** `str` — key + +
+
+ +
+
+ +**company:** `typing.Optional[typing.Dict[str, str]]` + +
+
+ +
+
+ +**user:** `typing.Optional[typing.Dict[str, str]]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.check_flags(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.check_flags() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company:** `typing.Optional[typing.Dict[str, str]]` + +
+
+ +
+
+ +**user:** `typing.Optional[typing.Dict[str, str]]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.features.count_flags(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.features.count_flags() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**feature_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## billing +
client.billing.upsert_billing_customer(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.billing.upsert_billing_customer( + email="email", + external_id="external_id", + failed_to_import=True, + meta={"key": "value"}, + name="name", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**email:** `str` + +
+
+ +
+
+ +**external_id:** `str` + +
+
+ +
+
+ +**failed_to_import:** `bool` + +
+
+ +
+
+ +**meta:** `typing.Dict[str, str]` + +
+
+ +
+
+ +**name:** `str` + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.billing.list_customers(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.billing.list_customers() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**failed_to_import:** `typing.Optional[bool]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.billing.count_customers(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.billing.count_customers() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**failed_to_import:** `typing.Optional[bool]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.billing.list_invoices(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.billing.list_invoices( + customer_external_id="customer_external_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customer_external_id:** `str` + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**subscription_external_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.billing.upsert_invoice(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.billing.upsert_invoice( + amount_due=1, + amount_paid=1, + amount_remaining=1, + collection_method="collection_method", + currency="currency", + customer_external_id="customer_external_id", + external_id="external_id", + subtotal=1, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**amount_due:** `int` + +
+
+ +
+
+ +**amount_paid:** `int` + +
+
+ +
+
+ +**amount_remaining:** `int` + +
+
+ +
+
+ +**collection_method:** `str` + +
+
+ +
+
+ +**currency:** `str` + +
+
+ +
+
+ +**customer_external_id:** `str` + +
+
+ +
+
+ +**external_id:** `str` + +
+
+ +
+
+ +**subtotal:** `int` + +
+
+ +
+
+ +**due_date:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**payment_method_external_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**subscription_external_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.billing.list_payment_methods(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.billing.list_payment_methods( + customer_external_id="customer_external_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customer_external_id:** `str` + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**subscription_external_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.billing.upsert_payment_method(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.billing.upsert_payment_method( + customer_external_id="customer_external_id", + external_id="external_id", + payment_method_type="payment_method_type", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customer_external_id:** `str` + +
+
+ +
+
+ +**external_id:** `str` + +
+
+ +
+
+ +**payment_method_type:** `str` + +
+
+ +
+
+ +**card_brand:** `typing.Optional[str]` + +
+
+ +
+
+ +**card_exp_month:** `typing.Optional[int]` + +
+
+ +
+
+ +**card_exp_year:** `typing.Optional[int]` + +
+
+ +
+
+ +**card_last_4:** `typing.Optional[str]` + +
+
+ +
+
+ +**subscription_external_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.billing.upsert_billing_price(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.billing.upsert_billing_price( + interval="interval", + price=1, + price_external_id="price_external_id", + product_external_id="product_external_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**interval:** `str` + +
+
+ +
+
+ +**price:** `int` + +
+
+ +
+
+ +**price_external_id:** `str` + +
+
+ +
+
+ +**product_external_id:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.billing.list_product_prices(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.billing.list_product_prices() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.billing.upsert_billing_product(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.billing.upsert_billing_product( + currency="currency", + external_id="external_id", + name="name", + price=1.1, + quantity=1, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**currency:** `str` + +
+
+ +
+
+ +**external_id:** `str` + +
+
+ +
+
+ +**name:** `str` + +
+
+ +
+
+ +**price:** `float` + +
+
+ +
+
+ +**quantity:** `int` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.billing.list_billing_products(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.billing.list_billing_products() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.billing.count_billing_products(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.billing.count_billing_products() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.billing.upsert_billing_subscription(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime + +from schematic import BillingProductPricing, Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.billing.upsert_billing_subscription( + customer_external_id="customer_external_id", + expired_at=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + product_external_ids=[ + BillingProductPricing( + price=1, + product_external_id="product_external_id", + ) + ], + subscription_external_id="subscription_external_id", + total_price=1, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customer_external_id:** `str` + +
+
+ +
+
+ +**expired_at:** `dt.datetime` + +
+
+ +
+
+ +**product_external_ids:** `typing.Sequence[BillingProductPricing]` + +
+
+ +
+
+ +**subscription_external_id:** `str` + +
+
+ +
+
+ +**total_price:** `int` + +
+
+ +
+
+ +**interval:** `typing.Optional[str]` + +
+
+ +
+
+ +**metadata:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` + +
+
+ +
+
+ +**status:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## companies +
client.companies.list_companies(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.list_companies() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**plan_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` — Search filter + +
+
+ +
+
+ +**without_feature_override_for:** `typing.Optional[str]` — Filter out companies that already have a company override for the specified feature ID + +
+
+ +
+
+ +**without_plan:** `typing.Optional[bool]` — Filter out companies that have a plan + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.upsert_company(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.upsert_company( + keys={"key": "value"}, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**keys:** `typing.Dict[str, str]` + +
+
+ +
+
+ +**id:** `typing.Optional[str]` — If you know the Schematic ID, you can use that here instead of keys + +
+
+ +
+
+ +**last_seen_at:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**traits:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — A map of trait names to trait values + +
+
+ +
+
+ +**update_only:** `typing.Optional[bool]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.get_company(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.get_company( + company_id="company_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `str` — company_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.delete_company(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.delete_company( + company_id="company_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `str` — company_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.count_companies(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.count_companies() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**plan_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` — Search filter + +
+
+ +
+
+ +**without_feature_override_for:** `typing.Optional[str]` — Filter out companies that already have a company override for the specified feature ID + +
+
+ +
+
+ +**without_plan:** `typing.Optional[bool]` — Filter out companies that have a plan + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.create_company(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.create_company( + keys={"key": "value"}, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**keys:** `typing.Dict[str, str]` + +
+
+ +
+
+ +**id:** `typing.Optional[str]` — If you know the Schematic ID, you can use that here instead of keys + +
+
+ +
+
+ +**last_seen_at:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**traits:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — A map of trait names to trait values + +
+
+ +
+
+ +**update_only:** `typing.Optional[bool]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.delete_company_by_keys(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.delete_company_by_keys( + keys={"key": "value"}, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**keys:** `typing.Dict[str, str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.lookup_company(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.lookup_company( + keys={"string": {"key": "value"}}, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**keys:** `typing.Dict[str, typing.Optional[typing.Any]]` — Key/value pairs + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.get_active_deals(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.get_active_deals( + company_id="company_id", + deal_stage="deal_stage", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `str` + +
+
+ +
+
+ +**deal_stage:** `str` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.list_company_memberships(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.list_company_memberships() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**user_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.get_or_create_company_membership(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.get_or_create_company_membership( + company_id="company_id", + user_id="user_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `str` + +
+
+ +
+
+ +**user_id:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.delete_company_membership(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.delete_company_membership( + company_membership_id="company_membership_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_membership_id:** `str` — company_membership_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.get_active_company_subscription(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.get_active_company_subscription( + company_id="company_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `str` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.upsert_company_trait(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.upsert_company_trait( + keys={"key": "value"}, + trait="trait", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**keys:** `typing.Dict[str, str]` — Key/value pairs too identify a company or user + +
+
+ +
+
+ +**trait:** `str` — Name of the trait to update + +
+
+ +
+
+ +**incr:** `typing.Optional[int]` — Amount to increment the trait by (positive or negative) + +
+
+ +
+
+ +**set_:** `typing.Optional[str]` — Value to set the trait to + +
+
+ +
+
+ +**update_only:** `typing.Optional[bool]` — Unless this is set, the company or user will be created if it does not already exist + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.list_entity_key_definitions(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.list_entity_key_definitions() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_type:** `typing.Optional[ListEntityKeyDefinitionsRequestEntityType]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.count_entity_key_definitions(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.count_entity_key_definitions() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_type:** `typing.Optional[CountEntityKeyDefinitionsRequestEntityType]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.list_entity_trait_definitions(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.list_entity_trait_definitions() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_type:** `typing.Optional[ListEntityTraitDefinitionsRequestEntityType]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**trait_type:** `typing.Optional[ListEntityTraitDefinitionsRequestTraitType]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.get_or_create_entity_trait_definition(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.get_or_create_entity_trait_definition( + entity_type="company", + hierarchy=["hierarchy"], + trait_type="boolean", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_type:** `CreateEntityTraitDefinitionRequestBodyEntityType` + +
+
+ +
+
+ +**hierarchy:** `typing.Sequence[str]` + +
+
+ +
+
+ +**trait_type:** `CreateEntityTraitDefinitionRequestBodyTraitType` + +
+
+ +
+
+ +**display_name:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.get_entity_trait_definition(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.get_entity_trait_definition( + entity_trait_definition_id="entity_trait_definition_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_trait_definition_id:** `str` — entity_trait_definition_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.update_entity_trait_definition(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.update_entity_trait_definition( + entity_trait_definition_id="entity_trait_definition_id", + trait_type="boolean", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_trait_definition_id:** `str` — entity_trait_definition_id + +
+
+ +
+
+ +**trait_type:** `UpdateEntityTraitDefinitionRequestBodyTraitType` + +
+
+ +
+
+ +**display_name:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.count_entity_trait_definitions(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.count_entity_trait_definitions() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_type:** `typing.Optional[CountEntityTraitDefinitionsRequestEntityType]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**trait_type:** `typing.Optional[CountEntityTraitDefinitionsRequestTraitType]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.get_entity_trait_values(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.get_entity_trait_values( + definition_id="definition_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**definition_id:** `str` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.upsert_user_trait(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.upsert_user_trait( + keys={"key": "value"}, + trait="trait", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**keys:** `typing.Dict[str, str]` — Key/value pairs too identify a company or user + +
+
+ +
+
+ +**trait:** `str` — Name of the trait to update + +
+
+ +
+
+ +**incr:** `typing.Optional[int]` — Amount to increment the trait by (positive or negative) + +
+
+ +
+
+ +**set_:** `typing.Optional[str]` — Value to set the trait to + +
+
+ +
+
+ +**update_only:** `typing.Optional[bool]` — Unless this is set, the company or user will be created if it does not already exist + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.list_users(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.list_users() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**plan_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` — Search filter + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.upsert_user(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.upsert_user( + company={"key": "value"}, + keys={"key": "value"}, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company:** `typing.Dict[str, str]` — Optionally specify company using key/value pairs + +
+
+ +
+
+ +**keys:** `typing.Dict[str, str]` + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` — Optionally specify company using Schematic company ID + +
+
+ +
+
+ +**id:** `typing.Optional[str]` — If you know the Schematic ID, you can use that here instead of keys + +
+
+ +
+
+ +**last_seen_at:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**traits:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — A map of trait names to trait values + +
+
+ +
+
+ +**update_only:** `typing.Optional[bool]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.get_user(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.get_user( + user_id="user_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**user_id:** `str` — user_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.delete_user(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.delete_user( + user_id="user_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**user_id:** `str` — user_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.count_users(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.count_users() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**plan_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` — Search filter + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.create_user(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.create_user( + company={"key": "value"}, + keys={"key": "value"}, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company:** `typing.Dict[str, str]` — Optionally specify company using key/value pairs + +
+
+ +
+
+ +**keys:** `typing.Dict[str, str]` + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` — Optionally specify company using Schematic company ID + +
+
+ +
+
+ +**id:** `typing.Optional[str]` — If you know the Schematic ID, you can use that here instead of keys + +
+
+ +
+
+ +**last_seen_at:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**traits:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]` — A map of trait names to trait values + +
+
+ +
+
+ +**update_only:** `typing.Optional[bool]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.delete_user_by_keys(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.delete_user_by_keys( + keys={"key": "value"}, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**keys:** `typing.Dict[str, str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.companies.lookup_user(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.companies.lookup_user( + keys={"string": {"key": "value"}}, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**keys:** `typing.Dict[str, typing.Optional[typing.Any]]` — Key/value pairs + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## entitlements +
client.entitlements.list_company_overrides(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.list_company_overrides() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**company_ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**feature_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**feature_ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.create_company_override(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.create_company_override( + company_id="company_id", + feature_id="feature_id", + value_type="boolean", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `str` + +
+
+ +
+
+ +**feature_id:** `str` + +
+
+ +
+
+ +**value_type:** `CreateCompanyOverrideRequestBodyValueType` + +
+
+ +
+
+ +**metric_period:** `typing.Optional[CreateCompanyOverrideRequestBodyMetricPeriod]` + +
+
+ +
+
+ +**value_bool:** `typing.Optional[bool]` + +
+
+ +
+
+ +**value_numeric:** `typing.Optional[int]` + +
+
+ +
+
+ +**value_trait_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.get_company_override(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.get_company_override( + company_override_id="company_override_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_override_id:** `str` — company_override_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.update_company_override(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.update_company_override( + company_override_id="company_override_id", + value_type="boolean", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_override_id:** `str` — company_override_id + +
+
+ +
+
+ +**value_type:** `UpdateCompanyOverrideRequestBodyValueType` + +
+
+ +
+
+ +**metric_period:** `typing.Optional[UpdateCompanyOverrideRequestBodyMetricPeriod]` + +
+
+ +
+
+ +**value_bool:** `typing.Optional[bool]` + +
+
+ +
+
+ +**value_numeric:** `typing.Optional[int]` + +
+
+ +
+
+ +**value_trait_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.delete_company_override(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.delete_company_override( + company_override_id="company_override_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_override_id:** `str` — company_override_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.count_company_overrides(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.count_company_overrides() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**company_ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**feature_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**feature_ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.list_feature_companies(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.list_feature_companies( + feature_id="feature_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**feature_id:** `str` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.count_feature_companies(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.count_feature_companies( + feature_id="feature_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**feature_id:** `str` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.list_feature_usage(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.list_feature_usage() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**company_keys:** `typing.Optional[typing.Dict[str, str]]` + +
+
+ +
+
+ +**feature_ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.count_feature_usage(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.count_feature_usage() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**company_keys:** `typing.Optional[typing.Dict[str, str]]` + +
+
+ +
+
+ +**feature_ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.list_feature_users(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.list_feature_users( + feature_id="feature_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**feature_id:** `str` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.count_feature_users(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.count_feature_users( + feature_id="feature_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**feature_id:** `str` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.list_plan_entitlements(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.list_plan_entitlements() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**feature_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**feature_ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**plan_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**plan_ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.create_plan_entitlement(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.create_plan_entitlement( + feature_id="feature_id", + plan_id="plan_id", + value_type="boolean", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**feature_id:** `str` + +
+
+ +
+
+ +**plan_id:** `str` + +
+
+ +
+
+ +**value_type:** `CreatePlanEntitlementRequestBodyValueType` + +
+
+ +
+
+ +**metric_period:** `typing.Optional[CreatePlanEntitlementRequestBodyMetricPeriod]` + +
+
+ +
+
+ +**value_bool:** `typing.Optional[bool]` + +
+
+ +
+
+ +**value_numeric:** `typing.Optional[int]` + +
+
+ +
+
+ +**value_trait_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.get_plan_entitlement(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.get_plan_entitlement( + plan_entitlement_id="plan_entitlement_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**plan_entitlement_id:** `str` — plan_entitlement_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.update_plan_entitlement(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.update_plan_entitlement( + plan_entitlement_id="plan_entitlement_id", + value_type="boolean", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**plan_entitlement_id:** `str` — plan_entitlement_id + +
+
+ +
+
+ +**value_type:** `UpdatePlanEntitlementRequestBodyValueType` + +
+
+ +
+
+ +**metric_period:** `typing.Optional[UpdatePlanEntitlementRequestBodyMetricPeriod]` + +
+
+ +
+
+ +**value_bool:** `typing.Optional[bool]` + +
+
+ +
+
+ +**value_numeric:** `typing.Optional[int]` + +
+
+ +
+
+ +**value_trait_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.delete_plan_entitlement(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.delete_plan_entitlement( + plan_entitlement_id="plan_entitlement_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**plan_entitlement_id:** `str` — plan_entitlement_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.count_plan_entitlements(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.count_plan_entitlements() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**feature_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**feature_ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**plan_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**plan_ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.entitlements.get_feature_usage_by_company(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.entitlements.get_feature_usage_by_company( + keys={"string": {"key": "value"}}, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**keys:** `typing.Dict[str, typing.Optional[typing.Any]]` — Key/value pairs + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## components +
client.components.list_components(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.components.list_components() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.components.create_component(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.components.create_component( + entity_type="entitlement", + name="name", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entity_type:** `CreateComponentRequestBodyEntityType` + +
+
+ +
+
+ +**name:** `str` + +
+
+ +
+
+ +**ast:** `typing.Optional[typing.Dict[str, float]]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.components.get_component(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.components.get_component( + component_id="component_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**component_id:** `str` — component_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.components.update_component(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.components.update_component( + component_id="component_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**component_id:** `str` — component_id + +
+
+ +
+
+ +**ast:** `typing.Optional[typing.Dict[str, float]]` + +
+
+ +
+
+ +**entity_type:** `typing.Optional[UpdateComponentRequestBodyEntityType]` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**state:** `typing.Optional[UpdateComponentRequestBodyState]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.components.delete_component(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.components.delete_component( + component_id="component_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**component_id:** `str` — component_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.components.count_components(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.components.count_components() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.components.preview_component_data(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.components.preview_component_data() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**component_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## crm +
client.crm.upsert_deal_line_item_association(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.crm.upsert_deal_line_item_association( + deal_external_id="deal_external_id", + line_item_external_id="line_item_external_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**deal_external_id:** `str` + +
+
+ +
+
+ +**line_item_external_id:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.crm.upsert_line_item(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.crm.upsert_line_item( + amount="amount", + interval="interval", + line_item_external_id="line_item_external_id", + product_external_id="product_external_id", + quantity=1, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**amount:** `str` + +
+
+ +
+
+ +**interval:** `str` + +
+
+ +
+
+ +**line_item_external_id:** `str` + +
+
+ +
+
+ +**product_external_id:** `str` + +
+
+ +
+
+ +**quantity:** `int` + +
+
+ +
+
+ +**term_month:** `typing.Optional[int]` + +
+
+ +
+
+ +**discount_percentage:** `typing.Optional[str]` + +
+
+ +
+
+ +**total_discount:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.crm.upsert_crm_deal(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.crm.upsert_crm_deal( + crm_company_key="crm_company_key", + crm_type="crm_type", + deal_external_id="deal_external_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**crm_company_key:** `str` + +
+
+ +
+
+ +**crm_type:** `str` + +
+
+ +
+
+ +**deal_external_id:** `str` + +
+
+ +
+
+ +**arr:** `typing.Optional[str]` + +
+
+ +
+
+ +**crm_company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**crm_product_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**deal_name:** `typing.Optional[str]` + +
+
+ +
+
+ +**deal_stage:** `typing.Optional[str]` + +
+
+ +
+
+ +**mrr:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.crm.list_crm_products(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.crm.list_crm_products() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.crm.upsert_crm_product(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.crm.upsert_crm_product( + currency="currency", + description="description", + external_id="external_id", + interval="interval", + name="name", + price="price", + quantity=1, + sku="sku", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**currency:** `str` + +
+
+ +
+
+ +**description:** `str` + +
+
+ +
+
+ +**external_id:** `str` + +
+
+ +
+
+ +**interval:** `str` + +
+
+ +
+
+ +**name:** `str` + +
+
+ +
+
+ +**price:** `str` + +
+
+ +
+
+ +**quantity:** `int` + +
+
+ +
+
+ +**sku:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## events +
client.events.create_event_batch(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import CreateEventRequestBody, Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.events.create_event_batch( + events=[ + CreateEventRequestBody( + event_type="identify", + ) + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**events:** `typing.Sequence[CreateEventRequestBody]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.events.get_event_summaries(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.events.get_event_summaries() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**event_subtypes:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.events.get_event_summary_by_subtype(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.events.get_event_summary_by_subtype( + key="key", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**key:** `str` — key + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.events.list_events(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.events.list_events() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**event_subtype:** `typing.Optional[str]` + +
+
+ +
+
+ +**event_types:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**flag_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**user_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.events.create_event(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.events.create_event( + event_type="identify", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**event_type:** `CreateEventRequestBodyEventType` — Either 'identify' or 'track' + +
+
+ +
+
+ +**body:** `typing.Optional[EventBody]` + +
+
+ +
+
+ +**sent_at:** `typing.Optional[dt.datetime]` — Optionally provide a timestamp at which the event was sent to Schematic + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.events.get_event(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.events.get_event( + event_id="event_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**event_id:** `str` — event_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.events.list_metric_counts(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.events.list_metric_counts() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**start_time:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**end_time:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**event_subtype:** `typing.Optional[str]` + +
+
+ +
+
+ +**event_subtypes:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**company_ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**user_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**grouping:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.events.get_segment_integration_status() +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.events.get_segment_integration_status() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## plans +
client.plans.get_audience(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.plans.get_audience( + plan_audience_id="plan_audience_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**plan_audience_id:** `str` — plan_audience_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.plans.update_audience(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import ( + CreateOrUpdateConditionGroupRequestBody, + CreateOrUpdateConditionRequestBody, + Schematic, +) + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.plans.update_audience( + plan_audience_id="plan_audience_id", + condition_groups=[ + CreateOrUpdateConditionGroupRequestBody( + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + ], + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**plan_audience_id:** `str` — plan_audience_id + +
+
+ +
+
+ +**condition_groups:** `typing.Sequence[CreateOrUpdateConditionGroupRequestBody]` + +
+
+ +
+
+ +**conditions:** `typing.Sequence[CreateOrUpdateConditionRequestBody]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.plans.delete_audience(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.plans.delete_audience( + plan_audience_id="plan_audience_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**plan_audience_id:** `str` — plan_audience_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.plans.list_plans(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.plans.list_plans() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**plan_type:** `typing.Optional[ListPlansRequestPlanType]` — Filter by plan type + +
+
+ +
+
+ +**has_product_id:** `typing.Optional[bool]` — Filter out plans that do not have a billing product ID + +
+
+ +
+
+ +**without_entitlement_for:** `typing.Optional[str]` — Filter out plans that already have a plan entitlement for the specified feature ID + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.plans.create_plan(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.plans.create_plan( + description="description", + name="name", + plan_type="plan", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**description:** `str` + +
+
+ +
+
+ +**name:** `str` + +
+
+ +
+
+ +**plan_type:** `CreatePlanRequestBodyPlanType` + +
+
+ +
+
+ +**icon:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.plans.get_plan(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.plans.get_plan( + plan_id="plan_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**plan_id:** `str` — plan_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.plans.update_plan(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.plans.update_plan( + plan_id="plan_id", + name="name", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**plan_id:** `str` — plan_id + +
+
+ +
+
+ +**name:** `str` + +
+
+ +
+
+ +**description:** `typing.Optional[str]` + +
+
+ +
+
+ +**icon:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.plans.delete_plan(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.plans.delete_plan( + plan_id="plan_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**plan_id:** `str` — plan_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.plans.upsert_billing_product_plan(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.plans.upsert_billing_product_plan( + plan_id="plan_id", + billing_product_id="billing_product_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**plan_id:** `str` — plan_id + +
+
+ +
+
+ +**billing_product_id:** `str` + +
+
+ +
+
+ +**monthly_price_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**yearly_price_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.plans.count_plans(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.plans.count_plans() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**plan_type:** `typing.Optional[CountPlansRequestPlanType]` — Filter by plan type + +
+
+ +
+
+ +**has_product_id:** `typing.Optional[bool]` — Filter out plans that do not have a billing product ID + +
+
+ +
+
+ +**without_entitlement_for:** `typing.Optional[str]` — Filter out plans that already have a plan entitlement for the specified feature ID + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## plangroups +
client.plangroups.get_plan_group() +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.plangroups.get_plan_group() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.plangroups.create_plan_group(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.plangroups.create_plan_group( + plan_ids=["plan_ids"], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**plan_ids:** `typing.Sequence[str]` + +
+
+ +
+
+ +**default_plan_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.plangroups.update_plan_group(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.plangroups.update_plan_group( + plan_group_id="plan_group_id", + plan_ids=["plan_ids"], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**plan_group_id:** `str` — plan_group_id + +
+
+ +
+
+ +**plan_ids:** `typing.Sequence[str]` + +
+
+ +
+
+ +**default_plan_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## accesstokens +
client.accesstokens.issue_temporary_access_token(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.accesstokens.issue_temporary_access_token( + lookup={"key": "value"}, + resource_type="resource_type", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**lookup:** `typing.Dict[str, str]` + +
+
+ +
+
+ +**resource_type:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## webhooks +
client.webhooks.list_webhook_events(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.webhooks.list_webhook_events() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhook_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.webhooks.get_webhook_event(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.webhooks.get_webhook_event( + webhook_event_id="webhook_event_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhook_event_id:** `str` — webhook_event_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.webhooks.count_webhook_events(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.webhooks.count_webhook_events() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhook_id:** `typing.Optional[str]` + +
+
+ +
+
+ +**ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.webhooks.list_webhooks(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.webhooks.list_webhooks() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.webhooks.create_webhook(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.webhooks.create_webhook( + name="name", + request_types=["company.updated"], + url="url", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**name:** `str` + +
+
+ +
+
+ +**request_types:** `typing.Sequence[CreateWebhookRequestBodyRequestTypesItem]` + +
+
+ +
+
+ +**url:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.webhooks.get_webhook(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.webhooks.get_webhook( + webhook_id="webhook_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhook_id:** `str` — webhook_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.webhooks.update_webhook(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.webhooks.update_webhook( + webhook_id="webhook_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhook_id:** `str` — webhook_id + +
+
+ +
+
+ +**name:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_types:** `typing.Optional[typing.Sequence[UpdateWebhookRequestBodyRequestTypesItem]]` + +
+
+ +
+
+ +**status:** `typing.Optional[UpdateWebhookRequestBodyStatus]` + +
+
+ +
+
+ +**url:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.webhooks.delete_webhook(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.webhooks.delete_webhook( + webhook_id="webhook_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhook_id:** `str` — webhook_id + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.webhooks.count_webhooks(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from schematic import Schematic + +client = Schematic( + api_key="YOUR_API_KEY", +) +client.webhooks.count_webhooks() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**q:** `typing.Optional[str]` + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `typing.Optional[int]` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ diff --git a/src/schematic/__init__.py b/src/schematic/__init__.py index 4f87ef2..96184a6 100644 --- a/src/schematic/__init__.py +++ b/src/schematic/__init__.py @@ -7,6 +7,15 @@ ApiKeyRequestResponseData, ApiKeyResponseData, AudienceRequestBody, + BillingCustomerResponseData, + BillingCustomerSubscription, + BillingCustomerWithSubscriptionsResponseData, + BillingPlan, + BillingPriceResponseData, + BillingProductDetailResponseData, + BillingProductForSubscriptionResponseData, + BillingProductPlanResponseData, + BillingProductPricing, BillingProductResponseData, BillingSubscriptionResponseData, CheckFlagOutputWithFlagKey, @@ -18,9 +27,11 @@ CompanyMembershipDetailResponseData, CompanyMembershipResponseData, CompanyOverrideResponseData, - CompanyPlanResponseData, + CompanyPlanDetailResponseData, CompanyResponseData, CompanySubscriptionResponseData, + ComponentHydrateResponseData, + ComponentResponseData, CountResponse, CreateEventRequestBody, CreateEventRequestBodyEventType, @@ -52,6 +63,7 @@ EnvironmentDetailResponseData, EnvironmentResponseData, EventBody, + EventBodyFlagCheck, EventBodyIdentify, EventBodyIdentifyCompany, EventBodyTrack, @@ -59,22 +71,31 @@ EventResponseData, EventSummaryResponseData, FeatureCompanyResponseData, + FeatureCompanyResponseDataAllocationType, FeatureCompanyUserResponseData, + FeatureCompanyUserResponseDataAllocationType, FeatureDetailResponseData, FeatureResponseData, FeatureUsageDetailResponseData, FeatureUsageResponseData, - FlagCheckLogDetailResponseData, - FlagCheckLogResponseData, + FeatureUsageResponseDataAllocationType, FlagDetailResponseData, FlagResponseData, + InvoiceRequestBody, + InvoiceResponseData, + IssueTemporaryAccessTokenResponseData, KeysRequestBody, MetricCountsHourlyResponseData, PaginationFilter, + PaymentMethodRequestBody, + PaymentMethodResponseData, PlanAudienceDetailResponseData, PlanAudienceResponseData, PlanDetailResponseData, PlanEntitlementResponseData, + PlanGroupDetailResponseData, + PlanGroupPlanDetailResponseData, + PlanGroupResponseData, PlanResponseData, PreviewObject, RawEventBatchResponseData, @@ -88,6 +109,8 @@ RuleResponseData, RulesDetailResponseData, SegmentStatusResp, + StripeEmbedInfo, + TemporaryAccessTokenResponseData, UpdateReqCommon, UpdateReqCommonMetricPeriod, UpdateReqCommonValueType, @@ -103,7 +126,21 @@ WebhookResponseData, ) from .errors import BadRequestError, ForbiddenError, InternalServerError, NotFoundError, UnauthorizedError -from . import accounts, billing, companies, crm, entitlements, events, features, plans, webhooks +from . import ( + accesstokens, + accounts, + billing, + companies, + components, + crm, + entitlements, + events, + features, + plangroups, + plans, + webhooks, +) +from .accesstokens import IssueTemporaryAccessTokenResponse from .accounts import ( CountApiKeysParams, CountApiKeysResponse, @@ -128,10 +165,26 @@ UpdateEnvironmentResponse, ) from .billing import ( - ListProductsParams, - ListProductsResponse, + CountBillingProductsParams, + CountBillingProductsResponse, + CountCustomersParams, + CountCustomersResponse, + ListBillingProductsParams, + ListBillingProductsResponse, + ListCustomersParams, + ListCustomersResponse, + ListInvoicesParams, + ListInvoicesResponse, + ListPaymentMethodsParams, + ListPaymentMethodsResponse, + ListProductPricesParams, + ListProductPricesResponse, + UpsertBillingCustomerResponse, + UpsertBillingPriceResponse, UpsertBillingProductResponse, UpsertBillingSubscriptionResponse, + UpsertInvoiceResponse, + UpsertPaymentMethodResponse, ) from .client import AsyncSchematic, AsyncSchematicConfig, LocalCache, Schematic, SchematicConfig from .companies import ( @@ -173,8 +226,6 @@ ListCompaniesResponse, ListCompanyMembershipsParams, ListCompanyMembershipsResponse, - ListCompanyPlansParams, - ListCompanyPlansResponse, ListEntityKeyDefinitionsParams, ListEntityKeyDefinitionsRequestEntityType, ListEntityKeyDefinitionsResponse, @@ -198,6 +249,21 @@ UpsertUserResponse, UpsertUserTraitResponse, ) +from .components import ( + CountComponentsParams, + CountComponentsResponse, + CreateComponentRequestBodyEntityType, + CreateComponentResponse, + DeleteComponentResponse, + GetComponentResponse, + ListComponentsParams, + ListComponentsResponse, + PreviewComponentDataParams, + PreviewComponentDataResponse, + UpdateComponentRequestBodyEntityType, + UpdateComponentRequestBodyState, + UpdateComponentResponse, +) from .crm import ( ListCrmProductsParams, ListCrmProductsResponse, @@ -267,8 +333,6 @@ CountAudienceUsersResponse, CountFeaturesParams, CountFeaturesResponse, - CountFlagChecksParams, - CountFlagChecksResponse, CountFlagsParams, CountFlagsResponse, CreateFeatureRequestBodyFeatureType, @@ -277,16 +341,11 @@ DeleteFeatureResponse, DeleteFlagResponse, GetFeatureResponse, - GetFlagCheckResponse, GetFlagResponse, - GetLatestFlagChecksParams, - GetLatestFlagChecksResponse, ListAudienceCompaniesResponse, ListAudienceUsersResponse, ListFeaturesParams, ListFeaturesResponse, - ListFlagChecksParams, - ListFlagChecksResponse, ListFlagsParams, ListFlagsResponse, UpdateFeatureRequestBodyFeatureType, @@ -294,9 +353,12 @@ UpdateFlagResponse, UpdateFlagRulesResponse, ) +from .plangroups import CreatePlanGroupResponse, GetPlanGroupResponse, UpdatePlanGroupResponse from .plans import ( CountPlansParams, + CountPlansRequestPlanType, CountPlansResponse, + CountPlansResponseParamsPlanType, CreatePlanRequestBodyPlanType, CreatePlanResponse, DeleteAudienceResponse, @@ -304,10 +366,12 @@ GetAudienceResponse, GetPlanResponse, ListPlansParams, + ListPlansRequestPlanType, ListPlansResponse, + ListPlansResponseParamsPlanType, UpdateAudienceResponse, - UpdatePlanRequestBodyPlanType, UpdatePlanResponse, + UpsertBillingProductPlanResponse, ) from .version import __version__ from .webhooks import ( @@ -325,6 +389,7 @@ ListWebhooksParams, ListWebhooksResponse, UpdateWebhookRequestBodyRequestTypesItem, + UpdateWebhookRequestBodyStatus, UpdateWebhookResponse, ) @@ -338,6 +403,15 @@ "AsyncSchematicConfig", "AudienceRequestBody", "BadRequestError", + "BillingCustomerResponseData", + "BillingCustomerSubscription", + "BillingCustomerWithSubscriptionsResponseData", + "BillingPlan", + "BillingPriceResponseData", + "BillingProductDetailResponseData", + "BillingProductForSubscriptionResponseData", + "BillingProductPlanResponseData", + "BillingProductPricing", "BillingProductResponseData", "BillingSubscriptionResponseData", "CheckFlagOutputWithFlagKey", @@ -351,19 +425,27 @@ "CompanyMembershipDetailResponseData", "CompanyMembershipResponseData", "CompanyOverrideResponseData", - "CompanyPlanResponseData", + "CompanyPlanDetailResponseData", "CompanyResponseData", "CompanySubscriptionResponseData", + "ComponentHydrateResponseData", + "ComponentResponseData", "CountApiKeysParams", "CountApiKeysResponse", "CountApiRequestsParams", "CountApiRequestsResponse", "CountAudienceCompaniesResponse", "CountAudienceUsersResponse", + "CountBillingProductsParams", + "CountBillingProductsResponse", "CountCompaniesParams", "CountCompaniesResponse", "CountCompanyOverridesParams", "CountCompanyOverridesResponse", + "CountComponentsParams", + "CountComponentsResponse", + "CountCustomersParams", + "CountCustomersResponse", "CountEntityKeyDefinitionsParams", "CountEntityKeyDefinitionsRequestEntityType", "CountEntityKeyDefinitionsResponse", @@ -382,14 +464,14 @@ "CountFeatureUsersResponse", "CountFeaturesParams", "CountFeaturesResponse", - "CountFlagChecksParams", - "CountFlagChecksResponse", "CountFlagsParams", "CountFlagsResponse", "CountPlanEntitlementsParams", "CountPlanEntitlementsResponse", "CountPlansParams", + "CountPlansRequestPlanType", "CountPlansResponse", + "CountPlansResponseParamsPlanType", "CountResponse", "CountUsersParams", "CountUsersResponse", @@ -402,6 +484,8 @@ "CreateCompanyOverrideRequestBodyValueType", "CreateCompanyOverrideResponse", "CreateCompanyResponse", + "CreateComponentRequestBodyEntityType", + "CreateComponentResponse", "CreateEntityTraitDefinitionRequestBodyEntityType", "CreateEntityTraitDefinitionRequestBodyTraitType", "CreateEnvironmentRequestBodyEnvironmentType", @@ -425,6 +509,7 @@ "CreatePlanEntitlementRequestBodyMetricPeriod", "CreatePlanEntitlementRequestBodyValueType", "CreatePlanEntitlementResponse", + "CreatePlanGroupResponse", "CreatePlanRequestBodyPlanType", "CreatePlanResponse", "CreateReqCommon", @@ -444,6 +529,7 @@ "DeleteCompanyMembershipResponse", "DeleteCompanyOverrideResponse", "DeleteCompanyResponse", + "DeleteComponentResponse", "DeleteEnvironmentResponse", "DeleteFeatureResponse", "DeleteFlagResponse", @@ -463,6 +549,7 @@ "EnvironmentDetailResponseData", "EnvironmentResponseData", "EventBody", + "EventBodyFlagCheck", "EventBodyIdentify", "EventBodyIdentifyCompany", "EventBodyTrack", @@ -470,13 +557,14 @@ "EventResponseData", "EventSummaryResponseData", "FeatureCompanyResponseData", + "FeatureCompanyResponseDataAllocationType", "FeatureCompanyUserResponseData", + "FeatureCompanyUserResponseDataAllocationType", "FeatureDetailResponseData", "FeatureResponseData", "FeatureUsageDetailResponseData", "FeatureUsageResponseData", - "FlagCheckLogDetailResponseData", - "FlagCheckLogResponseData", + "FeatureUsageResponseDataAllocationType", "FlagDetailResponseData", "FlagResponseData", "ForbiddenError", @@ -489,6 +577,7 @@ "GetAudienceResponse", "GetCompanyOverrideResponse", "GetCompanyResponse", + "GetComponentResponse", "GetEntityTraitDefinitionResponse", "GetEntityTraitValuesParams", "GetEntityTraitValuesResponse", @@ -500,19 +589,21 @@ "GetFeatureResponse", "GetFeatureUsageByCompanyParams", "GetFeatureUsageByCompanyResponse", - "GetFlagCheckResponse", "GetFlagResponse", - "GetLatestFlagChecksParams", - "GetLatestFlagChecksResponse", "GetOrCreateCompanyMembershipResponse", "GetOrCreateEntityTraitDefinitionResponse", "GetPlanEntitlementResponse", + "GetPlanGroupResponse", "GetPlanResponse", "GetSegmentIntegrationStatusResponse", "GetUserResponse", "GetWebhookEventResponse", "GetWebhookResponse", "InternalServerError", + "InvoiceRequestBody", + "InvoiceResponseData", + "IssueTemporaryAccessTokenResponse", + "IssueTemporaryAccessTokenResponseData", "KeysRequestBody", "ListApiKeysParams", "ListApiKeysResponse", @@ -520,16 +611,20 @@ "ListApiRequestsResponse", "ListAudienceCompaniesResponse", "ListAudienceUsersResponse", + "ListBillingProductsParams", + "ListBillingProductsResponse", "ListCompaniesParams", "ListCompaniesResponse", "ListCompanyMembershipsParams", "ListCompanyMembershipsResponse", "ListCompanyOverridesParams", "ListCompanyOverridesResponse", - "ListCompanyPlansParams", - "ListCompanyPlansResponse", + "ListComponentsParams", + "ListComponentsResponse", "ListCrmProductsParams", "ListCrmProductsResponse", + "ListCustomersParams", + "ListCustomersResponse", "ListEntityKeyDefinitionsParams", "ListEntityKeyDefinitionsRequestEntityType", "ListEntityKeyDefinitionsResponse", @@ -552,18 +647,22 @@ "ListFeatureUsersResponse", "ListFeaturesParams", "ListFeaturesResponse", - "ListFlagChecksParams", - "ListFlagChecksResponse", "ListFlagsParams", "ListFlagsResponse", + "ListInvoicesParams", + "ListInvoicesResponse", "ListMetricCountsParams", "ListMetricCountsResponse", + "ListPaymentMethodsParams", + "ListPaymentMethodsResponse", "ListPlanEntitlementsParams", "ListPlanEntitlementsResponse", "ListPlansParams", + "ListPlansRequestPlanType", "ListPlansResponse", - "ListProductsParams", - "ListProductsResponse", + "ListPlansResponseParamsPlanType", + "ListProductPricesParams", + "ListProductPricesResponse", "ListUsersParams", "ListUsersResponse", "ListWebhookEventsParams", @@ -578,11 +677,18 @@ "MetricCountsHourlyResponseData", "NotFoundError", "PaginationFilter", + "PaymentMethodRequestBody", + "PaymentMethodResponseData", "PlanAudienceDetailResponseData", "PlanAudienceResponseData", "PlanDetailResponseData", "PlanEntitlementResponseData", + "PlanGroupDetailResponseData", + "PlanGroupPlanDetailResponseData", + "PlanGroupResponseData", "PlanResponseData", + "PreviewComponentDataParams", + "PreviewComponentDataResponse", "PreviewObject", "RawEventBatchResponseData", "RawEventResponseData", @@ -598,12 +704,17 @@ "SchematicConfig", "SchematicEnvironment", "SegmentStatusResp", + "StripeEmbedInfo", + "TemporaryAccessTokenResponseData", "UnauthorizedError", "UpdateApiKeyResponse", "UpdateAudienceResponse", "UpdateCompanyOverrideRequestBodyMetricPeriod", "UpdateCompanyOverrideRequestBodyValueType", "UpdateCompanyOverrideResponse", + "UpdateComponentRequestBodyEntityType", + "UpdateComponentRequestBodyState", + "UpdateComponentResponse", "UpdateEntityTraitDefinitionRequestBodyTraitType", "UpdateEntityTraitDefinitionResponse", "UpdateEnvironmentRequestBodyEnvironmentType", @@ -615,14 +726,18 @@ "UpdatePlanEntitlementRequestBodyMetricPeriod", "UpdatePlanEntitlementRequestBodyValueType", "UpdatePlanEntitlementResponse", - "UpdatePlanRequestBodyPlanType", + "UpdatePlanGroupResponse", "UpdatePlanResponse", "UpdateReqCommon", "UpdateReqCommonMetricPeriod", "UpdateReqCommonValueType", "UpdateRuleRequestBody", "UpdateWebhookRequestBodyRequestTypesItem", + "UpdateWebhookRequestBodyStatus", "UpdateWebhookResponse", + "UpsertBillingCustomerResponse", + "UpsertBillingPriceResponse", + "UpsertBillingProductPlanResponse", "UpsertBillingProductResponse", "UpsertBillingSubscriptionResponse", "UpsertCompanyRequestBody", @@ -631,7 +746,9 @@ "UpsertCrmDealResponse", "UpsertCrmProductResponse", "UpsertDealLineItemAssociationResponse", + "UpsertInvoiceResponse", "UpsertLineItemResponse", + "UpsertPaymentMethodResponse", "UpsertTraitRequestBody", "UpsertUserRequestBody", "UpsertUserResponse", @@ -643,13 +760,16 @@ "WebhookEventResponseData", "WebhookResponseData", "__version__", + "accesstokens", "accounts", "billing", "companies", + "components", "crm", "entitlements", "events", "features", + "plangroups", "plans", "webhooks", ] diff --git a/src/schematic/accesstokens/__init__.py b/src/schematic/accesstokens/__init__.py new file mode 100644 index 0000000..6aad770 --- /dev/null +++ b/src/schematic/accesstokens/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .types import IssueTemporaryAccessTokenResponse + +__all__ = ["IssueTemporaryAccessTokenResponse"] diff --git a/src/schematic/accesstokens/client.py b/src/schematic/accesstokens/client.py new file mode 100644 index 0000000..a1ced65 --- /dev/null +++ b/src/schematic/accesstokens/client.py @@ -0,0 +1,232 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from ..core.client_wrapper import SyncClientWrapper +from ..core.request_options import RequestOptions +from .types.issue_temporary_access_token_response import IssueTemporaryAccessTokenResponse +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 ..errors.forbidden_error import ForbiddenError +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 + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class AccesstokensClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def issue_temporary_access_token( + self, + *, + lookup: typing.Dict[str, str], + resource_type: str, + request_options: typing.Optional[RequestOptions] = None, + ) -> IssueTemporaryAccessTokenResponse: + """ + Parameters + ---------- + lookup : typing.Dict[str, str] + + resource_type : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + IssueTemporaryAccessTokenResponse + Created + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.accesstokens.issue_temporary_access_token( + lookup={"key": "value"}, + resource_type="resource_type", + ) + """ + _response = self._client_wrapper.httpx_client.request( + "temporary-access-tokens", + method="POST", + json={ + "lookup": lookup, + "resource_type": resource_type, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + IssueTemporaryAccessTokenResponse, + parse_obj_as( + type_=IssueTemporaryAccessTokenResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + +class AsyncAccesstokensClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def issue_temporary_access_token( + self, + *, + lookup: typing.Dict[str, str], + resource_type: str, + request_options: typing.Optional[RequestOptions] = None, + ) -> IssueTemporaryAccessTokenResponse: + """ + Parameters + ---------- + lookup : typing.Dict[str, str] + + resource_type : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + IssueTemporaryAccessTokenResponse + Created + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.accesstokens.issue_temporary_access_token( + lookup={"key": "value"}, + resource_type="resource_type", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "temporary-access-tokens", + method="POST", + json={ + "lookup": lookup, + "resource_type": resource_type, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + IssueTemporaryAccessTokenResponse, + parse_obj_as( + type_=IssueTemporaryAccessTokenResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) diff --git a/src/schematic/accesstokens/types/__init__.py b/src/schematic/accesstokens/types/__init__.py new file mode 100644 index 0000000..aa03522 --- /dev/null +++ b/src/schematic/accesstokens/types/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .issue_temporary_access_token_response import IssueTemporaryAccessTokenResponse + +__all__ = ["IssueTemporaryAccessTokenResponse"] diff --git a/src/schematic/accesstokens/types/issue_temporary_access_token_response.py b/src/schematic/accesstokens/types/issue_temporary_access_token_response.py new file mode 100644 index 0000000..0b99b85 --- /dev/null +++ b/src/schematic/accesstokens/types/issue_temporary_access_token_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.issue_temporary_access_token_response_data import IssueTemporaryAccessTokenResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class IssueTemporaryAccessTokenResponse(UniversalBaseModel): + data: IssueTemporaryAccessTokenResponseData + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/accounts/client.py b/src/schematic/accounts/client.py index 313b508..af4bfff 100644 --- a/src/schematic/accounts/client.py +++ b/src/schematic/accounts/client.py @@ -1,38 +1,35 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse -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.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 -from ..core.query_encoder import encode_query -from ..core.remove_none_from_dict import remove_none_from_dict +from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions +from .types.list_api_keys_response import ListApiKeysResponse +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 ..errors.forbidden_error import ForbiddenError 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.create_api_key_response import CreateApiKeyResponse +from .types.get_api_key_response import GetApiKeyResponse +from ..core.jsonable_encoder import jsonable_encoder 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.update_api_key_response import UpdateApiKeyResponse +from .types.delete_api_key_response import DeleteApiKeyResponse from .types.count_api_keys_response import CountApiKeysResponse +from .types.list_api_requests_response import ListApiRequestsResponse +from .types.get_api_request_response import GetApiRequestResponse from .types.count_api_requests_response import CountApiRequestsResponse -from .types.create_api_key_response import CreateApiKeyResponse +from .types.list_environments_response import ListEnvironmentsResponse from .types.create_environment_request_body_environment_type import CreateEnvironmentRequestBodyEnvironmentType from .types.create_environment_response import CreateEnvironmentResponse -from .types.delete_api_key_response import DeleteApiKeyResponse -from .types.delete_environment_response import DeleteEnvironmentResponse -from .types.get_api_key_response import GetApiKeyResponse -from .types.get_api_request_response import GetApiRequestResponse from .types.get_environment_response import GetEnvironmentResponse -from .types.list_api_keys_response import ListApiKeysResponse -from .types.list_api_requests_response import ListApiRequestsResponse -from .types.list_environments_response import ListEnvironmentsResponse -from .types.update_api_key_response import UpdateApiKeyResponse from .types.update_environment_request_body_environment_type import UpdateEnvironmentRequestBodyEnvironmentType from .types.update_environment_response import UpdateEnvironmentResponse +from .types.delete_environment_response import DeleteEnvironmentResponse +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -74,7 +71,7 @@ def list_api_keys( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -84,54 +81,65 @@ def list_api_keys( ) """ _response = self._client_wrapper.httpx_client.request( + "api-keys", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api-keys"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "environment_id": environment_id, - "require_environment": require_environment, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListApiKeysResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "environment_id": environment_id, + "require_environment": require_environment, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListApiKeysResponse, + parse_obj_as( + type_=ListApiKeysResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -164,7 +172,7 @@ def create_api_key( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -173,54 +181,66 @@ def create_api_key( name="name", ) """ - _request: typing.Dict[str, typing.Any] = {"name": name} - if description is not OMIT: - _request["description"] = description - if environment_id is not OMIT: - _request["environment_id"] = environment_id _response = self._client_wrapper.httpx_client.request( + "api-keys", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api-keys"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "description": description, + "environment_id": environment_id, + "name": name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateApiKeyResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateApiKeyResponse, + parse_obj_as( + type_=CreateApiKeyResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -245,7 +265,7 @@ def get_api_key( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -255,44 +275,59 @@ def get_api_key( ) """ _response = self._client_wrapper.httpx_client.request( + f"api-keys/{jsonable_encoder(api_key_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"api-keys/{jsonable_encoder(api_key_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetApiKeyResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetApiKeyResponse, + parse_obj_as( + type_=GetApiKeyResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -326,7 +361,7 @@ def update_api_key( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -335,58 +370,75 @@ def update_api_key( api_key_id="api_key_id", ) """ - _request: typing.Dict[str, typing.Any] = {} - if description is not OMIT: - _request["description"] = description - if name is not OMIT: - _request["name"] = name _response = self._client_wrapper.httpx_client.request( + f"api-keys/{jsonable_encoder(api_key_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"api-keys/{jsonable_encoder(api_key_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "description": description, + "name": name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateApiKeyResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateApiKeyResponse, + parse_obj_as( + type_=UpdateApiKeyResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -411,7 +463,7 @@ def delete_api_key( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -421,44 +473,59 @@ def delete_api_key( ) """ _response = self._client_wrapper.httpx_client.request( + f"api-keys/{jsonable_encoder(api_key_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"api-keys/{jsonable_encoder(api_key_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteApiKeyResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteApiKeyResponse, + parse_obj_as( + type_=DeleteApiKeyResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -496,7 +563,7 @@ def count_api_keys( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -506,54 +573,65 @@ def count_api_keys( ) """ _response = self._client_wrapper.httpx_client.request( + "api-keys/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api-keys/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "environment_id": environment_id, - "require_environment": require_environment, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountApiKeysResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "environment_id": environment_id, + "require_environment": require_environment, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountApiKeysResponse, + parse_obj_as( + type_=CountApiKeysResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -594,7 +672,7 @@ def list_api_requests( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -602,55 +680,66 @@ def list_api_requests( client.accounts.list_api_requests() """ _response = self._client_wrapper.httpx_client.request( + "api-requests", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api-requests"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "q": q, - "request_type": request_type, - "environment_id": environment_id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListApiRequestsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "q": q, + "request_type": request_type, + "environment_id": environment_id, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListApiRequestsResponse, + parse_obj_as( + type_=ListApiRequestsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -675,7 +764,7 @@ def get_api_request( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -685,44 +774,59 @@ def get_api_request( ) """ _response = self._client_wrapper.httpx_client.request( + f"api-requests/{jsonable_encoder(api_request_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"api-requests/{jsonable_encoder(api_request_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetApiRequestResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetApiRequestResponse, + parse_obj_as( + type_=GetApiRequestResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -763,7 +867,7 @@ def count_api_requests( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -771,55 +875,66 @@ def count_api_requests( client.accounts.count_api_requests() """ _response = self._client_wrapper.httpx_client.request( + "api-requests/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api-requests/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "q": q, - "request_type": request_type, - "environment_id": environment_id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountApiRequestsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "q": q, + "request_type": request_type, + "environment_id": environment_id, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountApiRequestsResponse, + parse_obj_as( + type_=CountApiRequestsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -854,7 +969,7 @@ def list_environments( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -862,53 +977,64 @@ def list_environments( client.accounts.list_environments() """ _response = self._client_wrapper.httpx_client.request( + "environments", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "environments"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "ids": ids, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListEnvironmentsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "ids": ids, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListEnvironmentsResponse, + parse_obj_as( + type_=ListEnvironmentsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -938,7 +1064,7 @@ def create_environment( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -949,48 +1075,64 @@ def create_environment( ) """ _response = self._client_wrapper.httpx_client.request( + "environments", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "environments"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder({"environment_type": environment_type, "name": name}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"environment_type": environment_type, "name": name}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "environment_type": environment_type, + "name": name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateEnvironmentResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateEnvironmentResponse, + parse_obj_as( + type_=CreateEnvironmentResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1015,7 +1157,7 @@ def get_environment( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1025,44 +1167,59 @@ def get_environment( ) """ _response = self._client_wrapper.httpx_client.request( + f"environments/{jsonable_encoder(environment_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"environments/{jsonable_encoder(environment_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetEnvironmentResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetEnvironmentResponse, + parse_obj_as( + type_=GetEnvironmentResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1096,7 +1253,7 @@ def update_environment( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1105,58 +1262,75 @@ def update_environment( environment_id="environment_id", ) """ - _request: typing.Dict[str, typing.Any] = {} - if environment_type is not OMIT: - _request["environment_type"] = environment_type - if name is not OMIT: - _request["name"] = name _response = self._client_wrapper.httpx_client.request( + f"environments/{jsonable_encoder(environment_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"environments/{jsonable_encoder(environment_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "environment_type": environment_type, + "name": name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateEnvironmentResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateEnvironmentResponse, + parse_obj_as( + type_=UpdateEnvironmentResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1181,7 +1355,7 @@ def delete_environment( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1191,44 +1365,59 @@ def delete_environment( ) """ _response = self._client_wrapper.httpx_client.request( + f"environments/{jsonable_encoder(environment_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"environments/{jsonable_encoder(environment_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteEnvironmentResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteEnvironmentResponse, + parse_obj_as( + type_=DeleteEnvironmentResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1271,64 +1460,83 @@ async def list_api_keys( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.accounts.list_api_keys( - require_environment=True, - ) + + + async def main() -> None: + await client.accounts.list_api_keys( + require_environment=True, + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "api-keys", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api-keys"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "environment_id": environment_id, - "require_environment": require_environment, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListApiKeysResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "environment_id": environment_id, + "require_environment": require_environment, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListApiKeysResponse, + parse_obj_as( + type_=ListApiKeysResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1361,63 +1569,83 @@ async def create_api_key( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.accounts.create_api_key( - name="name", - ) + + + async def main() -> None: + await client.accounts.create_api_key( + name="name", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"name": name} - if description is not OMIT: - _request["description"] = description - if environment_id is not OMIT: - _request["environment_id"] = environment_id _response = await self._client_wrapper.httpx_client.request( + "api-keys", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api-keys"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "description": description, + "environment_id": environment_id, + "name": name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateApiKeyResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateApiKeyResponse, + parse_obj_as( + type_=CreateApiKeyResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1442,54 +1670,77 @@ async def get_api_key( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.accounts.get_api_key( - api_key_id="api_key_id", - ) + + + async def main() -> None: + await client.accounts.get_api_key( + api_key_id="api_key_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"api-keys/{jsonable_encoder(api_key_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"api-keys/{jsonable_encoder(api_key_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetApiKeyResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetApiKeyResponse, + parse_obj_as( + type_=GetApiKeyResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1523,67 +1774,92 @@ async def update_api_key( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.accounts.update_api_key( - api_key_id="api_key_id", - ) + + + async def main() -> None: + await client.accounts.update_api_key( + api_key_id="api_key_id", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {} - if description is not OMIT: - _request["description"] = description - if name is not OMIT: - _request["name"] = name _response = await self._client_wrapper.httpx_client.request( + f"api-keys/{jsonable_encoder(api_key_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"api-keys/{jsonable_encoder(api_key_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "description": description, + "name": name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateApiKeyResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateApiKeyResponse, + parse_obj_as( + type_=UpdateApiKeyResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1608,54 +1884,77 @@ async def delete_api_key( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.accounts.delete_api_key( - api_key_id="api_key_id", - ) + + + async def main() -> None: + await client.accounts.delete_api_key( + api_key_id="api_key_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"api-keys/{jsonable_encoder(api_key_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"api-keys/{jsonable_encoder(api_key_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteApiKeyResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteApiKeyResponse, + parse_obj_as( + type_=DeleteApiKeyResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1693,64 +1992,83 @@ async def count_api_keys( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.accounts.count_api_keys( - require_environment=True, - ) + + + async def main() -> None: + await client.accounts.count_api_keys( + require_environment=True, + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "api-keys/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api-keys/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "environment_id": environment_id, - "require_environment": require_environment, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountApiKeysResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "environment_id": environment_id, + "require_environment": require_environment, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountApiKeysResponse, + parse_obj_as( + type_=CountApiKeysResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1791,63 +2109,82 @@ async def list_api_requests( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.accounts.list_api_requests() + + + async def main() -> None: + await client.accounts.list_api_requests() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "api-requests", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api-requests"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "q": q, - "request_type": request_type, - "environment_id": environment_id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListApiRequestsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "q": q, + "request_type": request_type, + "environment_id": environment_id, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListApiRequestsResponse, + parse_obj_as( + type_=ListApiRequestsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1872,54 +2209,77 @@ async def get_api_request( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.accounts.get_api_request( - api_request_id="api_request_id", - ) + + + async def main() -> None: + await client.accounts.get_api_request( + api_request_id="api_request_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"api-requests/{jsonable_encoder(api_request_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"api-requests/{jsonable_encoder(api_request_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetApiRequestResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetApiRequestResponse, + parse_obj_as( + type_=GetApiRequestResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1960,63 +2320,82 @@ async def count_api_requests( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.accounts.count_api_requests() + + + async def main() -> None: + await client.accounts.count_api_requests() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "api-requests/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api-requests/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "q": q, - "request_type": request_type, - "environment_id": environment_id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountApiRequestsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "q": q, + "request_type": request_type, + "environment_id": environment_id, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountApiRequestsResponse, + parse_obj_as( + type_=CountApiRequestsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2051,61 +2430,80 @@ async def list_environments( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.accounts.list_environments() + + + async def main() -> None: + await client.accounts.list_environments() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "environments", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "environments"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "ids": ids, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListEnvironmentsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "ids": ids, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListEnvironmentsResponse, + parse_obj_as( + type_=ListEnvironmentsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2135,59 +2533,83 @@ async def create_environment( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.accounts.create_environment( - environment_type="development", - name="name", - ) + + + async def main() -> None: + await client.accounts.create_environment( + environment_type="development", + name="name", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "environments", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "environments"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder({"environment_type": environment_type, "name": name}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"environment_type": environment_type, "name": name}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "environment_type": environment_type, + "name": name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateEnvironmentResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateEnvironmentResponse, + parse_obj_as( + type_=CreateEnvironmentResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2212,54 +2634,77 @@ async def get_environment( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.accounts.get_environment( - environment_id="environment_id", - ) + + + async def main() -> None: + await client.accounts.get_environment( + environment_id="environment_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"environments/{jsonable_encoder(environment_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"environments/{jsonable_encoder(environment_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetEnvironmentResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetEnvironmentResponse, + parse_obj_as( + type_=GetEnvironmentResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2293,67 +2738,92 @@ async def update_environment( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.accounts.update_environment( - environment_id="environment_id", - ) + + + async def main() -> None: + await client.accounts.update_environment( + environment_id="environment_id", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {} - if environment_type is not OMIT: - _request["environment_type"] = environment_type - if name is not OMIT: - _request["name"] = name _response = await self._client_wrapper.httpx_client.request( + f"environments/{jsonable_encoder(environment_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"environments/{jsonable_encoder(environment_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "environment_type": environment_type, + "name": name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateEnvironmentResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateEnvironmentResponse, + parse_obj_as( + type_=UpdateEnvironmentResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2378,54 +2848,77 @@ async def delete_environment( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.accounts.delete_environment( - environment_id="environment_id", - ) + + + async def main() -> None: + await client.accounts.delete_environment( + environment_id="environment_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"environments/{jsonable_encoder(environment_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"environments/{jsonable_encoder(environment_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteEnvironmentResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteEnvironmentResponse, + parse_obj_as( + type_=DeleteEnvironmentResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) diff --git a/src/schematic/accounts/types/count_api_keys_params.py b/src/schematic/accounts/types/count_api_keys_params.py index 7179e31..3789800 100644 --- a/src/schematic/accounts/types/count_api_keys_params.py +++ b/src/schematic/accounts/types/count_api_keys_params.py @@ -1,44 +1,34 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountApiKeysParams(pydantic_v1.BaseModel): +class CountApiKeysParams(UniversalBaseModel): """ Input parameters """ environment_id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ require_environment: typing.Optional[bool] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/count_api_keys_response.py b/src/schematic/accounts/types/count_api_keys_response.py index f902987..513783f 100644 --- a/src/schematic/accounts/types/count_api_keys_response.py +++ b/src/schematic/accounts/types/count_api_keys_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_api_keys_params import CountApiKeysParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountApiKeysResponse(pydantic_v1.BaseModel): +class CountApiKeysResponse(UniversalBaseModel): data: CountResponse - params: CountApiKeysParams = pydantic_v1.Field() + params: CountApiKeysParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/count_api_requests_params.py b/src/schematic/accounts/types/count_api_requests_params.py index f9832f5..4f06729 100644 --- a/src/schematic/accounts/types/count_api_requests_params.py +++ b/src/schematic/accounts/types/count_api_requests_params.py @@ -1,24 +1,23 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountApiRequestsParams(pydantic_v1.BaseModel): +class CountApiRequestsParams(UniversalBaseModel): """ Input parameters """ environment_id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ @@ -26,20 +25,11 @@ class CountApiRequestsParams(pydantic_v1.BaseModel): q: typing.Optional[str] = None request_type: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/count_api_requests_response.py b/src/schematic/accounts/types/count_api_requests_response.py index 30d37c8..5c58731 100644 --- a/src/schematic/accounts/types/count_api_requests_response.py +++ b/src/schematic/accounts/types/count_api_requests_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_api_requests_params import CountApiRequestsParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountApiRequestsResponse(pydantic_v1.BaseModel): +class CountApiRequestsResponse(UniversalBaseModel): data: CountResponse - params: CountApiRequestsParams = pydantic_v1.Field() + params: CountApiRequestsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/create_api_key_response.py b/src/schematic/accounts/types/create_api_key_response.py index 4f99434..9f4126f 100644 --- a/src/schematic/accounts/types/create_api_key_response.py +++ b/src/schematic/accounts/types/create_api_key_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.api_key_create_response_data import ApiKeyCreateResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CreateApiKeyResponse(pydantic_v1.BaseModel): +class CreateApiKeyResponse(UniversalBaseModel): data: ApiKeyCreateResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/create_environment_response.py b/src/schematic/accounts/types/create_environment_response.py index 4b48f36..c6ccd57 100644 --- a/src/schematic/accounts/types/create_environment_response.py +++ b/src/schematic/accounts/types/create_environment_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.environment_detail_response_data import EnvironmentDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CreateEnvironmentResponse(pydantic_v1.BaseModel): +class CreateEnvironmentResponse(UniversalBaseModel): data: EnvironmentDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/delete_api_key_response.py b/src/schematic/accounts/types/delete_api_key_response.py index 8b2f065..7faba9a 100644 --- a/src/schematic/accounts/types/delete_api_key_response.py +++ b/src/schematic/accounts/types/delete_api_key_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.delete_response import DeleteResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class DeleteApiKeyResponse(pydantic_v1.BaseModel): +class DeleteApiKeyResponse(UniversalBaseModel): data: DeleteResponse - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/delete_environment_response.py b/src/schematic/accounts/types/delete_environment_response.py index 1986f00..0a04be9 100644 --- a/src/schematic/accounts/types/delete_environment_response.py +++ b/src/schematic/accounts/types/delete_environment_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.delete_response import DeleteResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class DeleteEnvironmentResponse(pydantic_v1.BaseModel): +class DeleteEnvironmentResponse(UniversalBaseModel): data: DeleteResponse - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/get_api_key_response.py b/src/schematic/accounts/types/get_api_key_response.py index 60ae517..0f558de 100644 --- a/src/schematic/accounts/types/get_api_key_response.py +++ b/src/schematic/accounts/types/get_api_key_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.api_key_response_data import ApiKeyResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetApiKeyResponse(pydantic_v1.BaseModel): +class GetApiKeyResponse(UniversalBaseModel): data: ApiKeyResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/get_api_request_response.py b/src/schematic/accounts/types/get_api_request_response.py index 9f38387..51bfe97 100644 --- a/src/schematic/accounts/types/get_api_request_response.py +++ b/src/schematic/accounts/types/get_api_request_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.api_key_request_response_data import ApiKeyRequestResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetApiRequestResponse(pydantic_v1.BaseModel): +class GetApiRequestResponse(UniversalBaseModel): data: ApiKeyRequestResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/get_environment_response.py b/src/schematic/accounts/types/get_environment_response.py index da4b451..f8d5fe4 100644 --- a/src/schematic/accounts/types/get_environment_response.py +++ b/src/schematic/accounts/types/get_environment_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.environment_response_data import EnvironmentResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetEnvironmentResponse(pydantic_v1.BaseModel): +class GetEnvironmentResponse(UniversalBaseModel): data: EnvironmentResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/list_api_keys_params.py b/src/schematic/accounts/types/list_api_keys_params.py index 4a61804..5fe3bc4 100644 --- a/src/schematic/accounts/types/list_api_keys_params.py +++ b/src/schematic/accounts/types/list_api_keys_params.py @@ -1,44 +1,34 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListApiKeysParams(pydantic_v1.BaseModel): +class ListApiKeysParams(UniversalBaseModel): """ Input parameters """ environment_id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ require_environment: typing.Optional[bool] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/list_api_keys_response.py b/src/schematic/accounts/types/list_api_keys_response.py index a0effed..6edfd3c 100644 --- a/src/schematic/accounts/types/list_api_keys_response.py +++ b/src/schematic/accounts/types/list_api_keys_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.api_key_response_data import ApiKeyResponseData +import pydantic from .list_api_keys_params import ListApiKeysParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListApiKeysResponse(pydantic_v1.BaseModel): - data: typing.List[ApiKeyResponseData] = pydantic_v1.Field() +class ListApiKeysResponse(UniversalBaseModel): + data: typing.List[ApiKeyResponseData] = pydantic.Field() """ The returned resources """ - params: ListApiKeysParams = pydantic_v1.Field() + params: ListApiKeysParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/list_api_requests_params.py b/src/schematic/accounts/types/list_api_requests_params.py index 4236e9c..5679442 100644 --- a/src/schematic/accounts/types/list_api_requests_params.py +++ b/src/schematic/accounts/types/list_api_requests_params.py @@ -1,24 +1,23 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListApiRequestsParams(pydantic_v1.BaseModel): +class ListApiRequestsParams(UniversalBaseModel): """ Input parameters """ environment_id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ @@ -26,20 +25,11 @@ class ListApiRequestsParams(pydantic_v1.BaseModel): q: typing.Optional[str] = None request_type: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/list_api_requests_response.py b/src/schematic/accounts/types/list_api_requests_response.py index 07d25e5..d265c86 100644 --- a/src/schematic/accounts/types/list_api_requests_response.py +++ b/src/schematic/accounts/types/list_api_requests_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.api_key_request_list_response_data import ApiKeyRequestListResponseData +import pydantic from .list_api_requests_params import ListApiRequestsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListApiRequestsResponse(pydantic_v1.BaseModel): - data: typing.List[ApiKeyRequestListResponseData] = pydantic_v1.Field() +class ListApiRequestsResponse(UniversalBaseModel): + data: typing.List[ApiKeyRequestListResponseData] = pydantic.Field() """ The returned resources """ - params: ListApiRequestsParams = pydantic_v1.Field() + params: ListApiRequestsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/list_environments_params.py b/src/schematic/accounts/types/list_environments_params.py index 23a46d4..199829e 100644 --- a/src/schematic/accounts/types/list_environments_params.py +++ b/src/schematic/accounts/types/list_environments_params.py @@ -1,42 +1,32 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListEnvironmentsParams(pydantic_v1.BaseModel): +class ListEnvironmentsParams(UniversalBaseModel): """ Input parameters """ ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/list_environments_response.py b/src/schematic/accounts/types/list_environments_response.py index 5c48826..6959e14 100644 --- a/src/schematic/accounts/types/list_environments_response.py +++ b/src/schematic/accounts/types/list_environments_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.environment_response_data import EnvironmentResponseData +import pydantic from .list_environments_params import ListEnvironmentsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListEnvironmentsResponse(pydantic_v1.BaseModel): - data: typing.List[EnvironmentResponseData] = pydantic_v1.Field() +class ListEnvironmentsResponse(UniversalBaseModel): + data: typing.List[EnvironmentResponseData] = pydantic.Field() """ The returned resources """ - params: ListEnvironmentsParams = pydantic_v1.Field() + params: ListEnvironmentsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/update_api_key_response.py b/src/schematic/accounts/types/update_api_key_response.py index b46acab..c26479d 100644 --- a/src/schematic/accounts/types/update_api_key_response.py +++ b/src/schematic/accounts/types/update_api_key_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.api_key_response_data import ApiKeyResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpdateApiKeyResponse(pydantic_v1.BaseModel): +class UpdateApiKeyResponse(UniversalBaseModel): data: ApiKeyResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/accounts/types/update_environment_response.py b/src/schematic/accounts/types/update_environment_response.py index acb6a29..94dcf04 100644 --- a/src/schematic/accounts/types/update_environment_response.py +++ b/src/schematic/accounts/types/update_environment_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.environment_response_data import EnvironmentResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpdateEnvironmentResponse(pydantic_v1.BaseModel): +class UpdateEnvironmentResponse(UniversalBaseModel): data: EnvironmentResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/base_client.py b/src/schematic/base_client.py index 99febf5..90dfab0 100644 --- a/src/schematic/base_client.py +++ b/src/schematic/base_client.py @@ -1,25 +1,42 @@ # This file was auto-generated by Fern from our API Definition. import typing - -import httpx - -from .accounts.client import AccountsClient, AsyncAccountsClient -from .billing.client import AsyncBillingClient, BillingClient -from .companies.client import AsyncCompaniesClient, CompaniesClient -from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from .crm.client import AsyncCrmClient, CrmClient -from .entitlements.client import AsyncEntitlementsClient, EntitlementsClient from .environment import SchematicEnvironment -from .events.client import AsyncEventsClient, EventsClient -from .features.client import AsyncFeaturesClient, FeaturesClient -from .plans.client import AsyncPlansClient, PlansClient -from .webhooks.client import AsyncWebhooksClient, WebhooksClient +import httpx +from .core.client_wrapper import SyncClientWrapper +from .accounts.client import AccountsClient +from .features.client import FeaturesClient +from .billing.client import BillingClient +from .companies.client import CompaniesClient +from .entitlements.client import EntitlementsClient +from .components.client import ComponentsClient +from .crm.client import CrmClient +from .events.client import EventsClient +from .plans.client import PlansClient +from .plangroups.client import PlangroupsClient +from .accesstokens.client import AccesstokensClient +from .webhooks.client import WebhooksClient +from .core.request_options import RequestOptions +from json.decoder import JSONDecodeError +from .core.api_error import ApiError +from .core.client_wrapper import AsyncClientWrapper +from .accounts.client import AsyncAccountsClient +from .features.client import AsyncFeaturesClient +from .billing.client import AsyncBillingClient +from .companies.client import AsyncCompaniesClient +from .entitlements.client import AsyncEntitlementsClient +from .components.client import AsyncComponentsClient +from .crm.client import AsyncCrmClient +from .events.client import AsyncEventsClient +from .plans.client import AsyncPlansClient +from .plangroups.client import AsyncPlangroupsClient +from .accesstokens.client import AsyncAccesstokensClient +from .webhooks.client import AsyncWebhooksClient class BaseSchematic: """ - Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions. + Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions. Parameters ---------- @@ -37,7 +54,7 @@ class BaseSchematic: api_key : str 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 a default is not set. + 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. follow_redirects : typing.Optional[bool] Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in. @@ -47,7 +64,7 @@ class BaseSchematic: Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -62,7 +79,7 @@ def __init__( api_key: str, timeout: typing.Optional[float] = None, follow_redirects: typing.Optional[bool] = True, - httpx_client: typing.Optional[httpx.Client] = None + httpx_client: typing.Optional[httpx.Client] = None, ): _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None self._client_wrapper = SyncClientWrapper( @@ -80,15 +97,51 @@ def __init__( self.billing = BillingClient(client_wrapper=self._client_wrapper) self.companies = CompaniesClient(client_wrapper=self._client_wrapper) self.entitlements = EntitlementsClient(client_wrapper=self._client_wrapper) + self.components = ComponentsClient(client_wrapper=self._client_wrapper) self.crm = CrmClient(client_wrapper=self._client_wrapper) self.events = EventsClient(client_wrapper=self._client_wrapper) self.plans = PlansClient(client_wrapper=self._client_wrapper) + self.plangroups = PlangroupsClient(client_wrapper=self._client_wrapper) + self.accesstokens = AccesstokensClient(client_wrapper=self._client_wrapper) self.webhooks = WebhooksClient(client_wrapper=self._client_wrapper) + def get_company_plans(self, *, request_options: typing.Optional[RequestOptions] = None) -> None: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.get_company_plans() + """ + _response = self._client_wrapper.httpx_client.request( + "company-plans", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + class AsyncBaseSchematic: """ - Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions. + Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions. Parameters ---------- @@ -106,7 +159,7 @@ class AsyncBaseSchematic: api_key : str 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 a default is not set. + 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. follow_redirects : typing.Optional[bool] Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in. @@ -116,7 +169,7 @@ class AsyncBaseSchematic: Examples -------- - from schematic.client import AsyncSchematic + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", @@ -131,7 +184,7 @@ def __init__( api_key: str, timeout: typing.Optional[float] = None, follow_redirects: typing.Optional[bool] = True, - httpx_client: typing.Optional[httpx.AsyncClient] = None + httpx_client: typing.Optional[httpx.AsyncClient] = None, ): _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None self._client_wrapper = AsyncClientWrapper( @@ -149,11 +202,55 @@ def __init__( self.billing = AsyncBillingClient(client_wrapper=self._client_wrapper) self.companies = AsyncCompaniesClient(client_wrapper=self._client_wrapper) self.entitlements = AsyncEntitlementsClient(client_wrapper=self._client_wrapper) + self.components = AsyncComponentsClient(client_wrapper=self._client_wrapper) self.crm = AsyncCrmClient(client_wrapper=self._client_wrapper) self.events = AsyncEventsClient(client_wrapper=self._client_wrapper) self.plans = AsyncPlansClient(client_wrapper=self._client_wrapper) + self.plangroups = AsyncPlangroupsClient(client_wrapper=self._client_wrapper) + self.accesstokens = AsyncAccesstokensClient(client_wrapper=self._client_wrapper) self.webhooks = AsyncWebhooksClient(client_wrapper=self._client_wrapper) + async def get_company_plans(self, *, request_options: typing.Optional[RequestOptions] = None) -> None: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.get_company_plans() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "company-plans", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + def _get_base_url(*, base_url: typing.Optional[str] = None, environment: SchematicEnvironment) -> str: if base_url is not None: diff --git a/src/schematic/billing/__init__.py b/src/schematic/billing/__init__.py index 231a1b8..356f147 100644 --- a/src/schematic/billing/__init__.py +++ b/src/schematic/billing/__init__.py @@ -1,15 +1,47 @@ # This file was auto-generated by Fern from our API Definition. from .types import ( - ListProductsParams, - ListProductsResponse, + CountBillingProductsParams, + CountBillingProductsResponse, + CountCustomersParams, + CountCustomersResponse, + ListBillingProductsParams, + ListBillingProductsResponse, + ListCustomersParams, + ListCustomersResponse, + ListInvoicesParams, + ListInvoicesResponse, + ListPaymentMethodsParams, + ListPaymentMethodsResponse, + ListProductPricesParams, + ListProductPricesResponse, + UpsertBillingCustomerResponse, + UpsertBillingPriceResponse, UpsertBillingProductResponse, UpsertBillingSubscriptionResponse, + UpsertInvoiceResponse, + UpsertPaymentMethodResponse, ) __all__ = [ - "ListProductsParams", - "ListProductsResponse", + "CountBillingProductsParams", + "CountBillingProductsResponse", + "CountCustomersParams", + "CountCustomersResponse", + "ListBillingProductsParams", + "ListBillingProductsResponse", + "ListCustomersParams", + "ListCustomersResponse", + "ListInvoicesParams", + "ListInvoicesResponse", + "ListPaymentMethodsParams", + "ListPaymentMethodsResponse", + "ListProductPricesParams", + "ListProductPricesResponse", + "UpsertBillingCustomerResponse", + "UpsertBillingPriceResponse", "UpsertBillingProductResponse", "UpsertBillingSubscriptionResponse", + "UpsertInvoiceResponse", + "UpsertPaymentMethodResponse", ] diff --git a/src/schematic/billing/client.py b/src/schematic/billing/client.py index 8de1db1..4eb8a2a 100644 --- a/src/schematic/billing/client.py +++ b/src/schematic/billing/client.py @@ -1,25 +1,33 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt import typing -import urllib.parse -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.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 -from ..core.query_encoder import encode_query -from ..core.remove_none_from_dict import remove_none_from_dict +from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions +from .types.upsert_billing_customer_response import UpsertBillingCustomerResponse +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 ..errors.forbidden_error import ForbiddenError 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.list_products_response import ListProductsResponse +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError as core_api_error_ApiError +from .types.list_customers_response import ListCustomersResponse +from .types.count_customers_response import CountCustomersResponse +from .types.list_invoices_response import ListInvoicesResponse +import datetime as dt +from .types.upsert_invoice_response import UpsertInvoiceResponse +from .types.list_payment_methods_response import ListPaymentMethodsResponse +from .types.upsert_payment_method_response import UpsertPaymentMethodResponse +from .types.upsert_billing_price_response import UpsertBillingPriceResponse +from .types.list_product_prices_response import ListProductPricesResponse from .types.upsert_billing_product_response import UpsertBillingProductResponse +from .types.list_billing_products_response import ListBillingProductsResponse +from .types.count_billing_products_response import CountBillingProductsResponse +from ..types.billing_product_pricing import BillingProductPricing from .types.upsert_billing_subscription_response import UpsertBillingSubscriptionResponse +from ..core.serialization import convert_and_respect_annotation_metadata +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -29,126 +37,142 @@ class BillingClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def upsert_billing_product( + def upsert_billing_customer( self, *, - currency: str, + email: str, external_id: str, + failed_to_import: bool, + meta: typing.Dict[str, str], name: str, - price: float, - quantity: int, + company_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> UpsertBillingProductResponse: + ) -> UpsertBillingCustomerResponse: """ Parameters ---------- - currency : str + email : str external_id : str - name : str + failed_to_import : bool - price : float + meta : typing.Dict[str, str] - quantity : int + name : str + + company_id : typing.Optional[str] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - UpsertBillingProductResponse + UpsertBillingCustomerResponse Created Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) - client.billing.upsert_billing_product( - currency="currency", + client.billing.upsert_billing_customer( + email="email", external_id="external_id", + failed_to_import=True, + meta={"key": "value"}, name="name", - price=1.1, - quantity=1, ) """ _response = self._client_wrapper.httpx_client.request( + "billing/customer/upsert", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "billing/product/upsert"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder( - {"currency": currency, "external_id": external_id, "name": name, "price": price, "quantity": quantity} - ) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder( - { - "currency": currency, - "external_id": external_id, - "name": name, - "price": price, - "quantity": quantity, - } - ), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "company_id": company_id, + "email": email, + "external_id": external_id, + "failed_to_import": failed_to_import, + "meta": meta, + "name": name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertBillingProductResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertBillingCustomerResponse, + parse_obj_as( + type_=UpsertBillingCustomerResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) - def list_products( + def list_customers( self, *, - ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, name: typing.Optional[str] = None, + failed_to_import: typing.Optional[bool] = None, + q: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> ListProductsResponse: + ) -> ListCustomersResponse: """ Parameters ---------- - ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] - name : typing.Optional[str] + failed_to_import : typing.Optional[bool] + + q : typing.Optional[str] + limit : typing.Optional[int] Page limit (default 100) @@ -160,301 +184,460 @@ def list_products( Returns ------- - ListProductsResponse + ListCustomersResponse OK Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) - client.billing.list_products() + client.billing.list_customers() """ _response = self._client_wrapper.httpx_client.request( + "billing/customers", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "billing/products"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "ids": ids, - "name": name, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params={ + "name": name, + "failed_to_import": failed_to_import, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListCustomersResponse, + parse_obj_as( + type_=ListCustomersResponse, # 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(), + ), ) ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ) ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListProductsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + 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) + + def count_customers( + self, + *, + name: typing.Optional[str] = None, + failed_to_import: typing.Optional[bool] = None, + q: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> CountCustomersResponse: + """ + Parameters + ---------- + name : typing.Optional[str] + + failed_to_import : typing.Optional[bool] + + q : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CountCustomersResponse + OK + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.billing.count_customers() + """ + _response = self._client_wrapper.httpx_client.request( + "billing/customers/count", + method="GET", + params={ + "name": name, + "failed_to_import": failed_to_import, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountCustomersResponse, + parse_obj_as( + type_=CountCustomersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) - def upsert_billing_subscription( + def list_invoices( self, *, customer_external_id: str, - expired_at: dt.datetime, - product_external_ids: typing.Sequence[str], - subscription_external_id: str, - interval: typing.Optional[str] = OMIT, + company_id: typing.Optional[str] = None, + subscription_external_id: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> UpsertBillingSubscriptionResponse: + ) -> ListInvoicesResponse: """ Parameters ---------- customer_external_id : str - expired_at : dt.datetime + company_id : typing.Optional[str] - product_external_ids : typing.Sequence[str] + subscription_external_id : typing.Optional[str] - subscription_external_id : str + limit : typing.Optional[int] + Page limit (default 100) - interval : typing.Optional[str] + offset : typing.Optional[int] + Page offset (default 0) request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - UpsertBillingSubscriptionResponse - Created + ListInvoicesResponse + OK Examples -------- - import datetime - - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) - client.billing.upsert_billing_subscription( + client.billing.list_invoices( customer_external_id="customer_external_id", - expired_at=datetime.datetime.fromisoformat( - "2024-01-15 09:30:00+00:00", - ), - product_external_ids=["product_external_ids"], - subscription_external_id="subscription_external_id", ) """ - _request: typing.Dict[str, typing.Any] = { - "customer_external_id": customer_external_id, - "expired_at": expired_at, - "product_external_ids": product_external_ids, - "subscription_external_id": subscription_external_id, - } - if interval is not OMIT: - _request["interval"] = interval _response = self._client_wrapper.httpx_client.request( - method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "billing/subscription/upsert"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + "billing/invoices", + method="GET", + params={ + "company_id": company_id, + "customer_external_id": customer_external_id, + "subscription_external_id": subscription_external_id, + "limit": limit, + "offset": offset, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertBillingSubscriptionResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListInvoicesResponse, + parse_obj_as( + type_=ListInvoicesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) - -class AsyncBillingClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - - async def upsert_billing_product( + def upsert_invoice( self, *, + amount_due: int, + amount_paid: int, + amount_remaining: int, + collection_method: str, currency: str, + customer_external_id: str, external_id: str, - name: str, - price: float, - quantity: int, + subtotal: int, + due_date: typing.Optional[dt.datetime] = OMIT, + payment_method_external_id: typing.Optional[str] = OMIT, + subscription_external_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> UpsertBillingProductResponse: + ) -> UpsertInvoiceResponse: """ Parameters ---------- + amount_due : int + + amount_paid : int + + amount_remaining : int + + collection_method : str + currency : str + customer_external_id : str + external_id : str - name : str + subtotal : int - price : float + due_date : typing.Optional[dt.datetime] - quantity : int + payment_method_external_id : typing.Optional[str] + + subscription_external_id : typing.Optional[str] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - UpsertBillingProductResponse + UpsertInvoiceResponse Created Examples -------- - from schematic.client import AsyncSchematic + from schematic import Schematic - client = AsyncSchematic( + client = Schematic( api_key="YOUR_API_KEY", ) - await client.billing.upsert_billing_product( + client.billing.upsert_invoice( + amount_due=1, + amount_paid=1, + amount_remaining=1, + collection_method="collection_method", currency="currency", + customer_external_id="customer_external_id", external_id="external_id", - name="name", - price=1.1, - quantity=1, + subtotal=1, ) """ - _response = await self._client_wrapper.httpx_client.request( + _response = self._client_wrapper.httpx_client.request( + "billing/invoices", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "billing/product/upsert"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder( - {"currency": currency, "external_id": external_id, "name": name, "price": price, "quantity": quantity} - ) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder( - { - "currency": currency, - "external_id": external_id, - "name": name, - "price": price, - "quantity": quantity, - } - ), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "amount_due": amount_due, + "amount_paid": amount_paid, + "amount_remaining": amount_remaining, + "collection_method": collection_method, + "currency": currency, + "customer_external_id": customer_external_id, + "due_date": due_date, + "external_id": external_id, + "payment_method_external_id": payment_method_external_id, + "subscription_external_id": subscription_external_id, + "subtotal": subtotal, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertBillingProductResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertInvoiceResponse, + parse_obj_as( + type_=UpsertInvoiceResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) - async def list_products( + def list_payment_methods( self, *, - ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, - name: typing.Optional[str] = None, + customer_external_id: str, + company_id: typing.Optional[str] = None, + subscription_external_id: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> ListProductsResponse: + ) -> ListPaymentMethodsResponse: """ Parameters ---------- - ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + customer_external_id : str - name : typing.Optional[str] + company_id : typing.Optional[str] + + subscription_external_id : typing.Optional[str] limit : typing.Optional[int] Page limit (default 100) @@ -467,172 +650,2490 @@ async def list_products( Returns ------- - ListProductsResponse + ListPaymentMethodsResponse OK Examples -------- - from schematic.client import AsyncSchematic + from schematic import Schematic - client = AsyncSchematic( + client = Schematic( api_key="YOUR_API_KEY", ) - await client.billing.list_products() + client.billing.list_payment_methods( + customer_external_id="customer_external_id", + ) """ - _response = await self._client_wrapper.httpx_client.request( + _response = self._client_wrapper.httpx_client.request( + "billing/payment-methods", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "billing/products"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "ids": ids, - "name": name, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params={ + "company_id": company_id, + "customer_external_id": customer_external_id, + "subscription_external_id": subscription_external_id, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListPaymentMethodsResponse, + parse_obj_as( + type_=ListPaymentMethodsResponse, # 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(), + ), ) ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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(), + ), + ) ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListProductsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - try: _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 upsert_billing_subscription( + def upsert_payment_method( self, *, customer_external_id: str, - expired_at: dt.datetime, - product_external_ids: typing.Sequence[str], - subscription_external_id: str, - interval: typing.Optional[str] = OMIT, + external_id: str, + payment_method_type: str, + card_brand: typing.Optional[str] = OMIT, + card_exp_month: typing.Optional[int] = OMIT, + card_exp_year: typing.Optional[int] = OMIT, + card_last_4: typing.Optional[str] = OMIT, + subscription_external_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> UpsertBillingSubscriptionResponse: + ) -> UpsertPaymentMethodResponse: """ Parameters ---------- customer_external_id : str - expired_at : dt.datetime + external_id : str - product_external_ids : typing.Sequence[str] + payment_method_type : str - subscription_external_id : str + card_brand : typing.Optional[str] - interval : typing.Optional[str] + card_exp_month : typing.Optional[int] + + card_exp_year : typing.Optional[int] + + card_last_4 : typing.Optional[str] + + subscription_external_id : typing.Optional[str] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - UpsertBillingSubscriptionResponse + UpsertPaymentMethodResponse Created Examples -------- - import datetime + from schematic import Schematic - from schematic.client import AsyncSchematic - - client = AsyncSchematic( + client = Schematic( api_key="YOUR_API_KEY", ) - await client.billing.upsert_billing_subscription( + client.billing.upsert_payment_method( customer_external_id="customer_external_id", - expired_at=datetime.datetime.fromisoformat( - "2024-01-15 09:30:00+00:00", - ), - product_external_ids=["product_external_ids"], - subscription_external_id="subscription_external_id", + external_id="external_id", + payment_method_type="payment_method_type", ) """ - _request: typing.Dict[str, typing.Any] = { - "customer_external_id": customer_external_id, - "expired_at": expired_at, - "product_external_ids": product_external_ids, - "subscription_external_id": subscription_external_id, - } - if interval is not OMIT: - _request["interval"] = interval - _response = await self._client_wrapper.httpx_client.request( + _response = self._client_wrapper.httpx_client.request( + "billing/payment-methods", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "billing/subscription/upsert"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + json={ + "card_brand": card_brand, + "card_exp_month": card_exp_month, + "card_exp_year": card_exp_year, + "card_last4": card_last_4, + "customer_external_id": customer_external_id, + "external_id": external_id, + "payment_method_type": payment_method_type, + "subscription_external_id": subscription_external_id, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertPaymentMethodResponse, + parse_obj_as( + type_=UpsertPaymentMethodResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def upsert_billing_price( + self, + *, + interval: str, + price: int, + price_external_id: str, + product_external_id: str, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertBillingPriceResponse: + """ + Parameters + ---------- + interval : str + + price : int + + price_external_id : str + + product_external_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertBillingPriceResponse + Created + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.billing.upsert_billing_price( + interval="interval", + price=1, + price_external_id="price_external_id", + product_external_id="product_external_id", + ) + """ + _response = self._client_wrapper.httpx_client.request( + "billing/price/upsert", + method="POST", + json={ + "interval": interval, + "price": price, + "price_external_id": price_external_id, + "product_external_id": product_external_id, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertBillingPriceResponse, + parse_obj_as( + type_=UpsertBillingPriceResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def list_product_prices( + self, + *, + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + name: typing.Optional[str] = None, + q: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ListProductPricesResponse: + """ + Parameters + ---------- + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + name : typing.Optional[str] + + q : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ListProductPricesResponse + OK + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.billing.list_product_prices() + """ + _response = self._client_wrapper.httpx_client.request( + "billing/product/prices", + method="GET", + params={ + "ids": ids, + "name": name, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListProductPricesResponse, + parse_obj_as( + type_=ListProductPricesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def upsert_billing_product( + self, + *, + currency: str, + external_id: str, + name: str, + price: float, + quantity: int, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertBillingProductResponse: + """ + Parameters + ---------- + currency : str + + external_id : str + + name : str + + price : float + + quantity : int + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertBillingProductResponse + Created + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.billing.upsert_billing_product( + currency="currency", + external_id="external_id", + name="name", + price=1.1, + quantity=1, + ) + """ + _response = self._client_wrapper.httpx_client.request( + "billing/product/upsert", + method="POST", + json={ + "currency": currency, + "external_id": external_id, + "name": name, + "price": price, + "quantity": quantity, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertBillingProductResponse, + parse_obj_as( + type_=UpsertBillingProductResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def list_billing_products( + self, + *, + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + name: typing.Optional[str] = None, + q: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ListBillingProductsResponse: + """ + Parameters + ---------- + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + name : typing.Optional[str] + + q : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ListBillingProductsResponse + OK + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.billing.list_billing_products() + """ + _response = self._client_wrapper.httpx_client.request( + "billing/products", + method="GET", + params={ + "ids": ids, + "name": name, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListBillingProductsResponse, + parse_obj_as( + type_=ListBillingProductsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def count_billing_products( + self, + *, + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + name: typing.Optional[str] = None, + q: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> CountBillingProductsResponse: + """ + Parameters + ---------- + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + name : typing.Optional[str] + + q : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CountBillingProductsResponse + OK + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.billing.count_billing_products() + """ + _response = self._client_wrapper.httpx_client.request( + "billing/products/count", + method="GET", + params={ + "ids": ids, + "name": name, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountBillingProductsResponse, + parse_obj_as( + type_=CountBillingProductsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def upsert_billing_subscription( + self, + *, + customer_external_id: str, + expired_at: dt.datetime, + product_external_ids: typing.Sequence[BillingProductPricing], + subscription_external_id: str, + total_price: int, + interval: typing.Optional[str] = OMIT, + metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, + status: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertBillingSubscriptionResponse: + """ + Parameters + ---------- + customer_external_id : str + + expired_at : dt.datetime + + product_external_ids : typing.Sequence[BillingProductPricing] + + subscription_external_id : str + + total_price : int + + interval : typing.Optional[str] + + metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] + + status : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertBillingSubscriptionResponse + Created + + Examples + -------- + import datetime + + from schematic import BillingProductPricing, Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.billing.upsert_billing_subscription( + customer_external_id="customer_external_id", + expired_at=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + product_external_ids=[ + BillingProductPricing( + price=1, + product_external_id="product_external_id", + ) + ], + subscription_external_id="subscription_external_id", + total_price=1, + ) + """ + _response = self._client_wrapper.httpx_client.request( + "billing/subscription/upsert", + method="POST", + json={ + "customer_external_id": customer_external_id, + "expired_at": expired_at, + "interval": interval, + "metadata": metadata, + "product_external_ids": convert_and_respect_annotation_metadata( + object_=product_external_ids, annotation=typing.Sequence[BillingProductPricing], direction="write" + ), + "status": status, + "subscription_external_id": subscription_external_id, + "total_price": total_price, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertBillingSubscriptionResponse, + parse_obj_as( + type_=UpsertBillingSubscriptionResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + +class AsyncBillingClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def upsert_billing_customer( + self, + *, + email: str, + external_id: str, + failed_to_import: bool, + meta: typing.Dict[str, str], + name: str, + company_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertBillingCustomerResponse: + """ + Parameters + ---------- + email : str + + external_id : str + + failed_to_import : bool + + meta : typing.Dict[str, str] + + name : str + + company_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertBillingCustomerResponse + Created + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.billing.upsert_billing_customer( + email="email", + external_id="external_id", + failed_to_import=True, + meta={"key": "value"}, + name="name", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "billing/customer/upsert", + method="POST", + json={ + "company_id": company_id, + "email": email, + "external_id": external_id, + "failed_to_import": failed_to_import, + "meta": meta, + "name": name, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertBillingCustomerResponse, + parse_obj_as( + type_=UpsertBillingCustomerResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def list_customers( + self, + *, + name: typing.Optional[str] = None, + failed_to_import: typing.Optional[bool] = None, + q: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ListCustomersResponse: + """ + Parameters + ---------- + name : typing.Optional[str] + + failed_to_import : typing.Optional[bool] + + q : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ListCustomersResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.billing.list_customers() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "billing/customers", + method="GET", + params={ + "name": name, + "failed_to_import": failed_to_import, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListCustomersResponse, + parse_obj_as( + type_=ListCustomersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def count_customers( + self, + *, + name: typing.Optional[str] = None, + failed_to_import: typing.Optional[bool] = None, + q: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> CountCustomersResponse: + """ + Parameters + ---------- + name : typing.Optional[str] + + failed_to_import : typing.Optional[bool] + + q : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CountCustomersResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.billing.count_customers() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "billing/customers/count", + method="GET", + params={ + "name": name, + "failed_to_import": failed_to_import, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountCustomersResponse, + parse_obj_as( + type_=CountCustomersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def list_invoices( + self, + *, + customer_external_id: str, + company_id: typing.Optional[str] = None, + subscription_external_id: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ListInvoicesResponse: + """ + Parameters + ---------- + customer_external_id : str + + company_id : typing.Optional[str] + + subscription_external_id : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ListInvoicesResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.billing.list_invoices( + customer_external_id="customer_external_id", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "billing/invoices", + method="GET", + params={ + "company_id": company_id, + "customer_external_id": customer_external_id, + "subscription_external_id": subscription_external_id, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListInvoicesResponse, + parse_obj_as( + type_=ListInvoicesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def upsert_invoice( + self, + *, + amount_due: int, + amount_paid: int, + amount_remaining: int, + collection_method: str, + currency: str, + customer_external_id: str, + external_id: str, + subtotal: int, + due_date: typing.Optional[dt.datetime] = OMIT, + payment_method_external_id: typing.Optional[str] = OMIT, + subscription_external_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertInvoiceResponse: + """ + Parameters + ---------- + amount_due : int + + amount_paid : int + + amount_remaining : int + + collection_method : str + + currency : str + + customer_external_id : str + + external_id : str + + subtotal : int + + due_date : typing.Optional[dt.datetime] + + payment_method_external_id : typing.Optional[str] + + subscription_external_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertInvoiceResponse + Created + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.billing.upsert_invoice( + amount_due=1, + amount_paid=1, + amount_remaining=1, + collection_method="collection_method", + currency="currency", + customer_external_id="customer_external_id", + external_id="external_id", + subtotal=1, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "billing/invoices", + method="POST", + json={ + "amount_due": amount_due, + "amount_paid": amount_paid, + "amount_remaining": amount_remaining, + "collection_method": collection_method, + "currency": currency, + "customer_external_id": customer_external_id, + "due_date": due_date, + "external_id": external_id, + "payment_method_external_id": payment_method_external_id, + "subscription_external_id": subscription_external_id, + "subtotal": subtotal, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertInvoiceResponse, + parse_obj_as( + type_=UpsertInvoiceResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def list_payment_methods( + self, + *, + customer_external_id: str, + company_id: typing.Optional[str] = None, + subscription_external_id: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ListPaymentMethodsResponse: + """ + Parameters + ---------- + customer_external_id : str + + company_id : typing.Optional[str] + + subscription_external_id : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ListPaymentMethodsResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.billing.list_payment_methods( + customer_external_id="customer_external_id", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "billing/payment-methods", + method="GET", + params={ + "company_id": company_id, + "customer_external_id": customer_external_id, + "subscription_external_id": subscription_external_id, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListPaymentMethodsResponse, + parse_obj_as( + type_=ListPaymentMethodsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def upsert_payment_method( + self, + *, + customer_external_id: str, + external_id: str, + payment_method_type: str, + card_brand: typing.Optional[str] = OMIT, + card_exp_month: typing.Optional[int] = OMIT, + card_exp_year: typing.Optional[int] = OMIT, + card_last_4: typing.Optional[str] = OMIT, + subscription_external_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertPaymentMethodResponse: + """ + Parameters + ---------- + customer_external_id : str + + external_id : str + + payment_method_type : str + + card_brand : typing.Optional[str] + + card_exp_month : typing.Optional[int] + + card_exp_year : typing.Optional[int] + + card_last_4 : typing.Optional[str] + + subscription_external_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertPaymentMethodResponse + Created + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.billing.upsert_payment_method( + customer_external_id="customer_external_id", + external_id="external_id", + payment_method_type="payment_method_type", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "billing/payment-methods", + method="POST", + json={ + "card_brand": card_brand, + "card_exp_month": card_exp_month, + "card_exp_year": card_exp_year, + "card_last4": card_last_4, + "customer_external_id": customer_external_id, + "external_id": external_id, + "payment_method_type": payment_method_type, + "subscription_external_id": subscription_external_id, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertPaymentMethodResponse, + parse_obj_as( + type_=UpsertPaymentMethodResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def upsert_billing_price( + self, + *, + interval: str, + price: int, + price_external_id: str, + product_external_id: str, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertBillingPriceResponse: + """ + Parameters + ---------- + interval : str + + price : int + + price_external_id : str + + product_external_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertBillingPriceResponse + Created + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.billing.upsert_billing_price( + interval="interval", + price=1, + price_external_id="price_external_id", + product_external_id="product_external_id", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "billing/price/upsert", + method="POST", + json={ + "interval": interval, + "price": price, + "price_external_id": price_external_id, + "product_external_id": product_external_id, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertBillingPriceResponse, + parse_obj_as( + type_=UpsertBillingPriceResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def list_product_prices( + self, + *, + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + name: typing.Optional[str] = None, + q: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ListProductPricesResponse: + """ + Parameters + ---------- + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + name : typing.Optional[str] + + q : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ListProductPricesResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.billing.list_product_prices() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "billing/product/prices", + method="GET", + params={ + "ids": ids, + "name": name, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListProductPricesResponse, + parse_obj_as( + type_=ListProductPricesResponse, # type: ignore + object_=_response.json(), + ), ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } + 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(), + ), + ) ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertBillingSubscriptionResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def upsert_billing_product( + self, + *, + currency: str, + external_id: str, + name: str, + price: float, + quantity: int, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertBillingProductResponse: + """ + Parameters + ---------- + currency : str + + external_id : str + + name : str + + price : float + + quantity : int + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertBillingProductResponse + Created + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.billing.upsert_billing_product( + currency="currency", + external_id="external_id", + name="name", + price=1.1, + quantity=1, ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "billing/product/upsert", + method="POST", + json={ + "currency": currency, + "external_id": external_id, + "name": name, + "price": price, + "quantity": quantity, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertBillingProductResponse, + parse_obj_as( + type_=UpsertBillingProductResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def list_billing_products( + self, + *, + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + name: typing.Optional[str] = None, + q: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ListBillingProductsResponse: + """ + Parameters + ---------- + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + name : typing.Optional[str] + + q : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ListBillingProductsResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.billing.list_billing_products() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "billing/products", + method="GET", + params={ + "ids": ids, + "name": name, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListBillingProductsResponse, + parse_obj_as( + type_=ListBillingProductsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def count_billing_products( + self, + *, + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + name: typing.Optional[str] = None, + q: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> CountBillingProductsResponse: + """ + Parameters + ---------- + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + name : typing.Optional[str] + + q : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CountBillingProductsResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.billing.count_billing_products() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "billing/products/count", + method="GET", + params={ + "ids": ids, + "name": name, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountBillingProductsResponse, + parse_obj_as( + type_=CountBillingProductsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def upsert_billing_subscription( + self, + *, + customer_external_id: str, + expired_at: dt.datetime, + product_external_ids: typing.Sequence[BillingProductPricing], + subscription_external_id: str, + total_price: int, + interval: typing.Optional[str] = OMIT, + metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, + status: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertBillingSubscriptionResponse: + """ + Parameters + ---------- + customer_external_id : str + + expired_at : dt.datetime + + product_external_ids : typing.Sequence[BillingProductPricing] + + subscription_external_id : str + + total_price : int + + interval : typing.Optional[str] + + metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] + + status : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertBillingSubscriptionResponse + Created + + Examples + -------- + import asyncio + import datetime + + from schematic import AsyncSchematic, BillingProductPricing + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.billing.upsert_billing_subscription( + customer_external_id="customer_external_id", + expired_at=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + product_external_ids=[ + BillingProductPricing( + price=1, + product_external_id="product_external_id", + ) + ], + subscription_external_id="subscription_external_id", + total_price=1, ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "billing/subscription/upsert", + method="POST", + json={ + "customer_external_id": customer_external_id, + "expired_at": expired_at, + "interval": interval, + "metadata": metadata, + "product_external_ids": convert_and_respect_annotation_metadata( + object_=product_external_ids, annotation=typing.Sequence[BillingProductPricing], direction="write" + ), + "status": status, + "subscription_external_id": subscription_external_id, + "total_price": total_price, + }, + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertBillingSubscriptionResponse, + parse_obj_as( + type_=UpsertBillingSubscriptionResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) diff --git a/src/schematic/billing/types/__init__.py b/src/schematic/billing/types/__init__.py index 3ce7bc2..6e74bbf 100644 --- a/src/schematic/billing/types/__init__.py +++ b/src/schematic/billing/types/__init__.py @@ -1,13 +1,45 @@ # This file was auto-generated by Fern from our API Definition. -from .list_products_params import ListProductsParams -from .list_products_response import ListProductsResponse +from .count_billing_products_params import CountBillingProductsParams +from .count_billing_products_response import CountBillingProductsResponse +from .count_customers_params import CountCustomersParams +from .count_customers_response import CountCustomersResponse +from .list_billing_products_params import ListBillingProductsParams +from .list_billing_products_response import ListBillingProductsResponse +from .list_customers_params import ListCustomersParams +from .list_customers_response import ListCustomersResponse +from .list_invoices_params import ListInvoicesParams +from .list_invoices_response import ListInvoicesResponse +from .list_payment_methods_params import ListPaymentMethodsParams +from .list_payment_methods_response import ListPaymentMethodsResponse +from .list_product_prices_params import ListProductPricesParams +from .list_product_prices_response import ListProductPricesResponse +from .upsert_billing_customer_response import UpsertBillingCustomerResponse +from .upsert_billing_price_response import UpsertBillingPriceResponse from .upsert_billing_product_response import UpsertBillingProductResponse from .upsert_billing_subscription_response import UpsertBillingSubscriptionResponse +from .upsert_invoice_response import UpsertInvoiceResponse +from .upsert_payment_method_response import UpsertPaymentMethodResponse __all__ = [ - "ListProductsParams", - "ListProductsResponse", + "CountBillingProductsParams", + "CountBillingProductsResponse", + "CountCustomersParams", + "CountCustomersResponse", + "ListBillingProductsParams", + "ListBillingProductsResponse", + "ListCustomersParams", + "ListCustomersResponse", + "ListInvoicesParams", + "ListInvoicesResponse", + "ListPaymentMethodsParams", + "ListPaymentMethodsResponse", + "ListProductPricesParams", + "ListProductPricesResponse", + "UpsertBillingCustomerResponse", + "UpsertBillingPriceResponse", "UpsertBillingProductResponse", "UpsertBillingSubscriptionResponse", + "UpsertInvoiceResponse", + "UpsertPaymentMethodResponse", ] diff --git a/src/schematic/billing/types/count_billing_products_params.py b/src/schematic/billing/types/count_billing_products_params.py new file mode 100644 index 0000000..e100147 --- /dev/null +++ b/src/schematic/billing/types/count_billing_products_params.py @@ -0,0 +1,35 @@ +# 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 + + +class CountBillingProductsParams(UniversalBaseModel): + """ + Input parameters + """ + + ids: typing.Optional[typing.List[str]] = None + limit: typing.Optional[int] = pydantic.Field(default=None) + """ + Page limit (default 100) + """ + + name: typing.Optional[str] = None + offset: typing.Optional[int] = pydantic.Field(default=None) + """ + Page offset (default 0) + """ + + q: 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/schematic/billing/types/count_billing_products_response.py b/src/schematic/billing/types/count_billing_products_response.py new file mode 100644 index 0000000..fcff859 --- /dev/null +++ b/src/schematic/billing/types/count_billing_products_response.py @@ -0,0 +1,25 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.count_response import CountResponse +from .count_billing_products_params import CountBillingProductsParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing + + +class CountBillingProductsResponse(UniversalBaseModel): + data: CountResponse + params: CountBillingProductsParams = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/billing/types/count_customers_params.py b/src/schematic/billing/types/count_customers_params.py new file mode 100644 index 0000000..bc11a00 --- /dev/null +++ b/src/schematic/billing/types/count_customers_params.py @@ -0,0 +1,35 @@ +# 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 + + +class CountCustomersParams(UniversalBaseModel): + """ + Input parameters + """ + + failed_to_import: typing.Optional[bool] = None + limit: typing.Optional[int] = pydantic.Field(default=None) + """ + Page limit (default 100) + """ + + name: typing.Optional[str] = None + offset: typing.Optional[int] = pydantic.Field(default=None) + """ + Page offset (default 0) + """ + + q: 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/schematic/billing/types/count_customers_response.py b/src/schematic/billing/types/count_customers_response.py new file mode 100644 index 0000000..1a78a73 --- /dev/null +++ b/src/schematic/billing/types/count_customers_response.py @@ -0,0 +1,25 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.count_response import CountResponse +from .count_customers_params import CountCustomersParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing + + +class CountCustomersResponse(UniversalBaseModel): + data: CountResponse + params: CountCustomersParams = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/billing/types/list_billing_products_params.py b/src/schematic/billing/types/list_billing_products_params.py new file mode 100644 index 0000000..2b38ba5 --- /dev/null +++ b/src/schematic/billing/types/list_billing_products_params.py @@ -0,0 +1,35 @@ +# 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 + + +class ListBillingProductsParams(UniversalBaseModel): + """ + Input parameters + """ + + ids: typing.Optional[typing.List[str]] = None + limit: typing.Optional[int] = pydantic.Field(default=None) + """ + Page limit (default 100) + """ + + name: typing.Optional[str] = None + offset: typing.Optional[int] = pydantic.Field(default=None) + """ + Page offset (default 0) + """ + + q: 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/schematic/billing/types/list_billing_products_response.py b/src/schematic/billing/types/list_billing_products_response.py new file mode 100644 index 0000000..0af53a4 --- /dev/null +++ b/src/schematic/billing/types/list_billing_products_response.py @@ -0,0 +1,29 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +import typing +from ...types.billing_product_detail_response_data import BillingProductDetailResponseData +import pydantic +from .list_billing_products_params import ListBillingProductsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class ListBillingProductsResponse(UniversalBaseModel): + data: typing.List[BillingProductDetailResponseData] = pydantic.Field() + """ + The returned resources + """ + + params: ListBillingProductsParams = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/billing/types/list_customers_params.py b/src/schematic/billing/types/list_customers_params.py new file mode 100644 index 0000000..d0d2c84 --- /dev/null +++ b/src/schematic/billing/types/list_customers_params.py @@ -0,0 +1,35 @@ +# 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 + + +class ListCustomersParams(UniversalBaseModel): + """ + Input parameters + """ + + failed_to_import: typing.Optional[bool] = None + limit: typing.Optional[int] = pydantic.Field(default=None) + """ + Page limit (default 100) + """ + + name: typing.Optional[str] = None + offset: typing.Optional[int] = pydantic.Field(default=None) + """ + Page offset (default 0) + """ + + q: 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/schematic/billing/types/list_customers_response.py b/src/schematic/billing/types/list_customers_response.py new file mode 100644 index 0000000..de37d23 --- /dev/null +++ b/src/schematic/billing/types/list_customers_response.py @@ -0,0 +1,29 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +import typing +from ...types.billing_customer_with_subscriptions_response_data import BillingCustomerWithSubscriptionsResponseData +import pydantic +from .list_customers_params import ListCustomersParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class ListCustomersResponse(UniversalBaseModel): + data: typing.List[BillingCustomerWithSubscriptionsResponseData] = pydantic.Field() + """ + The returned resources + """ + + params: ListCustomersParams = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/billing/types/list_invoices_params.py b/src/schematic/billing/types/list_invoices_params.py new file mode 100644 index 0000000..62ba189 --- /dev/null +++ b/src/schematic/billing/types/list_invoices_params.py @@ -0,0 +1,35 @@ +# 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 + + +class ListInvoicesParams(UniversalBaseModel): + """ + Input parameters + """ + + company_id: typing.Optional[str] = None + customer_external_id: typing.Optional[str] = None + limit: typing.Optional[int] = pydantic.Field(default=None) + """ + Page limit (default 100) + """ + + offset: typing.Optional[int] = pydantic.Field(default=None) + """ + Page offset (default 0) + """ + + subscription_external_id: 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/schematic/billing/types/list_invoices_response.py b/src/schematic/billing/types/list_invoices_response.py new file mode 100644 index 0000000..2d513f2 --- /dev/null +++ b/src/schematic/billing/types/list_invoices_response.py @@ -0,0 +1,29 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +import typing +from ...types.invoice_response_data import InvoiceResponseData +import pydantic +from .list_invoices_params import ListInvoicesParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class ListInvoicesResponse(UniversalBaseModel): + data: typing.List[InvoiceResponseData] = pydantic.Field() + """ + The returned resources + """ + + params: ListInvoicesParams = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/billing/types/list_payment_methods_params.py b/src/schematic/billing/types/list_payment_methods_params.py new file mode 100644 index 0000000..7d8b66a --- /dev/null +++ b/src/schematic/billing/types/list_payment_methods_params.py @@ -0,0 +1,35 @@ +# 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 + + +class ListPaymentMethodsParams(UniversalBaseModel): + """ + Input parameters + """ + + company_id: typing.Optional[str] = None + customer_external_id: typing.Optional[str] = None + limit: typing.Optional[int] = pydantic.Field(default=None) + """ + Page limit (default 100) + """ + + offset: typing.Optional[int] = pydantic.Field(default=None) + """ + Page offset (default 0) + """ + + subscription_external_id: 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/schematic/billing/types/list_payment_methods_response.py b/src/schematic/billing/types/list_payment_methods_response.py new file mode 100644 index 0000000..f6a87b1 --- /dev/null +++ b/src/schematic/billing/types/list_payment_methods_response.py @@ -0,0 +1,29 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +import typing +from ...types.payment_method_response_data import PaymentMethodResponseData +import pydantic +from .list_payment_methods_params import ListPaymentMethodsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class ListPaymentMethodsResponse(UniversalBaseModel): + data: typing.List[PaymentMethodResponseData] = pydantic.Field() + """ + The returned resources + """ + + params: ListPaymentMethodsParams = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/billing/types/list_product_prices_params.py b/src/schematic/billing/types/list_product_prices_params.py new file mode 100644 index 0000000..0d1b245 --- /dev/null +++ b/src/schematic/billing/types/list_product_prices_params.py @@ -0,0 +1,35 @@ +# 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 + + +class ListProductPricesParams(UniversalBaseModel): + """ + Input parameters + """ + + ids: typing.Optional[typing.List[str]] = None + limit: typing.Optional[int] = pydantic.Field(default=None) + """ + Page limit (default 100) + """ + + name: typing.Optional[str] = None + offset: typing.Optional[int] = pydantic.Field(default=None) + """ + Page offset (default 0) + """ + + q: 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/schematic/billing/types/list_product_prices_response.py b/src/schematic/billing/types/list_product_prices_response.py new file mode 100644 index 0000000..37e7b0e --- /dev/null +++ b/src/schematic/billing/types/list_product_prices_response.py @@ -0,0 +1,29 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +import typing +from ...types.billing_price_response_data import BillingPriceResponseData +import pydantic +from .list_product_prices_params import ListProductPricesParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class ListProductPricesResponse(UniversalBaseModel): + data: typing.List[BillingPriceResponseData] = pydantic.Field() + """ + The returned resources + """ + + params: ListProductPricesParams = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/billing/types/list_products_params.py b/src/schematic/billing/types/list_products_params.py deleted file mode 100644 index 6419024..0000000 --- a/src/schematic/billing/types/list_products_params.py +++ /dev/null @@ -1,43 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - - -class ListProductsParams(pydantic_v1.BaseModel): - """ - Input parameters - """ - - ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) - """ - Page limit (default 100) - """ - - name: typing.Optional[str] = None - offset: typing.Optional[int] = pydantic_v1.Field(default=None) - """ - Page offset (default 0) - """ - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/billing/types/list_products_response.py b/src/schematic/billing/types/list_products_response.py deleted file mode 100644 index 094d35b..0000000 --- a/src/schematic/billing/types/list_products_response.py +++ /dev/null @@ -1,39 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from ...types.billing_product_response_data import BillingProductResponseData -from .list_products_params import ListProductsParams - - -class ListProductsResponse(pydantic_v1.BaseModel): - data: typing.List[BillingProductResponseData] = pydantic_v1.Field() - """ - The returned resources - """ - - params: ListProductsParams = pydantic_v1.Field() - """ - Input parameters - """ - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/billing/types/upsert_billing_customer_response.py b/src/schematic/billing/types/upsert_billing_customer_response.py new file mode 100644 index 0000000..125d053 --- /dev/null +++ b/src/schematic/billing/types/upsert_billing_customer_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.billing_customer_response_data import BillingCustomerResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class UpsertBillingCustomerResponse(UniversalBaseModel): + data: BillingCustomerResponseData + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/billing/types/upsert_billing_price_response.py b/src/schematic/billing/types/upsert_billing_price_response.py new file mode 100644 index 0000000..8298154 --- /dev/null +++ b/src/schematic/billing/types/upsert_billing_price_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.billing_price_response_data import BillingPriceResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class UpsertBillingPriceResponse(UniversalBaseModel): + data: BillingPriceResponseData + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/billing/types/upsert_billing_product_response.py b/src/schematic/billing/types/upsert_billing_product_response.py index 35fdfeb..6c66b7f 100644 --- a/src/schematic/billing/types/upsert_billing_product_response.py +++ b/src/schematic/billing/types/upsert_billing_product_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.billing_product_response_data import BillingProductResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpsertBillingProductResponse(pydantic_v1.BaseModel): +class UpsertBillingProductResponse(UniversalBaseModel): data: BillingProductResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/billing/types/upsert_billing_subscription_response.py b/src/schematic/billing/types/upsert_billing_subscription_response.py index 28a3941..32639bb 100644 --- a/src/schematic/billing/types/upsert_billing_subscription_response.py +++ b/src/schematic/billing/types/upsert_billing_subscription_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.billing_subscription_response_data import BillingSubscriptionResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpsertBillingSubscriptionResponse(pydantic_v1.BaseModel): +class UpsertBillingSubscriptionResponse(UniversalBaseModel): data: BillingSubscriptionResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/billing/types/upsert_invoice_response.py b/src/schematic/billing/types/upsert_invoice_response.py new file mode 100644 index 0000000..f167421 --- /dev/null +++ b/src/schematic/billing/types/upsert_invoice_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.invoice_response_data import InvoiceResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class UpsertInvoiceResponse(UniversalBaseModel): + data: InvoiceResponseData + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/billing/types/upsert_payment_method_response.py b/src/schematic/billing/types/upsert_payment_method_response.py new file mode 100644 index 0000000..cce6cae --- /dev/null +++ b/src/schematic/billing/types/upsert_payment_method_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.payment_method_response_data import PaymentMethodResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class UpsertPaymentMethodResponse(UniversalBaseModel): + data: PaymentMethodResponseData + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/companies/__init__.py b/src/schematic/companies/__init__.py index 420f3ca..634bf1e 100644 --- a/src/schematic/companies/__init__.py +++ b/src/schematic/companies/__init__.py @@ -39,8 +39,6 @@ ListCompaniesResponse, ListCompanyMembershipsParams, ListCompanyMembershipsResponse, - ListCompanyPlansParams, - ListCompanyPlansResponse, ListEntityKeyDefinitionsParams, ListEntityKeyDefinitionsRequestEntityType, ListEntityKeyDefinitionsResponse, @@ -104,8 +102,6 @@ "ListCompaniesResponse", "ListCompanyMembershipsParams", "ListCompanyMembershipsResponse", - "ListCompanyPlansParams", - "ListCompanyPlansResponse", "ListEntityKeyDefinitionsParams", "ListEntityKeyDefinitionsRequestEntityType", "ListEntityKeyDefinitionsResponse", diff --git a/src/schematic/companies/client.py b/src/schematic/companies/client.py index 484c54f..d2033db 100644 --- a/src/schematic/companies/client.py +++ b/src/schematic/companies/client.py @@ -1,70 +1,66 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt import typing -import urllib.parse -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.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 -from ..core.query_encoder import encode_query -from ..core.remove_none_from_dict import remove_none_from_dict +from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions +from .types.list_companies_response import ListCompaniesResponse +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 ..errors.forbidden_error import ForbiddenError from ..errors.internal_server_error import InternalServerError +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError as core_api_error_ApiError +import datetime as dt +from .types.upsert_company_response import UpsertCompanyResponse +from .types.get_company_response import GetCompanyResponse +from ..core.jsonable_encoder import jsonable_encoder 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.delete_company_response import DeleteCompanyResponse from .types.count_companies_response import CountCompaniesResponse -from .types.count_entity_key_definitions_request_entity_type import CountEntityKeyDefinitionsRequestEntityType -from .types.count_entity_key_definitions_response import CountEntityKeyDefinitionsResponse -from .types.count_entity_trait_definitions_request_entity_type import CountEntityTraitDefinitionsRequestEntityType -from .types.count_entity_trait_definitions_request_trait_type import CountEntityTraitDefinitionsRequestTraitType -from .types.count_entity_trait_definitions_response import CountEntityTraitDefinitionsResponse -from .types.count_users_response import CountUsersResponse from .types.create_company_response import CreateCompanyResponse -from .types.create_entity_trait_definition_request_body_entity_type import ( - CreateEntityTraitDefinitionRequestBodyEntityType, -) -from .types.create_entity_trait_definition_request_body_trait_type import ( - CreateEntityTraitDefinitionRequestBodyTraitType, -) -from .types.create_user_response import CreateUserResponse from .types.delete_company_by_keys_response import DeleteCompanyByKeysResponse -from .types.delete_company_membership_response import DeleteCompanyMembershipResponse -from .types.delete_company_response import DeleteCompanyResponse -from .types.delete_user_by_keys_response import DeleteUserByKeysResponse -from .types.delete_user_response import DeleteUserResponse -from .types.get_active_company_subscription_response import GetActiveCompanySubscriptionResponse +from .types.lookup_company_response import LookupCompanyResponse from .types.get_active_deals_response import GetActiveDealsResponse -from .types.get_company_response import GetCompanyResponse -from .types.get_entity_trait_definition_response import GetEntityTraitDefinitionResponse -from .types.get_entity_trait_values_response import GetEntityTraitValuesResponse -from .types.get_or_create_company_membership_response import GetOrCreateCompanyMembershipResponse -from .types.get_or_create_entity_trait_definition_response import GetOrCreateEntityTraitDefinitionResponse -from .types.get_user_response import GetUserResponse -from .types.list_companies_response import ListCompaniesResponse from .types.list_company_memberships_response import ListCompanyMembershipsResponse -from .types.list_company_plans_response import ListCompanyPlansResponse +from .types.get_or_create_company_membership_response import GetOrCreateCompanyMembershipResponse +from .types.delete_company_membership_response import DeleteCompanyMembershipResponse +from .types.get_active_company_subscription_response import GetActiveCompanySubscriptionResponse +from .types.upsert_company_trait_response import UpsertCompanyTraitResponse from .types.list_entity_key_definitions_request_entity_type import ListEntityKeyDefinitionsRequestEntityType from .types.list_entity_key_definitions_response import ListEntityKeyDefinitionsResponse +from .types.count_entity_key_definitions_request_entity_type import CountEntityKeyDefinitionsRequestEntityType +from .types.count_entity_key_definitions_response import CountEntityKeyDefinitionsResponse from .types.list_entity_trait_definitions_request_entity_type import ListEntityTraitDefinitionsRequestEntityType from .types.list_entity_trait_definitions_request_trait_type import ListEntityTraitDefinitionsRequestTraitType from .types.list_entity_trait_definitions_response import ListEntityTraitDefinitionsResponse -from .types.list_users_response import ListUsersResponse -from .types.lookup_company_response import LookupCompanyResponse -from .types.lookup_user_response import LookupUserResponse +from .types.create_entity_trait_definition_request_body_entity_type import ( + CreateEntityTraitDefinitionRequestBodyEntityType, +) +from .types.create_entity_trait_definition_request_body_trait_type import ( + CreateEntityTraitDefinitionRequestBodyTraitType, +) +from .types.get_or_create_entity_trait_definition_response import GetOrCreateEntityTraitDefinitionResponse +from .types.get_entity_trait_definition_response import GetEntityTraitDefinitionResponse from .types.update_entity_trait_definition_request_body_trait_type import ( UpdateEntityTraitDefinitionRequestBodyTraitType, ) from .types.update_entity_trait_definition_response import UpdateEntityTraitDefinitionResponse -from .types.upsert_company_response import UpsertCompanyResponse -from .types.upsert_company_trait_response import UpsertCompanyTraitResponse -from .types.upsert_user_response import UpsertUserResponse +from .types.count_entity_trait_definitions_request_entity_type import CountEntityTraitDefinitionsRequestEntityType +from .types.count_entity_trait_definitions_request_trait_type import CountEntityTraitDefinitionsRequestTraitType +from .types.count_entity_trait_definitions_response import CountEntityTraitDefinitionsResponse +from .types.get_entity_trait_values_response import GetEntityTraitValuesResponse from .types.upsert_user_trait_response import UpsertUserTraitResponse +from .types.list_users_response import ListUsersResponse +from .types.upsert_user_response import UpsertUserResponse +from .types.get_user_response import GetUserResponse +from .types.delete_user_response import DeleteUserResponse +from .types.count_users_response import CountUsersResponse +from .types.create_user_response import CreateUserResponse +from .types.delete_user_by_keys_response import DeleteUserByKeysResponse +from .types.lookup_user_response import LookupUserResponse +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -81,6 +77,7 @@ def list_companies( plan_id: typing.Optional[str] = None, q: typing.Optional[str] = None, without_feature_override_for: typing.Optional[str] = None, + without_plan: typing.Optional[bool] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -98,6 +95,9 @@ def list_companies( without_feature_override_for : typing.Optional[str] Filter out companies that already have a company override for the specified feature ID + without_plan : typing.Optional[bool] + Filter out companies that have a plan + limit : typing.Optional[int] Page limit (default 100) @@ -114,7 +114,7 @@ def list_companies( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -122,56 +122,68 @@ def list_companies( client.companies.list_companies() """ _response = self._client_wrapper.httpx_client.request( + "companies", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "companies"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "ids": ids, - "plan_id": plan_id, - "q": q, - "without_feature_override_for": without_feature_override_for, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListCompaniesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "ids": ids, + "plan_id": plan_id, + "q": q, + "without_feature_override_for": without_feature_override_for, + "without_plan": without_plan, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListCompaniesResponse, + parse_obj_as( + type_=ListCompaniesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -184,7 +196,7 @@ def upsert_company( id: typing.Optional[str] = OMIT, last_seen_at: typing.Optional[dt.datetime] = OMIT, name: typing.Optional[str] = OMIT, - traits: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, update_only: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UpsertCompanyResponse: @@ -194,12 +206,13 @@ def upsert_company( keys : typing.Dict[str, str] id : typing.Optional[str] + If you know the Schematic ID, you can use that here instead of keys last_seen_at : typing.Optional[dt.datetime] name : typing.Optional[str] - traits : typing.Optional[typing.Dict[str, typing.Any]] + traits : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] A map of trait names to trait values update_only : typing.Optional[bool] @@ -214,69 +227,78 @@ def upsert_company( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) client.companies.upsert_company( - keys={"keys": "keys"}, + keys={"key": "value"}, ) """ - _request: typing.Dict[str, typing.Any] = {"keys": keys} - if id is not OMIT: - _request["id"] = id - if last_seen_at is not OMIT: - _request["last_seen_at"] = last_seen_at - if name is not OMIT: - _request["name"] = name - if traits is not OMIT: - _request["traits"] = traits - if update_only is not OMIT: - _request["update_only"] = update_only _response = self._client_wrapper.httpx_client.request( + "companies", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "companies"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "id": id, + "keys": keys, + "last_seen_at": last_seen_at, + "name": name, + "traits": traits, + "update_only": update_only, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertCompanyResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertCompanyResponse, + parse_obj_as( + type_=UpsertCompanyResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -301,7 +323,7 @@ def get_company( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -311,44 +333,59 @@ def get_company( ) """ _response = self._client_wrapper.httpx_client.request( + f"companies/{jsonable_encoder(company_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"companies/{jsonable_encoder(company_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetCompanyResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetCompanyResponse, + parse_obj_as( + type_=GetCompanyResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -373,7 +410,7 @@ def delete_company( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -383,44 +420,59 @@ def delete_company( ) """ _response = self._client_wrapper.httpx_client.request( + f"companies/{jsonable_encoder(company_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"companies/{jsonable_encoder(company_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteCompanyResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteCompanyResponse, + parse_obj_as( + type_=DeleteCompanyResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -433,6 +485,7 @@ def count_companies( plan_id: typing.Optional[str] = None, q: typing.Optional[str] = None, without_feature_override_for: typing.Optional[str] = None, + without_plan: typing.Optional[bool] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -450,6 +503,9 @@ def count_companies( without_feature_override_for : typing.Optional[str] Filter out companies that already have a company override for the specified feature ID + without_plan : typing.Optional[bool] + Filter out companies that have a plan + limit : typing.Optional[int] Page limit (default 100) @@ -466,7 +522,7 @@ def count_companies( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -474,56 +530,68 @@ def count_companies( client.companies.count_companies() """ _response = self._client_wrapper.httpx_client.request( + "companies/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "companies/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "ids": ids, - "plan_id": plan_id, - "q": q, - "without_feature_override_for": without_feature_override_for, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountCompaniesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "ids": ids, + "plan_id": plan_id, + "q": q, + "without_feature_override_for": without_feature_override_for, + "without_plan": without_plan, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountCompaniesResponse, + parse_obj_as( + type_=CountCompaniesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -536,7 +604,7 @@ def create_company( id: typing.Optional[str] = OMIT, last_seen_at: typing.Optional[dt.datetime] = OMIT, name: typing.Optional[str] = OMIT, - traits: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, update_only: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CreateCompanyResponse: @@ -546,12 +614,13 @@ def create_company( keys : typing.Dict[str, str] id : typing.Optional[str] + If you know the Schematic ID, you can use that here instead of keys last_seen_at : typing.Optional[dt.datetime] name : typing.Optional[str] - traits : typing.Optional[typing.Dict[str, typing.Any]] + traits : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] A map of trait names to trait values update_only : typing.Optional[bool] @@ -566,69 +635,78 @@ def create_company( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) client.companies.create_company( - keys={"keys": "keys"}, + keys={"key": "value"}, ) """ - _request: typing.Dict[str, typing.Any] = {"keys": keys} - if id is not OMIT: - _request["id"] = id - if last_seen_at is not OMIT: - _request["last_seen_at"] = last_seen_at - if name is not OMIT: - _request["name"] = name - if traits is not OMIT: - _request["traits"] = traits - if update_only is not OMIT: - _request["update_only"] = update_only _response = self._client_wrapper.httpx_client.request( + "companies/create", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "companies/create"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "id": id, + "keys": keys, + "last_seen_at": last_seen_at, + "name": name, + "traits": traits, + "update_only": update_only, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateCompanyResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateCompanyResponse, + parse_obj_as( + type_=CreateCompanyResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -652,71 +730,88 @@ def delete_company_by_keys( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) client.companies.delete_company_by_keys( - keys={"keys": "keys"}, + keys={"key": "value"}, ) """ - _request: typing.Dict[str, typing.Any] = {"keys": keys} _response = self._client_wrapper.httpx_client.request( + "companies/delete", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "companies/delete"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "keys": keys, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteCompanyByKeysResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteCompanyByKeysResponse, + parse_obj_as( + type_=DeleteCompanyByKeysResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) def lookup_company( - self, *, keys: typing.Dict[str, typing.Any], request_options: typing.Optional[RequestOptions] = None + self, + *, + keys: typing.Dict[str, typing.Optional[typing.Any]], + request_options: typing.Optional[RequestOptions] = None, ) -> LookupCompanyResponse: """ Parameters ---------- - keys : typing.Dict[str, typing.Any] + keys : typing.Dict[str, typing.Optional[typing.Any]] Key/value pairs request_options : typing.Optional[RequestOptions] @@ -729,7 +824,7 @@ def lookup_company( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -739,51 +834,62 @@ def lookup_company( ) """ _response = self._client_wrapper.httpx_client.request( + "companies/lookup", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "companies/lookup"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "keys": jsonable_encoder(keys), - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(LookupCompanyResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "keys": keys, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + LookupCompanyResponse, + parse_obj_as( + type_=LookupCompanyResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -821,7 +927,7 @@ def get_active_deals( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -832,54 +938,65 @@ def get_active_deals( ) """ _response = self._client_wrapper.httpx_client.request( + "company-crm-deals", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-crm-deals"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "deal_stage": deal_stage, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetActiveDealsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "deal_stage": deal_stage, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetActiveDealsResponse, + parse_obj_as( + type_=GetActiveDealsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -917,7 +1034,7 @@ def list_company_memberships( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -925,54 +1042,65 @@ def list_company_memberships( client.companies.list_company_memberships() """ _response = self._client_wrapper.httpx_client.request( + "company-memberships", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-memberships"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "user_id": user_id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListCompanyMembershipsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "user_id": user_id, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListCompanyMembershipsResponse, + parse_obj_as( + type_=ListCompanyMembershipsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -998,7 +1126,7 @@ def get_or_create_company_membership( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1009,48 +1137,64 @@ def get_or_create_company_membership( ) """ _response = self._client_wrapper.httpx_client.request( + "company-memberships", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-memberships"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder({"company_id": company_id, "user_id": user_id}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"company_id": company_id, "user_id": user_id}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "company_id": company_id, + "user_id": user_id, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetOrCreateCompanyMembershipResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetOrCreateCompanyMembershipResponse, + parse_obj_as( + type_=GetOrCreateCompanyMembershipResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1075,7 +1219,7 @@ def delete_company_membership( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1085,65 +1229,76 @@ def delete_company_membership( ) """ _response = self._client_wrapper.httpx_client.request( + f"company-memberships/{jsonable_encoder(company_membership_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"company-memberships/{jsonable_encoder(company_membership_id)}", - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteCompanyMembershipResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteCompanyMembershipResponse, + parse_obj_as( + type_=DeleteCompanyMembershipResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) - def list_company_plans( + def get_active_company_subscription( self, *, - company_id: typing.Optional[str] = None, - plan_id: typing.Optional[str] = None, + company_id: str, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> ListCompanyPlansResponse: + ) -> GetActiveCompanySubscriptionResponse: """ Parameters ---------- - company_id : typing.Optional[str] - - plan_id : typing.Optional[str] + company_id : str limit : typing.Optional[int] Page limit (default 100) @@ -1156,173 +1311,94 @@ def list_company_plans( Returns ------- - ListCompanyPlansResponse + GetActiveCompanySubscriptionResponse OK Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) - client.companies.list_company_plans() + client.companies.get_active_company_subscription( + company_id="company_id", + ) """ _response = self._client_wrapper.httpx_client.request( + "company-subscriptions", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-plans"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "plan_id": plan_id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListCompanyPlansResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetActiveCompanySubscriptionResponse, + parse_obj_as( + type_=GetActiveCompanySubscriptionResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) - def get_active_company_subscription( + def upsert_company_trait( self, *, - company_id: str, - limit: typing.Optional[int] = None, - offset: typing.Optional[int] = None, + keys: typing.Dict[str, str], + trait: str, + incr: typing.Optional[int] = OMIT, + set_: typing.Optional[str] = OMIT, + update_only: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> GetActiveCompanySubscriptionResponse: - """ - Parameters - ---------- - company_id : str - - limit : typing.Optional[int] - Page limit (default 100) - - offset : typing.Optional[int] - Page offset (default 0) - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetActiveCompanySubscriptionResponse - OK - - Examples - -------- - from schematic.client import Schematic - - client = Schematic( - api_key="YOUR_API_KEY", - ) - client.companies.get_active_company_subscription( - company_id="company_id", - ) - """ - _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-subscriptions"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetActiveCompanySubscriptionResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - try: - _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 upsert_company_trait( - self, - *, - keys: typing.Dict[str, str], - trait: str, - incr: typing.Optional[int] = OMIT, - set_: typing.Optional[str] = OMIT, - update_only: typing.Optional[bool] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> UpsertCompanyTraitResponse: + ) -> UpsertCompanyTraitResponse: """ Parameters ---------- @@ -1351,66 +1427,78 @@ def upsert_company_trait( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) client.companies.upsert_company_trait( - keys={"keys": "keys"}, + keys={"key": "value"}, trait="trait", ) """ - _request: typing.Dict[str, typing.Any] = {"keys": keys, "trait": trait} - if incr is not OMIT: - _request["incr"] = incr - if set_ is not OMIT: - _request["set"] = set_ - if update_only is not OMIT: - _request["update_only"] = update_only _response = self._client_wrapper.httpx_client.request( + "company-traits", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-traits"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "incr": incr, + "keys": keys, + "set": set_, + "trait": trait, + "update_only": update_only, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertCompanyTraitResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertCompanyTraitResponse, + parse_obj_as( + type_=UpsertCompanyTraitResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1421,7 +1509,7 @@ def list_entity_key_definitions( *, entity_type: typing.Optional[ListEntityKeyDefinitionsRequestEntityType] = None, ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, - key: typing.Optional[str] = None, + q: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -1433,7 +1521,7 @@ def list_entity_key_definitions( ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] - key : typing.Optional[str] + q : typing.Optional[str] limit : typing.Optional[int] Page limit (default 100) @@ -1451,7 +1539,7 @@ def list_entity_key_definitions( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1459,55 +1547,66 @@ def list_entity_key_definitions( client.companies.list_entity_key_definitions() """ _response = self._client_wrapper.httpx_client.request( + "entity-key-definitions", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity-key-definitions"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "entity_type": entity_type, - "ids": ids, - "key": key, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListEntityKeyDefinitionsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "entity_type": entity_type, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListEntityKeyDefinitionsResponse, + parse_obj_as( + type_=ListEntityKeyDefinitionsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1518,7 +1617,7 @@ def count_entity_key_definitions( *, entity_type: typing.Optional[CountEntityKeyDefinitionsRequestEntityType] = None, ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, - key: typing.Optional[str] = None, + q: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -1530,7 +1629,7 @@ def count_entity_key_definitions( ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] - key : typing.Optional[str] + q : typing.Optional[str] limit : typing.Optional[int] Page limit (default 100) @@ -1548,7 +1647,7 @@ def count_entity_key_definitions( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1556,55 +1655,66 @@ def count_entity_key_definitions( client.companies.count_entity_key_definitions() """ _response = self._client_wrapper.httpx_client.request( + "entity-key-definitions/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity-key-definitions/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "entity_type": entity_type, - "ids": ids, - "key": key, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountEntityKeyDefinitionsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "entity_type": entity_type, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountEntityKeyDefinitionsResponse, + parse_obj_as( + type_=CountEntityKeyDefinitionsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1648,7 +1758,7 @@ def list_entity_trait_definitions( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1656,56 +1766,67 @@ def list_entity_trait_definitions( client.companies.list_entity_trait_definitions() """ _response = self._client_wrapper.httpx_client.request( + "entity-trait-definitions", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity-trait-definitions"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "entity_type": entity_type, - "ids": ids, - "trait_type": trait_type, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListEntityTraitDefinitionsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "entity_type": entity_type, + "ids": ids, + "trait_type": trait_type, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListEntityTraitDefinitionsResponse, + parse_obj_as( + type_=ListEntityTraitDefinitionsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1741,7 +1862,7 @@ def get_or_create_entity_trait_definition( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1752,56 +1873,67 @@ def get_or_create_entity_trait_definition( trait_type="boolean", ) """ - _request: typing.Dict[str, typing.Any] = { - "entity_type": entity_type, - "hierarchy": hierarchy, - "trait_type": trait_type, - } - if display_name is not OMIT: - _request["display_name"] = display_name _response = self._client_wrapper.httpx_client.request( + "entity-trait-definitions", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity-trait-definitions"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "display_name": display_name, + "entity_type": entity_type, + "hierarchy": hierarchy, + "trait_type": trait_type, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetOrCreateEntityTraitDefinitionResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetOrCreateEntityTraitDefinitionResponse, + parse_obj_as( + type_=GetOrCreateEntityTraitDefinitionResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1826,7 +1958,7 @@ def get_entity_trait_definition( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1836,45 +1968,59 @@ def get_entity_trait_definition( ) """ _response = self._client_wrapper.httpx_client.request( + f"entity-trait-definitions/{jsonable_encoder(entity_trait_definition_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity-trait-definitions/{jsonable_encoder(entity_trait_definition_id)}", - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetEntityTraitDefinitionResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetEntityTraitDefinitionResponse, + parse_obj_as( + type_=GetEntityTraitDefinitionResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1908,7 +2054,7 @@ def update_entity_trait_definition( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1918,57 +2064,75 @@ def update_entity_trait_definition( trait_type="boolean", ) """ - _request: typing.Dict[str, typing.Any] = {"trait_type": trait_type} - if display_name is not OMIT: - _request["display_name"] = display_name _response = self._client_wrapper.httpx_client.request( + f"entity-trait-definitions/{jsonable_encoder(entity_trait_definition_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity-trait-definitions/{jsonable_encoder(entity_trait_definition_id)}", - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "display_name": display_name, + "trait_type": trait_type, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateEntityTraitDefinitionResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateEntityTraitDefinitionResponse, + parse_obj_as( + type_=UpdateEntityTraitDefinitionResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2012,7 +2176,7 @@ def count_entity_trait_definitions( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -2020,56 +2184,67 @@ def count_entity_trait_definitions( client.companies.count_entity_trait_definitions() """ _response = self._client_wrapper.httpx_client.request( + "entity-trait-definitions/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity-trait-definitions/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "entity_type": entity_type, - "ids": ids, - "trait_type": trait_type, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountEntityTraitDefinitionsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "entity_type": entity_type, + "ids": ids, + "trait_type": trait_type, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountEntityTraitDefinitionsResponse, + parse_obj_as( + type_=CountEntityTraitDefinitionsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2107,7 +2282,7 @@ def get_entity_trait_values( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -2117,54 +2292,65 @@ def get_entity_trait_values( ) """ _response = self._client_wrapper.httpx_client.request( + "entity-trait-values", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity-trait-values"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "definition_id": definition_id, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetEntityTraitValuesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "definition_id": definition_id, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetEntityTraitValuesResponse, + parse_obj_as( + type_=GetEntityTraitValuesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2208,66 +2394,78 @@ def upsert_user_trait( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) client.companies.upsert_user_trait( - keys={"keys": "keys"}, + keys={"key": "value"}, trait="trait", ) """ - _request: typing.Dict[str, typing.Any] = {"keys": keys, "trait": trait} - if incr is not OMIT: - _request["incr"] = incr - if set_ is not OMIT: - _request["set"] = set_ - if update_only is not OMIT: - _request["update_only"] = update_only _response = self._client_wrapper.httpx_client.request( + "user-traits", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "user-traits"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "incr": incr, + "keys": keys, + "set": set_, + "trait": trait, + "update_only": update_only, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertUserTraitResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertUserTraitResponse, + parse_obj_as( + type_=UpsertUserTraitResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2312,7 +2510,7 @@ def list_users( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -2320,56 +2518,67 @@ def list_users( client.companies.list_users() """ _response = self._client_wrapper.httpx_client.request( + "users", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "ids": ids, - "plan_id": plan_id, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListUsersResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "ids": ids, + "plan_id": plan_id, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListUsersResponse, + parse_obj_as( + type_=ListUsersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2381,9 +2590,10 @@ def upsert_user( company: typing.Dict[str, str], keys: typing.Dict[str, str], company_id: typing.Optional[str] = OMIT, + id: typing.Optional[str] = OMIT, last_seen_at: typing.Optional[dt.datetime] = OMIT, name: typing.Optional[str] = OMIT, - traits: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, update_only: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UpsertUserResponse: @@ -2398,11 +2608,14 @@ def upsert_user( company_id : typing.Optional[str] Optionally specify company using Schematic company ID + id : typing.Optional[str] + If you know the Schematic ID, you can use that here instead of keys + last_seen_at : typing.Optional[dt.datetime] name : typing.Optional[str] - traits : typing.Optional[typing.Dict[str, typing.Any]] + traits : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] A map of trait names to trait values update_only : typing.Optional[bool] @@ -2417,70 +2630,81 @@ def upsert_user( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) client.companies.upsert_user( - company={"company": "company"}, - keys={"keys": "keys"}, + company={"key": "value"}, + keys={"key": "value"}, ) """ - _request: typing.Dict[str, typing.Any] = {"company": company, "keys": keys} - if company_id is not OMIT: - _request["company_id"] = company_id - if last_seen_at is not OMIT: - _request["last_seen_at"] = last_seen_at - if name is not OMIT: - _request["name"] = name - if traits is not OMIT: - _request["traits"] = traits - if update_only is not OMIT: - _request["update_only"] = update_only _response = self._client_wrapper.httpx_client.request( + "users", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "company": company, + "company_id": company_id, + "id": id, + "keys": keys, + "last_seen_at": last_seen_at, + "name": name, + "traits": traits, + "update_only": update_only, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertUserResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertUserResponse, + parse_obj_as( + type_=UpsertUserResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2503,7 +2727,7 @@ def get_user(self, user_id: str, *, request_options: typing.Optional[RequestOpti Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -2513,42 +2737,59 @@ def get_user(self, user_id: str, *, request_options: typing.Optional[RequestOpti ) """ _response = self._client_wrapper.httpx_client.request( + f"users/{jsonable_encoder(user_id)}", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetUserResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetUserResponse, + parse_obj_as( + type_=GetUserResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2573,7 +2814,7 @@ def delete_user( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -2583,42 +2824,59 @@ def delete_user( ) """ _response = self._client_wrapper.httpx_client.request( + f"users/{jsonable_encoder(user_id)}", method="DELETE", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteUserResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteUserResponse, + parse_obj_as( + type_=DeleteUserResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2663,7 +2921,7 @@ def count_users( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -2671,56 +2929,67 @@ def count_users( client.companies.count_users() """ _response = self._client_wrapper.httpx_client.request( + "users/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "ids": ids, - "plan_id": plan_id, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountUsersResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "ids": ids, + "plan_id": plan_id, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountUsersResponse, + parse_obj_as( + type_=CountUsersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2732,9 +3001,10 @@ def create_user( company: typing.Dict[str, str], keys: typing.Dict[str, str], company_id: typing.Optional[str] = OMIT, + id: typing.Optional[str] = OMIT, last_seen_at: typing.Optional[dt.datetime] = OMIT, name: typing.Optional[str] = OMIT, - traits: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, update_only: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CreateUserResponse: @@ -2749,11 +3019,14 @@ def create_user( company_id : typing.Optional[str] Optionally specify company using Schematic company ID + id : typing.Optional[str] + If you know the Schematic ID, you can use that here instead of keys + last_seen_at : typing.Optional[dt.datetime] name : typing.Optional[str] - traits : typing.Optional[typing.Dict[str, typing.Any]] + traits : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] A map of trait names to trait values update_only : typing.Optional[bool] @@ -2768,70 +3041,81 @@ def create_user( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) client.companies.create_user( - company={"company": "company"}, - keys={"keys": "keys"}, + company={"key": "value"}, + keys={"key": "value"}, ) """ - _request: typing.Dict[str, typing.Any] = {"company": company, "keys": keys} - if company_id is not OMIT: - _request["company_id"] = company_id - if last_seen_at is not OMIT: - _request["last_seen_at"] = last_seen_at - if name is not OMIT: - _request["name"] = name - if traits is not OMIT: - _request["traits"] = traits - if update_only is not OMIT: - _request["update_only"] = update_only _response = self._client_wrapper.httpx_client.request( + "users/create", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users/create"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "company": company, + "company_id": company_id, + "id": id, + "keys": keys, + "last_seen_at": last_seen_at, + "name": name, + "traits": traits, + "update_only": update_only, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateUserResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateUserResponse, + parse_obj_as( + type_=CreateUserResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2855,71 +3139,88 @@ def delete_user_by_keys( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) client.companies.delete_user_by_keys( - keys={"keys": "keys"}, + keys={"key": "value"}, ) """ - _request: typing.Dict[str, typing.Any] = {"keys": keys} _response = self._client_wrapper.httpx_client.request( + "users/delete", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users/delete"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "keys": keys, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteUserByKeysResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteUserByKeysResponse, + parse_obj_as( + type_=DeleteUserByKeysResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) def lookup_user( - self, *, keys: typing.Dict[str, typing.Any], request_options: typing.Optional[RequestOptions] = None + self, + *, + keys: typing.Dict[str, typing.Optional[typing.Any]], + request_options: typing.Optional[RequestOptions] = None, ) -> LookupUserResponse: """ Parameters ---------- - keys : typing.Dict[str, typing.Any] + keys : typing.Dict[str, typing.Optional[typing.Any]] Key/value pairs request_options : typing.Optional[RequestOptions] @@ -2932,7 +3233,7 @@ def lookup_user( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -2942,51 +3243,62 @@ def lookup_user( ) """ _response = self._client_wrapper.httpx_client.request( + "users/lookup", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users/lookup"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "keys": jsonable_encoder(keys), - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(LookupUserResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "keys": keys, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + LookupUserResponse, + parse_obj_as( + type_=LookupUserResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3004,6 +3316,7 @@ async def list_companies( plan_id: typing.Optional[str] = None, q: typing.Optional[str] = None, without_feature_override_for: typing.Optional[str] = None, + without_plan: typing.Optional[bool] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -3021,6 +3334,9 @@ async def list_companies( without_feature_override_for : typing.Optional[str] Filter out companies that already have a company override for the specified feature ID + without_plan : typing.Optional[bool] + Filter out companies that have a plan + limit : typing.Optional[int] Page limit (default 100) @@ -3037,64 +3353,84 @@ async def list_companies( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.list_companies() + + + async def main() -> None: + await client.companies.list_companies() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "companies", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "companies"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "ids": ids, - "plan_id": plan_id, - "q": q, - "without_feature_override_for": without_feature_override_for, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListCompaniesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "ids": ids, + "plan_id": plan_id, + "q": q, + "without_feature_override_for": without_feature_override_for, + "without_plan": without_plan, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListCompaniesResponse, + parse_obj_as( + type_=ListCompaniesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3107,7 +3443,7 @@ async def upsert_company( id: typing.Optional[str] = OMIT, last_seen_at: typing.Optional[dt.datetime] = OMIT, name: typing.Optional[str] = OMIT, - traits: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, update_only: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UpsertCompanyResponse: @@ -3117,12 +3453,13 @@ async def upsert_company( keys : typing.Dict[str, str] id : typing.Optional[str] + If you know the Schematic ID, you can use that here instead of keys last_seen_at : typing.Optional[dt.datetime] name : typing.Optional[str] - traits : typing.Optional[typing.Dict[str, typing.Any]] + traits : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] A map of trait names to trait values update_only : typing.Optional[bool] @@ -3137,69 +3474,86 @@ async def upsert_company( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.upsert_company( - keys={"keys": "keys"}, - ) + + + async def main() -> None: + await client.companies.upsert_company( + keys={"key": "value"}, + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"keys": keys} - if id is not OMIT: - _request["id"] = id - if last_seen_at is not OMIT: - _request["last_seen_at"] = last_seen_at - if name is not OMIT: - _request["name"] = name - if traits is not OMIT: - _request["traits"] = traits - if update_only is not OMIT: - _request["update_only"] = update_only _response = await self._client_wrapper.httpx_client.request( + "companies", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "companies"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "id": id, + "keys": keys, + "last_seen_at": last_seen_at, + "name": name, + "traits": traits, + "update_only": update_only, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertCompanyResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertCompanyResponse, + parse_obj_as( + type_=UpsertCompanyResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3224,54 +3578,77 @@ async def get_company( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.get_company( - company_id="company_id", - ) + + + async def main() -> None: + await client.companies.get_company( + company_id="company_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"companies/{jsonable_encoder(company_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"companies/{jsonable_encoder(company_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetCompanyResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetCompanyResponse, + parse_obj_as( + type_=GetCompanyResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3296,54 +3673,77 @@ async def delete_company( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.delete_company( - company_id="company_id", - ) + + + async def main() -> None: + await client.companies.delete_company( + company_id="company_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"companies/{jsonable_encoder(company_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"companies/{jsonable_encoder(company_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteCompanyResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteCompanyResponse, + parse_obj_as( + type_=DeleteCompanyResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3356,6 +3756,7 @@ async def count_companies( plan_id: typing.Optional[str] = None, q: typing.Optional[str] = None, without_feature_override_for: typing.Optional[str] = None, + without_plan: typing.Optional[bool] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -3373,6 +3774,9 @@ async def count_companies( without_feature_override_for : typing.Optional[str] Filter out companies that already have a company override for the specified feature ID + without_plan : typing.Optional[bool] + Filter out companies that have a plan + limit : typing.Optional[int] Page limit (default 100) @@ -3389,64 +3793,84 @@ async def count_companies( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.count_companies() + + + async def main() -> None: + await client.companies.count_companies() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "companies/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "companies/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "ids": ids, - "plan_id": plan_id, - "q": q, - "without_feature_override_for": without_feature_override_for, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountCompaniesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "ids": ids, + "plan_id": plan_id, + "q": q, + "without_feature_override_for": without_feature_override_for, + "without_plan": without_plan, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountCompaniesResponse, + parse_obj_as( + type_=CountCompaniesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3459,7 +3883,7 @@ async def create_company( id: typing.Optional[str] = OMIT, last_seen_at: typing.Optional[dt.datetime] = OMIT, name: typing.Optional[str] = OMIT, - traits: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, update_only: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CreateCompanyResponse: @@ -3469,12 +3893,13 @@ async def create_company( keys : typing.Dict[str, str] id : typing.Optional[str] + If you know the Schematic ID, you can use that here instead of keys last_seen_at : typing.Optional[dt.datetime] name : typing.Optional[str] - traits : typing.Optional[typing.Dict[str, typing.Any]] + traits : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] A map of trait names to trait values update_only : typing.Optional[bool] @@ -3489,69 +3914,86 @@ async def create_company( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.create_company( - keys={"keys": "keys"}, - ) + + + async def main() -> None: + await client.companies.create_company( + keys={"key": "value"}, + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"keys": keys} - if id is not OMIT: - _request["id"] = id - if last_seen_at is not OMIT: - _request["last_seen_at"] = last_seen_at - if name is not OMIT: - _request["name"] = name - if traits is not OMIT: - _request["traits"] = traits - if update_only is not OMIT: - _request["update_only"] = update_only _response = await self._client_wrapper.httpx_client.request( + "companies/create", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "companies/create"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "id": id, + "keys": keys, + "last_seen_at": last_seen_at, + "name": name, + "traits": traits, + "update_only": update_only, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateCompanyResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateCompanyResponse, + parse_obj_as( + type_=CreateCompanyResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3575,71 +4017,96 @@ async def delete_company_by_keys( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.delete_company_by_keys( - keys={"keys": "keys"}, - ) + + + async def main() -> None: + await client.companies.delete_company_by_keys( + keys={"key": "value"}, + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"keys": keys} _response = await self._client_wrapper.httpx_client.request( + "companies/delete", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "companies/delete"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "keys": keys, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteCompanyByKeysResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteCompanyByKeysResponse, + parse_obj_as( + type_=DeleteCompanyByKeysResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) async def lookup_company( - self, *, keys: typing.Dict[str, typing.Any], request_options: typing.Optional[RequestOptions] = None + self, + *, + keys: typing.Dict[str, typing.Optional[typing.Any]], + request_options: typing.Optional[RequestOptions] = None, ) -> LookupCompanyResponse: """ Parameters ---------- - keys : typing.Dict[str, typing.Any] + keys : typing.Dict[str, typing.Optional[typing.Any]] Key/value pairs request_options : typing.Optional[RequestOptions] @@ -3652,61 +4119,80 @@ async def lookup_company( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.lookup_company( - keys={"string": {"key": "value"}}, - ) + + + async def main() -> None: + await client.companies.lookup_company( + keys={"string": {"key": "value"}}, + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "companies/lookup", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "companies/lookup"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "keys": jsonable_encoder(keys), - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(LookupCompanyResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "keys": keys, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + LookupCompanyResponse, + parse_obj_as( + type_=LookupCompanyResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3744,65 +4230,84 @@ async def get_active_deals( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.get_active_deals( - company_id="company_id", - deal_stage="deal_stage", - ) + + + async def main() -> None: + await client.companies.get_active_deals( + company_id="company_id", + deal_stage="deal_stage", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "company-crm-deals", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-crm-deals"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "deal_stage": deal_stage, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetActiveDealsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "deal_stage": deal_stage, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetActiveDealsResponse, + parse_obj_as( + type_=GetActiveDealsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3840,62 +4345,81 @@ async def list_company_memberships( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.list_company_memberships() + + + async def main() -> None: + await client.companies.list_company_memberships() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "company-memberships", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-memberships"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "user_id": user_id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListCompanyMembershipsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "user_id": user_id, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListCompanyMembershipsResponse, + parse_obj_as( + type_=ListCompanyMembershipsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3921,59 +4445,83 @@ async def get_or_create_company_membership( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.get_or_create_company_membership( - company_id="company_id", - user_id="user_id", - ) + + + async def main() -> None: + await client.companies.get_or_create_company_membership( + company_id="company_id", + user_id="user_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "company-memberships", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-memberships"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder({"company_id": company_id, "user_id": user_id}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"company_id": company_id, "user_id": user_id}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "company_id": company_id, + "user_id": user_id, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetOrCreateCompanyMembershipResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetOrCreateCompanyMembershipResponse, + parse_obj_as( + type_=GetOrCreateCompanyMembershipResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3998,148 +4546,77 @@ async def delete_company_membership( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.delete_company_membership( - company_membership_id="company_membership_id", - ) - """ - _response = await self._client_wrapper.httpx_client.request( - method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"company-memberships/{jsonable_encoder(company_membership_id)}", - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteCompanyMembershipResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - try: - _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 list_company_plans( - self, - *, - company_id: typing.Optional[str] = None, - plan_id: typing.Optional[str] = None, - limit: typing.Optional[int] = None, - offset: typing.Optional[int] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> ListCompanyPlansResponse: - """ - Parameters - ---------- - company_id : typing.Optional[str] - - plan_id : typing.Optional[str] - - limit : typing.Optional[int] - Page limit (default 100) - - offset : typing.Optional[int] - Page offset (default 0) - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - Returns - ------- - ListCompanyPlansResponse - OK + async def main() -> None: + await client.companies.delete_company_membership( + company_membership_id="company_membership_id", + ) - Examples - -------- - from schematic.client import AsyncSchematic - client = AsyncSchematic( - api_key="YOUR_API_KEY", - ) - await client.companies.list_company_plans() + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-plans"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "plan_id": plan_id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListCompanyPlansResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + f"company-memberships/{jsonable_encoder(company_membership_id)}", + method="DELETE", + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteCompanyMembershipResponse, + parse_obj_as( + type_=DeleteCompanyMembershipResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4174,63 +4651,82 @@ async def get_active_company_subscription( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.get_active_company_subscription( - company_id="company_id", - ) + + + async def main() -> None: + await client.companies.get_active_company_subscription( + company_id="company_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "company-subscriptions", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-subscriptions"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetActiveCompanySubscriptionResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetActiveCompanySubscriptionResponse, + parse_obj_as( + type_=GetActiveCompanySubscriptionResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4274,66 +4770,86 @@ async def upsert_company_trait( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.upsert_company_trait( - keys={"keys": "keys"}, - trait="trait", - ) + + + async def main() -> None: + await client.companies.upsert_company_trait( + keys={"key": "value"}, + trait="trait", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"keys": keys, "trait": trait} - if incr is not OMIT: - _request["incr"] = incr - if set_ is not OMIT: - _request["set"] = set_ - if update_only is not OMIT: - _request["update_only"] = update_only _response = await self._client_wrapper.httpx_client.request( + "company-traits", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-traits"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "incr": incr, + "keys": keys, + "set": set_, + "trait": trait, + "update_only": update_only, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertCompanyTraitResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertCompanyTraitResponse, + parse_obj_as( + type_=UpsertCompanyTraitResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4344,7 +4860,7 @@ async def list_entity_key_definitions( *, entity_type: typing.Optional[ListEntityKeyDefinitionsRequestEntityType] = None, ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, - key: typing.Optional[str] = None, + q: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -4356,7 +4872,7 @@ async def list_entity_key_definitions( ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] - key : typing.Optional[str] + q : typing.Optional[str] limit : typing.Optional[int] Page limit (default 100) @@ -4374,63 +4890,82 @@ async def list_entity_key_definitions( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.list_entity_key_definitions() + + + async def main() -> None: + await client.companies.list_entity_key_definitions() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "entity-key-definitions", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity-key-definitions"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "entity_type": entity_type, - "ids": ids, - "key": key, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListEntityKeyDefinitionsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "entity_type": entity_type, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListEntityKeyDefinitionsResponse, + parse_obj_as( + type_=ListEntityKeyDefinitionsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4441,7 +4976,7 @@ async def count_entity_key_definitions( *, entity_type: typing.Optional[CountEntityKeyDefinitionsRequestEntityType] = None, ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, - key: typing.Optional[str] = None, + q: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -4453,7 +4988,7 @@ async def count_entity_key_definitions( ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] - key : typing.Optional[str] + q : typing.Optional[str] limit : typing.Optional[int] Page limit (default 100) @@ -4471,63 +5006,82 @@ async def count_entity_key_definitions( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.count_entity_key_definitions() + + + async def main() -> None: + await client.companies.count_entity_key_definitions() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "entity-key-definitions/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity-key-definitions/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "entity_type": entity_type, - "ids": ids, - "key": key, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountEntityKeyDefinitionsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "entity_type": entity_type, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountEntityKeyDefinitionsResponse, + parse_obj_as( + type_=CountEntityKeyDefinitionsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4571,64 +5125,83 @@ async def list_entity_trait_definitions( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.list_entity_trait_definitions() + + + async def main() -> None: + await client.companies.list_entity_trait_definitions() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "entity-trait-definitions", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity-trait-definitions"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "entity_type": entity_type, - "ids": ids, - "trait_type": trait_type, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListEntityTraitDefinitionsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "entity_type": entity_type, + "ids": ids, + "trait_type": trait_type, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListEntityTraitDefinitionsResponse, + parse_obj_as( + type_=ListEntityTraitDefinitionsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4664,67 +5237,86 @@ async def get_or_create_entity_trait_definition( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.get_or_create_entity_trait_definition( - entity_type="company", - hierarchy=["hierarchy"], - trait_type="boolean", - ) + + + async def main() -> None: + await client.companies.get_or_create_entity_trait_definition( + entity_type="company", + hierarchy=["hierarchy"], + trait_type="boolean", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = { - "entity_type": entity_type, - "hierarchy": hierarchy, - "trait_type": trait_type, - } - if display_name is not OMIT: - _request["display_name"] = display_name _response = await self._client_wrapper.httpx_client.request( + "entity-trait-definitions", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity-trait-definitions"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "display_name": display_name, + "entity_type": entity_type, + "hierarchy": hierarchy, + "trait_type": trait_type, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetOrCreateEntityTraitDefinitionResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetOrCreateEntityTraitDefinitionResponse, + parse_obj_as( + type_=GetOrCreateEntityTraitDefinitionResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4749,55 +5341,77 @@ async def get_entity_trait_definition( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.get_entity_trait_definition( - entity_trait_definition_id="entity_trait_definition_id", - ) + + + async def main() -> None: + await client.companies.get_entity_trait_definition( + entity_trait_definition_id="entity_trait_definition_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"entity-trait-definitions/{jsonable_encoder(entity_trait_definition_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity-trait-definitions/{jsonable_encoder(entity_trait_definition_id)}", - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetEntityTraitDefinitionResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetEntityTraitDefinitionResponse, + parse_obj_as( + type_=GetEntityTraitDefinitionResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4831,67 +5445,93 @@ async def update_entity_trait_definition( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.update_entity_trait_definition( - entity_trait_definition_id="entity_trait_definition_id", - trait_type="boolean", - ) + + + async def main() -> None: + await client.companies.update_entity_trait_definition( + entity_trait_definition_id="entity_trait_definition_id", + trait_type="boolean", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"trait_type": trait_type} - if display_name is not OMIT: - _request["display_name"] = display_name _response = await self._client_wrapper.httpx_client.request( + f"entity-trait-definitions/{jsonable_encoder(entity_trait_definition_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", - f"entity-trait-definitions/{jsonable_encoder(entity_trait_definition_id)}", - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "display_name": display_name, + "trait_type": trait_type, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateEntityTraitDefinitionResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateEntityTraitDefinitionResponse, + parse_obj_as( + type_=UpdateEntityTraitDefinitionResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4935,64 +5575,83 @@ async def count_entity_trait_definitions( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.count_entity_trait_definitions() + + + async def main() -> None: + await client.companies.count_entity_trait_definitions() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "entity-trait-definitions/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity-trait-definitions/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "entity_type": entity_type, - "ids": ids, - "trait_type": trait_type, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountEntityTraitDefinitionsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "entity_type": entity_type, + "ids": ids, + "trait_type": trait_type, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountEntityTraitDefinitionsResponse, + parse_obj_as( + type_=CountEntityTraitDefinitionsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -5030,64 +5689,83 @@ async def get_entity_trait_values( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.get_entity_trait_values( - definition_id="definition_id", - ) + + + async def main() -> None: + await client.companies.get_entity_trait_values( + definition_id="definition_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "entity-trait-values", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity-trait-values"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "definition_id": definition_id, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetEntityTraitValuesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "definition_id": definition_id, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetEntityTraitValuesResponse, + parse_obj_as( + type_=GetEntityTraitValuesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -5131,66 +5809,86 @@ async def upsert_user_trait( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.upsert_user_trait( - keys={"keys": "keys"}, - trait="trait", - ) + + + async def main() -> None: + await client.companies.upsert_user_trait( + keys={"key": "value"}, + trait="trait", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"keys": keys, "trait": trait} - if incr is not OMIT: - _request["incr"] = incr - if set_ is not OMIT: - _request["set"] = set_ - if update_only is not OMIT: - _request["update_only"] = update_only _response = await self._client_wrapper.httpx_client.request( + "user-traits", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "user-traits"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "incr": incr, + "keys": keys, + "set": set_, + "trait": trait, + "update_only": update_only, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertUserTraitResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertUserTraitResponse, + parse_obj_as( + type_=UpsertUserTraitResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -5235,64 +5933,83 @@ async def list_users( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.list_users() + + + async def main() -> None: + await client.companies.list_users() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "users", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "ids": ids, - "plan_id": plan_id, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListUsersResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "ids": ids, + "plan_id": plan_id, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListUsersResponse, + parse_obj_as( + type_=ListUsersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -5304,9 +6021,10 @@ async def upsert_user( company: typing.Dict[str, str], keys: typing.Dict[str, str], company_id: typing.Optional[str] = OMIT, + id: typing.Optional[str] = OMIT, last_seen_at: typing.Optional[dt.datetime] = OMIT, name: typing.Optional[str] = OMIT, - traits: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, update_only: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UpsertUserResponse: @@ -5321,11 +6039,14 @@ async def upsert_user( company_id : typing.Optional[str] Optionally specify company using Schematic company ID + id : typing.Optional[str] + If you know the Schematic ID, you can use that here instead of keys + last_seen_at : typing.Optional[dt.datetime] name : typing.Optional[str] - traits : typing.Optional[typing.Dict[str, typing.Any]] + traits : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] A map of trait names to trait values update_only : typing.Optional[bool] @@ -5340,70 +6061,89 @@ async def upsert_user( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.upsert_user( - company={"company": "company"}, - keys={"keys": "keys"}, - ) + + + async def main() -> None: + await client.companies.upsert_user( + company={"key": "value"}, + keys={"key": "value"}, + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"company": company, "keys": keys} - if company_id is not OMIT: - _request["company_id"] = company_id - if last_seen_at is not OMIT: - _request["last_seen_at"] = last_seen_at - if name is not OMIT: - _request["name"] = name - if traits is not OMIT: - _request["traits"] = traits - if update_only is not OMIT: - _request["update_only"] = update_only _response = await self._client_wrapper.httpx_client.request( + "users", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "company": company, + "company_id": company_id, + "id": id, + "keys": keys, + "last_seen_at": last_seen_at, + "name": name, + "traits": traits, + "update_only": update_only, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertUserResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertUserResponse, + parse_obj_as( + type_=UpsertUserResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -5428,52 +6168,77 @@ async def get_user( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.get_user( - user_id="user_id", - ) + + + async def main() -> None: + await client.companies.get_user( + user_id="user_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"users/{jsonable_encoder(user_id)}", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetUserResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetUserResponse, + parse_obj_as( + type_=GetUserResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -5498,52 +6263,77 @@ async def delete_user( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.delete_user( - user_id="user_id", - ) + + + async def main() -> None: + await client.companies.delete_user( + user_id="user_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"users/{jsonable_encoder(user_id)}", method="DELETE", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteUserResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteUserResponse, + parse_obj_as( + type_=DeleteUserResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -5588,64 +6378,83 @@ async def count_users( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.count_users() + + + async def main() -> None: + await client.companies.count_users() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "users/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "ids": ids, - "plan_id": plan_id, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountUsersResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "ids": ids, + "plan_id": plan_id, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountUsersResponse, + parse_obj_as( + type_=CountUsersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -5657,9 +6466,10 @@ async def create_user( company: typing.Dict[str, str], keys: typing.Dict[str, str], company_id: typing.Optional[str] = OMIT, + id: typing.Optional[str] = OMIT, last_seen_at: typing.Optional[dt.datetime] = OMIT, name: typing.Optional[str] = OMIT, - traits: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, update_only: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CreateUserResponse: @@ -5674,11 +6484,14 @@ async def create_user( company_id : typing.Optional[str] Optionally specify company using Schematic company ID + id : typing.Optional[str] + If you know the Schematic ID, you can use that here instead of keys + last_seen_at : typing.Optional[dt.datetime] name : typing.Optional[str] - traits : typing.Optional[typing.Dict[str, typing.Any]] + traits : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] A map of trait names to trait values update_only : typing.Optional[bool] @@ -5693,70 +6506,89 @@ async def create_user( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.create_user( - company={"company": "company"}, - keys={"keys": "keys"}, - ) + + + async def main() -> None: + await client.companies.create_user( + company={"key": "value"}, + keys={"key": "value"}, + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"company": company, "keys": keys} - if company_id is not OMIT: - _request["company_id"] = company_id - if last_seen_at is not OMIT: - _request["last_seen_at"] = last_seen_at - if name is not OMIT: - _request["name"] = name - if traits is not OMIT: - _request["traits"] = traits - if update_only is not OMIT: - _request["update_only"] = update_only _response = await self._client_wrapper.httpx_client.request( + "users/create", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users/create"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "company": company, + "company_id": company_id, + "id": id, + "keys": keys, + "last_seen_at": last_seen_at, + "name": name, + "traits": traits, + "update_only": update_only, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateUserResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateUserResponse, + parse_obj_as( + type_=CreateUserResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -5780,71 +6612,96 @@ async def delete_user_by_keys( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.delete_user_by_keys( - keys={"keys": "keys"}, - ) + + + async def main() -> None: + await client.companies.delete_user_by_keys( + keys={"key": "value"}, + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"keys": keys} _response = await self._client_wrapper.httpx_client.request( + "users/delete", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users/delete"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "keys": keys, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteUserByKeysResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteUserByKeysResponse, + parse_obj_as( + type_=DeleteUserByKeysResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) async def lookup_user( - self, *, keys: typing.Dict[str, typing.Any], request_options: typing.Optional[RequestOptions] = None + self, + *, + keys: typing.Dict[str, typing.Optional[typing.Any]], + request_options: typing.Optional[RequestOptions] = None, ) -> LookupUserResponse: """ Parameters ---------- - keys : typing.Dict[str, typing.Any] + keys : typing.Dict[str, typing.Optional[typing.Any]] Key/value pairs request_options : typing.Optional[RequestOptions] @@ -5857,61 +6714,80 @@ async def lookup_user( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.companies.lookup_user( - keys={"string": {"key": "value"}}, - ) + + + async def main() -> None: + await client.companies.lookup_user( + keys={"string": {"key": "value"}}, + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "users/lookup", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "users/lookup"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "keys": jsonable_encoder(keys), - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(LookupUserResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "keys": keys, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + LookupUserResponse, + parse_obj_as( + type_=LookupUserResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) diff --git a/src/schematic/companies/types/__init__.py b/src/schematic/companies/types/__init__.py index 53a6cfc..2c4c539 100644 --- a/src/schematic/companies/types/__init__.py +++ b/src/schematic/companies/types/__init__.py @@ -42,8 +42,6 @@ from .list_companies_response import ListCompaniesResponse from .list_company_memberships_params import ListCompanyMembershipsParams from .list_company_memberships_response import ListCompanyMembershipsResponse -from .list_company_plans_params import ListCompanyPlansParams -from .list_company_plans_response import ListCompanyPlansResponse from .list_entity_key_definitions_params import ListEntityKeyDefinitionsParams from .list_entity_key_definitions_request_entity_type import ListEntityKeyDefinitionsRequestEntityType from .list_entity_key_definitions_response import ListEntityKeyDefinitionsResponse @@ -108,8 +106,6 @@ "ListCompaniesResponse", "ListCompanyMembershipsParams", "ListCompanyMembershipsResponse", - "ListCompanyPlansParams", - "ListCompanyPlansResponse", "ListEntityKeyDefinitionsParams", "ListEntityKeyDefinitionsRequestEntityType", "ListEntityKeyDefinitionsResponse", diff --git a/src/schematic/companies/types/count_companies_params.py b/src/schematic/companies/types/count_companies_params.py index a8f0722..f597f7b 100644 --- a/src/schematic/companies/types/count_companies_params.py +++ b/src/schematic/companies/types/count_companies_params.py @@ -1,53 +1,48 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountCompaniesParams(pydantic_v1.BaseModel): +class CountCompaniesParams(UniversalBaseModel): """ Input parameters """ ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ plan_id: typing.Optional[str] = None - q: typing.Optional[str] = pydantic_v1.Field(default=None) + q: typing.Optional[str] = pydantic.Field(default=None) """ Search filter """ - without_feature_override_for: typing.Optional[str] = pydantic_v1.Field(default=None) + without_feature_override_for: typing.Optional[str] = pydantic.Field(default=None) """ Filter out companies that already have a company override for the specified feature ID """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + without_plan: typing.Optional[bool] = pydantic.Field(default=None) + """ + Filter out companies that have a plan + """ - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/count_companies_response.py b/src/schematic/companies/types/count_companies_response.py index fc84ace..ad1469a 100644 --- a/src/schematic/companies/types/count_companies_response.py +++ b/src/schematic/companies/types/count_companies_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_companies_params import CountCompaniesParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountCompaniesResponse(pydantic_v1.BaseModel): +class CountCompaniesResponse(UniversalBaseModel): data: CountResponse - params: CountCompaniesParams = pydantic_v1.Field() + params: CountCompaniesParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/count_entity_key_definitions_params.py b/src/schematic/companies/types/count_entity_key_definitions_params.py index aa6094e..33810f4 100644 --- a/src/schematic/companies/types/count_entity_key_definitions_params.py +++ b/src/schematic/companies/types/count_entity_key_definitions_params.py @@ -1,45 +1,36 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .count_entity_key_definitions_response_params_entity_type import CountEntityKeyDefinitionsResponseParamsEntityType +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CountEntityKeyDefinitionsParams(pydantic_v1.BaseModel): +class CountEntityKeyDefinitionsParams(UniversalBaseModel): """ Input parameters """ entity_type: typing.Optional[CountEntityKeyDefinitionsResponseParamsEntityType] = None ids: typing.Optional[typing.List[str]] = None - key: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + q: typing.Optional[str] = None - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/count_entity_key_definitions_response.py b/src/schematic/companies/types/count_entity_key_definitions_response.py index bc7e71b..93c62ed 100644 --- a/src/schematic/companies/types/count_entity_key_definitions_response.py +++ b/src/schematic/companies/types/count_entity_key_definitions_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_entity_key_definitions_params import CountEntityKeyDefinitionsParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountEntityKeyDefinitionsResponse(pydantic_v1.BaseModel): +class CountEntityKeyDefinitionsResponse(UniversalBaseModel): data: CountResponse - params: CountEntityKeyDefinitionsParams = pydantic_v1.Field() + params: CountEntityKeyDefinitionsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/count_entity_trait_definitions_params.py b/src/schematic/companies/types/count_entity_trait_definitions_params.py index 902be48..9ba5624 100644 --- a/src/schematic/companies/types/count_entity_trait_definitions_params.py +++ b/src/schematic/companies/types/count_entity_trait_definitions_params.py @@ -1,31 +1,30 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .count_entity_trait_definitions_response_params_entity_type import ( CountEntityTraitDefinitionsResponseParamsEntityType, ) +import pydantic from .count_entity_trait_definitions_response_params_trait_type import ( CountEntityTraitDefinitionsResponseParamsTraitType, ) +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CountEntityTraitDefinitionsParams(pydantic_v1.BaseModel): +class CountEntityTraitDefinitionsParams(UniversalBaseModel): """ Input parameters """ entity_type: typing.Optional[CountEntityTraitDefinitionsResponseParamsEntityType] = None ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ @@ -33,20 +32,11 @@ class CountEntityTraitDefinitionsParams(pydantic_v1.BaseModel): q: typing.Optional[str] = None trait_type: typing.Optional[CountEntityTraitDefinitionsResponseParamsTraitType] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/count_entity_trait_definitions_response.py b/src/schematic/companies/types/count_entity_trait_definitions_response.py index 5ea8921..4f15601 100644 --- a/src/schematic/companies/types/count_entity_trait_definitions_response.py +++ b/src/schematic/companies/types/count_entity_trait_definitions_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_entity_trait_definitions_params import CountEntityTraitDefinitionsParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountEntityTraitDefinitionsResponse(pydantic_v1.BaseModel): +class CountEntityTraitDefinitionsResponse(UniversalBaseModel): data: CountResponse - params: CountEntityTraitDefinitionsParams = pydantic_v1.Field() + params: CountEntityTraitDefinitionsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/count_users_params.py b/src/schematic/companies/types/count_users_params.py index b58d20f..5336cc9 100644 --- a/src/schematic/companies/types/count_users_params.py +++ b/src/schematic/companies/types/count_users_params.py @@ -1,49 +1,39 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountUsersParams(pydantic_v1.BaseModel): +class CountUsersParams(UniversalBaseModel): """ Input parameters """ company_id: typing.Optional[str] = None ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ plan_id: typing.Optional[str] = None - q: typing.Optional[str] = pydantic_v1.Field(default=None) + q: typing.Optional[str] = pydantic.Field(default=None) """ Search filter """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/count_users_response.py b/src/schematic/companies/types/count_users_response.py index 0edfb85..ba835ec 100644 --- a/src/schematic/companies/types/count_users_response.py +++ b/src/schematic/companies/types/count_users_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_users_params import CountUsersParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountUsersResponse(pydantic_v1.BaseModel): +class CountUsersResponse(UniversalBaseModel): data: CountResponse - params: CountUsersParams = pydantic_v1.Field() + params: CountUsersParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/create_company_response.py b/src/schematic/companies/types/create_company_response.py index 3c51efe..78cca5d 100644 --- a/src/schematic/companies/types/create_company_response.py +++ b/src/schematic/companies/types/create_company_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.company_detail_response_data import CompanyDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CreateCompanyResponse(pydantic_v1.BaseModel): +class CreateCompanyResponse(UniversalBaseModel): data: CompanyDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/create_user_response.py b/src/schematic/companies/types/create_user_response.py index 47e26eb..a2eae91 100644 --- a/src/schematic/companies/types/create_user_response.py +++ b/src/schematic/companies/types/create_user_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.user_detail_response_data import UserDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CreateUserResponse(pydantic_v1.BaseModel): +class CreateUserResponse(UniversalBaseModel): data: UserDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/delete_company_by_keys_response.py b/src/schematic/companies/types/delete_company_by_keys_response.py index 2c0e9cd..fe768e7 100644 --- a/src/schematic/companies/types/delete_company_by_keys_response.py +++ b/src/schematic/companies/types/delete_company_by_keys_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.company_response_data import CompanyResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class DeleteCompanyByKeysResponse(pydantic_v1.BaseModel): +class DeleteCompanyByKeysResponse(UniversalBaseModel): data: CompanyResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/delete_company_membership_response.py b/src/schematic/companies/types/delete_company_membership_response.py index 70c10cd..b81a889 100644 --- a/src/schematic/companies/types/delete_company_membership_response.py +++ b/src/schematic/companies/types/delete_company_membership_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.delete_response import DeleteResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class DeleteCompanyMembershipResponse(pydantic_v1.BaseModel): +class DeleteCompanyMembershipResponse(UniversalBaseModel): data: DeleteResponse - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/delete_company_response.py b/src/schematic/companies/types/delete_company_response.py index 8a0fc6c..7610815 100644 --- a/src/schematic/companies/types/delete_company_response.py +++ b/src/schematic/companies/types/delete_company_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.delete_response import DeleteResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class DeleteCompanyResponse(pydantic_v1.BaseModel): +class DeleteCompanyResponse(UniversalBaseModel): data: DeleteResponse - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/delete_user_by_keys_response.py b/src/schematic/companies/types/delete_user_by_keys_response.py index 202ba59..3f7d6d0 100644 --- a/src/schematic/companies/types/delete_user_by_keys_response.py +++ b/src/schematic/companies/types/delete_user_by_keys_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.user_response_data import UserResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class DeleteUserByKeysResponse(pydantic_v1.BaseModel): +class DeleteUserByKeysResponse(UniversalBaseModel): data: UserResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/delete_user_response.py b/src/schematic/companies/types/delete_user_response.py index 87e075b..bb60a0a 100644 --- a/src/schematic/companies/types/delete_user_response.py +++ b/src/schematic/companies/types/delete_user_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.delete_response import DeleteResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class DeleteUserResponse(pydantic_v1.BaseModel): +class DeleteUserResponse(UniversalBaseModel): data: DeleteResponse - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/get_active_company_subscription_params.py b/src/schematic/companies/types/get_active_company_subscription_params.py index 7202030..ca26a9d 100644 --- a/src/schematic/companies/types/get_active_company_subscription_params.py +++ b/src/schematic/companies/types/get_active_company_subscription_params.py @@ -1,42 +1,32 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class GetActiveCompanySubscriptionParams(pydantic_v1.BaseModel): +class GetActiveCompanySubscriptionParams(UniversalBaseModel): """ Input parameters """ company_id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/get_active_company_subscription_response.py b/src/schematic/companies/types/get_active_company_subscription_response.py index 21df1ec..6663c11 100644 --- a/src/schematic/companies/types/get_active_company_subscription_response.py +++ b/src/schematic/companies/types/get_active_company_subscription_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.company_subscription_response_data import CompanySubscriptionResponseData +import pydantic from .get_active_company_subscription_params import GetActiveCompanySubscriptionParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetActiveCompanySubscriptionResponse(pydantic_v1.BaseModel): - data: typing.List[CompanySubscriptionResponseData] = pydantic_v1.Field() +class GetActiveCompanySubscriptionResponse(UniversalBaseModel): + data: typing.List[CompanySubscriptionResponseData] = pydantic.Field() """ The returned resources """ - params: GetActiveCompanySubscriptionParams = pydantic_v1.Field() + params: GetActiveCompanySubscriptionParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/get_active_deals_params.py b/src/schematic/companies/types/get_active_deals_params.py index c94367b..50db620 100644 --- a/src/schematic/companies/types/get_active_deals_params.py +++ b/src/schematic/companies/types/get_active_deals_params.py @@ -1,43 +1,33 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class GetActiveDealsParams(pydantic_v1.BaseModel): +class GetActiveDealsParams(UniversalBaseModel): """ Input parameters """ company_id: typing.Optional[str] = None deal_stage: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/get_active_deals_response.py b/src/schematic/companies/types/get_active_deals_response.py index f9bd1e2..a0062bf 100644 --- a/src/schematic/companies/types/get_active_deals_response.py +++ b/src/schematic/companies/types/get_active_deals_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.company_crm_deals_response_data import CompanyCrmDealsResponseData +import pydantic from .get_active_deals_params import GetActiveDealsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetActiveDealsResponse(pydantic_v1.BaseModel): - data: typing.List[CompanyCrmDealsResponseData] = pydantic_v1.Field() +class GetActiveDealsResponse(UniversalBaseModel): + data: typing.List[CompanyCrmDealsResponseData] = pydantic.Field() """ The returned resources """ - params: GetActiveDealsParams = pydantic_v1.Field() + params: GetActiveDealsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/get_company_response.py b/src/schematic/companies/types/get_company_response.py index 10d62fa..4e6104a 100644 --- a/src/schematic/companies/types/get_company_response.py +++ b/src/schematic/companies/types/get_company_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.company_detail_response_data import CompanyDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetCompanyResponse(pydantic_v1.BaseModel): +class GetCompanyResponse(UniversalBaseModel): data: CompanyDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/get_entity_trait_definition_response.py b/src/schematic/companies/types/get_entity_trait_definition_response.py index 1f7d6d3..057f58b 100644 --- a/src/schematic/companies/types/get_entity_trait_definition_response.py +++ b/src/schematic/companies/types/get_entity_trait_definition_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.entity_trait_definition_response_data import EntityTraitDefinitionResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetEntityTraitDefinitionResponse(pydantic_v1.BaseModel): +class GetEntityTraitDefinitionResponse(UniversalBaseModel): data: EntityTraitDefinitionResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/get_entity_trait_values_params.py b/src/schematic/companies/types/get_entity_trait_values_params.py index 2e86683..db1de7d 100644 --- a/src/schematic/companies/types/get_entity_trait_values_params.py +++ b/src/schematic/companies/types/get_entity_trait_values_params.py @@ -1,44 +1,34 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class GetEntityTraitValuesParams(pydantic_v1.BaseModel): +class GetEntityTraitValuesParams(UniversalBaseModel): """ Input parameters """ definition_id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/get_entity_trait_values_response.py b/src/schematic/companies/types/get_entity_trait_values_response.py index 7673b73..72ce45d 100644 --- a/src/schematic/companies/types/get_entity_trait_values_response.py +++ b/src/schematic/companies/types/get_entity_trait_values_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.entity_trait_value import EntityTraitValue +import pydantic from .get_entity_trait_values_params import GetEntityTraitValuesParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetEntityTraitValuesResponse(pydantic_v1.BaseModel): - data: typing.List[EntityTraitValue] = pydantic_v1.Field() +class GetEntityTraitValuesResponse(UniversalBaseModel): + data: typing.List[EntityTraitValue] = pydantic.Field() """ The returned resources """ - params: GetEntityTraitValuesParams = pydantic_v1.Field() + params: GetEntityTraitValuesParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/get_or_create_company_membership_response.py b/src/schematic/companies/types/get_or_create_company_membership_response.py index 11ec13d..996b037 100644 --- a/src/schematic/companies/types/get_or_create_company_membership_response.py +++ b/src/schematic/companies/types/get_or_create_company_membership_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.company_membership_detail_response_data import CompanyMembershipDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetOrCreateCompanyMembershipResponse(pydantic_v1.BaseModel): +class GetOrCreateCompanyMembershipResponse(UniversalBaseModel): data: CompanyMembershipDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/get_or_create_entity_trait_definition_response.py b/src/schematic/companies/types/get_or_create_entity_trait_definition_response.py index fcb124c..f7d0744 100644 --- a/src/schematic/companies/types/get_or_create_entity_trait_definition_response.py +++ b/src/schematic/companies/types/get_or_create_entity_trait_definition_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.entity_trait_definition_response_data import EntityTraitDefinitionResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetOrCreateEntityTraitDefinitionResponse(pydantic_v1.BaseModel): +class GetOrCreateEntityTraitDefinitionResponse(UniversalBaseModel): data: EntityTraitDefinitionResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/get_user_response.py b/src/schematic/companies/types/get_user_response.py index e87d8f8..c4d7564 100644 --- a/src/schematic/companies/types/get_user_response.py +++ b/src/schematic/companies/types/get_user_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.user_detail_response_data import UserDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetUserResponse(pydantic_v1.BaseModel): +class GetUserResponse(UniversalBaseModel): data: UserDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/list_companies_params.py b/src/schematic/companies/types/list_companies_params.py index 7f1dfa6..0594906 100644 --- a/src/schematic/companies/types/list_companies_params.py +++ b/src/schematic/companies/types/list_companies_params.py @@ -1,53 +1,48 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListCompaniesParams(pydantic_v1.BaseModel): +class ListCompaniesParams(UniversalBaseModel): """ Input parameters """ ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ plan_id: typing.Optional[str] = None - q: typing.Optional[str] = pydantic_v1.Field(default=None) + q: typing.Optional[str] = pydantic.Field(default=None) """ Search filter """ - without_feature_override_for: typing.Optional[str] = pydantic_v1.Field(default=None) + without_feature_override_for: typing.Optional[str] = pydantic.Field(default=None) """ Filter out companies that already have a company override for the specified feature ID """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + without_plan: typing.Optional[bool] = pydantic.Field(default=None) + """ + Filter out companies that have a plan + """ - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/list_companies_response.py b/src/schematic/companies/types/list_companies_response.py index 19cbe1e..a53d769 100644 --- a/src/schematic/companies/types/list_companies_response.py +++ b/src/schematic/companies/types/list_companies_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.company_detail_response_data import CompanyDetailResponseData +import pydantic from .list_companies_params import ListCompaniesParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListCompaniesResponse(pydantic_v1.BaseModel): - data: typing.List[CompanyDetailResponseData] = pydantic_v1.Field() +class ListCompaniesResponse(UniversalBaseModel): + data: typing.List[CompanyDetailResponseData] = pydantic.Field() """ The returned resources """ - params: ListCompaniesParams = pydantic_v1.Field() + params: ListCompaniesParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/list_company_memberships_params.py b/src/schematic/companies/types/list_company_memberships_params.py index 0d371c0..5048584 100644 --- a/src/schematic/companies/types/list_company_memberships_params.py +++ b/src/schematic/companies/types/list_company_memberships_params.py @@ -1,44 +1,34 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListCompanyMembershipsParams(pydantic_v1.BaseModel): +class ListCompanyMembershipsParams(UniversalBaseModel): """ Input parameters """ company_id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ user_id: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/list_company_memberships_response.py b/src/schematic/companies/types/list_company_memberships_response.py index 3053403..b0f2ea1 100644 --- a/src/schematic/companies/types/list_company_memberships_response.py +++ b/src/schematic/companies/types/list_company_memberships_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.company_membership_detail_response_data import CompanyMembershipDetailResponseData +import pydantic from .list_company_memberships_params import ListCompanyMembershipsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListCompanyMembershipsResponse(pydantic_v1.BaseModel): - data: typing.List[CompanyMembershipDetailResponseData] = pydantic_v1.Field() +class ListCompanyMembershipsResponse(UniversalBaseModel): + data: typing.List[CompanyMembershipDetailResponseData] = pydantic.Field() """ The returned resources """ - params: ListCompanyMembershipsParams = pydantic_v1.Field() + params: ListCompanyMembershipsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/list_company_plans_params.py b/src/schematic/companies/types/list_company_plans_params.py deleted file mode 100644 index 57f5f6e..0000000 --- a/src/schematic/companies/types/list_company_plans_params.py +++ /dev/null @@ -1,44 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - - -class ListCompanyPlansParams(pydantic_v1.BaseModel): - """ - Input parameters - """ - - company_id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) - """ - Page limit (default 100) - """ - - offset: typing.Optional[int] = pydantic_v1.Field(default=None) - """ - Page offset (default 0) - """ - - plan_id: typing.Optional[str] = None - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/companies/types/list_company_plans_response.py b/src/schematic/companies/types/list_company_plans_response.py deleted file mode 100644 index fdba27c..0000000 --- a/src/schematic/companies/types/list_company_plans_response.py +++ /dev/null @@ -1,39 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from ...types.company_plan_response_data import CompanyPlanResponseData -from .list_company_plans_params import ListCompanyPlansParams - - -class ListCompanyPlansResponse(pydantic_v1.BaseModel): - data: typing.List[CompanyPlanResponseData] = pydantic_v1.Field() - """ - The returned resources - """ - - params: ListCompanyPlansParams = pydantic_v1.Field() - """ - Input parameters - """ - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/companies/types/list_entity_key_definitions_params.py b/src/schematic/companies/types/list_entity_key_definitions_params.py index 1fa75ab..a5873f6 100644 --- a/src/schematic/companies/types/list_entity_key_definitions_params.py +++ b/src/schematic/companies/types/list_entity_key_definitions_params.py @@ -1,45 +1,36 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .list_entity_key_definitions_response_params_entity_type import ListEntityKeyDefinitionsResponseParamsEntityType +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListEntityKeyDefinitionsParams(pydantic_v1.BaseModel): +class ListEntityKeyDefinitionsParams(UniversalBaseModel): """ Input parameters """ entity_type: typing.Optional[ListEntityKeyDefinitionsResponseParamsEntityType] = None ids: typing.Optional[typing.List[str]] = None - key: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + q: typing.Optional[str] = None - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/list_entity_key_definitions_response.py b/src/schematic/companies/types/list_entity_key_definitions_response.py index c3e2a5f..856648f 100644 --- a/src/schematic/companies/types/list_entity_key_definitions_response.py +++ b/src/schematic/companies/types/list_entity_key_definitions_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.entity_key_definition_response_data import EntityKeyDefinitionResponseData +import pydantic from .list_entity_key_definitions_params import ListEntityKeyDefinitionsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListEntityKeyDefinitionsResponse(pydantic_v1.BaseModel): - data: typing.List[EntityKeyDefinitionResponseData] = pydantic_v1.Field() +class ListEntityKeyDefinitionsResponse(UniversalBaseModel): + data: typing.List[EntityKeyDefinitionResponseData] = pydantic.Field() """ The returned resources """ - params: ListEntityKeyDefinitionsParams = pydantic_v1.Field() + params: ListEntityKeyDefinitionsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/list_entity_trait_definitions_params.py b/src/schematic/companies/types/list_entity_trait_definitions_params.py index 899596a..0e79fc7 100644 --- a/src/schematic/companies/types/list_entity_trait_definitions_params.py +++ b/src/schematic/companies/types/list_entity_trait_definitions_params.py @@ -1,29 +1,28 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .list_entity_trait_definitions_response_params_entity_type import ( ListEntityTraitDefinitionsResponseParamsEntityType, ) +import pydantic from .list_entity_trait_definitions_response_params_trait_type import ListEntityTraitDefinitionsResponseParamsTraitType +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListEntityTraitDefinitionsParams(pydantic_v1.BaseModel): +class ListEntityTraitDefinitionsParams(UniversalBaseModel): """ Input parameters """ entity_type: typing.Optional[ListEntityTraitDefinitionsResponseParamsEntityType] = None ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ @@ -31,20 +30,11 @@ class ListEntityTraitDefinitionsParams(pydantic_v1.BaseModel): q: typing.Optional[str] = None trait_type: typing.Optional[ListEntityTraitDefinitionsResponseParamsTraitType] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/list_entity_trait_definitions_response.py b/src/schematic/companies/types/list_entity_trait_definitions_response.py index 5cd035b..09c2a99 100644 --- a/src/schematic/companies/types/list_entity_trait_definitions_response.py +++ b/src/schematic/companies/types/list_entity_trait_definitions_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.entity_trait_definition_response_data import EntityTraitDefinitionResponseData +import pydantic from .list_entity_trait_definitions_params import ListEntityTraitDefinitionsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListEntityTraitDefinitionsResponse(pydantic_v1.BaseModel): - data: typing.List[EntityTraitDefinitionResponseData] = pydantic_v1.Field() +class ListEntityTraitDefinitionsResponse(UniversalBaseModel): + data: typing.List[EntityTraitDefinitionResponseData] = pydantic.Field() """ The returned resources """ - params: ListEntityTraitDefinitionsParams = pydantic_v1.Field() + params: ListEntityTraitDefinitionsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/list_users_params.py b/src/schematic/companies/types/list_users_params.py index ec22e6b..7e2bcae 100644 --- a/src/schematic/companies/types/list_users_params.py +++ b/src/schematic/companies/types/list_users_params.py @@ -1,49 +1,39 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListUsersParams(pydantic_v1.BaseModel): +class ListUsersParams(UniversalBaseModel): """ Input parameters """ company_id: typing.Optional[str] = None ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ plan_id: typing.Optional[str] = None - q: typing.Optional[str] = pydantic_v1.Field(default=None) + q: typing.Optional[str] = pydantic.Field(default=None) """ Search filter """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/list_users_response.py b/src/schematic/companies/types/list_users_response.py index 8d8e720..bec2c86 100644 --- a/src/schematic/companies/types/list_users_response.py +++ b/src/schematic/companies/types/list_users_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.user_detail_response_data import UserDetailResponseData +import pydantic from .list_users_params import ListUsersParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListUsersResponse(pydantic_v1.BaseModel): - data: typing.List[UserDetailResponseData] = pydantic_v1.Field() +class ListUsersResponse(UniversalBaseModel): + data: typing.List[UserDetailResponseData] = pydantic.Field() """ The returned resources """ - params: ListUsersParams = pydantic_v1.Field() + params: ListUsersParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/lookup_company_params.py b/src/schematic/companies/types/lookup_company_params.py index 227ed12..ec4cf8d 100644 --- a/src/schematic/companies/types/lookup_company_params.py +++ b/src/schematic/companies/types/lookup_company_params.py @@ -1,33 +1,23 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class LookupCompanyParams(pydantic_v1.BaseModel): +class LookupCompanyParams(UniversalBaseModel): """ Input parameters """ - keys: typing.Optional[typing.Dict[str, typing.Any]] = None - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + keys: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/lookup_company_response.py b/src/schematic/companies/types/lookup_company_response.py index 897d7c5..ab1783d 100644 --- a/src/schematic/companies/types/lookup_company_response.py +++ b/src/schematic/companies/types/lookup_company_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.company_detail_response_data import CompanyDetailResponseData from .lookup_company_params import LookupCompanyParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class LookupCompanyResponse(pydantic_v1.BaseModel): +class LookupCompanyResponse(UniversalBaseModel): data: CompanyDetailResponseData - params: LookupCompanyParams = pydantic_v1.Field() + params: LookupCompanyParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/lookup_user_params.py b/src/schematic/companies/types/lookup_user_params.py index 070a56f..c3ec7aa 100644 --- a/src/schematic/companies/types/lookup_user_params.py +++ b/src/schematic/companies/types/lookup_user_params.py @@ -1,33 +1,23 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class LookupUserParams(pydantic_v1.BaseModel): +class LookupUserParams(UniversalBaseModel): """ Input parameters """ - keys: typing.Optional[typing.Dict[str, typing.Any]] = None - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + keys: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/lookup_user_response.py b/src/schematic/companies/types/lookup_user_response.py index 10c0e42..d7a075f 100644 --- a/src/schematic/companies/types/lookup_user_response.py +++ b/src/schematic/companies/types/lookup_user_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.user_detail_response_data import UserDetailResponseData from .lookup_user_params import LookupUserParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class LookupUserResponse(pydantic_v1.BaseModel): +class LookupUserResponse(UniversalBaseModel): data: UserDetailResponseData - params: LookupUserParams = pydantic_v1.Field() + params: LookupUserParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/update_entity_trait_definition_response.py b/src/schematic/companies/types/update_entity_trait_definition_response.py index 064019c..4493b05 100644 --- a/src/schematic/companies/types/update_entity_trait_definition_response.py +++ b/src/schematic/companies/types/update_entity_trait_definition_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.entity_trait_definition_response_data import EntityTraitDefinitionResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpdateEntityTraitDefinitionResponse(pydantic_v1.BaseModel): +class UpdateEntityTraitDefinitionResponse(UniversalBaseModel): data: EntityTraitDefinitionResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/upsert_company_response.py b/src/schematic/companies/types/upsert_company_response.py index 10258c7..a0c8d69 100644 --- a/src/schematic/companies/types/upsert_company_response.py +++ b/src/schematic/companies/types/upsert_company_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.company_detail_response_data import CompanyDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpsertCompanyResponse(pydantic_v1.BaseModel): +class UpsertCompanyResponse(UniversalBaseModel): data: CompanyDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/upsert_company_trait_response.py b/src/schematic/companies/types/upsert_company_trait_response.py index 466227b..66fcd25 100644 --- a/src/schematic/companies/types/upsert_company_trait_response.py +++ b/src/schematic/companies/types/upsert_company_trait_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.company_detail_response_data import CompanyDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpsertCompanyTraitResponse(pydantic_v1.BaseModel): +class UpsertCompanyTraitResponse(UniversalBaseModel): data: CompanyDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/upsert_user_response.py b/src/schematic/companies/types/upsert_user_response.py index be019a9..52b72b0 100644 --- a/src/schematic/companies/types/upsert_user_response.py +++ b/src/schematic/companies/types/upsert_user_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.user_detail_response_data import UserDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpsertUserResponse(pydantic_v1.BaseModel): +class UpsertUserResponse(UniversalBaseModel): data: UserDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/companies/types/upsert_user_trait_response.py b/src/schematic/companies/types/upsert_user_trait_response.py index 9b04564..097d1ea 100644 --- a/src/schematic/companies/types/upsert_user_trait_response.py +++ b/src/schematic/companies/types/upsert_user_trait_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.user_detail_response_data import UserDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpsertUserTraitResponse(pydantic_v1.BaseModel): +class UpsertUserTraitResponse(UniversalBaseModel): data: UserDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/components/__init__.py b/src/schematic/components/__init__.py new file mode 100644 index 0000000..b52adff --- /dev/null +++ b/src/schematic/components/__init__.py @@ -0,0 +1,33 @@ +# This file was auto-generated by Fern from our API Definition. + +from .types import ( + CountComponentsParams, + CountComponentsResponse, + CreateComponentRequestBodyEntityType, + CreateComponentResponse, + DeleteComponentResponse, + GetComponentResponse, + ListComponentsParams, + ListComponentsResponse, + PreviewComponentDataParams, + PreviewComponentDataResponse, + UpdateComponentRequestBodyEntityType, + UpdateComponentRequestBodyState, + UpdateComponentResponse, +) + +__all__ = [ + "CountComponentsParams", + "CountComponentsResponse", + "CreateComponentRequestBodyEntityType", + "CreateComponentResponse", + "DeleteComponentResponse", + "GetComponentResponse", + "ListComponentsParams", + "ListComponentsResponse", + "PreviewComponentDataParams", + "PreviewComponentDataResponse", + "UpdateComponentRequestBodyEntityType", + "UpdateComponentRequestBodyState", + "UpdateComponentResponse", +] diff --git a/src/schematic/components/client.py b/src/schematic/components/client.py new file mode 100644 index 0000000..b4ca6cf --- /dev/null +++ b/src/schematic/components/client.py @@ -0,0 +1,1473 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from ..core.client_wrapper import SyncClientWrapper +from ..core.request_options import RequestOptions +from .types.list_components_response import ListComponentsResponse +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 ..errors.forbidden_error import ForbiddenError +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.create_component_request_body_entity_type import CreateComponentRequestBodyEntityType +from .types.create_component_response import CreateComponentResponse +from .types.get_component_response import GetComponentResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..errors.not_found_error import NotFoundError +from .types.update_component_request_body_entity_type import UpdateComponentRequestBodyEntityType +from .types.update_component_request_body_state import UpdateComponentRequestBodyState +from .types.update_component_response import UpdateComponentResponse +from .types.delete_component_response import DeleteComponentResponse +from .types.count_components_response import CountComponentsResponse +from .types.preview_component_data_response import PreviewComponentDataResponse +from ..core.client_wrapper import AsyncClientWrapper + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class ComponentsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list_components( + self, + *, + q: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ListComponentsResponse: + """ + Parameters + ---------- + q : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ListComponentsResponse + OK + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.components.list_components() + """ + _response = self._client_wrapper.httpx_client.request( + "components", + method="GET", + params={ + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListComponentsResponse, + parse_obj_as( + type_=ListComponentsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def create_component( + self, + *, + entity_type: CreateComponentRequestBodyEntityType, + name: str, + ast: typing.Optional[typing.Dict[str, float]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreateComponentResponse: + """ + Parameters + ---------- + entity_type : CreateComponentRequestBodyEntityType + + name : str + + ast : typing.Optional[typing.Dict[str, float]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreateComponentResponse + Created + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.components.create_component( + entity_type="entitlement", + name="name", + ) + """ + _response = self._client_wrapper.httpx_client.request( + "components", + method="POST", + json={ + "ast": ast, + "entity_type": entity_type, + "name": name, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateComponentResponse, + parse_obj_as( + type_=CreateComponentResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def get_component( + self, component_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetComponentResponse: + """ + Parameters + ---------- + component_id : str + component_id + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetComponentResponse + OK + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.components.get_component( + component_id="component_id", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"components/{jsonable_encoder(component_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetComponentResponse, + parse_obj_as( + type_=GetComponentResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def update_component( + self, + component_id: str, + *, + ast: typing.Optional[typing.Dict[str, float]] = OMIT, + entity_type: typing.Optional[UpdateComponentRequestBodyEntityType] = OMIT, + name: typing.Optional[str] = OMIT, + state: typing.Optional[UpdateComponentRequestBodyState] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpdateComponentResponse: + """ + Parameters + ---------- + component_id : str + component_id + + ast : typing.Optional[typing.Dict[str, float]] + + entity_type : typing.Optional[UpdateComponentRequestBodyEntityType] + + name : typing.Optional[str] + + state : typing.Optional[UpdateComponentRequestBodyState] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpdateComponentResponse + OK + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.components.update_component( + component_id="component_id", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"components/{jsonable_encoder(component_id)}", + method="PUT", + json={ + "ast": ast, + "entity_type": entity_type, + "name": name, + "state": state, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateComponentResponse, + parse_obj_as( + type_=UpdateComponentResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def delete_component( + self, component_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> DeleteComponentResponse: + """ + Parameters + ---------- + component_id : str + component_id + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DeleteComponentResponse + OK + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.components.delete_component( + component_id="component_id", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"components/{jsonable_encoder(component_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteComponentResponse, + parse_obj_as( + type_=DeleteComponentResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def count_components( + self, + *, + q: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> CountComponentsResponse: + """ + Parameters + ---------- + q : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CountComponentsResponse + OK + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.components.count_components() + """ + _response = self._client_wrapper.httpx_client.request( + "components/count", + method="GET", + params={ + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountComponentsResponse, + parse_obj_as( + type_=CountComponentsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def preview_component_data( + self, + *, + company_id: typing.Optional[str] = None, + component_id: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> PreviewComponentDataResponse: + """ + Parameters + ---------- + company_id : typing.Optional[str] + + component_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PreviewComponentDataResponse + OK + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.components.preview_component_data() + """ + _response = self._client_wrapper.httpx_client.request( + "components/preview-data", + method="GET", + params={ + "company_id": company_id, + "component_id": component_id, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + PreviewComponentDataResponse, + parse_obj_as( + type_=PreviewComponentDataResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + +class AsyncComponentsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list_components( + self, + *, + q: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ListComponentsResponse: + """ + Parameters + ---------- + q : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ListComponentsResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.components.list_components() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "components", + method="GET", + params={ + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListComponentsResponse, + parse_obj_as( + type_=ListComponentsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def create_component( + self, + *, + entity_type: CreateComponentRequestBodyEntityType, + name: str, + ast: typing.Optional[typing.Dict[str, float]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreateComponentResponse: + """ + Parameters + ---------- + entity_type : CreateComponentRequestBodyEntityType + + name : str + + ast : typing.Optional[typing.Dict[str, float]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreateComponentResponse + Created + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.components.create_component( + entity_type="entitlement", + name="name", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "components", + method="POST", + json={ + "ast": ast, + "entity_type": entity_type, + "name": name, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateComponentResponse, + parse_obj_as( + type_=CreateComponentResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def get_component( + self, component_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetComponentResponse: + """ + Parameters + ---------- + component_id : str + component_id + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetComponentResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.components.get_component( + component_id="component_id", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"components/{jsonable_encoder(component_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetComponentResponse, + parse_obj_as( + type_=GetComponentResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def update_component( + self, + component_id: str, + *, + ast: typing.Optional[typing.Dict[str, float]] = OMIT, + entity_type: typing.Optional[UpdateComponentRequestBodyEntityType] = OMIT, + name: typing.Optional[str] = OMIT, + state: typing.Optional[UpdateComponentRequestBodyState] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpdateComponentResponse: + """ + Parameters + ---------- + component_id : str + component_id + + ast : typing.Optional[typing.Dict[str, float]] + + entity_type : typing.Optional[UpdateComponentRequestBodyEntityType] + + name : typing.Optional[str] + + state : typing.Optional[UpdateComponentRequestBodyState] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpdateComponentResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.components.update_component( + component_id="component_id", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"components/{jsonable_encoder(component_id)}", + method="PUT", + json={ + "ast": ast, + "entity_type": entity_type, + "name": name, + "state": state, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateComponentResponse, + parse_obj_as( + type_=UpdateComponentResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def delete_component( + self, component_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> DeleteComponentResponse: + """ + Parameters + ---------- + component_id : str + component_id + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DeleteComponentResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.components.delete_component( + component_id="component_id", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"components/{jsonable_encoder(component_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteComponentResponse, + parse_obj_as( + type_=DeleteComponentResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def count_components( + self, + *, + q: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> CountComponentsResponse: + """ + Parameters + ---------- + q : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CountComponentsResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.components.count_components() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "components/count", + method="GET", + params={ + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountComponentsResponse, + parse_obj_as( + type_=CountComponentsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def preview_component_data( + self, + *, + company_id: typing.Optional[str] = None, + component_id: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> PreviewComponentDataResponse: + """ + Parameters + ---------- + company_id : typing.Optional[str] + + component_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PreviewComponentDataResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.components.preview_component_data() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "components/preview-data", + method="GET", + params={ + "company_id": company_id, + "component_id": component_id, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + PreviewComponentDataResponse, + parse_obj_as( + type_=PreviewComponentDataResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) diff --git a/src/schematic/components/types/__init__.py b/src/schematic/components/types/__init__.py new file mode 100644 index 0000000..abc3487 --- /dev/null +++ b/src/schematic/components/types/__init__.py @@ -0,0 +1,31 @@ +# This file was auto-generated by Fern from our API Definition. + +from .count_components_params import CountComponentsParams +from .count_components_response import CountComponentsResponse +from .create_component_request_body_entity_type import CreateComponentRequestBodyEntityType +from .create_component_response import CreateComponentResponse +from .delete_component_response import DeleteComponentResponse +from .get_component_response import GetComponentResponse +from .list_components_params import ListComponentsParams +from .list_components_response import ListComponentsResponse +from .preview_component_data_params import PreviewComponentDataParams +from .preview_component_data_response import PreviewComponentDataResponse +from .update_component_request_body_entity_type import UpdateComponentRequestBodyEntityType +from .update_component_request_body_state import UpdateComponentRequestBodyState +from .update_component_response import UpdateComponentResponse + +__all__ = [ + "CountComponentsParams", + "CountComponentsResponse", + "CreateComponentRequestBodyEntityType", + "CreateComponentResponse", + "DeleteComponentResponse", + "GetComponentResponse", + "ListComponentsParams", + "ListComponentsResponse", + "PreviewComponentDataParams", + "PreviewComponentDataResponse", + "UpdateComponentRequestBodyEntityType", + "UpdateComponentRequestBodyState", + "UpdateComponentResponse", +] diff --git a/src/schematic/components/types/count_components_params.py b/src/schematic/components/types/count_components_params.py new file mode 100644 index 0000000..1de5be8 --- /dev/null +++ b/src/schematic/components/types/count_components_params.py @@ -0,0 +1,33 @@ +# 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 + + +class CountComponentsParams(UniversalBaseModel): + """ + Input parameters + """ + + limit: typing.Optional[int] = pydantic.Field(default=None) + """ + Page limit (default 100) + """ + + offset: typing.Optional[int] = pydantic.Field(default=None) + """ + Page offset (default 0) + """ + + q: 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/schematic/components/types/count_components_response.py b/src/schematic/components/types/count_components_response.py new file mode 100644 index 0000000..916d335 --- /dev/null +++ b/src/schematic/components/types/count_components_response.py @@ -0,0 +1,25 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.count_response import CountResponse +from .count_components_params import CountComponentsParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing + + +class CountComponentsResponse(UniversalBaseModel): + data: CountResponse + params: CountComponentsParams = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/components/types/create_component_request_body_entity_type.py b/src/schematic/components/types/create_component_request_body_entity_type.py new file mode 100644 index 0000000..2560517 --- /dev/null +++ b/src/schematic/components/types/create_component_request_body_entity_type.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +CreateComponentRequestBodyEntityType = typing.Union[typing.Literal["entitlement", "billing"], typing.Any] diff --git a/src/schematic/components/types/create_component_response.py b/src/schematic/components/types/create_component_response.py new file mode 100644 index 0000000..02e544d --- /dev/null +++ b/src/schematic/components/types/create_component_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.component_response_data import ComponentResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class CreateComponentResponse(UniversalBaseModel): + data: ComponentResponseData + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/components/types/delete_component_response.py b/src/schematic/components/types/delete_component_response.py new file mode 100644 index 0000000..27179e1 --- /dev/null +++ b/src/schematic/components/types/delete_component_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.delete_response import DeleteResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class DeleteComponentResponse(UniversalBaseModel): + data: DeleteResponse + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/components/types/get_component_response.py b/src/schematic/components/types/get_component_response.py new file mode 100644 index 0000000..0f6da27 --- /dev/null +++ b/src/schematic/components/types/get_component_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.component_response_data import ComponentResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class GetComponentResponse(UniversalBaseModel): + data: ComponentResponseData + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/components/types/list_components_params.py b/src/schematic/components/types/list_components_params.py new file mode 100644 index 0000000..de0dbd9 --- /dev/null +++ b/src/schematic/components/types/list_components_params.py @@ -0,0 +1,33 @@ +# 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 + + +class ListComponentsParams(UniversalBaseModel): + """ + Input parameters + """ + + limit: typing.Optional[int] = pydantic.Field(default=None) + """ + Page limit (default 100) + """ + + offset: typing.Optional[int] = pydantic.Field(default=None) + """ + Page offset (default 0) + """ + + q: 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/schematic/components/types/list_components_response.py b/src/schematic/components/types/list_components_response.py new file mode 100644 index 0000000..5064b15 --- /dev/null +++ b/src/schematic/components/types/list_components_response.py @@ -0,0 +1,29 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +import typing +from ...types.component_response_data import ComponentResponseData +import pydantic +from .list_components_params import ListComponentsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class ListComponentsResponse(UniversalBaseModel): + data: typing.List[ComponentResponseData] = pydantic.Field() + """ + The returned resources + """ + + params: ListComponentsParams = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/components/types/preview_component_data_params.py b/src/schematic/components/types/preview_component_data_params.py new file mode 100644 index 0000000..b09c25b --- /dev/null +++ b/src/schematic/components/types/preview_component_data_params.py @@ -0,0 +1,24 @@ +# 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 + + +class PreviewComponentDataParams(UniversalBaseModel): + """ + Input parameters + """ + + company_id: typing.Optional[str] = None + component_id: 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/schematic/components/types/preview_component_data_response.py b/src/schematic/components/types/preview_component_data_response.py new file mode 100644 index 0000000..f43dbec --- /dev/null +++ b/src/schematic/components/types/preview_component_data_response.py @@ -0,0 +1,25 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.component_hydrate_response_data import ComponentHydrateResponseData +from .preview_component_data_params import PreviewComponentDataParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing + + +class PreviewComponentDataResponse(UniversalBaseModel): + data: ComponentHydrateResponseData + params: PreviewComponentDataParams = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/components/types/update_component_request_body_entity_type.py b/src/schematic/components/types/update_component_request_body_entity_type.py new file mode 100644 index 0000000..04e683a --- /dev/null +++ b/src/schematic/components/types/update_component_request_body_entity_type.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +UpdateComponentRequestBodyEntityType = typing.Union[typing.Literal["entitlement", "billing"], typing.Any] diff --git a/src/schematic/components/types/update_component_request_body_state.py b/src/schematic/components/types/update_component_request_body_state.py new file mode 100644 index 0000000..9691fca --- /dev/null +++ b/src/schematic/components/types/update_component_request_body_state.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +UpdateComponentRequestBodyState = typing.Union[typing.Literal["draft", "live"], typing.Any] diff --git a/src/schematic/components/types/update_component_response.py b/src/schematic/components/types/update_component_response.py new file mode 100644 index 0000000..0af1225 --- /dev/null +++ b/src/schematic/components/types/update_component_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.component_response_data import ComponentResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class UpdateComponentResponse(UniversalBaseModel): + data: ComponentResponseData + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/core/__init__.py b/src/schematic/core/__init__.py index 58ad52a..f03aecb 100644 --- a/src/schematic/core/__init__.py +++ b/src/schematic/core/__init__.py @@ -3,28 +3,45 @@ 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 +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 deep_union_pydantic_dicts, pydantic_v1 +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 __all__ = [ "ApiError", "AsyncClientWrapper", "AsyncHttpClient", "BaseClientWrapper", + "FieldMetadata", "File", "HttpClient", + "IS_PYDANTIC_V2", "RequestOptions", "SyncClientWrapper", + "UniversalBaseModel", + "UniversalRootModel", + "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", - "pydantic_v1", + "parse_obj_as", "remove_none_from_dict", "serialize_datetime", + "universal_field_validator", + "universal_root_validator", + "update_forward_refs", + "with_content_type", ] diff --git a/src/schematic/core/client_wrapper.py b/src/schematic/core/client_wrapper.py index 45f0483..773c60b 100644 --- a/src/schematic/core/client_wrapper.py +++ b/src/schematic/core/client_wrapper.py @@ -1,10 +1,9 @@ # This file was auto-generated by Fern from our API Definition. import typing - import httpx - -from .http_client import AsyncHttpClient, HttpClient +from .http_client import HttpClient +from .http_client import AsyncHttpClient class BaseClientWrapper: @@ -17,7 +16,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "schematichq", - "X-Fern-SDK-Version": "1.0.4", + "X-Fern-SDK-Version": "1.0.5", } headers["X-Schematic-Api-Key"] = self.api_key return headers @@ -34,7 +33,12 @@ def __init__( self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.Client ): super().__init__(api_key=api_key, base_url=base_url, timeout=timeout) - self.httpx_client = HttpClient(httpx_client=httpx_client) + self.httpx_client = HttpClient( + httpx_client=httpx_client, + base_headers=self.get_headers, + base_timeout=self.get_timeout, + base_url=self.get_base_url, + ) class AsyncClientWrapper(BaseClientWrapper): @@ -42,4 +46,9 @@ def __init__( self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.AsyncClient ): super().__init__(api_key=api_key, base_url=base_url, timeout=timeout) - self.httpx_client = AsyncHttpClient(httpx_client=httpx_client) + self.httpx_client = AsyncHttpClient( + httpx_client=httpx_client, + base_headers=self.get_headers, + base_timeout=self.get_timeout, + base_url=self.get_base_url, + ) diff --git a/src/schematic/core/file.py b/src/schematic/core/file.py index cb0d40b..b4cbba3 100644 --- a/src/schematic/core/file.py +++ b/src/schematic/core/file.py @@ -1,25 +1,30 @@ # This file was auto-generated by Fern from our API Definition. -import typing +from typing import IO, Dict, List, Mapping, Optional, Tuple, Union, cast # File typing inspired by the flexibility of types within the httpx library # https://github.com/encode/httpx/blob/master/httpx/_types.py -FileContent = typing.Union[typing.IO[bytes], bytes, str] -File = typing.Union[ +FileContent = Union[IO[bytes], bytes, str] +File = Union[ # file (or bytes) FileContent, # (filename, file (or bytes)) - typing.Tuple[typing.Optional[str], FileContent], + Tuple[Optional[str], FileContent], # (filename, file (or bytes), content_type) - typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str]], + Tuple[Optional[str], FileContent, Optional[str]], # (filename, file (or bytes), content_type, headers) - typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str], typing.Mapping[str, str]], + Tuple[ + Optional[str], + FileContent, + Optional[str], + Mapping[str, str], + ], ] def convert_file_dict_to_httpx_tuples( - d: typing.Dict[str, typing.Union[File, typing.List[File]]] -) -> typing.List[typing.Tuple[str, File]]: + d: Dict[str, Union[File, List[File]]], +) -> List[Tuple[str, File]]: """ The format we use is a list of tuples, where the first element is the name of the file and the second is the file object. Typically HTTPX wants @@ -36,3 +41,22 @@ def convert_file_dict_to_httpx_tuples( else: httpx_tuples.append((key, file_like)) return httpx_tuples + + +def with_content_type(*, file: File, content_type: str) -> File: + """ """ + if isinstance(file, tuple): + if len(file) == 2: + filename, content = cast(Tuple[Optional[str], FileContent], file) # type: ignore + return (filename, content, content_type) + elif len(file) == 3: + filename, content, _ = cast(Tuple[Optional[str], FileContent, Optional[str]], file) # type: ignore + return (filename, content, content_type) + elif len(file) == 4: + filename, content, _, headers = cast( # type: ignore + Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]], file + ) + return (filename, content, content_type, headers) + else: + raise ValueError(f"Unexpected tuple length: {len(file)}") + return (None, file, content_type) diff --git a/src/schematic/core/http_client.py b/src/schematic/core/http_client.py index 4e6877d..eb4e894 100644 --- a/src/schematic/core/http_client.py +++ b/src/schematic/core/http_client.py @@ -2,15 +2,22 @@ import asyncio import email.utils +import json import re import time import typing +import urllib.parse from contextlib import asynccontextmanager, contextmanager -from functools import wraps from random import random import httpx +from .file import File, convert_file_dict_to_httpx_tuples +from .jsonable_encoder import jsonable_encoder +from .query_encoder import encode_query +from .remove_none_from_dict import remove_none_from_dict +from .request_options import RequestOptions + INITIAL_RETRY_DELAY_SECONDS = 0.5 MAX_RETRY_DELAY_SECONDS = 10 MAX_RETRY_DELAY_SECONDS_FROM_HEADER = 30 @@ -82,49 +89,399 @@ def _should_retry(response: httpx.Response) -> bool: return response.status_code >= 500 or response.status_code in retriable_400s +def remove_omit_from_dict( + original: typing.Dict[str, typing.Optional[typing.Any]], + omit: typing.Optional[typing.Any], +) -> typing.Dict[str, typing.Any]: + if omit is None: + return original + new: typing.Dict[str, typing.Any] = {} + for key, value in original.items(): + if value is not omit: + new[key] = value + return new + + +def maybe_filter_request_body( + data: typing.Optional[typing.Any], + request_options: typing.Optional[RequestOptions], + omit: typing.Optional[typing.Any], +) -> typing.Optional[typing.Any]: + if data is None: + return ( + jsonable_encoder(request_options.get("additional_body_parameters", {})) or {} + if request_options is not None + else None + ) + elif not isinstance(data, typing.Mapping): + data_content = jsonable_encoder(data) + else: + data_content = { + **(jsonable_encoder(remove_omit_from_dict(data, omit))), # type: ignore + **( + jsonable_encoder(request_options.get("additional_body_parameters", {})) or {} + if request_options is not None + else {} + ), + } + return data_content + + +# Abstracted out for testing purposes +def get_request_body( + *, + json: typing.Optional[typing.Any], + data: typing.Optional[typing.Any], + request_options: typing.Optional[RequestOptions], + omit: typing.Optional[typing.Any], +) -> typing.Tuple[typing.Optional[typing.Any], typing.Optional[typing.Any]]: + json_body = None + data_body = None + if data is not None: + data_body = maybe_filter_request_body(data, request_options, omit) + else: + # 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 + + class HttpClient: - def __init__(self, *, httpx_client: httpx.Client): + def __init__( + self, + *, + httpx_client: httpx.Client, + base_timeout: typing.Callable[[], typing.Optional[float]], + base_headers: typing.Callable[[], typing.Dict[str, str]], + base_url: typing.Optional[typing.Callable[[], str]] = None, + ): + self.base_url = base_url + self.base_timeout = base_timeout + self.base_headers = base_headers self.httpx_client = httpx_client - # Ensure that the signature of the `request` method is the same as the `httpx.Client.request` method - @wraps(httpx.Client.request) + def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str: + base_url = maybe_base_url + if self.base_url is not None and base_url is None: + base_url = self.base_url() + + if base_url is None: + raise ValueError("A base_url is required to make this request, please provide one and try again.") + return base_url + def request( - self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any + self, + path: typing.Optional[str] = None, + *, + method: str, + base_url: typing.Optional[str] = None, + params: typing.Optional[typing.Dict[str, typing.Any]] = None, + 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, + headers: typing.Optional[typing.Dict[str, typing.Any]] = None, + request_options: typing.Optional[RequestOptions] = None, + retries: int = 0, + omit: typing.Optional[typing.Any] = None, ) -> httpx.Response: - response = self.httpx_client.request(*args, **kwargs) + base_url = self.get_base_url(base_url) + timeout = ( + request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self.base_timeout() + ) + + 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( + 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, + ) + ) + ) + ), + json=json_body, + data=data_body, + content=content, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) + if (files is not None and files is not omit) + else None, + timeout=timeout, + ) + + max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0 if _should_retry(response=response): if max_retries > retries: time.sleep(_retry_timeout(response=response, retries=retries)) - return self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) + return self.request( + path=path, + method=method, + base_url=base_url, + params=params, + json=json, + content=content, + files=files, + headers=headers, + request_options=request_options, + retries=retries + 1, + omit=omit, + ) + return response - @wraps(httpx.Client.stream) @contextmanager - def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - with self.httpx_client.stream(*args, **kwargs) as stream: + def stream( + self, + path: typing.Optional[str] = None, + *, + method: str, + base_url: typing.Optional[str] = None, + params: typing.Optional[typing.Dict[str, typing.Any]] = None, + 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, + headers: typing.Optional[typing.Dict[str, typing.Any]] = None, + request_options: typing.Optional[RequestOptions] = None, + retries: int = 0, + omit: typing.Optional[typing.Any] = None, + ) -> typing.Iterator[httpx.Response]: + base_url = self.get_base_url(base_url) + timeout = ( + request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self.base_timeout() + ) + + 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( + 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, + ) + ) + ) + ), + json=json_body, + data=data_body, + content=content, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) + if (files is not None and files is not omit) + else None, + timeout=timeout, + ) as stream: yield stream class AsyncHttpClient: - def __init__(self, *, httpx_client: httpx.AsyncClient): + def __init__( + self, + *, + httpx_client: httpx.AsyncClient, + base_timeout: typing.Callable[[], typing.Optional[float]], + base_headers: typing.Callable[[], typing.Dict[str, str]], + base_url: typing.Optional[typing.Callable[[], str]] = None, + ): + self.base_url = base_url + self.base_timeout = base_timeout + self.base_headers = base_headers self.httpx_client = httpx_client - # Ensure that the signature of the `request` method is the same as the `httpx.Client.request` method - @wraps(httpx.AsyncClient.request) + def get_base_url(self, maybe_base_url: typing.Optional[str]) -> str: + base_url = maybe_base_url + if self.base_url is not None and base_url is None: + base_url = self.base_url() + + if base_url is None: + raise ValueError("A base_url is required to make this request, please provide one and try again.") + return base_url + async def request( - self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any + self, + path: typing.Optional[str] = None, + *, + method: str, + base_url: typing.Optional[str] = None, + params: typing.Optional[typing.Dict[str, typing.Any]] = None, + 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, + headers: typing.Optional[typing.Dict[str, typing.Any]] = None, + request_options: typing.Optional[RequestOptions] = None, + retries: int = 0, + omit: typing.Optional[typing.Any] = None, ) -> httpx.Response: - response = await self.httpx_client.request(*args, **kwargs) + base_url = self.get_base_url(base_url) + timeout = ( + request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self.base_timeout() + ) + + 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( + 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, + ) + ) + ) + ), + json=json_body, + data=data_body, + content=content, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, + timeout=timeout, + ) + + max_retries: int = request_options.get("max_retries", 0) if request_options is not None else 0 if _should_retry(response=response): if max_retries > retries: await asyncio.sleep(_retry_timeout(response=response, retries=retries)) - return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) + return await self.request( + path=path, + method=method, + base_url=base_url, + params=params, + json=json, + content=content, + files=files, + headers=headers, + request_options=request_options, + retries=retries + 1, + omit=omit, + ) return response - @wraps(httpx.AsyncClient.stream) @asynccontextmanager async def stream( - self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any - ) -> typing.Any: - async with self.httpx_client.stream(*args, **kwargs) as stream: + self, + path: typing.Optional[str] = None, + *, + method: str, + base_url: typing.Optional[str] = None, + params: typing.Optional[typing.Dict[str, typing.Any]] = None, + 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, + headers: typing.Optional[typing.Dict[str, typing.Any]] = None, + request_options: typing.Optional[RequestOptions] = None, + retries: int = 0, + omit: typing.Optional[typing.Any] = None, + ) -> typing.AsyncIterator[httpx.Response]: + base_url = self.get_base_url(base_url) + timeout = ( + request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self.base_timeout() + ) + + 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( + 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, + ) + ) + ) + ), + json=json_body, + data=data_body, + content=content, + files=convert_file_dict_to_httpx_tuples(remove_none_from_dict(files)) if files is not None else None, + timeout=timeout, + ) as stream: yield stream diff --git a/src/schematic/core/jsonable_encoder.py b/src/schematic/core/jsonable_encoder.py index 7f48273..1b631e9 100644 --- a/src/schematic/core/jsonable_encoder.py +++ b/src/schematic/core/jsonable_encoder.py @@ -8,33 +8,27 @@ https://github.com/tiangolo/fastapi/blob/master/fastapi/encoders.py """ +import base64 import dataclasses import datetime as dt -from collections import defaultdict from enum import Enum from pathlib import PurePath from types import GeneratorType -from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union +from typing import Any, Callable, Dict, List, Optional, Set, Union + +import pydantic from .datetime_utils import serialize_datetime -from .pydantic_utilities import pydantic_v1 +from .pydantic_utilities import ( + IS_PYDANTIC_V2, + encode_by_type, + to_jsonable_with_fallback, +) SetIntStr = Set[Union[int, str]] DictIntStrAny = Dict[Union[int, str], Any] -def generate_encoders_by_class_tuples( - type_encoder_map: Dict[Any, Callable[[Any], Any]] -) -> Dict[Callable[[Any], Any], Tuple[Any, ...]]: - encoders_by_class_tuples: Dict[Callable[[Any], Any], Tuple[Any, ...]] = defaultdict(tuple) - for type_, encoder in type_encoder_map.items(): - encoders_by_class_tuples[encoder] += (type_,) - return encoders_by_class_tuples - - -encoders_by_class_tuples = generate_encoders_by_class_tuples(pydantic_v1.json.ENCODERS_BY_TYPE) - - def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any: custom_encoder = custom_encoder or {} if custom_encoder: @@ -44,17 +38,24 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any] for encoder_type, encoder_instance in custom_encoder.items(): if isinstance(obj, encoder_type): return encoder_instance(obj) - if isinstance(obj, pydantic_v1.BaseModel): - encoder = getattr(obj.__config__, "json_encoders", {}) + if isinstance(obj, pydantic.BaseModel): + if IS_PYDANTIC_V2: + encoder = getattr(obj.model_config, "json_encoders", {}) # type: ignore # Pydantic v2 + else: + encoder = getattr(obj.__config__, "json_encoders", {}) # type: ignore # Pydantic v1 if custom_encoder: encoder.update(custom_encoder) obj_dict = obj.dict(by_alias=True) if "__root__" in obj_dict: obj_dict = obj_dict["__root__"] + if "root" in obj_dict: + obj_dict = obj_dict["root"] return jsonable_encoder(obj_dict, custom_encoder=encoder) if dataclasses.is_dataclass(obj): - obj_dict = dataclasses.asdict(obj) + obj_dict = dataclasses.asdict(obj) # type: ignore return jsonable_encoder(obj_dict, custom_encoder=custom_encoder) + if isinstance(obj, bytes): + return base64.b64encode(obj).decode("utf-8") if isinstance(obj, Enum): return obj.value if isinstance(obj, PurePath): @@ -80,20 +81,21 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any] encoded_list.append(jsonable_encoder(item, custom_encoder=custom_encoder)) return encoded_list - if type(obj) in pydantic_v1.json.ENCODERS_BY_TYPE: - return pydantic_v1.json.ENCODERS_BY_TYPE[type(obj)](obj) - for encoder, classes_tuple in encoders_by_class_tuples.items(): - if isinstance(obj, classes_tuple): - return encoder(obj) + def fallback_serializer(o: Any) -> Any: + attempt_encode = encode_by_type(o) + if attempt_encode is not None: + return attempt_encode - try: - data = dict(obj) - except Exception as e: - errors: List[Exception] = [] - errors.append(e) try: - data = vars(obj) + data = dict(o) except Exception as e: + errors: List[Exception] = [] errors.append(e) - raise ValueError(errors) from e - return jsonable_encoder(data, custom_encoder=custom_encoder) + try: + data = vars(o) + except Exception as e: + errors.append(e) + raise ValueError(errors) from e + return jsonable_encoder(data, custom_encoder=custom_encoder) + + return to_jsonable_with_fallback(obj, fallback_serializer) diff --git a/src/schematic/core/pydantic_utilities.py b/src/schematic/core/pydantic_utilities.py index a72c1a5..ee8f0e4 100644 --- a/src/schematic/core/pydantic_utilities.py +++ b/src/schematic/core/pydantic_utilities.py @@ -1,28 +1,296 @@ # This file was auto-generated by Fern from our API Definition. +# nopycln: file +import datetime as dt import typing +from collections import defaultdict + +import typing_extensions import pydantic +from .datetime_utils import serialize_datetime +from .serialization import convert_and_respect_annotation_metadata + IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.") if IS_PYDANTIC_V2: - import pydantic.v1 as pydantic_v1 # type: ignore # nopycln: import + # 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, + ) + from pydantic.v1.datetime_parse import ( # pyright: ignore[reportMissingImports] # Pydantic v2 + parse_datetime as parse_datetime, + ) + from pydantic.v1.json import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 + ENCODERS_BY_TYPE as encoders_by_type, + ) + from pydantic.v1.typing import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 + get_args as get_args, + ) + from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 + get_origin as get_origin, + ) + from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 + is_literal_type as is_literal_type, + ) + 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 else: - import pydantic as pydantic_v1 # type: ignore # nopycln: import + 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) + + +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") + if IS_PYDANTIC_V2: + adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 + return adapter.validate_python(dealiased_object) + else: + 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: + if IS_PYDANTIC_V2: + from pydantic_core import to_jsonable_python + + return to_jsonable_python(obj, fallback=fallback_serializer) + else: + return fallback_serializer(obj) + + +class UniversalBaseModel(pydantic.BaseModel): + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + # Allow fields begining 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) + data = {k: serialize_datetime(v) if isinstance(v, dt.datetime) else v for k, v in serialized.items()} + return data + + else: + + class Config: + smart_union = True + json_encoders = {dt.datetime: serialize_datetime} + + @classmethod + def model_construct( + cls: typing.Type["Model"], _fields_set: typing.Optional[typing.Set[str]] = None, **values: typing.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": + 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) + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = { + "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) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.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. + """ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # 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, + "by_alias": True, + "exclude_unset": True, + "exclude_none": False, + } + kwargs_with_defaults_exclude_none: typing.Any = { + **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 + ) + + else: + _fields_set = self.__fields_set__.copy() + + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if name not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default is not None or ("exclude_unset" in kwargs and not kwargs["exclude_unset"]): + _fields_set.add(name) + + if default is not None: + self.__fields_set__.add(name) + + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { + "by_alias": True, + "exclude_unset": True, + "include": _fields_set, + **kwargs, + } + + 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") + + +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] = [] + for i, item in enumerate(source): + destination_value = destination[i] # type: ignore + if isinstance(item, dict): + converted_list.append(deep_union_pydantic_dicts(item, destination_value)) + elif isinstance(item, list): + converted_list.append(_union_list_of_pydantic_dicts(item, destination_value)) + else: + converted_list.append(item) + 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]: for key, value in source.items(): + node = destination.setdefault(key, {}) if isinstance(value, dict): - node = destination.setdefault(key, {}) deep_union_pydantic_dicts(value, node) + # Note: we do not do this same processing for sets given we do not have sets of models + # and given the sets are unordered, the processing of the set and matching objects would + # be non-trivial. + elif isinstance(value, list): + destination[key] = _union_list_of_pydantic_dicts(value, node) else: destination[key] = value return destination -__all__ = ["pydantic_v1"] +if IS_PYDANTIC_V2: + + class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 + pass + + UniversalRootModel: typing_extensions.TypeAlias = V2RootModel # type: ignore +else: + UniversalRootModel: typing_extensions.TypeAlias = UniversalBaseModel # type: ignore + + +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) + ) + for type_, encoder in encoders_by_type.items(): + encoders_by_class_tuples[encoder] += (type_,) + + if type(o) in encoders_by_type: + return encoders_by_type[type(o)](o) + for encoder, classes_tuple in encoders_by_class_tuples.items(): + if isinstance(o, classes_tuple): + return encoder(o) + + +def update_forward_refs(model: typing.Type["Model"], **localns: typing.Any) -> None: + if IS_PYDANTIC_V2: + model.model_rebuild(raise_errors=False) # type: ignore # Pydantic v2 + else: + model.update_forward_refs(**localns) + + +# Mirrors Pydantic's internal typing +AnyCallable = typing.Callable[..., typing.Any] + + +def universal_root_validator( + pre: bool = False, +) -> typing.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 + + return decorator + + +def universal_field_validator(field_name: str, pre: bool = False) -> typing.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 decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/src/schematic/core/query_encoder.py b/src/schematic/core/query_encoder.py index 1f5f766..3183001 100644 --- a/src/schematic/core/query_encoder.py +++ b/src/schematic/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple -from .pydantic_utilities import pydantic_v1 +import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: - if isinstance(query_value, pydantic_v1.BaseModel) or isinstance(query_value, dict): - if isinstance(query_value, pydantic_v1.BaseModel): +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: + if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): + if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/src/schematic/core/remove_none_from_dict.py b/src/schematic/core/remove_none_from_dict.py index 2da30f7..c229814 100644 --- a/src/schematic/core/remove_none_from_dict.py +++ b/src/schematic/core/remove_none_from_dict.py @@ -1,9 +1,9 @@ # This file was auto-generated by Fern from our API Definition. -from typing import Any, Dict, Optional +from typing import Any, Dict, Mapping, Optional -def remove_none_from_dict(original: Dict[str, Optional[Any]]) -> Dict[str, Any]: +def remove_none_from_dict(original: Mapping[str, Optional[Any]]) -> Dict[str, Any]: new: Dict[str, Any] = {} for key, value in original.items(): if value is not None: diff --git a/src/schematic/core/request_options.py b/src/schematic/core/request_options.py index cd6f27a..d0bf0db 100644 --- a/src/schematic/core/request_options.py +++ b/src/schematic/core/request_options.py @@ -5,10 +5,10 @@ try: from typing import NotRequired # type: ignore except ImportError: - from typing_extensions import NotRequired # type: ignore + from typing_extensions import NotRequired -class RequestOptions(typing.TypedDict): +class RequestOptions(typing.TypedDict, total=False): """ Additional options for request-specific configuration when calling APIs via the SDK. This is used primarily as an optional final parameter for service functions. diff --git a/src/schematic/core/serialization.py b/src/schematic/core/serialization.py new file mode 100644 index 0000000..cb5dcbf --- /dev/null +++ b/src/schematic/core/serialization.py @@ -0,0 +1,272 @@ +# This file was auto-generated by Fern from our API Definition. + +import collections +import inspect +import typing + +import typing_extensions + +import pydantic + + +class FieldMetadata: + """ + Metadata class used to annotate fields to provide additional information. + + Example: + class MyDict(TypedDict): + field: typing.Annotated[str, FieldMetadata(alias="field_name")] + + Will serialize: `{"field": "value"}` + To: `{"field_name": "value"}` + """ + + alias: str + + def __init__(self, *, alias: str) -> None: + self.alias = alias + + +def convert_and_respect_annotation_metadata( + *, + object_: typing.Any, + annotation: typing.Any, + inner_type: typing.Optional[typing.Any] = None, + direction: typing.Literal["read", "write"], +) -> typing.Any: + """ + Respect the metadata annotations on a field, such as aliasing. This function effectively + manipulates the dict-form of an object to respect the metadata annotations. This is primarily used for + TypedDicts, which cannot support aliasing out of the box, and can be extended for additional + utilities, such as defaults. + + Parameters + ---------- + object_ : typing.Any + + annotation : type + The type we're looking to apply typing annotations from + + inner_type : typing.Optional[type] + + Returns + ------- + typing.Any + """ + + if object_ is None: + return None + if inner_type is None: + inner_type = annotation + + clean_type = _remove_annotations(inner_type) + # Pydantic models + if ( + inspect.isclass(clean_type) + and issubclass(clean_type, pydantic.BaseModel) + and isinstance(object_, typing.Mapping) + ): + return _convert_mapping(object_, clean_type, direction) + # TypedDicts + if typing_extensions.is_typeddict(clean_type) and isinstance(object_, typing.Mapping): + return _convert_mapping(object_, clean_type, direction) + + if ( + typing_extensions.get_origin(clean_type) == typing.Dict + or typing_extensions.get_origin(clean_type) == dict + or clean_type == typing.Dict + ) and isinstance(object_, typing.Dict): + key_type = typing_extensions.get_args(clean_type)[0] + value_type = typing_extensions.get_args(clean_type)[1] + + return { + key: convert_and_respect_annotation_metadata( + object_=value, + annotation=annotation, + inner_type=value_type, + direction=direction, + ) + for key, value in object_.items() + } + + # If you're iterating on a string, do not bother to coerce it to a sequence. + if not isinstance(object_, str): + if ( + typing_extensions.get_origin(clean_type) == typing.Set + or typing_extensions.get_origin(clean_type) == set + or clean_type == typing.Set + ) and isinstance(object_, typing.Set): + inner_type = typing_extensions.get_args(clean_type)[0] + return { + convert_and_respect_annotation_metadata( + object_=item, + annotation=annotation, + inner_type=inner_type, + direction=direction, + ) + for item in object_ + } + elif ( + ( + typing_extensions.get_origin(clean_type) == typing.List + or typing_extensions.get_origin(clean_type) == list + or clean_type == typing.List + ) + and isinstance(object_, typing.List) + ) or ( + ( + typing_extensions.get_origin(clean_type) == typing.Sequence + or typing_extensions.get_origin(clean_type) == collections.abc.Sequence + or clean_type == typing.Sequence + ) + and isinstance(object_, typing.Sequence) + ): + inner_type = typing_extensions.get_args(clean_type)[0] + return [ + convert_and_respect_annotation_metadata( + object_=item, + annotation=annotation, + inner_type=inner_type, + direction=direction, + ) + for item in object_ + ] + + if typing_extensions.get_origin(clean_type) == typing.Union: + # We should be able to ~relatively~ safely try to convert keys against all + # member types in the union, the edge case here is if one member aliases a field + # of the same name to a different name from another member + # Or if another member aliases a field of the same name that another member does not. + for member in typing_extensions.get_args(clean_type): + object_ = convert_and_respect_annotation_metadata( + object_=object_, + annotation=annotation, + inner_type=member, + direction=direction, + ) + return object_ + + annotated_type = _get_annotation(annotation) + if annotated_type is None: + return object_ + + # If the object is not a TypedDict, a Union, or other container (list, set, sequence, etc.) + # Then we can safely call it on the recursive conversion. + return object_ + + +def _convert_mapping( + object_: typing.Mapping[str, object], + expected_type: typing.Any, + 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) + 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: + dealiased_key = aliases_to_field_names.get(key) + if dealiased_key is not None: + type_ = annotations.get(dealiased_key) + else: + type_ = annotations.get(key) + # Note you can't get the annotation by the field name if you're in read mode, so you must check the aliases map + # + # So this is effectively saying if we're in write mode, and we don't have a type, or if we're in read mode and we don't have an alias + # then we can just pass the value through as is + if type_ is None: + converted_object[key] = value + elif direction == "read" and key not in aliases_to_field_names: + converted_object[key] = convert_and_respect_annotation_metadata( + object_=value, annotation=type_, direction=direction + ) + else: + converted_object[_alias_key(key, type_, direction, aliases_to_field_names)] = ( + convert_and_respect_annotation_metadata(object_=value, annotation=type_, direction=direction) + ) + return converted_object + + +def _get_annotation(type_: typing.Any) -> typing.Optional[typing.Any]: + maybe_annotated_type = typing_extensions.get_origin(type_) + if maybe_annotated_type is None: + return None + + if maybe_annotated_type == typing_extensions.NotRequired: + type_ = typing_extensions.get_args(type_)[0] + maybe_annotated_type = typing_extensions.get_origin(type_) + + if maybe_annotated_type == typing_extensions.Annotated: + return type_ + + return None + + +def _remove_annotations(type_: typing.Any) -> typing.Any: + maybe_annotated_type = typing_extensions.get_origin(type_) + if maybe_annotated_type is None: + return type_ + + if maybe_annotated_type == typing_extensions.NotRequired: + return _remove_annotations(typing_extensions.get_args(type_)[0]) + + if maybe_annotated_type == typing_extensions.Annotated: + return _remove_annotations(typing_extensions.get_args(type_)[0]) + + return type_ + + +def get_alias_to_field_mapping(type_: typing.Any) -> typing.Dict[str, str]: + annotations = typing_extensions.get_type_hints(type_, include_extras=True) + return _get_alias_to_field_name(annotations) + + +def get_field_to_alias_mapping(type_: typing.Any) -> typing.Dict[str, str]: + annotations = typing_extensions.get_type_hints(type_, include_extras=True) + return _get_field_to_alias_name(annotations) + + +def _get_alias_to_field_name( + field_to_hint: typing.Dict[str, typing.Any], +) -> typing.Dict[str, str]: + aliases = {} + for field, hint in field_to_hint.items(): + maybe_alias = _get_alias_from_type(hint) + if maybe_alias is not None: + aliases[maybe_alias] = field + return aliases + + +def _get_field_to_alias_name( + field_to_hint: typing.Dict[str, typing.Any], +) -> typing.Dict[str, str]: + aliases = {} + for field, hint in field_to_hint.items(): + maybe_alias = _get_alias_from_type(hint) + if maybe_alias is not None: + aliases[field] = maybe_alias + return aliases + + +def _get_alias_from_type(type_: typing.Any) -> typing.Optional[str]: + maybe_annotated_type = _get_annotation(type_) + + if maybe_annotated_type is not None: + # The actual annotations are 1 onward, the first is the annotated type + annotations = typing_extensions.get_args(maybe_annotated_type)[1:] + + for annotation in annotations: + if isinstance(annotation, FieldMetadata) and annotation.alias is not None: + return annotation.alias + return None + + +def _alias_key( + key: str, + type_: typing.Any, + direction: typing.Literal["read", "write"], + aliases_to_field_names: typing.Dict[str, str], +) -> str: + if direction == "read": + return aliases_to_field_names.get(key, key) + return _get_alias_from_type(type_=type_) or key diff --git a/src/schematic/crm/client.py b/src/schematic/crm/client.py index 95e72bc..36d1ce0 100644 --- a/src/schematic/crm/client.py +++ b/src/schematic/crm/client.py @@ -1,26 +1,22 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse -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.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 -from ..core.query_encoder import encode_query -from ..core.remove_none_from_dict import remove_none_from_dict +from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions +from .types.upsert_deal_line_item_association_response import UpsertDealLineItemAssociationResponse +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 ..errors.forbidden_error import ForbiddenError 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.list_crm_products_response import ListCrmProductsResponse +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError as core_api_error_ApiError +from .types.upsert_line_item_response import UpsertLineItemResponse from .types.upsert_crm_deal_response import UpsertCrmDealResponse +from .types.list_crm_products_response import ListCrmProductsResponse from .types.upsert_crm_product_response import UpsertCrmProductResponse -from .types.upsert_deal_line_item_association_response import UpsertDealLineItemAssociationResponse -from .types.upsert_line_item_response import UpsertLineItemResponse +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -54,7 +50,7 @@ def upsert_deal_line_item_association( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -65,52 +61,64 @@ def upsert_deal_line_item_association( ) """ _response = self._client_wrapper.httpx_client.request( + "crm/associations/deal-line-item", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/associations/deal-line-item"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder( - {"deal_external_id": deal_external_id, "line_item_external_id": line_item_external_id} - ) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder( - {"deal_external_id": deal_external_id, "line_item_external_id": line_item_external_id} - ), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "deal_external_id": deal_external_id, + "line_item_external_id": line_item_external_id, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertDealLineItemAssociationResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertDealLineItemAssociationResponse, + parse_obj_as( + type_=UpsertDealLineItemAssociationResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -158,7 +166,7 @@ def upsert_line_item( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -171,62 +179,71 @@ def upsert_line_item( quantity=1, ) """ - _request: typing.Dict[str, typing.Any] = { - "amount": amount, - "interval": interval, - "line_item_external_id": line_item_external_id, - "product_external_id": product_external_id, - "quantity": quantity, - } - if term_month is not OMIT: - _request["TermMonth"] = term_month - if discount_percentage is not OMIT: - _request["discount_percentage"] = discount_percentage - if total_discount is not OMIT: - _request["total_discount"] = total_discount _response = self._client_wrapper.httpx_client.request( + "crm/deal-line-item/upsert", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/deal-line-item/upsert"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "TermMonth": term_month, + "amount": amount, + "discount_percentage": discount_percentage, + "interval": interval, + "line_item_external_id": line_item_external_id, + "product_external_id": product_external_id, + "quantity": quantity, + "total_discount": total_discount, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertLineItemResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertLineItemResponse, + parse_obj_as( + type_=UpsertLineItemResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -277,7 +294,7 @@ def upsert_crm_deal( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -288,66 +305,72 @@ def upsert_crm_deal( deal_external_id="deal_external_id", ) """ - _request: typing.Dict[str, typing.Any] = { - "crm_company_key": crm_company_key, - "crm_type": crm_type, - "deal_external_id": deal_external_id, - } - if arr is not OMIT: - _request["arr"] = arr - if crm_company_id is not OMIT: - _request["crm_company_id"] = crm_company_id - if crm_product_id is not OMIT: - _request["crm_product_id"] = crm_product_id - if deal_name is not OMIT: - _request["deal_name"] = deal_name - if deal_stage is not OMIT: - _request["deal_stage"] = deal_stage - if mrr is not OMIT: - _request["mrr"] = mrr _response = self._client_wrapper.httpx_client.request( + "crm/deals/upsert", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/deals/upsert"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "arr": arr, + "crm_company_id": crm_company_id, + "crm_company_key": crm_company_key, + "crm_product_id": crm_product_id, + "crm_type": crm_type, + "deal_external_id": deal_external_id, + "deal_name": deal_name, + "deal_stage": deal_stage, + "mrr": mrr, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertCrmDealResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertCrmDealResponse, + parse_obj_as( + type_=UpsertCrmDealResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -385,7 +408,7 @@ def list_crm_products( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -393,54 +416,65 @@ def list_crm_products( client.crm.list_crm_products() """ _response = self._client_wrapper.httpx_client.request( + "crm/products", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/products"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "ids": ids, - "name": name, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params={ + "ids": ids, + "name": name, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListCrmProductsResponse, + parse_obj_as( + type_=ListCrmProductsResponse, # 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(), + ), ) ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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(), + ), + ) ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListCrmProductsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - try: _response_json = _response.json() except JSONDecodeError: raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) @@ -488,7 +522,7 @@ def upsert_crm_product( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -505,70 +539,70 @@ def upsert_crm_product( ) """ _response = self._client_wrapper.httpx_client.request( + "crm/products/upsert", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/products/upsert"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder( - { - "currency": currency, - "description": description, - "external_id": external_id, - "interval": interval, - "name": name, - "price": price, - "quantity": quantity, - "sku": sku, - } - ) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder( - { - "currency": currency, - "description": description, - "external_id": external_id, - "interval": interval, - "name": name, - "price": price, - "quantity": quantity, - "sku": sku, - } - ), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "currency": currency, + "description": description, + "external_id": external_id, + "interval": interval, + "name": name, + "price": price, + "quantity": quantity, + "sku": sku, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertCrmProductResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertCrmProductResponse, + parse_obj_as( + type_=UpsertCrmProductResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -603,63 +637,83 @@ async def upsert_deal_line_item_association( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.crm.upsert_deal_line_item_association( - deal_external_id="deal_external_id", - line_item_external_id="line_item_external_id", - ) + + + async def main() -> None: + await client.crm.upsert_deal_line_item_association( + deal_external_id="deal_external_id", + line_item_external_id="line_item_external_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "crm/associations/deal-line-item", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/associations/deal-line-item"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder( - {"deal_external_id": deal_external_id, "line_item_external_id": line_item_external_id} - ) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder( - {"deal_external_id": deal_external_id, "line_item_external_id": line_item_external_id} - ), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "deal_external_id": deal_external_id, + "line_item_external_id": line_item_external_id, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertDealLineItemAssociationResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertDealLineItemAssociationResponse, + parse_obj_as( + type_=UpsertDealLineItemAssociationResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -707,75 +761,92 @@ async def upsert_line_item( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.crm.upsert_line_item( - amount="amount", - interval="interval", - line_item_external_id="line_item_external_id", - product_external_id="product_external_id", - quantity=1, - ) + + + async def main() -> None: + await client.crm.upsert_line_item( + amount="amount", + interval="interval", + line_item_external_id="line_item_external_id", + product_external_id="product_external_id", + quantity=1, + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = { - "amount": amount, - "interval": interval, - "line_item_external_id": line_item_external_id, - "product_external_id": product_external_id, - "quantity": quantity, - } - if term_month is not OMIT: - _request["TermMonth"] = term_month - if discount_percentage is not OMIT: - _request["discount_percentage"] = discount_percentage - if total_discount is not OMIT: - _request["total_discount"] = total_discount _response = await self._client_wrapper.httpx_client.request( + "crm/deal-line-item/upsert", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/deal-line-item/upsert"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "TermMonth": term_month, + "amount": amount, + "discount_percentage": discount_percentage, + "interval": interval, + "line_item_external_id": line_item_external_id, + "product_external_id": product_external_id, + "quantity": quantity, + "total_discount": total_discount, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertLineItemResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertLineItemResponse, + parse_obj_as( + type_=UpsertLineItemResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -826,77 +897,91 @@ async def upsert_crm_deal( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.crm.upsert_crm_deal( - crm_company_key="crm_company_key", - crm_type="crm_type", - deal_external_id="deal_external_id", - ) + + + async def main() -> None: + await client.crm.upsert_crm_deal( + crm_company_key="crm_company_key", + crm_type="crm_type", + deal_external_id="deal_external_id", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = { - "crm_company_key": crm_company_key, - "crm_type": crm_type, - "deal_external_id": deal_external_id, - } - if arr is not OMIT: - _request["arr"] = arr - if crm_company_id is not OMIT: - _request["crm_company_id"] = crm_company_id - if crm_product_id is not OMIT: - _request["crm_product_id"] = crm_product_id - if deal_name is not OMIT: - _request["deal_name"] = deal_name - if deal_stage is not OMIT: - _request["deal_stage"] = deal_stage - if mrr is not OMIT: - _request["mrr"] = mrr _response = await self._client_wrapper.httpx_client.request( + "crm/deals/upsert", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/deals/upsert"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "arr": arr, + "crm_company_id": crm_company_id, + "crm_company_key": crm_company_key, + "crm_product_id": crm_product_id, + "crm_type": crm_type, + "deal_external_id": deal_external_id, + "deal_name": deal_name, + "deal_stage": deal_stage, + "mrr": mrr, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertCrmDealResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertCrmDealResponse, + parse_obj_as( + type_=UpsertCrmDealResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -934,62 +1019,81 @@ async def list_crm_products( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.crm.list_crm_products() + + + async def main() -> None: + await client.crm.list_crm_products() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "crm/products", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/products"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "ids": ids, - "name": name, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params={ + "ids": ids, + "name": name, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListCrmProductsResponse, + parse_obj_as( + type_=ListCrmProductsResponse, # 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(), + ), ) ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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(), + ), + ) ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListCrmProductsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - try: _response_json = _response.json() except JSONDecodeError: raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) @@ -1037,87 +1141,95 @@ async def upsert_crm_product( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.crm.upsert_crm_product( - currency="currency", - description="description", - external_id="external_id", - interval="interval", - name="name", - price="price", - quantity=1, - sku="sku", - ) + + + async def main() -> None: + await client.crm.upsert_crm_product( + currency="currency", + description="description", + external_id="external_id", + interval="interval", + name="name", + price="price", + quantity=1, + sku="sku", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "crm/products/upsert", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/products/upsert"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder( - { - "currency": currency, - "description": description, - "external_id": external_id, - "interval": interval, - "name": name, - "price": price, - "quantity": quantity, - "sku": sku, - } - ) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder( - { - "currency": currency, - "description": description, - "external_id": external_id, - "interval": interval, - "name": name, - "price": price, - "quantity": quantity, - "sku": sku, - } - ), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "currency": currency, + "description": description, + "external_id": external_id, + "interval": interval, + "name": name, + "price": price, + "quantity": quantity, + "sku": sku, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpsertCrmProductResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertCrmProductResponse, + parse_obj_as( + type_=UpsertCrmProductResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) diff --git a/src/schematic/crm/types/list_crm_products_params.py b/src/schematic/crm/types/list_crm_products_params.py index bfe20e6..9dd6e8b 100644 --- a/src/schematic/crm/types/list_crm_products_params.py +++ b/src/schematic/crm/types/list_crm_products_params.py @@ -1,43 +1,33 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListCrmProductsParams(pydantic_v1.BaseModel): +class ListCrmProductsParams(UniversalBaseModel): """ Input parameters """ ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ name: typing.Optional[str] = None - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/crm/types/list_crm_products_response.py b/src/schematic/crm/types/list_crm_products_response.py index df0e9a0..fa57acd 100644 --- a/src/schematic/crm/types/list_crm_products_response.py +++ b/src/schematic/crm/types/list_crm_products_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.crm_product_response_data import CrmProductResponseData +import pydantic from .list_crm_products_params import ListCrmProductsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListCrmProductsResponse(pydantic_v1.BaseModel): - data: typing.List[CrmProductResponseData] = pydantic_v1.Field() +class ListCrmProductsResponse(UniversalBaseModel): + data: typing.List[CrmProductResponseData] = pydantic.Field() """ The returned resources """ - params: ListCrmProductsParams = pydantic_v1.Field() + params: ListCrmProductsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/crm/types/upsert_crm_deal_response.py b/src/schematic/crm/types/upsert_crm_deal_response.py index 54a66de..07de3f4 100644 --- a/src/schematic/crm/types/upsert_crm_deal_response.py +++ b/src/schematic/crm/types/upsert_crm_deal_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.crm_deal_response_data import CrmDealResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpsertCrmDealResponse(pydantic_v1.BaseModel): +class UpsertCrmDealResponse(UniversalBaseModel): data: CrmDealResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/crm/types/upsert_crm_product_response.py b/src/schematic/crm/types/upsert_crm_product_response.py index 3e785f1..62cb353 100644 --- a/src/schematic/crm/types/upsert_crm_product_response.py +++ b/src/schematic/crm/types/upsert_crm_product_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.crm_product_response_data import CrmProductResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpsertCrmProductResponse(pydantic_v1.BaseModel): +class UpsertCrmProductResponse(UniversalBaseModel): data: CrmProductResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/crm/types/upsert_deal_line_item_association_response.py b/src/schematic/crm/types/upsert_deal_line_item_association_response.py index c6ef6ca..51f5e0d 100644 --- a/src/schematic/crm/types/upsert_deal_line_item_association_response.py +++ b/src/schematic/crm/types/upsert_deal_line_item_association_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.crm_line_item_response_data import CrmLineItemResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpsertDealLineItemAssociationResponse(pydantic_v1.BaseModel): +class UpsertDealLineItemAssociationResponse(UniversalBaseModel): data: CrmLineItemResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/crm/types/upsert_line_item_response.py b/src/schematic/crm/types/upsert_line_item_response.py index 16a35b0..c8d1668 100644 --- a/src/schematic/crm/types/upsert_line_item_response.py +++ b/src/schematic/crm/types/upsert_line_item_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.crm_line_item_response_data import CrmLineItemResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpsertLineItemResponse(pydantic_v1.BaseModel): +class UpsertLineItemResponse(UniversalBaseModel): data: CrmLineItemResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/client.py b/src/schematic/entitlements/client.py index 320b944..eefc54b 100644 --- a/src/schematic/entitlements/client.py +++ b/src/schematic/entitlements/client.py @@ -1,49 +1,46 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse -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.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 -from ..core.query_encoder import encode_query -from ..core.remove_none_from_dict import remove_none_from_dict +from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions +from .types.list_company_overrides_response import ListCompanyOverridesResponse +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 ..errors.forbidden_error import ForbiddenError 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.create_company_override_request_body_value_type import CreateCompanyOverrideRequestBodyValueType +from .types.create_company_override_request_body_metric_period import CreateCompanyOverrideRequestBodyMetricPeriod +from .types.create_company_override_response import CreateCompanyOverrideResponse +from .types.get_company_override_response import GetCompanyOverrideResponse +from ..core.jsonable_encoder import jsonable_encoder 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.update_company_override_request_body_value_type import UpdateCompanyOverrideRequestBodyValueType +from .types.update_company_override_request_body_metric_period import UpdateCompanyOverrideRequestBodyMetricPeriod +from .types.update_company_override_response import UpdateCompanyOverrideResponse +from .types.delete_company_override_response import DeleteCompanyOverrideResponse from .types.count_company_overrides_response import CountCompanyOverridesResponse +from .types.list_feature_companies_response import ListFeatureCompaniesResponse from .types.count_feature_companies_response import CountFeatureCompaniesResponse +from .types.list_feature_usage_response import ListFeatureUsageResponse from .types.count_feature_usage_response import CountFeatureUsageResponse +from .types.list_feature_users_response import ListFeatureUsersResponse from .types.count_feature_users_response import CountFeatureUsersResponse -from .types.count_plan_entitlements_response import CountPlanEntitlementsResponse -from .types.create_company_override_request_body_metric_period import CreateCompanyOverrideRequestBodyMetricPeriod -from .types.create_company_override_request_body_value_type import CreateCompanyOverrideRequestBodyValueType -from .types.create_company_override_response import CreateCompanyOverrideResponse -from .types.create_plan_entitlement_request_body_metric_period import CreatePlanEntitlementRequestBodyMetricPeriod +from .types.list_plan_entitlements_response import ListPlanEntitlementsResponse from .types.create_plan_entitlement_request_body_value_type import CreatePlanEntitlementRequestBodyValueType +from .types.create_plan_entitlement_request_body_metric_period import CreatePlanEntitlementRequestBodyMetricPeriod from .types.create_plan_entitlement_response import CreatePlanEntitlementResponse -from .types.delete_company_override_response import DeleteCompanyOverrideResponse -from .types.delete_plan_entitlement_response import DeletePlanEntitlementResponse -from .types.get_company_override_response import GetCompanyOverrideResponse -from .types.get_feature_usage_by_company_response import GetFeatureUsageByCompanyResponse from .types.get_plan_entitlement_response import GetPlanEntitlementResponse -from .types.list_company_overrides_response import ListCompanyOverridesResponse -from .types.list_feature_companies_response import ListFeatureCompaniesResponse -from .types.list_feature_usage_response import ListFeatureUsageResponse -from .types.list_feature_users_response import ListFeatureUsersResponse -from .types.list_plan_entitlements_response import ListPlanEntitlementsResponse -from .types.update_company_override_request_body_metric_period import UpdateCompanyOverrideRequestBodyMetricPeriod -from .types.update_company_override_request_body_value_type import UpdateCompanyOverrideRequestBodyValueType -from .types.update_company_override_response import UpdateCompanyOverrideResponse -from .types.update_plan_entitlement_request_body_metric_period import UpdatePlanEntitlementRequestBodyMetricPeriod from .types.update_plan_entitlement_request_body_value_type import UpdatePlanEntitlementRequestBodyValueType +from .types.update_plan_entitlement_request_body_metric_period import UpdatePlanEntitlementRequestBodyMetricPeriod from .types.update_plan_entitlement_response import UpdatePlanEntitlementResponse +from .types.delete_plan_entitlement_response import DeletePlanEntitlementResponse +from .types.count_plan_entitlements_response import CountPlanEntitlementsResponse +from .types.get_feature_usage_by_company_response import GetFeatureUsageByCompanyResponse +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -61,6 +58,7 @@ def list_company_overrides( feature_id: typing.Optional[str] = None, feature_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + q: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -78,6 +76,8 @@ def list_company_overrides( ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + q : typing.Optional[str] + limit : typing.Optional[int] Page limit (default 100) @@ -94,7 +94,7 @@ def list_company_overrides( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -102,57 +102,69 @@ def list_company_overrides( client.entitlements.list_company_overrides() """ _response = self._client_wrapper.httpx_client.request( + "company-overrides", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-overrides"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "company_ids": company_ids, - "feature_id": feature_id, - "feature_ids": feature_ids, - "ids": ids, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListCompanyOverridesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "company_ids": company_ids, + "feature_id": feature_id, + "feature_ids": feature_ids, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListCompanyOverridesResponse, + parse_obj_as( + type_=ListCompanyOverridesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -197,7 +209,7 @@ def create_company_override( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -205,65 +217,73 @@ def create_company_override( client.entitlements.create_company_override( company_id="company_id", feature_id="feature_id", - value_type="Boolean", - ) - """ - _request: typing.Dict[str, typing.Any] = { - "company_id": company_id, - "feature_id": feature_id, - "value_type": value_type, - } - if metric_period is not OMIT: - _request["metric_period"] = metric_period - if value_bool is not OMIT: - _request["value_bool"] = value_bool - if value_numeric is not OMIT: - _request["value_numeric"] = value_numeric - if value_trait_id is not OMIT: - _request["value_trait_id"] = value_trait_id + value_type="boolean", + ) + """ _response = self._client_wrapper.httpx_client.request( + "company-overrides", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-overrides"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "company_id": company_id, + "feature_id": feature_id, + "metric_period": metric_period, + "value_bool": value_bool, + "value_numeric": value_numeric, + "value_trait_id": value_trait_id, + "value_type": value_type, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateCompanyOverrideResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateCompanyOverrideResponse, + parse_obj_as( + type_=CreateCompanyOverrideResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -288,7 +308,7 @@ def get_company_override( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -298,44 +318,59 @@ def get_company_override( ) """ _response = self._client_wrapper.httpx_client.request( + f"company-overrides/{jsonable_encoder(company_override_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"company-overrides/{jsonable_encoder(company_override_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetCompanyOverrideResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetCompanyOverrideResponse, + parse_obj_as( + type_=GetCompanyOverrideResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -378,72 +413,88 @@ def update_company_override( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) client.entitlements.update_company_override( company_override_id="company_override_id", - value_type="Boolean", - ) - """ - _request: typing.Dict[str, typing.Any] = {"value_type": value_type} - if metric_period is not OMIT: - _request["metric_period"] = metric_period - if value_bool is not OMIT: - _request["value_bool"] = value_bool - if value_numeric is not OMIT: - _request["value_numeric"] = value_numeric - if value_trait_id is not OMIT: - _request["value_trait_id"] = value_trait_id + value_type="boolean", + ) + """ _response = self._client_wrapper.httpx_client.request( + f"company-overrides/{jsonable_encoder(company_override_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"company-overrides/{jsonable_encoder(company_override_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "metric_period": metric_period, + "value_bool": value_bool, + "value_numeric": value_numeric, + "value_trait_id": value_trait_id, + "value_type": value_type, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateCompanyOverrideResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateCompanyOverrideResponse, + parse_obj_as( + type_=UpdateCompanyOverrideResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -468,7 +519,7 @@ def delete_company_override( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -478,44 +529,59 @@ def delete_company_override( ) """ _response = self._client_wrapper.httpx_client.request( + f"company-overrides/{jsonable_encoder(company_override_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"company-overrides/{jsonable_encoder(company_override_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteCompanyOverrideResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteCompanyOverrideResponse, + parse_obj_as( + type_=DeleteCompanyOverrideResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -529,6 +595,7 @@ def count_company_overrides( feature_id: typing.Optional[str] = None, feature_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + q: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -546,6 +613,8 @@ def count_company_overrides( ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + q : typing.Optional[str] + limit : typing.Optional[int] Page limit (default 100) @@ -562,7 +631,7 @@ def count_company_overrides( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -570,57 +639,69 @@ def count_company_overrides( client.entitlements.count_company_overrides() """ _response = self._client_wrapper.httpx_client.request( + "company-overrides/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-overrides/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "company_ids": company_ids, - "feature_id": feature_id, - "feature_ids": feature_ids, - "ids": ids, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountCompanyOverridesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "company_ids": company_ids, + "feature_id": feature_id, + "feature_ids": feature_ids, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountCompanyOverridesResponse, + parse_obj_as( + type_=CountCompanyOverridesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -658,7 +739,7 @@ def list_feature_companies( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -668,54 +749,65 @@ def list_feature_companies( ) """ _response = self._client_wrapper.httpx_client.request( + "feature-companies", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "feature-companies"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListFeatureCompaniesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "feature_id": feature_id, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListFeatureCompaniesResponse, + parse_obj_as( + type_=ListFeatureCompaniesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -753,7 +845,7 @@ def count_feature_companies( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -763,54 +855,65 @@ def count_feature_companies( ) """ _response = self._client_wrapper.httpx_client.request( + "feature-companies/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "feature-companies/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountFeatureCompaniesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "feature_id": feature_id, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountFeatureCompaniesResponse, + parse_obj_as( + type_=CountFeatureCompaniesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -820,7 +923,7 @@ def list_feature_usage( self, *, company_id: typing.Optional[str] = None, - company_keys: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None, + company_keys: typing.Optional[typing.Dict[str, str]] = None, feature_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, q: typing.Optional[str] = None, limit: typing.Optional[int] = None, @@ -832,7 +935,7 @@ def list_feature_usage( ---------- company_id : typing.Optional[str] - company_keys : typing.Optional[typing.Dict[str, typing.Optional[str]]] + company_keys : typing.Optional[typing.Dict[str, str]] feature_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] @@ -854,7 +957,7 @@ def list_feature_usage( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -862,56 +965,67 @@ def list_feature_usage( client.entitlements.list_feature_usage() """ _response = self._client_wrapper.httpx_client.request( + "feature-usage", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "feature-usage"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "company_keys": jsonable_encoder(company_keys), - "feature_ids": feature_ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListFeatureUsageResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "company_keys": company_keys, + "feature_ids": feature_ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListFeatureUsageResponse, + parse_obj_as( + type_=ListFeatureUsageResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -921,7 +1035,7 @@ def count_feature_usage( self, *, company_id: typing.Optional[str] = None, - company_keys: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None, + company_keys: typing.Optional[typing.Dict[str, str]] = None, feature_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, q: typing.Optional[str] = None, limit: typing.Optional[int] = None, @@ -933,7 +1047,7 @@ def count_feature_usage( ---------- company_id : typing.Optional[str] - company_keys : typing.Optional[typing.Dict[str, typing.Optional[str]]] + company_keys : typing.Optional[typing.Dict[str, str]] feature_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] @@ -955,7 +1069,7 @@ def count_feature_usage( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -963,56 +1077,67 @@ def count_feature_usage( client.entitlements.count_feature_usage() """ _response = self._client_wrapper.httpx_client.request( + "feature-usage/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "feature-usage/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "company_keys": jsonable_encoder(company_keys), - "feature_ids": feature_ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountFeatureUsageResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "company_keys": company_keys, + "feature_ids": feature_ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountFeatureUsageResponse, + parse_obj_as( + type_=CountFeatureUsageResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1050,7 +1175,7 @@ def list_feature_users( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1060,54 +1185,65 @@ def list_feature_users( ) """ _response = self._client_wrapper.httpx_client.request( + "feature-users", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "feature-users"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListFeatureUsersResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "feature_id": feature_id, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListFeatureUsersResponse, + parse_obj_as( + type_=ListFeatureUsersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1145,7 +1281,7 @@ def count_feature_users( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1155,54 +1291,65 @@ def count_feature_users( ) """ _response = self._client_wrapper.httpx_client.request( + "feature-users/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "feature-users/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountFeatureUsersResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "feature_id": feature_id, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountFeatureUsersResponse, + parse_obj_as( + type_=CountFeatureUsersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1252,7 +1399,7 @@ def list_plan_entitlements( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1260,58 +1407,69 @@ def list_plan_entitlements( client.entitlements.list_plan_entitlements() """ _response = self._client_wrapper.httpx_client.request( + "plan-entitlements", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "plan-entitlements"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "feature_ids": feature_ids, - "ids": ids, - "plan_id": plan_id, - "plan_ids": plan_ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListPlanEntitlementsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "feature_id": feature_id, + "feature_ids": feature_ids, + "ids": ids, + "plan_id": plan_id, + "plan_ids": plan_ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListPlanEntitlementsResponse, + parse_obj_as( + type_=ListPlanEntitlementsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1356,7 +1514,7 @@ def create_plan_entitlement( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1364,65 +1522,73 @@ def create_plan_entitlement( client.entitlements.create_plan_entitlement( feature_id="feature_id", plan_id="plan_id", - value_type="Boolean", - ) - """ - _request: typing.Dict[str, typing.Any] = { - "feature_id": feature_id, - "plan_id": plan_id, - "value_type": value_type, - } - if metric_period is not OMIT: - _request["metric_period"] = metric_period - if value_bool is not OMIT: - _request["value_bool"] = value_bool - if value_numeric is not OMIT: - _request["value_numeric"] = value_numeric - if value_trait_id is not OMIT: - _request["value_trait_id"] = value_trait_id + value_type="boolean", + ) + """ _response = self._client_wrapper.httpx_client.request( + "plan-entitlements", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "plan-entitlements"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "feature_id": feature_id, + "metric_period": metric_period, + "plan_id": plan_id, + "value_bool": value_bool, + "value_numeric": value_numeric, + "value_trait_id": value_trait_id, + "value_type": value_type, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreatePlanEntitlementResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreatePlanEntitlementResponse, + parse_obj_as( + type_=CreatePlanEntitlementResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1447,7 +1613,7 @@ def get_plan_entitlement( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1457,44 +1623,59 @@ def get_plan_entitlement( ) """ _response = self._client_wrapper.httpx_client.request( + f"plan-entitlements/{jsonable_encoder(plan_entitlement_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"plan-entitlements/{jsonable_encoder(plan_entitlement_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetPlanEntitlementResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetPlanEntitlementResponse, + parse_obj_as( + type_=GetPlanEntitlementResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1537,73 +1718,89 @@ def update_plan_entitlement( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) client.entitlements.update_plan_entitlement( plan_entitlement_id="plan_entitlement_id", - value_type="Boolean", - ) - """ - _request: typing.Dict[str, typing.Any] = {"value_type": value_type} - if metric_period is not OMIT: - _request["metric_period"] = metric_period - if value_bool is not OMIT: - _request["value_bool"] = value_bool - if value_numeric is not OMIT: - _request["value_numeric"] = value_numeric - if value_trait_id is not OMIT: - _request["value_trait_id"] = value_trait_id + value_type="boolean", + ) + """ _response = self._client_wrapper.httpx_client.request( + f"plan-entitlements/{jsonable_encoder(plan_entitlement_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"plan-entitlements/{jsonable_encoder(plan_entitlement_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "metric_period": metric_period, + "value_bool": value_bool, + "value_numeric": value_numeric, + "value_trait_id": value_trait_id, + "value_type": value_type, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdatePlanEntitlementResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: - _response_json = _response.json() + if 200 <= _response.status_code < 300: + return typing.cast( + UpdatePlanEntitlementResponse, + parse_obj_as( + type_=UpdatePlanEntitlementResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1627,7 +1824,7 @@ def delete_plan_entitlement( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1637,44 +1834,59 @@ def delete_plan_entitlement( ) """ _response = self._client_wrapper.httpx_client.request( + f"plan-entitlements/{jsonable_encoder(plan_entitlement_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"plan-entitlements/{jsonable_encoder(plan_entitlement_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeletePlanEntitlementResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeletePlanEntitlementResponse, + parse_obj_as( + type_=DeletePlanEntitlementResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1724,7 +1936,7 @@ def count_plan_entitlements( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1732,70 +1944,84 @@ def count_plan_entitlements( client.entitlements.count_plan_entitlements() """ _response = self._client_wrapper.httpx_client.request( + "plan-entitlements/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "plan-entitlements/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "feature_ids": feature_ids, - "ids": ids, - "plan_id": plan_id, - "plan_ids": plan_ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountPlanEntitlementsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "feature_id": feature_id, + "feature_ids": feature_ids, + "ids": ids, + "plan_id": plan_id, + "plan_ids": plan_ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountPlanEntitlementsResponse, + parse_obj_as( + type_=CountPlanEntitlementsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) def get_feature_usage_by_company( - self, *, keys: typing.Dict[str, typing.Any], request_options: typing.Optional[RequestOptions] = None + self, + *, + keys: typing.Dict[str, typing.Optional[typing.Any]], + request_options: typing.Optional[RequestOptions] = None, ) -> GetFeatureUsageByCompanyResponse: """ Parameters ---------- - keys : typing.Dict[str, typing.Any] + keys : typing.Dict[str, typing.Optional[typing.Any]] Key/value pairs request_options : typing.Optional[RequestOptions] @@ -1808,7 +2034,7 @@ def get_feature_usage_by_company( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1818,51 +2044,62 @@ def get_feature_usage_by_company( ) """ _response = self._client_wrapper.httpx_client.request( + "usage-by-company", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "usage-by-company"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "keys": jsonable_encoder(keys), - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetFeatureUsageByCompanyResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "keys": keys, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetFeatureUsageByCompanyResponse, + parse_obj_as( + type_=GetFeatureUsageByCompanyResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1881,6 +2118,7 @@ async def list_company_overrides( feature_id: typing.Optional[str] = None, feature_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + q: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -1898,6 +2136,8 @@ async def list_company_overrides( ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + q : typing.Optional[str] + limit : typing.Optional[int] Page limit (default 100) @@ -1914,65 +2154,85 @@ async def list_company_overrides( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.list_company_overrides() + + + async def main() -> None: + await client.entitlements.list_company_overrides() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "company-overrides", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-overrides"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "company_ids": company_ids, - "feature_id": feature_id, - "feature_ids": feature_ids, - "ids": ids, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListCompanyOverridesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "company_ids": company_ids, + "feature_id": feature_id, + "feature_ids": feature_ids, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListCompanyOverridesResponse, + parse_obj_as( + type_=ListCompanyOverridesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2017,73 +2277,89 @@ async def create_company_override( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.create_company_override( - company_id="company_id", - feature_id="feature_id", - value_type="Boolean", - ) - """ - _request: typing.Dict[str, typing.Any] = { - "company_id": company_id, - "feature_id": feature_id, - "value_type": value_type, - } - if metric_period is not OMIT: - _request["metric_period"] = metric_period - if value_bool is not OMIT: - _request["value_bool"] = value_bool - if value_numeric is not OMIT: - _request["value_numeric"] = value_numeric - if value_trait_id is not OMIT: - _request["value_trait_id"] = value_trait_id + + + async def main() -> None: + await client.entitlements.create_company_override( + company_id="company_id", + feature_id="feature_id", + value_type="boolean", + ) + + + asyncio.run(main()) + """ _response = await self._client_wrapper.httpx_client.request( + "company-overrides", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-overrides"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "company_id": company_id, + "feature_id": feature_id, + "metric_period": metric_period, + "value_bool": value_bool, + "value_numeric": value_numeric, + "value_trait_id": value_trait_id, + "value_type": value_type, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateCompanyOverrideResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateCompanyOverrideResponse, + parse_obj_as( + type_=CreateCompanyOverrideResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2108,54 +2384,77 @@ async def get_company_override( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.get_company_override( - company_override_id="company_override_id", - ) + + + async def main() -> None: + await client.entitlements.get_company_override( + company_override_id="company_override_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"company-overrides/{jsonable_encoder(company_override_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"company-overrides/{jsonable_encoder(company_override_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetCompanyOverrideResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetCompanyOverrideResponse, + parse_obj_as( + type_=GetCompanyOverrideResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2198,72 +2497,96 @@ async def update_company_override( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.update_company_override( - company_override_id="company_override_id", - value_type="Boolean", - ) - """ - _request: typing.Dict[str, typing.Any] = {"value_type": value_type} - if metric_period is not OMIT: - _request["metric_period"] = metric_period - if value_bool is not OMIT: - _request["value_bool"] = value_bool - if value_numeric is not OMIT: - _request["value_numeric"] = value_numeric - if value_trait_id is not OMIT: - _request["value_trait_id"] = value_trait_id + + + async def main() -> None: + await client.entitlements.update_company_override( + company_override_id="company_override_id", + value_type="boolean", + ) + + + asyncio.run(main()) + """ _response = await self._client_wrapper.httpx_client.request( + f"company-overrides/{jsonable_encoder(company_override_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"company-overrides/{jsonable_encoder(company_override_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "metric_period": metric_period, + "value_bool": value_bool, + "value_numeric": value_numeric, + "value_trait_id": value_trait_id, + "value_type": value_type, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateCompanyOverrideResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateCompanyOverrideResponse, + parse_obj_as( + type_=UpdateCompanyOverrideResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2288,54 +2611,77 @@ async def delete_company_override( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.delete_company_override( - company_override_id="company_override_id", - ) + + + async def main() -> None: + await client.entitlements.delete_company_override( + company_override_id="company_override_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"company-overrides/{jsonable_encoder(company_override_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"company-overrides/{jsonable_encoder(company_override_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteCompanyOverrideResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteCompanyOverrideResponse, + parse_obj_as( + type_=DeleteCompanyOverrideResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2349,6 +2695,7 @@ async def count_company_overrides( feature_id: typing.Optional[str] = None, feature_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + q: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -2366,6 +2713,8 @@ async def count_company_overrides( ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + q : typing.Optional[str] + limit : typing.Optional[int] Page limit (default 100) @@ -2382,65 +2731,85 @@ async def count_company_overrides( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.count_company_overrides() + + + async def main() -> None: + await client.entitlements.count_company_overrides() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "company-overrides/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-overrides/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "company_ids": company_ids, - "feature_id": feature_id, - "feature_ids": feature_ids, - "ids": ids, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountCompanyOverridesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "company_ids": company_ids, + "feature_id": feature_id, + "feature_ids": feature_ids, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountCompanyOverridesResponse, + parse_obj_as( + type_=CountCompanyOverridesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2478,64 +2847,83 @@ async def list_feature_companies( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.list_feature_companies( - feature_id="feature_id", - ) + + + async def main() -> None: + await client.entitlements.list_feature_companies( + feature_id="feature_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "feature-companies", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "feature-companies"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListFeatureCompaniesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "feature_id": feature_id, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListFeatureCompaniesResponse, + parse_obj_as( + type_=ListFeatureCompaniesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2573,64 +2961,83 @@ async def count_feature_companies( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.count_feature_companies( - feature_id="feature_id", - ) + + + async def main() -> None: + await client.entitlements.count_feature_companies( + feature_id="feature_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "feature-companies/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "feature-companies/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountFeatureCompaniesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "feature_id": feature_id, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountFeatureCompaniesResponse, + parse_obj_as( + type_=CountFeatureCompaniesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2640,7 +3047,7 @@ async def list_feature_usage( self, *, company_id: typing.Optional[str] = None, - company_keys: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None, + company_keys: typing.Optional[typing.Dict[str, str]] = None, feature_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, q: typing.Optional[str] = None, limit: typing.Optional[int] = None, @@ -2652,7 +3059,7 @@ async def list_feature_usage( ---------- company_id : typing.Optional[str] - company_keys : typing.Optional[typing.Dict[str, typing.Optional[str]]] + company_keys : typing.Optional[typing.Dict[str, str]] feature_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] @@ -2674,64 +3081,83 @@ async def list_feature_usage( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.list_feature_usage() + + + async def main() -> None: + await client.entitlements.list_feature_usage() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "feature-usage", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "feature-usage"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "company_keys": jsonable_encoder(company_keys), - "feature_ids": feature_ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListFeatureUsageResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "company_keys": company_keys, + "feature_ids": feature_ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListFeatureUsageResponse, + parse_obj_as( + type_=ListFeatureUsageResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2741,7 +3167,7 @@ async def count_feature_usage( self, *, company_id: typing.Optional[str] = None, - company_keys: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None, + company_keys: typing.Optional[typing.Dict[str, str]] = None, feature_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, q: typing.Optional[str] = None, limit: typing.Optional[int] = None, @@ -2753,7 +3179,7 @@ async def count_feature_usage( ---------- company_id : typing.Optional[str] - company_keys : typing.Optional[typing.Dict[str, typing.Optional[str]]] + company_keys : typing.Optional[typing.Dict[str, str]] feature_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] @@ -2775,64 +3201,83 @@ async def count_feature_usage( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.count_feature_usage() + + + async def main() -> None: + await client.entitlements.count_feature_usage() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "feature-usage/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "feature-usage/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "company_keys": jsonable_encoder(company_keys), - "feature_ids": feature_ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountFeatureUsageResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "company_id": company_id, + "company_keys": company_keys, + "feature_ids": feature_ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountFeatureUsageResponse, + parse_obj_as( + type_=CountFeatureUsageResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2870,64 +3315,83 @@ async def list_feature_users( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.list_feature_users( - feature_id="feature_id", - ) + + + async def main() -> None: + await client.entitlements.list_feature_users( + feature_id="feature_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "feature-users", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "feature-users"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListFeatureUsersResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "feature_id": feature_id, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListFeatureUsersResponse, + parse_obj_as( + type_=ListFeatureUsersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2965,64 +3429,83 @@ async def count_feature_users( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.count_feature_users( - feature_id="feature_id", - ) + + + async def main() -> None: + await client.entitlements.count_feature_users( + feature_id="feature_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "feature-users/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "feature-users/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountFeatureUsersResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "feature_id": feature_id, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountFeatureUsersResponse, + parse_obj_as( + type_=CountFeatureUsersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3072,66 +3555,85 @@ async def list_plan_entitlements( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.list_plan_entitlements() + + + async def main() -> None: + await client.entitlements.list_plan_entitlements() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "plan-entitlements", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "plan-entitlements"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "feature_ids": feature_ids, - "ids": ids, - "plan_id": plan_id, - "plan_ids": plan_ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListPlanEntitlementsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "feature_id": feature_id, + "feature_ids": feature_ids, + "ids": ids, + "plan_id": plan_id, + "plan_ids": plan_ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListPlanEntitlementsResponse, + parse_obj_as( + type_=ListPlanEntitlementsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3176,73 +3678,89 @@ async def create_plan_entitlement( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.create_plan_entitlement( - feature_id="feature_id", - plan_id="plan_id", - value_type="Boolean", - ) - """ - _request: typing.Dict[str, typing.Any] = { - "feature_id": feature_id, - "plan_id": plan_id, - "value_type": value_type, - } - if metric_period is not OMIT: - _request["metric_period"] = metric_period - if value_bool is not OMIT: - _request["value_bool"] = value_bool - if value_numeric is not OMIT: - _request["value_numeric"] = value_numeric - if value_trait_id is not OMIT: - _request["value_trait_id"] = value_trait_id + + + async def main() -> None: + await client.entitlements.create_plan_entitlement( + feature_id="feature_id", + plan_id="plan_id", + value_type="boolean", + ) + + + asyncio.run(main()) + """ _response = await self._client_wrapper.httpx_client.request( + "plan-entitlements", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "plan-entitlements"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "feature_id": feature_id, + "metric_period": metric_period, + "plan_id": plan_id, + "value_bool": value_bool, + "value_numeric": value_numeric, + "value_trait_id": value_trait_id, + "value_type": value_type, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreatePlanEntitlementResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreatePlanEntitlementResponse, + parse_obj_as( + type_=CreatePlanEntitlementResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3267,54 +3785,77 @@ async def get_plan_entitlement( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.get_plan_entitlement( - plan_entitlement_id="plan_entitlement_id", - ) + + + async def main() -> None: + await client.entitlements.get_plan_entitlement( + plan_entitlement_id="plan_entitlement_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"plan-entitlements/{jsonable_encoder(plan_entitlement_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"plan-entitlements/{jsonable_encoder(plan_entitlement_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetPlanEntitlementResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetPlanEntitlementResponse, + parse_obj_as( + type_=GetPlanEntitlementResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3357,72 +3898,96 @@ async def update_plan_entitlement( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.update_plan_entitlement( - plan_entitlement_id="plan_entitlement_id", - value_type="Boolean", - ) - """ - _request: typing.Dict[str, typing.Any] = {"value_type": value_type} - if metric_period is not OMIT: - _request["metric_period"] = metric_period - if value_bool is not OMIT: - _request["value_bool"] = value_bool - if value_numeric is not OMIT: - _request["value_numeric"] = value_numeric - if value_trait_id is not OMIT: - _request["value_trait_id"] = value_trait_id + + + async def main() -> None: + await client.entitlements.update_plan_entitlement( + plan_entitlement_id="plan_entitlement_id", + value_type="boolean", + ) + + + asyncio.run(main()) + """ _response = await self._client_wrapper.httpx_client.request( + f"plan-entitlements/{jsonable_encoder(plan_entitlement_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"plan-entitlements/{jsonable_encoder(plan_entitlement_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "metric_period": metric_period, + "value_bool": value_bool, + "value_numeric": value_numeric, + "value_trait_id": value_trait_id, + "value_type": value_type, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdatePlanEntitlementResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdatePlanEntitlementResponse, + parse_obj_as( + type_=UpdatePlanEntitlementResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3447,54 +4012,77 @@ async def delete_plan_entitlement( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.delete_plan_entitlement( - plan_entitlement_id="plan_entitlement_id", - ) + + + async def main() -> None: + await client.entitlements.delete_plan_entitlement( + plan_entitlement_id="plan_entitlement_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"plan-entitlements/{jsonable_encoder(plan_entitlement_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"plan-entitlements/{jsonable_encoder(plan_entitlement_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeletePlanEntitlementResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeletePlanEntitlementResponse, + parse_obj_as( + type_=DeletePlanEntitlementResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3544,78 +4132,100 @@ async def count_plan_entitlements( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.count_plan_entitlements() + + + async def main() -> None: + await client.entitlements.count_plan_entitlements() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "plan-entitlements/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "plan-entitlements/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "feature_ids": feature_ids, - "ids": ids, - "plan_id": plan_id, - "plan_ids": plan_ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountPlanEntitlementsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "feature_id": feature_id, + "feature_ids": feature_ids, + "ids": ids, + "plan_id": plan_id, + "plan_ids": plan_ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountPlanEntitlementsResponse, + parse_obj_as( + type_=CountPlanEntitlementsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) async def get_feature_usage_by_company( - self, *, keys: typing.Dict[str, typing.Any], request_options: typing.Optional[RequestOptions] = None + self, + *, + keys: typing.Dict[str, typing.Optional[typing.Any]], + request_options: typing.Optional[RequestOptions] = None, ) -> GetFeatureUsageByCompanyResponse: """ Parameters ---------- - keys : typing.Dict[str, typing.Any] + keys : typing.Dict[str, typing.Optional[typing.Any]] Key/value pairs request_options : typing.Optional[RequestOptions] @@ -3628,61 +4238,80 @@ async def get_feature_usage_by_company( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.entitlements.get_feature_usage_by_company( - keys={"string": {"key": "value"}}, - ) + + + async def main() -> None: + await client.entitlements.get_feature_usage_by_company( + keys={"string": {"key": "value"}}, + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "usage-by-company", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "usage-by-company"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "keys": jsonable_encoder(keys), - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetFeatureUsageByCompanyResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) + params={ + "keys": keys, + }, + request_options=request_options, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetFeatureUsageByCompanyResponse, + parse_obj_as( + type_=GetFeatureUsageByCompanyResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) diff --git a/src/schematic/entitlements/types/count_company_overrides_params.py b/src/schematic/entitlements/types/count_company_overrides_params.py index 9e06bfc..233d8fd 100644 --- a/src/schematic/entitlements/types/count_company_overrides_params.py +++ b/src/schematic/entitlements/types/count_company_overrides_params.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountCompanyOverridesParams(pydantic_v1.BaseModel): +class CountCompanyOverridesParams(UniversalBaseModel): """ Input parameters """ @@ -17,30 +16,23 @@ class CountCompanyOverridesParams(pydantic_v1.BaseModel): feature_id: typing.Optional[str] = None feature_ids: typing.Optional[typing.List[str]] = None ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + q: typing.Optional[str] = None - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/count_company_overrides_response.py b/src/schematic/entitlements/types/count_company_overrides_response.py index ca91114..d6bfe6e 100644 --- a/src/schematic/entitlements/types/count_company_overrides_response.py +++ b/src/schematic/entitlements/types/count_company_overrides_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_company_overrides_params import CountCompanyOverridesParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountCompanyOverridesResponse(pydantic_v1.BaseModel): +class CountCompanyOverridesResponse(UniversalBaseModel): data: CountResponse - params: CountCompanyOverridesParams = pydantic_v1.Field() + params: CountCompanyOverridesParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/count_feature_companies_params.py b/src/schematic/entitlements/types/count_feature_companies_params.py index 6040801..5df5756 100644 --- a/src/schematic/entitlements/types/count_feature_companies_params.py +++ b/src/schematic/entitlements/types/count_feature_companies_params.py @@ -1,44 +1,34 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountFeatureCompaniesParams(pydantic_v1.BaseModel): +class CountFeatureCompaniesParams(UniversalBaseModel): """ Input parameters """ feature_id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/count_feature_companies_response.py b/src/schematic/entitlements/types/count_feature_companies_response.py index b12b167..662ecc4 100644 --- a/src/schematic/entitlements/types/count_feature_companies_response.py +++ b/src/schematic/entitlements/types/count_feature_companies_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_feature_companies_params import CountFeatureCompaniesParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountFeatureCompaniesResponse(pydantic_v1.BaseModel): +class CountFeatureCompaniesResponse(UniversalBaseModel): data: CountResponse - params: CountFeatureCompaniesParams = pydantic_v1.Field() + params: CountFeatureCompaniesParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/count_feature_usage_params.py b/src/schematic/entitlements/types/count_feature_usage_params.py index 600db58..8517092 100644 --- a/src/schematic/entitlements/types/count_feature_usage_params.py +++ b/src/schematic/entitlements/types/count_feature_usage_params.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountFeatureUsageParams(pydantic_v1.BaseModel): +class CountFeatureUsageParams(UniversalBaseModel): """ Input parameters """ @@ -15,32 +14,23 @@ class CountFeatureUsageParams(pydantic_v1.BaseModel): company_id: typing.Optional[str] = None company_keys: typing.Optional[typing.Dict[str, str]] = None feature_ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/count_feature_usage_response.py b/src/schematic/entitlements/types/count_feature_usage_response.py index 7460ca0..5e1855b 100644 --- a/src/schematic/entitlements/types/count_feature_usage_response.py +++ b/src/schematic/entitlements/types/count_feature_usage_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_feature_usage_params import CountFeatureUsageParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountFeatureUsageResponse(pydantic_v1.BaseModel): +class CountFeatureUsageResponse(UniversalBaseModel): data: CountResponse - params: CountFeatureUsageParams = pydantic_v1.Field() + params: CountFeatureUsageParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/count_feature_users_params.py b/src/schematic/entitlements/types/count_feature_users_params.py index 19c359d..cee3afd 100644 --- a/src/schematic/entitlements/types/count_feature_users_params.py +++ b/src/schematic/entitlements/types/count_feature_users_params.py @@ -1,44 +1,34 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountFeatureUsersParams(pydantic_v1.BaseModel): +class CountFeatureUsersParams(UniversalBaseModel): """ Input parameters """ feature_id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/count_feature_users_response.py b/src/schematic/entitlements/types/count_feature_users_response.py index aba3d83..491b957 100644 --- a/src/schematic/entitlements/types/count_feature_users_response.py +++ b/src/schematic/entitlements/types/count_feature_users_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_feature_users_params import CountFeatureUsersParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountFeatureUsersResponse(pydantic_v1.BaseModel): +class CountFeatureUsersResponse(UniversalBaseModel): data: CountResponse - params: CountFeatureUsersParams = pydantic_v1.Field() + params: CountFeatureUsersParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/count_plan_entitlements_params.py b/src/schematic/entitlements/types/count_plan_entitlements_params.py index db2f7c2..ff8cb5a 100644 --- a/src/schematic/entitlements/types/count_plan_entitlements_params.py +++ b/src/schematic/entitlements/types/count_plan_entitlements_params.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountPlanEntitlementsParams(pydantic_v1.BaseModel): +class CountPlanEntitlementsParams(UniversalBaseModel): """ Input parameters """ @@ -15,12 +14,12 @@ class CountPlanEntitlementsParams(pydantic_v1.BaseModel): feature_id: typing.Optional[str] = None feature_ids: typing.Optional[typing.List[str]] = None ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ @@ -29,20 +28,11 @@ class CountPlanEntitlementsParams(pydantic_v1.BaseModel): plan_ids: typing.Optional[typing.List[str]] = None q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/count_plan_entitlements_response.py b/src/schematic/entitlements/types/count_plan_entitlements_response.py index 3d7ac75..5189bb5 100644 --- a/src/schematic/entitlements/types/count_plan_entitlements_response.py +++ b/src/schematic/entitlements/types/count_plan_entitlements_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_plan_entitlements_params import CountPlanEntitlementsParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountPlanEntitlementsResponse(pydantic_v1.BaseModel): +class CountPlanEntitlementsResponse(UniversalBaseModel): data: CountResponse - params: CountPlanEntitlementsParams = pydantic_v1.Field() + params: CountPlanEntitlementsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/create_company_override_request_body_value_type.py b/src/schematic/entitlements/types/create_company_override_request_body_value_type.py index 171fa30..5038dbf 100644 --- a/src/schematic/entitlements/types/create_company_override_request_body_value_type.py +++ b/src/schematic/entitlements/types/create_company_override_request_body_value_type.py @@ -3,5 +3,5 @@ import typing CreateCompanyOverrideRequestBodyValueType = typing.Union[ - typing.Literal["Boolean", "Numeric", "Trait", "Unlimited"], typing.Any + typing.Literal["boolean", "numeric", "trait", "unlimited"], typing.Any ] diff --git a/src/schematic/entitlements/types/create_company_override_response.py b/src/schematic/entitlements/types/create_company_override_response.py index a6591f9..0fa887b 100644 --- a/src/schematic/entitlements/types/create_company_override_response.py +++ b/src/schematic/entitlements/types/create_company_override_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.company_override_response_data import CompanyOverrideResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CreateCompanyOverrideResponse(pydantic_v1.BaseModel): +class CreateCompanyOverrideResponse(UniversalBaseModel): data: CompanyOverrideResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/create_plan_entitlement_request_body_value_type.py b/src/schematic/entitlements/types/create_plan_entitlement_request_body_value_type.py index 8c599a3..3521092 100644 --- a/src/schematic/entitlements/types/create_plan_entitlement_request_body_value_type.py +++ b/src/schematic/entitlements/types/create_plan_entitlement_request_body_value_type.py @@ -3,5 +3,5 @@ import typing CreatePlanEntitlementRequestBodyValueType = typing.Union[ - typing.Literal["Boolean", "Numeric", "Trait", "Unlimited"], typing.Any + typing.Literal["boolean", "numeric", "trait", "unlimited"], typing.Any ] diff --git a/src/schematic/entitlements/types/create_plan_entitlement_response.py b/src/schematic/entitlements/types/create_plan_entitlement_response.py index dfa47e8..da6079d 100644 --- a/src/schematic/entitlements/types/create_plan_entitlement_response.py +++ b/src/schematic/entitlements/types/create_plan_entitlement_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.plan_entitlement_response_data import PlanEntitlementResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CreatePlanEntitlementResponse(pydantic_v1.BaseModel): +class CreatePlanEntitlementResponse(UniversalBaseModel): data: PlanEntitlementResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/delete_company_override_response.py b/src/schematic/entitlements/types/delete_company_override_response.py index 30d0693..403e080 100644 --- a/src/schematic/entitlements/types/delete_company_override_response.py +++ b/src/schematic/entitlements/types/delete_company_override_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.delete_response import DeleteResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class DeleteCompanyOverrideResponse(pydantic_v1.BaseModel): +class DeleteCompanyOverrideResponse(UniversalBaseModel): data: DeleteResponse - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/delete_plan_entitlement_response.py b/src/schematic/entitlements/types/delete_plan_entitlement_response.py index 2684928..a03b992 100644 --- a/src/schematic/entitlements/types/delete_plan_entitlement_response.py +++ b/src/schematic/entitlements/types/delete_plan_entitlement_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.delete_response import DeleteResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class DeletePlanEntitlementResponse(pydantic_v1.BaseModel): +class DeletePlanEntitlementResponse(UniversalBaseModel): data: DeleteResponse - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/get_company_override_response.py b/src/schematic/entitlements/types/get_company_override_response.py index 8c2e167..6d6bc54 100644 --- a/src/schematic/entitlements/types/get_company_override_response.py +++ b/src/schematic/entitlements/types/get_company_override_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.company_override_response_data import CompanyOverrideResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetCompanyOverrideResponse(pydantic_v1.BaseModel): +class GetCompanyOverrideResponse(UniversalBaseModel): data: CompanyOverrideResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/get_feature_usage_by_company_params.py b/src/schematic/entitlements/types/get_feature_usage_by_company_params.py index 7e52791..3e9cdb3 100644 --- a/src/schematic/entitlements/types/get_feature_usage_by_company_params.py +++ b/src/schematic/entitlements/types/get_feature_usage_by_company_params.py @@ -1,33 +1,23 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class GetFeatureUsageByCompanyParams(pydantic_v1.BaseModel): +class GetFeatureUsageByCompanyParams(UniversalBaseModel): """ Input parameters """ - keys: typing.Optional[typing.Dict[str, typing.Any]] = None - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + keys: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/get_feature_usage_by_company_response.py b/src/schematic/entitlements/types/get_feature_usage_by_company_response.py index 6cb3f0d..55a66dd 100644 --- a/src/schematic/entitlements/types/get_feature_usage_by_company_response.py +++ b/src/schematic/entitlements/types/get_feature_usage_by_company_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.feature_usage_detail_response_data import FeatureUsageDetailResponseData from .get_feature_usage_by_company_params import GetFeatureUsageByCompanyParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class GetFeatureUsageByCompanyResponse(pydantic_v1.BaseModel): +class GetFeatureUsageByCompanyResponse(UniversalBaseModel): data: FeatureUsageDetailResponseData - params: GetFeatureUsageByCompanyParams = pydantic_v1.Field() + params: GetFeatureUsageByCompanyParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/get_plan_entitlement_response.py b/src/schematic/entitlements/types/get_plan_entitlement_response.py index 8cb271b..a22de1f 100644 --- a/src/schematic/entitlements/types/get_plan_entitlement_response.py +++ b/src/schematic/entitlements/types/get_plan_entitlement_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.plan_entitlement_response_data import PlanEntitlementResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetPlanEntitlementResponse(pydantic_v1.BaseModel): +class GetPlanEntitlementResponse(UniversalBaseModel): data: PlanEntitlementResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/list_company_overrides_params.py b/src/schematic/entitlements/types/list_company_overrides_params.py index 49ba0a5..29e57ba 100644 --- a/src/schematic/entitlements/types/list_company_overrides_params.py +++ b/src/schematic/entitlements/types/list_company_overrides_params.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListCompanyOverridesParams(pydantic_v1.BaseModel): +class ListCompanyOverridesParams(UniversalBaseModel): """ Input parameters """ @@ -17,30 +16,23 @@ class ListCompanyOverridesParams(pydantic_v1.BaseModel): feature_id: typing.Optional[str] = None feature_ids: typing.Optional[typing.List[str]] = None ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + q: typing.Optional[str] = None - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/list_company_overrides_response.py b/src/schematic/entitlements/types/list_company_overrides_response.py index c5e130d..eacc268 100644 --- a/src/schematic/entitlements/types/list_company_overrides_response.py +++ b/src/schematic/entitlements/types/list_company_overrides_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.company_override_response_data import CompanyOverrideResponseData +import pydantic from .list_company_overrides_params import ListCompanyOverridesParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListCompanyOverridesResponse(pydantic_v1.BaseModel): - data: typing.List[CompanyOverrideResponseData] = pydantic_v1.Field() +class ListCompanyOverridesResponse(UniversalBaseModel): + data: typing.List[CompanyOverrideResponseData] = pydantic.Field() """ The returned resources """ - params: ListCompanyOverridesParams = pydantic_v1.Field() + params: ListCompanyOverridesParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/list_feature_companies_params.py b/src/schematic/entitlements/types/list_feature_companies_params.py index 6a8780b..dad1e6e 100644 --- a/src/schematic/entitlements/types/list_feature_companies_params.py +++ b/src/schematic/entitlements/types/list_feature_companies_params.py @@ -1,44 +1,34 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListFeatureCompaniesParams(pydantic_v1.BaseModel): +class ListFeatureCompaniesParams(UniversalBaseModel): """ Input parameters """ feature_id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/list_feature_companies_response.py b/src/schematic/entitlements/types/list_feature_companies_response.py index b369f43..79750eb 100644 --- a/src/schematic/entitlements/types/list_feature_companies_response.py +++ b/src/schematic/entitlements/types/list_feature_companies_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.feature_company_response_data import FeatureCompanyResponseData +import pydantic from .list_feature_companies_params import ListFeatureCompaniesParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListFeatureCompaniesResponse(pydantic_v1.BaseModel): - data: typing.List[FeatureCompanyResponseData] = pydantic_v1.Field() +class ListFeatureCompaniesResponse(UniversalBaseModel): + data: typing.List[FeatureCompanyResponseData] = pydantic.Field() """ The returned resources """ - params: ListFeatureCompaniesParams = pydantic_v1.Field() + params: ListFeatureCompaniesParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/list_feature_usage_params.py b/src/schematic/entitlements/types/list_feature_usage_params.py index 2749f61..51041ff 100644 --- a/src/schematic/entitlements/types/list_feature_usage_params.py +++ b/src/schematic/entitlements/types/list_feature_usage_params.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListFeatureUsageParams(pydantic_v1.BaseModel): +class ListFeatureUsageParams(UniversalBaseModel): """ Input parameters """ @@ -15,32 +14,23 @@ class ListFeatureUsageParams(pydantic_v1.BaseModel): company_id: typing.Optional[str] = None company_keys: typing.Optional[typing.Dict[str, str]] = None feature_ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/list_feature_usage_response.py b/src/schematic/entitlements/types/list_feature_usage_response.py index ba176dc..3d9f277 100644 --- a/src/schematic/entitlements/types/list_feature_usage_response.py +++ b/src/schematic/entitlements/types/list_feature_usage_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.feature_usage_response_data import FeatureUsageResponseData +import pydantic from .list_feature_usage_params import ListFeatureUsageParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListFeatureUsageResponse(pydantic_v1.BaseModel): - data: typing.List[FeatureUsageResponseData] = pydantic_v1.Field() +class ListFeatureUsageResponse(UniversalBaseModel): + data: typing.List[FeatureUsageResponseData] = pydantic.Field() """ The returned resources """ - params: ListFeatureUsageParams = pydantic_v1.Field() + params: ListFeatureUsageParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/list_feature_users_params.py b/src/schematic/entitlements/types/list_feature_users_params.py index b9fd8b8..54b753e 100644 --- a/src/schematic/entitlements/types/list_feature_users_params.py +++ b/src/schematic/entitlements/types/list_feature_users_params.py @@ -1,44 +1,34 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListFeatureUsersParams(pydantic_v1.BaseModel): +class ListFeatureUsersParams(UniversalBaseModel): """ Input parameters """ feature_id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/list_feature_users_response.py b/src/schematic/entitlements/types/list_feature_users_response.py index 3ce9a7c..dabc217 100644 --- a/src/schematic/entitlements/types/list_feature_users_response.py +++ b/src/schematic/entitlements/types/list_feature_users_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.feature_company_user_response_data import FeatureCompanyUserResponseData +import pydantic from .list_feature_users_params import ListFeatureUsersParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListFeatureUsersResponse(pydantic_v1.BaseModel): - data: typing.List[FeatureCompanyUserResponseData] = pydantic_v1.Field() +class ListFeatureUsersResponse(UniversalBaseModel): + data: typing.List[FeatureCompanyUserResponseData] = pydantic.Field() """ The returned resources """ - params: ListFeatureUsersParams = pydantic_v1.Field() + params: ListFeatureUsersParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/list_plan_entitlements_params.py b/src/schematic/entitlements/types/list_plan_entitlements_params.py index dd37124..f296e20 100644 --- a/src/schematic/entitlements/types/list_plan_entitlements_params.py +++ b/src/schematic/entitlements/types/list_plan_entitlements_params.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListPlanEntitlementsParams(pydantic_v1.BaseModel): +class ListPlanEntitlementsParams(UniversalBaseModel): """ Input parameters """ @@ -15,12 +14,12 @@ class ListPlanEntitlementsParams(pydantic_v1.BaseModel): feature_id: typing.Optional[str] = None feature_ids: typing.Optional[typing.List[str]] = None ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ @@ -29,20 +28,11 @@ class ListPlanEntitlementsParams(pydantic_v1.BaseModel): plan_ids: typing.Optional[typing.List[str]] = None q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/list_plan_entitlements_response.py b/src/schematic/entitlements/types/list_plan_entitlements_response.py index f71c0b3..8429b46 100644 --- a/src/schematic/entitlements/types/list_plan_entitlements_response.py +++ b/src/schematic/entitlements/types/list_plan_entitlements_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.plan_entitlement_response_data import PlanEntitlementResponseData +import pydantic from .list_plan_entitlements_params import ListPlanEntitlementsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListPlanEntitlementsResponse(pydantic_v1.BaseModel): - data: typing.List[PlanEntitlementResponseData] = pydantic_v1.Field() +class ListPlanEntitlementsResponse(UniversalBaseModel): + data: typing.List[PlanEntitlementResponseData] = pydantic.Field() """ The returned resources """ - params: ListPlanEntitlementsParams = pydantic_v1.Field() + params: ListPlanEntitlementsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/update_company_override_request_body_value_type.py b/src/schematic/entitlements/types/update_company_override_request_body_value_type.py index ac30476..1f09ef4 100644 --- a/src/schematic/entitlements/types/update_company_override_request_body_value_type.py +++ b/src/schematic/entitlements/types/update_company_override_request_body_value_type.py @@ -3,5 +3,5 @@ import typing UpdateCompanyOverrideRequestBodyValueType = typing.Union[ - typing.Literal["Boolean", "Numeric", "Trait", "Unlimited"], typing.Any + typing.Literal["boolean", "numeric", "trait", "unlimited"], typing.Any ] diff --git a/src/schematic/entitlements/types/update_company_override_response.py b/src/schematic/entitlements/types/update_company_override_response.py index ad365bd..f144bf1 100644 --- a/src/schematic/entitlements/types/update_company_override_response.py +++ b/src/schematic/entitlements/types/update_company_override_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.company_override_response_data import CompanyOverrideResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpdateCompanyOverrideResponse(pydantic_v1.BaseModel): +class UpdateCompanyOverrideResponse(UniversalBaseModel): data: CompanyOverrideResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/entitlements/types/update_plan_entitlement_request_body_value_type.py b/src/schematic/entitlements/types/update_plan_entitlement_request_body_value_type.py index 31e2c6b..4c5c93b 100644 --- a/src/schematic/entitlements/types/update_plan_entitlement_request_body_value_type.py +++ b/src/schematic/entitlements/types/update_plan_entitlement_request_body_value_type.py @@ -3,5 +3,5 @@ import typing UpdatePlanEntitlementRequestBodyValueType = typing.Union[ - typing.Literal["Boolean", "Numeric", "Trait", "Unlimited"], typing.Any + typing.Literal["boolean", "numeric", "trait", "unlimited"], typing.Any ] diff --git a/src/schematic/entitlements/types/update_plan_entitlement_response.py b/src/schematic/entitlements/types/update_plan_entitlement_response.py index aed406d..3c1f681 100644 --- a/src/schematic/entitlements/types/update_plan_entitlement_response.py +++ b/src/schematic/entitlements/types/update_plan_entitlement_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.plan_entitlement_response_data import PlanEntitlementResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpdatePlanEntitlementResponse(pydantic_v1.BaseModel): +class UpdatePlanEntitlementResponse(UniversalBaseModel): data: PlanEntitlementResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/events/client.py b/src/schematic/events/client.py index d47f5c5..dd2be10 100644 --- a/src/schematic/events/client.py +++ b/src/schematic/events/client.py @@ -1,35 +1,33 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt import typing -import urllib.parse -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.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 -from ..core.query_encoder import encode_query -from ..core.remove_none_from_dict import remove_none_from_dict +from ..core.client_wrapper import SyncClientWrapper +from ..types.create_event_request_body import CreateEventRequestBody from ..core.request_options import RequestOptions +from .types.create_event_batch_response import CreateEventBatchResponse +from ..core.serialization import convert_and_respect_annotation_metadata +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 ..errors.forbidden_error import ForbiddenError 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.get_event_summaries_response import GetEventSummariesResponse +from .types.get_event_summary_by_subtype_response import GetEventSummaryBySubtypeResponse +from ..core.jsonable_encoder import jsonable_encoder 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.create_event_request_body import CreateEventRequestBody +from .types.list_events_response import ListEventsResponse from ..types.create_event_request_body_event_type import CreateEventRequestBodyEventType from ..types.event_body import EventBody -from .types.create_event_batch_response import CreateEventBatchResponse +import datetime as dt from .types.create_event_response import CreateEventResponse from .types.get_event_response import GetEventResponse -from .types.get_event_summaries_response import GetEventSummariesResponse -from .types.get_event_summary_by_subtype_response import GetEventSummaryBySubtypeResponse -from .types.get_segment_integration_status_response import GetSegmentIntegrationStatusResponse -from .types.list_events_response import ListEventsResponse from .types.list_metric_counts_response import ListMetricCountsResponse +from ..core.datetime_utils import serialize_datetime +from .types.get_segment_integration_status_response import GetSegmentIntegrationStatusResponse +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -60,8 +58,7 @@ def create_event_batch( Examples -------- - from schematic import CreateEventRequestBody - from schematic.client import Schematic + from schematic import CreateEventRequestBody, Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -75,48 +72,65 @@ def create_event_batch( ) """ _response = self._client_wrapper.httpx_client.request( + "event-batch", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "event-batch"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder({"events": events}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"events": events}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "events": convert_and_respect_annotation_metadata( + object_=events, annotation=typing.Sequence[CreateEventRequestBody], direction="write" + ), }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateEventBatchResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateEventBatchResponse, + parse_obj_as( + type_=CreateEventBatchResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -154,7 +168,7 @@ def get_event_summaries( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -162,54 +176,65 @@ def get_event_summaries( client.events.get_event_summaries() """ _response = self._client_wrapper.httpx_client.request( + "event-types", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "event-types"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "q": q, - "event_subtypes": event_subtypes, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "q": q, + "event_subtypes": event_subtypes, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetEventSummariesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetEventSummariesResponse, + parse_obj_as( + type_=GetEventSummariesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -234,7 +259,7 @@ def get_event_summary_by_subtype( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -244,42 +269,59 @@ def get_event_summary_by_subtype( ) """ _response = self._client_wrapper.httpx_client.request( + f"event-types/{jsonable_encoder(key)}", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"event-types/{jsonable_encoder(key)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetEventSummaryBySubtypeResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetEventSummaryBySubtypeResponse, + parse_obj_as( + type_=GetEventSummaryBySubtypeResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -289,8 +331,10 @@ def list_events( self, *, company_id: typing.Optional[str] = None, - user_id: typing.Optional[str] = None, event_subtype: typing.Optional[str] = None, + event_types: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + flag_id: typing.Optional[str] = None, + user_id: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -300,10 +344,14 @@ def list_events( ---------- company_id : typing.Optional[str] - user_id : typing.Optional[str] - event_subtype : typing.Optional[str] + event_types : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + flag_id : typing.Optional[str] + + user_id : typing.Optional[str] + limit : typing.Optional[int] Page limit (default 100) @@ -320,7 +368,7 @@ def list_events( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -328,55 +376,68 @@ def list_events( client.events.list_events() """ _response = self._client_wrapper.httpx_client.request( + "events", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "events"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "user_id": user_id, - "event_subtype": event_subtype, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "company_id": company_id, + "event_subtype": event_subtype, + "event_types": event_types, + "flag_id": flag_id, + "user_id": user_id, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListEventsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListEventsResponse, + parse_obj_as( + type_=ListEventsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -411,7 +472,7 @@ def create_event( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -420,54 +481,66 @@ def create_event( event_type="identify", ) """ - _request: typing.Dict[str, typing.Any] = {"event_type": event_type} - if body is not OMIT: - _request["body"] = body - if sent_at is not OMIT: - _request["sent_at"] = sent_at _response = self._client_wrapper.httpx_client.request( + "events", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "events"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "body": convert_and_respect_annotation_metadata(object_=body, annotation=EventBody, direction="write"), + "event_type": event_type, + "sent_at": sent_at, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateEventResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateEventResponse, + parse_obj_as( + type_=CreateEventResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -490,7 +563,7 @@ def get_event(self, event_id: str, *, request_options: typing.Optional[RequestOp Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -500,42 +573,59 @@ def get_event(self, event_id: str, *, request_options: typing.Optional[RequestOp ) """ _response = self._client_wrapper.httpx_client.request( + f"events/{jsonable_encoder(event_id)}", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"events/{jsonable_encoder(event_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetEventResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetEventResponse, + parse_obj_as( + type_=GetEventResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -591,7 +681,7 @@ def list_metric_counts( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -599,60 +689,71 @@ def list_metric_counts( client.events.list_metric_counts() """ _response = self._client_wrapper.httpx_client.request( + "metric-counts", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "metric-counts"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "start_time": serialize_datetime(start_time) if start_time is not None else None, - "end_time": serialize_datetime(end_time) if end_time is not None else None, - "event_subtype": event_subtype, - "event_subtypes": event_subtypes, - "company_id": company_id, - "company_ids": company_ids, - "user_id": user_id, - "limit": limit, - "offset": offset, - "grouping": grouping, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "start_time": serialize_datetime(start_time) if start_time is not None else None, + "end_time": serialize_datetime(end_time) if end_time is not None else None, + "event_subtype": event_subtype, + "event_subtypes": event_subtypes, + "company_id": company_id, + "company_ids": company_ids, + "user_id": user_id, + "limit": limit, + "offset": offset, + "grouping": grouping, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListMetricCountsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListMetricCountsResponse, + parse_obj_as( + type_=ListMetricCountsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -674,7 +775,7 @@ def get_segment_integration_status( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -682,42 +783,59 @@ def get_segment_integration_status( client.events.get_segment_integration_status() """ _response = self._client_wrapper.httpx_client.request( + "segment-integration", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "segment-integration"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetSegmentIntegrationStatusResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetSegmentIntegrationStatusResponse, + parse_obj_as( + type_=GetSegmentIntegrationStatusResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -749,63 +867,87 @@ async def create_event_batch( Examples -------- - from schematic import CreateEventRequestBody - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic, CreateEventRequestBody client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.events.create_event_batch( - events=[ - CreateEventRequestBody( - event_type="identify", - ) - ], - ) + + + async def main() -> None: + await client.events.create_event_batch( + events=[ + CreateEventRequestBody( + event_type="identify", + ) + ], + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "event-batch", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "event-batch"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder({"events": events}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"events": events}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "events": convert_and_respect_annotation_metadata( + object_=events, annotation=typing.Sequence[CreateEventRequestBody], direction="write" + ), }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateEventBatchResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateEventBatchResponse, + parse_obj_as( + type_=CreateEventBatchResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -843,62 +985,81 @@ async def get_event_summaries( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.events.get_event_summaries() + + + async def main() -> None: + await client.events.get_event_summaries() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "event-types", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "event-types"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "q": q, - "event_subtypes": event_subtypes, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "q": q, + "event_subtypes": event_subtypes, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetEventSummariesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetEventSummariesResponse, + parse_obj_as( + type_=GetEventSummariesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -923,52 +1084,77 @@ async def get_event_summary_by_subtype( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.events.get_event_summary_by_subtype( - key="key", - ) + + + async def main() -> None: + await client.events.get_event_summary_by_subtype( + key="key", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"event-types/{jsonable_encoder(key)}", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"event-types/{jsonable_encoder(key)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetEventSummaryBySubtypeResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetEventSummaryBySubtypeResponse, + parse_obj_as( + type_=GetEventSummaryBySubtypeResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -978,8 +1164,10 @@ async def list_events( self, *, company_id: typing.Optional[str] = None, - user_id: typing.Optional[str] = None, event_subtype: typing.Optional[str] = None, + event_types: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + flag_id: typing.Optional[str] = None, + user_id: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -989,10 +1177,14 @@ async def list_events( ---------- company_id : typing.Optional[str] - user_id : typing.Optional[str] - event_subtype : typing.Optional[str] + event_types : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + flag_id : typing.Optional[str] + + user_id : typing.Optional[str] + limit : typing.Optional[int] Page limit (default 100) @@ -1009,63 +1201,84 @@ async def list_events( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.events.list_events() + + + async def main() -> None: + await client.events.list_events() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "events", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "events"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "user_id": user_id, - "event_subtype": event_subtype, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "company_id": company_id, + "event_subtype": event_subtype, + "event_types": event_types, + "flag_id": flag_id, + "user_id": user_id, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListEventsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListEventsResponse, + parse_obj_as( + type_=ListEventsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1100,63 +1313,83 @@ async def create_event( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.events.create_event( - event_type="identify", - ) + + + async def main() -> None: + await client.events.create_event( + event_type="identify", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"event_type": event_type} - if body is not OMIT: - _request["body"] = body - if sent_at is not OMIT: - _request["sent_at"] = sent_at _response = await self._client_wrapper.httpx_client.request( + "events", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "events"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "body": convert_and_respect_annotation_metadata(object_=body, annotation=EventBody, direction="write"), + "event_type": event_type, + "sent_at": sent_at, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateEventResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateEventResponse, + parse_obj_as( + type_=CreateEventResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1181,52 +1414,77 @@ async def get_event( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.events.get_event( - event_id="event_id", - ) + + + async def main() -> None: + await client.events.get_event( + event_id="event_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"events/{jsonable_encoder(event_id)}", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"events/{jsonable_encoder(event_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetEventResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetEventResponse, + parse_obj_as( + type_=GetEventResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1282,68 +1540,87 @@ async def list_metric_counts( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.events.list_metric_counts() + + + async def main() -> None: + await client.events.list_metric_counts() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "metric-counts", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "metric-counts"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "start_time": serialize_datetime(start_time) if start_time is not None else None, - "end_time": serialize_datetime(end_time) if end_time is not None else None, - "event_subtype": event_subtype, - "event_subtypes": event_subtypes, - "company_id": company_id, - "company_ids": company_ids, - "user_id": user_id, - "limit": limit, - "offset": offset, - "grouping": grouping, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "start_time": serialize_datetime(start_time) if start_time is not None else None, + "end_time": serialize_datetime(end_time) if end_time is not None else None, + "event_subtype": event_subtype, + "event_subtypes": event_subtypes, + "company_id": company_id, + "company_ids": company_ids, + "user_id": user_id, + "limit": limit, + "offset": offset, + "grouping": grouping, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListMetricCountsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListMetricCountsResponse, + parse_obj_as( + type_=ListMetricCountsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1365,50 +1642,75 @@ async def get_segment_integration_status( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.events.get_segment_integration_status() + + + async def main() -> None: + await client.events.get_segment_integration_status() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "segment-integration", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "segment-integration"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetSegmentIntegrationStatusResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetSegmentIntegrationStatusResponse, + parse_obj_as( + type_=GetSegmentIntegrationStatusResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) diff --git a/src/schematic/events/types/create_event_batch_response.py b/src/schematic/events/types/create_event_batch_response.py index 6a011da..c5f003a 100644 --- a/src/schematic/events/types/create_event_batch_response.py +++ b/src/schematic/events/types/create_event_batch_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.raw_event_batch_response_data import RawEventBatchResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CreateEventBatchResponse(pydantic_v1.BaseModel): +class CreateEventBatchResponse(UniversalBaseModel): data: RawEventBatchResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/events/types/create_event_response.py b/src/schematic/events/types/create_event_response.py index a7aabea..b12cfee 100644 --- a/src/schematic/events/types/create_event_response.py +++ b/src/schematic/events/types/create_event_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.raw_event_response_data import RawEventResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CreateEventResponse(pydantic_v1.BaseModel): +class CreateEventResponse(UniversalBaseModel): data: RawEventResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/events/types/get_event_response.py b/src/schematic/events/types/get_event_response.py index 0cca644..1b97dcd 100644 --- a/src/schematic/events/types/get_event_response.py +++ b/src/schematic/events/types/get_event_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.event_detail_response_data import EventDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetEventResponse(pydantic_v1.BaseModel): +class GetEventResponse(UniversalBaseModel): data: EventDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/events/types/get_event_summaries_params.py b/src/schematic/events/types/get_event_summaries_params.py index 9884df1..366774f 100644 --- a/src/schematic/events/types/get_event_summaries_params.py +++ b/src/schematic/events/types/get_event_summaries_params.py @@ -1,44 +1,34 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class GetEventSummariesParams(pydantic_v1.BaseModel): +class GetEventSummariesParams(UniversalBaseModel): """ Input parameters """ event_subtypes: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/events/types/get_event_summaries_response.py b/src/schematic/events/types/get_event_summaries_response.py index 0124cdc..ca269f8 100644 --- a/src/schematic/events/types/get_event_summaries_response.py +++ b/src/schematic/events/types/get_event_summaries_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.event_summary_response_data import EventSummaryResponseData +import pydantic from .get_event_summaries_params import GetEventSummariesParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetEventSummariesResponse(pydantic_v1.BaseModel): - data: typing.List[EventSummaryResponseData] = pydantic_v1.Field() +class GetEventSummariesResponse(UniversalBaseModel): + data: typing.List[EventSummaryResponseData] = pydantic.Field() """ The returned resources """ - params: GetEventSummariesParams = pydantic_v1.Field() + params: GetEventSummariesParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/events/types/get_event_summary_by_subtype_response.py b/src/schematic/events/types/get_event_summary_by_subtype_response.py index 5d4cf4d..79c807f 100644 --- a/src/schematic/events/types/get_event_summary_by_subtype_response.py +++ b/src/schematic/events/types/get_event_summary_by_subtype_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.event_summary_response_data import EventSummaryResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetEventSummaryBySubtypeResponse(pydantic_v1.BaseModel): +class GetEventSummaryBySubtypeResponse(UniversalBaseModel): data: EventSummaryResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/events/types/get_segment_integration_status_response.py b/src/schematic/events/types/get_segment_integration_status_response.py index 375eb8d..073b835 100644 --- a/src/schematic/events/types/get_segment_integration_status_response.py +++ b/src/schematic/events/types/get_segment_integration_status_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.segment_status_resp import SegmentStatusResp +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetSegmentIntegrationStatusResponse(pydantic_v1.BaseModel): +class GetSegmentIntegrationStatusResponse(UniversalBaseModel): data: SegmentStatusResp - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/events/types/list_events_params.py b/src/schematic/events/types/list_events_params.py index 56fc234..0b3c532 100644 --- a/src/schematic/events/types/list_events_params.py +++ b/src/schematic/events/types/list_events_params.py @@ -1,45 +1,37 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListEventsParams(pydantic_v1.BaseModel): +class ListEventsParams(UniversalBaseModel): """ Input parameters """ company_id: typing.Optional[str] = None event_subtype: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + event_types: typing.Optional[typing.List[str]] = None + flag_id: typing.Optional[str] = None + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ user_id: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/events/types/list_events_response.py b/src/schematic/events/types/list_events_response.py index 7d39ccb..0e4f2f0 100644 --- a/src/schematic/events/types/list_events_response.py +++ b/src/schematic/events/types/list_events_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.event_detail_response_data import EventDetailResponseData +import pydantic from .list_events_params import ListEventsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListEventsResponse(pydantic_v1.BaseModel): - data: typing.List[EventDetailResponseData] = pydantic_v1.Field() +class ListEventsResponse(UniversalBaseModel): + data: typing.List[EventDetailResponseData] = pydantic.Field() """ The returned resources """ - params: ListEventsParams = pydantic_v1.Field() + params: ListEventsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/events/types/list_metric_counts_params.py b/src/schematic/events/types/list_metric_counts_params.py index 902695f..ba226b6 100644 --- a/src/schematic/events/types/list_metric_counts_params.py +++ b/src/schematic/events/types/list_metric_counts_params.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import datetime as dt +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListMetricCountsParams(pydantic_v1.BaseModel): +class ListMetricCountsParams(UniversalBaseModel): """ Input parameters """ @@ -18,12 +18,12 @@ class ListMetricCountsParams(pydantic_v1.BaseModel): event_subtype: typing.Optional[str] = None event_subtypes: typing.Optional[typing.List[str]] = None grouping: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ @@ -31,20 +31,11 @@ class ListMetricCountsParams(pydantic_v1.BaseModel): start_time: typing.Optional[dt.datetime] = None user_id: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/events/types/list_metric_counts_response.py b/src/schematic/events/types/list_metric_counts_response.py index 03726b8..9bfd070 100644 --- a/src/schematic/events/types/list_metric_counts_response.py +++ b/src/schematic/events/types/list_metric_counts_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.metric_counts_hourly_response_data import MetricCountsHourlyResponseData +import pydantic from .list_metric_counts_params import ListMetricCountsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListMetricCountsResponse(pydantic_v1.BaseModel): - data: typing.List[MetricCountsHourlyResponseData] = pydantic_v1.Field() +class ListMetricCountsResponse(UniversalBaseModel): + data: typing.List[MetricCountsHourlyResponseData] = pydantic.Field() """ The returned resources """ - params: ListMetricCountsParams = pydantic_v1.Field() + params: ListMetricCountsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/__init__.py b/src/schematic/features/__init__.py index 6085d6a..bfd873c 100644 --- a/src/schematic/features/__init__.py +++ b/src/schematic/features/__init__.py @@ -7,8 +7,6 @@ CountAudienceUsersResponse, CountFeaturesParams, CountFeaturesResponse, - CountFlagChecksParams, - CountFlagChecksResponse, CountFlagsParams, CountFlagsResponse, CreateFeatureRequestBodyFeatureType, @@ -17,16 +15,11 @@ DeleteFeatureResponse, DeleteFlagResponse, GetFeatureResponse, - GetFlagCheckResponse, GetFlagResponse, - GetLatestFlagChecksParams, - GetLatestFlagChecksResponse, ListAudienceCompaniesResponse, ListAudienceUsersResponse, ListFeaturesParams, ListFeaturesResponse, - ListFlagChecksParams, - ListFlagChecksResponse, ListFlagsParams, ListFlagsResponse, UpdateFeatureRequestBodyFeatureType, @@ -42,8 +35,6 @@ "CountAudienceUsersResponse", "CountFeaturesParams", "CountFeaturesResponse", - "CountFlagChecksParams", - "CountFlagChecksResponse", "CountFlagsParams", "CountFlagsResponse", "CreateFeatureRequestBodyFeatureType", @@ -52,16 +43,11 @@ "DeleteFeatureResponse", "DeleteFlagResponse", "GetFeatureResponse", - "GetFlagCheckResponse", "GetFlagResponse", - "GetLatestFlagChecksParams", - "GetLatestFlagChecksResponse", "ListAudienceCompaniesResponse", "ListAudienceUsersResponse", "ListFeaturesParams", "ListFeaturesResponse", - "ListFlagChecksParams", - "ListFlagChecksResponse", "ListFlagsParams", "ListFlagsResponse", "UpdateFeatureRequestBodyFeatureType", diff --git a/src/schematic/features/client.py b/src/schematic/features/client.py index e5d2694..80f90fc 100644 --- a/src/schematic/features/client.py +++ b/src/schematic/features/client.py @@ -1,51 +1,45 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse -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.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 -from ..core.query_encoder import encode_query -from ..core.remove_none_from_dict import remove_none_from_dict +from ..core.client_wrapper import SyncClientWrapper +from ..types.create_or_update_condition_group_request_body import CreateOrUpdateConditionGroupRequestBody +from ..types.create_or_update_condition_request_body import CreateOrUpdateConditionRequestBody from ..core.request_options import RequestOptions +from .types.count_audience_companies_response import CountAudienceCompaniesResponse +from ..core.serialization import convert_and_respect_annotation_metadata +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 ..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.create_or_update_condition_group_request_body import CreateOrUpdateConditionGroupRequestBody -from ..types.create_or_update_condition_request_body import CreateOrUpdateConditionRequestBody -from ..types.create_or_update_flag_request_body import CreateOrUpdateFlagRequestBody -from ..types.create_or_update_rule_request_body import CreateOrUpdateRuleRequestBody -from .types.check_flag_response import CheckFlagResponse -from .types.check_flags_response import CheckFlagsResponse -from .types.count_audience_companies_response import CountAudienceCompaniesResponse +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError as core_api_error_ApiError from .types.count_audience_users_response import CountAudienceUsersResponse -from .types.count_features_response import CountFeaturesResponse -from .types.count_flag_checks_response import CountFlagChecksResponse -from .types.count_flags_response import CountFlagsResponse -from .types.create_feature_request_body_feature_type import CreateFeatureRequestBodyFeatureType -from .types.create_feature_response import CreateFeatureResponse -from .types.create_flag_response import CreateFlagResponse -from .types.delete_feature_response import DeleteFeatureResponse -from .types.delete_flag_response import DeleteFlagResponse -from .types.get_feature_response import GetFeatureResponse -from .types.get_flag_check_response import GetFlagCheckResponse -from .types.get_flag_response import GetFlagResponse -from .types.get_latest_flag_checks_response import GetLatestFlagChecksResponse from .types.list_audience_companies_response import ListAudienceCompaniesResponse from .types.list_audience_users_response import ListAudienceUsersResponse from .types.list_features_response import ListFeaturesResponse -from .types.list_flag_checks_response import ListFlagChecksResponse -from .types.list_flags_response import ListFlagsResponse +from .types.create_feature_request_body_feature_type import CreateFeatureRequestBodyFeatureType +from ..types.create_or_update_flag_request_body import CreateOrUpdateFlagRequestBody +from .types.create_feature_response import CreateFeatureResponse +from .types.get_feature_response import GetFeatureResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..errors.not_found_error import NotFoundError from .types.update_feature_request_body_feature_type import UpdateFeatureRequestBodyFeatureType from .types.update_feature_response import UpdateFeatureResponse +from .types.delete_feature_response import DeleteFeatureResponse +from .types.count_features_response import CountFeaturesResponse +from .types.list_flags_response import ListFlagsResponse +from .types.create_flag_response import CreateFlagResponse +from .types.get_flag_response import GetFlagResponse from .types.update_flag_response import UpdateFlagResponse +from .types.delete_flag_response import DeleteFlagResponse +from ..types.create_or_update_rule_request_body import CreateOrUpdateRuleRequestBody from .types.update_flag_rules_response import UpdateFlagRulesResponse +from .types.check_flag_response import CheckFlagResponse +from .types.check_flags_response import CheckFlagsResponse +from .types.count_flags_response import CountFlagsResponse +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -93,8 +87,8 @@ def count_audience_companies( from schematic import ( CreateOrUpdateConditionGroupRequestBody, CreateOrUpdateConditionRequestBody, + Schematic, ) - from schematic.client import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -105,7 +99,6 @@ def count_audience_companies( conditions=[ CreateOrUpdateConditionRequestBody( condition_type="company", - metric_value=1, operator="eq", resource_ids=["resource_ids"], ) @@ -115,63 +108,82 @@ def count_audience_companies( conditions=[ CreateOrUpdateConditionRequestBody( condition_type="company", - metric_value=1, operator="eq", resource_ids=["resource_ids"], ) ], ) """ - _request: typing.Dict[str, typing.Any] = {"condition_groups": condition_groups, "conditions": conditions} - if limit is not OMIT: - _request["limit"] = limit - if offset is not OMIT: - _request["offset"] = offset - if q is not OMIT: - _request["q"] = q _response = self._client_wrapper.httpx_client.request( + "audience/count-companies", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "audience/count-companies"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "condition_groups": convert_and_respect_annotation_metadata( + object_=condition_groups, + annotation=typing.Sequence[CreateOrUpdateConditionGroupRequestBody], + direction="write", + ), + "conditions": convert_and_respect_annotation_metadata( + object_=conditions, + annotation=typing.Sequence[CreateOrUpdateConditionRequestBody], + direction="write", + ), + "limit": limit, + "offset": offset, + "q": q, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountAudienceCompaniesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountAudienceCompaniesResponse, + parse_obj_as( + type_=CountAudienceCompaniesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -215,8 +227,8 @@ def count_audience_users( from schematic import ( CreateOrUpdateConditionGroupRequestBody, CreateOrUpdateConditionRequestBody, + Schematic, ) - from schematic.client import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -227,7 +239,6 @@ def count_audience_users( conditions=[ CreateOrUpdateConditionRequestBody( condition_type="company", - metric_value=1, operator="eq", resource_ids=["resource_ids"], ) @@ -237,63 +248,82 @@ def count_audience_users( conditions=[ CreateOrUpdateConditionRequestBody( condition_type="company", - metric_value=1, operator="eq", resource_ids=["resource_ids"], ) ], ) """ - _request: typing.Dict[str, typing.Any] = {"condition_groups": condition_groups, "conditions": conditions} - if limit is not OMIT: - _request["limit"] = limit - if offset is not OMIT: - _request["offset"] = offset - if q is not OMIT: - _request["q"] = q _response = self._client_wrapper.httpx_client.request( + "audience/count-users", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "audience/count-users"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "condition_groups": convert_and_respect_annotation_metadata( + object_=condition_groups, + annotation=typing.Sequence[CreateOrUpdateConditionGroupRequestBody], + direction="write", + ), + "conditions": convert_and_respect_annotation_metadata( + object_=conditions, + annotation=typing.Sequence[CreateOrUpdateConditionRequestBody], + direction="write", + ), + "limit": limit, + "offset": offset, + "q": q, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountAudienceUsersResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountAudienceUsersResponse, + parse_obj_as( + type_=CountAudienceUsersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -337,8 +367,8 @@ def list_audience_companies( from schematic import ( CreateOrUpdateConditionGroupRequestBody, CreateOrUpdateConditionRequestBody, + Schematic, ) - from schematic.client import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -349,7 +379,6 @@ def list_audience_companies( conditions=[ CreateOrUpdateConditionRequestBody( condition_type="company", - metric_value=1, operator="eq", resource_ids=["resource_ids"], ) @@ -359,63 +388,82 @@ def list_audience_companies( conditions=[ CreateOrUpdateConditionRequestBody( condition_type="company", - metric_value=1, operator="eq", resource_ids=["resource_ids"], ) ], ) """ - _request: typing.Dict[str, typing.Any] = {"condition_groups": condition_groups, "conditions": conditions} - if limit is not OMIT: - _request["limit"] = limit - if offset is not OMIT: - _request["offset"] = offset - if q is not OMIT: - _request["q"] = q _response = self._client_wrapper.httpx_client.request( + "audience/get-companies", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "audience/get-companies"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "condition_groups": convert_and_respect_annotation_metadata( + object_=condition_groups, + annotation=typing.Sequence[CreateOrUpdateConditionGroupRequestBody], + direction="write", + ), + "conditions": convert_and_respect_annotation_metadata( + object_=conditions, + annotation=typing.Sequence[CreateOrUpdateConditionRequestBody], + direction="write", + ), + "limit": limit, + "offset": offset, + "q": q, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListAudienceCompaniesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListAudienceCompaniesResponse, + parse_obj_as( + type_=ListAudienceCompaniesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -459,8 +507,8 @@ def list_audience_users( from schematic import ( CreateOrUpdateConditionGroupRequestBody, CreateOrUpdateConditionRequestBody, + Schematic, ) - from schematic.client import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -471,7 +519,6 @@ def list_audience_users( conditions=[ CreateOrUpdateConditionRequestBody( condition_type="company", - metric_value=1, operator="eq", resource_ids=["resource_ids"], ) @@ -481,63 +528,82 @@ def list_audience_users( conditions=[ CreateOrUpdateConditionRequestBody( condition_type="company", - metric_value=1, operator="eq", resource_ids=["resource_ids"], ) ], ) """ - _request: typing.Dict[str, typing.Any] = {"condition_groups": condition_groups, "conditions": conditions} - if limit is not OMIT: - _request["limit"] = limit - if offset is not OMIT: - _request["offset"] = offset - if q is not OMIT: - _request["q"] = q _response = self._client_wrapper.httpx_client.request( + "audience/get-users", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "audience/get-users"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "condition_groups": convert_and_respect_annotation_metadata( + object_=condition_groups, + annotation=typing.Sequence[CreateOrUpdateConditionGroupRequestBody], + direction="write", + ), + "conditions": convert_and_respect_annotation_metadata( + object_=conditions, + annotation=typing.Sequence[CreateOrUpdateConditionRequestBody], + direction="write", + ), + "limit": limit, + "offset": offset, + "q": q, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListAudienceUsersResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListAudienceUsersResponse, + parse_obj_as( + type_=ListAudienceUsersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -583,7 +649,7 @@ def list_features( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -591,56 +657,67 @@ def list_features( client.features.list_features() """ _response = self._client_wrapper.httpx_client.request( + "features", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "features"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "ids": ids, - "q": q, - "without_company_override_for": without_company_override_for, - "without_plan_entitlement_for": without_plan_entitlement_for, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "ids": ids, + "q": q, + "without_company_override_for": without_company_override_for, + "without_plan_entitlement_for": without_plan_entitlement_for, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListFeaturesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListFeaturesResponse, + parse_obj_as( + type_=ListFeaturesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -654,7 +731,9 @@ def create_feature( name: str, event_subtype: typing.Optional[str] = OMIT, flag: typing.Optional[CreateOrUpdateFlagRequestBody] = OMIT, + icon: typing.Optional[str] = OMIT, lifecycle_phase: typing.Optional[str] = OMIT, + maintainer_id: typing.Optional[str] = OMIT, trait_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CreateFeatureResponse: @@ -671,8 +750,12 @@ def create_feature( flag : typing.Optional[CreateOrUpdateFlagRequestBody] + icon : typing.Optional[str] + lifecycle_phase : typing.Optional[str] + maintainer_id : typing.Optional[str] + trait_id : typing.Optional[str] request_options : typing.Optional[RequestOptions] @@ -685,7 +768,7 @@ def create_feature( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -696,62 +779,74 @@ def create_feature( name="name", ) """ - _request: typing.Dict[str, typing.Any] = { - "description": description, - "feature_type": feature_type, - "name": name, - } - if event_subtype is not OMIT: - _request["event_subtype"] = event_subtype - if flag is not OMIT: - _request["flag"] = flag - if lifecycle_phase is not OMIT: - _request["lifecycle_phase"] = lifecycle_phase - if trait_id is not OMIT: - _request["trait_id"] = trait_id _response = self._client_wrapper.httpx_client.request( + "features", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "features"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "description": description, + "event_subtype": event_subtype, + "feature_type": feature_type, + "flag": convert_and_respect_annotation_metadata( + object_=flag, annotation=CreateOrUpdateFlagRequestBody, direction="write" + ), + "icon": icon, + "lifecycle_phase": lifecycle_phase, + "maintainer_id": maintainer_id, + "name": name, + "trait_id": trait_id, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateFeatureResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateFeatureResponse, + parse_obj_as( + type_=CreateFeatureResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -776,7 +871,7 @@ def get_feature( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -786,44 +881,59 @@ def get_feature( ) """ _response = self._client_wrapper.httpx_client.request( + f"features/{jsonable_encoder(feature_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"features/{jsonable_encoder(feature_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetFeatureResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetFeatureResponse, + parse_obj_as( + type_=GetFeatureResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -837,7 +947,9 @@ def update_feature( event_subtype: typing.Optional[str] = OMIT, feature_type: typing.Optional[UpdateFeatureRequestBodyFeatureType] = OMIT, flag: typing.Optional[CreateOrUpdateFlagRequestBody] = OMIT, + icon: typing.Optional[str] = OMIT, lifecycle_phase: typing.Optional[str] = OMIT, + maintainer_id: typing.Optional[str] = OMIT, name: typing.Optional[str] = OMIT, trait_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, @@ -856,8 +968,12 @@ def update_feature( flag : typing.Optional[CreateOrUpdateFlagRequestBody] + icon : typing.Optional[str] + lifecycle_phase : typing.Optional[str] + maintainer_id : typing.Optional[str] + name : typing.Optional[str] trait_id : typing.Optional[str] @@ -872,7 +988,7 @@ def update_feature( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -881,68 +997,84 @@ def update_feature( feature_id="feature_id", ) """ - _request: typing.Dict[str, typing.Any] = {} - if description is not OMIT: - _request["description"] = description - if event_subtype is not OMIT: - _request["event_subtype"] = event_subtype - if feature_type is not OMIT: - _request["feature_type"] = feature_type - if flag is not OMIT: - _request["flag"] = flag - if lifecycle_phase is not OMIT: - _request["lifecycle_phase"] = lifecycle_phase - if name is not OMIT: - _request["name"] = name - if trait_id is not OMIT: - _request["trait_id"] = trait_id _response = self._client_wrapper.httpx_client.request( + f"features/{jsonable_encoder(feature_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"features/{jsonable_encoder(feature_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "description": description, + "event_subtype": event_subtype, + "feature_type": feature_type, + "flag": convert_and_respect_annotation_metadata( + object_=flag, annotation=CreateOrUpdateFlagRequestBody, direction="write" + ), + "icon": icon, + "lifecycle_phase": lifecycle_phase, + "maintainer_id": maintainer_id, + "name": name, + "trait_id": trait_id, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateFeatureResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateFeatureResponse, + parse_obj_as( + type_=UpdateFeatureResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -967,7 +1099,7 @@ def delete_feature( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -977,44 +1109,59 @@ def delete_feature( ) """ _response = self._client_wrapper.httpx_client.request( + f"features/{jsonable_encoder(feature_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"features/{jsonable_encoder(feature_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteFeatureResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteFeatureResponse, + parse_obj_as( + type_=DeleteFeatureResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1060,7 +1207,7 @@ def count_features( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1068,79 +1215,90 @@ def count_features( client.features.count_features() """ _response = self._client_wrapper.httpx_client.request( + "features/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "features/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "ids": ids, - "q": q, - "without_company_override_for": without_company_override_for, - "without_plan_entitlement_for": without_plan_entitlement_for, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "ids": ids, + "q": q, + "without_company_override_for": without_company_override_for, + "without_plan_entitlement_for": without_plan_entitlement_for, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountFeaturesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountFeaturesResponse, + parse_obj_as( + type_=CountFeaturesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) - def list_flag_checks( + def list_flags( self, *, - flag_id: typing.Optional[str] = None, - flag_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, - id: typing.Optional[str] = None, + feature_id: typing.Optional[str] = None, + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + q: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> ListFlagChecksResponse: + ) -> ListFlagsResponse: """ Parameters ---------- - flag_id : typing.Optional[str] + feature_id : typing.Optional[str] - flag_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] - id : typing.Optional[str] + q : typing.Optional[str] limit : typing.Optional[int] Page limit (default 100) @@ -1153,605 +1311,285 @@ def list_flag_checks( Returns ------- - ListFlagChecksResponse + ListFlagsResponse OK Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) - client.features.list_flag_checks() + client.features.list_flags() """ _response = self._client_wrapper.httpx_client.request( + "flags", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "flag-checks"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "flag_id": flag_id, - "flag_ids": flag_ids, - "id": id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "feature_id": feature_id, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListFlagChecksResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListFlagsResponse, + parse_obj_as( + type_=ListFlagsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) - def get_flag_check( - self, flag_check_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetFlagCheckResponse: + def create_flag( + self, + *, + default_value: bool, + description: str, + flag_type: str, + key: str, + name: str, + feature_id: typing.Optional[str] = OMIT, + maintainer_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreateFlagResponse: """ Parameters ---------- - flag_check_id : str - flag_check_id + default_value : bool + + description : str + + flag_type : str + + key : str + + name : str + + feature_id : typing.Optional[str] + + maintainer_id : typing.Optional[str] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - GetFlagCheckResponse - OK + CreateFlagResponse + Created Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) - client.features.get_flag_check( - flag_check_id="flag_check_id", + client.features.create_flag( + default_value=True, + description="description", + flag_type="flag_type", + key="key", + name="name", ) """ _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"flag-checks/{jsonable_encoder(flag_check_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + "flags", + method="POST", + json={ + "default_value": default_value, + "description": description, + "feature_id": feature_id, + "flag_type": flag_type, + "key": key, + "maintainer_id": maintainer_id, + "name": name, + }, + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetFlagCheckResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateFlagResponse, + parse_obj_as( + type_=CreateFlagResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) - def count_flag_checks( - self, - *, - flag_id: typing.Optional[str] = None, - flag_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, - id: typing.Optional[str] = None, - limit: typing.Optional[int] = None, - offset: typing.Optional[int] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> CountFlagChecksResponse: + def get_flag(self, flag_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetFlagResponse: """ Parameters ---------- - flag_id : typing.Optional[str] - - flag_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] - - id : typing.Optional[str] - - limit : typing.Optional[int] - Page limit (default 100) - - offset : typing.Optional[int] - Page offset (default 0) + flag_id : str + flag_id request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - CountFlagChecksResponse + GetFlagResponse OK Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) - client.features.count_flag_checks() + client.features.get_flag( + flag_id="flag_id", + ) """ _response = self._client_wrapper.httpx_client.request( + f"flags/{jsonable_encoder(flag_id)}", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "flag-checks/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "flag_id": flag_id, - "flag_ids": flag_ids, - "id": id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountFlagChecksResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - try: - _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_latest_flag_checks( - self, - *, - flag_id: typing.Optional[str] = None, - flag_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, - id: typing.Optional[str] = None, - limit: typing.Optional[int] = None, - offset: typing.Optional[int] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetLatestFlagChecksResponse: - """ - Parameters - ---------- - flag_id : typing.Optional[str] - - flag_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] - - id : typing.Optional[str] - - limit : typing.Optional[int] - Page limit (default 100) - - offset : typing.Optional[int] - Page offset (default 0) - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetLatestFlagChecksResponse - OK - - Examples - -------- - from schematic.client import Schematic - - client = Schematic( - api_key="YOUR_API_KEY", - ) - client.features.get_latest_flag_checks() - """ - _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "flag-checks/latest"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "flag_id": flag_id, - "flag_ids": flag_ids, - "id": id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetLatestFlagChecksResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - try: - _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 list_flags( - self, - *, - feature_id: typing.Optional[str] = None, - ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, - q: typing.Optional[str] = None, - limit: typing.Optional[int] = None, - offset: typing.Optional[int] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> ListFlagsResponse: - """ - Parameters - ---------- - feature_id : typing.Optional[str] - - ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] - - q : typing.Optional[str] - - limit : typing.Optional[int] - Page limit (default 100) - - offset : typing.Optional[int] - Page offset (default 0) - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ListFlagsResponse - OK - - Examples - -------- - from schematic.client import Schematic - - client = Schematic( - api_key="YOUR_API_KEY", - ) - client.features.list_flags() - """ - _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "flags"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "ids": ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListFlagsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - try: - _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 create_flag( - self, - *, - default_value: bool, - description: str, - flag_type: str, - key: str, - name: str, - feature_id: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> CreateFlagResponse: - """ - Parameters - ---------- - default_value : bool - - description : str - - flag_type : str - - key : str - - name : str - - feature_id : typing.Optional[str] - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - CreateFlagResponse - Created - - Examples - -------- - from schematic.client import Schematic - - client = Schematic( - api_key="YOUR_API_KEY", - ) - client.features.create_flag( - default_value=True, - description="description", - flag_type="flag_type", - key="key", - name="name", - ) - """ - _request: typing.Dict[str, typing.Any] = { - "default_value": default_value, - "description": description, - "flag_type": flag_type, - "key": key, - "name": name, - } - if feature_id is not OMIT: - _request["feature_id"] = feature_id - _response = self._client_wrapper.httpx_client.request( - method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "flags"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), - }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateFlagResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - try: - _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_flag(self, flag_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetFlagResponse: - """ - Parameters - ---------- - flag_id : str - flag_id - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetFlagResponse - OK - - Examples - -------- - from schematic.client import Schematic - - client = Schematic( - api_key="YOUR_API_KEY", - ) - client.features.get_flag( - flag_id="flag_id", - ) - """ - _response = self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"flags/{jsonable_encoder(flag_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetFlagResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetFlagResponse, + parse_obj_as( + type_=GetFlagResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1767,6 +1605,7 @@ def update_flag( key: str, name: str, feature_id: typing.Optional[str] = OMIT, + maintainer_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UpdateFlagResponse: """ @@ -1787,6 +1626,8 @@ def update_flag( feature_id : typing.Optional[str] + maintainer_id : typing.Optional[str] + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1797,7 +1638,7 @@ def update_flag( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1811,60 +1652,80 @@ def update_flag( name="name", ) """ - _request: typing.Dict[str, typing.Any] = { - "default_value": default_value, - "description": description, - "flag_type": flag_type, - "key": key, - "name": name, - } - if feature_id is not OMIT: - _request["feature_id"] = feature_id _response = self._client_wrapper.httpx_client.request( + f"flags/{jsonable_encoder(flag_id)}", method="PUT", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"flags/{jsonable_encoder(flag_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "default_value": default_value, + "description": description, + "feature_id": feature_id, + "flag_type": flag_type, + "key": key, + "maintainer_id": maintainer_id, + "name": name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateFlagResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateFlagResponse, + parse_obj_as( + type_=UpdateFlagResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1889,7 +1750,7 @@ def delete_flag( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1899,42 +1760,59 @@ def delete_flag( ) """ _response = self._client_wrapper.httpx_client.request( + f"flags/{jsonable_encoder(flag_id)}", method="DELETE", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"flags/{jsonable_encoder(flag_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteFlagResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteFlagResponse, + parse_obj_as( + type_=DeleteFlagResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1969,8 +1847,8 @@ def update_flag_rules( CreateOrUpdateConditionGroupRequestBody, CreateOrUpdateConditionRequestBody, CreateOrUpdateRuleRequestBody, + Schematic, ) - from schematic.client import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -1984,7 +1862,6 @@ def update_flag_rules( conditions=[ CreateOrUpdateConditionRequestBody( condition_type="company", - metric_value=1, operator="eq", resource_ids=["resource_ids"], ) @@ -1994,7 +1871,6 @@ def update_flag_rules( conditions=[ CreateOrUpdateConditionRequestBody( condition_type="company", - metric_value=1, operator="eq", resource_ids=["resource_ids"], ) @@ -2007,52 +1883,75 @@ def update_flag_rules( ) """ _response = self._client_wrapper.httpx_client.request( + f"flags/{jsonable_encoder(flag_id)}/rules", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"flags/{jsonable_encoder(flag_id)}/rules" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder({"rules": rules}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"rules": rules}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "rules": convert_and_respect_annotation_metadata( + object_=rules, annotation=typing.Sequence[CreateOrUpdateRuleRequestBody], direction="write" + ), }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateFlagRulesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateFlagRulesResponse, + parse_obj_as( + type_=UpdateFlagRulesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2062,8 +1961,8 @@ def check_flag( self, key: str, *, - company: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, - user: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + company: typing.Optional[typing.Dict[str, str]] = OMIT, + user: typing.Optional[typing.Dict[str, str]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CheckFlagResponse: """ @@ -2072,9 +1971,9 @@ def check_flag( key : str key - company : typing.Optional[typing.Dict[str, typing.Optional[str]]] + company : typing.Optional[typing.Dict[str, str]] - user : typing.Optional[typing.Dict[str, typing.Optional[str]]] + user : typing.Optional[typing.Dict[str, str]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -2086,7 +1985,7 @@ def check_flag( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -2095,54 +1994,65 @@ def check_flag( key="key", ) """ - _request: typing.Dict[str, typing.Any] = {} - if company is not OMIT: - _request["company"] = company - if user is not OMIT: - _request["user"] = user _response = self._client_wrapper.httpx_client.request( + f"flags/{jsonable_encoder(key)}/check", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"flags/{jsonable_encoder(key)}/check"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "company": company, + "user": user, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CheckFlagResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CheckFlagResponse, + parse_obj_as( + type_=CheckFlagResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2151,16 +2061,16 @@ def check_flag( def check_flags( self, *, - company: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, - user: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + company: typing.Optional[typing.Dict[str, str]] = OMIT, + user: typing.Optional[typing.Dict[str, str]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CheckFlagsResponse: """ Parameters ---------- - company : typing.Optional[typing.Dict[str, typing.Optional[str]]] + company : typing.Optional[typing.Dict[str, str]] - user : typing.Optional[typing.Dict[str, typing.Optional[str]]] + user : typing.Optional[typing.Dict[str, str]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -2172,68 +2082,79 @@ def check_flags( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", ) client.features.check_flags() """ - _request: typing.Dict[str, typing.Any] = {} - if company is not OMIT: - _request["company"] = company - if user is not OMIT: - _request["user"] = user _response = self._client_wrapper.httpx_client.request( + "flags/check", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "flags/check"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "company": company, + "user": user, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CheckFlagsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: - _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 count_flags( - self, + if 200 <= _response.status_code < 300: + return typing.cast( + CheckFlagsResponse, + parse_obj_as( + type_=CheckFlagsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def count_flags( + self, *, feature_id: typing.Optional[str] = None, ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, @@ -2267,7 +2188,7 @@ def count_flags( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -2275,55 +2196,66 @@ def count_flags( client.features.count_flags() """ _response = self._client_wrapper.httpx_client.request( + "flags/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "flags/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "ids": ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "feature_id": feature_id, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountFlagsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountFlagsResponse, + parse_obj_as( + type_=CountFlagsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2369,88 +2301,114 @@ async def count_audience_companies( Examples -------- + import asyncio + from schematic import ( + AsyncSchematic, CreateOrUpdateConditionGroupRequestBody, CreateOrUpdateConditionRequestBody, ) - from schematic.client import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.count_audience_companies( - condition_groups=[ - CreateOrUpdateConditionGroupRequestBody( - conditions=[ - CreateOrUpdateConditionRequestBody( - condition_type="company", - metric_value=1, - operator="eq", - resource_ids=["resource_ids"], - ) - ], - ) - ], - conditions=[ - CreateOrUpdateConditionRequestBody( - condition_type="company", - metric_value=1, - operator="eq", - resource_ids=["resource_ids"], - ) - ], - ) + + + async def main() -> None: + await client.features.count_audience_companies( + condition_groups=[ + CreateOrUpdateConditionGroupRequestBody( + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + ], + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"condition_groups": condition_groups, "conditions": conditions} - if limit is not OMIT: - _request["limit"] = limit - if offset is not OMIT: - _request["offset"] = offset - if q is not OMIT: - _request["q"] = q _response = await self._client_wrapper.httpx_client.request( + "audience/count-companies", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "audience/count-companies"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "condition_groups": convert_and_respect_annotation_metadata( + object_=condition_groups, + annotation=typing.Sequence[CreateOrUpdateConditionGroupRequestBody], + direction="write", + ), + "conditions": convert_and_respect_annotation_metadata( + object_=conditions, + annotation=typing.Sequence[CreateOrUpdateConditionRequestBody], + direction="write", + ), + "limit": limit, + "offset": offset, + "q": q, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountAudienceCompaniesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountAudienceCompaniesResponse, + parse_obj_as( + type_=CountAudienceCompaniesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2491,88 +2449,114 @@ async def count_audience_users( Examples -------- + import asyncio + from schematic import ( + AsyncSchematic, CreateOrUpdateConditionGroupRequestBody, CreateOrUpdateConditionRequestBody, ) - from schematic.client import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.count_audience_users( - condition_groups=[ - CreateOrUpdateConditionGroupRequestBody( - conditions=[ - CreateOrUpdateConditionRequestBody( - condition_type="company", - metric_value=1, - operator="eq", - resource_ids=["resource_ids"], - ) - ], - ) - ], - conditions=[ - CreateOrUpdateConditionRequestBody( - condition_type="company", - metric_value=1, - operator="eq", - resource_ids=["resource_ids"], - ) - ], - ) + + + async def main() -> None: + await client.features.count_audience_users( + condition_groups=[ + CreateOrUpdateConditionGroupRequestBody( + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + ], + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"condition_groups": condition_groups, "conditions": conditions} - if limit is not OMIT: - _request["limit"] = limit - if offset is not OMIT: - _request["offset"] = offset - if q is not OMIT: - _request["q"] = q _response = await self._client_wrapper.httpx_client.request( + "audience/count-users", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "audience/count-users"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "condition_groups": convert_and_respect_annotation_metadata( + object_=condition_groups, + annotation=typing.Sequence[CreateOrUpdateConditionGroupRequestBody], + direction="write", + ), + "conditions": convert_and_respect_annotation_metadata( + object_=conditions, + annotation=typing.Sequence[CreateOrUpdateConditionRequestBody], + direction="write", + ), + "limit": limit, + "offset": offset, + "q": q, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountAudienceUsersResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountAudienceUsersResponse, + parse_obj_as( + type_=CountAudienceUsersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2613,88 +2597,114 @@ async def list_audience_companies( Examples -------- + import asyncio + from schematic import ( + AsyncSchematic, CreateOrUpdateConditionGroupRequestBody, CreateOrUpdateConditionRequestBody, ) - from schematic.client import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.list_audience_companies( - condition_groups=[ - CreateOrUpdateConditionGroupRequestBody( - conditions=[ - CreateOrUpdateConditionRequestBody( - condition_type="company", - metric_value=1, - operator="eq", - resource_ids=["resource_ids"], - ) - ], - ) - ], - conditions=[ - CreateOrUpdateConditionRequestBody( - condition_type="company", - metric_value=1, - operator="eq", - resource_ids=["resource_ids"], - ) - ], - ) + + + async def main() -> None: + await client.features.list_audience_companies( + condition_groups=[ + CreateOrUpdateConditionGroupRequestBody( + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + ], + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"condition_groups": condition_groups, "conditions": conditions} - if limit is not OMIT: - _request["limit"] = limit - if offset is not OMIT: - _request["offset"] = offset - if q is not OMIT: - _request["q"] = q _response = await self._client_wrapper.httpx_client.request( + "audience/get-companies", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "audience/get-companies"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "condition_groups": convert_and_respect_annotation_metadata( + object_=condition_groups, + annotation=typing.Sequence[CreateOrUpdateConditionGroupRequestBody], + direction="write", + ), + "conditions": convert_and_respect_annotation_metadata( + object_=conditions, + annotation=typing.Sequence[CreateOrUpdateConditionRequestBody], + direction="write", + ), + "limit": limit, + "offset": offset, + "q": q, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListAudienceCompaniesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListAudienceCompaniesResponse, + parse_obj_as( + type_=ListAudienceCompaniesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2735,88 +2745,114 @@ async def list_audience_users( Examples -------- + import asyncio + from schematic import ( + AsyncSchematic, CreateOrUpdateConditionGroupRequestBody, CreateOrUpdateConditionRequestBody, ) - from schematic.client import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.list_audience_users( - condition_groups=[ - CreateOrUpdateConditionGroupRequestBody( - conditions=[ - CreateOrUpdateConditionRequestBody( - condition_type="company", - metric_value=1, - operator="eq", - resource_ids=["resource_ids"], - ) - ], - ) - ], - conditions=[ - CreateOrUpdateConditionRequestBody( - condition_type="company", - metric_value=1, - operator="eq", - resource_ids=["resource_ids"], - ) - ], - ) + + + async def main() -> None: + await client.features.list_audience_users( + condition_groups=[ + CreateOrUpdateConditionGroupRequestBody( + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + ], + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"condition_groups": condition_groups, "conditions": conditions} - if limit is not OMIT: - _request["limit"] = limit - if offset is not OMIT: - _request["offset"] = offset - if q is not OMIT: - _request["q"] = q _response = await self._client_wrapper.httpx_client.request( + "audience/get-users", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "audience/get-users"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "condition_groups": convert_and_respect_annotation_metadata( + object_=condition_groups, + annotation=typing.Sequence[CreateOrUpdateConditionGroupRequestBody], + direction="write", + ), + "conditions": convert_and_respect_annotation_metadata( + object_=conditions, + annotation=typing.Sequence[CreateOrUpdateConditionRequestBody], + direction="write", + ), + "limit": limit, + "offset": offset, + "q": q, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListAudienceUsersResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListAudienceUsersResponse, + parse_obj_as( + type_=ListAudienceUsersResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2862,64 +2898,83 @@ async def list_features( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.list_features() + + + async def main() -> None: + await client.features.list_features() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "features", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "features"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "ids": ids, - "q": q, - "without_company_override_for": without_company_override_for, - "without_plan_entitlement_for": without_plan_entitlement_for, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "ids": ids, + "q": q, + "without_company_override_for": without_company_override_for, + "without_plan_entitlement_for": without_plan_entitlement_for, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListFeaturesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListFeaturesResponse, + parse_obj_as( + type_=ListFeaturesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -2933,7 +2988,9 @@ async def create_feature( name: str, event_subtype: typing.Optional[str] = OMIT, flag: typing.Optional[CreateOrUpdateFlagRequestBody] = OMIT, + icon: typing.Optional[str] = OMIT, lifecycle_phase: typing.Optional[str] = OMIT, + maintainer_id: typing.Optional[str] = OMIT, trait_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CreateFeatureResponse: @@ -2950,8 +3007,12 @@ async def create_feature( flag : typing.Optional[CreateOrUpdateFlagRequestBody] + icon : typing.Optional[str] + lifecycle_phase : typing.Optional[str] + maintainer_id : typing.Optional[str] + trait_id : typing.Optional[str] request_options : typing.Optional[RequestOptions] @@ -2964,73 +3025,93 @@ async def create_feature( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.create_feature( - description="description", - feature_type="boolean", - name="name", - ) + + + async def main() -> None: + await client.features.create_feature( + description="description", + feature_type="boolean", + name="name", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = { - "description": description, - "feature_type": feature_type, - "name": name, - } - if event_subtype is not OMIT: - _request["event_subtype"] = event_subtype - if flag is not OMIT: - _request["flag"] = flag - if lifecycle_phase is not OMIT: - _request["lifecycle_phase"] = lifecycle_phase - if trait_id is not OMIT: - _request["trait_id"] = trait_id _response = await self._client_wrapper.httpx_client.request( + "features", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "features"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "description": description, + "event_subtype": event_subtype, + "feature_type": feature_type, + "flag": convert_and_respect_annotation_metadata( + object_=flag, annotation=CreateOrUpdateFlagRequestBody, direction="write" + ), + "icon": icon, + "lifecycle_phase": lifecycle_phase, + "maintainer_id": maintainer_id, + "name": name, + "trait_id": trait_id, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateFeatureResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateFeatureResponse, + parse_obj_as( + type_=CreateFeatureResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3055,54 +3136,77 @@ async def get_feature( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.get_feature( - feature_id="feature_id", - ) + + + async def main() -> None: + await client.features.get_feature( + feature_id="feature_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"features/{jsonable_encoder(feature_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"features/{jsonable_encoder(feature_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetFeatureResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetFeatureResponse, + parse_obj_as( + type_=GetFeatureResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3116,7 +3220,9 @@ async def update_feature( event_subtype: typing.Optional[str] = OMIT, feature_type: typing.Optional[UpdateFeatureRequestBodyFeatureType] = OMIT, flag: typing.Optional[CreateOrUpdateFlagRequestBody] = OMIT, + icon: typing.Optional[str] = OMIT, lifecycle_phase: typing.Optional[str] = OMIT, + maintainer_id: typing.Optional[str] = OMIT, name: typing.Optional[str] = OMIT, trait_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, @@ -3135,8 +3241,12 @@ async def update_feature( flag : typing.Optional[CreateOrUpdateFlagRequestBody] + icon : typing.Optional[str] + lifecycle_phase : typing.Optional[str] + maintainer_id : typing.Optional[str] + name : typing.Optional[str] trait_id : typing.Optional[str] @@ -3151,77 +3261,101 @@ async def update_feature( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.update_feature( - feature_id="feature_id", - ) + + + async def main() -> None: + await client.features.update_feature( + feature_id="feature_id", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {} - if description is not OMIT: - _request["description"] = description - if event_subtype is not OMIT: - _request["event_subtype"] = event_subtype - if feature_type is not OMIT: - _request["feature_type"] = feature_type - if flag is not OMIT: - _request["flag"] = flag - if lifecycle_phase is not OMIT: - _request["lifecycle_phase"] = lifecycle_phase - if name is not OMIT: - _request["name"] = name - if trait_id is not OMIT: - _request["trait_id"] = trait_id _response = await self._client_wrapper.httpx_client.request( + f"features/{jsonable_encoder(feature_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"features/{jsonable_encoder(feature_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "description": description, + "event_subtype": event_subtype, + "feature_type": feature_type, + "flag": convert_and_respect_annotation_metadata( + object_=flag, annotation=CreateOrUpdateFlagRequestBody, direction="write" + ), + "icon": icon, + "lifecycle_phase": lifecycle_phase, + "maintainer_id": maintainer_id, + "name": name, + "trait_id": trait_id, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateFeatureResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateFeatureResponse, + parse_obj_as( + type_=UpdateFeatureResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3241,451 +3375,110 @@ async def delete_feature( Returns ------- - DeleteFeatureResponse - OK - - Examples - -------- - from schematic.client import AsyncSchematic - - client = AsyncSchematic( - api_key="YOUR_API_KEY", - ) - await client.features.delete_feature( - feature_id="feature_id", - ) - """ - _response = await self._client_wrapper.httpx_client.request( - method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"features/{jsonable_encoder(feature_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteFeatureResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - try: - _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 count_features( - self, - *, - ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, - q: typing.Optional[str] = None, - without_company_override_for: typing.Optional[str] = None, - without_plan_entitlement_for: typing.Optional[str] = None, - limit: typing.Optional[int] = None, - offset: typing.Optional[int] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> CountFeaturesResponse: - """ - Parameters - ---------- - ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] - - q : typing.Optional[str] - - without_company_override_for : typing.Optional[str] - Filter out features that already have a company override for the specified company ID - - without_plan_entitlement_for : typing.Optional[str] - Filter out features that already have a plan entitlement for the specified plan ID - - limit : typing.Optional[int] - Page limit (default 100) - - offset : typing.Optional[int] - Page offset (default 0) - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - CountFeaturesResponse - OK - - Examples - -------- - from schematic.client import AsyncSchematic - - client = AsyncSchematic( - api_key="YOUR_API_KEY", - ) - await client.features.count_features() - """ - _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "features/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "ids": ids, - "q": q, - "without_company_override_for": without_company_override_for, - "without_plan_entitlement_for": without_plan_entitlement_for, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountFeaturesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - try: - _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 list_flag_checks( - self, - *, - flag_id: typing.Optional[str] = None, - flag_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, - id: typing.Optional[str] = None, - limit: typing.Optional[int] = None, - offset: typing.Optional[int] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> ListFlagChecksResponse: - """ - Parameters - ---------- - flag_id : typing.Optional[str] - - flag_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] - - id : typing.Optional[str] - - limit : typing.Optional[int] - Page limit (default 100) - - offset : typing.Optional[int] - Page offset (default 0) - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ListFlagChecksResponse - OK - - Examples - -------- - from schematic.client import AsyncSchematic - - client = AsyncSchematic( - api_key="YOUR_API_KEY", - ) - await client.features.list_flag_checks() - """ - _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "flag-checks"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "flag_id": flag_id, - "flag_ids": flag_ids, - "id": id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListFlagChecksResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - try: - _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 get_flag_check( - self, flag_check_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetFlagCheckResponse: - """ - Parameters - ---------- - flag_check_id : str - flag_check_id - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetFlagCheckResponse - OK - - Examples - -------- - from schematic.client import AsyncSchematic - - client = AsyncSchematic( - api_key="YOUR_API_KEY", - ) - await client.features.get_flag_check( - flag_check_id="flag_check_id", - ) - """ - _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"flag-checks/{jsonable_encoder(flag_check_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore - ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetFlagCheckResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - try: - _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 count_flag_checks( - self, - *, - flag_id: typing.Optional[str] = None, - flag_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, - id: typing.Optional[str] = None, - limit: typing.Optional[int] = None, - offset: typing.Optional[int] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> CountFlagChecksResponse: - """ - Parameters - ---------- - flag_id : typing.Optional[str] - - flag_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] - - id : typing.Optional[str] - - limit : typing.Optional[int] - Page limit (default 100) - - offset : typing.Optional[int] - Page offset (default 0) - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - CountFlagChecksResponse + DeleteFeatureResponse OK Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.count_flag_checks() + + + async def main() -> None: + await client.features.delete_feature( + feature_id="feature_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "flag-checks/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "flag_id": flag_id, - "flag_ids": flag_ids, - "id": id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + f"features/{jsonable_encoder(feature_id)}", + method="DELETE", + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountFlagChecksResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteFeatureResponse, + parse_obj_as( + type_=DeleteFeatureResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) - async def get_latest_flag_checks( + async def count_features( self, *, - flag_id: typing.Optional[str] = None, - flag_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, - id: typing.Optional[str] = None, + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + q: typing.Optional[str] = None, + without_company_override_for: typing.Optional[str] = None, + without_plan_entitlement_for: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> GetLatestFlagChecksResponse: + ) -> CountFeaturesResponse: """ Parameters ---------- - flag_id : typing.Optional[str] + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + q : typing.Optional[str] - flag_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + without_company_override_for : typing.Optional[str] + Filter out features that already have a company override for the specified company ID - id : typing.Optional[str] + without_plan_entitlement_for : typing.Optional[str] + Filter out features that already have a plan entitlement for the specified plan ID limit : typing.Optional[int] Page limit (default 100) @@ -3698,68 +3491,88 @@ async def get_latest_flag_checks( Returns ------- - GetLatestFlagChecksResponse + CountFeaturesResponse OK Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.get_latest_flag_checks() + + + async def main() -> None: + await client.features.count_features() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "features/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "flag-checks/latest"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "flag_id": flag_id, - "flag_ids": flag_ids, - "id": id, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "ids": ids, + "q": q, + "without_company_override_for": without_company_override_for, + "without_plan_entitlement_for": without_plan_entitlement_for, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetLatestFlagChecksResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountFeaturesResponse, + parse_obj_as( + type_=CountFeaturesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3800,63 +3613,82 @@ async def list_flags( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.list_flags() + + + async def main() -> None: + await client.features.list_flags() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "flags", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "flags"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "ids": ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "feature_id": feature_id, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListFlagsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListFlagsResponse, + parse_obj_as( + type_=ListFlagsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3871,6 +3703,7 @@ async def create_flag( key: str, name: str, feature_id: typing.Optional[str] = OMIT, + maintainer_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CreateFlagResponse: """ @@ -3888,6 +3721,8 @@ async def create_flag( feature_id : typing.Optional[str] + maintainer_id : typing.Optional[str] + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -3898,71 +3733,91 @@ async def create_flag( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.create_flag( - default_value=True, - description="description", - flag_type="flag_type", - key="key", - name="name", - ) + + + async def main() -> None: + await client.features.create_flag( + default_value=True, + description="description", + flag_type="flag_type", + key="key", + name="name", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = { - "default_value": default_value, - "description": description, - "flag_type": flag_type, - "key": key, - "name": name, - } - if feature_id is not OMIT: - _request["feature_id"] = feature_id _response = await self._client_wrapper.httpx_client.request( + "flags", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "flags"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "default_value": default_value, + "description": description, + "feature_id": feature_id, + "flag_type": flag_type, + "key": key, + "maintainer_id": maintainer_id, + "name": name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateFlagResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateFlagResponse, + parse_obj_as( + type_=CreateFlagResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -3987,52 +3842,77 @@ async def get_flag( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.get_flag( - flag_id="flag_id", - ) + + + async def main() -> None: + await client.features.get_flag( + flag_id="flag_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"flags/{jsonable_encoder(flag_id)}", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"flags/{jsonable_encoder(flag_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetFlagResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetFlagResponse, + parse_obj_as( + type_=GetFlagResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4048,6 +3928,7 @@ async def update_flag( key: str, name: str, feature_id: typing.Optional[str] = OMIT, + maintainer_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UpdateFlagResponse: """ @@ -4068,6 +3949,8 @@ async def update_flag( feature_id : typing.Optional[str] + maintainer_id : typing.Optional[str] + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -4078,74 +3961,102 @@ async def update_flag( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.update_flag( - flag_id="flag_id", - default_value=True, - description="description", - flag_type="flag_type", - key="key", - name="name", - ) + + + async def main() -> None: + await client.features.update_flag( + flag_id="flag_id", + default_value=True, + description="description", + flag_type="flag_type", + key="key", + name="name", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = { - "default_value": default_value, - "description": description, - "flag_type": flag_type, - "key": key, - "name": name, - } - if feature_id is not OMIT: - _request["feature_id"] = feature_id _response = await self._client_wrapper.httpx_client.request( + f"flags/{jsonable_encoder(flag_id)}", method="PUT", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"flags/{jsonable_encoder(flag_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "default_value": default_value, + "description": description, + "feature_id": feature_id, + "flag_type": flag_type, + "key": key, + "maintainer_id": maintainer_id, + "name": name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateFlagResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateFlagResponse, + parse_obj_as( + type_=UpdateFlagResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4170,52 +4081,77 @@ async def delete_flag( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.delete_flag( - flag_id="flag_id", - ) + + + async def main() -> None: + await client.features.delete_flag( + flag_id="flag_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"flags/{jsonable_encoder(flag_id)}", method="DELETE", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"flags/{jsonable_encoder(flag_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteFlagResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteFlagResponse, + parse_obj_as( + type_=DeleteFlagResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4246,94 +4182,123 @@ async def update_flag_rules( Examples -------- + import asyncio + from schematic import ( + AsyncSchematic, CreateOrUpdateConditionGroupRequestBody, CreateOrUpdateConditionRequestBody, CreateOrUpdateRuleRequestBody, ) - from schematic.client import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.update_flag_rules( - flag_id="flag_id", - rules=[ - CreateOrUpdateRuleRequestBody( - condition_groups=[ - CreateOrUpdateConditionGroupRequestBody( - conditions=[ - CreateOrUpdateConditionRequestBody( - condition_type="company", - metric_value=1, - operator="eq", - resource_ids=["resource_ids"], - ) - ], - ) - ], - conditions=[ - CreateOrUpdateConditionRequestBody( - condition_type="company", - metric_value=1, - operator="eq", - resource_ids=["resource_ids"], - ) - ], - name="name", - priority=1, - value=True, - ) - ], - ) + + + async def main() -> None: + await client.features.update_flag_rules( + flag_id="flag_id", + rules=[ + CreateOrUpdateRuleRequestBody( + condition_groups=[ + CreateOrUpdateConditionGroupRequestBody( + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + ], + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + name="name", + priority=1, + value=True, + ) + ], + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"flags/{jsonable_encoder(flag_id)}/rules", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"flags/{jsonable_encoder(flag_id)}/rules" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder({"rules": rules}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"rules": rules}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "rules": convert_and_respect_annotation_metadata( + object_=rules, annotation=typing.Sequence[CreateOrUpdateRuleRequestBody], direction="write" + ), }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateFlagRulesResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateFlagRulesResponse, + parse_obj_as( + type_=UpdateFlagRulesResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4343,8 +4308,8 @@ async def check_flag( self, key: str, *, - company: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, - user: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + company: typing.Optional[typing.Dict[str, str]] = OMIT, + user: typing.Optional[typing.Dict[str, str]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CheckFlagResponse: """ @@ -4353,9 +4318,9 @@ async def check_flag( key : str key - company : typing.Optional[typing.Dict[str, typing.Optional[str]]] + company : typing.Optional[typing.Dict[str, str]] - user : typing.Optional[typing.Dict[str, typing.Optional[str]]] + user : typing.Optional[typing.Dict[str, str]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -4367,63 +4332,82 @@ async def check_flag( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.check_flag( - key="key", - ) + + + async def main() -> None: + await client.features.check_flag( + key="key", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {} - if company is not OMIT: - _request["company"] = company - if user is not OMIT: - _request["user"] = user _response = await self._client_wrapper.httpx_client.request( + f"flags/{jsonable_encoder(key)}/check", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"flags/{jsonable_encoder(key)}/check"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "company": company, + "user": user, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CheckFlagResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CheckFlagResponse, + parse_obj_as( + type_=CheckFlagResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4432,16 +4416,16 @@ async def check_flag( async def check_flags( self, *, - company: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, - user: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + company: typing.Optional[typing.Dict[str, str]] = OMIT, + user: typing.Optional[typing.Dict[str, str]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CheckFlagsResponse: """ Parameters ---------- - company : typing.Optional[typing.Dict[str, typing.Optional[str]]] + company : typing.Optional[typing.Dict[str, str]] - user : typing.Optional[typing.Dict[str, typing.Optional[str]]] + user : typing.Optional[typing.Dict[str, str]] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -4453,61 +4437,80 @@ async def check_flags( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.check_flags() + + + async def main() -> None: + await client.features.check_flags() + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {} - if company is not OMIT: - _request["company"] = company - if user is not OMIT: - _request["user"] = user _response = await self._client_wrapper.httpx_client.request( + "flags/check", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "flags/check"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "company": company, + "user": user, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CheckFlagsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CheckFlagsResponse, + parse_obj_as( + type_=CheckFlagsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -4548,63 +4551,82 @@ async def count_flags( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.features.count_flags() + + + async def main() -> None: + await client.features.count_flags() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "flags/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "flags/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "feature_id": feature_id, - "ids": ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "feature_id": feature_id, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountFlagsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountFlagsResponse, + parse_obj_as( + type_=CountFlagsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) diff --git a/src/schematic/features/types/__init__.py b/src/schematic/features/types/__init__.py index b663b2a..179a0d6 100644 --- a/src/schematic/features/types/__init__.py +++ b/src/schematic/features/types/__init__.py @@ -6,8 +6,6 @@ from .count_audience_users_response import CountAudienceUsersResponse from .count_features_params import CountFeaturesParams from .count_features_response import CountFeaturesResponse -from .count_flag_checks_params import CountFlagChecksParams -from .count_flag_checks_response import CountFlagChecksResponse from .count_flags_params import CountFlagsParams from .count_flags_response import CountFlagsResponse from .create_feature_request_body_feature_type import CreateFeatureRequestBodyFeatureType @@ -16,16 +14,11 @@ from .delete_feature_response import DeleteFeatureResponse from .delete_flag_response import DeleteFlagResponse from .get_feature_response import GetFeatureResponse -from .get_flag_check_response import GetFlagCheckResponse from .get_flag_response import GetFlagResponse -from .get_latest_flag_checks_params import GetLatestFlagChecksParams -from .get_latest_flag_checks_response import GetLatestFlagChecksResponse from .list_audience_companies_response import ListAudienceCompaniesResponse from .list_audience_users_response import ListAudienceUsersResponse from .list_features_params import ListFeaturesParams from .list_features_response import ListFeaturesResponse -from .list_flag_checks_params import ListFlagChecksParams -from .list_flag_checks_response import ListFlagChecksResponse from .list_flags_params import ListFlagsParams from .list_flags_response import ListFlagsResponse from .update_feature_request_body_feature_type import UpdateFeatureRequestBodyFeatureType @@ -40,8 +33,6 @@ "CountAudienceUsersResponse", "CountFeaturesParams", "CountFeaturesResponse", - "CountFlagChecksParams", - "CountFlagChecksResponse", "CountFlagsParams", "CountFlagsResponse", "CreateFeatureRequestBodyFeatureType", @@ -50,16 +41,11 @@ "DeleteFeatureResponse", "DeleteFlagResponse", "GetFeatureResponse", - "GetFlagCheckResponse", "GetFlagResponse", - "GetLatestFlagChecksParams", - "GetLatestFlagChecksResponse", "ListAudienceCompaniesResponse", "ListAudienceUsersResponse", "ListFeaturesParams", "ListFeaturesResponse", - "ListFlagChecksParams", - "ListFlagChecksResponse", "ListFlagsParams", "ListFlagsResponse", "UpdateFeatureRequestBodyFeatureType", diff --git a/src/schematic/features/types/check_flag_response.py b/src/schematic/features/types/check_flag_response.py index 8d9289e..1d3babc 100644 --- a/src/schematic/features/types/check_flag_response.py +++ b/src/schematic/features/types/check_flag_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.check_flag_response_data import CheckFlagResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CheckFlagResponse(pydantic_v1.BaseModel): +class CheckFlagResponse(UniversalBaseModel): data: CheckFlagResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/check_flags_response.py b/src/schematic/features/types/check_flags_response.py index 15c3819..bd0a723 100644 --- a/src/schematic/features/types/check_flags_response.py +++ b/src/schematic/features/types/check_flags_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.check_flags_response_data import CheckFlagsResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CheckFlagsResponse(pydantic_v1.BaseModel): +class CheckFlagsResponse(UniversalBaseModel): data: CheckFlagsResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/count_audience_companies_response.py b/src/schematic/features/types/count_audience_companies_response.py index 265d8d1..6f0a746 100644 --- a/src/schematic/features/types/count_audience_companies_response.py +++ b/src/schematic/features/types/count_audience_companies_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CountAudienceCompaniesResponse(pydantic_v1.BaseModel): +class CountAudienceCompaniesResponse(UniversalBaseModel): data: CountResponse - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/count_audience_users_response.py b/src/schematic/features/types/count_audience_users_response.py index 45453f3..7dd74fc 100644 --- a/src/schematic/features/types/count_audience_users_response.py +++ b/src/schematic/features/types/count_audience_users_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CountAudienceUsersResponse(pydantic_v1.BaseModel): +class CountAudienceUsersResponse(UniversalBaseModel): data: CountResponse - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/count_features_params.py b/src/schematic/features/types/count_features_params.py index f98eeee..d070a5b 100644 --- a/src/schematic/features/types/count_features_params.py +++ b/src/schematic/features/types/count_features_params.py @@ -1,53 +1,43 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountFeaturesParams(pydantic_v1.BaseModel): +class CountFeaturesParams(UniversalBaseModel): """ Input parameters """ ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - without_company_override_for: typing.Optional[str] = pydantic_v1.Field(default=None) + without_company_override_for: typing.Optional[str] = pydantic.Field(default=None) """ Filter out features that already have a company override for the specified company ID """ - without_plan_entitlement_for: typing.Optional[str] = pydantic_v1.Field(default=None) + without_plan_entitlement_for: typing.Optional[str] = pydantic.Field(default=None) """ Filter out features that already have a plan entitlement for the specified plan ID """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/count_features_response.py b/src/schematic/features/types/count_features_response.py index 65c7e9c..a4a853b 100644 --- a/src/schematic/features/types/count_features_response.py +++ b/src/schematic/features/types/count_features_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_features_params import CountFeaturesParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountFeaturesResponse(pydantic_v1.BaseModel): +class CountFeaturesResponse(UniversalBaseModel): data: CountResponse - params: CountFeaturesParams = pydantic_v1.Field() + params: CountFeaturesParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/count_flag_checks_params.py b/src/schematic/features/types/count_flag_checks_params.py deleted file mode 100644 index c354f8b..0000000 --- a/src/schematic/features/types/count_flag_checks_params.py +++ /dev/null @@ -1,44 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - - -class CountFlagChecksParams(pydantic_v1.BaseModel): - """ - Input parameters - """ - - flag_id: typing.Optional[str] = None - flag_ids: typing.Optional[typing.List[str]] = None - id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) - """ - Page limit (default 100) - """ - - offset: typing.Optional[int] = pydantic_v1.Field(default=None) - """ - Page offset (default 0) - """ - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/features/types/count_flag_checks_response.py b/src/schematic/features/types/count_flag_checks_response.py deleted file mode 100644 index 3800160..0000000 --- a/src/schematic/features/types/count_flag_checks_response.py +++ /dev/null @@ -1,35 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from ...types.count_response import CountResponse -from .count_flag_checks_params import CountFlagChecksParams - - -class CountFlagChecksResponse(pydantic_v1.BaseModel): - data: CountResponse - params: CountFlagChecksParams = pydantic_v1.Field() - """ - Input parameters - """ - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/features/types/count_flags_params.py b/src/schematic/features/types/count_flags_params.py index cec6665..01b5db3 100644 --- a/src/schematic/features/types/count_flags_params.py +++ b/src/schematic/features/types/count_flags_params.py @@ -1,45 +1,35 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountFlagsParams(pydantic_v1.BaseModel): +class CountFlagsParams(UniversalBaseModel): """ Input parameters """ feature_id: typing.Optional[str] = None ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/count_flags_response.py b/src/schematic/features/types/count_flags_response.py index 2bbbe0b..554314d 100644 --- a/src/schematic/features/types/count_flags_response.py +++ b/src/schematic/features/types/count_flags_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_flags_params import CountFlagsParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountFlagsResponse(pydantic_v1.BaseModel): +class CountFlagsResponse(UniversalBaseModel): data: CountResponse - params: CountFlagsParams = pydantic_v1.Field() + params: CountFlagsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/create_feature_response.py b/src/schematic/features/types/create_feature_response.py index 15c3aa3..e334815 100644 --- a/src/schematic/features/types/create_feature_response.py +++ b/src/schematic/features/types/create_feature_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.feature_detail_response_data import FeatureDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CreateFeatureResponse(pydantic_v1.BaseModel): +class CreateFeatureResponse(UniversalBaseModel): data: FeatureDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/create_flag_response.py b/src/schematic/features/types/create_flag_response.py index 76e6659..381f81c 100644 --- a/src/schematic/features/types/create_flag_response.py +++ b/src/schematic/features/types/create_flag_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.flag_detail_response_data import FlagDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CreateFlagResponse(pydantic_v1.BaseModel): +class CreateFlagResponse(UniversalBaseModel): data: FlagDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/delete_feature_response.py b/src/schematic/features/types/delete_feature_response.py index 61343d8..49a83db 100644 --- a/src/schematic/features/types/delete_feature_response.py +++ b/src/schematic/features/types/delete_feature_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.delete_response import DeleteResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class DeleteFeatureResponse(pydantic_v1.BaseModel): +class DeleteFeatureResponse(UniversalBaseModel): data: DeleteResponse - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/delete_flag_response.py b/src/schematic/features/types/delete_flag_response.py index 5ed1e7b..20b121a 100644 --- a/src/schematic/features/types/delete_flag_response.py +++ b/src/schematic/features/types/delete_flag_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.delete_response import DeleteResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class DeleteFlagResponse(pydantic_v1.BaseModel): +class DeleteFlagResponse(UniversalBaseModel): data: DeleteResponse - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/get_feature_response.py b/src/schematic/features/types/get_feature_response.py index f97e407..b87fe7b 100644 --- a/src/schematic/features/types/get_feature_response.py +++ b/src/schematic/features/types/get_feature_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.feature_detail_response_data import FeatureDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetFeatureResponse(pydantic_v1.BaseModel): +class GetFeatureResponse(UniversalBaseModel): data: FeatureDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/get_flag_check_response.py b/src/schematic/features/types/get_flag_check_response.py deleted file mode 100644 index d0712b4..0000000 --- a/src/schematic/features/types/get_flag_check_response.py +++ /dev/null @@ -1,34 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from ...types.flag_check_log_detail_response_data import FlagCheckLogDetailResponseData - - -class GetFlagCheckResponse(pydantic_v1.BaseModel): - data: FlagCheckLogDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() - """ - Input parameters - """ - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/features/types/get_flag_response.py b/src/schematic/features/types/get_flag_response.py index fe52bdc..872eceb 100644 --- a/src/schematic/features/types/get_flag_response.py +++ b/src/schematic/features/types/get_flag_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.flag_detail_response_data import FlagDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetFlagResponse(pydantic_v1.BaseModel): +class GetFlagResponse(UniversalBaseModel): data: FlagDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/get_latest_flag_checks_params.py b/src/schematic/features/types/get_latest_flag_checks_params.py deleted file mode 100644 index a93c922..0000000 --- a/src/schematic/features/types/get_latest_flag_checks_params.py +++ /dev/null @@ -1,44 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - - -class GetLatestFlagChecksParams(pydantic_v1.BaseModel): - """ - Input parameters - """ - - flag_id: typing.Optional[str] = None - flag_ids: typing.Optional[typing.List[str]] = None - id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) - """ - Page limit (default 100) - """ - - offset: typing.Optional[int] = pydantic_v1.Field(default=None) - """ - Page offset (default 0) - """ - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/features/types/get_latest_flag_checks_response.py b/src/schematic/features/types/get_latest_flag_checks_response.py deleted file mode 100644 index e58bcb3..0000000 --- a/src/schematic/features/types/get_latest_flag_checks_response.py +++ /dev/null @@ -1,39 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from ...types.flag_check_log_response_data import FlagCheckLogResponseData -from .get_latest_flag_checks_params import GetLatestFlagChecksParams - - -class GetLatestFlagChecksResponse(pydantic_v1.BaseModel): - data: typing.List[FlagCheckLogResponseData] = pydantic_v1.Field() - """ - The returned resources - """ - - params: GetLatestFlagChecksParams = pydantic_v1.Field() - """ - Input parameters - """ - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/features/types/list_audience_companies_response.py b/src/schematic/features/types/list_audience_companies_response.py index c1480a2..0389168 100644 --- a/src/schematic/features/types/list_audience_companies_response.py +++ b/src/schematic/features/types/list_audience_companies_response.py @@ -1,38 +1,28 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.company_detail_response_data import CompanyDetailResponseData +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListAudienceCompaniesResponse(pydantic_v1.BaseModel): - data: typing.List[CompanyDetailResponseData] = pydantic_v1.Field() +class ListAudienceCompaniesResponse(UniversalBaseModel): + data: typing.List[CompanyDetailResponseData] = pydantic.Field() """ The returned resources """ - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/list_audience_users_response.py b/src/schematic/features/types/list_audience_users_response.py index 40e86d0..bad8b3b 100644 --- a/src/schematic/features/types/list_audience_users_response.py +++ b/src/schematic/features/types/list_audience_users_response.py @@ -1,38 +1,28 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.user_detail_response_data import UserDetailResponseData +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListAudienceUsersResponse(pydantic_v1.BaseModel): - data: typing.List[UserDetailResponseData] = pydantic_v1.Field() +class ListAudienceUsersResponse(UniversalBaseModel): + data: typing.List[UserDetailResponseData] = pydantic.Field() """ The returned resources """ - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/list_features_params.py b/src/schematic/features/types/list_features_params.py index f51a9f4..350ac0f 100644 --- a/src/schematic/features/types/list_features_params.py +++ b/src/schematic/features/types/list_features_params.py @@ -1,53 +1,43 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListFeaturesParams(pydantic_v1.BaseModel): +class ListFeaturesParams(UniversalBaseModel): """ Input parameters """ ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - without_company_override_for: typing.Optional[str] = pydantic_v1.Field(default=None) + without_company_override_for: typing.Optional[str] = pydantic.Field(default=None) """ Filter out features that already have a company override for the specified company ID """ - without_plan_entitlement_for: typing.Optional[str] = pydantic_v1.Field(default=None) + without_plan_entitlement_for: typing.Optional[str] = pydantic.Field(default=None) """ Filter out features that already have a plan entitlement for the specified plan ID """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/list_features_response.py b/src/schematic/features/types/list_features_response.py index 18101e1..8570100 100644 --- a/src/schematic/features/types/list_features_response.py +++ b/src/schematic/features/types/list_features_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.feature_detail_response_data import FeatureDetailResponseData +import pydantic from .list_features_params import ListFeaturesParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListFeaturesResponse(pydantic_v1.BaseModel): - data: typing.List[FeatureDetailResponseData] = pydantic_v1.Field() +class ListFeaturesResponse(UniversalBaseModel): + data: typing.List[FeatureDetailResponseData] = pydantic.Field() """ The returned resources """ - params: ListFeaturesParams = pydantic_v1.Field() + params: ListFeaturesParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/list_flag_checks_params.py b/src/schematic/features/types/list_flag_checks_params.py deleted file mode 100644 index 27d1a6e..0000000 --- a/src/schematic/features/types/list_flag_checks_params.py +++ /dev/null @@ -1,44 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - - -class ListFlagChecksParams(pydantic_v1.BaseModel): - """ - Input parameters - """ - - flag_id: typing.Optional[str] = None - flag_ids: typing.Optional[typing.List[str]] = None - id: typing.Optional[str] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) - """ - Page limit (default 100) - """ - - offset: typing.Optional[int] = pydantic_v1.Field(default=None) - """ - Page offset (default 0) - """ - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/features/types/list_flag_checks_response.py b/src/schematic/features/types/list_flag_checks_response.py deleted file mode 100644 index 1497b1f..0000000 --- a/src/schematic/features/types/list_flag_checks_response.py +++ /dev/null @@ -1,39 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from ...types.flag_check_log_detail_response_data import FlagCheckLogDetailResponseData -from .list_flag_checks_params import ListFlagChecksParams - - -class ListFlagChecksResponse(pydantic_v1.BaseModel): - data: typing.List[FlagCheckLogDetailResponseData] = pydantic_v1.Field() - """ - The returned resources - """ - - params: ListFlagChecksParams = pydantic_v1.Field() - """ - Input parameters - """ - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/features/types/list_flags_params.py b/src/schematic/features/types/list_flags_params.py index 0ca80b9..7a4930f 100644 --- a/src/schematic/features/types/list_flags_params.py +++ b/src/schematic/features/types/list_flags_params.py @@ -1,45 +1,35 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListFlagsParams(pydantic_v1.BaseModel): +class ListFlagsParams(UniversalBaseModel): """ Input parameters """ feature_id: typing.Optional[str] = None ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/list_flags_response.py b/src/schematic/features/types/list_flags_response.py index 96d59dc..8e3c8b5 100644 --- a/src/schematic/features/types/list_flags_response.py +++ b/src/schematic/features/types/list_flags_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.flag_detail_response_data import FlagDetailResponseData +import pydantic from .list_flags_params import ListFlagsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListFlagsResponse(pydantic_v1.BaseModel): - data: typing.List[FlagDetailResponseData] = pydantic_v1.Field() +class ListFlagsResponse(UniversalBaseModel): + data: typing.List[FlagDetailResponseData] = pydantic.Field() """ The returned resources """ - params: ListFlagsParams = pydantic_v1.Field() + params: ListFlagsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/update_feature_response.py b/src/schematic/features/types/update_feature_response.py index e013c2b..b978130 100644 --- a/src/schematic/features/types/update_feature_response.py +++ b/src/schematic/features/types/update_feature_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.feature_detail_response_data import FeatureDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpdateFeatureResponse(pydantic_v1.BaseModel): +class UpdateFeatureResponse(UniversalBaseModel): data: FeatureDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/update_flag_response.py b/src/schematic/features/types/update_flag_response.py index 578ccb2..4e4fdfd 100644 --- a/src/schematic/features/types/update_flag_response.py +++ b/src/schematic/features/types/update_flag_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.flag_detail_response_data import FlagDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpdateFlagResponse(pydantic_v1.BaseModel): +class UpdateFlagResponse(UniversalBaseModel): data: FlagDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/features/types/update_flag_rules_response.py b/src/schematic/features/types/update_flag_rules_response.py index 40c3a46..79fdfe4 100644 --- a/src/schematic/features/types/update_flag_rules_response.py +++ b/src/schematic/features/types/update_flag_rules_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.rules_detail_response_data import RulesDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpdateFlagRulesResponse(pydantic_v1.BaseModel): +class UpdateFlagRulesResponse(UniversalBaseModel): data: RulesDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/plangroups/__init__.py b/src/schematic/plangroups/__init__.py new file mode 100644 index 0000000..3c6149c --- /dev/null +++ b/src/schematic/plangroups/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .types import CreatePlanGroupResponse, GetPlanGroupResponse, UpdatePlanGroupResponse + +__all__ = ["CreatePlanGroupResponse", "GetPlanGroupResponse", "UpdatePlanGroupResponse"] diff --git a/src/schematic/plangroups/client.py b/src/schematic/plangroups/client.py new file mode 100644 index 0000000..97dd61b --- /dev/null +++ b/src/schematic/plangroups/client.py @@ -0,0 +1,634 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from ..core.client_wrapper import SyncClientWrapper +from ..core.request_options import RequestOptions +from .types.get_plan_group_response import GetPlanGroupResponse +from ..core.pydantic_utilities import parse_obj_as +from ..errors.unauthorized_error import UnauthorizedError +from ..types.api_error import ApiError as types_api_error_ApiError +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.create_plan_group_response import CreatePlanGroupResponse +from ..errors.bad_request_error import BadRequestError +from .types.update_plan_group_response import UpdatePlanGroupResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.client_wrapper import AsyncClientWrapper + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class PlangroupsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_plan_group(self, *, request_options: typing.Optional[RequestOptions] = None) -> GetPlanGroupResponse: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetPlanGroupResponse + OK + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.plangroups.get_plan_group() + """ + _response = self._client_wrapper.httpx_client.request( + "plan-groups", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetPlanGroupResponse, + parse_obj_as( + type_=GetPlanGroupResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def create_plan_group( + self, + *, + plan_ids: typing.Sequence[str], + default_plan_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreatePlanGroupResponse: + """ + Parameters + ---------- + plan_ids : typing.Sequence[str] + + default_plan_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreatePlanGroupResponse + Created + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.plangroups.create_plan_group( + plan_ids=["plan_ids"], + ) + """ + _response = self._client_wrapper.httpx_client.request( + "plan-groups", + method="POST", + json={ + "default_plan_id": default_plan_id, + "plan_ids": plan_ids, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreatePlanGroupResponse, + parse_obj_as( + type_=CreatePlanGroupResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def update_plan_group( + self, + plan_group_id: str, + *, + plan_ids: typing.Sequence[str], + default_plan_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpdatePlanGroupResponse: + """ + Parameters + ---------- + plan_group_id : str + plan_group_id + + plan_ids : typing.Sequence[str] + + default_plan_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpdatePlanGroupResponse + OK + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.plangroups.update_plan_group( + plan_group_id="plan_group_id", + plan_ids=["plan_ids"], + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"plan-groups/{jsonable_encoder(plan_group_id)}", + method="PUT", + json={ + "default_plan_id": default_plan_id, + "plan_ids": plan_ids, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdatePlanGroupResponse, + parse_obj_as( + type_=UpdatePlanGroupResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + +class AsyncPlangroupsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_plan_group(self, *, request_options: typing.Optional[RequestOptions] = None) -> GetPlanGroupResponse: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetPlanGroupResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.plangroups.get_plan_group() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "plan-groups", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetPlanGroupResponse, + parse_obj_as( + type_=GetPlanGroupResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def create_plan_group( + self, + *, + plan_ids: typing.Sequence[str], + default_plan_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreatePlanGroupResponse: + """ + Parameters + ---------- + plan_ids : typing.Sequence[str] + + default_plan_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreatePlanGroupResponse + Created + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.plangroups.create_plan_group( + plan_ids=["plan_ids"], + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "plan-groups", + method="POST", + json={ + "default_plan_id": default_plan_id, + "plan_ids": plan_ids, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreatePlanGroupResponse, + parse_obj_as( + type_=CreatePlanGroupResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def update_plan_group( + self, + plan_group_id: str, + *, + plan_ids: typing.Sequence[str], + default_plan_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpdatePlanGroupResponse: + """ + Parameters + ---------- + plan_group_id : str + plan_group_id + + plan_ids : typing.Sequence[str] + + default_plan_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpdatePlanGroupResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.plangroups.update_plan_group( + plan_group_id="plan_group_id", + plan_ids=["plan_ids"], + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"plan-groups/{jsonable_encoder(plan_group_id)}", + method="PUT", + json={ + "default_plan_id": default_plan_id, + "plan_ids": plan_ids, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdatePlanGroupResponse, + parse_obj_as( + type_=UpdatePlanGroupResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) diff --git a/src/schematic/plangroups/types/__init__.py b/src/schematic/plangroups/types/__init__.py new file mode 100644 index 0000000..7baa094 --- /dev/null +++ b/src/schematic/plangroups/types/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +from .create_plan_group_response import CreatePlanGroupResponse +from .get_plan_group_response import GetPlanGroupResponse +from .update_plan_group_response import UpdatePlanGroupResponse + +__all__ = ["CreatePlanGroupResponse", "GetPlanGroupResponse", "UpdatePlanGroupResponse"] diff --git a/src/schematic/plangroups/types/create_plan_group_response.py b/src/schematic/plangroups/types/create_plan_group_response.py new file mode 100644 index 0000000..e62f6f9 --- /dev/null +++ b/src/schematic/plangroups/types/create_plan_group_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.plan_group_response_data import PlanGroupResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class CreatePlanGroupResponse(UniversalBaseModel): + data: PlanGroupResponseData + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/plangroups/types/get_plan_group_response.py b/src/schematic/plangroups/types/get_plan_group_response.py new file mode 100644 index 0000000..fc9f9a4 --- /dev/null +++ b/src/schematic/plangroups/types/get_plan_group_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.plan_group_detail_response_data import PlanGroupDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class GetPlanGroupResponse(UniversalBaseModel): + data: PlanGroupDetailResponseData + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/plangroups/types/update_plan_group_response.py b/src/schematic/plangroups/types/update_plan_group_response.py new file mode 100644 index 0000000..01a680f --- /dev/null +++ b/src/schematic/plangroups/types/update_plan_group_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.plan_group_response_data import PlanGroupResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class UpdatePlanGroupResponse(UniversalBaseModel): + data: PlanGroupResponseData + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/plans/__init__.py b/src/schematic/plans/__init__.py index 663080f..c593a35 100644 --- a/src/schematic/plans/__init__.py +++ b/src/schematic/plans/__init__.py @@ -2,7 +2,9 @@ from .types import ( CountPlansParams, + CountPlansRequestPlanType, CountPlansResponse, + CountPlansResponseParamsPlanType, CreatePlanRequestBodyPlanType, CreatePlanResponse, DeleteAudienceResponse, @@ -10,15 +12,19 @@ GetAudienceResponse, GetPlanResponse, ListPlansParams, + ListPlansRequestPlanType, ListPlansResponse, + ListPlansResponseParamsPlanType, UpdateAudienceResponse, - UpdatePlanRequestBodyPlanType, UpdatePlanResponse, + UpsertBillingProductPlanResponse, ) __all__ = [ "CountPlansParams", + "CountPlansRequestPlanType", "CountPlansResponse", + "CountPlansResponseParamsPlanType", "CreatePlanRequestBodyPlanType", "CreatePlanResponse", "DeleteAudienceResponse", @@ -26,8 +32,10 @@ "GetAudienceResponse", "GetPlanResponse", "ListPlansParams", + "ListPlansRequestPlanType", "ListPlansResponse", + "ListPlansResponseParamsPlanType", "UpdateAudienceResponse", - "UpdatePlanRequestBodyPlanType", "UpdatePlanResponse", + "UpsertBillingProductPlanResponse", ] diff --git a/src/schematic/plans/client.py b/src/schematic/plans/client.py index ac5f71e..eb4df4f 100644 --- a/src/schematic/plans/client.py +++ b/src/schematic/plans/client.py @@ -1,35 +1,35 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse -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.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 -from ..core.query_encoder import encode_query -from ..core.remove_none_from_dict import remove_none_from_dict +from ..core.client_wrapper import SyncClientWrapper 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 .types.get_audience_response import GetAudienceResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.pydantic_utilities import parse_obj_as from ..errors.unauthorized_error import UnauthorizedError from ..types.api_error import ApiError as types_api_error_ApiError +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.create_or_update_condition_group_request_body import CreateOrUpdateConditionGroupRequestBody from ..types.create_or_update_condition_request_body import CreateOrUpdateConditionRequestBody -from .types.count_plans_response import CountPlansResponse +from .types.update_audience_response import UpdateAudienceResponse +from ..core.serialization import convert_and_respect_annotation_metadata +from ..errors.bad_request_error import BadRequestError +from .types.delete_audience_response import DeleteAudienceResponse +from .types.list_plans_request_plan_type import ListPlansRequestPlanType +from .types.list_plans_response import ListPlansResponse from .types.create_plan_request_body_plan_type import CreatePlanRequestBodyPlanType from .types.create_plan_response import CreatePlanResponse -from .types.delete_audience_response import DeleteAudienceResponse -from .types.delete_plan_response import DeletePlanResponse -from .types.get_audience_response import GetAudienceResponse from .types.get_plan_response import GetPlanResponse -from .types.list_plans_response import ListPlansResponse -from .types.update_audience_response import UpdateAudienceResponse -from .types.update_plan_request_body_plan_type import UpdatePlanRequestBodyPlanType from .types.update_plan_response import UpdatePlanResponse +from .types.delete_plan_response import DeletePlanResponse +from .types.upsert_billing_product_plan_response import UpsertBillingProductPlanResponse +from .types.count_plans_request_plan_type import CountPlansRequestPlanType +from .types.count_plans_response import CountPlansResponse +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -58,7 +58,7 @@ def get_audience( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -68,44 +68,59 @@ def get_audience( ) """ _response = self._client_wrapper.httpx_client.request( + f"plan-audiences/{jsonable_encoder(plan_audience_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"plan-audiences/{jsonable_encoder(plan_audience_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetAudienceResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetAudienceResponse, + parse_obj_as( + type_=GetAudienceResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -142,8 +157,8 @@ def update_audience( from schematic import ( CreateOrUpdateConditionGroupRequestBody, CreateOrUpdateConditionRequestBody, + Schematic, ) - from schematic.client import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -155,7 +170,6 @@ def update_audience( conditions=[ CreateOrUpdateConditionRequestBody( condition_type="company", - metric_value=1, operator="eq", resource_ids=["resource_ids"], ) @@ -165,7 +179,6 @@ def update_audience( conditions=[ CreateOrUpdateConditionRequestBody( condition_type="company", - metric_value=1, operator="eq", resource_ids=["resource_ids"], ) @@ -173,52 +186,82 @@ def update_audience( ) """ _response = self._client_wrapper.httpx_client.request( + f"plan-audiences/{jsonable_encoder(plan_audience_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"plan-audiences/{jsonable_encoder(plan_audience_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder({"condition_groups": condition_groups, "conditions": conditions}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"condition_groups": condition_groups, "conditions": conditions}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "condition_groups": convert_and_respect_annotation_metadata( + object_=condition_groups, + annotation=typing.Sequence[CreateOrUpdateConditionGroupRequestBody], + direction="write", + ), + "conditions": convert_and_respect_annotation_metadata( + object_=conditions, + annotation=typing.Sequence[CreateOrUpdateConditionRequestBody], + direction="write", + ), }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateAudienceResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateAudienceResponse, + parse_obj_as( + type_=UpdateAudienceResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -243,7 +286,7 @@ def delete_audience( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -253,44 +296,59 @@ def delete_audience( ) """ _response = self._client_wrapper.httpx_client.request( + f"plan-audiences/{jsonable_encoder(plan_audience_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"plan-audiences/{jsonable_encoder(plan_audience_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteAudienceResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteAudienceResponse, + parse_obj_as( + type_=DeleteAudienceResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -302,6 +360,8 @@ def list_plans( company_id: typing.Optional[str] = None, ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, q: typing.Optional[str] = None, + plan_type: typing.Optional[ListPlansRequestPlanType] = None, + has_product_id: typing.Optional[bool] = None, without_entitlement_for: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, @@ -316,6 +376,12 @@ def list_plans( q : typing.Optional[str] + plan_type : typing.Optional[ListPlansRequestPlanType] + Filter by plan type + + has_product_id : typing.Optional[bool] + Filter out plans that do not have a billing product ID + without_entitlement_for : typing.Optional[str] Filter out plans that already have a plan entitlement for the specified feature ID @@ -335,7 +401,7 @@ def list_plans( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -343,56 +409,69 @@ def list_plans( client.plans.list_plans() """ _response = self._client_wrapper.httpx_client.request( + "plans", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "plans"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "ids": ids, - "q": q, - "without_entitlement_for": without_entitlement_for, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "company_id": company_id, + "ids": ids, + "q": q, + "plan_type": plan_type, + "has_product_id": has_product_id, + "without_entitlement_for": without_entitlement_for, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListPlansResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListPlansResponse, + parse_obj_as( + type_=ListPlansResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -404,6 +483,7 @@ def create_plan( description: str, name: str, plan_type: CreatePlanRequestBodyPlanType, + icon: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CreatePlanResponse: """ @@ -415,6 +495,8 @@ def create_plan( plan_type : CreatePlanRequestBodyPlanType + icon : typing.Optional[str] + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -425,7 +507,7 @@ def create_plan( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -433,52 +515,70 @@ def create_plan( client.plans.create_plan( description="description", name="name", - plan_type="product", + plan_type="plan", ) """ _response = self._client_wrapper.httpx_client.request( + "plans", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "plans"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder({"description": description, "name": name, "plan_type": plan_type}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"description": description, "name": name, "plan_type": plan_type}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "description": description, + "icon": icon, + "name": name, + "plan_type": plan_type, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreatePlanResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreatePlanResponse, + parse_obj_as( + type_=CreatePlanResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -501,7 +601,7 @@ def get_plan(self, plan_id: str, *, request_options: typing.Optional[RequestOpti Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -511,42 +611,59 @@ def get_plan(self, plan_id: str, *, request_options: typing.Optional[RequestOpti ) """ _response = self._client_wrapper.httpx_client.request( + f"plans/{jsonable_encoder(plan_id)}", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"plans/{jsonable_encoder(plan_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetPlanResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetPlanResponse, + parse_obj_as( + type_=GetPlanResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -558,7 +675,7 @@ def update_plan( *, name: str, description: typing.Optional[str] = OMIT, - plan_type: typing.Optional[UpdatePlanRequestBodyPlanType] = OMIT, + icon: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UpdatePlanResponse: """ @@ -571,7 +688,7 @@ def update_plan( description : typing.Optional[str] - plan_type : typing.Optional[UpdatePlanRequestBodyPlanType] + icon : typing.Optional[str] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -583,7 +700,7 @@ def update_plan( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -593,56 +710,76 @@ def update_plan( name="name", ) """ - _request: typing.Dict[str, typing.Any] = {"name": name} - if description is not OMIT: - _request["description"] = description - if plan_type is not OMIT: - _request["plan_type"] = plan_type _response = self._client_wrapper.httpx_client.request( + f"plans/{jsonable_encoder(plan_id)}", method="PUT", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"plans/{jsonable_encoder(plan_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "description": description, + "icon": icon, + "name": name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdatePlanResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdatePlanResponse, + parse_obj_as( + type_=UpdatePlanResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -667,7 +804,7 @@ def delete_plan( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -677,42 +814,175 @@ def delete_plan( ) """ _response = self._client_wrapper.httpx_client.request( + f"plans/{jsonable_encoder(plan_id)}", method="DELETE", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"plans/{jsonable_encoder(plan_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeletePlanResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeletePlanResponse, + parse_obj_as( + type_=DeletePlanResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + def upsert_billing_product_plan( + self, + plan_id: str, + *, + billing_product_id: str, + monthly_price_id: typing.Optional[str] = OMIT, + yearly_price_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertBillingProductPlanResponse: + """ + Parameters + ---------- + plan_id : str + plan_id + + billing_product_id : str + + monthly_price_id : typing.Optional[str] + + yearly_price_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertBillingProductPlanResponse + OK + + Examples + -------- + from schematic import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.plans.upsert_billing_product_plan( + plan_id="plan_id", + billing_product_id="billing_product_id", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"plans/{jsonable_encoder(plan_id)}/billing_products", + method="PUT", + json={ + "billing_product_id": billing_product_id, + "monthly_price_id": monthly_price_id, + "yearly_price_id": yearly_price_id, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertBillingProductPlanResponse, + parse_obj_as( + type_=UpsertBillingProductPlanResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -724,6 +994,8 @@ def count_plans( company_id: typing.Optional[str] = None, ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, q: typing.Optional[str] = None, + plan_type: typing.Optional[CountPlansRequestPlanType] = None, + has_product_id: typing.Optional[bool] = None, without_entitlement_for: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, @@ -738,6 +1010,12 @@ def count_plans( q : typing.Optional[str] + plan_type : typing.Optional[CountPlansRequestPlanType] + Filter by plan type + + has_product_id : typing.Optional[bool] + Filter out plans that do not have a billing product ID + without_entitlement_for : typing.Optional[str] Filter out plans that already have a plan entitlement for the specified feature ID @@ -757,7 +1035,7 @@ def count_plans( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -765,56 +1043,69 @@ def count_plans( client.plans.count_plans() """ _response = self._client_wrapper.httpx_client.request( + "plans/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "plans/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "ids": ids, - "q": q, - "without_entitlement_for": without_entitlement_for, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "company_id": company_id, + "ids": ids, + "q": q, + "plan_type": plan_type, + "has_product_id": has_product_id, + "without_entitlement_for": without_entitlement_for, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountPlansResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountPlansResponse, + parse_obj_as( + type_=CountPlansResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -844,54 +1135,77 @@ async def get_audience( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.plans.get_audience( - plan_audience_id="plan_audience_id", - ) + + + async def main() -> None: + await client.plans.get_audience( + plan_audience_id="plan_audience_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"plan-audiences/{jsonable_encoder(plan_audience_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"plan-audiences/{jsonable_encoder(plan_audience_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetAudienceResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetAudienceResponse, + parse_obj_as( + type_=GetAudienceResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -925,86 +1239,122 @@ async def update_audience( Examples -------- + import asyncio + from schematic import ( + AsyncSchematic, CreateOrUpdateConditionGroupRequestBody, CreateOrUpdateConditionRequestBody, ) - from schematic.client import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.plans.update_audience( - plan_audience_id="plan_audience_id", - condition_groups=[ - CreateOrUpdateConditionGroupRequestBody( - conditions=[ - CreateOrUpdateConditionRequestBody( - condition_type="company", - metric_value=1, - operator="eq", - resource_ids=["resource_ids"], - ) - ], - ) - ], - conditions=[ - CreateOrUpdateConditionRequestBody( - condition_type="company", - metric_value=1, - operator="eq", - resource_ids=["resource_ids"], - ) - ], - ) + + + async def main() -> None: + await client.plans.update_audience( + plan_audience_id="plan_audience_id", + condition_groups=[ + CreateOrUpdateConditionGroupRequestBody( + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + ], + conditions=[ + CreateOrUpdateConditionRequestBody( + condition_type="company", + operator="eq", + resource_ids=["resource_ids"], + ) + ], + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"plan-audiences/{jsonable_encoder(plan_audience_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"plan-audiences/{jsonable_encoder(plan_audience_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder({"condition_groups": condition_groups, "conditions": conditions}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"condition_groups": condition_groups, "conditions": conditions}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "condition_groups": convert_and_respect_annotation_metadata( + object_=condition_groups, + annotation=typing.Sequence[CreateOrUpdateConditionGroupRequestBody], + direction="write", + ), + "conditions": convert_and_respect_annotation_metadata( + object_=conditions, + annotation=typing.Sequence[CreateOrUpdateConditionRequestBody], + direction="write", + ), }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateAudienceResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateAudienceResponse, + parse_obj_as( + type_=UpdateAudienceResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1029,54 +1379,77 @@ async def delete_audience( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.plans.delete_audience( - plan_audience_id="plan_audience_id", - ) + + + async def main() -> None: + await client.plans.delete_audience( + plan_audience_id="plan_audience_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"plan-audiences/{jsonable_encoder(plan_audience_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"plan-audiences/{jsonable_encoder(plan_audience_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteAudienceResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteAudienceResponse, + parse_obj_as( + type_=DeleteAudienceResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1088,6 +1461,8 @@ async def list_plans( company_id: typing.Optional[str] = None, ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, q: typing.Optional[str] = None, + plan_type: typing.Optional[ListPlansRequestPlanType] = None, + has_product_id: typing.Optional[bool] = None, without_entitlement_for: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, @@ -1102,6 +1477,12 @@ async def list_plans( q : typing.Optional[str] + plan_type : typing.Optional[ListPlansRequestPlanType] + Filter by plan type + + has_product_id : typing.Optional[bool] + Filter out plans that do not have a billing product ID + without_entitlement_for : typing.Optional[str] Filter out plans that already have a plan entitlement for the specified feature ID @@ -1121,64 +1502,85 @@ async def list_plans( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.plans.list_plans() + + + async def main() -> None: + await client.plans.list_plans() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "plans", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "plans"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "ids": ids, - "q": q, - "without_entitlement_for": without_entitlement_for, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "company_id": company_id, + "ids": ids, + "q": q, + "plan_type": plan_type, + "has_product_id": has_product_id, + "without_entitlement_for": without_entitlement_for, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListPlansResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListPlansResponse, + parse_obj_as( + type_=ListPlansResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1190,6 +1592,7 @@ async def create_plan( description: str, name: str, plan_type: CreatePlanRequestBodyPlanType, + icon: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CreatePlanResponse: """ @@ -1201,6 +1604,8 @@ async def create_plan( plan_type : CreatePlanRequestBodyPlanType + icon : typing.Optional[str] + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1211,60 +1616,86 @@ async def create_plan( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.plans.create_plan( - description="description", - name="name", - plan_type="product", - ) + + + async def main() -> None: + await client.plans.create_plan( + description="description", + name="name", + plan_type="plan", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "plans", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "plans"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder({"description": description, "name": name, "plan_type": plan_type}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"description": description, "name": name, "plan_type": plan_type}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "description": description, + "icon": icon, + "name": name, + "plan_type": plan_type, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreatePlanResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreatePlanResponse, + parse_obj_as( + type_=CreatePlanResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1289,52 +1720,77 @@ async def get_plan( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.plans.get_plan( - plan_id="plan_id", - ) + + + async def main() -> None: + await client.plans.get_plan( + plan_id="plan_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"plans/{jsonable_encoder(plan_id)}", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"plans/{jsonable_encoder(plan_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetPlanResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetPlanResponse, + parse_obj_as( + type_=GetPlanResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1346,7 +1802,7 @@ async def update_plan( *, name: str, description: typing.Optional[str] = OMIT, - plan_type: typing.Optional[UpdatePlanRequestBodyPlanType] = OMIT, + icon: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UpdatePlanResponse: """ @@ -1359,7 +1815,7 @@ async def update_plan( description : typing.Optional[str] - plan_type : typing.Optional[UpdatePlanRequestBodyPlanType] + icon : typing.Optional[str] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1371,66 +1827,94 @@ async def update_plan( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.plans.update_plan( - plan_id="plan_id", - name="name", - ) + + + async def main() -> None: + await client.plans.update_plan( + plan_id="plan_id", + name="name", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {"name": name} - if description is not OMIT: - _request["description"] = description - if plan_type is not OMIT: - _request["plan_type"] = plan_type _response = await self._client_wrapper.httpx_client.request( + f"plans/{jsonable_encoder(plan_id)}", method="PUT", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"plans/{jsonable_encoder(plan_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "description": description, + "icon": icon, + "name": name, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdatePlanResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdatePlanResponse, + parse_obj_as( + type_=UpdatePlanResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1455,52 +1939,201 @@ async def delete_plan( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.plans.delete_plan( - plan_id="plan_id", - ) + + + async def main() -> None: + await client.plans.delete_plan( + plan_id="plan_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"plans/{jsonable_encoder(plan_id)}", method="DELETE", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"plans/{jsonable_encoder(plan_id)}"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeletePlanResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeletePlanResponse, + parse_obj_as( + type_=DeletePlanResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) + + async def upsert_billing_product_plan( + self, + plan_id: str, + *, + billing_product_id: str, + monthly_price_id: typing.Optional[str] = OMIT, + yearly_price_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertBillingProductPlanResponse: + """ + Parameters + ---------- + plan_id : str + plan_id + + billing_product_id : str + + monthly_price_id : typing.Optional[str] + + yearly_price_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertBillingProductPlanResponse + OK + + Examples + -------- + import asyncio + + from schematic import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.plans.upsert_billing_product_plan( + plan_id="plan_id", + billing_product_id="billing_product_id", ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"plans/{jsonable_encoder(plan_id)}/billing_products", + method="PUT", + json={ + "billing_product_id": billing_product_id, + "monthly_price_id": monthly_price_id, + "yearly_price_id": yearly_price_id, + }, + request_options=request_options, + omit=OMIT, + ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpsertBillingProductPlanResponse, + parse_obj_as( + type_=UpsertBillingProductPlanResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1512,6 +2145,8 @@ async def count_plans( company_id: typing.Optional[str] = None, ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, q: typing.Optional[str] = None, + plan_type: typing.Optional[CountPlansRequestPlanType] = None, + has_product_id: typing.Optional[bool] = None, without_entitlement_for: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, @@ -1526,6 +2161,12 @@ async def count_plans( q : typing.Optional[str] + plan_type : typing.Optional[CountPlansRequestPlanType] + Filter by plan type + + has_product_id : typing.Optional[bool] + Filter out plans that do not have a billing product ID + without_entitlement_for : typing.Optional[str] Filter out plans that already have a plan entitlement for the specified feature ID @@ -1545,64 +2186,85 @@ async def count_plans( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.plans.count_plans() + + + async def main() -> None: + await client.plans.count_plans() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "plans/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "plans/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "company_id": company_id, - "ids": ids, - "q": q, - "without_entitlement_for": without_entitlement_for, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "company_id": company_id, + "ids": ids, + "q": q, + "plan_type": plan_type, + "has_product_id": has_product_id, + "without_entitlement_for": without_entitlement_for, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountPlansResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountPlansResponse, + parse_obj_as( + type_=CountPlansResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) diff --git a/src/schematic/plans/types/__init__.py b/src/schematic/plans/types/__init__.py index 1a6c451..c4103dd 100644 --- a/src/schematic/plans/types/__init__.py +++ b/src/schematic/plans/types/__init__.py @@ -1,7 +1,9 @@ # This file was auto-generated by Fern from our API Definition. from .count_plans_params import CountPlansParams +from .count_plans_request_plan_type import CountPlansRequestPlanType from .count_plans_response import CountPlansResponse +from .count_plans_response_params_plan_type import CountPlansResponseParamsPlanType from .create_plan_request_body_plan_type import CreatePlanRequestBodyPlanType from .create_plan_response import CreatePlanResponse from .delete_audience_response import DeleteAudienceResponse @@ -9,14 +11,18 @@ from .get_audience_response import GetAudienceResponse from .get_plan_response import GetPlanResponse from .list_plans_params import ListPlansParams +from .list_plans_request_plan_type import ListPlansRequestPlanType from .list_plans_response import ListPlansResponse +from .list_plans_response_params_plan_type import ListPlansResponseParamsPlanType from .update_audience_response import UpdateAudienceResponse -from .update_plan_request_body_plan_type import UpdatePlanRequestBodyPlanType from .update_plan_response import UpdatePlanResponse +from .upsert_billing_product_plan_response import UpsertBillingProductPlanResponse __all__ = [ "CountPlansParams", + "CountPlansRequestPlanType", "CountPlansResponse", + "CountPlansResponseParamsPlanType", "CreatePlanRequestBodyPlanType", "CreatePlanResponse", "DeleteAudienceResponse", @@ -24,8 +30,10 @@ "GetAudienceResponse", "GetPlanResponse", "ListPlansParams", + "ListPlansRequestPlanType", "ListPlansResponse", + "ListPlansResponseParamsPlanType", "UpdateAudienceResponse", - "UpdatePlanRequestBodyPlanType", "UpdatePlanResponse", + "UpsertBillingProductPlanResponse", ] diff --git a/src/schematic/plans/types/count_plans_params.py b/src/schematic/plans/types/count_plans_params.py index ff6ea2e..d250925 100644 --- a/src/schematic/plans/types/count_plans_params.py +++ b/src/schematic/plans/types/count_plans_params.py @@ -1,49 +1,50 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from .count_plans_response_params_plan_type import CountPlansResponseParamsPlanType +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountPlansParams(pydantic_v1.BaseModel): +class CountPlansParams(UniversalBaseModel): """ Input parameters """ company_id: typing.Optional[str] = None + has_product_id: typing.Optional[bool] = pydantic.Field(default=None) + """ + Filter out plans that do not have a billing product ID + """ + ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ + plan_type: typing.Optional[CountPlansResponseParamsPlanType] = pydantic.Field(default=None) + """ + Filter by plan type + """ + q: typing.Optional[str] = None - without_entitlement_for: typing.Optional[str] = pydantic_v1.Field(default=None) + without_entitlement_for: typing.Optional[str] = pydantic.Field(default=None) """ Filter out plans that already have a plan entitlement for the specified feature ID """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/plans/types/count_plans_request_plan_type.py b/src/schematic/plans/types/count_plans_request_plan_type.py new file mode 100644 index 0000000..ce6d343 --- /dev/null +++ b/src/schematic/plans/types/count_plans_request_plan_type.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +CountPlansRequestPlanType = typing.Union[typing.Literal["plan", "add_on"], typing.Any] diff --git a/src/schematic/plans/types/count_plans_response.py b/src/schematic/plans/types/count_plans_response.py index 5cfeb40..c29ab39 100644 --- a/src/schematic/plans/types/count_plans_response.py +++ b/src/schematic/plans/types/count_plans_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_plans_params import CountPlansParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountPlansResponse(pydantic_v1.BaseModel): +class CountPlansResponse(UniversalBaseModel): data: CountResponse - params: CountPlansParams = pydantic_v1.Field() + params: CountPlansParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/plans/types/count_plans_response_params_plan_type.py b/src/schematic/plans/types/count_plans_response_params_plan_type.py new file mode 100644 index 0000000..d340226 --- /dev/null +++ b/src/schematic/plans/types/count_plans_response_params_plan_type.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +CountPlansResponseParamsPlanType = typing.Union[typing.Literal["plan", "add_on"], typing.Any] diff --git a/src/schematic/plans/types/create_plan_request_body_plan_type.py b/src/schematic/plans/types/create_plan_request_body_plan_type.py index e6a27e1..6bd0367 100644 --- a/src/schematic/plans/types/create_plan_request_body_plan_type.py +++ b/src/schematic/plans/types/create_plan_request_body_plan_type.py @@ -2,6 +2,4 @@ import typing -CreatePlanRequestBodyPlanType = typing.Union[ - typing.Literal["product", "pricing_plan", "add_on", "overage", "billable_metric", "other"], typing.Any -] +CreatePlanRequestBodyPlanType = typing.Union[typing.Literal["plan", "add_on"], typing.Any] diff --git a/src/schematic/plans/types/create_plan_response.py b/src/schematic/plans/types/create_plan_response.py index 21ec338..a9c54a8 100644 --- a/src/schematic/plans/types/create_plan_response.py +++ b/src/schematic/plans/types/create_plan_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.plan_detail_response_data import PlanDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CreatePlanResponse(pydantic_v1.BaseModel): +class CreatePlanResponse(UniversalBaseModel): data: PlanDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/plans/types/delete_audience_response.py b/src/schematic/plans/types/delete_audience_response.py index f01e2f3..55ebc42 100644 --- a/src/schematic/plans/types/delete_audience_response.py +++ b/src/schematic/plans/types/delete_audience_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.delete_response import DeleteResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class DeleteAudienceResponse(pydantic_v1.BaseModel): +class DeleteAudienceResponse(UniversalBaseModel): data: DeleteResponse - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/plans/types/delete_plan_response.py b/src/schematic/plans/types/delete_plan_response.py index d28b94d..b48ace6 100644 --- a/src/schematic/plans/types/delete_plan_response.py +++ b/src/schematic/plans/types/delete_plan_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.delete_response import DeleteResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class DeletePlanResponse(pydantic_v1.BaseModel): +class DeletePlanResponse(UniversalBaseModel): data: DeleteResponse - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/plans/types/get_audience_response.py b/src/schematic/plans/types/get_audience_response.py index 90f9d8c..bc5c0e1 100644 --- a/src/schematic/plans/types/get_audience_response.py +++ b/src/schematic/plans/types/get_audience_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.plan_audience_detail_response_data import PlanAudienceDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetAudienceResponse(pydantic_v1.BaseModel): +class GetAudienceResponse(UniversalBaseModel): data: PlanAudienceDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/plans/types/get_plan_response.py b/src/schematic/plans/types/get_plan_response.py index e27071f..8d74e83 100644 --- a/src/schematic/plans/types/get_plan_response.py +++ b/src/schematic/plans/types/get_plan_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.plan_detail_response_data import PlanDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetPlanResponse(pydantic_v1.BaseModel): +class GetPlanResponse(UniversalBaseModel): data: PlanDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/plans/types/list_plans_params.py b/src/schematic/plans/types/list_plans_params.py index 3bc964e..cc5f947 100644 --- a/src/schematic/plans/types/list_plans_params.py +++ b/src/schematic/plans/types/list_plans_params.py @@ -1,49 +1,50 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from .list_plans_response_params_plan_type import ListPlansResponseParamsPlanType +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListPlansParams(pydantic_v1.BaseModel): +class ListPlansParams(UniversalBaseModel): """ Input parameters """ company_id: typing.Optional[str] = None + has_product_id: typing.Optional[bool] = pydantic.Field(default=None) + """ + Filter out plans that do not have a billing product ID + """ + ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ + plan_type: typing.Optional[ListPlansResponseParamsPlanType] = pydantic.Field(default=None) + """ + Filter by plan type + """ + q: typing.Optional[str] = None - without_entitlement_for: typing.Optional[str] = pydantic_v1.Field(default=None) + without_entitlement_for: typing.Optional[str] = pydantic.Field(default=None) """ Filter out plans that already have a plan entitlement for the specified feature ID """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/plans/types/list_plans_request_plan_type.py b/src/schematic/plans/types/list_plans_request_plan_type.py new file mode 100644 index 0000000..0ab6b17 --- /dev/null +++ b/src/schematic/plans/types/list_plans_request_plan_type.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +ListPlansRequestPlanType = typing.Union[typing.Literal["plan", "add_on"], typing.Any] diff --git a/src/schematic/plans/types/list_plans_response.py b/src/schematic/plans/types/list_plans_response.py index 6d1124f..b357f4e 100644 --- a/src/schematic/plans/types/list_plans_response.py +++ b/src/schematic/plans/types/list_plans_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.plan_detail_response_data import PlanDetailResponseData +import pydantic from .list_plans_params import ListPlansParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListPlansResponse(pydantic_v1.BaseModel): - data: typing.List[PlanDetailResponseData] = pydantic_v1.Field() +class ListPlansResponse(UniversalBaseModel): + data: typing.List[PlanDetailResponseData] = pydantic.Field() """ The returned resources """ - params: ListPlansParams = pydantic_v1.Field() + params: ListPlansParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/plans/types/list_plans_response_params_plan_type.py b/src/schematic/plans/types/list_plans_response_params_plan_type.py new file mode 100644 index 0000000..13ff96a --- /dev/null +++ b/src/schematic/plans/types/list_plans_response_params_plan_type.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +ListPlansResponseParamsPlanType = typing.Union[typing.Literal["plan", "add_on"], typing.Any] diff --git a/src/schematic/plans/types/update_audience_response.py b/src/schematic/plans/types/update_audience_response.py index 07567f9..3fd92f7 100644 --- a/src/schematic/plans/types/update_audience_response.py +++ b/src/schematic/plans/types/update_audience_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.plan_audience_detail_response_data import PlanAudienceDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpdateAudienceResponse(pydantic_v1.BaseModel): +class UpdateAudienceResponse(UniversalBaseModel): data: PlanAudienceDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/plans/types/update_plan_request_body_plan_type.py b/src/schematic/plans/types/update_plan_request_body_plan_type.py deleted file mode 100644 index 91a775c..0000000 --- a/src/schematic/plans/types/update_plan_request_body_plan_type.py +++ /dev/null @@ -1,7 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -UpdatePlanRequestBodyPlanType = typing.Union[ - typing.Literal["product", "pricing_plan", "add_on", "overage", "billable_metric", "other"], typing.Any -] diff --git a/src/schematic/plans/types/update_plan_response.py b/src/schematic/plans/types/update_plan_response.py index 9430abb..33512de 100644 --- a/src/schematic/plans/types/update_plan_response.py +++ b/src/schematic/plans/types/update_plan_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.plan_detail_response_data import PlanDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpdatePlanResponse(pydantic_v1.BaseModel): +class UpdatePlanResponse(UniversalBaseModel): data: PlanDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/plans/types/upsert_billing_product_plan_response.py b/src/schematic/plans/types/upsert_billing_product_plan_response.py new file mode 100644 index 0000000..74d22f5 --- /dev/null +++ b/src/schematic/plans/types/upsert_billing_product_plan_response.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +from ...types.billing_product_plan_response_data import BillingProductPlanResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 + + +class UpsertBillingProductPlanResponse(UniversalBaseModel): + data: BillingProductPlanResponseData + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() + """ + Input parameters + """ + + 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/schematic/types/__init__.py b/src/schematic/types/__init__.py index a8da277..6475276 100644 --- a/src/schematic/types/__init__.py +++ b/src/schematic/types/__init__.py @@ -6,6 +6,15 @@ from .api_key_request_response_data import ApiKeyRequestResponseData from .api_key_response_data import ApiKeyResponseData from .audience_request_body import AudienceRequestBody +from .billing_customer_response_data import BillingCustomerResponseData +from .billing_customer_subscription import BillingCustomerSubscription +from .billing_customer_with_subscriptions_response_data import BillingCustomerWithSubscriptionsResponseData +from .billing_plan import BillingPlan +from .billing_price_response_data import BillingPriceResponseData +from .billing_product_detail_response_data import BillingProductDetailResponseData +from .billing_product_for_subscription_response_data import BillingProductForSubscriptionResponseData +from .billing_product_plan_response_data import BillingProductPlanResponseData +from .billing_product_pricing import BillingProductPricing from .billing_product_response_data import BillingProductResponseData from .billing_subscription_response_data import BillingSubscriptionResponseData from .check_flag_output_with_flag_key import CheckFlagOutputWithFlagKey @@ -17,9 +26,11 @@ from .company_membership_detail_response_data import CompanyMembershipDetailResponseData from .company_membership_response_data import CompanyMembershipResponseData from .company_override_response_data import CompanyOverrideResponseData -from .company_plan_response_data import CompanyPlanResponseData +from .company_plan_detail_response_data import CompanyPlanDetailResponseData from .company_response_data import CompanyResponseData from .company_subscription_response_data import CompanySubscriptionResponseData +from .component_hydrate_response_data import ComponentHydrateResponseData +from .component_response_data import ComponentResponseData from .count_response import CountResponse from .create_event_request_body import CreateEventRequestBody from .create_event_request_body_event_type import CreateEventRequestBodyEventType @@ -51,6 +62,7 @@ from .environment_detail_response_data import EnvironmentDetailResponseData from .environment_response_data import EnvironmentResponseData from .event_body import EventBody +from .event_body_flag_check import EventBodyFlagCheck from .event_body_identify import EventBodyIdentify from .event_body_identify_company import EventBodyIdentifyCompany from .event_body_track import EventBodyTrack @@ -58,22 +70,31 @@ from .event_response_data import EventResponseData from .event_summary_response_data import EventSummaryResponseData from .feature_company_response_data import FeatureCompanyResponseData +from .feature_company_response_data_allocation_type import FeatureCompanyResponseDataAllocationType from .feature_company_user_response_data import FeatureCompanyUserResponseData +from .feature_company_user_response_data_allocation_type import FeatureCompanyUserResponseDataAllocationType from .feature_detail_response_data import FeatureDetailResponseData from .feature_response_data import FeatureResponseData from .feature_usage_detail_response_data import FeatureUsageDetailResponseData from .feature_usage_response_data import FeatureUsageResponseData -from .flag_check_log_detail_response_data import FlagCheckLogDetailResponseData -from .flag_check_log_response_data import FlagCheckLogResponseData +from .feature_usage_response_data_allocation_type import FeatureUsageResponseDataAllocationType from .flag_detail_response_data import FlagDetailResponseData from .flag_response_data import FlagResponseData +from .invoice_request_body import InvoiceRequestBody +from .invoice_response_data import InvoiceResponseData +from .issue_temporary_access_token_response_data import IssueTemporaryAccessTokenResponseData from .keys_request_body import KeysRequestBody from .metric_counts_hourly_response_data import MetricCountsHourlyResponseData from .pagination_filter import PaginationFilter +from .payment_method_request_body import PaymentMethodRequestBody +from .payment_method_response_data import PaymentMethodResponseData from .plan_audience_detail_response_data import PlanAudienceDetailResponseData from .plan_audience_response_data import PlanAudienceResponseData from .plan_detail_response_data import PlanDetailResponseData from .plan_entitlement_response_data import PlanEntitlementResponseData +from .plan_group_detail_response_data import PlanGroupDetailResponseData +from .plan_group_plan_detail_response_data import PlanGroupPlanDetailResponseData +from .plan_group_response_data import PlanGroupResponseData from .plan_response_data import PlanResponseData from .preview_object import PreviewObject from .raw_event_batch_response_data import RawEventBatchResponseData @@ -87,6 +108,8 @@ from .rule_response_data import RuleResponseData from .rules_detail_response_data import RulesDetailResponseData from .segment_status_resp import SegmentStatusResp +from .stripe_embed_info import StripeEmbedInfo +from .temporary_access_token_response_data import TemporaryAccessTokenResponseData from .update_req_common import UpdateReqCommon from .update_req_common_metric_period import UpdateReqCommonMetricPeriod from .update_req_common_value_type import UpdateReqCommonValueType @@ -108,6 +131,15 @@ "ApiKeyRequestResponseData", "ApiKeyResponseData", "AudienceRequestBody", + "BillingCustomerResponseData", + "BillingCustomerSubscription", + "BillingCustomerWithSubscriptionsResponseData", + "BillingPlan", + "BillingPriceResponseData", + "BillingProductDetailResponseData", + "BillingProductForSubscriptionResponseData", + "BillingProductPlanResponseData", + "BillingProductPricing", "BillingProductResponseData", "BillingSubscriptionResponseData", "CheckFlagOutputWithFlagKey", @@ -119,9 +151,11 @@ "CompanyMembershipDetailResponseData", "CompanyMembershipResponseData", "CompanyOverrideResponseData", - "CompanyPlanResponseData", + "CompanyPlanDetailResponseData", "CompanyResponseData", "CompanySubscriptionResponseData", + "ComponentHydrateResponseData", + "ComponentResponseData", "CountResponse", "CreateEventRequestBody", "CreateEventRequestBodyEventType", @@ -153,6 +187,7 @@ "EnvironmentDetailResponseData", "EnvironmentResponseData", "EventBody", + "EventBodyFlagCheck", "EventBodyIdentify", "EventBodyIdentifyCompany", "EventBodyTrack", @@ -160,22 +195,31 @@ "EventResponseData", "EventSummaryResponseData", "FeatureCompanyResponseData", + "FeatureCompanyResponseDataAllocationType", "FeatureCompanyUserResponseData", + "FeatureCompanyUserResponseDataAllocationType", "FeatureDetailResponseData", "FeatureResponseData", "FeatureUsageDetailResponseData", "FeatureUsageResponseData", - "FlagCheckLogDetailResponseData", - "FlagCheckLogResponseData", + "FeatureUsageResponseDataAllocationType", "FlagDetailResponseData", "FlagResponseData", + "InvoiceRequestBody", + "InvoiceResponseData", + "IssueTemporaryAccessTokenResponseData", "KeysRequestBody", "MetricCountsHourlyResponseData", "PaginationFilter", + "PaymentMethodRequestBody", + "PaymentMethodResponseData", "PlanAudienceDetailResponseData", "PlanAudienceResponseData", "PlanDetailResponseData", "PlanEntitlementResponseData", + "PlanGroupDetailResponseData", + "PlanGroupPlanDetailResponseData", + "PlanGroupResponseData", "PlanResponseData", "PreviewObject", "RawEventBatchResponseData", @@ -189,6 +233,8 @@ "RuleResponseData", "RulesDetailResponseData", "SegmentStatusResp", + "StripeEmbedInfo", + "TemporaryAccessTokenResponseData", "UpdateReqCommon", "UpdateReqCommonMetricPeriod", "UpdateReqCommonValueType", diff --git a/src/schematic/types/api_error.py b/src/schematic/types/api_error.py index 6c4fac2..fa3dee9 100644 --- a/src/schematic/types/api_error.py +++ b/src/schematic/types/api_error.py @@ -1,32 +1,22 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ApiError(pydantic_v1.BaseModel): - error: str = pydantic_v1.Field() +class ApiError(UniversalBaseModel): + error: str = pydantic.Field() """ Error message """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/api_key_create_response_data.py b/src/schematic/types/api_key_create_response_data.py index 5cec1fd..eff28d6 100644 --- a/src/schematic/types/api_key_create_response_data.py +++ b/src/schematic/types/api_key_create_response_data.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 ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ApiKeyCreateResponseData(pydantic_v1.BaseModel): +class ApiKeyCreateResponseData(UniversalBaseModel): """ The created resource """ @@ -22,20 +22,11 @@ class ApiKeyCreateResponseData(pydantic_v1.BaseModel): secret: str updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/api_key_request_list_response_data.py b/src/schematic/types/api_key_request_list_response_data.py index 349bb01..b1f0c39 100644 --- a/src/schematic/types/api_key_request_list_response_data.py +++ b/src/schematic/types/api_key_request_list_response_data.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class ApiKeyRequestListResponseData(pydantic_v1.BaseModel): +class ApiKeyRequestListResponseData(UniversalBaseModel): api_key_id: str ended_at: typing.Optional[dt.datetime] = None environment_id: typing.Optional[str] = None @@ -25,20 +25,11 @@ class ApiKeyRequestListResponseData(pydantic_v1.BaseModel): url: str user_name: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/api_key_request_response_data.py b/src/schematic/types/api_key_request_response_data.py index c80098d..c388c70 100644 --- a/src/schematic/types/api_key_request_response_data.py +++ b/src/schematic/types/api_key_request_response_data.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class ApiKeyRequestResponseData(pydantic_v1.BaseModel): +class ApiKeyRequestResponseData(UniversalBaseModel): """ The returned resource """ @@ -32,20 +32,11 @@ class ApiKeyRequestResponseData(pydantic_v1.BaseModel): user_id: typing.Optional[str] = None user_name: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/api_key_response_data.py b/src/schematic/types/api_key_response_data.py index 8c90d5a..f6d5f8e 100644 --- a/src/schematic/types/api_key_response_data.py +++ b/src/schematic/types/api_key_response_data.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 ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ApiKeyResponseData(pydantic_v1.BaseModel): +class ApiKeyResponseData(UniversalBaseModel): """ The updated resource """ @@ -21,20 +21,11 @@ class ApiKeyResponseData(pydantic_v1.BaseModel): scopes: typing.List[str] updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/audience_request_body.py b/src/schematic/types/audience_request_body.py index 1fe6297..05f3c37 100644 --- a/src/schematic/types/audience_request_body.py +++ b/src/schematic/types/audience_request_body.py @@ -1,43 +1,33 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .create_or_update_condition_group_request_body import CreateOrUpdateConditionGroupRequestBody from .create_or_update_condition_request_body import CreateOrUpdateConditionRequestBody +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -class AudienceRequestBody(pydantic_v1.BaseModel): +class AudienceRequestBody(UniversalBaseModel): condition_groups: typing.List[CreateOrUpdateConditionGroupRequestBody] conditions: typing.List[CreateOrUpdateConditionRequestBody] - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/billing_customer_response_data.py b/src/schematic/types/billing_customer_response_data.py new file mode 100644 index 0000000..e7aab09 --- /dev/null +++ b/src/schematic/types/billing_customer_response_data.py @@ -0,0 +1,31 @@ +# 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 pydantic + + +class BillingCustomerResponseData(UniversalBaseModel): + """ + The created resource + """ + + company_id: typing.Optional[str] = None + deleted_at: typing.Optional[dt.datetime] = None + email: str + external_id: str + failed_to_import: bool + id: str + name: str + updated_at: dt.datetime + + 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/schematic/types/billing_customer_subscription.py b/src/schematic/types/billing_customer_subscription.py new file mode 100644 index 0000000..1e92420 --- /dev/null +++ b/src/schematic/types/billing_customer_subscription.py @@ -0,0 +1,21 @@ +# 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 pydantic + + +class BillingCustomerSubscription(UniversalBaseModel): + expired_at: typing.Optional[dt.datetime] = None + total_price: int + + 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/schematic/types/billing_customer_with_subscriptions_response_data.py b/src/schematic/types/billing_customer_with_subscriptions_response_data.py new file mode 100644 index 0000000..f31ffc2 --- /dev/null +++ b/src/schematic/types/billing_customer_with_subscriptions_response_data.py @@ -0,0 +1,29 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.pydantic_utilities import UniversalBaseModel +import typing +import datetime as dt +from .billing_customer_subscription import BillingCustomerSubscription +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class BillingCustomerWithSubscriptionsResponseData(UniversalBaseModel): + company_id: typing.Optional[str] = None + deleted_at: typing.Optional[dt.datetime] = None + email: str + external_id: str + failed_to_import: bool + id: str + name: str + subscriptions: typing.List[BillingCustomerSubscription] + updated_at: dt.datetime + + 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/schematic/types/billing_plan.py b/src/schematic/types/billing_plan.py new file mode 100644 index 0000000..838042c --- /dev/null +++ b/src/schematic/types/billing_plan.py @@ -0,0 +1,24 @@ +# 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 + + +class BillingPlan(UniversalBaseModel): + description: typing.Optional[str] = None + id: str + image_url: typing.Optional[str] = None + name: str + plan_period: typing.Optional[str] = None + plan_price: typing.Optional[int] = 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/schematic/types/billing_price_response_data.py b/src/schematic/types/billing_price_response_data.py new file mode 100644 index 0000000..6fe9f27 --- /dev/null +++ b/src/schematic/types/billing_price_response_data.py @@ -0,0 +1,22 @@ +# 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 + + +class BillingPriceResponseData(UniversalBaseModel): + external_price_id: str + id: str + interval: str + price: int + + 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/schematic/types/billing_product_detail_response_data.py b/src/schematic/types/billing_product_detail_response_data.py new file mode 100644 index 0000000..c877576 --- /dev/null +++ b/src/schematic/types/billing_product_detail_response_data.py @@ -0,0 +1,33 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.pydantic_utilities import UniversalBaseModel +import typing_extensions +import typing +from .billing_price_response_data import BillingPriceResponseData +from ..core.serialization import FieldMetadata +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class BillingProductDetailResponseData(UniversalBaseModel): + prices: typing_extensions.Annotated[typing.List[BillingPriceResponseData], FieldMetadata(alias="Prices")] + account_id: str + created_at: dt.datetime + currency: str + environment_id: str + external_id: str + name: str + price: float + product_id: str + quantity: float + updated_at: dt.datetime + + 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/schematic/types/billing_product_for_subscription_response_data.py b/src/schematic/types/billing_product_for_subscription_response_data.py new file mode 100644 index 0000000..8efc6a5 --- /dev/null +++ b/src/schematic/types/billing_product_for_subscription_response_data.py @@ -0,0 +1,31 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.pydantic_utilities import UniversalBaseModel +import datetime as dt +import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class BillingProductForSubscriptionResponseData(UniversalBaseModel): + account_id: str + created_at: dt.datetime + currency: str + environment_id: str + external_id: str + id: str + interval: typing.Optional[str] = None + name: str + price: float + quantity: float + subscription_id: str + updated_at: dt.datetime + + 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/schematic/types/billing_product_plan_response_data.py b/src/schematic/types/billing_product_plan_response_data.py new file mode 100644 index 0000000..516468d --- /dev/null +++ b/src/schematic/types/billing_product_plan_response_data.py @@ -0,0 +1,28 @@ +# 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 + + +class BillingProductPlanResponseData(UniversalBaseModel): + """ + The updated resource + """ + + account_id: str + billing_product_id: str + environment_id: str + monthly_price_id: typing.Optional[str] = None + plan_id: str + yearly_price_id: 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/schematic/types/billing_product_pricing.py b/src/schematic/types/billing_product_pricing.py new file mode 100644 index 0000000..429e86b --- /dev/null +++ b/src/schematic/types/billing_product_pricing.py @@ -0,0 +1,22 @@ +# 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 + + +class BillingProductPricing(UniversalBaseModel): + interval: typing.Optional[str] = None + price: int + price_external_id: typing.Optional[str] = None + product_external_id: str + + 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/schematic/types/billing_product_response_data.py b/src/schematic/types/billing_product_response_data.py index a3e3999..55faa73 100644 --- a/src/schematic/types/billing_product_response_data.py +++ b/src/schematic/types/billing_product_response_data.py @@ -1,17 +1,16 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.pydantic_utilities import UniversalBaseModel import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class BillingProductResponseData(pydantic_v1.BaseModel): +class BillingProductResponseData(UniversalBaseModel): account_id: str created_at: dt.datetime currency: str - deleted_at: typing.Optional[dt.datetime] = None environment_id: str external_id: str name: str @@ -20,20 +19,11 @@ class BillingProductResponseData(pydantic_v1.BaseModel): quantity: float updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/billing_subscription_response_data.py b/src/schematic/types/billing_subscription_response_data.py index 868a954..298064b 100644 --- a/src/schematic/types/billing_subscription_response_data.py +++ b/src/schematic/types/billing_subscription_response_data.py @@ -1,37 +1,27 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class BillingSubscriptionResponseData(pydantic_v1.BaseModel): +class BillingSubscriptionResponseData(UniversalBaseModel): """ The created resource """ - deleted_at: typing.Optional[dt.datetime] = None expired_at: typing.Optional[dt.datetime] = None external_id: str id: int updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/check_flag_output_with_flag_key.py b/src/schematic/types/check_flag_output_with_flag_key.py index 4388964..3c21bec 100644 --- a/src/schematic/types/check_flag_output_with_flag_key.py +++ b/src/schematic/types/check_flag_output_with_flag_key.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CheckFlagOutputWithFlagKey(pydantic_v1.BaseModel): +class CheckFlagOutputWithFlagKey(UniversalBaseModel): company_id: typing.Optional[str] = None error: typing.Optional[str] = None flag: str @@ -16,20 +15,11 @@ class CheckFlagOutputWithFlagKey(pydantic_v1.BaseModel): user_id: typing.Optional[str] = None value: bool - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/check_flag_request_body.py b/src/schematic/types/check_flag_request_body.py index 8f2c6bf..de1067a 100644 --- a/src/schematic/types/check_flag_request_body.py +++ b/src/schematic/types/check_flag_request_body.py @@ -1,30 +1,20 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +class CheckFlagRequestBody(UniversalBaseModel): + company: typing.Optional[typing.Dict[str, str]] = None + user: typing.Optional[typing.Dict[str, str]] = None -class CheckFlagRequestBody(pydantic_v1.BaseModel): - company: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None - user: typing.Optional[typing.Dict[str, 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: - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/check_flag_response_data.py b/src/schematic/types/check_flag_response_data.py index 8c664a8..a4542b1 100644 --- a/src/schematic/types/check_flag_response_data.py +++ b/src/schematic/types/check_flag_response_data.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CheckFlagResponseData(pydantic_v1.BaseModel): +class CheckFlagResponseData(UniversalBaseModel): """ The returned resource """ @@ -19,20 +18,11 @@ class CheckFlagResponseData(pydantic_v1.BaseModel): user_id: typing.Optional[str] = None value: bool - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/check_flags_response_data.py b/src/schematic/types/check_flags_response_data.py index 7a340ae..958e8d6 100644 --- a/src/schematic/types/check_flags_response_data.py +++ b/src/schematic/types/check_flags_response_data.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .check_flag_output_with_flag_key import CheckFlagOutputWithFlagKey +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class CheckFlagsResponseData(pydantic_v1.BaseModel): +class CheckFlagsResponseData(UniversalBaseModel): """ The created resource """ flags: typing.List[CheckFlagOutputWithFlagKey] - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/company_crm_deals_response_data.py b/src/schematic/types/company_crm_deals_response_data.py index 70c4ca7..a06e502 100644 --- a/src/schematic/types/company_crm_deals_response_data.py +++ b/src/schematic/types/company_crm_deals_response_data.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .crm_deal_line_item import CrmDealLineItem +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class CompanyCrmDealsResponseData(pydantic_v1.BaseModel): +class CompanyCrmDealsResponseData(UniversalBaseModel): deal_arr: str deal_external_id: str deal_mrr: str deal_name: typing.Optional[str] = None line_items: typing.List[CrmDealLineItem] - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/company_detail_response_data.py b/src/schematic/types/company_detail_response_data.py index 150521c..7cf03a5 100644 --- a/src/schematic/types/company_detail_response_data.py +++ b/src/schematic/types/company_detail_response_data.py @@ -1,16 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from .entity_key_detail_response_data import EntityKeyDetailResponseData +from .billing_plan import BillingPlan +import datetime as dt from .entity_trait_detail_response_data import EntityTraitDetailResponseData +from .entity_key_detail_response_data import EntityKeyDetailResponseData from .preview_object import PreviewObject +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -class CompanyDetailResponseData(pydantic_v1.BaseModel): +class CompanyDetailResponseData(UniversalBaseModel): + add_ons: typing.List[BillingPlan] created_at: dt.datetime entity_traits: typing.List[EntityTraitDetailResponseData] environment_id: str @@ -19,8 +21,9 @@ class CompanyDetailResponseData(pydantic_v1.BaseModel): last_seen_at: typing.Optional[dt.datetime] = None logo_url: typing.Optional[str] = None name: str + plan: typing.Optional[BillingPlan] = None plans: typing.List[PreviewObject] - traits: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None) + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) """ A map of trait names to trait values """ @@ -28,20 +31,11 @@ class CompanyDetailResponseData(pydantic_v1.BaseModel): updated_at: dt.datetime user_count: int - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/company_membership_detail_response_data.py b/src/schematic/types/company_membership_detail_response_data.py index 7d1b8a6..fcf4bf6 100644 --- a/src/schematic/types/company_membership_detail_response_data.py +++ b/src/schematic/types/company_membership_detail_response_data.py @@ -1,14 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .company_response_data import CompanyResponseData +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class CompanyMembershipDetailResponseData(pydantic_v1.BaseModel): +class CompanyMembershipDetailResponseData(UniversalBaseModel): company: typing.Optional[CompanyResponseData] = None company_id: str created_at: dt.datetime @@ -16,20 +16,11 @@ class CompanyMembershipDetailResponseData(pydantic_v1.BaseModel): updated_at: dt.datetime user_id: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/company_membership_response_data.py b/src/schematic/types/company_membership_response_data.py index ef194e7..5b7884b 100644 --- a/src/schematic/types/company_membership_response_data.py +++ b/src/schematic/types/company_membership_response_data.py @@ -1,33 +1,24 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.pydantic_utilities import UniversalBaseModel import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CompanyMembershipResponseData(pydantic_v1.BaseModel): +class CompanyMembershipResponseData(UniversalBaseModel): company_id: str created_at: dt.datetime id: str updated_at: dt.datetime user_id: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/company_override_response_data.py b/src/schematic/types/company_override_response_data.py index 2202559..61e7472 100644 --- a/src/schematic/types/company_override_response_data.py +++ b/src/schematic/types/company_override_response_data.py @@ -1,16 +1,16 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .company_detail_response_data import CompanyDetailResponseData -from .entity_trait_definition_response_data import EntityTraitDefinitionResponseData +import datetime as dt from .feature_response_data import FeatureResponseData +from .entity_trait_definition_response_data import EntityTraitDefinitionResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class CompanyOverrideResponseData(pydantic_v1.BaseModel): +class CompanyOverrideResponseData(UniversalBaseModel): """ The updated resource """ @@ -31,20 +31,11 @@ class CompanyOverrideResponseData(pydantic_v1.BaseModel): value_trait_id: typing.Optional[str] = None value_type: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/company_plan_detail_response_data.py b/src/schematic/types/company_plan_detail_response_data.py new file mode 100644 index 0000000..67e14d7 --- /dev/null +++ b/src/schematic/types/company_plan_detail_response_data.py @@ -0,0 +1,39 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.pydantic_utilities import UniversalBaseModel +import typing +from .billing_product_detail_response_data import BillingProductDetailResponseData +import datetime as dt +from .plan_entitlement_response_data import PlanEntitlementResponseData +from .feature_detail_response_data import FeatureDetailResponseData +from .billing_price_response_data import BillingPriceResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class CompanyPlanDetailResponseData(UniversalBaseModel): + audience_type: typing.Optional[str] = None + billing_product: typing.Optional[BillingProductDetailResponseData] = None + company_count: int + created_at: dt.datetime + current: bool + description: str + entitlements: typing.List[PlanEntitlementResponseData] + features: typing.List[FeatureDetailResponseData] + icon: str + id: str + monthly_price: typing.Optional[BillingPriceResponseData] = None + name: str + plan_type: str + updated_at: dt.datetime + valid: bool + yearly_price: typing.Optional[BillingPriceResponseData] = 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/schematic/types/company_plan_response_data.py b/src/schematic/types/company_plan_response_data.py deleted file mode 100644 index 4d1db94..0000000 --- a/src/schematic/types/company_plan_response_data.py +++ /dev/null @@ -1,34 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - - -class CompanyPlanResponseData(pydantic_v1.BaseModel): - company_id: str - created_at: dt.datetime - environment_id: str - id: str - plan_id: str - updated_at: dt.datetime - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/types/company_response_data.py b/src/schematic/types/company_response_data.py index 9e072aa..8f1ab3e 100644 --- a/src/schematic/types/company_response_data.py +++ b/src/schematic/types/company_response_data.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 ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CompanyResponseData(pydantic_v1.BaseModel): +class CompanyResponseData(UniversalBaseModel): created_at: dt.datetime environment_id: str id: str @@ -16,20 +16,11 @@ class CompanyResponseData(pydantic_v1.BaseModel): name: str updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/company_subscription_response_data.py b/src/schematic/types/company_subscription_response_data.py index 71e7118..38070c5 100644 --- a/src/schematic/types/company_subscription_response_data.py +++ b/src/schematic/types/company_subscription_response_data.py @@ -1,34 +1,30 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from .billing_product_response_data import BillingProductResponseData +import datetime as dt +from .invoice_response_data import InvoiceResponseData +from .payment_method_response_data import PaymentMethodResponseData +from .billing_product_for_subscription_response_data import BillingProductForSubscriptionResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class CompanySubscriptionResponseData(pydantic_v1.BaseModel): +class CompanySubscriptionResponseData(UniversalBaseModel): customer_external_id: str expired_at: typing.Optional[dt.datetime] = None interval: str - products: typing.List[BillingProductResponseData] + latest_invoice: typing.Optional[InvoiceResponseData] = None + payment_method: typing.Optional[PaymentMethodResponseData] = None + products: typing.List[BillingProductForSubscriptionResponseData] subscription_external_id: str + total_price: int - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/component_hydrate_response_data.py b/src/schematic/types/component_hydrate_response_data.py new file mode 100644 index 0000000..ac92861 --- /dev/null +++ b/src/schematic/types/component_hydrate_response_data.py @@ -0,0 +1,36 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.pydantic_utilities import UniversalBaseModel +import typing +from .company_plan_detail_response_data import CompanyPlanDetailResponseData +from .company_detail_response_data import CompanyDetailResponseData +from .component_response_data import ComponentResponseData +from .feature_usage_detail_response_data import FeatureUsageDetailResponseData +from .stripe_embed_info import StripeEmbedInfo +from .company_subscription_response_data import CompanySubscriptionResponseData +from .invoice_response_data import InvoiceResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class ComponentHydrateResponseData(UniversalBaseModel): + """ + The returned resource + """ + + active_plans: typing.List[CompanyPlanDetailResponseData] + company: typing.Optional[CompanyDetailResponseData] = None + component: typing.Optional[ComponentResponseData] = None + feature_usage: typing.Optional[FeatureUsageDetailResponseData] = None + stripe_embed: typing.Optional[StripeEmbedInfo] = None + subscription: typing.Optional[CompanySubscriptionResponseData] = None + upcoming_invoice: typing.Optional[InvoiceResponseData] = 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/schematic/types/component_response_data.py b/src/schematic/types/component_response_data.py new file mode 100644 index 0000000..37d4f1b --- /dev/null +++ b/src/schematic/types/component_response_data.py @@ -0,0 +1,30 @@ +# 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 pydantic + + +class ComponentResponseData(UniversalBaseModel): + """ + The updated resource + """ + + ast: typing.Optional[typing.Dict[str, float]] = None + created_at: dt.datetime + id: str + name: str + state: str + type: str + updated_at: dt.datetime + + 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/schematic/types/count_response.py b/src/schematic/types/count_response.py index c9ca1f1..2cd259b 100644 --- a/src/schematic/types/count_response.py +++ b/src/schematic/types/count_response.py @@ -1,33 +1,23 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountResponse(pydantic_v1.BaseModel): +class CountResponse(UniversalBaseModel): """ The created resource """ count: int - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/create_event_request_body.py b/src/schematic/types/create_event_request_body.py index 7dd0d40..a88da01 100644 --- a/src/schematic/types/create_event_request_body.py +++ b/src/schematic/types/create_event_request_body.py @@ -1,40 +1,31 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from .create_event_request_body_event_type import CreateEventRequestBodyEventType from .event_body import EventBody +from .create_event_request_body_event_type import CreateEventRequestBodyEventType +import pydantic +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -class CreateEventRequestBody(pydantic_v1.BaseModel): +class CreateEventRequestBody(UniversalBaseModel): body: typing.Optional[EventBody] = None - event_type: CreateEventRequestBodyEventType = pydantic_v1.Field() + event_type: CreateEventRequestBodyEventType = pydantic.Field() """ Either 'identify' or 'track' """ - sent_at: typing.Optional[dt.datetime] = pydantic_v1.Field(default=None) + sent_at: typing.Optional[dt.datetime] = pydantic.Field(default=None) """ Optionally provide a timestamp at which the event was sent to Schematic """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/create_event_request_body_event_type.py b/src/schematic/types/create_event_request_body_event_type.py index 7909028..b7ba268 100644 --- a/src/schematic/types/create_event_request_body_event_type.py +++ b/src/schematic/types/create_event_request_body_event_type.py @@ -2,4 +2,4 @@ import typing -CreateEventRequestBodyEventType = typing.Union[typing.Literal["identify", "track"], typing.Any] +CreateEventRequestBodyEventType = typing.Union[typing.Literal["identify", "track", "flag_check"], typing.Any] diff --git a/src/schematic/types/create_flag_request_body.py b/src/schematic/types/create_flag_request_body.py index ce25c1f..7914c8b 100644 --- a/src/schematic/types/create_flag_request_body.py +++ b/src/schematic/types/create_flag_request_body.py @@ -1,34 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CreateFlagRequestBody(pydantic_v1.BaseModel): +class CreateFlagRequestBody(UniversalBaseModel): default_value: bool description: str feature_id: typing.Optional[str] = None flag_type: str key: str + maintainer_id: typing.Optional[str] = None name: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/create_or_update_condition_group_request_body.py b/src/schematic/types/create_or_update_condition_group_request_body.py index b7a773a..7c113da 100644 --- a/src/schematic/types/create_or_update_condition_group_request_body.py +++ b/src/schematic/types/create_or_update_condition_group_request_body.py @@ -1,33 +1,23 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .create_or_update_condition_request_body import CreateOrUpdateConditionRequestBody +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class CreateOrUpdateConditionGroupRequestBody(pydantic_v1.BaseModel): +class CreateOrUpdateConditionGroupRequestBody(UniversalBaseModel): conditions: typing.List[CreateOrUpdateConditionRequestBody] flag_id: typing.Optional[str] = None id: typing.Optional[str] = None plan_id: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/create_or_update_condition_request_body.py b/src/schematic/types/create_or_update_condition_request_body.py index cfb8a60..5d36754 100644 --- a/src/schematic/types/create_or_update_condition_request_body.py +++ b/src/schematic/types/create_or_update_condition_request_body.py @@ -1,68 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import pydantic from .create_or_update_condition_request_body_condition_type import CreateOrUpdateConditionRequestBodyConditionType from .create_or_update_condition_request_body_metric_period import CreateOrUpdateConditionRequestBodyMetricPeriod from .create_or_update_condition_request_body_operator import CreateOrUpdateConditionRequestBodyOperator +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -class CreateOrUpdateConditionRequestBody(pydantic_v1.BaseModel): - comparison_trait_id: typing.Optional[str] = pydantic_v1.Field(default=None) +class CreateOrUpdateConditionRequestBody(UniversalBaseModel): + comparison_trait_id: typing.Optional[str] = pydantic.Field(default=None) """ Optionally provide a trait ID to compare a metric or trait value against instead of a value """ condition_type: CreateOrUpdateConditionRequestBodyConditionType - event_subtype: typing.Optional[str] = pydantic_v1.Field(default=None) + event_subtype: typing.Optional[str] = pydantic.Field(default=None) """ Name of track event type used to measure this condition """ id: typing.Optional[str] = None - metric_period: typing.Optional[CreateOrUpdateConditionRequestBodyMetricPeriod] = pydantic_v1.Field(default=None) + metric_period: typing.Optional[CreateOrUpdateConditionRequestBodyMetricPeriod] = pydantic.Field(default=None) """ Period of time over which to measure the track event metric """ - metric_value: int = pydantic_v1.Field() + metric_value: typing.Optional[int] = pydantic.Field(default=None) """ Value to compare the track event metric against """ operator: CreateOrUpdateConditionRequestBodyOperator - resource_ids: typing.List[str] = pydantic_v1.Field() + resource_ids: typing.List[str] = pydantic.Field() """ List of resource IDs (companies, users, or plans) targeted by this condition """ - trait_id: typing.Optional[str] = pydantic_v1.Field(default=None) + trait_id: typing.Optional[str] = pydantic.Field(default=None) """ ID of trait to use to measure this condition """ - trait_value: typing.Optional[str] = pydantic_v1.Field(default=None) + trait_value: typing.Optional[str] = pydantic.Field(default=None) """ Value to compare the trait value against """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/create_or_update_flag_request_body.py b/src/schematic/types/create_or_update_flag_request_body.py index f55067a..837efa9 100644 --- a/src/schematic/types/create_or_update_flag_request_body.py +++ b/src/schematic/types/create_or_update_flag_request_body.py @@ -1,35 +1,26 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CreateOrUpdateFlagRequestBody(pydantic_v1.BaseModel): +class CreateOrUpdateFlagRequestBody(UniversalBaseModel): default_value: bool description: str feature_id: typing.Optional[str] = None flag_type: str id: typing.Optional[str] = None key: str + maintainer_id: typing.Optional[str] = None name: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/create_or_update_rule_request_body.py b/src/schematic/types/create_or_update_rule_request_body.py index 7e5f7bb..38d6dd4 100644 --- a/src/schematic/types/create_or_update_rule_request_body.py +++ b/src/schematic/types/create_or_update_rule_request_body.py @@ -1,16 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .create_or_update_condition_group_request_body import CreateOrUpdateConditionGroupRequestBody from .create_or_update_condition_request_body import CreateOrUpdateConditionRequestBody from .create_or_update_rule_request_body_rule_type import CreateOrUpdateRuleRequestBodyRuleType +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class CreateOrUpdateRuleRequestBody(pydantic_v1.BaseModel): +class CreateOrUpdateRuleRequestBody(UniversalBaseModel): condition_groups: typing.List[CreateOrUpdateConditionGroupRequestBody] conditions: typing.List[CreateOrUpdateConditionRequestBody] id: typing.Optional[str] = None @@ -19,20 +18,11 @@ class CreateOrUpdateRuleRequestBody(pydantic_v1.BaseModel): rule_type: typing.Optional[CreateOrUpdateRuleRequestBodyRuleType] = None value: bool - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/create_req_common.py b/src/schematic/types/create_req_common.py index 0cfd81a..8f4a063 100644 --- a/src/schematic/types/create_req_common.py +++ b/src/schematic/types/create_req_common.py @@ -1,15 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .create_req_common_metric_period import CreateReqCommonMetricPeriod from .create_req_common_value_type import CreateReqCommonValueType +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class CreateReqCommon(pydantic_v1.BaseModel): +class CreateReqCommon(UniversalBaseModel): feature_id: str metric_period: typing.Optional[CreateReqCommonMetricPeriod] = None value_bool: typing.Optional[bool] = None @@ -17,20 +16,11 @@ class CreateReqCommon(pydantic_v1.BaseModel): value_trait_id: typing.Optional[str] = None value_type: CreateReqCommonValueType - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/create_req_common_value_type.py b/src/schematic/types/create_req_common_value_type.py index a5223b8..5029608 100644 --- a/src/schematic/types/create_req_common_value_type.py +++ b/src/schematic/types/create_req_common_value_type.py @@ -2,4 +2,4 @@ import typing -CreateReqCommonValueType = typing.Union[typing.Literal["Boolean", "Numeric", "Trait", "Unlimited"], typing.Any] +CreateReqCommonValueType = typing.Union[typing.Literal["boolean", "numeric", "trait", "unlimited"], typing.Any] diff --git a/src/schematic/types/crm_deal_line_item.py b/src/schematic/types/crm_deal_line_item.py index dcfc00e..e9fc90d 100644 --- a/src/schematic/types/crm_deal_line_item.py +++ b/src/schematic/types/crm_deal_line_item.py @@ -1,18 +1,17 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.pydantic_utilities import UniversalBaseModel import datetime as dt import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .decimal import Decimal +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class CrmDealLineItem(pydantic_v1.BaseModel): +class CrmDealLineItem(UniversalBaseModel): billing_frequency: str created_at: dt.datetime currency: str - deleted_at: typing.Optional[dt.datetime] = None description: str discount_percentage: typing.Optional[Decimal] = None id: str @@ -23,20 +22,11 @@ class CrmDealLineItem(pydantic_v1.BaseModel): total_discount: typing.Optional[Decimal] = None updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/crm_deal_response_data.py b/src/schematic/types/crm_deal_response_data.py index 3bccef4..b9a7cdf 100644 --- a/src/schematic/types/crm_deal_response_data.py +++ b/src/schematic/types/crm_deal_response_data.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class CrmDealResponseData(pydantic_v1.BaseModel): +class CrmDealResponseData(UniversalBaseModel): """ The created resource """ @@ -18,27 +18,17 @@ class CrmDealResponseData(pydantic_v1.BaseModel): created_at: dt.datetime deal_external_id: str deal_id: str - deleted_at: typing.Optional[dt.datetime] = None environment_id: str mrr: str name: typing.Optional[str] = None product_external_id: typing.Optional[str] = None updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/crm_line_item_response_data.py b/src/schematic/types/crm_line_item_response_data.py index d455b3f..b792dbf 100644 --- a/src/schematic/types/crm_line_item_response_data.py +++ b/src/schematic/types/crm_line_item_response_data.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 ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CrmLineItemResponseData(pydantic_v1.BaseModel): +class CrmLineItemResponseData(UniversalBaseModel): """ The created resource """ @@ -15,25 +15,15 @@ class CrmLineItemResponseData(pydantic_v1.BaseModel): account_id: str created_at: dt.datetime deal_id: typing.Optional[str] = None - deleted_at: typing.Optional[dt.datetime] = None environment_id: str product_external_id: typing.Optional[str] = None updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/crm_product_response_data.py b/src/schematic/types/crm_product_response_data.py index 2ccc4ad..ff0f9ec 100644 --- a/src/schematic/types/crm_product_response_data.py +++ b/src/schematic/types/crm_product_response_data.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 +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CrmProductResponseData(pydantic_v1.BaseModel): +class CrmProductResponseData(UniversalBaseModel): """ The created resource """ @@ -15,7 +15,6 @@ class CrmProductResponseData(pydantic_v1.BaseModel): account_id: str created_at: dt.datetime currency: str - deleted_at: typing.Optional[dt.datetime] = None environment_id: str external_id: str name: str @@ -24,20 +23,11 @@ class CrmProductResponseData(pydantic_v1.BaseModel): quantity: float updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/decimal.py b/src/schematic/types/decimal.py index b290d5b..ebeb4f8 100644 --- a/src/schematic/types/decimal.py +++ b/src/schematic/types/decimal.py @@ -2,4 +2,4 @@ import typing -Decimal = typing.Dict[str, typing.Any] +Decimal = typing.Dict[str, typing.Optional[typing.Any]] diff --git a/src/schematic/types/delete_response.py b/src/schematic/types/delete_response.py index 545e663..960047f 100644 --- a/src/schematic/types/delete_response.py +++ b/src/schematic/types/delete_response.py @@ -1,32 +1,22 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class DeleteResponse(pydantic_v1.BaseModel): - deleted: typing.Optional[bool] = pydantic_v1.Field(default=None) +class DeleteResponse(UniversalBaseModel): + deleted: typing.Optional[bool] = pydantic.Field(default=None) """ Whether the delete was successful """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/entity_key_definition_response_data.py b/src/schematic/types/entity_key_definition_response_data.py index 9f3962d..dd847e4 100644 --- a/src/schematic/types/entity_key_definition_response_data.py +++ b/src/schematic/types/entity_key_definition_response_data.py @@ -1,33 +1,24 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.pydantic_utilities import UniversalBaseModel import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class EntityKeyDefinitionResponseData(pydantic_v1.BaseModel): +class EntityKeyDefinitionResponseData(UniversalBaseModel): created_at: dt.datetime entity_type: str id: str key: str updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/entity_key_detail_response_data.py b/src/schematic/types/entity_key_detail_response_data.py index 37c48ca..c9a8bf9 100644 --- a/src/schematic/types/entity_key_detail_response_data.py +++ b/src/schematic/types/entity_key_detail_response_data.py @@ -1,14 +1,14 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.pydantic_utilities import UniversalBaseModel import datetime as dt import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .entity_key_definition_response_data import EntityKeyDefinitionResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class EntityKeyDetailResponseData(pydantic_v1.BaseModel): +class EntityKeyDetailResponseData(UniversalBaseModel): created_at: dt.datetime definition: typing.Optional[EntityKeyDefinitionResponseData] = None definition_id: str @@ -20,20 +20,11 @@ class EntityKeyDetailResponseData(pydantic_v1.BaseModel): updated_at: dt.datetime value: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/entity_key_response_data.py b/src/schematic/types/entity_key_response_data.py index 884c4b3..254fb34 100644 --- a/src/schematic/types/entity_key_response_data.py +++ b/src/schematic/types/entity_key_response_data.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 +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class EntityKeyResponseData(pydantic_v1.BaseModel): +class EntityKeyResponseData(UniversalBaseModel): created_at: dt.datetime definition_id: str entity_id: str @@ -18,20 +18,11 @@ class EntityKeyResponseData(pydantic_v1.BaseModel): updated_at: dt.datetime value: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/entity_trait_definition_response_data.py b/src/schematic/types/entity_trait_definition_response_data.py index d7dbd1f..65ce14a 100644 --- a/src/schematic/types/entity_trait_definition_response_data.py +++ b/src/schematic/types/entity_trait_definition_response_data.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 ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class EntityTraitDefinitionResponseData(pydantic_v1.BaseModel): +class EntityTraitDefinitionResponseData(UniversalBaseModel): created_at: dt.datetime display_name: str entity_type: str @@ -16,20 +16,11 @@ class EntityTraitDefinitionResponseData(pydantic_v1.BaseModel): trait_type: str updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/entity_trait_detail_response_data.py b/src/schematic/types/entity_trait_detail_response_data.py index 68b82f8..3958c01 100644 --- a/src/schematic/types/entity_trait_detail_response_data.py +++ b/src/schematic/types/entity_trait_detail_response_data.py @@ -1,14 +1,14 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.pydantic_utilities import UniversalBaseModel import datetime as dt import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .entity_trait_definition_response_data import EntityTraitDefinitionResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class EntityTraitDetailResponseData(pydantic_v1.BaseModel): +class EntityTraitDetailResponseData(UniversalBaseModel): created_at: dt.datetime definition: typing.Optional[EntityTraitDefinitionResponseData] = None definition_id: str @@ -17,20 +17,11 @@ class EntityTraitDetailResponseData(pydantic_v1.BaseModel): updated_at: dt.datetime value: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/entity_trait_response_data.py b/src/schematic/types/entity_trait_response_data.py index 5d6f0d5..cb80d46 100644 --- a/src/schematic/types/entity_trait_response_data.py +++ b/src/schematic/types/entity_trait_response_data.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 +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class EntityTraitResponseData(pydantic_v1.BaseModel): +class EntityTraitResponseData(UniversalBaseModel): created_at: dt.datetime definition_id: str environment_id: str @@ -15,20 +15,11 @@ class EntityTraitResponseData(pydantic_v1.BaseModel): updated_at: dt.datetime value: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/entity_trait_value.py b/src/schematic/types/entity_trait_value.py index 084ae58..799872c 100644 --- a/src/schematic/types/entity_trait_value.py +++ b/src/schematic/types/entity_trait_value.py @@ -1,30 +1,20 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class EntityTraitValue(pydantic_v1.BaseModel): +class EntityTraitValue(UniversalBaseModel): definition_id: str value: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/environment_detail_response_data.py b/src/schematic/types/environment_detail_response_data.py index 37c42d8..1909c46 100644 --- a/src/schematic/types/environment_detail_response_data.py +++ b/src/schematic/types/environment_detail_response_data.py @@ -1,14 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .api_key_response_data import ApiKeyResponseData +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class EnvironmentDetailResponseData(pydantic_v1.BaseModel): +class EnvironmentDetailResponseData(UniversalBaseModel): """ The created resource """ @@ -20,20 +20,11 @@ class EnvironmentDetailResponseData(pydantic_v1.BaseModel): name: str updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/environment_response_data.py b/src/schematic/types/environment_response_data.py index d14dc43..29df87b 100644 --- a/src/schematic/types/environment_response_data.py +++ b/src/schematic/types/environment_response_data.py @@ -1,33 +1,28 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.pydantic_utilities import UniversalBaseModel import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +class EnvironmentResponseData(UniversalBaseModel): + """ + The updated resource + """ -class EnvironmentResponseData(pydantic_v1.BaseModel): created_at: dt.datetime environment_type: str id: str name: str updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/event_body.py b/src/schematic/types/event_body.py index 61038dd..de900e6 100644 --- a/src/schematic/types/event_body.py +++ b/src/schematic/types/event_body.py @@ -1,8 +1,8 @@ # This file was auto-generated by Fern from our API Definition. import typing - -from .event_body_identify import EventBodyIdentify from .event_body_track import EventBodyTrack +from .event_body_flag_check import EventBodyFlagCheck +from .event_body_identify import EventBodyIdentify -EventBody = typing.Union[EventBodyTrack, EventBodyIdentify] +EventBody = typing.Union[EventBodyTrack, EventBodyFlagCheck, EventBodyIdentify] diff --git a/src/schematic/types/event_body_flag_check.py b/src/schematic/types/event_body_flag_check.py new file mode 100644 index 0000000..b51a264 --- /dev/null +++ b/src/schematic/types/event_body_flag_check.py @@ -0,0 +1,67 @@ +# 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 + + +class EventBodyFlagCheck(UniversalBaseModel): + company_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Schematic company ID (starting with 'comp\_') of the company evaluated, if any + """ + + error: typing.Optional[str] = pydantic.Field(default=None) + """ + Report an error that occurred during the flag check + """ + + flag_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Schematic flag ID (starting with 'flag\_') for the flag matching the key, if any + """ + + flag_key: str = pydantic.Field() + """ + The key of the flag being checked + """ + + reason: str = pydantic.Field() + """ + The reason why the value was returned + """ + + req_company: typing.Optional[typing.Dict[str, str]] = pydantic.Field(default=None) + """ + Key-value pairs used to to identify company for which the flag was checked + """ + + req_user: typing.Optional[typing.Dict[str, str]] = pydantic.Field(default=None) + """ + Key-value pairs used to to identify user for which the flag was checked + """ + + rule_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Schematic rule ID (starting with 'rule\_') of the rule that matched for the flag, if any + """ + + user_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Schematic user ID (starting with 'user\_') of the user evaluated, if any + """ + + value: bool = pydantic.Field() + """ + The value of the flag for the given company and/or user + """ + + 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/schematic/types/event_body_identify.py b/src/schematic/types/event_body_identify.py index bce141b..0208216 100644 --- a/src/schematic/types/event_body_identify.py +++ b/src/schematic/types/event_body_identify.py @@ -1,48 +1,38 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .event_body_identify_company import EventBodyIdentifyCompany +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -class EventBodyIdentify(pydantic_v1.BaseModel): - company: typing.Optional[EventBodyIdentifyCompany] = pydantic_v1.Field(default=None) +class EventBodyIdentify(UniversalBaseModel): + company: typing.Optional[EventBodyIdentifyCompany] = pydantic.Field(default=None) """ Information about the company associated with the user; required only if it is a new user """ - keys: typing.Dict[str, str] = pydantic_v1.Field() + keys: typing.Dict[str, str] = pydantic.Field() """ Key-value pairs to identify the user """ - name: typing.Optional[str] = pydantic_v1.Field(default=None) + name: typing.Optional[str] = pydantic.Field(default=None) """ The display name of the user being identified; required only if it is a new user """ - traits: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None) + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) """ A map of trait names to trait values """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/event_body_identify_company.py b/src/schematic/types/event_body_identify_company.py index a42cd41..16bfab2 100644 --- a/src/schematic/types/event_body_identify_company.py +++ b/src/schematic/types/event_body_identify_company.py @@ -1,46 +1,36 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class EventBodyIdentifyCompany(pydantic_v1.BaseModel): +class EventBodyIdentifyCompany(UniversalBaseModel): """ Information about the company associated with the user; required only if it is a new user """ - keys: typing.Dict[str, str] = pydantic_v1.Field() + keys: typing.Dict[str, str] = pydantic.Field() """ Key-value pairs to identify the company """ - name: typing.Optional[str] = pydantic_v1.Field(default=None) + name: typing.Optional[str] = pydantic.Field(default=None) """ The display name of the company; required only if it is a new company """ - traits: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None) + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) """ A map of trait names to trait values """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/event_body_track.py b/src/schematic/types/event_body_track.py index 3a6006d..abbd7c9 100644 --- a/src/schematic/types/event_body_track.py +++ b/src/schematic/types/event_body_track.py @@ -1,47 +1,37 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class EventBodyTrack(pydantic_v1.BaseModel): - company: typing.Optional[typing.Dict[str, str]] = pydantic_v1.Field(default=None) +class EventBodyTrack(UniversalBaseModel): + company: typing.Optional[typing.Dict[str, str]] = pydantic.Field(default=None) """ Key-value pairs to identify company associated with track event """ - event: str = pydantic_v1.Field() + event: str = pydantic.Field() """ The name of the type of track event """ - traits: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None) + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) """ A map of trait names to trait values """ - user: typing.Optional[typing.Dict[str, str]] = pydantic_v1.Field(default=None) + user: typing.Optional[typing.Dict[str, str]] = pydantic.Field(default=None) """ Key-value pairs to identify user associated with track event """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/event_detail_response_data.py b/src/schematic/types/event_detail_response_data.py index 2bdf3a7..c9eb39c 100644 --- a/src/schematic/types/event_detail_response_data.py +++ b/src/schematic/types/event_detail_response_data.py @@ -1,16 +1,16 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import datetime as dt from .preview_object import PreviewObject +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class EventDetailResponseData(pydantic_v1.BaseModel): +class EventDetailResponseData(UniversalBaseModel): api_key: typing.Optional[str] = None - body: typing.Dict[str, typing.Any] + body: typing.Dict[str, typing.Optional[typing.Any]] body_preview: str captured_at: dt.datetime company: typing.Optional[PreviewObject] = None @@ -31,20 +31,11 @@ class EventDetailResponseData(pydantic_v1.BaseModel): user: typing.Optional[PreviewObject] = None user_id: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/event_response_data.py b/src/schematic/types/event_response_data.py index 1259ae9..0172842 100644 --- a/src/schematic/types/event_response_data.py +++ b/src/schematic/types/event_response_data.py @@ -1,15 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class EventResponseData(pydantic_v1.BaseModel): +class EventResponseData(UniversalBaseModel): api_key: typing.Optional[str] = None - body: typing.Dict[str, typing.Any] + body: typing.Dict[str, typing.Optional[typing.Any]] body_preview: str captured_at: dt.datetime company_id: typing.Optional[str] = None @@ -27,20 +27,11 @@ class EventResponseData(pydantic_v1.BaseModel): updated_at: dt.datetime user_id: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/event_summary_response_data.py b/src/schematic/types/event_summary_response_data.py index 7a112f6..2cd71a3 100644 --- a/src/schematic/types/event_summary_response_data.py +++ b/src/schematic/types/event_summary_response_data.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class EventSummaryResponseData(pydantic_v1.BaseModel): +class EventSummaryResponseData(UniversalBaseModel): company_count: int environment_id: str event_count: int @@ -15,20 +15,11 @@ class EventSummaryResponseData(pydantic_v1.BaseModel): last_seen_at: typing.Optional[dt.datetime] = None user_count: int - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/feature_company_response_data.py b/src/schematic/types/feature_company_response_data.py index 3355a11..f7437dd 100644 --- a/src/schematic/types/feature_company_response_data.py +++ b/src/schematic/types/feature_company_response_data.py @@ -1,55 +1,51 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel +import pydantic import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .feature_company_response_data_allocation_type import FeatureCompanyResponseDataAllocationType from .company_detail_response_data import CompanyDetailResponseData from .feature_detail_response_data import FeatureDetailResponseData from .plan_response_data import PlanResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -class FeatureCompanyResponseData(pydantic_v1.BaseModel): - access: bool = pydantic_v1.Field() +class FeatureCompanyResponseData(UniversalBaseModel): + access: bool = pydantic.Field() """ Whether further usage is permitted. """ - allocation: typing.Optional[int] = pydantic_v1.Field(default=None) + allocation: typing.Optional[int] = pydantic.Field(default=None) """ The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted. """ + allocation_type: FeatureCompanyResponseDataAllocationType = pydantic.Field() + """ + The type of allocation that is being used. + """ + company: typing.Optional[CompanyDetailResponseData] = None entitlement_id: str entitlement_type: str feature: typing.Optional[FeatureDetailResponseData] = None - period: typing.Optional[str] = pydantic_v1.Field(default=None) + period: typing.Optional[str] = pydantic.Field(default=None) """ The period over which usage is measured. """ plan: typing.Optional[PlanResponseData] = None - usage: typing.Optional[int] = pydantic_v1.Field(default=None) + usage: typing.Optional[int] = pydantic.Field(default=None) """ The amount of usage that has been consumed; a null value indicates that usage is not being measured. """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/feature_company_response_data_allocation_type.py b/src/schematic/types/feature_company_response_data_allocation_type.py new file mode 100644 index 0000000..68b803b --- /dev/null +++ b/src/schematic/types/feature_company_response_data_allocation_type.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +FeatureCompanyResponseDataAllocationType = typing.Union[ + typing.Literal["boolean", "numeric", "trait", "unlimited"], typing.Any +] diff --git a/src/schematic/types/feature_company_user_response_data.py b/src/schematic/types/feature_company_user_response_data.py index fd6f2a2..6c89a1b 100644 --- a/src/schematic/types/feature_company_user_response_data.py +++ b/src/schematic/types/feature_company_user_response_data.py @@ -1,58 +1,54 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel +import pydantic import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .feature_company_user_response_data_allocation_type import FeatureCompanyUserResponseDataAllocationType from .company_detail_response_data import CompanyDetailResponseData from .feature_detail_response_data import FeatureDetailResponseData from .plan_response_data import PlanResponseData from .user_response_data import UserResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -class FeatureCompanyUserResponseData(pydantic_v1.BaseModel): - access: bool = pydantic_v1.Field() +class FeatureCompanyUserResponseData(UniversalBaseModel): + access: bool = pydantic.Field() """ Whether further usage is permitted. """ - allocation: typing.Optional[int] = pydantic_v1.Field(default=None) + allocation: typing.Optional[int] = pydantic.Field(default=None) """ The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted. """ + allocation_type: FeatureCompanyUserResponseDataAllocationType = pydantic.Field() + """ + The type of allocation that is being used. + """ + company: typing.Optional[CompanyDetailResponseData] = None entitlement_id: str entitlement_type: str feature: typing.Optional[FeatureDetailResponseData] = None - period: typing.Optional[str] = pydantic_v1.Field(default=None) + period: typing.Optional[str] = pydantic.Field(default=None) """ The period over which usage is measured. """ plan: typing.Optional[PlanResponseData] = None - usage: typing.Optional[int] = pydantic_v1.Field(default=None) + usage: typing.Optional[int] = pydantic.Field(default=None) """ The amount of usage that has been consumed; a null value indicates that usage is not being measured. """ user: typing.Optional[UserResponseData] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/feature_company_user_response_data_allocation_type.py b/src/schematic/types/feature_company_user_response_data_allocation_type.py new file mode 100644 index 0000000..1dd789d --- /dev/null +++ b/src/schematic/types/feature_company_user_response_data_allocation_type.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +FeatureCompanyUserResponseDataAllocationType = typing.Union[ + typing.Literal["boolean", "numeric", "trait", "unlimited"], typing.Any +] diff --git a/src/schematic/types/feature_detail_response_data.py b/src/schematic/types/feature_detail_response_data.py index b4d5b70..7ad893a 100644 --- a/src/schematic/types/feature_detail_response_data.py +++ b/src/schematic/types/feature_detail_response_data.py @@ -1,45 +1,38 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.pydantic_utilities import UniversalBaseModel import datetime as dt import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from .entity_trait_definition_response_data import EntityTraitDefinitionResponseData from .event_summary_response_data import EventSummaryResponseData from .flag_detail_response_data import FlagDetailResponseData from .preview_object import PreviewObject +from .entity_trait_definition_response_data import EntityTraitDefinitionResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class FeatureDetailResponseData(pydantic_v1.BaseModel): +class FeatureDetailResponseData(UniversalBaseModel): created_at: dt.datetime description: str event_subtype: typing.Optional[str] = None event_summary: typing.Optional[EventSummaryResponseData] = None feature_type: str flags: typing.List[FlagDetailResponseData] + icon: str id: str lifecycle_phase: typing.Optional[str] = None + maintainer_id: typing.Optional[str] = None name: str plans: typing.List[PreviewObject] trait: typing.Optional[EntityTraitDefinitionResponseData] = None trait_id: typing.Optional[str] = None updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/feature_response_data.py b/src/schematic/types/feature_response_data.py index 354769b..6ddfadc 100644 --- a/src/schematic/types/feature_response_data.py +++ b/src/schematic/types/feature_response_data.py @@ -1,37 +1,30 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.pydantic_utilities import UniversalBaseModel import datetime as dt import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class FeatureResponseData(pydantic_v1.BaseModel): +class FeatureResponseData(UniversalBaseModel): created_at: dt.datetime description: str event_subtype: typing.Optional[str] = None feature_type: str + icon: str id: str lifecycle_phase: typing.Optional[str] = None + maintainer_id: typing.Optional[str] = None name: str trait_id: typing.Optional[str] = None updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/feature_usage_detail_response_data.py b/src/schematic/types/feature_usage_detail_response_data.py index d81c3e0..65f25fb 100644 --- a/src/schematic/types/feature_usage_detail_response_data.py +++ b/src/schematic/types/feature_usage_detail_response_data.py @@ -1,34 +1,20 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .feature_usage_response_data import FeatureUsageResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class FeatureUsageDetailResponseData(pydantic_v1.BaseModel): - """ - The returned resource - """ - +class FeatureUsageDetailResponseData(UniversalBaseModel): features: typing.List[FeatureUsageResponseData] - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/feature_usage_response_data.py b/src/schematic/types/feature_usage_response_data.py index 8034de6..fee6948 100644 --- a/src/schematic/types/feature_usage_response_data.py +++ b/src/schematic/types/feature_usage_response_data.py @@ -1,53 +1,49 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel +import pydantic import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .feature_usage_response_data_allocation_type import FeatureUsageResponseDataAllocationType from .feature_detail_response_data import FeatureDetailResponseData from .plan_response_data import PlanResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -class FeatureUsageResponseData(pydantic_v1.BaseModel): - access: bool = pydantic_v1.Field() +class FeatureUsageResponseData(UniversalBaseModel): + access: bool = pydantic.Field() """ Whether further usage is permitted. """ - allocation: typing.Optional[int] = pydantic_v1.Field(default=None) + allocation: typing.Optional[int] = pydantic.Field(default=None) """ The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted. """ + allocation_type: FeatureUsageResponseDataAllocationType = pydantic.Field() + """ + The type of allocation that is being used. + """ + entitlement_id: str entitlement_type: str feature: typing.Optional[FeatureDetailResponseData] = None - period: typing.Optional[str] = pydantic_v1.Field(default=None) + period: typing.Optional[str] = pydantic.Field(default=None) """ The period over which usage is measured. """ plan: typing.Optional[PlanResponseData] = None - usage: typing.Optional[int] = pydantic_v1.Field(default=None) + usage: typing.Optional[int] = pydantic.Field(default=None) """ The amount of usage that has been consumed; a null value indicates that usage is not being measured. """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/feature_usage_response_data_allocation_type.py b/src/schematic/types/feature_usage_response_data_allocation_type.py new file mode 100644 index 0000000..dbabb1c --- /dev/null +++ b/src/schematic/types/feature_usage_response_data_allocation_type.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +FeatureUsageResponseDataAllocationType = typing.Union[ + typing.Literal["boolean", "numeric", "trait", "unlimited"], typing.Any +] diff --git a/src/schematic/types/flag_check_log_detail_response_data.py b/src/schematic/types/flag_check_log_detail_response_data.py deleted file mode 100644 index aacd371..0000000 --- a/src/schematic/types/flag_check_log_detail_response_data.py +++ /dev/null @@ -1,53 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from .company_response_data import CompanyResponseData -from .environment_response_data import EnvironmentResponseData -from .flag_response_data import FlagResponseData -from .rule_response_data import RuleResponseData -from .user_response_data import UserResponseData - - -class FlagCheckLogDetailResponseData(pydantic_v1.BaseModel): - check_status: str - company: typing.Optional[CompanyResponseData] = None - company_id: typing.Optional[str] = None - created_at: dt.datetime - environment: typing.Optional[EnvironmentResponseData] = None - environment_id: str - error: typing.Optional[str] = None - flag: typing.Optional[FlagResponseData] = None - flag_id: typing.Optional[str] = None - flag_key: str - id: str - reason: str - req_company: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None - req_user: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None - rule: typing.Optional[RuleResponseData] = None - rule_id: typing.Optional[str] = None - updated_at: dt.datetime - user: typing.Optional[UserResponseData] = None - user_id: typing.Optional[str] = None - value: bool - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/types/flag_check_log_response_data.py b/src/schematic/types/flag_check_log_response_data.py deleted file mode 100644 index 8227b82..0000000 --- a/src/schematic/types/flag_check_log_response_data.py +++ /dev/null @@ -1,43 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - - -class FlagCheckLogResponseData(pydantic_v1.BaseModel): - check_status: str - company_id: typing.Optional[str] = None - created_at: dt.datetime - environment_id: str - error: typing.Optional[str] = None - flag_id: typing.Optional[str] = None - flag_key: str - id: str - reason: str - req_company: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None - req_user: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None - rule_id: typing.Optional[str] = None - updated_at: dt.datetime - user_id: typing.Optional[str] = None - value: bool - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) - - class Config: - frozen = True - smart_union = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/types/flag_detail_response_data.py b/src/schematic/types/flag_detail_response_data.py index 55447c9..d5d5765 100644 --- a/src/schematic/types/flag_detail_response_data.py +++ b/src/schematic/types/flag_detail_response_data.py @@ -1,16 +1,15 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.pydantic_utilities import UniversalBaseModel import datetime as dt import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .feature_response_data import FeatureResponseData -from .flag_check_log_response_data import FlagCheckLogResponseData from .rule_detail_response_data import RuleDetailResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class FlagDetailResponseData(pydantic_v1.BaseModel): +class FlagDetailResponseData(UniversalBaseModel): created_at: dt.datetime default_value: bool description: str @@ -19,25 +18,17 @@ class FlagDetailResponseData(pydantic_v1.BaseModel): flag_type: str id: str key: str - latest_check: typing.Optional[FlagCheckLogResponseData] = None + last_checked_at: typing.Optional[dt.datetime] = None + maintainer_id: typing.Optional[str] = None name: str rules: typing.List[RuleDetailResponseData] updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/flag_response_data.py b/src/schematic/types/flag_response_data.py index 5e2a668..2a68eb2 100644 --- a/src/schematic/types/flag_response_data.py +++ b/src/schematic/types/flag_response_data.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 ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class FlagResponseData(pydantic_v1.BaseModel): +class FlagResponseData(UniversalBaseModel): created_at: dt.datetime default_value: bool description: str @@ -15,23 +15,15 @@ class FlagResponseData(pydantic_v1.BaseModel): flag_type: str id: str key: str + maintainer_id: typing.Optional[str] = None name: str updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/invoice_request_body.py b/src/schematic/types/invoice_request_body.py new file mode 100644 index 0000000..0c47639 --- /dev/null +++ b/src/schematic/types/invoice_request_body.py @@ -0,0 +1,29 @@ +# 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 pydantic + + +class InvoiceRequestBody(UniversalBaseModel): + amount_due: int + amount_paid: int + amount_remaining: int + collection_method: str + currency: str + customer_external_id: str + due_date: typing.Optional[dt.datetime] = None + payment_method_external_id: typing.Optional[str] = None + subscription_external_id: typing.Optional[str] = None + subtotal: int + + 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/schematic/types/invoice_response_data.py b/src/schematic/types/invoice_response_data.py new file mode 100644 index 0000000..b668d24 --- /dev/null +++ b/src/schematic/types/invoice_response_data.py @@ -0,0 +1,35 @@ +# 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 pydantic + + +class InvoiceResponseData(UniversalBaseModel): + amount_due: int + amount_paid: int + amount_remaining: int + collection_method: str + company_id: typing.Optional[str] = None + created_at: dt.datetime + currency: str + customer_external_id: str + due_date: typing.Optional[dt.datetime] = None + environment_id: str + external_id: str + id: str + payment_method_external_id: typing.Optional[str] = None + subscription_external_id: typing.Optional[str] = None + subtotal: int + updated_at: dt.datetime + + 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/schematic/types/issue_temporary_access_token_response_data.py b/src/schematic/types/issue_temporary_access_token_response_data.py new file mode 100644 index 0000000..1364268 --- /dev/null +++ b/src/schematic/types/issue_temporary_access_token_response_data.py @@ -0,0 +1,31 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.pydantic_utilities import UniversalBaseModel +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing +import pydantic + + +class IssueTemporaryAccessTokenResponseData(UniversalBaseModel): + """ + The created resource + """ + + api_key_id: str + created_at: dt.datetime + environment_id: str + expired_at: dt.datetime + id: str + resource_type: str + token: str + updated_at: dt.datetime + + 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/schematic/types/keys_request_body.py b/src/schematic/types/keys_request_body.py index 511203a..8c4b587 100644 --- a/src/schematic/types/keys_request_body.py +++ b/src/schematic/types/keys_request_body.py @@ -1,29 +1,19 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class KeysRequestBody(pydantic_v1.BaseModel): +class KeysRequestBody(UniversalBaseModel): keys: typing.Dict[str, str] - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/metric_counts_hourly_response_data.py b/src/schematic/types/metric_counts_hourly_response_data.py index 4ccadb1..ab5d950 100644 --- a/src/schematic/types/metric_counts_hourly_response_data.py +++ b/src/schematic/types/metric_counts_hourly_response_data.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class MetricCountsHourlyResponseData(pydantic_v1.BaseModel): +class MetricCountsHourlyResponseData(UniversalBaseModel): company_id: typing.Optional[str] = None created_at: dt.datetime environment_id: str @@ -16,20 +16,11 @@ class MetricCountsHourlyResponseData(pydantic_v1.BaseModel): user_id: typing.Optional[str] = None value: int - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/pagination_filter.py b/src/schematic/types/pagination_filter.py index 6a79c38..398fa48 100644 --- a/src/schematic/types/pagination_filter.py +++ b/src/schematic/types/pagination_filter.py @@ -1,37 +1,27 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class PaginationFilter(pydantic_v1.BaseModel): - limit: typing.Optional[int] = pydantic_v1.Field(default=None) +class PaginationFilter(UniversalBaseModel): + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/payment_method_request_body.py b/src/schematic/types/payment_method_request_body.py new file mode 100644 index 0000000..ae3c6ae --- /dev/null +++ b/src/schematic/types/payment_method_request_body.py @@ -0,0 +1,27 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.pydantic_utilities import UniversalBaseModel +import typing +import typing_extensions +from ..core.serialization import FieldMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class PaymentMethodRequestBody(UniversalBaseModel): + card_brand: typing.Optional[str] = None + card_exp_month: typing.Optional[int] = None + card_exp_year: typing.Optional[int] = None + card_last_4: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="card_last4")] = None + customer_external_id: str + payment_method_type: str + subscription_external_id: 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/schematic/types/payment_method_response_data.py b/src/schematic/types/payment_method_response_data.py new file mode 100644 index 0000000..2f99a0f --- /dev/null +++ b/src/schematic/types/payment_method_response_data.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.pydantic_utilities import UniversalBaseModel +import typing +import typing_extensions +from ..core.serialization import FieldMetadata +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class PaymentMethodResponseData(UniversalBaseModel): + card_brand: typing.Optional[str] = None + card_exp_month: typing.Optional[int] = None + card_exp_year: typing.Optional[int] = None + card_last_4: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="card_last4")] = None + company_id: typing.Optional[str] = None + created_at: dt.datetime + customer_external_id: str + environment_id: str + external_id: str + id: str + payment_method_type: str + subscription_external_id: typing.Optional[str] = None + updated_at: dt.datetime + + 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/schematic/types/plan_audience_detail_response_data.py b/src/schematic/types/plan_audience_detail_response_data.py index aa02277..d5b60f9 100644 --- a/src/schematic/types/plan_audience_detail_response_data.py +++ b/src/schematic/types/plan_audience_detail_response_data.py @@ -1,15 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from .rule_condition_detail_response_data import RuleConditionDetailResponseData from .rule_condition_group_detail_response_data import RuleConditionGroupDetailResponseData +from .rule_condition_detail_response_data import RuleConditionDetailResponseData +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class PlanAudienceDetailResponseData(pydantic_v1.BaseModel): +class PlanAudienceDetailResponseData(UniversalBaseModel): """ The updated resource """ @@ -27,20 +27,11 @@ class PlanAudienceDetailResponseData(pydantic_v1.BaseModel): updated_at: dt.datetime value: bool - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/plan_audience_response_data.py b/src/schematic/types/plan_audience_response_data.py index d902f34..e707cea 100644 --- a/src/schematic/types/plan_audience_response_data.py +++ b/src/schematic/types/plan_audience_response_data.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 ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class PlanAudienceResponseData(pydantic_v1.BaseModel): +class PlanAudienceResponseData(UniversalBaseModel): created_at: dt.datetime environment_id: str flag_id: typing.Optional[str] = None @@ -19,20 +19,11 @@ class PlanAudienceResponseData(pydantic_v1.BaseModel): updated_at: dt.datetime value: bool - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/plan_detail_response_data.py b/src/schematic/types/plan_detail_response_data.py index 6249a8d..1fec9a7 100644 --- a/src/schematic/types/plan_detail_response_data.py +++ b/src/schematic/types/plan_detail_response_data.py @@ -1,41 +1,35 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .billing_product_detail_response_data import BillingProductDetailResponseData +import datetime as dt from .feature_detail_response_data import FeatureDetailResponseData +from .billing_price_response_data import BillingPriceResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class PlanDetailResponseData(pydantic_v1.BaseModel): - """ - The updated resource - """ - +class PlanDetailResponseData(UniversalBaseModel): + audience_type: typing.Optional[str] = None + billing_product: typing.Optional[BillingProductDetailResponseData] = None company_count: int created_at: dt.datetime description: str features: typing.List[FeatureDetailResponseData] + icon: str id: str + monthly_price: typing.Optional[BillingPriceResponseData] = None name: str plan_type: str updated_at: dt.datetime + yearly_price: typing.Optional[BillingPriceResponseData] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/plan_entitlement_response_data.py b/src/schematic/types/plan_entitlement_response_data.py index 6c97315..314d7ee 100644 --- a/src/schematic/types/plan_entitlement_response_data.py +++ b/src/schematic/types/plan_entitlement_response_data.py @@ -1,20 +1,16 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.pydantic_utilities import UniversalBaseModel import datetime as dt import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from .entity_trait_definition_response_data import EntityTraitDefinitionResponseData from .feature_response_data import FeatureResponseData from .plan_response_data import PlanResponseData +from .entity_trait_definition_response_data import EntityTraitDefinitionResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class PlanEntitlementResponseData(pydantic_v1.BaseModel): - """ - The updated resource - """ - +class PlanEntitlementResponseData(UniversalBaseModel): created_at: dt.datetime environment_id: str feature: typing.Optional[FeatureResponseData] = None @@ -31,20 +27,11 @@ class PlanEntitlementResponseData(pydantic_v1.BaseModel): value_trait_id: typing.Optional[str] = None value_type: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/plan_group_detail_response_data.py b/src/schematic/types/plan_group_detail_response_data.py new file mode 100644 index 0000000..a70cb69 --- /dev/null +++ b/src/schematic/types/plan_group_detail_response_data.py @@ -0,0 +1,27 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.pydantic_utilities import UniversalBaseModel +import typing +from .plan_group_plan_detail_response_data import PlanGroupPlanDetailResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class PlanGroupDetailResponseData(UniversalBaseModel): + """ + The returned resource + """ + + default_plan: typing.Optional[PlanGroupPlanDetailResponseData] = None + default_plan_id: typing.Optional[str] = None + id: str + plans: typing.List[PlanGroupPlanDetailResponseData] + + 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/schematic/types/plan_group_plan_detail_response_data.py b/src/schematic/types/plan_group_plan_detail_response_data.py new file mode 100644 index 0000000..a9e496d --- /dev/null +++ b/src/schematic/types/plan_group_plan_detail_response_data.py @@ -0,0 +1,38 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.pydantic_utilities import UniversalBaseModel +import typing +from .billing_product_detail_response_data import BillingProductDetailResponseData +import datetime as dt +from .plan_entitlement_response_data import PlanEntitlementResponseData +from .feature_detail_response_data import FeatureDetailResponseData +from .billing_price_response_data import BillingPriceResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class PlanGroupPlanDetailResponseData(UniversalBaseModel): + audience_type: typing.Optional[str] = None + billing_product: typing.Optional[BillingProductDetailResponseData] = None + company_count: int + created_at: dt.datetime + description: str + entitlements: typing.List[PlanEntitlementResponseData] + features: typing.List[FeatureDetailResponseData] + icon: str + id: str + is_default: bool + monthly_price: typing.Optional[BillingPriceResponseData] = None + name: str + plan_type: str + updated_at: dt.datetime + yearly_price: typing.Optional[BillingPriceResponseData] = 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/schematic/types/plan_group_response_data.py b/src/schematic/types/plan_group_response_data.py new file mode 100644 index 0000000..c8fd682 --- /dev/null +++ b/src/schematic/types/plan_group_response_data.py @@ -0,0 +1,25 @@ +# 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 + + +class PlanGroupResponseData(UniversalBaseModel): + """ + The updated resource + """ + + default_plan_id: typing.Optional[str] = None + id: str + plan_ids: typing.List[str] + + 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/schematic/types/plan_response_data.py b/src/schematic/types/plan_response_data.py index 3b25069..6ea3a74 100644 --- a/src/schematic/types/plan_response_data.py +++ b/src/schematic/types/plan_response_data.py @@ -1,34 +1,27 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class PlanResponseData(pydantic_v1.BaseModel): +class PlanResponseData(UniversalBaseModel): + audience_type: typing.Optional[str] = None created_at: dt.datetime description: str + icon: str id: str name: str plan_type: str updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/preview_object.py b/src/schematic/types/preview_object.py index ea8ac1f..26d5c61 100644 --- a/src/schematic/types/preview_object.py +++ b/src/schematic/types/preview_object.py @@ -1,31 +1,22 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class PreviewObject(pydantic_v1.BaseModel): +class PreviewObject(UniversalBaseModel): + description: typing.Optional[str] = None id: str image_url: typing.Optional[str] = None name: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/raw_event_batch_response_data.py b/src/schematic/types/raw_event_batch_response_data.py index e020ce9..221c20c 100644 --- a/src/schematic/types/raw_event_batch_response_data.py +++ b/src/schematic/types/raw_event_batch_response_data.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .raw_event_response_data import RawEventResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class RawEventBatchResponseData(pydantic_v1.BaseModel): +class RawEventBatchResponseData(UniversalBaseModel): """ The created resource """ events: typing.List[RawEventResponseData] - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/raw_event_response_data.py b/src/schematic/types/raw_event_response_data.py index 2b2d26b..3369e96 100644 --- a/src/schematic/types/raw_event_response_data.py +++ b/src/schematic/types/raw_event_response_data.py @@ -1,33 +1,24 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.pydantic_utilities import UniversalBaseModel import datetime as dt import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class RawEventResponseData(pydantic_v1.BaseModel): +class RawEventResponseData(UniversalBaseModel): captured_at: dt.datetime event_id: typing.Optional[str] = None remote_addr: str remote_ip: str user_agent: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/rule_condition_detail_response_data.py b/src/schematic/types/rule_condition_detail_response_data.py index 02e93ec..1b4e60e 100644 --- a/src/schematic/types/rule_condition_detail_response_data.py +++ b/src/schematic/types/rule_condition_detail_response_data.py @@ -1,15 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .entity_trait_definition_response_data import EntityTraitDefinitionResponseData +import datetime as dt from .rule_condition_resource_response_data import RuleConditionResourceResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class RuleConditionDetailResponseData(pydantic_v1.BaseModel): +class RuleConditionDetailResponseData(UniversalBaseModel): comparison_trait: typing.Optional[EntityTraitDefinitionResponseData] = None comparison_trait_id: typing.Optional[str] = None condition_group_id: typing.Optional[str] = None @@ -20,7 +20,7 @@ class RuleConditionDetailResponseData(pydantic_v1.BaseModel): flag_id: typing.Optional[str] = None id: str metric_period: typing.Optional[str] = None - metric_value: int + metric_value: typing.Optional[int] = None operator: str plan_id: typing.Optional[str] = None resource_ids: typing.List[str] @@ -32,20 +32,11 @@ class RuleConditionDetailResponseData(pydantic_v1.BaseModel): trait_value: str updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/rule_condition_group_detail_response_data.py b/src/schematic/types/rule_condition_group_detail_response_data.py index 72b1112..10c7130 100644 --- a/src/schematic/types/rule_condition_group_detail_response_data.py +++ b/src/schematic/types/rule_condition_group_detail_response_data.py @@ -1,14 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .rule_condition_detail_response_data import RuleConditionDetailResponseData +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class RuleConditionGroupDetailResponseData(pydantic_v1.BaseModel): +class RuleConditionGroupDetailResponseData(UniversalBaseModel): conditions: typing.List[RuleConditionDetailResponseData] created_at: dt.datetime environment_id: str @@ -18,20 +18,11 @@ class RuleConditionGroupDetailResponseData(pydantic_v1.BaseModel): rule_id: str updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/rule_condition_group_response_data.py b/src/schematic/types/rule_condition_group_response_data.py index 5d91181..3ded6ca 100644 --- a/src/schematic/types/rule_condition_group_response_data.py +++ b/src/schematic/types/rule_condition_group_response_data.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 ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class RuleConditionGroupResponseData(pydantic_v1.BaseModel): +class RuleConditionGroupResponseData(UniversalBaseModel): created_at: dt.datetime environment_id: str flag_id: typing.Optional[str] = None @@ -16,20 +16,11 @@ class RuleConditionGroupResponseData(pydantic_v1.BaseModel): rule_id: str updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/rule_condition_resource_response_data.py b/src/schematic/types/rule_condition_resource_response_data.py index 2f724db..cd230e1 100644 --- a/src/schematic/types/rule_condition_resource_response_data.py +++ b/src/schematic/types/rule_condition_resource_response_data.py @@ -1,30 +1,20 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel +from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class RuleConditionResourceResponseData(pydantic_v1.BaseModel): +class RuleConditionResourceResponseData(UniversalBaseModel): id: str name: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/rule_condition_response_data.py b/src/schematic/types/rule_condition_response_data.py index 12618bd..78873ea 100644 --- a/src/schematic/types/rule_condition_response_data.py +++ b/src/schematic/types/rule_condition_response_data.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class RuleConditionResponseData(pydantic_v1.BaseModel): +class RuleConditionResponseData(UniversalBaseModel): comparison_trait_id: typing.Optional[str] = None condition_group_id: typing.Optional[str] = None condition_type: str @@ -17,7 +17,7 @@ class RuleConditionResponseData(pydantic_v1.BaseModel): flag_id: typing.Optional[str] = None id: str metric_period: typing.Optional[str] = None - metric_value: int + metric_value: typing.Optional[int] = None operator: str plan_id: typing.Optional[str] = None resource_ids: typing.List[str] @@ -27,20 +27,11 @@ class RuleConditionResponseData(pydantic_v1.BaseModel): trait_value: str updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/rule_detail_response_data.py b/src/schematic/types/rule_detail_response_data.py index 093552d..d69b7f5 100644 --- a/src/schematic/types/rule_detail_response_data.py +++ b/src/schematic/types/rule_detail_response_data.py @@ -1,15 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from .rule_condition_detail_response_data import RuleConditionDetailResponseData from .rule_condition_group_detail_response_data import RuleConditionGroupDetailResponseData +from .rule_condition_detail_response_data import RuleConditionDetailResponseData +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class RuleDetailResponseData(pydantic_v1.BaseModel): +class RuleDetailResponseData(UniversalBaseModel): condition_groups: typing.List[RuleConditionGroupDetailResponseData] conditions: typing.List[RuleConditionDetailResponseData] created_at: dt.datetime @@ -23,20 +23,11 @@ class RuleDetailResponseData(pydantic_v1.BaseModel): updated_at: dt.datetime value: bool - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/rule_response_data.py b/src/schematic/types/rule_response_data.py index bfeb045..df2f68b 100644 --- a/src/schematic/types/rule_response_data.py +++ b/src/schematic/types/rule_response_data.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 ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class RuleResponseData(pydantic_v1.BaseModel): +class RuleResponseData(UniversalBaseModel): created_at: dt.datetime environment_id: str flag_id: typing.Optional[str] = None @@ -19,20 +19,11 @@ class RuleResponseData(pydantic_v1.BaseModel): updated_at: dt.datetime value: bool - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/rules_detail_response_data.py b/src/schematic/types/rules_detail_response_data.py index b9a0261..f068742 100644 --- a/src/schematic/types/rules_detail_response_data.py +++ b/src/schematic/types/rules_detail_response_data.py @@ -1,38 +1,28 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel +import typing_extensions import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .flag_response_data import FlagResponseData +from ..core.serialization import FieldMetadata from .rule_detail_response_data import RuleDetailResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class RulesDetailResponseData(pydantic_v1.BaseModel): +class RulesDetailResponseData(UniversalBaseModel): """ The updated resource """ - flag: typing.Optional[FlagResponseData] = pydantic_v1.Field(alias="Flag", default=None) + flag: typing_extensions.Annotated[typing.Optional[FlagResponseData], FieldMetadata(alias="Flag")] = None rules: typing.List[RuleDetailResponseData] - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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 - allow_population_by_field_name = True - populate_by_name = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/segment_status_resp.py b/src/schematic/types/segment_status_resp.py index 95d828f..4c3e18a 100644 --- a/src/schematic/types/segment_status_resp.py +++ b/src/schematic/types/segment_status_resp.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class SegmentStatusResp(pydantic_v1.BaseModel): +class SegmentStatusResp(UniversalBaseModel): """ The returned resource """ @@ -16,20 +16,11 @@ class SegmentStatusResp(pydantic_v1.BaseModel): environment_id: str last_event_at: typing.Optional[dt.datetime] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/stripe_embed_info.py b/src/schematic/types/stripe_embed_info.py new file mode 100644 index 0000000..2d69907 --- /dev/null +++ b/src/schematic/types/stripe_embed_info.py @@ -0,0 +1,21 @@ +# 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 + + +class StripeEmbedInfo(UniversalBaseModel): + customer_ekey: typing.Optional[str] = None + publishable_key: str + setup_intent_client_secret: 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/schematic/types/temporary_access_token_response_data.py b/src/schematic/types/temporary_access_token_response_data.py new file mode 100644 index 0000000..692bde6 --- /dev/null +++ b/src/schematic/types/temporary_access_token_response_data.py @@ -0,0 +1,26 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.pydantic_utilities import UniversalBaseModel +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import typing +import pydantic + + +class TemporaryAccessTokenResponseData(UniversalBaseModel): + api_key_id: str + created_at: dt.datetime + environment_id: str + expired_at: dt.datetime + id: str + resource_type: str + updated_at: dt.datetime + + 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/schematic/types/update_req_common.py b/src/schematic/types/update_req_common.py index 3b25d14..168537e 100644 --- a/src/schematic/types/update_req_common.py +++ b/src/schematic/types/update_req_common.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .update_req_common_metric_period import UpdateReqCommonMetricPeriod from .update_req_common_value_type import UpdateReqCommonValueType +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class UpdateReqCommon(pydantic_v1.BaseModel): +class UpdateReqCommon(UniversalBaseModel): metric_period: typing.Optional[UpdateReqCommonMetricPeriod] = None value_bool: typing.Optional[bool] = None value_numeric: typing.Optional[int] = None value_trait_id: typing.Optional[str] = None value_type: UpdateReqCommonValueType - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/update_req_common_value_type.py b/src/schematic/types/update_req_common_value_type.py index dc38d7e..4ef818e 100644 --- a/src/schematic/types/update_req_common_value_type.py +++ b/src/schematic/types/update_req_common_value_type.py @@ -2,4 +2,4 @@ import typing -UpdateReqCommonValueType = typing.Union[typing.Literal["Boolean", "Numeric", "Trait", "Unlimited"], typing.Any] +UpdateReqCommonValueType = typing.Union[typing.Literal["boolean", "numeric", "trait", "unlimited"], typing.Any] diff --git a/src/schematic/types/update_rule_request_body.py b/src/schematic/types/update_rule_request_body.py index 25573a7..e904fe2 100644 --- a/src/schematic/types/update_rule_request_body.py +++ b/src/schematic/types/update_rule_request_body.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .create_or_update_condition_group_request_body import CreateOrUpdateConditionGroupRequestBody from .create_or_update_condition_request_body import CreateOrUpdateConditionRequestBody +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class UpdateRuleRequestBody(pydantic_v1.BaseModel): +class UpdateRuleRequestBody(UniversalBaseModel): condition_groups: typing.List[CreateOrUpdateConditionGroupRequestBody] conditions: typing.List[CreateOrUpdateConditionRequestBody] name: str priority: int value: bool - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/upsert_company_request_body.py b/src/schematic/types/upsert_company_request_body.py index b00bfa2..ad55314 100644 --- a/src/schematic/types/upsert_company_request_body.py +++ b/src/schematic/types/upsert_company_request_body.py @@ -1,38 +1,33 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +class UpsertCompanyRequestBody(UniversalBaseModel): + id: typing.Optional[str] = pydantic.Field(default=None) + """ + If you know the Schematic ID, you can use that here instead of keys + """ -class UpsertCompanyRequestBody(pydantic_v1.BaseModel): - id: typing.Optional[str] = None keys: typing.Dict[str, str] last_seen_at: typing.Optional[dt.datetime] = None name: typing.Optional[str] = None - traits: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None) + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) """ A map of trait names to trait values """ update_only: typing.Optional[bool] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/upsert_trait_request_body.py b/src/schematic/types/upsert_trait_request_body.py index 544e8a6..2690298 100644 --- a/src/schematic/types/upsert_trait_request_body.py +++ b/src/schematic/types/upsert_trait_request_body.py @@ -1,54 +1,44 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +import typing_extensions +from ..core.serialization import FieldMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class UpsertTraitRequestBody(pydantic_v1.BaseModel): - incr: typing.Optional[int] = pydantic_v1.Field(default=None) +class UpsertTraitRequestBody(UniversalBaseModel): + incr: typing.Optional[int] = pydantic.Field(default=None) """ Amount to increment the trait by (positive or negative) """ - keys: typing.Dict[str, str] = pydantic_v1.Field() + keys: typing.Dict[str, str] = pydantic.Field() """ Key/value pairs too identify a company or user """ - set_: typing.Optional[str] = pydantic_v1.Field(alias="set", default=None) + set_: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="set")] = pydantic.Field(default=None) """ Value to set the trait to """ - trait: str = pydantic_v1.Field() + trait: str = pydantic.Field() """ Name of the trait to update """ - update_only: typing.Optional[bool] = pydantic_v1.Field(default=None) + update_only: typing.Optional[bool] = pydantic.Field(default=None) """ Unless this is set, the company or user will be created if it does not already exist """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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 - allow_population_by_field_name = True - populate_by_name = True - extra = pydantic_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/upsert_user_request_body.py b/src/schematic/types/upsert_user_request_body.py index 3e756c7..ceda904 100644 --- a/src/schematic/types/upsert_user_request_body.py +++ b/src/schematic/types/upsert_user_request_body.py @@ -1,47 +1,43 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import pydantic +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -class UpsertUserRequestBody(pydantic_v1.BaseModel): - company: typing.Dict[str, str] = pydantic_v1.Field() +class UpsertUserRequestBody(UniversalBaseModel): + company: typing.Dict[str, str] = pydantic.Field() """ Optionally specify company using key/value pairs """ - company_id: typing.Optional[str] = pydantic_v1.Field(default=None) + company_id: typing.Optional[str] = pydantic.Field(default=None) """ Optionally specify company using Schematic company ID """ + id: typing.Optional[str] = pydantic.Field(default=None) + """ + If you know the Schematic ID, you can use that here instead of keys + """ + keys: typing.Dict[str, str] last_seen_at: typing.Optional[dt.datetime] = None name: typing.Optional[str] = None - traits: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None) + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) """ A map of trait names to trait values """ update_only: typing.Optional[bool] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/upsert_user_sub_request_body.py b/src/schematic/types/upsert_user_sub_request_body.py index 3a3cf6f..0977dc5 100644 --- a/src/schematic/types/upsert_user_sub_request_body.py +++ b/src/schematic/types/upsert_user_sub_request_body.py @@ -1,42 +1,38 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +import pydantic +import datetime as dt +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -class UpsertUserSubRequestBody(pydantic_v1.BaseModel): - company_id: typing.Optional[str] = pydantic_v1.Field(default=None) +class UpsertUserSubRequestBody(UniversalBaseModel): + company_id: typing.Optional[str] = pydantic.Field(default=None) """ Optionally specify company using Schematic company ID """ + id: typing.Optional[str] = pydantic.Field(default=None) + """ + If you know the Schematic ID, you can use that here instead of keys + """ + keys: typing.Dict[str, str] last_seen_at: typing.Optional[dt.datetime] = None name: typing.Optional[str] = None - traits: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None) + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) """ A map of trait names to trait values """ update_only: typing.Optional[bool] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/user_detail_response_data.py b/src/schematic/types/user_detail_response_data.py index de7f92a..772f728 100644 --- a/src/schematic/types/user_detail_response_data.py +++ b/src/schematic/types/user_detail_response_data.py @@ -1,16 +1,16 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ..core.pydantic_utilities import UniversalBaseModel import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .company_membership_detail_response_data import CompanyMembershipDetailResponseData -from .entity_key_detail_response_data import EntityKeyDetailResponseData +import datetime as dt from .entity_trait_detail_response_data import EntityTraitDetailResponseData +from .entity_key_detail_response_data import EntityKeyDetailResponseData +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 -class UserDetailResponseData(pydantic_v1.BaseModel): +class UserDetailResponseData(UniversalBaseModel): company_memberships: typing.List[CompanyMembershipDetailResponseData] created_at: dt.datetime entity_traits: typing.List[EntityTraitDetailResponseData] @@ -19,27 +19,18 @@ class UserDetailResponseData(pydantic_v1.BaseModel): keys: typing.List[EntityKeyDetailResponseData] last_seen_at: typing.Optional[dt.datetime] = None name: str - traits: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None) + traits: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None) """ A map of trait names to trait values """ updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/user_response_data.py b/src/schematic/types/user_response_data.py index 0fa9a6d..cd76256 100644 --- a/src/schematic/types/user_response_data.py +++ b/src/schematic/types/user_response_data.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 ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class UserResponseData(pydantic_v1.BaseModel): +class UserResponseData(UniversalBaseModel): created_at: dt.datetime environment_id: str id: str @@ -15,20 +15,11 @@ class UserResponseData(pydantic_v1.BaseModel): name: str updated_at: dt.datetime - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/webhook_event_detail_response_data.py b/src/schematic/types/webhook_event_detail_response_data.py index 473b30e..134ac3a 100644 --- a/src/schematic/types/webhook_event_detail_response_data.py +++ b/src/schematic/types/webhook_event_detail_response_data.py @@ -1,16 +1,17 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.pydantic_utilities import UniversalBaseModel import datetime as dt import typing - -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .webhook_response_data import WebhookResponseData +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -class WebhookEventDetailResponseData(pydantic_v1.BaseModel): +class WebhookEventDetailResponseData(UniversalBaseModel): created_at: dt.datetime id: str + payload: typing.Optional[str] = None request_type: str response_code: typing.Optional[int] = None sent_at: typing.Optional[dt.datetime] = None @@ -19,20 +20,11 @@ class WebhookEventDetailResponseData(pydantic_v1.BaseModel): webhook: typing.Optional[WebhookResponseData] = None webhook_id: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/webhook_event_response_data.py b/src/schematic/types/webhook_event_response_data.py index 4f6488c..e207588 100644 --- a/src/schematic/types/webhook_event_response_data.py +++ b/src/schematic/types/webhook_event_response_data.py @@ -1,15 +1,16 @@ # This file was auto-generated by Fern from our API Definition. +from ..core.pydantic_utilities import UniversalBaseModel import datetime as dt import typing +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class WebhookEventResponseData(pydantic_v1.BaseModel): +class WebhookEventResponseData(UniversalBaseModel): created_at: dt.datetime id: str + payload: typing.Optional[str] = None request_type: str response_code: typing.Optional[int] = None sent_at: typing.Optional[dt.datetime] = None @@ -17,20 +18,11 @@ class WebhookEventResponseData(pydantic_v1.BaseModel): updated_at: dt.datetime webhook_id: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/types/webhook_response_data.py b/src/schematic/types/webhook_response_data.py index eec7364..f078340 100644 --- a/src/schematic/types/webhook_response_data.py +++ b/src/schematic/types/webhook_response_data.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 ..core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic -from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class WebhookResponseData(pydantic_v1.BaseModel): +class WebhookResponseData(UniversalBaseModel): created_at: dt.datetime id: str name: str @@ -16,20 +16,11 @@ class WebhookResponseData(pydantic_v1.BaseModel): updated_at: dt.datetime url: str - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/version.py b/src/schematic/version.py index f636d8b..55954a0 100644 --- a/src/schematic/version.py +++ b/src/schematic/version.py @@ -1,4 +1,3 @@ - from importlib import metadata __version__ = metadata.version("schematichq") diff --git a/src/schematic/webhooks/__init__.py b/src/schematic/webhooks/__init__.py index d78c25c..1639137 100644 --- a/src/schematic/webhooks/__init__.py +++ b/src/schematic/webhooks/__init__.py @@ -15,6 +15,7 @@ ListWebhooksParams, ListWebhooksResponse, UpdateWebhookRequestBodyRequestTypesItem, + UpdateWebhookRequestBodyStatus, UpdateWebhookResponse, ) @@ -33,5 +34,6 @@ "ListWebhooksParams", "ListWebhooksResponse", "UpdateWebhookRequestBodyRequestTypesItem", + "UpdateWebhookRequestBodyStatus", "UpdateWebhookResponse", ] diff --git a/src/schematic/webhooks/client.py b/src/schematic/webhooks/client.py index 6cfa0d0..02a9250 100644 --- a/src/schematic/webhooks/client.py +++ b/src/schematic/webhooks/client.py @@ -1,33 +1,31 @@ # This file was auto-generated by Fern from our API Definition. import typing -import urllib.parse -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.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 -from ..core.query_encoder import encode_query -from ..core.remove_none_from_dict import remove_none_from_dict +from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions +from .types.list_webhook_events_response import ListWebhookEventsResponse +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 ..errors.forbidden_error import ForbiddenError 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.get_webhook_event_response import GetWebhookEventResponse +from ..core.jsonable_encoder import jsonable_encoder 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.count_webhook_events_response import CountWebhookEventsResponse -from .types.count_webhooks_response import CountWebhooksResponse +from .types.list_webhooks_response import ListWebhooksResponse from .types.create_webhook_request_body_request_types_item import CreateWebhookRequestBodyRequestTypesItem from .types.create_webhook_response import CreateWebhookResponse -from .types.delete_webhook_response import DeleteWebhookResponse -from .types.get_webhook_event_response import GetWebhookEventResponse from .types.get_webhook_response import GetWebhookResponse -from .types.list_webhook_events_response import ListWebhookEventsResponse -from .types.list_webhooks_response import ListWebhooksResponse from .types.update_webhook_request_body_request_types_item import UpdateWebhookRequestBodyRequestTypesItem +from .types.update_webhook_request_body_status import UpdateWebhookRequestBodyStatus from .types.update_webhook_response import UpdateWebhookResponse +from .types.delete_webhook_response import DeleteWebhookResponse +from .types.count_webhooks_response import CountWebhooksResponse +from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -72,7 +70,7 @@ def list_webhook_events( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -80,55 +78,66 @@ def list_webhook_events( client.webhooks.list_webhook_events() """ _response = self._client_wrapper.httpx_client.request( + "webhook-events", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "webhook-events"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "webhook_id": webhook_id, - "ids": ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "webhook_id": webhook_id, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListWebhookEventsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListWebhookEventsResponse, + parse_obj_as( + type_=ListWebhookEventsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -153,7 +162,7 @@ def get_webhook_event( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -163,44 +172,59 @@ def get_webhook_event( ) """ _response = self._client_wrapper.httpx_client.request( + f"webhook-events/{jsonable_encoder(webhook_event_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"webhook-events/{jsonable_encoder(webhook_event_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetWebhookEventResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetWebhookEventResponse, + parse_obj_as( + type_=GetWebhookEventResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -241,7 +265,7 @@ def count_webhook_events( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -249,55 +273,66 @@ def count_webhook_events( client.webhooks.count_webhook_events() """ _response = self._client_wrapper.httpx_client.request( + "webhook-events/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "webhook-events/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "webhook_id": webhook_id, - "ids": ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "webhook_id": webhook_id, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountWebhookEventsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountWebhookEventsResponse, + parse_obj_as( + type_=CountWebhookEventsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -332,7 +367,7 @@ def list_webhooks( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -340,53 +375,64 @@ def list_webhooks( client.webhooks.list_webhooks() """ _response = self._client_wrapper.httpx_client.request( + "webhooks", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "webhooks"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListWebhooksResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListWebhooksResponse, + parse_obj_as( + type_=ListWebhooksResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -419,7 +465,7 @@ def create_webhook( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -431,48 +477,65 @@ def create_webhook( ) """ _response = self._client_wrapper.httpx_client.request( + "webhooks", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "webhooks"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder({"name": name, "request_types": request_types, "url": url}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"name": name, "request_types": request_types, "url": url}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "name": name, + "request_types": request_types, + "url": url, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateWebhookResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateWebhookResponse, + parse_obj_as( + type_=CreateWebhookResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -497,7 +560,7 @@ def get_webhook( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -507,44 +570,59 @@ def get_webhook( ) """ _response = self._client_wrapper.httpx_client.request( + f"webhooks/{jsonable_encoder(webhook_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"webhooks/{jsonable_encoder(webhook_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetWebhookResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetWebhookResponse, + parse_obj_as( + type_=GetWebhookResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -556,6 +634,7 @@ def update_webhook( *, name: typing.Optional[str] = OMIT, request_types: typing.Optional[typing.Sequence[UpdateWebhookRequestBodyRequestTypesItem]] = OMIT, + status: typing.Optional[UpdateWebhookRequestBodyStatus] = OMIT, url: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UpdateWebhookResponse: @@ -569,6 +648,8 @@ def update_webhook( request_types : typing.Optional[typing.Sequence[UpdateWebhookRequestBodyRequestTypesItem]] + status : typing.Optional[UpdateWebhookRequestBodyStatus] + url : typing.Optional[str] request_options : typing.Optional[RequestOptions] @@ -581,7 +662,7 @@ def update_webhook( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -590,60 +671,77 @@ def update_webhook( webhook_id="webhook_id", ) """ - _request: typing.Dict[str, typing.Any] = {} - if name is not OMIT: - _request["name"] = name - if request_types is not OMIT: - _request["request_types"] = request_types - if url is not OMIT: - _request["url"] = url _response = self._client_wrapper.httpx_client.request( + f"webhooks/{jsonable_encoder(webhook_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"webhooks/{jsonable_encoder(webhook_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "name": name, + "request_types": request_types, + "status": status, + "url": url, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateWebhookResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateWebhookResponse, + parse_obj_as( + type_=UpdateWebhookResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -668,7 +766,7 @@ def delete_webhook( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -678,44 +776,59 @@ def delete_webhook( ) """ _response = self._client_wrapper.httpx_client.request( + f"webhooks/{jsonable_encoder(webhook_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"webhooks/{jsonable_encoder(webhook_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteWebhookResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteWebhookResponse, + parse_obj_as( + type_=DeleteWebhookResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -750,7 +863,7 @@ def count_webhooks( Examples -------- - from schematic.client import Schematic + from schematic import Schematic client = Schematic( api_key="YOUR_API_KEY", @@ -758,53 +871,64 @@ def count_webhooks( client.webhooks.count_webhooks() """ _response = self._client_wrapper.httpx_client.request( + "webhooks/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "webhooks/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountWebhooksResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountWebhooksResponse, + parse_obj_as( + type_=CountWebhooksResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -850,63 +974,82 @@ async def list_webhook_events( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.webhooks.list_webhook_events() + + + async def main() -> None: + await client.webhooks.list_webhook_events() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "webhook-events", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "webhook-events"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "webhook_id": webhook_id, - "ids": ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "webhook_id": webhook_id, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListWebhookEventsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListWebhookEventsResponse, + parse_obj_as( + type_=ListWebhookEventsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -931,54 +1074,77 @@ async def get_webhook_event( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.webhooks.get_webhook_event( - webhook_event_id="webhook_event_id", - ) + + + async def main() -> None: + await client.webhooks.get_webhook_event( + webhook_event_id="webhook_event_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"webhook-events/{jsonable_encoder(webhook_event_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"webhook-events/{jsonable_encoder(webhook_event_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetWebhookEventResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetWebhookEventResponse, + parse_obj_as( + type_=GetWebhookEventResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1019,63 +1185,82 @@ async def count_webhook_events( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.webhooks.count_webhook_events() + + + async def main() -> None: + await client.webhooks.count_webhook_events() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "webhook-events/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "webhook-events/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "webhook_id": webhook_id, - "ids": ids, - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "webhook_id": webhook_id, + "ids": ids, + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountWebhookEventsResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountWebhookEventsResponse, + parse_obj_as( + type_=CountWebhookEventsResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1110,61 +1295,80 @@ async def list_webhooks( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.webhooks.list_webhooks() + + + async def main() -> None: + await client.webhooks.list_webhooks() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "webhooks", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "webhooks"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListWebhooksResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + ListWebhooksResponse, + parse_obj_as( + type_=ListWebhooksResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1197,60 +1401,85 @@ async def create_webhook( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.webhooks.create_webhook( - name="name", - request_types=["company.updated"], - url="url", - ) + + + async def main() -> None: + await client.webhooks.create_webhook( + name="name", + request_types=["company.updated"], + url="url", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "webhooks", method="POST", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "webhooks"), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder({"name": name, "request_types": request_types, "url": url}) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder({"name": name, "request_types": request_types, "url": url}), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "name": name, + "request_types": request_types, + "url": url, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CreateWebhookResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CreateWebhookResponse, + parse_obj_as( + type_=CreateWebhookResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1275,54 +1504,77 @@ async def get_webhook( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.webhooks.get_webhook( - webhook_id="webhook_id", - ) + + + async def main() -> None: + await client.webhooks.get_webhook( + webhook_id="webhook_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"webhooks/{jsonable_encoder(webhook_id)}", method="GET", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"webhooks/{jsonable_encoder(webhook_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetWebhookResponse, _response.json()) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + GetWebhookResponse, + parse_obj_as( + type_=GetWebhookResponse, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1334,6 +1586,7 @@ async def update_webhook( *, name: typing.Optional[str] = OMIT, request_types: typing.Optional[typing.Sequence[UpdateWebhookRequestBodyRequestTypesItem]] = OMIT, + status: typing.Optional[UpdateWebhookRequestBodyStatus] = OMIT, url: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UpdateWebhookResponse: @@ -1347,6 +1600,8 @@ async def update_webhook( request_types : typing.Optional[typing.Sequence[UpdateWebhookRequestBodyRequestTypesItem]] + status : typing.Optional[UpdateWebhookRequestBodyStatus] + url : typing.Optional[str] request_options : typing.Optional[RequestOptions] @@ -1359,69 +1614,94 @@ async def update_webhook( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.webhooks.update_webhook( - webhook_id="webhook_id", - ) + + + async def main() -> None: + await client.webhooks.update_webhook( + webhook_id="webhook_id", + ) + + + asyncio.run(main()) """ - _request: typing.Dict[str, typing.Any] = {} - if name is not OMIT: - _request["name"] = name - if request_types is not OMIT: - _request["request_types"] = request_types - if url is not OMIT: - _request["url"] = url _response = await self._client_wrapper.httpx_client.request( + f"webhooks/{jsonable_encoder(webhook_id)}", method="PUT", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"webhooks/{jsonable_encoder(webhook_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - json=jsonable_encoder(_request) - if request_options is None or request_options.get("additional_body_parameters") is None - else { - **jsonable_encoder(_request), - **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + json={ + "name": name, + "request_types": request_types, + "status": status, + "url": url, }, - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, + omit=OMIT, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UpdateWebhookResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + UpdateWebhookResponse, + parse_obj_as( + type_=UpdateWebhookResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1446,54 +1726,77 @@ async def delete_webhook( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.webhooks.delete_webhook( - webhook_id="webhook_id", - ) + + + async def main() -> None: + await client.webhooks.delete_webhook( + webhook_id="webhook_id", + ) + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + f"webhooks/{jsonable_encoder(webhook_id)}", method="DELETE", - url=urllib.parse.urljoin( - f"{self._client_wrapper.get_base_url()}/", f"webhooks/{jsonable_encoder(webhook_id)}" - ), - params=encode_query( - jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteWebhookResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + DeleteWebhookResponse, + parse_obj_as( + type_=DeleteWebhookResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) @@ -1528,61 +1831,80 @@ async def count_webhooks( Examples -------- - from schematic.client import AsyncSchematic + import asyncio + + from schematic import AsyncSchematic client = AsyncSchematic( api_key="YOUR_API_KEY", ) - await client.webhooks.count_webhooks() + + + async def main() -> None: + await client.webhooks.count_webhooks() + + + asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( + "webhooks/count", method="GET", - url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "webhooks/count"), - params=encode_query( - jsonable_encoder( - remove_none_from_dict( - { - "q": q, - "limit": limit, - "offset": offset, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } - ) - ) - ), - headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ), - timeout=request_options.get("timeout_in_seconds") - if request_options is not None and request_options.get("timeout_in_seconds") is not None - else self._client_wrapper.get_timeout(), - retries=0, - max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + params={ + "q": q, + "limit": limit, + "offset": offset, + }, + request_options=request_options, ) - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CountWebhooksResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 401: - raise UnauthorizedError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) - if _response.status_code == 403: - raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore - if _response.status_code == 500: - raise InternalServerError( - pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore - ) try: + if 200 <= _response.status_code < 300: + return typing.cast( + CountWebhooksResponse, + parse_obj_as( + type_=CountWebhooksResponse, # 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( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # 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) diff --git a/src/schematic/webhooks/types/__init__.py b/src/schematic/webhooks/types/__init__.py index 1671d9a..960befd 100644 --- a/src/schematic/webhooks/types/__init__.py +++ b/src/schematic/webhooks/types/__init__.py @@ -14,6 +14,7 @@ from .list_webhooks_params import ListWebhooksParams from .list_webhooks_response import ListWebhooksResponse from .update_webhook_request_body_request_types_item import UpdateWebhookRequestBodyRequestTypesItem +from .update_webhook_request_body_status import UpdateWebhookRequestBodyStatus from .update_webhook_response import UpdateWebhookResponse __all__ = [ @@ -31,5 +32,6 @@ "ListWebhooksParams", "ListWebhooksResponse", "UpdateWebhookRequestBodyRequestTypesItem", + "UpdateWebhookRequestBodyStatus", "UpdateWebhookResponse", ] diff --git a/src/schematic/webhooks/types/count_webhook_events_params.py b/src/schematic/webhooks/types/count_webhook_events_params.py index 3ff32e8..ce8fd90 100644 --- a/src/schematic/webhooks/types/count_webhook_events_params.py +++ b/src/schematic/webhooks/types/count_webhook_events_params.py @@ -1,24 +1,23 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountWebhookEventsParams(pydantic_v1.BaseModel): +class CountWebhookEventsParams(UniversalBaseModel): """ Input parameters """ ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ @@ -26,20 +25,11 @@ class CountWebhookEventsParams(pydantic_v1.BaseModel): q: typing.Optional[str] = None webhook_id: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/webhooks/types/count_webhook_events_response.py b/src/schematic/webhooks/types/count_webhook_events_response.py index 877a652..aae9b04 100644 --- a/src/schematic/webhooks/types/count_webhook_events_response.py +++ b/src/schematic/webhooks/types/count_webhook_events_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_webhook_events_params import CountWebhookEventsParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountWebhookEventsResponse(pydantic_v1.BaseModel): +class CountWebhookEventsResponse(UniversalBaseModel): data: CountResponse - params: CountWebhookEventsParams = pydantic_v1.Field() + params: CountWebhookEventsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/webhooks/types/count_webhooks_params.py b/src/schematic/webhooks/types/count_webhooks_params.py index 4dc9ec7..6bf6c8e 100644 --- a/src/schematic/webhooks/types/count_webhooks_params.py +++ b/src/schematic/webhooks/types/count_webhooks_params.py @@ -1,43 +1,33 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class CountWebhooksParams(pydantic_v1.BaseModel): +class CountWebhooksParams(UniversalBaseModel): """ Input parameters """ - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/webhooks/types/count_webhooks_response.py b/src/schematic/webhooks/types/count_webhooks_response.py index d766052..f78a880 100644 --- a/src/schematic/webhooks/types/count_webhooks_response.py +++ b/src/schematic/webhooks/types/count_webhooks_response.py @@ -1,35 +1,25 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.count_response import CountResponse from .count_webhooks_params import CountWebhooksParams +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing -class CountWebhooksResponse(pydantic_v1.BaseModel): +class CountWebhooksResponse(UniversalBaseModel): data: CountResponse - params: CountWebhooksParams = pydantic_v1.Field() + params: CountWebhooksParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/webhooks/types/create_webhook_response.py b/src/schematic/webhooks/types/create_webhook_response.py index a8a26bd..b5dc87f 100644 --- a/src/schematic/webhooks/types/create_webhook_response.py +++ b/src/schematic/webhooks/types/create_webhook_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.webhook_response_data import WebhookResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class CreateWebhookResponse(pydantic_v1.BaseModel): +class CreateWebhookResponse(UniversalBaseModel): data: WebhookResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/webhooks/types/delete_webhook_response.py b/src/schematic/webhooks/types/delete_webhook_response.py index 664982c..4f1c689 100644 --- a/src/schematic/webhooks/types/delete_webhook_response.py +++ b/src/schematic/webhooks/types/delete_webhook_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.delete_response import DeleteResponse +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class DeleteWebhookResponse(pydantic_v1.BaseModel): +class DeleteWebhookResponse(UniversalBaseModel): data: DeleteResponse - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/webhooks/types/get_webhook_event_response.py b/src/schematic/webhooks/types/get_webhook_event_response.py index bd6d750..00db336 100644 --- a/src/schematic/webhooks/types/get_webhook_event_response.py +++ b/src/schematic/webhooks/types/get_webhook_event_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.webhook_event_detail_response_data import WebhookEventDetailResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetWebhookEventResponse(pydantic_v1.BaseModel): +class GetWebhookEventResponse(UniversalBaseModel): data: WebhookEventDetailResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/webhooks/types/get_webhook_response.py b/src/schematic/webhooks/types/get_webhook_response.py index d19ab12..0c6e2ac 100644 --- a/src/schematic/webhooks/types/get_webhook_response.py +++ b/src/schematic/webhooks/types/get_webhook_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.webhook_response_data import WebhookResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class GetWebhookResponse(pydantic_v1.BaseModel): +class GetWebhookResponse(UniversalBaseModel): data: WebhookResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/webhooks/types/list_webhook_events_params.py b/src/schematic/webhooks/types/list_webhook_events_params.py index 8031491..0aa96f6 100644 --- a/src/schematic/webhooks/types/list_webhook_events_params.py +++ b/src/schematic/webhooks/types/list_webhook_events_params.py @@ -1,24 +1,23 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListWebhookEventsParams(pydantic_v1.BaseModel): +class ListWebhookEventsParams(UniversalBaseModel): """ Input parameters """ ids: typing.Optional[typing.List[str]] = None - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ @@ -26,20 +25,11 @@ class ListWebhookEventsParams(pydantic_v1.BaseModel): q: typing.Optional[str] = None webhook_id: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/webhooks/types/list_webhook_events_response.py b/src/schematic/webhooks/types/list_webhook_events_response.py index 43e4acb..d421212 100644 --- a/src/schematic/webhooks/types/list_webhook_events_response.py +++ b/src/schematic/webhooks/types/list_webhook_events_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.webhook_event_detail_response_data import WebhookEventDetailResponseData +import pydantic from .list_webhook_events_params import ListWebhookEventsParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListWebhookEventsResponse(pydantic_v1.BaseModel): - data: typing.List[WebhookEventDetailResponseData] = pydantic_v1.Field() +class ListWebhookEventsResponse(UniversalBaseModel): + data: typing.List[WebhookEventDetailResponseData] = pydantic.Field() """ The returned resources """ - params: ListWebhookEventsParams = pydantic_v1.Field() + params: ListWebhookEventsParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/webhooks/types/list_webhooks_params.py b/src/schematic/webhooks/types/list_webhooks_params.py index 1cbb967..4581e98 100644 --- a/src/schematic/webhooks/types/list_webhooks_params.py +++ b/src/schematic/webhooks/types/list_webhooks_params.py @@ -1,43 +1,33 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 - -class ListWebhooksParams(pydantic_v1.BaseModel): +class ListWebhooksParams(UniversalBaseModel): """ Input parameters """ - limit: typing.Optional[int] = pydantic_v1.Field(default=None) + limit: typing.Optional[int] = pydantic.Field(default=None) """ Page limit (default 100) """ - offset: typing.Optional[int] = pydantic_v1.Field(default=None) + offset: typing.Optional[int] = pydantic.Field(default=None) """ Page offset (default 0) """ q: typing.Optional[str] = None - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/webhooks/types/list_webhooks_response.py b/src/schematic/webhooks/types/list_webhooks_response.py index 692ed71..34db4d9 100644 --- a/src/schematic/webhooks/types/list_webhooks_response.py +++ b/src/schematic/webhooks/types/list_webhooks_response.py @@ -1,39 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.pydantic_utilities import UniversalBaseModel import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...types.webhook_response_data import WebhookResponseData +import pydantic from .list_webhooks_params import ListWebhooksParams +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class ListWebhooksResponse(pydantic_v1.BaseModel): - data: typing.List[WebhookResponseData] = pydantic_v1.Field() +class ListWebhooksResponse(UniversalBaseModel): + data: typing.List[WebhookResponseData] = pydantic.Field() """ The returned resources """ - params: ListWebhooksParams = pydantic_v1.Field() + params: ListWebhooksParams = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/schematic/webhooks/types/update_webhook_request_body_status.py b/src/schematic/webhooks/types/update_webhook_request_body_status.py new file mode 100644 index 0000000..a8889cb --- /dev/null +++ b/src/schematic/webhooks/types/update_webhook_request_body_status.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +UpdateWebhookRequestBodyStatus = typing.Union[typing.Literal["active", "inactive"], typing.Any] diff --git a/src/schematic/webhooks/types/update_webhook_response.py b/src/schematic/webhooks/types/update_webhook_response.py index 07b270f..568bf40 100644 --- a/src/schematic/webhooks/types/update_webhook_response.py +++ b/src/schematic/webhooks/types/update_webhook_response.py @@ -1,34 +1,24 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt -import typing - -from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.pydantic_utilities import UniversalBaseModel from ...types.webhook_response_data import WebhookResponseData +import typing +import pydantic +from ...core.pydantic_utilities import IS_PYDANTIC_V2 -class UpdateWebhookResponse(pydantic_v1.BaseModel): +class UpdateWebhookResponse(UniversalBaseModel): data: WebhookResponseData - params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + params: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field() """ Input parameters """ - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} - - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_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_v1.Extra.allow - json_encoders = {dt.datetime: serialize_datetime} + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py new file mode 100644 index 0000000..f3ea265 --- /dev/null +++ b/tests/utils/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/tests/utils/assets/models/__init__.py b/tests/utils/assets/models/__init__.py new file mode 100644 index 0000000..3a1c852 --- /dev/null +++ b/tests/utils/assets/models/__init__.py @@ -0,0 +1,21 @@ +# This file was auto-generated by Fern from our API Definition. + +# This file was auto-generated by Fern from our API Definition. + +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 .square import SquareParams +from .undiscriminated_shape import UndiscriminatedShapeParams + +__all__ = [ + "CircleParams", + "ObjectWithDefaultsParams", + "ObjectWithOptionalFieldParams", + "ShapeParams", + "Shape_CircleParams", + "Shape_SquareParams", + "SquareParams", + "UndiscriminatedShapeParams", +] diff --git a/tests/utils/assets/models/circle.py b/tests/utils/assets/models/circle.py new file mode 100644 index 0000000..05bd485 --- /dev/null +++ b/tests/utils/assets/models/circle.py @@ -0,0 +1,11 @@ +# This file was auto-generated by Fern from our API Definition. + +# This file was auto-generated by Fern from our API Definition. + +import typing_extensions +import typing_extensions +from schematic.core.serialization import FieldMetadata + + +class CircleParams(typing_extensions.TypedDict): + radius_measurement: typing_extensions.Annotated[float, FieldMetadata(alias="radiusMeasurement")] diff --git a/tests/utils/assets/models/color.py b/tests/utils/assets/models/color.py new file mode 100644 index 0000000..2aa2c4c --- /dev/null +++ b/tests/utils/assets/models/color.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +# This file was auto-generated by Fern from our API Definition. + +import typing + +Color = typing.Union[typing.Literal["red", "blue"], typing.Any] diff --git a/tests/utils/assets/models/object_with_defaults.py b/tests/utils/assets/models/object_with_defaults.py new file mode 100644 index 0000000..ef14f7b --- /dev/null +++ b/tests/utils/assets/models/object_with_defaults.py @@ -0,0 +1,16 @@ +# This file was auto-generated by Fern from our API Definition. + +# This file was auto-generated by Fern from our API Definition. + +import typing_extensions +import typing_extensions + + +class ObjectWithDefaultsParams(typing_extensions.TypedDict): + """ + Defines properties with default values and validation rules. + """ + + decimal: typing_extensions.NotRequired[float] + string: typing_extensions.NotRequired[str] + required_string: str diff --git a/tests/utils/assets/models/object_with_optional_field.py b/tests/utils/assets/models/object_with_optional_field.py new file mode 100644 index 0000000..a915f6c --- /dev/null +++ b/tests/utils/assets/models/object_with_optional_field.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +# This file was auto-generated by Fern from our API Definition. + +import typing_extensions +import typing +import typing_extensions +from schematic.core.serialization import FieldMetadata +import datetime as dt +import uuid +from .color import Color +from .shape import ShapeParams +from .undiscriminated_shape import UndiscriminatedShapeParams + + +class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): + literal: typing.Literal["lit_one"] + string: typing_extensions.NotRequired[str] + integer: typing_extensions.NotRequired[int] + long_: typing_extensions.NotRequired[typing_extensions.Annotated[int, FieldMetadata(alias="long")]] + double: typing_extensions.NotRequired[float] + bool_: typing_extensions.NotRequired[typing_extensions.Annotated[bool, FieldMetadata(alias="bool")]] + datetime: typing_extensions.NotRequired[dt.datetime] + date: typing_extensions.NotRequired[dt.date] + uuid_: typing_extensions.NotRequired[typing_extensions.Annotated[uuid.UUID, FieldMetadata(alias="uuid")]] + base_64: typing_extensions.NotRequired[typing_extensions.Annotated[str, FieldMetadata(alias="base64")]] + list_: typing_extensions.NotRequired[typing_extensions.Annotated[typing.Sequence[str], FieldMetadata(alias="list")]] + set_: typing_extensions.NotRequired[typing_extensions.Annotated[typing.Set[str], FieldMetadata(alias="set")]] + map_: typing_extensions.NotRequired[typing_extensions.Annotated[typing.Dict[int, str], FieldMetadata(alias="map")]] + enum: typing_extensions.NotRequired[Color] + union: typing_extensions.NotRequired[ShapeParams] + second_union: typing_extensions.NotRequired[ShapeParams] + undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] + any: typing.Optional[typing.Any] diff --git a/tests/utils/assets/models/shape.py b/tests/utils/assets/models/shape.py new file mode 100644 index 0000000..83ecfb8 --- /dev/null +++ b/tests/utils/assets/models/shape.py @@ -0,0 +1,26 @@ +# This file was auto-generated by Fern from our API Definition. + +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +import typing_extensions +import typing_extensions +import typing +from schematic.core.serialization import FieldMetadata + + +class Base(typing_extensions.TypedDict): + id: str + + +class Shape_CircleParams(Base): + shape_type: typing_extensions.Annotated[typing.Literal["circle"], FieldMetadata(alias="shapeType")] + radius_measurement: typing_extensions.Annotated[float, FieldMetadata(alias="radiusMeasurement")] + + +class Shape_SquareParams(Base): + shape_type: typing_extensions.Annotated[typing.Literal["square"], FieldMetadata(alias="shapeType")] + length_measurement: typing_extensions.Annotated[float, FieldMetadata(alias="lengthMeasurement")] + + +ShapeParams = typing.Union[Shape_CircleParams, Shape_SquareParams] diff --git a/tests/utils/assets/models/square.py b/tests/utils/assets/models/square.py new file mode 100644 index 0000000..b8a6dd8 --- /dev/null +++ b/tests/utils/assets/models/square.py @@ -0,0 +1,11 @@ +# This file was auto-generated by Fern from our API Definition. + +# This file was auto-generated by Fern from our API Definition. + +import typing_extensions +import typing_extensions +from schematic.core.serialization import FieldMetadata + + +class SquareParams(typing_extensions.TypedDict): + length_measurement: typing_extensions.Annotated[float, FieldMetadata(alias="lengthMeasurement")] diff --git a/tests/utils/assets/models/undiscriminated_shape.py b/tests/utils/assets/models/undiscriminated_shape.py new file mode 100644 index 0000000..68876a2 --- /dev/null +++ b/tests/utils/assets/models/undiscriminated_shape.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +# This file was auto-generated by Fern from our API Definition. + +import typing +from .circle import CircleParams +from .square import SquareParams + +UndiscriminatedShapeParams = typing.Union[CircleParams, SquareParams] diff --git a/tests/utils/test_http_client.py b/tests/utils/test_http_client.py new file mode 100644 index 0000000..a2a5554 --- /dev/null +++ b/tests/utils/test_http_client.py @@ -0,0 +1,61 @@ +# This file was auto-generated by Fern from our API Definition. + +from schematic.core.http_client import get_request_body +from schematic.core.request_options import RequestOptions + + +def get_request_options() -> RequestOptions: + return {"additional_body_parameters": {"see you": "later"}} + + +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"} + assert data_body is None + + json_body_extras, data_body_extras = get_request_body( + json={"goodbye": "world"}, data=None, request_options=get_request_options(), omit=None + ) + + assert json_body_extras == {"goodbye": "world", "see you": "later"} + assert data_body_extras is None + + +def test_get_files_request_body() -> None: + json_body, data_body = get_request_body(json=None, data={"hello": "world"}, request_options=None, omit=None) + assert data_body == {"hello": "world"} + assert json_body is None + + json_body_extras, data_body_extras = get_request_body( + json=None, data={"goodbye": "world"}, request_options=get_request_options(), omit=None + ) + + assert data_body_extras == {"goodbye": "world", "see you": "later"} + assert json_body_extras is None + + +def test_get_none_request_body() -> None: + json_body, data_body = get_request_body(json=None, data=None, request_options=None, omit=None) + assert data_body is None + assert json_body is None + + json_body_extras, data_body_extras = get_request_body( + json=None, data=None, request_options=get_request_options(), omit=None + ) + + assert json_body_extras == {"see you": "later"} + assert data_body_extras is None + + +def test_get_empty_json_request_body() -> 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 + ) + + assert json_body_extras is None + assert data_body_extras is None diff --git a/tests/utils/test_query_encoding.py b/tests/utils/test_query_encoding.py new file mode 100644 index 0000000..c8ac52d --- /dev/null +++ b/tests/utils/test_query_encoding.py @@ -0,0 +1,37 @@ +# This file was auto-generated by Fern from our API Definition. + + +from schematic.core.query_encoder import encode_query + + +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] + + +def test_encode_query_with_none() -> None: + encoded = encode_query(None) + assert encoded == None diff --git a/tests/utils/test_serialization.py b/tests/utils/test_serialization.py new file mode 100644 index 0000000..8cc4d20 --- /dev/null +++ b/tests/utils/test_serialization.py @@ -0,0 +1,72 @@ +# This file was auto-generated by Fern from our API Definition. + +from typing import List, Any + +from schematic.core.serialization import convert_and_respect_annotation_metadata +from .assets.models import ShapeParams, ObjectWithOptionalFieldParams + + +UNION_TEST: ShapeParams = {"radius_measurement": 1.0, "shape_type": "circle", "id": "1"} +UNION_TEST_CONVERTED = {"shapeType": "circle", "radiusMeasurement": 1.0, "id": "1"} + + +def test_convert_and_respect_annotation_metadata() -> None: + data: ObjectWithOptionalFieldParams = { + "string": "string", + "long_": 12345, + "bool_": True, + "literal": "lit_one", + "any": "any", + } + converted = convert_and_respect_annotation_metadata( + object_=data, annotation=ObjectWithOptionalFieldParams, direction="write" + ) + assert converted == {"string": "string", "long": 12345, "bool": True, "literal": "lit_one", "any": "any"} + + +def test_convert_and_respect_annotation_metadata_in_list() -> None: + data: List[ObjectWithOptionalFieldParams] = [ + {"string": "string", "long_": 12345, "bool_": True, "literal": "lit_one", "any": "any"}, + {"string": "another string", "long_": 67890, "list_": [], "literal": "lit_one", "any": "any"}, + ] + converted = convert_and_respect_annotation_metadata( + object_=data, annotation=List[ObjectWithOptionalFieldParams], direction="write" + ) + + assert converted == [ + {"string": "string", "long": 12345, "bool": True, "literal": "lit_one", "any": "any"}, + {"string": "another string", "long": 67890, "list": [], "literal": "lit_one", "any": "any"}, + ] + + +def test_convert_and_respect_annotation_metadata_in_nested_object() -> None: + data: ObjectWithOptionalFieldParams = { + "string": "string", + "long_": 12345, + "union": UNION_TEST, + "literal": "lit_one", + "any": "any", + } + converted = convert_and_respect_annotation_metadata( + object_=data, annotation=ObjectWithOptionalFieldParams, direction="write" + ) + + assert converted == { + "string": "string", + "long": 12345, + "union": UNION_TEST_CONVERTED, + "literal": "lit_one", + "any": "any", + } + + +def test_convert_and_respect_annotation_metadata_in_union() -> None: + converted = convert_and_respect_annotation_metadata(object_=UNION_TEST, annotation=ShapeParams, direction="write") + + assert converted == UNION_TEST_CONVERTED + + +def test_convert_and_respect_annotation_metadata_with_empty_object() -> None: + data: Any = {} + converted = convert_and_respect_annotation_metadata(object_=data, annotation=ShapeParams, direction="write") + assert converted == data From 2e40b322110deb31bfa12f204950034d4abcad8f Mon Sep 17 00:00:00 2001 From: Ben Papillon Date: Mon, 30 Sep 2024 13:32:41 -0400 Subject: [PATCH 2/2] Update custom code for type changes --- src/schematic/client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/schematic/client.py b/src/schematic/client.py index 28c12c5..cc66811 100644 --- a/src/schematic/client.py +++ b/src/schematic/client.py @@ -70,8 +70,8 @@ def shutdown(self) -> None: def check_flag( self, flag_key: str, - company: Optional[Dict[str, Optional[str]]] = None, - user: Optional[Dict[str, Optional[str]]] = None, + company: Optional[Dict[str, str]] = None, + user: Optional[Dict[str, str]] = None, ) -> bool: if self.offline: return self._get_flag_default(flag_key) @@ -195,8 +195,8 @@ async def initialize(self) -> None: async def check_flag( self, flag_key: str, - company: Optional[Dict[str, Optional[str]]] = None, - user: Optional[Dict[str, Optional[str]]] = None, + company: Optional[Dict[str, str]] = None, + user: Optional[Dict[str, str]] = None, ) -> bool: if self.offline: return self._get_flag_default(flag_key)