diff --git a/.github/workflows/publish-generator-fastapi.yml b/.github/workflows/publish-generator-fastapi.yml index 4b50ff06c3e..93cf8d5e636 100644 --- a/.github/workflows/publish-generator-fastapi.yml +++ b/.github/workflows/publish-generator-fastapi.yml @@ -5,8 +5,7 @@ on: push: branches: - main - paths: - - "generators/python/fastapi/versions.yml" + - dsinghvi/v2-wrapped-aliases workflow_dispatch: inputs: version: @@ -53,28 +52,38 @@ jobs: # Manually publish and register generators # The logic is identical to the step above, but could not find a good way to work with the matrix AND manual trigger in one job - publish-manually: + publish-fastapi: runs-on: ubuntu-latest - # Only run this job if this has been triggered manually - if: ${{ github.event_name == 'workflow_dispatch' }} steps: - - name: Checkout repo at current ref + - name: Checkout repo uses: actions/checkout@v4 with: - ref: main - fetch-depth: 2 + fetch-depth: 0 + + - name: Install Poetry + uses: snok/install-poetry@v1 - name: Install - uses: ./.github/actions/install + working-directory: ./generators/python + run: poetry install + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: fernapi + password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Run publish - env: - FERN_TOKEN: ${{ secrets.FERN_TOKEN }} - DOCKER_USERNAME: fernapi - DOCKER_PASSWORD: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - run: | - pnpm seed:local publish generator fastapi --ver ${{ inputs.version }} --log-level debug - pnpm seed:local register generator --generators fastapi + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: ./generators/python + file: ./generators/python/fastapi/Dockerfile + platforms: linux/amd64,linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=min + push: true + labels: version=1.6.0-rc5 + tags: fernapi/fern-fastapi-server:1.6.0-rc5 diff --git a/generators/python/fastapi/versions.yml b/generators/python/fastapi/versions.yml index e2fddfcb66d..f9ca26c25bd 100644 --- a/generators/python/fastapi/versions.yml +++ b/generators/python/fastapi/versions.yml @@ -1,4 +1,18 @@ # For unreleased changes, use unreleased.yml +- version: 1.6.0-rc1 + irVersion: 53 + changelogEntry: + - type: fix + summary: | + Support wrapped aliases in Pydantic V2. + +- version: 1.6.0-rc0 + irVersion: 53 + changelogEntry: + - type: fix + summary: | + Support wrapped aliases in Pydantic V2. + - version: 1.5.0 irVersion: 53 changelogEntry: diff --git a/generators/python/src/fern_python/cli/abstract_generator.py b/generators/python/src/fern_python/cli/abstract_generator.py index 2ae1d17db22..3d3d037b3b0 100644 --- a/generators/python/src/fern_python/cli/abstract_generator.py +++ b/generators/python/src/fern_python/cli/abstract_generator.py @@ -102,11 +102,14 @@ def generate_project( if output_mode_union.type == "downloadFiles": # since download files does not contain a pyproject.toml # we run ruff using the fern_python poetry.toml (copied into the docker) - publisher._run_command( - command=["poetry", "run", "ruff", "format", "/fern/output"], - safe_command="poetry run ruff format /fern/output", - cwd="/", - ) + try: + publisher._run_command( + command=["poetry", "run", "ruff", "format", "/fern/output"], + safe_command="poetry run ruff format /fern/output", + cwd="/", + ) + except: + pass elif output_mode_union.type == "github": publisher.run_poetry_install() publisher.run_ruff_format() diff --git a/generators/python/src/fern_python/cli/publisher.py b/generators/python/src/fern_python/cli/publisher.py index 5d6e8958b03..9548dcd0b97 100644 --- a/generators/python/src/fern_python/cli/publisher.py +++ b/generators/python/src/fern_python/cli/publisher.py @@ -22,11 +22,14 @@ def __init__( self._generator_config = generator_config def run_ruff_format(self) -> None: - self._run_command( - command=["poetry", "run", "ruff", "format", "--cache-dir", "../.ruffcache"], - safe_command="poetry run ruff format", - cwd=None, - ) + try: + self._run_command( + command=["poetry", "run", "ruff", "format", "--cache-dir", "../.ruffcache"], + safe_command="poetry run ruff format", + cwd=None, + ) + except: + pass def run_poetry_install(self) -> None: self._run_command( diff --git a/generators/python/src/fern_python/codegen/ast/references/reference.py b/generators/python/src/fern_python/codegen/ast/references/reference.py index 229b49205b0..f4eaf10131d 100644 --- a/generators/python/src/fern_python/codegen/ast/references/reference.py +++ b/generators/python/src/fern_python/codegen/ast/references/reference.py @@ -1,7 +1,7 @@ from __future__ import annotations from dataclasses import dataclass -from typing import Optional +from typing import Any, Optional from .module import Module from .qualfied_name import QualifiedName @@ -70,3 +70,5 @@ class Reference: This was originally added to ensure the use of NotRequired for TypedDicts brings in this import. """ + + generic: Optional[Any] = None diff --git a/generators/python/src/fern_python/codegen/node_writer_impl.py b/generators/python/src/fern_python/codegen/node_writer_impl.py index 445d9bdbf8e..8c3f27f567b 100644 --- a/generators/python/src/fern_python/codegen/node_writer_impl.py +++ b/generators/python/src/fern_python/codegen/node_writer_impl.py @@ -29,7 +29,7 @@ def write_node(self, node: AST.AstNode, should_write_as_snippet: Optional[bool] node.write(writer=self, should_write_as_snippet=should_write_as_snippet) def write_reference(self, reference: AST.Reference) -> None: - self.write(self._reference_resolver.resolve_reference(reference)) + self.write(self._reference_resolver.resolve_reference(reference, self)) def should_format_as_snippet(self) -> bool: return self._should_format_as_snippet diff --git a/generators/python/src/fern_python/codegen/reference_resolver.py b/generators/python/src/fern_python/codegen/reference_resolver.py index b075de618d0..ebed0388629 100644 --- a/generators/python/src/fern_python/codegen/reference_resolver.py +++ b/generators/python/src/fern_python/codegen/reference_resolver.py @@ -7,5 +7,5 @@ class ReferenceResolver(ABC): @abstractmethod - def resolve_reference(self, reference: AST.Reference) -> str: + def resolve_reference(self, reference: AST.Reference, writer: AST.NodeWriter) -> str: ... diff --git a/generators/python/src/fern_python/codegen/reference_resolver_impl.py b/generators/python/src/fern_python/codegen/reference_resolver_impl.py index c7be215ffb7..3b094b451ea 100644 --- a/generators/python/src/fern_python/codegen/reference_resolver_impl.py +++ b/generators/python/src/fern_python/codegen/reference_resolver_impl.py @@ -4,6 +4,8 @@ from ordered_set import OrderedSet +from fern_python.codegen.node_writer_impl import NodeWriterImpl + from . import AST from .reference_resolver import ReferenceResolver @@ -76,7 +78,7 @@ def resolve_references(self) -> None: prefix_for_qualfied_names=prefix_for_qualfied_names, ) - def resolve_reference(self, reference: AST.Reference) -> str: + def resolve_reference(self, reference: AST.Reference, writer: AST.NodeWriter) -> str: if self._original_import_to_resolved_import is None: raise RuntimeError("References have not yet been resolved.") @@ -97,6 +99,20 @@ def resolve_reference(self, reference: AST.Reference) -> str: ) ) + if reference.generic is not None: + temp_writer = NodeWriterImpl( + should_format=False, + should_format_as_snippet=False, + whitelabel=False, + should_include_header=False, + reference_resolver=self, + ) + + resolved_reference += "[" + reference.generic.write(writer=temp_writer) + resolved_reference += temp_writer.to_str() + resolved_reference += "]" + # Here we string-reference a type reference if the import is marked for `if TYPE_CHECKING` or if the import # is deferred until after the current declaration (e.g. for circular references when defining Pydantic models). return ( diff --git a/generators/python/src/fern_python/external_dependencies/pydantic.py b/generators/python/src/fern_python/external_dependencies/pydantic.py index d99af5d129e..766f3e59747 100644 --- a/generators/python/src/fern_python/external_dependencies/pydantic.py +++ b/generators/python/src/fern_python/external_dependencies/pydantic.py @@ -1,4 +1,5 @@ import enum +from typing import Optional, Tuple from fern_python.codegen import AST @@ -14,44 +15,47 @@ class PydanticVersionCompatibility(str, enum.Enum): Both = "both" -def _export(*export: str) -> AST.ClassReference: +def _export(export: Tuple[str, ...], generic: Optional[AST.TypeHint] = None) -> AST.ClassReference: return AST.ClassReference( - import_=AST.ReferenceImport( - module=AST.Module.external( - dependency=PYDANTIC_DEPENDENCY, - module_path=("pydantic",), - ), - ), - qualified_name_excluding_import=export, + import_=Pydantic.PydanticImport(), qualified_name_excluding_import=export, generic=generic ) class Pydantic: @staticmethod def Field() -> AST.ClassReference: - return _export("Field") + return _export(("Field",)) @staticmethod def BaseModel() -> AST.ClassReference: - return _export("BaseModel") + return _export(("BaseModel",)) @staticmethod def ConfigDict() -> AST.ClassReference: - return _export("ConfigDict") + return _export(("ConfigDict",)) @staticmethod def PrivateAttr() -> AST.ClassReference: - return _export("PrivateAttr") + return _export(("PrivateAttr",)) + + @staticmethod + def RootModel(generic: Optional[AST.TypeHint] = None) -> AST.ClassReference: + return _export(("RootModel",), generic) @staticmethod - def RootModel() -> AST.ClassReference: - return _export("RootModel") + def PydanticImport() -> AST.ReferenceImport: + return AST.ReferenceImport( + module=AST.Module.external( + dependency=PYDANTIC_DEPENDENCY, + module_path=("pydantic",), + ), + ) class Extra: @staticmethod def forbid() -> AST.Expression: - return AST.Expression(_export("Extra", "forbid")) + return AST.Expression(_export(("Extra", "forbid"))) @staticmethod def allow() -> AST.Expression: - return AST.Expression(_export("Extra", "allow")) + return AST.Expression(_export(("Extra", "allow"))) diff --git a/generators/python/src/fern_python/generators/pydantic_model/custom_config.py b/generators/python/src/fern_python/generators/pydantic_model/custom_config.py index 136cabbc5e5..198949f2311 100644 --- a/generators/python/src/fern_python/generators/pydantic_model/custom_config.py +++ b/generators/python/src/fern_python/generators/pydantic_model/custom_config.py @@ -52,9 +52,9 @@ def check_wrapped_aliases_v1_only(self) -> Self: version_compat = self.version use_wrapped_aliases = self.wrapped_aliases - if use_wrapped_aliases and version_compat != PydanticVersionCompatibility.V1: + if use_wrapped_aliases and version_compat == PydanticVersionCompatibility.Both: raise ValueError( - "Wrapped aliases are only supported in Pydantic V1, please update your `version` field to be 'v1' to continue using wrapped aliases." + "Wrapped aliases are not supported for `both`, please update your `version` field to be 'v1' or `v2` to continue using wrapped aliases." ) if self.enum_type != "literals": diff --git a/generators/python/src/fern_python/generators/pydantic_model/fern_aware_pydantic_model.py b/generators/python/src/fern_python/generators/pydantic_model/fern_aware_pydantic_model.py index 06388894a53..48eef1f10a8 100644 --- a/generators/python/src/fern_python/generators/pydantic_model/fern_aware_pydantic_model.py +++ b/generators/python/src/fern_python/generators/pydantic_model/fern_aware_pydantic_model.py @@ -6,13 +6,13 @@ import fern.ir.resources as ir_types from fern_python.codegen import AST, LocalClassReference, SourceFile -from fern_python.external_dependencies.pydantic import PydanticVersionCompatibility +from fern_python.external_dependencies.pydantic import Pydantic from fern_python.pydantic_codegen import PydanticField, PydanticModel from ..context import PydanticGeneratorContext from .custom_config import PydanticModelCustomConfig from .validators import ( - PydanticV1CustomRootTypeValidatorsGenerator, + PydanticCustomRootTypeValidatorsGenerator, PydanticValidatorsGenerator, ValidatorsGenerator, ) @@ -70,6 +70,8 @@ def __init__( self._model_contains_forward_refs = False + self._is_pydantic_v2_only = self._custom_config.version == "v2" + models_to_extend = [item for item in base_models] if base_models is not None else [] extends_crs = ( [context.get_class_reference_for_type_id(extended.type_id, as_request=False) for extended in extends] @@ -95,7 +97,9 @@ def __init__( require_optional_fields=custom_config.require_optional_fields, is_pydantic_v2=self._context.core_utilities.get_is_pydantic_v2(), universal_field_validator=self._context.core_utilities.universal_field_validator, - universal_root_validator=self._context.core_utilities.universal_root_validator, + universal_root_validator=self._model_validator + if self._is_pydantic_v2_only + else self._context.core_utilities.universal_root_validator, is_root_model=is_root_model, update_forward_ref_function_reference=self._context.core_utilities.get_update_forward_refs(), field_metadata_getter=lambda: self._context.core_utilities.get_field_metadata(), @@ -111,6 +115,15 @@ def to_reference(self) -> LocalClassReference: def get_class_name(self) -> str: return self._class_name + def _model_validator(self, pre: bool = False) -> AST.FunctionInvocation: + return AST.FunctionInvocation( + function_definition=AST.Reference( + qualified_name_excluding_import=("model_validator",), + import_=Pydantic.PydanticImport(), + ), + kwargs=[("mode", AST.Expression(expression='"before"' if pre else '"after"'))], + ) + def add_field( self, *, @@ -262,22 +275,22 @@ def add_method_unsafe( ) -> AST.FunctionDeclaration: return self._pydantic_model.add_method(declaration=declaration, decorator=decorator) - def set_root_type_v1_only( + def set_root_type( self, root_type: ir_types.TypeReference, annotation: Optional[AST.Expression] = None, is_forward_ref: bool = False, ) -> None: - self.set_root_type_unsafe_v1_only( + self.set_root_type_unsafe( root_type=self.get_type_hint_for_type_reference(root_type), annotation=annotation, is_forward_ref=is_forward_ref, ) - def set_root_type_unsafe_v1_only( + def set_root_type_unsafe( self, root_type: AST.TypeHint, annotation: Optional[AST.Expression] = None, is_forward_ref: bool = False ) -> None: - self._pydantic_model.set_root_type_unsafe_v1_only(root_type=root_type, annotation=annotation) + self._pydantic_model.set_root_type_unsafe(root_type=root_type, annotation=annotation) def add_ghost_reference(self, type_id: ir_types.TypeId) -> None: self._pydantic_model.add_ghost_reference( @@ -286,10 +299,7 @@ def add_ghost_reference(self, type_id: ir_types.TypeId) -> None: def finish(self) -> None: if self._custom_config.include_validators: - if ( - self._pydantic_model._v1_root_type is None - and self._custom_config.version == PydanticVersionCompatibility.V1 - ): + if self._pydantic_model._root_type is None: self._pydantic_model.add_partial_class() self._get_validators_generator().add_validators() if self._model_contains_forward_refs or self._force_update_forward_refs: @@ -309,11 +319,11 @@ def finish(self) -> None: self._pydantic_model.finish() def _get_validators_generator(self) -> ValidatorsGenerator: - v1_root_type = self._pydantic_model.get_root_type_unsafe_v1_only() - if v1_root_type is not None and self._custom_config.version == PydanticVersionCompatibility.V1: - return PydanticV1CustomRootTypeValidatorsGenerator( + root_type = self._pydantic_model.get_root_type_unsafe() + if root_type is not None: + return PydanticCustomRootTypeValidatorsGenerator( model=self._pydantic_model, - root_type=v1_root_type, + root_type=root_type, ) else: unique_name = [] diff --git a/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/discriminated_union/discriminated_union_with_utils_generator.py b/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/discriminated_union/discriminated_union_with_utils_generator.py index d384a10d06b..788049dde8a 100644 --- a/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/discriminated_union/discriminated_union_with_utils_generator.py +++ b/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/discriminated_union/discriminated_union_with_utils_generator.py @@ -363,7 +363,7 @@ def get_dict_method(writer: AST.NodeWriter) -> None: ) if self._custom_config.version == PydanticVersionCompatibility.V1: - external_pydantic_model.set_root_type_unsafe_v1_only( + external_pydantic_model.set_root_type_unsafe( is_forward_ref=True, root_type=root_type, annotation=AST.Expression( diff --git a/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/pydantic_models/pydantic_model_alias_generator.py b/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/pydantic_models/pydantic_model_alias_generator.py index 9210a3ae72f..b3babc0cad1 100644 --- a/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/pydantic_models/pydantic_model_alias_generator.py +++ b/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/pydantic_models/pydantic_model_alias_generator.py @@ -3,6 +3,7 @@ import fern.ir.resources as ir_types from fern_python.codegen import AST, SourceFile +from fern_python.external_dependencies.pydantic import Pydantic from fern_python.generators.pydantic_model.fern_aware_pydantic_model import ( FernAwarePydanticModel, ) @@ -50,9 +51,9 @@ def generate( should_export=True, ) else: - # NOTE: We validate the config to ensure wrapped aliases are only available for Pydantic V1 users. - # As such, we force the root field to be __root__ as opposed to conditional based on the Pydantic version. BUILDER_PARAMETER_NAME = "value" + is_pydantic_v2 = self._custom_config.version == "v2" + type_hint = self._context.get_type_hint_for_type_reference(self._alias.alias_of) with FernAwarePydanticModel( class_name=self._context.get_class_name_for_type_id(self._name.type_id, as_request=False), type_name=self._name, @@ -61,19 +62,24 @@ def generate( source_file=self._source_file, docstring=self._docs, snippet=self._snippet, + is_root_model=True, + base_models=[Pydantic.RootModel(type_hint)] if is_pydantic_v2 else [], ) as pydantic_model: - pydantic_model.set_root_type_v1_only(self._alias.alias_of) + root_name = "root" if is_pydantic_v2 else "__root__" + pydantic_model.set_root_type(self._alias.alias_of) pydantic_model.add_method( name=self._get_getter_name(self._alias.alias_of), parameters=[], return_type=self._alias.alias_of, - body=AST.CodeWriter("return self.__root__"), + body=AST.CodeWriter(f"return self.{root_name}"), ) pydantic_model.add_method( name=self._get_builder_name(self._alias.alias_of), parameters=[(BUILDER_PARAMETER_NAME, self._alias.alias_of)], return_type=ir_types.TypeReference.factory.named(declared_type_name_to_named_type(self._name)), - body=AST.CodeWriter(f"return {pydantic_model.get_class_name()}(__root__={BUILDER_PARAMETER_NAME})"), + body=AST.CodeWriter( + f"return {pydantic_model.get_class_name()}({root_name}={BUILDER_PARAMETER_NAME})" + ), decorator=AST.ClassMethodDecorator.STATIC, ) diff --git a/generators/python/src/fern_python/generators/pydantic_model/validators/__init__.py b/generators/python/src/fern_python/generators/pydantic_model/validators/__init__.py index f231cc244b0..b66fbb1efd3 100644 --- a/generators/python/src/fern_python/generators/pydantic_model/validators/__init__.py +++ b/generators/python/src/fern_python/generators/pydantic_model/validators/__init__.py @@ -1,7 +1,7 @@ -from .pydantic_v1_custom_root_type_validators_generator import ( - PydanticV1CustomRootTypeValidatorsGenerator, +from .pydantic_custom_root_type_validators_generator import ( + PydanticCustomRootTypeValidatorsGenerator, ) from .pydantic_validators_generator import PydanticValidatorsGenerator from .validators_generator import ValidatorsGenerator -__all__ = ["ValidatorsGenerator", "PydanticValidatorsGenerator", "PydanticV1CustomRootTypeValidatorsGenerator"] +__all__ = ["ValidatorsGenerator", "PydanticValidatorsGenerator", "PydanticCustomRootTypeValidatorsGenerator"] diff --git a/generators/python/src/fern_python/generators/pydantic_model/validators/pydantic_v1_custom_root_type_validators_generator.py b/generators/python/src/fern_python/generators/pydantic_model/validators/pydantic_custom_root_type_validators_generator.py similarity index 51% rename from generators/python/src/fern_python/generators/pydantic_model/validators/pydantic_v1_custom_root_type_validators_generator.py rename to generators/python/src/fern_python/generators/pydantic_model/validators/pydantic_custom_root_type_validators_generator.py index 53e6e775ada..5b83562bc91 100644 --- a/generators/python/src/fern_python/generators/pydantic_model/validators/pydantic_v1_custom_root_type_validators_generator.py +++ b/generators/python/src/fern_python/generators/pydantic_model/validators/pydantic_custom_root_type_validators_generator.py @@ -1,24 +1,33 @@ -from typing import Sequence +from typing import Any, Sequence from fern_python.codegen import AST +from fern_python.external_dependencies.pydantic import PydanticVersionCompatibility from fern_python.pydantic_codegen import PydanticModel from .validator_generators import ( PydanticV1CustomRootTypeValidatorGenerator, + PydanticV2CustomRootTypeValidatorGenerator, ValidatorGenerator, ) from .validators_generator import ValidatorsGenerator -class PydanticV1CustomRootTypeValidatorsGenerator(ValidatorsGenerator): +class PydanticCustomRootTypeValidatorsGenerator(ValidatorsGenerator): def __init__(self, root_type: AST.TypeHint, model: PydanticModel): super().__init__(model=model) self._root_type = root_type - self._root_type_generator = PydanticV1CustomRootTypeValidatorGenerator( - root_type=root_type, - model=model, - reference_to_validators_class=self._get_reference_to_validators_class(), - ) + if self._model._version == PydanticVersionCompatibility.V1: + self._root_type_generator: Any = PydanticV1CustomRootTypeValidatorGenerator( + root_type=root_type, + model=model, + reference_to_validators_class=self._get_reference_to_validators_class(), + ) + else: + self._root_type_generator: Any = PydanticV2CustomRootTypeValidatorGenerator( + root_type=root_type, + model=model, + reference_to_validators_class=self._get_reference_to_validators_class(), + ) def _populate_validators_class(self, validators_class: AST.ClassDeclaration) -> None: self._root_type_generator.add_to_validators_class(validators_class) diff --git a/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/__init__.py b/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/__init__.py index fca17e94347..a0bcfe3a71d 100644 --- a/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/__init__.py +++ b/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/__init__.py @@ -2,6 +2,9 @@ from .pydantic_v1_custom_root_type_validator_generator import ( PydanticV1CustomRootTypeValidatorGenerator, ) +from .pydantic_v2_custom_root_type_validator_generator import ( + PydanticV2CustomRootTypeValidatorGenerator, +) from .root_validator_generator import RootValidatorGenerator from .validator_generator import ValidatorGenerator @@ -9,5 +12,6 @@ "ValidatorGenerator", "FieldValidatorGenerator", "RootValidatorGenerator", + "PydanticV2CustomRootTypeValidatorGenerator", "PydanticV1CustomRootTypeValidatorGenerator", ] diff --git a/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/pydantic_v1_custom_root_type_validator_generator.py b/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/pydantic_v1_custom_root_type_validator_generator.py index 5a088216ae5..e40c907f13b 100644 --- a/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/pydantic_v1_custom_root_type_validator_generator.py +++ b/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/pydantic_v1_custom_root_type_validator_generator.py @@ -1,6 +1,7 @@ from typing import Tuple from fern_python.codegen import AST +from fern_python.external_dependencies.pydantic import PydanticVersionCompatibility from fern_python.pydantic_codegen import PydanticModel from .validator_generator import ValidatorGenerator @@ -33,7 +34,9 @@ def _write_validator_body(self, writer: AST.NodeWriter) -> None: ), args=[ AST.Expression(self._root_type), - AST.Expression(f'{PydanticModel.VALIDATOR_VALUES_PARAMETER_NAME}.get("__root__")'), + AST.Expression( + f'{PydanticModel.VALIDATOR_VALUES_PARAMETER_NAME}.get("{self._get_root_property_name()}")' + ), ], ), ) @@ -62,7 +65,8 @@ def _write_validator_body(self, writer: AST.NodeWriter) -> None: ) writer.write_line() writer.write_line( - "return " + f'{{ **{PydanticModel.VALIDATOR_VALUES_PARAMETER_NAME}, "__root__": {ROOT_VARIABLE_NAME} }}' + "return " + + f'{{ **{PydanticModel.VALIDATOR_VALUES_PARAMETER_NAME}, "{self._get_root_property_name()}": {ROOT_VARIABLE_NAME} }}' ) def add_to_validators_class(self, validators_class: AST.ClassDeclaration) -> None: @@ -109,3 +113,6 @@ def write_example_for_docstring(self, writer: AST.NodeWriter) -> None: with writer.indent(): writer.write_line("...") + + def _get_root_property_name(self) -> str: + return "__root__" diff --git a/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/pydantic_v2_custom_root_type_validator_generator.py b/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/pydantic_v2_custom_root_type_validator_generator.py new file mode 100644 index 00000000000..f739b4aa84b --- /dev/null +++ b/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/pydantic_v2_custom_root_type_validator_generator.py @@ -0,0 +1,104 @@ +from typing import Tuple + +from fern_python.codegen import AST +from fern_python.external_dependencies.pydantic import PydanticVersionCompatibility +from fern_python.pydantic_codegen import PydanticModel + +from .validator_generator import ValidatorGenerator + + +class PydanticV2CustomRootTypeValidatorGenerator(ValidatorGenerator): + _DECORATOR_FUNCTION_NAME = "validate" + _VALIDATOR_CLASS_VALIDATORS_CLASS_VAR = "_validators" + _MODEL_PARAMETER_NAME = "model" + + + def __init__(self, root_type: AST.TypeHint, model: PydanticModel, reference_to_validators_class: Tuple[str, ...]): + super().__init__(model=model, reference_to_validators_class=reference_to_validators_class) + self._root_type = root_type + + def add_validator_to_model(self) -> None: + self._model.add_root_validator( + validator_name="_validate", + body=AST.CodeWriter(self._write_validator_body), + ) + + def _write_validator_body(self, writer: AST.NodeWriter) -> None: + ROOT_VARIABLE_NAME = "value" + INDIVIDUAL_VALIDATOR_NAME = "validator" + + writer.write(f"{ROOT_VARIABLE_NAME} = model.{self._get_root_property_name()}") + writer.write_line() + + writer.write(f"for {INDIVIDUAL_VALIDATOR_NAME} in ") + writer.write_line( + ".".join( + ( + *self._reference_to_validators_class, + PydanticV2CustomRootTypeValidatorGenerator._VALIDATOR_CLASS_VALIDATORS_CLASS_VAR, + ) + ) + + ":" + ) + + with writer.indent(): + writer.write(f"{ROOT_VARIABLE_NAME} = ") + writer.write_node( + AST.FunctionInvocation( + function_definition=AST.Reference( + qualified_name_excluding_import=(INDIVIDUAL_VALIDATOR_NAME,), + ), + args=[AST.Expression(ROOT_VARIABLE_NAME)], + ) + ) + writer.write_line() + + writer.write_line(f"return model") + + def add_to_validators_class(self, validators_class: AST.ClassDeclaration) -> None: + VALIDATOR_PARAMETER = "validator" + + validator_type = AST.TypeHint.callable([self._root_type], self._root_type) + validators_class.add_class_var( + AST.VariableDeclaration( + name=PydanticV2CustomRootTypeValidatorGenerator._VALIDATOR_CLASS_VALIDATORS_CLASS_VAR, + type_hint=AST.TypeHint.class_var(AST.TypeHint.list(validator_type)), + initializer=AST.Expression("[]"), + ) + ) + validators_class.add_method( + declaration=AST.FunctionDeclaration( + name=PydanticV2CustomRootTypeValidatorGenerator._DECORATOR_FUNCTION_NAME, + signature=AST.FunctionSignature( + parameters=[AST.FunctionParameter(name=VALIDATOR_PARAMETER, type_hint=validator_type)], + return_type=AST.TypeHint.none(), + ), + body=AST.CodeWriter( + f"cls.{PydanticV2CustomRootTypeValidatorGenerator._VALIDATOR_CLASS_VALIDATORS_CLASS_VAR}" + + f".append({VALIDATOR_PARAMETER})" + ), + ), + decorator=AST.ClassMethodDecorator.CLASS_METHOD, + ) + + def write_example_for_docstring(self, writer: AST.NodeWriter) -> None: + + reference_to_decorator = ".".join( + (*self._reference_to_validators_class, PydanticV2CustomRootTypeValidatorGenerator._DECORATOR_FUNCTION_NAME) + ) + + with writer.indent(): + writer.write("@") + writer.write_line(reference_to_decorator) + + writer.write("def validate(value: ") + writer.write_node(self._root_type) + writer.write(") -> ") + writer.write_node(self._root_type) + writer.write_line(":") + + with writer.indent(): + writer.write_line("...") + + def _get_root_property_name(self) -> str: + return "root" diff --git a/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/root_validator_generator.py b/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/root_validator_generator.py index ab3bb230f8a..156fa1e4f46 100644 --- a/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/root_validator_generator.py +++ b/generators/python/src/fern_python/generators/pydantic_model/validators/validator_generators/root_validator_generator.py @@ -2,6 +2,7 @@ from fern_python.codegen import AST from fern_python.codegen.ast.nodes.code_writer.code_writer import CodeWriterFunction +from fern_python.external_dependencies.pydantic import PydanticVersionCompatibility from fern_python.pydantic_codegen import PydanticModel from .validator_generator import ValidatorGenerator @@ -49,18 +50,26 @@ def _write_validator_body(writer: AST.NodeWriter) -> None: ) with writer.indent(): - writer.write(f"{PydanticModel.VALIDATOR_VALUES_PARAMETER_NAME} = ") + if self._model._version == PydanticVersionCompatibility.V2: + writer.write(f"{PydanticModel.MODEL_PARAMETER_NAME} = ") + else: + writer.write(f"{PydanticModel.VALIDATOR_VALUES_PARAMETER_NAME} = ") writer.write_node( AST.FunctionInvocation( function_definition=AST.Reference( qualified_name_excluding_import=(INDIVIDUAL_VALIDATOR_NAME,), ), - args=[AST.Expression(PydanticModel.VALIDATOR_VALUES_PARAMETER_NAME)], + args=[AST.Expression(PydanticModel.MODEL_PARAMETER_NAME if self._model._version == PydanticVersionCompatibility.V2 else PydanticModel.VALIDATOR_VALUES_PARAMETER_NAME)], ) ) + if not pre: + writer.write(' # type: ignore') writer.write_line() - writer.write_line(f"return {PydanticModel.VALIDATOR_VALUES_PARAMETER_NAME}") + if self._model._version == PydanticVersionCompatibility.V2: + writer.write_line(f"return {PydanticModel.MODEL_PARAMETER_NAME}") + else: + writer.write_line(f"return {PydanticModel.VALIDATOR_VALUES_PARAMETER_NAME}") return _write_validator_body diff --git a/generators/python/src/fern_python/pydantic_codegen/pydantic_model.py b/generators/python/src/fern_python/pydantic_codegen/pydantic_model.py index 284c866fdde..1647f3495c0 100644 --- a/generators/python/src/fern_python/pydantic_codegen/pydantic_model.py +++ b/generators/python/src/fern_python/pydantic_codegen/pydantic_model.py @@ -18,6 +18,7 @@ class PydanticModel: VALIDATOR_FIELD_VALUE_PARAMETER_NAME = "v" VALIDATOR_VALUES_PARAMETER_NAME = "values" + MODEL_PARAMETER_NAME = "model" _PARTIAL_CLASS_NAME = "Partial" @@ -61,7 +62,7 @@ def __init__( ) self._has_aliases = False self._version = version - self._v1_root_type: Optional[AST.TypeHint] = None + self._root_type: Optional[AST.TypeHint] = None self._fields: List[PydanticField] = [] self._extra_fields = extra_fields self._frozen = frozen @@ -234,31 +235,49 @@ def add_root_validator( if should_use_partial_type else AST.TypeHint.dict(AST.TypeHint.str_(), AST.TypeHint.any()) ) - self._class_declaration.add_method( - decorator=AST.ClassMethodDecorator.CLASS_METHOD, - no_implicit_decorator=True, - declaration=AST.FunctionDeclaration( - name=validator_name, - signature=AST.FunctionSignature( - parameters=[ - AST.FunctionParameter(name=PydanticModel.VALIDATOR_VALUES_PARAMETER_NAME, type_hint=value_type) - ], - return_type=value_type, + if self._version == PydanticVersionCompatibility.V1: + self._class_declaration.add_method( + decorator=AST.ClassMethodDecorator.CLASS_METHOD, + no_implicit_decorator=True, + declaration=AST.FunctionDeclaration( + name=validator_name, + signature=AST.FunctionSignature( + parameters=[ + AST.FunctionParameter( + name=PydanticModel.VALIDATOR_VALUES_PARAMETER_NAME, type_hint=value_type + ) + ], + return_type=value_type, + ), + body=body, + decorators=[self._universal_root_validator(pre)], ), - body=body, - decorators=[self._universal_root_validator(pre)], - ), - ) + ) + elif self._version == PydanticVersionCompatibility.V2: + self._class_declaration.add_method( + decorator=AST.ClassMethodDecorator.CLASS_METHOD, + no_implicit_decorator=True, + declaration=AST.FunctionDeclaration( + name=validator_name, + signature=AST.FunctionSignature( + parameters=[ + AST.FunctionParameter(name=PydanticModel.MODEL_PARAMETER_NAME, type_hint=AST.TypeHint(self._local_class_reference)) + ], + return_type=AST.TypeHint(self._local_class_reference), + ), + body=body, + decorators=[self._universal_root_validator(pre)], + ), + ) - def set_root_type_unsafe_v1_only( - self, root_type: AST.TypeHint, annotation: Optional[AST.Expression] = None - ) -> None: - if self._version != PydanticVersionCompatibility.V1: - raise RuntimeError("Overriding root types is only available in Pydantic v1") + def set_root_type_unsafe(self, root_type: AST.TypeHint, annotation: Optional[AST.Expression] = None) -> None: + if self._version == PydanticVersionCompatibility.Both: + raise RuntimeError("Overriding root types is only available in Pydantic v1 or v2") - if self._v1_root_type is not None: + if self._root_type is not None: raise RuntimeError("__root__ was already added") - self._v1_root_type = root_type + + self._root_type = root_type root_type_with_annotation = ( AST.TypeHint.annotated( @@ -269,12 +288,18 @@ def set_root_type_unsafe_v1_only( else root_type ) - self._class_declaration.add_statement( - AST.VariableDeclaration(name="__root__", type_hint=root_type_with_annotation) - ) + if self._version == PydanticVersionCompatibility.V1: + self._class_declaration.add_statement( + AST.VariableDeclaration(name="__root__", type_hint=root_type_with_annotation) + ) + + if self._version == PydanticVersionCompatibility.V2: + self._class_declaration.add_statement( + AST.VariableDeclaration(name="root", type_hint=root_type_with_annotation) + ) - def get_root_type_unsafe_v1_only(self) -> Optional[AST.TypeHint]: - return self._v1_root_type + def get_root_type_unsafe(self) -> Optional[AST.TypeHint]: + return self._root_type def add_inner_class(self, inner_class: AST.ClassDeclaration) -> None: self._class_declaration.add_class(declaration=inner_class) diff --git a/generators/python/tests/sdk/test_custom_config.py b/generators/python/tests/sdk/test_custom_config.py index 73b74866ad4..8caf62b15e5 100644 --- a/generators/python/tests/sdk/test_custom_config.py +++ b/generators/python/tests/sdk/test_custom_config.py @@ -44,8 +44,9 @@ def test_parse_wrapped_aliases() -> None: "wrapped_aliases": True, }, } - with pytest.raises(pydantic.ValidationError, match="Wrapped aliases are only supported in Pydantic V1, please update your `version` field to be 'v1' to continue using wrapped aliases."): - SDKCustomConfig.parse_obj(v2) + sdk_custom_config_v2 = SDKCustomConfig.parse_obj(v2) + assert sdk_custom_config_v2.pydantic_config.version == "v2" and sdk_custom_config_v2.pydantic_config.wrapped_aliases is True + both = { "pydantic_config": { @@ -53,5 +54,5 @@ def test_parse_wrapped_aliases() -> None: "wrapped_aliases": True, }, } - with pytest.raises(pydantic.ValidationError, match="Wrapped aliases are only supported in Pydantic V1, please update your `version` field to be 'v1' to continue using wrapped aliases."): + with pytest.raises(pydantic.ValidationError, match="Wrapped aliases are not supported for `both`, please update your `version` field to be 'v1' or `v2` to continue using wrapped aliases."): SDKCustomConfig.parse_obj(both) diff --git a/seed/fastapi/exhaustive/include-validators/resources/general_errors/types/bad_object_request_info.py b/seed/fastapi/exhaustive/include-validators/resources/general_errors/types/bad_object_request_info.py index e99ce2f97aa..aa9ab21f924 100644 --- a/seed/fastapi/exhaustive/include-validators/resources/general_errors/types/bad_object_request_info.py +++ b/seed/fastapi/exhaustive/include-validators/resources/general_errors/types/bad_object_request_info.py @@ -3,6 +3,7 @@ from __future__ import annotations from ....core.pydantic_utilities import UniversalBaseModel import typing +import typing_extensions from ....core.pydantic_utilities import universal_root_validator from ....core.pydantic_utilities import universal_field_validator from ....core.pydantic_utilities import IS_PYDANTIC_V2 @@ -12,6 +13,9 @@ class BadObjectRequestInfo(UniversalBaseModel): message: str + class Partial(typing.TypedDict): + message: typing_extensions.NotRequired[str] + class Validators: """ Use this class to add validators to the Pydantic model. diff --git a/seed/fastapi/exhaustive/include-validators/resources/inlined_requests/service/post_with_object_body.py b/seed/fastapi/exhaustive/include-validators/resources/inlined_requests/service/post_with_object_body.py index d889190c618..12b5fa6feba 100644 --- a/seed/fastapi/exhaustive/include-validators/resources/inlined_requests/service/post_with_object_body.py +++ b/seed/fastapi/exhaustive/include-validators/resources/inlined_requests/service/post_with_object_body.py @@ -7,6 +7,7 @@ ) import pydantic import typing +import typing_extensions from ....core.pydantic_utilities import universal_root_validator from ....core.pydantic_utilities import universal_field_validator from ....core.pydantic_utilities import IS_PYDANTIC_V2 @@ -17,6 +18,11 @@ class PostWithObjectBody(UniversalBaseModel): integer: int nested_object: ObjectWithOptionalField = pydantic.Field(alias="NestedObject") + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[str] + integer: typing_extensions.NotRequired[int] + nested_object: typing_extensions.NotRequired[ObjectWithOptionalField] + class Validators: """ Use this class to add validators to the Pydantic model. diff --git a/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/double_optional.py b/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/double_optional.py index 7d05f548a40..959371389ce 100644 --- a/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/double_optional.py +++ b/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/double_optional.py @@ -5,6 +5,7 @@ import typing from .optional_alias import OptionalAlias import pydantic +import typing_extensions from ......core.pydantic_utilities import universal_root_validator from ......core.pydantic_utilities import universal_field_validator from ......core.pydantic_utilities import IS_PYDANTIC_V2 @@ -15,6 +16,9 @@ class DoubleOptional(UniversalBaseModel): alias="optionalAlias", default=None ) + class Partial(typing.TypedDict): + optional_alias: typing_extensions.NotRequired[typing.Optional[OptionalAlias]] + class Validators: """ Use this class to add validators to the Pydantic model. diff --git a/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/nested_object_with_optional_field.py b/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/nested_object_with_optional_field.py index 7e3e4b4009e..e572198b012 100644 --- a/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/nested_object_with_optional_field.py +++ b/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/nested_object_with_optional_field.py @@ -5,6 +5,7 @@ import typing from .object_with_optional_field import ObjectWithOptionalField import pydantic +import typing_extensions from ......core.pydantic_utilities import universal_root_validator from ......core.pydantic_utilities import universal_field_validator from ......core.pydantic_utilities import IS_PYDANTIC_V2 @@ -16,6 +17,12 @@ class NestedObjectWithOptionalField(UniversalBaseModel): alias="NestedObject", default=None ) + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[typing.Optional[str]] + nested_object: typing_extensions.NotRequired[ + typing.Optional[ObjectWithOptionalField] + ] + class Validators: """ Use this class to add validators to the Pydantic model. diff --git a/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/nested_object_with_required_field.py b/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/nested_object_with_required_field.py index dfc9d158cc4..6039780ece6 100644 --- a/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/nested_object_with_required_field.py +++ b/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/nested_object_with_required_field.py @@ -5,6 +5,7 @@ from .object_with_optional_field import ObjectWithOptionalField import pydantic import typing +import typing_extensions from ......core.pydantic_utilities import universal_root_validator from ......core.pydantic_utilities import universal_field_validator from ......core.pydantic_utilities import IS_PYDANTIC_V2 @@ -14,6 +15,10 @@ class NestedObjectWithRequiredField(UniversalBaseModel): string: str nested_object: ObjectWithOptionalField = pydantic.Field(alias="NestedObject") + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[str] + nested_object: typing_extensions.NotRequired[ObjectWithOptionalField] + class Validators: """ Use this class to add validators to the Pydantic model. diff --git a/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/object_with_map_of_map.py b/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/object_with_map_of_map.py index 38933cd0585..e35bd52e1ba 100644 --- a/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/object_with_map_of_map.py +++ b/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/object_with_map_of_map.py @@ -4,6 +4,7 @@ from ......core.pydantic_utilities import UniversalBaseModel import typing import pydantic +import typing_extensions from ......core.pydantic_utilities import universal_root_validator from ......core.pydantic_utilities import universal_field_validator from ......core.pydantic_utilities import IS_PYDANTIC_V2 @@ -12,6 +13,9 @@ class ObjectWithMapOfMap(UniversalBaseModel): map_: typing.Dict[str, typing.Dict[str, str]] = pydantic.Field(alias="map") + class Partial(typing.TypedDict): + map_: typing_extensions.NotRequired[typing.Dict[str, typing.Dict[str, str]]] + class Validators: """ Use this class to add validators to the Pydantic model. diff --git a/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/object_with_optional_field.py b/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/object_with_optional_field.py index 12e5310853e..7e40b1262c7 100644 --- a/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/object_with_optional_field.py +++ b/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/object_with_optional_field.py @@ -6,6 +6,7 @@ import pydantic import datetime as dt import uuid +import typing_extensions from ......core.pydantic_utilities import universal_root_validator from ......core.pydantic_utilities import universal_field_validator from ......core.pydantic_utilities import IS_PYDANTIC_V2 @@ -34,6 +35,21 @@ class ObjectWithOptionalField(UniversalBaseModel): ) bigint: typing.Optional[str] = None + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[typing.Optional[str]] + integer: typing_extensions.NotRequired[typing.Optional[int]] + long_: typing_extensions.NotRequired[typing.Optional[int]] + double: typing_extensions.NotRequired[typing.Optional[float]] + bool_: typing_extensions.NotRequired[typing.Optional[bool]] + datetime: typing_extensions.NotRequired[typing.Optional[dt.datetime]] + date: typing_extensions.NotRequired[typing.Optional[dt.date]] + uuid_: typing_extensions.NotRequired[typing.Optional[uuid.UUID]] + base_64: typing_extensions.NotRequired[typing.Optional[str]] + list_: typing_extensions.NotRequired[typing.Optional[typing.List[str]]] + set_: typing_extensions.NotRequired[typing.Optional[typing.Set[str]]] + map_: typing_extensions.NotRequired[typing.Optional[typing.Dict[int, str]]] + bigint: typing_extensions.NotRequired[typing.Optional[str]] + class Validators: """ Use this class to add validators to the Pydantic model. diff --git a/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/object_with_required_field.py b/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/object_with_required_field.py index 8d0882790e2..74d1be57cd0 100644 --- a/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/object_with_required_field.py +++ b/seed/fastapi/exhaustive/include-validators/resources/types/resources/object/types/object_with_required_field.py @@ -3,6 +3,7 @@ from __future__ import annotations from ......core.pydantic_utilities import UniversalBaseModel import typing +import typing_extensions from ......core.pydantic_utilities import universal_root_validator from ......core.pydantic_utilities import universal_field_validator from ......core.pydantic_utilities import IS_PYDANTIC_V2 @@ -12,6 +13,9 @@ class ObjectWithRequiredField(UniversalBaseModel): string: str + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[str] + class Validators: """ Use this class to add validators to the Pydantic model. diff --git a/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/animal.py b/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/animal.py index 1e1c9762745..d47b4babd4b 100644 --- a/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/animal.py +++ b/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/animal.py @@ -81,6 +81,9 @@ def visit( ) ) + class Partial(typing.TypedDict): + pass + class Validators: """ Use this class to add validators to the Pydantic model. diff --git a/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/cat.py b/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/cat.py index 0816f3df044..39c3093bc12 100644 --- a/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/cat.py +++ b/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/cat.py @@ -4,6 +4,7 @@ from ......core.pydantic_utilities import UniversalBaseModel import pydantic import typing +import typing_extensions from ......core.pydantic_utilities import universal_root_validator from ......core.pydantic_utilities import universal_field_validator from ......core.pydantic_utilities import IS_PYDANTIC_V2 @@ -13,6 +14,10 @@ class Cat(UniversalBaseModel): name: str likes_to_meow: bool = pydantic.Field(alias="likesToMeow") + class Partial(typing.TypedDict): + name: typing_extensions.NotRequired[str] + likes_to_meow: typing_extensions.NotRequired[bool] + class Validators: """ Use this class to add validators to the Pydantic model. diff --git a/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/dog.py b/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/dog.py index d9358117f0c..1fa3eeb2ed6 100644 --- a/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/dog.py +++ b/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/dog.py @@ -4,6 +4,7 @@ from ......core.pydantic_utilities import UniversalBaseModel import pydantic import typing +import typing_extensions from ......core.pydantic_utilities import universal_root_validator from ......core.pydantic_utilities import universal_field_validator from ......core.pydantic_utilities import IS_PYDANTIC_V2 @@ -13,6 +14,10 @@ class Dog(UniversalBaseModel): name: str likes_to_woof: bool = pydantic.Field(alias="likesToWoof") + class Partial(typing.TypedDict): + name: typing_extensions.NotRequired[str] + likes_to_woof: typing_extensions.NotRequired[bool] + class Validators: """ Use this class to add validators to the Pydantic model. diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/api.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/api.yml new file mode 100644 index 00000000000..dd65915538f --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/api.yml @@ -0,0 +1,4 @@ +name: exhaustive +auth: bearer +error-discrimination: + strategy: status-code diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/container.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/container.yml new file mode 100644 index 00000000000..165a039dc65 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/container.yml @@ -0,0 +1,48 @@ +imports: + objects: ../types/object.yml + +service: + auth: true + base-path: /container + endpoints: + getAndReturnListOfPrimitives: + path: /list-of-primitives + method: POST + request: list + response: list + + getAndReturnListOfObjects: + path: /list-of-objects + method: POST + request: list + response: list + + getAndReturnSetOfPrimitives: + path: /set-of-primitives + method: POST + request: set + response: set + + getAndReturnSetOfObjects: + path: /set-of-objects + method: POST + request: set + response: set + + getAndReturnMapPrimToPrim: + path: /map-prim-to-prim + method: POST + request: map + response: map + + getAndReturnMapOfPrimToObject: + path: /map-prim-to-object + method: POST + request: map + response: map + + getAndReturnOptional: + path: /opt-objects + method: POST + request: optional + response: optional diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/enum.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/enum.yml new file mode 100644 index 00000000000..335a0889cc7 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/enum.yml @@ -0,0 +1,12 @@ +imports: + enums: ../types/enum.yml + +service: + auth: true + base-path: /enum + endpoints: + getAndReturnEnum: + method: POST + path: "" + request: enums.WeatherReport + response: enums.WeatherReport diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/http-methods.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/http-methods.yml new file mode 100644 index 00000000000..51a54c0802c --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/http-methods.yml @@ -0,0 +1,43 @@ +imports: + objects: ../types/object.yml + +service: + auth: true + base-path: /http-methods + + endpoints: + testGet: + method: GET + path: /{id} + path-parameters: + id: string + response: string + + testPost: + method: POST + path: "" + request: objects.ObjectWithRequiredField + response: objects.ObjectWithOptionalField + + testPut: + method: PUT + path: /{id} + path-parameters: + id: string + request: objects.ObjectWithRequiredField + response: objects.ObjectWithOptionalField + + testPatch: + method: PATCH + path: /{id} + path-parameters: + id: string + request: objects.ObjectWithOptionalField + response: objects.ObjectWithOptionalField + + testDelete: + method: DELETE + path: /{id} + path-parameters: + id: string + response: boolean diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/object.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/object.yml new file mode 100644 index 00000000000..9fad6aa2776 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/object.yml @@ -0,0 +1,44 @@ +imports: + objects: ../types/object.yml + +service: + auth: true + base-path: /object + endpoints: + getAndReturnWithOptionalField: + path: /get-and-return-with-optional-field + method: POST + request: objects.ObjectWithOptionalField + response: objects.ObjectWithOptionalField + + getAndReturnWithRequiredField: + path: /get-and-return-with-required-field + method: POST + request: objects.ObjectWithRequiredField + response: objects.ObjectWithRequiredField + + getAndReturnWithMapOfMap: + path: /get-and-return-with-map-of-map + method: POST + request: objects.ObjectWithMapOfMap + response: objects.ObjectWithMapOfMap + + getAndReturnNestedWithOptionalField: + path: /get-and-return-nested-with-optional-field + method: POST + request: objects.NestedObjectWithOptionalField + response: objects.NestedObjectWithOptionalField + + getAndReturnNestedWithRequiredField: + path: /get-and-return-nested-with-required-field/{string} + method: POST + path-parameters: + string: string + request: objects.NestedObjectWithRequiredField + response: objects.NestedObjectWithRequiredField + + getAndReturnNestedWithRequiredFieldAsList: + path: /get-and-return-nested-with-required-field-list + method: POST + request: list + response: objects.NestedObjectWithRequiredField diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/params.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/params.yml new file mode 100644 index 00000000000..7766547ad79 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/params.yml @@ -0,0 +1,57 @@ +service: + auth: true + base-path: /params + endpoints: + getWithPath: + docs: GET with path param + path: /path/{param} + path-parameters: + param: string + method: GET + response: string + + getWithQuery: + docs: GET with query param + path: "" + method: GET + request: + name: GetWithQuery + query-parameters: + query: string #mandatory for test + number: integer + + getWithAllowMultipleQuery: + docs: GET with multiple of same query param + path: "" + method: GET + request: + name: GetWithMultipleQuery + query-parameters: + query: + type: string + allow-multiple: true + numer: + type: integer + allow-multiple: true + + getWithPathAndQuery: + docs: GET with path and query params + path: /path-query/{param} + path-parameters: + param: string + method: GET + request: + name: GetWithPathAndQuery + query-parameters: + query: string #mandatory for test + + modifyWithPath: + docs: PUT to update with path param + path: /path/{param} + path-parameters: + param: string + method: PUT + request: + name: ModifyResourceAtPath + body: string + response: string diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/primitive.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/primitive.yml new file mode 100644 index 00000000000..8dd7674164c --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/primitive.yml @@ -0,0 +1,60 @@ +imports: + objects: ../types/object.yml + +service: + auth: true + base-path: /primitive + endpoints: + getAndReturnString: + path: /string + method: POST + request: string + response: string + + getAndReturnInt: + path: /integer + method: POST + request: integer + response: integer + + getAndReturnLong: + path: /long + method: POST + request: long + response: long + + getAndReturnDouble: + path: /double + method: POST + request: double + response: double + + getAndReturnBool: + path: /boolean + method: POST + request: boolean + response: boolean + + getAndReturnDatetime: + path: /datetime + method: POST + request: datetime + response: datetime + + getAndReturnDate: + path: /date + method: POST + request: date + response: date + + getAndReturnUUID: + path: /uuid + method: POST + request: uuid + response: uuid + + getAndReturnBase64: + path: /base64 + method: POST + request: base64 + response: base64 diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/union.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/union.yml new file mode 100644 index 00000000000..ce9021160d7 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/endpoints/union.yml @@ -0,0 +1,12 @@ +imports: + unions: ../types/union.yml + +service: + auth: true + base-path: /union + endpoints: + getAndReturnUnion: + method: POST + path: "" + request: unions.Animal + response: unions.Animal diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/general-errors.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/general-errors.yml new file mode 100644 index 00000000000..5fbf9cfc417 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/general-errors.yml @@ -0,0 +1,9 @@ +errors: + BadRequestBody: + status-code: 400 + type: BadObjectRequestInfo + +types: + BadObjectRequestInfo: + properties: + message: string diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/inlined-requests.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/inlined-requests.yml new file mode 100644 index 00000000000..9347fe7e335 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/inlined-requests.yml @@ -0,0 +1,25 @@ +imports: + objects: ./types/object.yml + errors: ./general-errors.yml + +# test req bodies, path params, query params, multiple query params, etc. +# test union and enum as well + +service: + auth: false + base-path: /req-bodies + endpoints: + postWithObjectBodyandResponse: + docs: POST with custom object in request body, response is an object + path: /object + method: POST + request: + name: PostWithObjectBody + body: + properties: + string: string + integer: integer + NestedObject: objects.ObjectWithOptionalField + response: objects.ObjectWithOptionalField + errors: + - errors.BadRequestBody diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/no-auth.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/no-auth.yml new file mode 100644 index 00000000000..e3c33ed7fab --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/no-auth.yml @@ -0,0 +1,20 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json + +imports: + general-errors: ./general-errors.yml + +service: + auth: false + base-path: /no-auth + endpoints: + postWithNoAuth: + auth: false + docs: POST request with no auth + path: "" + method: POST + request: + name: PostWithNoAuth + body: unknown + response: boolean + errors: + - general-errors.BadRequestBody diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/no-req-body.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/no-req-body.yml new file mode 100644 index 00000000000..daffd9a495c --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/no-req-body.yml @@ -0,0 +1,16 @@ +imports: + objects: ./types/object.yml + +service: + auth: true + base-path: /no-req-body + endpoints: + getWithNoRequestBody: + path: "" + method: GET + response: objects.ObjectWithOptionalField + + postWithNoRequestBody: + path: "" + method: POST + response: string diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/req-with-headers.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/req-with-headers.yml new file mode 100644 index 00000000000..9e49725782f --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/req-with-headers.yml @@ -0,0 +1,14 @@ +service: + base-path: /test-headers + auth: true + headers: + X-TEST-SERVICE-HEADER: string + endpoints: + getWithCustomHeader: + path: /custom-header + method: POST + request: + name: ReqWithHeaders + headers: + X-TEST-ENDPOINT-HEADER: string + body: string diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/types/enum.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/types/enum.yml new file mode 100644 index 00000000000..a90686092e9 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/types/enum.yml @@ -0,0 +1,12 @@ +types: + WeatherReport: + enum: + - SUNNY + - CLOUDY + - RAINING + - SNOWING + +errors: + ErrorWithEnumBody: + status-code: 400 + type: WeatherReport #does this even make sense? the type of the error body would be enum, and it could only be one of the 4 values? diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/types/object.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/types/object.yml new file mode 100644 index 00000000000..a165ed94cfe --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/types/object.yml @@ -0,0 +1,59 @@ +types: + ObjectWithOptionalField: #generic object that supports any type, makes it easier to use when testing + properties: + string: + type: optional + docs: This is a rather long descriptor of this single field in a more complex type. If you ask me I think this is a pretty good description for this field all things considered. + integer: optional + long: optional + double: optional + bool: optional + datetime: optional + date: optional + uuid: optional + base64: optional + list: optional> + set: optional> + map: optional> + bigint: optional + + ObjectWithRequiredField: + properties: + string: string + + ObjectWithMapOfMap: + properties: + map: map> + + NestedObjectWithOptionalField: + properties: + string: optional + NestedObject: optional + + NestedObjectWithRequiredField: + properties: + string: string + NestedObject: ObjectWithOptionalField + + DoubleOptional: + properties: + optionalAlias: optional + + OptionalAlias: optional + +errors: + ObjectWithOptionalFieldError: + status-code: 400 + type: ObjectWithOptionalField + + ObjectWithRequiredFieldError: + status-code: 400 + type: ObjectWithRequiredField + + NestedObjectWithOptionalFieldError: + status-code: 400 + type: NestedObjectWithOptionalField + + NestedObjectWithRequiredFieldError: + status-code: 400 + type: NestedObjectWithRequiredField diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/types/union.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/types/union.yml new file mode 100644 index 00000000000..99ce8c75ed0 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/definition/types/union.yml @@ -0,0 +1,21 @@ +types: + Animal: + discriminant: animal + union: + dog: Dog + cat: Cat + + Dog: + properties: + name: string + likesToWoof: boolean + + Cat: + properties: + name: string + likesToMeow: boolean + +errors: + ErrorWithUnionBody: + status-code: 400 + type: Animal #has to send either dog or cat object in error body diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/fern.config.json b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/fern.config.json new file mode 100644 index 00000000000..4c8e54ac313 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/fern.config.json @@ -0,0 +1 @@ +{"organization": "fern-test", "version": "*"} \ No newline at end of file diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/generators.yml b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/generators.yml new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/.mock/generators.yml @@ -0,0 +1 @@ +{} diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/__init__.py new file mode 100644 index 00000000000..6eda4b194c2 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/__init__.py @@ -0,0 +1,21 @@ +# This file was auto-generated by Fern from our API Definition. + +from .resources import ( + BadObjectRequestInfo, + BadRequestBody, + PostWithObjectBody, + general_errors, + inlined_requests, + types, +) +from .security import ApiAuth + +__all__ = [ + "ApiAuth", + "BadObjectRequestInfo", + "BadRequestBody", + "PostWithObjectBody", + "general_errors", + "inlined_requests", + "types", +] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/core/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/core/__init__.py new file mode 100644 index 00000000000..f9c8e44aea0 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/core/__init__.py @@ -0,0 +1,42 @@ +# This file was auto-generated by Fern from our API Definition. + +from .datetime_utils import serialize_datetime +from .exceptions import ( + FernHTTPException, + UnauthorizedException, + default_exception_handler, + fern_http_exception_handler, + http_exception_handler, +) +from .pydantic_utilities import ( + IS_PYDANTIC_V2, + UniversalBaseModel, + UniversalRootModel, + parse_obj_as, + universal_field_validator, + universal_root_validator, + update_forward_refs, +) +from .route_args import route_args +from .security import BearerToken +from .serialization import FieldMetadata, convert_and_respect_annotation_metadata + +__all__ = [ + "BearerToken", + "FernHTTPException", + "FieldMetadata", + "IS_PYDANTIC_V2", + "UnauthorizedException", + "UniversalBaseModel", + "UniversalRootModel", + "convert_and_respect_annotation_metadata", + "default_exception_handler", + "fern_http_exception_handler", + "http_exception_handler", + "parse_obj_as", + "route_args", + "serialize_datetime", + "universal_field_validator", + "universal_root_validator", + "update_forward_refs", +] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/core/abstract_fern_service.py b/seed/fastapi/exhaustive/pydantic-v2-validators/core/abstract_fern_service.py new file mode 100644 index 00000000000..9966b4876da --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/core/abstract_fern_service.py @@ -0,0 +1,10 @@ +# This file was auto-generated by Fern from our API Definition. + +import abc + +import fastapi + + +class AbstractFernService(abc.ABC): + @classmethod + def _init_fern(cls, router: fastapi.APIRouter) -> None: ... diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/core/datetime_utils.py b/seed/fastapi/exhaustive/pydantic-v2-validators/core/datetime_utils.py new file mode 100644 index 00000000000..47344e9d9cc --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/core/datetime_utils.py @@ -0,0 +1,30 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt + + +def serialize_datetime(v: dt.datetime) -> str: + """ + Serialize a datetime including timezone info. + + Uses the timezone info provided if present, otherwise uses the current runtime's timezone info. + + UTC datetimes end in "Z" while all other timezones are represented as offset from UTC, e.g. +05:00. + """ + + def _serialize_zoned_datetime(v: dt.datetime) -> str: + if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname( + None + ): + # UTC is a special case where we use "Z" at the end instead of "+00:00" + return v.isoformat().replace("+00:00", "Z") + else: + # Delegate to the typical +/- offset format + return v.isoformat() + + if v.tzinfo is not None: + return _serialize_zoned_datetime(v) + else: + local_tz = dt.datetime.now().astimezone().tzinfo + localized_dt = v.replace(tzinfo=local_tz) + return _serialize_zoned_datetime(localized_dt) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/core/exceptions/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/core/exceptions/__init__.py new file mode 100644 index 00000000000..dae4b8980c1 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/core/exceptions/__init__.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +from .fern_http_exception import FernHTTPException +from .handlers import ( + default_exception_handler, + fern_http_exception_handler, + http_exception_handler, +) +from .unauthorized import UnauthorizedException + +__all__ = [ + "FernHTTPException", + "UnauthorizedException", + "default_exception_handler", + "fern_http_exception_handler", + "http_exception_handler", +] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/core/exceptions/fern_http_exception.py b/seed/fastapi/exhaustive/pydantic-v2-validators/core/exceptions/fern_http_exception.py new file mode 100644 index 00000000000..81610359a7f --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/core/exceptions/fern_http_exception.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import abc +import fastapi +import typing + + +class FernHTTPException(abc.ABC, fastapi.HTTPException): + def __init__( + self, + status_code: int, + name: typing.Optional[str] = None, + content: typing.Optional[typing.Any] = None, + ): + super().__init__(status_code=status_code) + self.name = name + self.status_code = status_code + self.content = content + + def to_json_response(self) -> fastapi.responses.JSONResponse: + content = fastapi.encoders.jsonable_encoder(self.content, exclude_none=True) + return fastapi.responses.JSONResponse( + content=content, status_code=self.status_code + ) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/core/exceptions/handlers.py b/seed/fastapi/exhaustive/pydantic-v2-validators/core/exceptions/handlers.py new file mode 100644 index 00000000000..ae1c2741f06 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/core/exceptions/handlers.py @@ -0,0 +1,50 @@ +# This file was auto-generated by Fern from our API Definition. + +import logging + +import starlette +import starlette.exceptions + +import fastapi + +from .fern_http_exception import FernHTTPException + + +def fern_http_exception_handler( + request: fastapi.requests.Request, + exc: FernHTTPException, + skip_log: bool = False, +) -> fastapi.responses.JSONResponse: + if not skip_log: + logging.getLogger(__name__).error( + f"{exc.__class__.__name__} in {request.url.path}", exc_info=exc + ) + return exc.to_json_response() + + +def http_exception_handler( + request: fastapi.requests.Request, + exc: starlette.exceptions.HTTPException, + skip_log: bool = False, +) -> fastapi.responses.JSONResponse: + if not skip_log: + logging.getLogger(__name__).error( + f"{exc.__class__.__name__} in {request.url.path}", exc_info=exc + ) + return FernHTTPException( + status_code=exc.status_code, content=exc.detail + ).to_json_response() + + +def default_exception_handler( + request: fastapi.requests.Request, + exc: Exception, + skip_log: bool = False, +) -> fastapi.responses.JSONResponse: + if not skip_log: + logging.getLogger(__name__).error( + f"{exc.__class__.__name__} in {request.url.path}", exc_info=exc + ) + return FernHTTPException( + status_code=500, content="Internal Server Error" + ).to_json_response() diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/core/exceptions/unauthorized.py b/seed/fastapi/exhaustive/pydantic-v2-validators/core/exceptions/unauthorized.py new file mode 100644 index 00000000000..32d532e5ef2 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/core/exceptions/unauthorized.py @@ -0,0 +1,15 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from .fern_http_exception import FernHTTPException + + +class UnauthorizedException(FernHTTPException): + """ + This is the exception that is thrown by Fern when auth is not present on a + request. + """ + + def __init__(self, content: typing.Optional[str] = None) -> None: + super().__init__(status_code=401, content=content) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v2-validators/core/pydantic_utilities.py new file mode 100644 index 00000000000..fe6359cf503 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/core/pydantic_utilities.py @@ -0,0 +1,273 @@ +# 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 + +IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.") + +if IS_PYDANTIC_V2: + # isort will try to reformat the comments on these imports, which breaks mypy + # isort: off + from pydantic.v1.datetime_parse import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 + parse_date as parse_date, + ) + 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: + 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: + if IS_PYDANTIC_V2: + adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 + return adapter.validate_python(object_) + else: + return pydantic.parse_obj_as(type_, 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): + class Config: + populate_by_name = True + smart_union = True + allow_population_by_field_name = True + json_encoders = {dt.datetime: serialize_datetime} + # Allow fields begining with `model_` to be used in the model + protected_namespaces = () + + 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, + } + return 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, + } + + return super().dict(**kwargs_with_defaults_exclude_unset_include_fields) + + +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): + 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 + + +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/seed/fastapi/exhaustive/pydantic-v2-validators/core/route_args.py b/seed/fastapi/exhaustive/pydantic-v2-validators/core/route_args.py new file mode 100644 index 00000000000..bd940bf4ddd --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/core/route_args.py @@ -0,0 +1,73 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import inspect +import typing + +import typing_extensions + +T = typing.TypeVar("T", bound=typing.Callable[..., typing.Any]) + +FERN_CONFIG_KEY = "__fern" + + +class RouteArgs(typing_extensions.TypedDict): + openapi_extra: typing.Optional[typing.Dict[str, typing.Any]] + tags: typing.Optional[typing.List[typing.Union[str, enum.Enum]]] + include_in_schema: bool + + +DEFAULT_ROUTE_ARGS = RouteArgs(openapi_extra=None, tags=None, include_in_schema=True) + + +def get_route_args( + endpoint_function: typing.Callable[..., typing.Any], *, default_tag: str +) -> RouteArgs: + unwrapped = inspect.unwrap( + endpoint_function, stop=(lambda f: hasattr(f, FERN_CONFIG_KEY)) + ) + route_args = typing.cast( + RouteArgs, getattr(unwrapped, FERN_CONFIG_KEY, DEFAULT_ROUTE_ARGS) + ) + if route_args["tags"] is None: + return RouteArgs( + openapi_extra=route_args["openapi_extra"], + tags=[default_tag], + include_in_schema=route_args["include_in_schema"], + ) + return route_args + + +def route_args( + openapi_extra: typing.Optional[typing.Dict[str, typing.Any]] = None, + tags: typing.Optional[typing.List[typing.Union[str, enum.Enum]]] = None, + include_in_schema: bool = True, +) -> typing.Callable[[T], T]: + """ + this decorator allows you to forward certain args to the FastAPI route decorator. + + usage: + @route_args(openapi_extra=...) + def your_endpoint_method(... + + currently supported args: + - openapi_extra + - tags + + if there's another FastAPI route arg you need to pass through, please + contact the Fern team! + """ + + def decorator(endpoint_function: T) -> T: + setattr( + endpoint_function, + FERN_CONFIG_KEY, + RouteArgs( + openapi_extra=openapi_extra, + tags=tags, + include_in_schema=include_in_schema, + ), + ) + return endpoint_function + + return decorator diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/core/security/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/core/security/__init__.py new file mode 100644 index 00000000000..e69ee6d9c5a --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/core/security/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .bearer import BearerToken + +__all__ = ["BearerToken"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/core/security/bearer.py b/seed/fastapi/exhaustive/pydantic-v2-validators/core/security/bearer.py new file mode 100644 index 00000000000..023342b668d --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/core/security/bearer.py @@ -0,0 +1,22 @@ +# This file was auto-generated by Fern from our API Definition. + +import fastapi + +from ..exceptions import UnauthorizedException + + +class BearerToken: + def __init__(self, token: str): + self.token = token + + +def HTTPBearer(request: fastapi.requests.Request) -> BearerToken: + authorization_header_value = request.headers.get("Authorization") + if not authorization_header_value: + raise UnauthorizedException("Missing Authorization header") + scheme, _, token = authorization_header_value.partition(" ") + if scheme.lower() != "bearer": + raise UnauthorizedException("Authorization header scheme is not bearer") + if not token: + raise UnauthorizedException("Authorization header is missing a token") + return BearerToken(token) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/core/serialization.py b/seed/fastapi/exhaustive/pydantic-v2-validators/core/serialization.py new file mode 100644 index 00000000000..5679deb8a56 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/core/serialization.py @@ -0,0 +1,276 @@ +# 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/seed/fastapi/exhaustive/pydantic-v2-validators/register.py b/seed/fastapi/exhaustive/pydantic-v2-validators/register.py new file mode 100644 index 00000000000..1f804567f73 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/register.py @@ -0,0 +1,98 @@ +# This file was auto-generated by Fern from our API Definition. + +import fastapi +from .resources.endpoints.resources.container.service.service import ( + AbstractEndpointsContainerService, +) +from .resources.endpoints.resources.enum.service.service import ( + AbstractEndpointsEnumService, +) +from .resources.endpoints.resources.http_methods.service.service import ( + AbstractEndpointsHttpMethodsService, +) +from .resources.endpoints.resources.object.service.service import ( + AbstractEndpointsObjectService, +) +from .resources.endpoints.resources.params.service.service import ( + AbstractEndpointsParamsService, +) +from .resources.endpoints.resources.primitive.service.service import ( + AbstractEndpointsPrimitiveService, +) +from .resources.endpoints.resources.union.service.service import ( + AbstractEndpointsUnionService, +) +from .resources.inlined_requests.service.service import AbstractInlinedRequestsService +from .resources.no_auth.service.service import AbstractNoAuthService +from .resources.no_req_body.service.service import AbstractNoReqBodyService +from .resources.req_with_headers.service.service import AbstractReqWithHeadersService +import typing +from fastapi import params +from .core.exceptions.fern_http_exception import FernHTTPException +from .core.exceptions import fern_http_exception_handler +import starlette.exceptions +from .core.exceptions import http_exception_handler +from .core.exceptions import default_exception_handler +from .core.abstract_fern_service import AbstractFernService +import types +import os +import glob +import importlib + + +def register( + _app: fastapi.FastAPI, + *, + endpoints_container: AbstractEndpointsContainerService, + endpoints_enum: AbstractEndpointsEnumService, + endpoints_http_methods: AbstractEndpointsHttpMethodsService, + endpoints_object: AbstractEndpointsObjectService, + endpoints_params: AbstractEndpointsParamsService, + endpoints_primitive: AbstractEndpointsPrimitiveService, + endpoints_union: AbstractEndpointsUnionService, + inlined_requests: AbstractInlinedRequestsService, + no_auth: AbstractNoAuthService, + no_req_body: AbstractNoReqBodyService, + req_with_headers: AbstractReqWithHeadersService, + dependencies: typing.Optional[typing.Sequence[params.Depends]] = None, +) -> None: + _app.include_router( + __register_service(endpoints_container), dependencies=dependencies + ) + _app.include_router(__register_service(endpoints_enum), dependencies=dependencies) + _app.include_router( + __register_service(endpoints_http_methods), dependencies=dependencies + ) + _app.include_router(__register_service(endpoints_object), dependencies=dependencies) + _app.include_router(__register_service(endpoints_params), dependencies=dependencies) + _app.include_router( + __register_service(endpoints_primitive), dependencies=dependencies + ) + _app.include_router(__register_service(endpoints_union), dependencies=dependencies) + _app.include_router(__register_service(inlined_requests), dependencies=dependencies) + _app.include_router(__register_service(no_auth), dependencies=dependencies) + _app.include_router(__register_service(no_req_body), dependencies=dependencies) + _app.include_router(__register_service(req_with_headers), dependencies=dependencies) + + _app.add_exception_handler(FernHTTPException, fern_http_exception_handler) # type: ignore + _app.add_exception_handler( + starlette.exceptions.HTTPException, http_exception_handler + ) # type: ignore + _app.add_exception_handler(Exception, default_exception_handler) # type: ignore + + +def __register_service(service: AbstractFernService) -> fastapi.APIRouter: + router = fastapi.APIRouter() + type(service)._init_fern(router) + return router + + +def register_validators(module: types.ModuleType) -> None: + validators_directory: str = os.path.dirname(module.__file__) # type: ignore + for path in glob.glob( + os.path.join(validators_directory, "**/*.py"), recursive=True + ): + if os.path.isfile(path): + relative_path = os.path.relpath(path, start=validators_directory) + module_path = ".".join([module.__name__] + relative_path[:-3].split("/")) + importlib.import_module(module_path) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/__init__.py new file mode 100644 index 00000000000..29cd2856565 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/__init__.py @@ -0,0 +1,14 @@ +# This file was auto-generated by Fern from our API Definition. + +from . import general_errors, inlined_requests, types +from .general_errors import BadObjectRequestInfo, BadRequestBody +from .inlined_requests import PostWithObjectBody + +__all__ = [ + "BadObjectRequestInfo", + "BadRequestBody", + "PostWithObjectBody", + "general_errors", + "inlined_requests", + "types", +] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/container/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/container/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/container/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/container/service/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/container/service/__init__.py new file mode 100644 index 00000000000..21bb0c47d17 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/container/service/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .service import AbstractEndpointsContainerService + +__all__ = ["AbstractEndpointsContainerService"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/container/service/service.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/container/service/service.py new file mode 100644 index 00000000000..79da48ea0cc --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/container/service/service.py @@ -0,0 +1,425 @@ +# This file was auto-generated by Fern from our API Definition. + +from ......core.abstract_fern_service import AbstractFernService +import typing +from ......security import ApiAuth +import abc +from .....types.resources.object.types.object_with_required_field import ( + ObjectWithRequiredField, +) +import fastapi +import inspect +from ......security import FernAuth +from ......core.exceptions.fern_http_exception import FernHTTPException +import logging +import functools +from ......core.route_args import get_route_args + + +class AbstractEndpointsContainerService(AbstractFernService): + """ + AbstractEndpointsContainerService is an abstract class containing the methods that you should implement. + + Each method is associated with an API route, which will be registered + with FastAPI when you register your implementation using Fern's register() + function. + """ + + @abc.abstractmethod + def get_and_return_list_of_primitives( + self, *, body: typing.List[str], auth: ApiAuth + ) -> typing.Sequence[str]: ... + + @abc.abstractmethod + def get_and_return_list_of_objects( + self, *, body: typing.List[ObjectWithRequiredField], auth: ApiAuth + ) -> typing.Sequence[ObjectWithRequiredField]: ... + + @abc.abstractmethod + def get_and_return_set_of_primitives( + self, *, body: typing.Set[str], auth: ApiAuth + ) -> typing.Set[str]: ... + + @abc.abstractmethod + def get_and_return_set_of_objects( + self, *, body: typing.List[ObjectWithRequiredField], auth: ApiAuth + ) -> typing.Sequence[ObjectWithRequiredField]: ... + + @abc.abstractmethod + def get_and_return_map_prim_to_prim( + self, *, body: typing.Dict[str, str], auth: ApiAuth + ) -> typing.Dict[str, str]: ... + + @abc.abstractmethod + def get_and_return_map_of_prim_to_object( + self, *, body: typing.Dict[str, ObjectWithRequiredField], auth: ApiAuth + ) -> typing.Dict[str, ObjectWithRequiredField]: ... + + @abc.abstractmethod + def get_and_return_optional( + self, *, body: typing.Optional[ObjectWithRequiredField] = None, auth: ApiAuth + ) -> typing.Optional[ObjectWithRequiredField]: ... + + """ + Below are internal methods used by Fern to register your implementation. + You can ignore them. + """ + + @classmethod + def _init_fern(cls, router: fastapi.APIRouter) -> None: + cls.__init_get_and_return_list_of_primitives(router=router) + cls.__init_get_and_return_list_of_objects(router=router) + cls.__init_get_and_return_set_of_primitives(router=router) + cls.__init_get_and_return_set_of_objects(router=router) + cls.__init_get_and_return_map_prim_to_prim(router=router) + cls.__init_get_and_return_map_of_prim_to_object(router=router) + cls.__init_get_and_return_optional(router=router) + + @classmethod + def __init_get_and_return_list_of_primitives( + cls, router: fastapi.APIRouter + ) -> None: + endpoint_function = inspect.signature(cls.get_and_return_list_of_primitives) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_list_of_primitives, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_list_of_primitives) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> typing.Sequence[str]: + try: + return cls.get_and_return_list_of_primitives(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_list_of_primitives' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_list_of_primitives.__globals__) + + router.post( + path="/container/list-of-primitives", + response_model=typing.Sequence[str], + description=AbstractEndpointsContainerService.get_and_return_list_of_primitives.__doc__, + **get_route_args( + cls.get_and_return_list_of_primitives, default_tag="endpoints.container" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_list_of_objects(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_list_of_objects) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_list_of_objects, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_list_of_objects) + def wrapper( + *args: typing.Any, **kwargs: typing.Any + ) -> typing.Sequence[ObjectWithRequiredField]: + try: + return cls.get_and_return_list_of_objects(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_list_of_objects' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_list_of_objects.__globals__) + + router.post( + path="/container/list-of-objects", + response_model=typing.Sequence[ObjectWithRequiredField], + description=AbstractEndpointsContainerService.get_and_return_list_of_objects.__doc__, + **get_route_args( + cls.get_and_return_list_of_objects, default_tag="endpoints.container" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_set_of_primitives(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_set_of_primitives) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_set_of_primitives, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_set_of_primitives) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> typing.Set[str]: + try: + return cls.get_and_return_set_of_primitives(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_set_of_primitives' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_set_of_primitives.__globals__) + + router.post( + path="/container/set-of-primitives", + response_model=typing.Set[str], + description=AbstractEndpointsContainerService.get_and_return_set_of_primitives.__doc__, + **get_route_args( + cls.get_and_return_set_of_primitives, default_tag="endpoints.container" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_set_of_objects(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_set_of_objects) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_set_of_objects, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_set_of_objects) + def wrapper( + *args: typing.Any, **kwargs: typing.Any + ) -> typing.Sequence[ObjectWithRequiredField]: + try: + return cls.get_and_return_set_of_objects(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_set_of_objects' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_set_of_objects.__globals__) + + router.post( + path="/container/set-of-objects", + response_model=typing.Sequence[ObjectWithRequiredField], + description=AbstractEndpointsContainerService.get_and_return_set_of_objects.__doc__, + **get_route_args( + cls.get_and_return_set_of_objects, default_tag="endpoints.container" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_map_prim_to_prim(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_map_prim_to_prim) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_map_prim_to_prim, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_map_prim_to_prim) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> typing.Dict[str, str]: + try: + return cls.get_and_return_map_prim_to_prim(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_map_prim_to_prim' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_map_prim_to_prim.__globals__) + + router.post( + path="/container/map-prim-to-prim", + response_model=typing.Dict[str, str], + description=AbstractEndpointsContainerService.get_and_return_map_prim_to_prim.__doc__, + **get_route_args( + cls.get_and_return_map_prim_to_prim, default_tag="endpoints.container" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_map_of_prim_to_object( + cls, router: fastapi.APIRouter + ) -> None: + endpoint_function = inspect.signature(cls.get_and_return_map_of_prim_to_object) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_map_of_prim_to_object, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_map_of_prim_to_object) + def wrapper( + *args: typing.Any, **kwargs: typing.Any + ) -> typing.Dict[str, ObjectWithRequiredField]: + try: + return cls.get_and_return_map_of_prim_to_object(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_map_of_prim_to_object' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_map_of_prim_to_object.__globals__) + + router.post( + path="/container/map-prim-to-object", + response_model=typing.Dict[str, ObjectWithRequiredField], + description=AbstractEndpointsContainerService.get_and_return_map_of_prim_to_object.__doc__, + **get_route_args( + cls.get_and_return_map_of_prim_to_object, + default_tag="endpoints.container", + ), + )(wrapper) + + @classmethod + def __init_get_and_return_optional(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_optional) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_optional, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_optional) + def wrapper( + *args: typing.Any, **kwargs: typing.Any + ) -> typing.Optional[ObjectWithRequiredField]: + try: + return cls.get_and_return_optional(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_optional' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_optional.__globals__) + + router.post( + path="/container/opt-objects", + response_model=typing.Optional[ObjectWithRequiredField], + description=AbstractEndpointsContainerService.get_and_return_optional.__doc__, + **get_route_args( + cls.get_and_return_optional, default_tag="endpoints.container" + ), + )(wrapper) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/enum/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/enum/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/enum/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/enum/service/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/enum/service/__init__.py new file mode 100644 index 00000000000..6415e959895 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/enum/service/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .service import AbstractEndpointsEnumService + +__all__ = ["AbstractEndpointsEnumService"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/enum/service/service.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/enum/service/service.py new file mode 100644 index 00000000000..4c665920e0b --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/enum/service/service.py @@ -0,0 +1,84 @@ +# This file was auto-generated by Fern from our API Definition. + +from ......core.abstract_fern_service import AbstractFernService +from .....types.resources.enum.types.weather_report import WeatherReport +from ......security import ApiAuth +import abc +import fastapi +import inspect +import typing +from ......security import FernAuth +from ......core.exceptions.fern_http_exception import FernHTTPException +import logging +import functools +from ......core.route_args import get_route_args + + +class AbstractEndpointsEnumService(AbstractFernService): + """ + AbstractEndpointsEnumService is an abstract class containing the methods that you should implement. + + Each method is associated with an API route, which will be registered + with FastAPI when you register your implementation using Fern's register() + function. + """ + + @abc.abstractmethod + def get_and_return_enum( + self, *, body: WeatherReport, auth: ApiAuth + ) -> WeatherReport: ... + + """ + Below are internal methods used by Fern to register your implementation. + You can ignore them. + """ + + @classmethod + def _init_fern(cls, router: fastapi.APIRouter) -> None: + cls.__init_get_and_return_enum(router=router) + + @classmethod + def __init_get_and_return_enum(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_enum) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_enum, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_enum) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> WeatherReport: + try: + return cls.get_and_return_enum(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_enum' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_enum.__globals__) + + router.post( + path="/enum", + response_model=WeatherReport, + description=AbstractEndpointsEnumService.get_and_return_enum.__doc__, + **get_route_args(cls.get_and_return_enum, default_tag="endpoints.enum"), + )(wrapper) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/http_methods/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/http_methods/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/http_methods/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/http_methods/service/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/http_methods/service/__init__.py new file mode 100644 index 00000000000..22ea254d225 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/http_methods/service/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .service import AbstractEndpointsHttpMethodsService + +__all__ = ["AbstractEndpointsHttpMethodsService"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/http_methods/service/service.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/http_methods/service/service.py new file mode 100644 index 00000000000..73b65270c55 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/http_methods/service/service.py @@ -0,0 +1,297 @@ +# This file was auto-generated by Fern from our API Definition. + +from ......core.abstract_fern_service import AbstractFernService +from ......security import ApiAuth +import abc +from .....types.resources.object.types.object_with_required_field import ( + ObjectWithRequiredField, +) +from .....types.resources.object.types.object_with_optional_field import ( + ObjectWithOptionalField, +) +import fastapi +import inspect +import typing +from ......security import FernAuth +from ......core.exceptions.fern_http_exception import FernHTTPException +import logging +import functools +from ......core.route_args import get_route_args + + +class AbstractEndpointsHttpMethodsService(AbstractFernService): + """ + AbstractEndpointsHttpMethodsService is an abstract class containing the methods that you should implement. + + Each method is associated with an API route, which will be registered + with FastAPI when you register your implementation using Fern's register() + function. + """ + + @abc.abstractmethod + def test_get(self, *, id: str, auth: ApiAuth) -> str: ... + + @abc.abstractmethod + def test_post( + self, *, body: ObjectWithRequiredField, auth: ApiAuth + ) -> ObjectWithOptionalField: ... + + @abc.abstractmethod + def test_put( + self, *, body: ObjectWithRequiredField, id: str, auth: ApiAuth + ) -> ObjectWithOptionalField: ... + + @abc.abstractmethod + def test_patch( + self, *, body: ObjectWithOptionalField, id: str, auth: ApiAuth + ) -> ObjectWithOptionalField: ... + + @abc.abstractmethod + def test_delete(self, *, id: str, auth: ApiAuth) -> bool: ... + + """ + Below are internal methods used by Fern to register your implementation. + You can ignore them. + """ + + @classmethod + def _init_fern(cls, router: fastapi.APIRouter) -> None: + cls.__init_test_get(router=router) + cls.__init_test_post(router=router) + cls.__init_test_put(router=router) + cls.__init_test_patch(router=router) + cls.__init_test_delete(router=router) + + @classmethod + def __init_test_get(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.test_get) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "id": + new_parameters.append(parameter.replace(default=fastapi.Path(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.test_get, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.test_get) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> str: + try: + return cls.test_get(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'test_get' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.test_get.__globals__) + + router.get( + path="/http-methods/{id}", + response_model=str, + description=AbstractEndpointsHttpMethodsService.test_get.__doc__, + **get_route_args(cls.test_get, default_tag="endpoints.http_methods"), + )(wrapper) + + @classmethod + def __init_test_post(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.test_post) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.test_post, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.test_post) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> ObjectWithOptionalField: + try: + return cls.test_post(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'test_post' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.test_post.__globals__) + + router.post( + path="/http-methods", + response_model=ObjectWithOptionalField, + description=AbstractEndpointsHttpMethodsService.test_post.__doc__, + **get_route_args(cls.test_post, default_tag="endpoints.http_methods"), + )(wrapper) + + @classmethod + def __init_test_put(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.test_put) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "id": + new_parameters.append(parameter.replace(default=fastapi.Path(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.test_put, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.test_put) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> ObjectWithOptionalField: + try: + return cls.test_put(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'test_put' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.test_put.__globals__) + + router.put( + path="/http-methods/{id}", + response_model=ObjectWithOptionalField, + description=AbstractEndpointsHttpMethodsService.test_put.__doc__, + **get_route_args(cls.test_put, default_tag="endpoints.http_methods"), + )(wrapper) + + @classmethod + def __init_test_patch(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.test_patch) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "id": + new_parameters.append(parameter.replace(default=fastapi.Path(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.test_patch, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.test_patch) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> ObjectWithOptionalField: + try: + return cls.test_patch(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'test_patch' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.test_patch.__globals__) + + router.patch( + path="/http-methods/{id}", + response_model=ObjectWithOptionalField, + description=AbstractEndpointsHttpMethodsService.test_patch.__doc__, + **get_route_args(cls.test_patch, default_tag="endpoints.http_methods"), + )(wrapper) + + @classmethod + def __init_test_delete(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.test_delete) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "id": + new_parameters.append(parameter.replace(default=fastapi.Path(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.test_delete, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.test_delete) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> bool: + try: + return cls.test_delete(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'test_delete' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.test_delete.__globals__) + + router.delete( + path="/http-methods/{id}", + response_model=bool, + description=AbstractEndpointsHttpMethodsService.test_delete.__doc__, + **get_route_args(cls.test_delete, default_tag="endpoints.http_methods"), + )(wrapper) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/object/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/object/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/object/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/object/service/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/object/service/__init__.py new file mode 100644 index 00000000000..9b7c53dfae2 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/object/service/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .service import AbstractEndpointsObjectService + +__all__ = ["AbstractEndpointsObjectService"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/object/service/service.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/object/service/service.py new file mode 100644 index 00000000000..8b73109a788 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/object/service/service.py @@ -0,0 +1,403 @@ +# This file was auto-generated by Fern from our API Definition. + +from ......core.abstract_fern_service import AbstractFernService +from .....types.resources.object.types.object_with_optional_field import ( + ObjectWithOptionalField, +) +from ......security import ApiAuth +import abc +from .....types.resources.object.types.object_with_required_field import ( + ObjectWithRequiredField, +) +from .....types.resources.object.types.object_with_map_of_map import ObjectWithMapOfMap +from .....types.resources.object.types.nested_object_with_optional_field import ( + NestedObjectWithOptionalField, +) +from .....types.resources.object.types.nested_object_with_required_field import ( + NestedObjectWithRequiredField, +) +import typing +import fastapi +import inspect +from ......security import FernAuth +from ......core.exceptions.fern_http_exception import FernHTTPException +import logging +import functools +from ......core.route_args import get_route_args + + +class AbstractEndpointsObjectService(AbstractFernService): + """ + AbstractEndpointsObjectService is an abstract class containing the methods that you should implement. + + Each method is associated with an API route, which will be registered + with FastAPI when you register your implementation using Fern's register() + function. + """ + + @abc.abstractmethod + def get_and_return_with_optional_field( + self, *, body: ObjectWithOptionalField, auth: ApiAuth + ) -> ObjectWithOptionalField: ... + + @abc.abstractmethod + def get_and_return_with_required_field( + self, *, body: ObjectWithRequiredField, auth: ApiAuth + ) -> ObjectWithRequiredField: ... + + @abc.abstractmethod + def get_and_return_with_map_of_map( + self, *, body: ObjectWithMapOfMap, auth: ApiAuth + ) -> ObjectWithMapOfMap: ... + + @abc.abstractmethod + def get_and_return_nested_with_optional_field( + self, *, body: NestedObjectWithOptionalField, auth: ApiAuth + ) -> NestedObjectWithOptionalField: ... + + @abc.abstractmethod + def get_and_return_nested_with_required_field( + self, *, body: NestedObjectWithRequiredField, string: str, auth: ApiAuth + ) -> NestedObjectWithRequiredField: ... + + @abc.abstractmethod + def get_and_return_nested_with_required_field_as_list( + self, *, body: typing.List[NestedObjectWithRequiredField], auth: ApiAuth + ) -> NestedObjectWithRequiredField: ... + + """ + Below are internal methods used by Fern to register your implementation. + You can ignore them. + """ + + @classmethod + def _init_fern(cls, router: fastapi.APIRouter) -> None: + cls.__init_get_and_return_with_optional_field(router=router) + cls.__init_get_and_return_with_required_field(router=router) + cls.__init_get_and_return_with_map_of_map(router=router) + cls.__init_get_and_return_nested_with_optional_field(router=router) + cls.__init_get_and_return_nested_with_required_field(router=router) + cls.__init_get_and_return_nested_with_required_field_as_list(router=router) + + @classmethod + def __init_get_and_return_with_optional_field( + cls, router: fastapi.APIRouter + ) -> None: + endpoint_function = inspect.signature(cls.get_and_return_with_optional_field) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_with_optional_field, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_with_optional_field) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> ObjectWithOptionalField: + try: + return cls.get_and_return_with_optional_field(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_with_optional_field' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_with_optional_field.__globals__) + + router.post( + path="/object/get-and-return-with-optional-field", + response_model=ObjectWithOptionalField, + description=AbstractEndpointsObjectService.get_and_return_with_optional_field.__doc__, + **get_route_args( + cls.get_and_return_with_optional_field, default_tag="endpoints.object" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_with_required_field( + cls, router: fastapi.APIRouter + ) -> None: + endpoint_function = inspect.signature(cls.get_and_return_with_required_field) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_with_required_field, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_with_required_field) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> ObjectWithRequiredField: + try: + return cls.get_and_return_with_required_field(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_with_required_field' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_with_required_field.__globals__) + + router.post( + path="/object/get-and-return-with-required-field", + response_model=ObjectWithRequiredField, + description=AbstractEndpointsObjectService.get_and_return_with_required_field.__doc__, + **get_route_args( + cls.get_and_return_with_required_field, default_tag="endpoints.object" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_with_map_of_map(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_with_map_of_map) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_with_map_of_map, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_with_map_of_map) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> ObjectWithMapOfMap: + try: + return cls.get_and_return_with_map_of_map(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_with_map_of_map' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_with_map_of_map.__globals__) + + router.post( + path="/object/get-and-return-with-map-of-map", + response_model=ObjectWithMapOfMap, + description=AbstractEndpointsObjectService.get_and_return_with_map_of_map.__doc__, + **get_route_args( + cls.get_and_return_with_map_of_map, default_tag="endpoints.object" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_nested_with_optional_field( + cls, router: fastapi.APIRouter + ) -> None: + endpoint_function = inspect.signature( + cls.get_and_return_nested_with_optional_field + ) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_nested_with_optional_field, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_nested_with_optional_field) + def wrapper( + *args: typing.Any, **kwargs: typing.Any + ) -> NestedObjectWithOptionalField: + try: + return cls.get_and_return_nested_with_optional_field(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_nested_with_optional_field' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update( + cls.get_and_return_nested_with_optional_field.__globals__ + ) + + router.post( + path="/object/get-and-return-nested-with-optional-field", + response_model=NestedObjectWithOptionalField, + description=AbstractEndpointsObjectService.get_and_return_nested_with_optional_field.__doc__, + **get_route_args( + cls.get_and_return_nested_with_optional_field, + default_tag="endpoints.object", + ), + )(wrapper) + + @classmethod + def __init_get_and_return_nested_with_required_field( + cls, router: fastapi.APIRouter + ) -> None: + endpoint_function = inspect.signature( + cls.get_and_return_nested_with_required_field + ) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "string": + new_parameters.append(parameter.replace(default=fastapi.Path(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_nested_with_required_field, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_nested_with_required_field) + def wrapper( + *args: typing.Any, **kwargs: typing.Any + ) -> NestedObjectWithRequiredField: + try: + return cls.get_and_return_nested_with_required_field(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_nested_with_required_field' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update( + cls.get_and_return_nested_with_required_field.__globals__ + ) + + router.post( + path="/object/get-and-return-nested-with-required-field/{string}", + response_model=NestedObjectWithRequiredField, + description=AbstractEndpointsObjectService.get_and_return_nested_with_required_field.__doc__, + **get_route_args( + cls.get_and_return_nested_with_required_field, + default_tag="endpoints.object", + ), + )(wrapper) + + @classmethod + def __init_get_and_return_nested_with_required_field_as_list( + cls, router: fastapi.APIRouter + ) -> None: + endpoint_function = inspect.signature( + cls.get_and_return_nested_with_required_field_as_list + ) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_nested_with_required_field_as_list, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_nested_with_required_field_as_list) + def wrapper( + *args: typing.Any, **kwargs: typing.Any + ) -> NestedObjectWithRequiredField: + try: + return cls.get_and_return_nested_with_required_field_as_list( + *args, **kwargs + ) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_nested_with_required_field_as_list' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update( + cls.get_and_return_nested_with_required_field_as_list.__globals__ + ) + + router.post( + path="/object/get-and-return-nested-with-required-field-list", + response_model=NestedObjectWithRequiredField, + description=AbstractEndpointsObjectService.get_and_return_nested_with_required_field_as_list.__doc__, + **get_route_args( + cls.get_and_return_nested_with_required_field_as_list, + default_tag="endpoints.object", + ), + )(wrapper) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/params/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/params/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/params/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/params/service/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/params/service/__init__.py new file mode 100644 index 00000000000..f7278fe82be --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/params/service/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .service import AbstractEndpointsParamsService + +__all__ = ["AbstractEndpointsParamsService"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/params/service/service.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/params/service/service.py new file mode 100644 index 00000000000..93c809bd4e7 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/params/service/service.py @@ -0,0 +1,329 @@ +# This file was auto-generated by Fern from our API Definition. + +from ......core.abstract_fern_service import AbstractFernService +from ......security import ApiAuth +import abc +import typing +import fastapi +import inspect +from ......security import FernAuth +from ......core.exceptions.fern_http_exception import FernHTTPException +import logging +import functools +from ......core.route_args import get_route_args +import starlette + + +class AbstractEndpointsParamsService(AbstractFernService): + """ + AbstractEndpointsParamsService is an abstract class containing the methods that you should implement. + + Each method is associated with an API route, which will be registered + with FastAPI when you register your implementation using Fern's register() + function. + """ + + @abc.abstractmethod + def get_with_path(self, *, param: str, auth: ApiAuth) -> str: + """ + GET with path param + """ + ... + + @abc.abstractmethod + def get_with_query(self, *, query: str, number: int, auth: ApiAuth) -> None: + """ + GET with query param + """ + ... + + @abc.abstractmethod + def get_with_allow_multiple_query( + self, *, query: typing.List[str], numer: typing.List[int], auth: ApiAuth + ) -> None: + """ + GET with multiple of same query param + """ + ... + + @abc.abstractmethod + def get_with_path_and_query(self, *, param: str, query: str, auth: ApiAuth) -> None: + """ + GET with path and query params + """ + ... + + @abc.abstractmethod + def modify_with_path(self, *, body: str, param: str, auth: ApiAuth) -> str: + """ + PUT to update with path param + """ + ... + + """ + Below are internal methods used by Fern to register your implementation. + You can ignore them. + """ + + @classmethod + def _init_fern(cls, router: fastapi.APIRouter) -> None: + cls.__init_get_with_path(router=router) + cls.__init_get_with_query(router=router) + cls.__init_get_with_allow_multiple_query(router=router) + cls.__init_get_with_path_and_query(router=router) + cls.__init_modify_with_path(router=router) + + @classmethod + def __init_get_with_path(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_with_path) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "param": + new_parameters.append(parameter.replace(default=fastapi.Path(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_with_path, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_with_path) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> str: + try: + return cls.get_with_path(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_with_path' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_with_path.__globals__) + + router.get( + path="/params/path/{param}", + response_model=str, + description=AbstractEndpointsParamsService.get_with_path.__doc__, + **get_route_args(cls.get_with_path, default_tag="endpoints.params"), + )(wrapper) + + @classmethod + def __init_get_with_query(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_with_query) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "query": + new_parameters.append( + parameter.replace(default=fastapi.Query(default=...)) + ) + elif parameter_name == "number": + new_parameters.append( + parameter.replace(default=fastapi.Query(default=...)) + ) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_with_query, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_with_query) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> None: + try: + return cls.get_with_query(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_with_query' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_with_query.__globals__) + + router.get( + path="/params", + response_model=None, + status_code=starlette.status.HTTP_204_NO_CONTENT, + description=AbstractEndpointsParamsService.get_with_query.__doc__, + **get_route_args(cls.get_with_query, default_tag="endpoints.params"), + )(wrapper) + + @classmethod + def __init_get_with_allow_multiple_query(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_with_allow_multiple_query) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "query": + new_parameters.append( + parameter.replace(default=fastapi.Query(default=[])) + ) + elif parameter_name == "numer": + new_parameters.append( + parameter.replace(default=fastapi.Query(default=[])) + ) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_with_allow_multiple_query, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_with_allow_multiple_query) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> None: + try: + return cls.get_with_allow_multiple_query(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_with_allow_multiple_query' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_with_allow_multiple_query.__globals__) + + router.get( + path="/params", + response_model=None, + status_code=starlette.status.HTTP_204_NO_CONTENT, + description=AbstractEndpointsParamsService.get_with_allow_multiple_query.__doc__, + **get_route_args( + cls.get_with_allow_multiple_query, default_tag="endpoints.params" + ), + )(wrapper) + + @classmethod + def __init_get_with_path_and_query(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_with_path_and_query) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "param": + new_parameters.append(parameter.replace(default=fastapi.Path(...))) + elif parameter_name == "query": + new_parameters.append( + parameter.replace(default=fastapi.Query(default=...)) + ) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_with_path_and_query, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_with_path_and_query) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> None: + try: + return cls.get_with_path_and_query(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_with_path_and_query' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_with_path_and_query.__globals__) + + router.get( + path="/params/path-query/{param}", + response_model=None, + status_code=starlette.status.HTTP_204_NO_CONTENT, + description=AbstractEndpointsParamsService.get_with_path_and_query.__doc__, + **get_route_args( + cls.get_with_path_and_query, default_tag="endpoints.params" + ), + )(wrapper) + + @classmethod + def __init_modify_with_path(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.modify_with_path) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "param": + new_parameters.append(parameter.replace(default=fastapi.Path(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.modify_with_path, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.modify_with_path) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> str: + try: + return cls.modify_with_path(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'modify_with_path' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.modify_with_path.__globals__) + + router.put( + path="/params/path/{param}", + response_model=str, + description=AbstractEndpointsParamsService.modify_with_path.__doc__, + **get_route_args(cls.modify_with_path, default_tag="endpoints.params"), + )(wrapper) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/primitive/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/primitive/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/primitive/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/primitive/service/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/primitive/service/__init__.py new file mode 100644 index 00000000000..cbdabe15630 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/primitive/service/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .service import AbstractEndpointsPrimitiveService + +__all__ = ["AbstractEndpointsPrimitiveService"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/primitive/service/service.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/primitive/service/service.py new file mode 100644 index 00000000000..78b3526b630 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/primitive/service/service.py @@ -0,0 +1,501 @@ +# This file was auto-generated by Fern from our API Definition. + +from ......core.abstract_fern_service import AbstractFernService +from ......security import ApiAuth +import abc +import datetime as dt +import uuid +import fastapi +import inspect +import typing +from ......security import FernAuth +from ......core.exceptions.fern_http_exception import FernHTTPException +import logging +import functools +from ......core.route_args import get_route_args + + +class AbstractEndpointsPrimitiveService(AbstractFernService): + """ + AbstractEndpointsPrimitiveService is an abstract class containing the methods that you should implement. + + Each method is associated with an API route, which will be registered + with FastAPI when you register your implementation using Fern's register() + function. + """ + + @abc.abstractmethod + def get_and_return_string(self, *, body: str, auth: ApiAuth) -> str: ... + + @abc.abstractmethod + def get_and_return_int(self, *, body: int, auth: ApiAuth) -> int: ... + + @abc.abstractmethod + def get_and_return_long(self, *, body: int, auth: ApiAuth) -> int: ... + + @abc.abstractmethod + def get_and_return_double(self, *, body: float, auth: ApiAuth) -> float: ... + + @abc.abstractmethod + def get_and_return_bool(self, *, body: bool, auth: ApiAuth) -> bool: ... + + @abc.abstractmethod + def get_and_return_datetime( + self, *, body: dt.datetime, auth: ApiAuth + ) -> dt.datetime: ... + + @abc.abstractmethod + def get_and_return_date(self, *, body: dt.date, auth: ApiAuth) -> dt.date: ... + + @abc.abstractmethod + def get_and_return_uuid(self, *, body: uuid.UUID, auth: ApiAuth) -> uuid.UUID: ... + + @abc.abstractmethod + def get_and_return_base_64(self, *, body: str, auth: ApiAuth) -> str: ... + + """ + Below are internal methods used by Fern to register your implementation. + You can ignore them. + """ + + @classmethod + def _init_fern(cls, router: fastapi.APIRouter) -> None: + cls.__init_get_and_return_string(router=router) + cls.__init_get_and_return_int(router=router) + cls.__init_get_and_return_long(router=router) + cls.__init_get_and_return_double(router=router) + cls.__init_get_and_return_bool(router=router) + cls.__init_get_and_return_datetime(router=router) + cls.__init_get_and_return_date(router=router) + cls.__init_get_and_return_uuid(router=router) + cls.__init_get_and_return_base_64(router=router) + + @classmethod + def __init_get_and_return_string(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_string) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_string, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_string) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> str: + try: + return cls.get_and_return_string(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_string' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_string.__globals__) + + router.post( + path="/primitive/string", + response_model=str, + description=AbstractEndpointsPrimitiveService.get_and_return_string.__doc__, + **get_route_args( + cls.get_and_return_string, default_tag="endpoints.primitive" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_int(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_int) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_int, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_int) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> int: + try: + return cls.get_and_return_int(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_int' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_int.__globals__) + + router.post( + path="/primitive/integer", + response_model=int, + description=AbstractEndpointsPrimitiveService.get_and_return_int.__doc__, + **get_route_args(cls.get_and_return_int, default_tag="endpoints.primitive"), + )(wrapper) + + @classmethod + def __init_get_and_return_long(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_long) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_long, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_long) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> int: + try: + return cls.get_and_return_long(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_long' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_long.__globals__) + + router.post( + path="/primitive/long", + response_model=int, + description=AbstractEndpointsPrimitiveService.get_and_return_long.__doc__, + **get_route_args( + cls.get_and_return_long, default_tag="endpoints.primitive" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_double(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_double) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_double, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_double) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> float: + try: + return cls.get_and_return_double(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_double' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_double.__globals__) + + router.post( + path="/primitive/double", + response_model=float, + description=AbstractEndpointsPrimitiveService.get_and_return_double.__doc__, + **get_route_args( + cls.get_and_return_double, default_tag="endpoints.primitive" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_bool(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_bool) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_bool, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_bool) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> bool: + try: + return cls.get_and_return_bool(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_bool' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_bool.__globals__) + + router.post( + path="/primitive/boolean", + response_model=bool, + description=AbstractEndpointsPrimitiveService.get_and_return_bool.__doc__, + **get_route_args( + cls.get_and_return_bool, default_tag="endpoints.primitive" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_datetime(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_datetime) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_datetime, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_datetime) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> dt.datetime: + try: + return cls.get_and_return_datetime(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_datetime' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_datetime.__globals__) + + router.post( + path="/primitive/datetime", + response_model=dt.datetime, + description=AbstractEndpointsPrimitiveService.get_and_return_datetime.__doc__, + **get_route_args( + cls.get_and_return_datetime, default_tag="endpoints.primitive" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_date(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_date) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_date, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_date) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> dt.date: + try: + return cls.get_and_return_date(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_date' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_date.__globals__) + + router.post( + path="/primitive/date", + response_model=dt.date, + description=AbstractEndpointsPrimitiveService.get_and_return_date.__doc__, + **get_route_args( + cls.get_and_return_date, default_tag="endpoints.primitive" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_uuid(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_uuid) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_uuid, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_uuid) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> uuid.UUID: + try: + return cls.get_and_return_uuid(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_uuid' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_uuid.__globals__) + + router.post( + path="/primitive/uuid", + response_model=uuid.UUID, + description=AbstractEndpointsPrimitiveService.get_and_return_uuid.__doc__, + **get_route_args( + cls.get_and_return_uuid, default_tag="endpoints.primitive" + ), + )(wrapper) + + @classmethod + def __init_get_and_return_base_64(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_base_64) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_base_64, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_base_64) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> str: + try: + return cls.get_and_return_base_64(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_base_64' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_base_64.__globals__) + + router.post( + path="/primitive/base64", + response_model=str, + description=AbstractEndpointsPrimitiveService.get_and_return_base_64.__doc__, + **get_route_args( + cls.get_and_return_base_64, default_tag="endpoints.primitive" + ), + )(wrapper) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/union/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/union/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/union/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/union/service/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/union/service/__init__.py new file mode 100644 index 00000000000..37bb942b185 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/union/service/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .service import AbstractEndpointsUnionService + +__all__ = ["AbstractEndpointsUnionService"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/union/service/service.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/union/service/service.py new file mode 100644 index 00000000000..cc962963db9 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/endpoints/resources/union/service/service.py @@ -0,0 +1,82 @@ +# This file was auto-generated by Fern from our API Definition. + +from ......core.abstract_fern_service import AbstractFernService +from .....types.resources.union.types.animal import Animal +from ......security import ApiAuth +import abc +import fastapi +import inspect +import typing +from ......security import FernAuth +from ......core.exceptions.fern_http_exception import FernHTTPException +import logging +import functools +from ......core.route_args import get_route_args + + +class AbstractEndpointsUnionService(AbstractFernService): + """ + AbstractEndpointsUnionService is an abstract class containing the methods that you should implement. + + Each method is associated with an API route, which will be registered + with FastAPI when you register your implementation using Fern's register() + function. + """ + + @abc.abstractmethod + def get_and_return_union(self, *, body: Animal, auth: ApiAuth) -> Animal: ... + + """ + Below are internal methods used by Fern to register your implementation. + You can ignore them. + """ + + @classmethod + def _init_fern(cls, router: fastapi.APIRouter) -> None: + cls.__init_get_and_return_union(router=router) + + @classmethod + def __init_get_and_return_union(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_and_return_union) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_and_return_union, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_and_return_union) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> Animal: + try: + return cls.get_and_return_union(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_and_return_union' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_and_return_union.__globals__) + + router.post( + path="/union", + response_model=Animal, + description=AbstractEndpointsUnionService.get_and_return_union.__doc__, + **get_route_args(cls.get_and_return_union, default_tag="endpoints.union"), + )(wrapper) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/__init__.py new file mode 100644 index 00000000000..115c26555f3 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/__init__.py @@ -0,0 +1,6 @@ +# This file was auto-generated by Fern from our API Definition. + +from .errors import BadRequestBody +from .types import BadObjectRequestInfo + +__all__ = ["BadObjectRequestInfo", "BadRequestBody"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/errors/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/errors/__init__.py new file mode 100644 index 00000000000..04eaf8e383b --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/errors/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .bad_request_body import BadRequestBody + +__all__ = ["BadRequestBody"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/errors/bad_request_body.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/errors/bad_request_body.py new file mode 100644 index 00000000000..9c75b4bcf0c --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/errors/bad_request_body.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.exceptions.fern_http_exception import FernHTTPException +from ..types.bad_object_request_info import BadObjectRequestInfo + + +class BadRequestBody(FernHTTPException): + def __init__(self, error: BadObjectRequestInfo): + super().__init__(status_code=400, name="BadRequestBody", content=error) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/types/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/types/__init__.py new file mode 100644 index 00000000000..b6788a57056 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/types/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .bad_object_request_info import BadObjectRequestInfo + +__all__ = ["BadObjectRequestInfo"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/types/bad_object_request_info.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/types/bad_object_request_info.py new file mode 100644 index 00000000000..463f69dec80 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/general_errors/types/bad_object_request_info.py @@ -0,0 +1,151 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ....core.pydantic_utilities import UniversalBaseModel +import typing +import typing_extensions +import pydantic +from ....core.pydantic_utilities import universal_field_validator + + +class BadObjectRequestInfo(UniversalBaseModel): + message: str + + class Partial(typing.TypedDict): + message: typing_extensions.NotRequired[str] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @BadObjectRequestInfo.Validators.root() + def validate(values: BadObjectRequestInfo.Partial) -> BadObjectRequestInfo.Partial: + ... + + @BadObjectRequestInfo.Validators.field("message") + def validate_message(message: str, values: BadObjectRequestInfo.Partial) -> str: + ... + """ + + _pre_validators: typing.ClassVar[ + typing.List[BadObjectRequestInfo.Validators._PreRootValidator] + ] = [] + _post_validators: typing.ClassVar[ + typing.List[BadObjectRequestInfo.Validators._RootValidator] + ] = [] + _message_pre_validators: typing.ClassVar[ + typing.List[BadObjectRequestInfo.Validators.PreMessageValidator] + ] = [] + _message_post_validators: typing.ClassVar[ + typing.List[BadObjectRequestInfo.Validators.MessageValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [BadObjectRequestInfo.Validators._RootValidator], + BadObjectRequestInfo.Validators._RootValidator, + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [BadObjectRequestInfo.Validators._PreRootValidator], + BadObjectRequestInfo.Validators._PreRootValidator, + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["message"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [BadObjectRequestInfo.Validators.PreMessageValidator], + BadObjectRequestInfo.Validators.PreMessageValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["message"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [BadObjectRequestInfo.Validators.MessageValidator], + BadObjectRequestInfo.Validators.MessageValidator, + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "message": + if pre: + cls._message_pre_validators.append(validator) + else: + cls._message_post_validators.append(validator) + return validator + + return decorator + + class PreMessageValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: BadObjectRequestInfo.Partial + ) -> typing.Any: ... + + class MessageValidator(typing.Protocol): + def __call__( + self, __v: str, __values: BadObjectRequestInfo.Partial + ) -> str: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__( + self, __values: BadObjectRequestInfo.Partial + ) -> BadObjectRequestInfo.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_bad_object_request_info( + cls, model: BadObjectRequestInfo + ) -> BadObjectRequestInfo: + for validator in BadObjectRequestInfo.Validators._pre_validators: + model = validator(model) + return model + + @pydantic.model_validator(mode="after") + def _post_validate_bad_object_request_info( + cls, model: BadObjectRequestInfo + ) -> BadObjectRequestInfo: + for validator in BadObjectRequestInfo.Validators._post_validators: + model = validator(model) # type: ignore + return model + + @universal_field_validator("message", pre=True) + def _pre_validate_message(cls, v: str, values: BadObjectRequestInfo.Partial) -> str: + for validator in BadObjectRequestInfo.Validators._message_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("message", pre=False) + def _post_validate_message( + cls, v: str, values: BadObjectRequestInfo.Partial + ) -> str: + for validator in BadObjectRequestInfo.Validators._message_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="forbid", frozen=True + ) # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/inlined_requests/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/inlined_requests/__init__.py new file mode 100644 index 00000000000..e49491cc185 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/inlined_requests/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .service import PostWithObjectBody + +__all__ = ["PostWithObjectBody"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/inlined_requests/service/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/inlined_requests/service/__init__.py new file mode 100644 index 00000000000..c1d5bec72c8 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/inlined_requests/service/__init__.py @@ -0,0 +1,6 @@ +# This file was auto-generated by Fern from our API Definition. + +from .post_with_object_body import PostWithObjectBody +from .service import AbstractInlinedRequestsService + +__all__ = ["AbstractInlinedRequestsService", "PostWithObjectBody"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/inlined_requests/service/post_with_object_body.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/inlined_requests/service/post_with_object_body.py new file mode 100644 index 00000000000..9350c3d8aac --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/inlined_requests/service/post_with_object_body.py @@ -0,0 +1,271 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ....core.pydantic_utilities import UniversalBaseModel +from ...types.resources.object.types.object_with_optional_field import ( + ObjectWithOptionalField, +) +import pydantic +import typing +import typing_extensions +from ....core.pydantic_utilities import universal_field_validator + + +class PostWithObjectBody(UniversalBaseModel): + string: str + integer: int + nested_object: ObjectWithOptionalField = pydantic.Field(alias="NestedObject") + + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[str] + integer: typing_extensions.NotRequired[int] + nested_object: typing_extensions.NotRequired[ObjectWithOptionalField] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @PostWithObjectBody.Validators.root() + def validate(values: PostWithObjectBody.Partial) -> PostWithObjectBody.Partial: + ... + + @PostWithObjectBody.Validators.field("string") + def validate_string(string: str, values: PostWithObjectBody.Partial) -> str: + ... + + @PostWithObjectBody.Validators.field("integer") + def validate_integer(integer: int, values: PostWithObjectBody.Partial) -> int: + ... + + @PostWithObjectBody.Validators.field("nested_object") + def validate_nested_object(nested_object: ObjectWithOptionalField, values: PostWithObjectBody.Partial) -> ObjectWithOptionalField: + ... + """ + + _pre_validators: typing.ClassVar[ + typing.List[PostWithObjectBody.Validators._PreRootValidator] + ] = [] + _post_validators: typing.ClassVar[ + typing.List[PostWithObjectBody.Validators._RootValidator] + ] = [] + _string_pre_validators: typing.ClassVar[ + typing.List[PostWithObjectBody.Validators.PreStringValidator] + ] = [] + _string_post_validators: typing.ClassVar[ + typing.List[PostWithObjectBody.Validators.StringValidator] + ] = [] + _integer_pre_validators: typing.ClassVar[ + typing.List[PostWithObjectBody.Validators.PreIntegerValidator] + ] = [] + _integer_post_validators: typing.ClassVar[ + typing.List[PostWithObjectBody.Validators.IntegerValidator] + ] = [] + _nested_object_pre_validators: typing.ClassVar[ + typing.List[PostWithObjectBody.Validators.PreNestedObjectValidator] + ] = [] + _nested_object_post_validators: typing.ClassVar[ + typing.List[PostWithObjectBody.Validators.NestedObjectValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [PostWithObjectBody.Validators._RootValidator], + PostWithObjectBody.Validators._RootValidator, + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [PostWithObjectBody.Validators._PreRootValidator], + PostWithObjectBody.Validators._PreRootValidator, + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [PostWithObjectBody.Validators.PreStringValidator], + PostWithObjectBody.Validators.PreStringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["string"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [PostWithObjectBody.Validators.StringValidator], + PostWithObjectBody.Validators.StringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["integer"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [PostWithObjectBody.Validators.PreIntegerValidator], + PostWithObjectBody.Validators.PreIntegerValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["integer"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [PostWithObjectBody.Validators.IntegerValidator], + PostWithObjectBody.Validators.IntegerValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["nested_object"], + *, + pre: typing.Literal[True], + ) -> typing.Callable[ + [PostWithObjectBody.Validators.PreNestedObjectValidator], + PostWithObjectBody.Validators.PreNestedObjectValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["nested_object"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [PostWithObjectBody.Validators.NestedObjectValidator], + PostWithObjectBody.Validators.NestedObjectValidator, + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "string": + if pre: + cls._string_pre_validators.append(validator) + else: + cls._string_post_validators.append(validator) + if field_name == "integer": + if pre: + cls._integer_pre_validators.append(validator) + else: + cls._integer_post_validators.append(validator) + if field_name == "nested_object": + if pre: + cls._nested_object_pre_validators.append(validator) + else: + cls._nested_object_post_validators.append(validator) + return validator + + return decorator + + class PreStringValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: PostWithObjectBody.Partial + ) -> typing.Any: ... + + class StringValidator(typing.Protocol): + def __call__( + self, __v: str, __values: PostWithObjectBody.Partial + ) -> str: ... + + class PreIntegerValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: PostWithObjectBody.Partial + ) -> typing.Any: ... + + class IntegerValidator(typing.Protocol): + def __call__( + self, __v: int, __values: PostWithObjectBody.Partial + ) -> int: ... + + class PreNestedObjectValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: PostWithObjectBody.Partial + ) -> typing.Any: ... + + class NestedObjectValidator(typing.Protocol): + def __call__( + self, __v: ObjectWithOptionalField, __values: PostWithObjectBody.Partial + ) -> ObjectWithOptionalField: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__( + self, __values: PostWithObjectBody.Partial + ) -> PostWithObjectBody.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate(cls, model: PostWithObjectBody) -> PostWithObjectBody: + for validator in PostWithObjectBody.Validators._pre_validators: + model = validator(model) + return model + + @pydantic.model_validator(mode="after") + def _post_validate(cls, model: PostWithObjectBody) -> PostWithObjectBody: + for validator in PostWithObjectBody.Validators._post_validators: + model = validator(model) # type: ignore + return model + + @universal_field_validator("string", pre=True) + def _pre_validate_string(cls, v: str, values: PostWithObjectBody.Partial) -> str: + for validator in PostWithObjectBody.Validators._string_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("string", pre=False) + def _post_validate_string(cls, v: str, values: PostWithObjectBody.Partial) -> str: + for validator in PostWithObjectBody.Validators._string_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("integer", pre=True) + def _pre_validate_integer(cls, v: int, values: PostWithObjectBody.Partial) -> int: + for validator in PostWithObjectBody.Validators._integer_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("integer", pre=False) + def _post_validate_integer(cls, v: int, values: PostWithObjectBody.Partial) -> int: + for validator in PostWithObjectBody.Validators._integer_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("nested_object", pre=True) + def _pre_validate_nested_object( + cls, v: ObjectWithOptionalField, values: PostWithObjectBody.Partial + ) -> ObjectWithOptionalField: + for validator in PostWithObjectBody.Validators._nested_object_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("nested_object", pre=False) + def _post_validate_nested_object( + cls, v: ObjectWithOptionalField, values: PostWithObjectBody.Partial + ) -> ObjectWithOptionalField: + for validator in PostWithObjectBody.Validators._nested_object_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="forbid", frozen=True + ) # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/inlined_requests/service/service.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/inlined_requests/service/service.py new file mode 100644 index 00000000000..9894c433149 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/inlined_requests/service/service.py @@ -0,0 +1,92 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.abstract_fern_service import AbstractFernService +from .post_with_object_body import PostWithObjectBody +from ...types.resources.object.types.object_with_optional_field import ( + ObjectWithOptionalField, +) +import abc +import fastapi +import inspect +import typing +from ...general_errors.errors.bad_request_body import BadRequestBody +from ....core.exceptions.fern_http_exception import FernHTTPException +import logging +import functools +from ....core.route_args import get_route_args + + +class AbstractInlinedRequestsService(AbstractFernService): + """ + AbstractInlinedRequestsService is an abstract class containing the methods that you should implement. + + Each method is associated with an API route, which will be registered + with FastAPI when you register your implementation using Fern's register() + function. + """ + + @abc.abstractmethod + def post_with_object_bodyand_response( + self, *, body: PostWithObjectBody + ) -> ObjectWithOptionalField: + """ + POST with custom object in request body, response is an object + """ + ... + + """ + Below are internal methods used by Fern to register your implementation. + You can ignore them. + """ + + @classmethod + def _init_fern(cls, router: fastapi.APIRouter) -> None: + cls.__init_post_with_object_bodyand_response(router=router) + + @classmethod + def __init_post_with_object_bodyand_response( + cls, router: fastapi.APIRouter + ) -> None: + endpoint_function = inspect.signature(cls.post_with_object_bodyand_response) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + else: + new_parameters.append(parameter) + setattr( + cls.post_with_object_bodyand_response, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.post_with_object_bodyand_response) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> ObjectWithOptionalField: + try: + return cls.post_with_object_bodyand_response(*args, **kwargs) + except BadRequestBody as e: + raise e + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'post_with_object_bodyand_response' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.post_with_object_bodyand_response.__globals__) + + router.post( + path="/req-bodies/object", + response_model=ObjectWithOptionalField, + description=AbstractInlinedRequestsService.post_with_object_bodyand_response.__doc__, + **get_route_args( + cls.post_with_object_bodyand_response, default_tag="inlined_requests" + ), + )(wrapper) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_auth/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_auth/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_auth/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_auth/service/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_auth/service/__init__.py new file mode 100644 index 00000000000..1c29f9f2a06 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_auth/service/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .service import AbstractNoAuthService + +__all__ = ["AbstractNoAuthService"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_auth/service/service.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_auth/service/service.py new file mode 100644 index 00000000000..4b9c9f48c50 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_auth/service/service.py @@ -0,0 +1,82 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.abstract_fern_service import AbstractFernService +import typing +import abc +import fastapi +import inspect +from ...general_errors.errors.bad_request_body import BadRequestBody +from ....core.exceptions.fern_http_exception import FernHTTPException +import logging +import functools +from ....core.route_args import get_route_args + + +class AbstractNoAuthService(AbstractFernService): + """ + AbstractNoAuthService is an abstract class containing the methods that you should implement. + + Each method is associated with an API route, which will be registered + with FastAPI when you register your implementation using Fern's register() + function. + """ + + @abc.abstractmethod + def post_with_no_auth(self, *, body: typing.Optional[typing.Any] = None) -> bool: + """ + POST request with no auth + """ + ... + + """ + Below are internal methods used by Fern to register your implementation. + You can ignore them. + """ + + @classmethod + def _init_fern(cls, router: fastapi.APIRouter) -> None: + cls.__init_post_with_no_auth(router=router) + + @classmethod + def __init_post_with_no_auth(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.post_with_no_auth) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + else: + new_parameters.append(parameter) + setattr( + cls.post_with_no_auth, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.post_with_no_auth) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> bool: + try: + return cls.post_with_no_auth(*args, **kwargs) + except BadRequestBody as e: + raise e + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'post_with_no_auth' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.post_with_no_auth.__globals__) + + router.post( + path="/no-auth", + response_model=bool, + description=AbstractNoAuthService.post_with_no_auth.__doc__, + **get_route_args(cls.post_with_no_auth, default_tag="no_auth"), + )(wrapper) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_req_body/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_req_body/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_req_body/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_req_body/service/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_req_body/service/__init__.py new file mode 100644 index 00000000000..a0ad1b0152f --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_req_body/service/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .service import AbstractNoReqBodyService + +__all__ = ["AbstractNoReqBodyService"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_req_body/service/service.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_req_body/service/service.py new file mode 100644 index 00000000000..40b96353e2d --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/no_req_body/service/service.py @@ -0,0 +1,130 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.abstract_fern_service import AbstractFernService +from ....security import ApiAuth +from ...types.resources.object.types.object_with_optional_field import ( + ObjectWithOptionalField, +) +import abc +import fastapi +import inspect +import typing +from ....security import FernAuth +from ....core.exceptions.fern_http_exception import FernHTTPException +import logging +import functools +from ....core.route_args import get_route_args + + +class AbstractNoReqBodyService(AbstractFernService): + """ + AbstractNoReqBodyService is an abstract class containing the methods that you should implement. + + Each method is associated with an API route, which will be registered + with FastAPI when you register your implementation using Fern's register() + function. + """ + + @abc.abstractmethod + def get_with_no_request_body(self, *, auth: ApiAuth) -> ObjectWithOptionalField: ... + + @abc.abstractmethod + def post_with_no_request_body(self, *, auth: ApiAuth) -> str: ... + + """ + Below are internal methods used by Fern to register your implementation. + You can ignore them. + """ + + @classmethod + def _init_fern(cls, router: fastapi.APIRouter) -> None: + cls.__init_get_with_no_request_body(router=router) + cls.__init_post_with_no_request_body(router=router) + + @classmethod + def __init_get_with_no_request_body(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_with_no_request_body) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_with_no_request_body, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_with_no_request_body) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> ObjectWithOptionalField: + try: + return cls.get_with_no_request_body(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_with_no_request_body' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_with_no_request_body.__globals__) + + router.get( + path="/no-req-body", + response_model=ObjectWithOptionalField, + description=AbstractNoReqBodyService.get_with_no_request_body.__doc__, + **get_route_args(cls.get_with_no_request_body, default_tag="no_req_body"), + )(wrapper) + + @classmethod + def __init_post_with_no_request_body(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.post_with_no_request_body) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.post_with_no_request_body, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.post_with_no_request_body) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> str: + try: + return cls.post_with_no_request_body(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'post_with_no_request_body' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.post_with_no_request_body.__globals__) + + router.post( + path="/no-req-body", + response_model=str, + description=AbstractNoReqBodyService.post_with_no_request_body.__doc__, + **get_route_args(cls.post_with_no_request_body, default_tag="no_req_body"), + )(wrapper) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/req_with_headers/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/req_with_headers/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/req_with_headers/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/req_with_headers/service/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/req_with_headers/service/__init__.py new file mode 100644 index 00000000000..c5f17c39b40 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/req_with_headers/service/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .service import AbstractReqWithHeadersService + +__all__ = ["AbstractReqWithHeadersService"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/req_with_headers/service/service.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/req_with_headers/service/service.py new file mode 100644 index 00000000000..0bb5ea5b04c --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/req_with_headers/service/service.py @@ -0,0 +1,93 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.abstract_fern_service import AbstractFernService +from ....security import ApiAuth +import abc +import fastapi +import inspect +import typing +from ....security import FernAuth +from ....core.exceptions.fern_http_exception import FernHTTPException +import logging +import functools +import starlette +from ....core.route_args import get_route_args + + +class AbstractReqWithHeadersService(AbstractFernService): + """ + AbstractReqWithHeadersService is an abstract class containing the methods that you should implement. + + Each method is associated with an API route, which will be registered + with FastAPI when you register your implementation using Fern's register() + function. + """ + + @abc.abstractmethod + def get_with_custom_header( + self, *, body: str, x_test_endpoint_header: str, auth: ApiAuth + ) -> None: ... + + """ + Below are internal methods used by Fern to register your implementation. + You can ignore them. + """ + + @classmethod + def _init_fern(cls, router: fastapi.APIRouter) -> None: + cls.__init_get_with_custom_header(router=router) + + @classmethod + def __init_get_with_custom_header(cls, router: fastapi.APIRouter) -> None: + endpoint_function = inspect.signature(cls.get_with_custom_header) + new_parameters: typing.List[inspect.Parameter] = [] + for index, (parameter_name, parameter) in enumerate( + endpoint_function.parameters.items() + ): + if index == 0: + new_parameters.append(parameter.replace(default=fastapi.Depends(cls))) + elif parameter_name == "body": + new_parameters.append(parameter.replace(default=fastapi.Body(...))) + elif parameter_name == "x_test_endpoint_header": + new_parameters.append( + parameter.replace( + default=fastapi.Header(alias="X-TEST-ENDPOINT-HEADER") + ) + ) + elif parameter_name == "auth": + new_parameters.append( + parameter.replace(default=fastapi.Depends(FernAuth)) + ) + else: + new_parameters.append(parameter) + setattr( + cls.get_with_custom_header, + "__signature__", + endpoint_function.replace(parameters=new_parameters), + ) + + @functools.wraps(cls.get_with_custom_header) + def wrapper(*args: typing.Any, **kwargs: typing.Any) -> None: + try: + return cls.get_with_custom_header(*args, **kwargs) + except FernHTTPException as e: + logging.getLogger(f"{cls.__module__}.{cls.__name__}").warn( + f"Endpoint 'get_with_custom_header' unexpectedly threw {e.__class__.__name__}. " + + f"If this was intentional, please add {e.__class__.__name__} to " + + "the endpoint's errors list in your Fern Definition." + ) + raise e + + # this is necessary for FastAPI to find forward-ref'ed type hints. + # https://github.com/tiangolo/fastapi/pull/5077 + wrapper.__globals__.update(cls.get_with_custom_header.__globals__) + + router.post( + path="/test-headers/custom-header", + response_model=None, + status_code=starlette.status.HTTP_204_NO_CONTENT, + description=AbstractReqWithHeadersService.get_with_custom_header.__doc__, + **get_route_args( + cls.get_with_custom_header, default_tag="req_with_headers" + ), + )(wrapper) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/__init__.py new file mode 100644 index 00000000000..a3867a6ebb1 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/__init__.py @@ -0,0 +1,47 @@ +# This file was auto-generated by Fern from our API Definition. + +from .resources import ( + Animal, + Cat, + Dog, + DoubleOptional, + ErrorWithEnumBody, + ErrorWithUnionBody, + NestedObjectWithOptionalField, + NestedObjectWithOptionalFieldError, + NestedObjectWithRequiredField, + NestedObjectWithRequiredFieldError, + ObjectWithMapOfMap, + ObjectWithOptionalField, + ObjectWithOptionalFieldError, + ObjectWithRequiredField, + ObjectWithRequiredFieldError, + OptionalAlias, + WeatherReport, + enum, + object, + union, +) + +__all__ = [ + "Animal", + "Cat", + "Dog", + "DoubleOptional", + "ErrorWithEnumBody", + "ErrorWithUnionBody", + "NestedObjectWithOptionalField", + "NestedObjectWithOptionalFieldError", + "NestedObjectWithRequiredField", + "NestedObjectWithRequiredFieldError", + "ObjectWithMapOfMap", + "ObjectWithOptionalField", + "ObjectWithOptionalFieldError", + "ObjectWithRequiredField", + "ObjectWithRequiredFieldError", + "OptionalAlias", + "WeatherReport", + "enum", + "object", + "union", +] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/__init__.py new file mode 100644 index 00000000000..8d48c2cf24e --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/__init__.py @@ -0,0 +1,41 @@ +# This file was auto-generated by Fern from our API Definition. + +from . import enum, object, union +from .enum import ErrorWithEnumBody, WeatherReport +from .object import ( + DoubleOptional, + NestedObjectWithOptionalField, + NestedObjectWithOptionalFieldError, + NestedObjectWithRequiredField, + NestedObjectWithRequiredFieldError, + ObjectWithMapOfMap, + ObjectWithOptionalField, + ObjectWithOptionalFieldError, + ObjectWithRequiredField, + ObjectWithRequiredFieldError, + OptionalAlias, +) +from .union import Animal, Cat, Dog, ErrorWithUnionBody + +__all__ = [ + "Animal", + "Cat", + "Dog", + "DoubleOptional", + "ErrorWithEnumBody", + "ErrorWithUnionBody", + "NestedObjectWithOptionalField", + "NestedObjectWithOptionalFieldError", + "NestedObjectWithRequiredField", + "NestedObjectWithRequiredFieldError", + "ObjectWithMapOfMap", + "ObjectWithOptionalField", + "ObjectWithOptionalFieldError", + "ObjectWithRequiredField", + "ObjectWithRequiredFieldError", + "OptionalAlias", + "WeatherReport", + "enum", + "object", + "union", +] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/__init__.py new file mode 100644 index 00000000000..3983fd06a84 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/__init__.py @@ -0,0 +1,6 @@ +# This file was auto-generated by Fern from our API Definition. + +from .errors import ErrorWithEnumBody +from .types import WeatherReport + +__all__ = ["ErrorWithEnumBody", "WeatherReport"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/errors/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/errors/__init__.py new file mode 100644 index 00000000000..f5945e36d9d --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/errors/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .error_with_enum_body import ErrorWithEnumBody + +__all__ = ["ErrorWithEnumBody"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/errors/error_with_enum_body.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/errors/error_with_enum_body.py new file mode 100644 index 00000000000..8b8a0d981c3 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/errors/error_with_enum_body.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ......core.exceptions.fern_http_exception import FernHTTPException +from ..types.weather_report import WeatherReport + + +class ErrorWithEnumBody(FernHTTPException): + def __init__(self, error: WeatherReport): + super().__init__(status_code=400, name="ErrorWithEnumBody", content=error) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/types/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/types/__init__.py new file mode 100644 index 00000000000..7a47d1fefc6 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/types/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .weather_report import WeatherReport + +__all__ = ["WeatherReport"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/types/weather_report.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/types/weather_report.py new file mode 100644 index 00000000000..0f2fc3aee2a --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/enum/types/weather_report.py @@ -0,0 +1,29 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class WeatherReport(str, enum.Enum): + SUNNY = "SUNNY" + CLOUDY = "CLOUDY" + RAINING = "RAINING" + SNOWING = "SNOWING" + + def visit( + self, + sunny: typing.Callable[[], T_Result], + cloudy: typing.Callable[[], T_Result], + raining: typing.Callable[[], T_Result], + snowing: typing.Callable[[], T_Result], + ) -> T_Result: + if self is WeatherReport.SUNNY: + return sunny() + if self is WeatherReport.CLOUDY: + return cloudy() + if self is WeatherReport.RAINING: + return raining() + if self is WeatherReport.SNOWING: + return snowing() diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/__init__.py new file mode 100644 index 00000000000..6be602ca8ef --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/__init__.py @@ -0,0 +1,31 @@ +# This file was auto-generated by Fern from our API Definition. + +from .errors import ( + NestedObjectWithOptionalFieldError, + NestedObjectWithRequiredFieldError, + ObjectWithOptionalFieldError, + ObjectWithRequiredFieldError, +) +from .types import ( + DoubleOptional, + NestedObjectWithOptionalField, + NestedObjectWithRequiredField, + ObjectWithMapOfMap, + ObjectWithOptionalField, + ObjectWithRequiredField, + OptionalAlias, +) + +__all__ = [ + "DoubleOptional", + "NestedObjectWithOptionalField", + "NestedObjectWithOptionalFieldError", + "NestedObjectWithRequiredField", + "NestedObjectWithRequiredFieldError", + "ObjectWithMapOfMap", + "ObjectWithOptionalField", + "ObjectWithOptionalFieldError", + "ObjectWithRequiredField", + "ObjectWithRequiredFieldError", + "OptionalAlias", +] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/__init__.py new file mode 100644 index 00000000000..7e7e4c63aa8 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/__init__.py @@ -0,0 +1,13 @@ +# This file was auto-generated by Fern from our API Definition. + +from .nested_object_with_optional_field_error import NestedObjectWithOptionalFieldError +from .nested_object_with_required_field_error import NestedObjectWithRequiredFieldError +from .object_with_optional_field_error import ObjectWithOptionalFieldError +from .object_with_required_field_error import ObjectWithRequiredFieldError + +__all__ = [ + "NestedObjectWithOptionalFieldError", + "NestedObjectWithRequiredFieldError", + "ObjectWithOptionalFieldError", + "ObjectWithRequiredFieldError", +] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/nested_object_with_optional_field_error.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/nested_object_with_optional_field_error.py new file mode 100644 index 00000000000..8ccad4823e1 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/nested_object_with_optional_field_error.py @@ -0,0 +1,11 @@ +# This file was auto-generated by Fern from our API Definition. + +from ......core.exceptions.fern_http_exception import FernHTTPException +from ..types.nested_object_with_optional_field import NestedObjectWithOptionalField + + +class NestedObjectWithOptionalFieldError(FernHTTPException): + def __init__(self, error: NestedObjectWithOptionalField): + super().__init__( + status_code=400, name="NestedObjectWithOptionalFieldError", content=error + ) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/nested_object_with_required_field_error.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/nested_object_with_required_field_error.py new file mode 100644 index 00000000000..d328ecaf35e --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/nested_object_with_required_field_error.py @@ -0,0 +1,11 @@ +# This file was auto-generated by Fern from our API Definition. + +from ......core.exceptions.fern_http_exception import FernHTTPException +from ..types.nested_object_with_required_field import NestedObjectWithRequiredField + + +class NestedObjectWithRequiredFieldError(FernHTTPException): + def __init__(self, error: NestedObjectWithRequiredField): + super().__init__( + status_code=400, name="NestedObjectWithRequiredFieldError", content=error + ) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/object_with_optional_field_error.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/object_with_optional_field_error.py new file mode 100644 index 00000000000..1205d252c69 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/object_with_optional_field_error.py @@ -0,0 +1,11 @@ +# This file was auto-generated by Fern from our API Definition. + +from ......core.exceptions.fern_http_exception import FernHTTPException +from ..types.object_with_optional_field import ObjectWithOptionalField + + +class ObjectWithOptionalFieldError(FernHTTPException): + def __init__(self, error: ObjectWithOptionalField): + super().__init__( + status_code=400, name="ObjectWithOptionalFieldError", content=error + ) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/object_with_required_field_error.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/object_with_required_field_error.py new file mode 100644 index 00000000000..53045a6279e --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/errors/object_with_required_field_error.py @@ -0,0 +1,11 @@ +# This file was auto-generated by Fern from our API Definition. + +from ......core.exceptions.fern_http_exception import FernHTTPException +from ..types.object_with_required_field import ObjectWithRequiredField + + +class ObjectWithRequiredFieldError(FernHTTPException): + def __init__(self, error: ObjectWithRequiredField): + super().__init__( + status_code=400, name="ObjectWithRequiredFieldError", content=error + ) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/__init__.py new file mode 100644 index 00000000000..2620e6eea12 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/__init__.py @@ -0,0 +1,19 @@ +# This file was auto-generated by Fern from our API Definition. + +from .double_optional import DoubleOptional +from .nested_object_with_optional_field import NestedObjectWithOptionalField +from .nested_object_with_required_field import NestedObjectWithRequiredField +from .object_with_map_of_map import ObjectWithMapOfMap +from .object_with_optional_field import ObjectWithOptionalField +from .object_with_required_field import ObjectWithRequiredField +from .optional_alias import OptionalAlias + +__all__ = [ + "DoubleOptional", + "NestedObjectWithOptionalField", + "NestedObjectWithRequiredField", + "ObjectWithMapOfMap", + "ObjectWithOptionalField", + "ObjectWithRequiredField", + "OptionalAlias", +] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/double_optional.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/double_optional.py new file mode 100644 index 00000000000..957a26a6635 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/double_optional.py @@ -0,0 +1,161 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ......core.pydantic_utilities import UniversalBaseModel +import typing +from .optional_alias import OptionalAlias +import pydantic +import typing_extensions +from ......core.pydantic_utilities import universal_field_validator + + +class DoubleOptional(UniversalBaseModel): + optional_alias: typing.Optional[OptionalAlias] = pydantic.Field( + alias="optionalAlias", default=None + ) + + class Partial(typing.TypedDict): + optional_alias: typing_extensions.NotRequired[typing.Optional[OptionalAlias]] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @DoubleOptional.Validators.root() + def validate(values: DoubleOptional.Partial) -> DoubleOptional.Partial: + ... + + @DoubleOptional.Validators.field("optional_alias") + def validate_optional_alias(optional_alias: typing.Optional[OptionalAlias], values: DoubleOptional.Partial) -> typing.Optional[OptionalAlias]: + ... + """ + + _pre_validators: typing.ClassVar[ + typing.List[DoubleOptional.Validators._PreRootValidator] + ] = [] + _post_validators: typing.ClassVar[ + typing.List[DoubleOptional.Validators._RootValidator] + ] = [] + _optional_alias_pre_validators: typing.ClassVar[ + typing.List[DoubleOptional.Validators.PreOptionalAliasValidator] + ] = [] + _optional_alias_post_validators: typing.ClassVar[ + typing.List[DoubleOptional.Validators.OptionalAliasValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [DoubleOptional.Validators._RootValidator], + DoubleOptional.Validators._RootValidator, + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [DoubleOptional.Validators._PreRootValidator], + DoubleOptional.Validators._PreRootValidator, + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["optional_alias"], + *, + pre: typing.Literal[True], + ) -> typing.Callable[ + [DoubleOptional.Validators.PreOptionalAliasValidator], + DoubleOptional.Validators.PreOptionalAliasValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["optional_alias"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [DoubleOptional.Validators.OptionalAliasValidator], + DoubleOptional.Validators.OptionalAliasValidator, + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "optional_alias": + if pre: + cls._optional_alias_pre_validators.append(validator) + else: + cls._optional_alias_post_validators.append(validator) + return validator + + return decorator + + class PreOptionalAliasValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: DoubleOptional.Partial + ) -> typing.Any: ... + + class OptionalAliasValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[OptionalAlias], + __values: DoubleOptional.Partial, + ) -> typing.Optional[OptionalAlias]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__( + self, __values: DoubleOptional.Partial + ) -> DoubleOptional.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_double_optional( + cls, model: DoubleOptional + ) -> DoubleOptional: + for validator in DoubleOptional.Validators._pre_validators: + model = validator(model) + return model + + @pydantic.model_validator(mode="after") + def _post_validate_types_double_optional( + cls, model: DoubleOptional + ) -> DoubleOptional: + for validator in DoubleOptional.Validators._post_validators: + model = validator(model) # type: ignore + return model + + @universal_field_validator("optional_alias", pre=True) + def _pre_validate_optional_alias( + cls, v: typing.Optional[OptionalAlias], values: DoubleOptional.Partial + ) -> typing.Optional[OptionalAlias]: + for validator in DoubleOptional.Validators._optional_alias_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("optional_alias", pre=False) + def _post_validate_optional_alias( + cls, v: typing.Optional[OptionalAlias], values: DoubleOptional.Partial + ) -> typing.Optional[OptionalAlias]: + for validator in DoubleOptional.Validators._optional_alias_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="forbid", frozen=True + ) # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/nested_object_with_optional_field.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/nested_object_with_optional_field.py new file mode 100644 index 00000000000..454d9e0e028 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/nested_object_with_optional_field.py @@ -0,0 +1,241 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ......core.pydantic_utilities import UniversalBaseModel +import typing +from .object_with_optional_field import ObjectWithOptionalField +import pydantic +import typing_extensions +from ......core.pydantic_utilities import universal_field_validator + + +class NestedObjectWithOptionalField(UniversalBaseModel): + string: typing.Optional[str] = None + nested_object: typing.Optional[ObjectWithOptionalField] = pydantic.Field( + alias="NestedObject", default=None + ) + + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[typing.Optional[str]] + nested_object: typing_extensions.NotRequired[ + typing.Optional[ObjectWithOptionalField] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @NestedObjectWithOptionalField.Validators.root() + def validate(values: NestedObjectWithOptionalField.Partial) -> NestedObjectWithOptionalField.Partial: + ... + + @NestedObjectWithOptionalField.Validators.field("string") + def validate_string(string: typing.Optional[str], values: NestedObjectWithOptionalField.Partial) -> typing.Optional[str]: + ... + + @NestedObjectWithOptionalField.Validators.field("nested_object") + def validate_nested_object(nested_object: typing.Optional[ObjectWithOptionalField], values: NestedObjectWithOptionalField.Partial) -> typing.Optional[ObjectWithOptionalField]: + ... + """ + + _pre_validators: typing.ClassVar[ + typing.List[NestedObjectWithOptionalField.Validators._PreRootValidator] + ] = [] + _post_validators: typing.ClassVar[ + typing.List[NestedObjectWithOptionalField.Validators._RootValidator] + ] = [] + _string_pre_validators: typing.ClassVar[ + typing.List[NestedObjectWithOptionalField.Validators.PreStringValidator] + ] = [] + _string_post_validators: typing.ClassVar[ + typing.List[NestedObjectWithOptionalField.Validators.StringValidator] + ] = [] + _nested_object_pre_validators: typing.ClassVar[ + typing.List[ + NestedObjectWithOptionalField.Validators.PreNestedObjectValidator + ] + ] = [] + _nested_object_post_validators: typing.ClassVar[ + typing.List[NestedObjectWithOptionalField.Validators.NestedObjectValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators._RootValidator], + NestedObjectWithOptionalField.Validators._RootValidator, + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators._PreRootValidator], + NestedObjectWithOptionalField.Validators._PreRootValidator, + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators.PreStringValidator], + NestedObjectWithOptionalField.Validators.PreStringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["string"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators.StringValidator], + NestedObjectWithOptionalField.Validators.StringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["nested_object"], + *, + pre: typing.Literal[True], + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators.PreNestedObjectValidator], + NestedObjectWithOptionalField.Validators.PreNestedObjectValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["nested_object"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators.NestedObjectValidator], + NestedObjectWithOptionalField.Validators.NestedObjectValidator, + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "string": + if pre: + cls._string_pre_validators.append(validator) + else: + cls._string_post_validators.append(validator) + if field_name == "nested_object": + if pre: + cls._nested_object_pre_validators.append(validator) + else: + cls._nested_object_post_validators.append(validator) + return validator + + return decorator + + class PreStringValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: NestedObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class StringValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[str], + __values: NestedObjectWithOptionalField.Partial, + ) -> typing.Optional[str]: ... + + class PreNestedObjectValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: NestedObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class NestedObjectValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[ObjectWithOptionalField], + __values: NestedObjectWithOptionalField.Partial, + ) -> typing.Optional[ObjectWithOptionalField]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__( + self, __values: NestedObjectWithOptionalField.Partial + ) -> NestedObjectWithOptionalField.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_nested_object_with_optional_field( + cls, model: NestedObjectWithOptionalField + ) -> NestedObjectWithOptionalField: + for validator in NestedObjectWithOptionalField.Validators._pre_validators: + model = validator(model) + return model + + @pydantic.model_validator(mode="after") + def _post_validate_types_nested_object_with_optional_field( + cls, model: NestedObjectWithOptionalField + ) -> NestedObjectWithOptionalField: + for validator in NestedObjectWithOptionalField.Validators._post_validators: + model = validator(model) # type: ignore + return model + + @universal_field_validator("string", pre=True) + def _pre_validate_string( + cls, v: typing.Optional[str], values: NestedObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for ( + validator + ) in NestedObjectWithOptionalField.Validators._string_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("string", pre=False) + def _post_validate_string( + cls, v: typing.Optional[str], values: NestedObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for ( + validator + ) in NestedObjectWithOptionalField.Validators._string_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("nested_object", pre=True) + def _pre_validate_nested_object( + cls, + v: typing.Optional[ObjectWithOptionalField], + values: NestedObjectWithOptionalField.Partial, + ) -> typing.Optional[ObjectWithOptionalField]: + for ( + validator + ) in NestedObjectWithOptionalField.Validators._nested_object_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("nested_object", pre=False) + def _post_validate_nested_object( + cls, + v: typing.Optional[ObjectWithOptionalField], + values: NestedObjectWithOptionalField.Partial, + ) -> typing.Optional[ObjectWithOptionalField]: + for ( + validator + ) in NestedObjectWithOptionalField.Validators._nested_object_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="forbid", frozen=True + ) # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/nested_object_with_required_field.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/nested_object_with_required_field.py new file mode 100644 index 00000000000..227bc2f2545 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/nested_object_with_required_field.py @@ -0,0 +1,231 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ......core.pydantic_utilities import UniversalBaseModel +from .object_with_optional_field import ObjectWithOptionalField +import pydantic +import typing +import typing_extensions +from ......core.pydantic_utilities import universal_field_validator + + +class NestedObjectWithRequiredField(UniversalBaseModel): + string: str + nested_object: ObjectWithOptionalField = pydantic.Field(alias="NestedObject") + + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[str] + nested_object: typing_extensions.NotRequired[ObjectWithOptionalField] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @NestedObjectWithRequiredField.Validators.root() + def validate(values: NestedObjectWithRequiredField.Partial) -> NestedObjectWithRequiredField.Partial: + ... + + @NestedObjectWithRequiredField.Validators.field("string") + def validate_string(string: str, values: NestedObjectWithRequiredField.Partial) -> str: + ... + + @NestedObjectWithRequiredField.Validators.field("nested_object") + def validate_nested_object(nested_object: ObjectWithOptionalField, values: NestedObjectWithRequiredField.Partial) -> ObjectWithOptionalField: + ... + """ + + _pre_validators: typing.ClassVar[ + typing.List[NestedObjectWithRequiredField.Validators._PreRootValidator] + ] = [] + _post_validators: typing.ClassVar[ + typing.List[NestedObjectWithRequiredField.Validators._RootValidator] + ] = [] + _string_pre_validators: typing.ClassVar[ + typing.List[NestedObjectWithRequiredField.Validators.PreStringValidator] + ] = [] + _string_post_validators: typing.ClassVar[ + typing.List[NestedObjectWithRequiredField.Validators.StringValidator] + ] = [] + _nested_object_pre_validators: typing.ClassVar[ + typing.List[ + NestedObjectWithRequiredField.Validators.PreNestedObjectValidator + ] + ] = [] + _nested_object_post_validators: typing.ClassVar[ + typing.List[NestedObjectWithRequiredField.Validators.NestedObjectValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators._RootValidator], + NestedObjectWithRequiredField.Validators._RootValidator, + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators._PreRootValidator], + NestedObjectWithRequiredField.Validators._PreRootValidator, + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators.PreStringValidator], + NestedObjectWithRequiredField.Validators.PreStringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["string"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators.StringValidator], + NestedObjectWithRequiredField.Validators.StringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["nested_object"], + *, + pre: typing.Literal[True], + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators.PreNestedObjectValidator], + NestedObjectWithRequiredField.Validators.PreNestedObjectValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["nested_object"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators.NestedObjectValidator], + NestedObjectWithRequiredField.Validators.NestedObjectValidator, + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "string": + if pre: + cls._string_pre_validators.append(validator) + else: + cls._string_post_validators.append(validator) + if field_name == "nested_object": + if pre: + cls._nested_object_pre_validators.append(validator) + else: + cls._nested_object_post_validators.append(validator) + return validator + + return decorator + + class PreStringValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: NestedObjectWithRequiredField.Partial + ) -> typing.Any: ... + + class StringValidator(typing.Protocol): + def __call__( + self, __v: str, __values: NestedObjectWithRequiredField.Partial + ) -> str: ... + + class PreNestedObjectValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: NestedObjectWithRequiredField.Partial + ) -> typing.Any: ... + + class NestedObjectValidator(typing.Protocol): + def __call__( + self, + __v: ObjectWithOptionalField, + __values: NestedObjectWithRequiredField.Partial, + ) -> ObjectWithOptionalField: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__( + self, __values: NestedObjectWithRequiredField.Partial + ) -> NestedObjectWithRequiredField.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_nested_object_with_required_field( + cls, model: NestedObjectWithRequiredField + ) -> NestedObjectWithRequiredField: + for validator in NestedObjectWithRequiredField.Validators._pre_validators: + model = validator(model) + return model + + @pydantic.model_validator(mode="after") + def _post_validate_types_nested_object_with_required_field( + cls, model: NestedObjectWithRequiredField + ) -> NestedObjectWithRequiredField: + for validator in NestedObjectWithRequiredField.Validators._post_validators: + model = validator(model) # type: ignore + return model + + @universal_field_validator("string", pre=True) + def _pre_validate_string( + cls, v: str, values: NestedObjectWithRequiredField.Partial + ) -> str: + for ( + validator + ) in NestedObjectWithRequiredField.Validators._string_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("string", pre=False) + def _post_validate_string( + cls, v: str, values: NestedObjectWithRequiredField.Partial + ) -> str: + for ( + validator + ) in NestedObjectWithRequiredField.Validators._string_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("nested_object", pre=True) + def _pre_validate_nested_object( + cls, v: ObjectWithOptionalField, values: NestedObjectWithRequiredField.Partial + ) -> ObjectWithOptionalField: + for ( + validator + ) in NestedObjectWithRequiredField.Validators._nested_object_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("nested_object", pre=False) + def _post_validate_nested_object( + cls, v: ObjectWithOptionalField, values: NestedObjectWithRequiredField.Partial + ) -> ObjectWithOptionalField: + for ( + validator + ) in NestedObjectWithRequiredField.Validators._nested_object_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="forbid", frozen=True + ) # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/object_with_map_of_map.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/object_with_map_of_map.py new file mode 100644 index 00000000000..1807ac7eb05 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/object_with_map_of_map.py @@ -0,0 +1,159 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ......core.pydantic_utilities import UniversalBaseModel +import typing +import pydantic +import typing_extensions +from ......core.pydantic_utilities import universal_field_validator + + +class ObjectWithMapOfMap(UniversalBaseModel): + map_: typing.Dict[str, typing.Dict[str, str]] = pydantic.Field(alias="map") + + class Partial(typing.TypedDict): + map_: typing_extensions.NotRequired[typing.Dict[str, typing.Dict[str, str]]] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @ObjectWithMapOfMap.Validators.root() + def validate(values: ObjectWithMapOfMap.Partial) -> ObjectWithMapOfMap.Partial: + ... + + @ObjectWithMapOfMap.Validators.field("map_") + def validate_map_(map_: typing.Dict[str, typing.Dict[str, str]], values: ObjectWithMapOfMap.Partial) -> typing.Dict[str, typing.Dict[str, str]]: + ... + """ + + _pre_validators: typing.ClassVar[ + typing.List[ObjectWithMapOfMap.Validators._PreRootValidator] + ] = [] + _post_validators: typing.ClassVar[ + typing.List[ObjectWithMapOfMap.Validators._RootValidator] + ] = [] + _map__pre_validators: typing.ClassVar[ + typing.List[ObjectWithMapOfMap.Validators.PreMapValidator] + ] = [] + _map__post_validators: typing.ClassVar[ + typing.List[ObjectWithMapOfMap.Validators.MapValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithMapOfMap.Validators._RootValidator], + ObjectWithMapOfMap.Validators._RootValidator, + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithMapOfMap.Validators._PreRootValidator], + ObjectWithMapOfMap.Validators._PreRootValidator, + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["map_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithMapOfMap.Validators.PreMapValidator], + ObjectWithMapOfMap.Validators.PreMapValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["map_"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithMapOfMap.Validators.MapValidator], + ObjectWithMapOfMap.Validators.MapValidator, + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "map_": + if pre: + cls._map__pre_validators.append(validator) + else: + cls._map__post_validators.append(validator) + return validator + + return decorator + + class PreMapValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithMapOfMap.Partial + ) -> typing.Any: ... + + class MapValidator(typing.Protocol): + def __call__( + self, + __v: typing.Dict[str, typing.Dict[str, str]], + __values: ObjectWithMapOfMap.Partial, + ) -> typing.Dict[str, typing.Dict[str, str]]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__( + self, __values: ObjectWithMapOfMap.Partial + ) -> ObjectWithMapOfMap.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_object_with_map_of_map( + cls, model: ObjectWithMapOfMap + ) -> ObjectWithMapOfMap: + for validator in ObjectWithMapOfMap.Validators._pre_validators: + model = validator(model) + return model + + @pydantic.model_validator(mode="after") + def _post_validate_types_object_with_map_of_map( + cls, model: ObjectWithMapOfMap + ) -> ObjectWithMapOfMap: + for validator in ObjectWithMapOfMap.Validators._post_validators: + model = validator(model) # type: ignore + return model + + @universal_field_validator("map_", pre=True) + def _pre_validate_map_( + cls, + v: typing.Dict[str, typing.Dict[str, str]], + values: ObjectWithMapOfMap.Partial, + ) -> typing.Dict[str, typing.Dict[str, str]]: + for validator in ObjectWithMapOfMap.Validators._map__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("map_", pre=False) + def _post_validate_map_( + cls, + v: typing.Dict[str, typing.Dict[str, str]], + values: ObjectWithMapOfMap.Partial, + ) -> typing.Dict[str, typing.Dict[str, str]]: + for validator in ObjectWithMapOfMap.Validators._map__post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="forbid", frozen=True + ) # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/object_with_optional_field.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/object_with_optional_field.py new file mode 100644 index 00000000000..48782421fbe --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/object_with_optional_field.py @@ -0,0 +1,945 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ......core.pydantic_utilities import UniversalBaseModel +import typing +import pydantic +import datetime as dt +import uuid +import typing_extensions +from ......core.pydantic_utilities import universal_field_validator + + +class ObjectWithOptionalField(UniversalBaseModel): + string: typing.Optional[str] = pydantic.Field(default=None) + """ + This is a rather long descriptor of this single field in a more complex type. If you ask me I think this is a pretty good description for this field all things considered. + """ + + integer: typing.Optional[int] = None + long_: typing.Optional[int] = pydantic.Field(alias="long", default=None) + double: typing.Optional[float] = None + bool_: typing.Optional[bool] = pydantic.Field(alias="bool", default=None) + datetime: typing.Optional[dt.datetime] = None + date: typing.Optional[dt.date] = None + uuid_: typing.Optional[uuid.UUID] = pydantic.Field(alias="uuid", default=None) + base_64: typing.Optional[str] = pydantic.Field(alias="base64", default=None) + list_: typing.Optional[typing.List[str]] = pydantic.Field( + alias="list", default=None + ) + set_: typing.Optional[typing.Set[str]] = pydantic.Field(alias="set", default=None) + map_: typing.Optional[typing.Dict[int, str]] = pydantic.Field( + alias="map", default=None + ) + bigint: typing.Optional[str] = None + + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[typing.Optional[str]] + integer: typing_extensions.NotRequired[typing.Optional[int]] + long_: typing_extensions.NotRequired[typing.Optional[int]] + double: typing_extensions.NotRequired[typing.Optional[float]] + bool_: typing_extensions.NotRequired[typing.Optional[bool]] + datetime: typing_extensions.NotRequired[typing.Optional[dt.datetime]] + date: typing_extensions.NotRequired[typing.Optional[dt.date]] + uuid_: typing_extensions.NotRequired[typing.Optional[uuid.UUID]] + base_64: typing_extensions.NotRequired[typing.Optional[str]] + list_: typing_extensions.NotRequired[typing.Optional[typing.List[str]]] + set_: typing_extensions.NotRequired[typing.Optional[typing.Set[str]]] + map_: typing_extensions.NotRequired[typing.Optional[typing.Dict[int, str]]] + bigint: typing_extensions.NotRequired[typing.Optional[str]] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @ObjectWithOptionalField.Validators.root() + def validate(values: ObjectWithOptionalField.Partial) -> ObjectWithOptionalField.Partial: + ... + + @ObjectWithOptionalField.Validators.field("string") + def validate_string(string: typing.Optional[str], values: ObjectWithOptionalField.Partial) -> typing.Optional[str]: + ... + + @ObjectWithOptionalField.Validators.field("integer") + def validate_integer(integer: typing.Optional[int], values: ObjectWithOptionalField.Partial) -> typing.Optional[int]: + ... + + @ObjectWithOptionalField.Validators.field("long_") + def validate_long_(long_: typing.Optional[int], values: ObjectWithOptionalField.Partial) -> typing.Optional[int]: + ... + + @ObjectWithOptionalField.Validators.field("double") + def validate_double(double: typing.Optional[float], values: ObjectWithOptionalField.Partial) -> typing.Optional[float]: + ... + + @ObjectWithOptionalField.Validators.field("bool_") + def validate_bool_(bool_: typing.Optional[bool], values: ObjectWithOptionalField.Partial) -> typing.Optional[bool]: + ... + + @ObjectWithOptionalField.Validators.field("datetime") + def validate_datetime(datetime: typing.Optional[dt.datetime], values: ObjectWithOptionalField.Partial) -> typing.Optional[dt.datetime]: + ... + + @ObjectWithOptionalField.Validators.field("date") + def validate_date(date: typing.Optional[dt.date], values: ObjectWithOptionalField.Partial) -> typing.Optional[dt.date]: + ... + + @ObjectWithOptionalField.Validators.field("uuid_") + def validate_uuid_(uuid_: typing.Optional[uuid.UUID], values: ObjectWithOptionalField.Partial) -> typing.Optional[uuid.UUID]: + ... + + @ObjectWithOptionalField.Validators.field("base_64") + def validate_base_64(base_64: typing.Optional[str], values: ObjectWithOptionalField.Partial) -> typing.Optional[str]: + ... + + @ObjectWithOptionalField.Validators.field("list_") + def validate_list_(list_: typing.Optional[typing.List[str]], values: ObjectWithOptionalField.Partial) -> typing.Optional[typing.List[str]]: + ... + + @ObjectWithOptionalField.Validators.field("set_") + def validate_set_(set_: typing.Optional[typing.Set[str]], values: ObjectWithOptionalField.Partial) -> typing.Optional[typing.Set[str]]: + ... + + @ObjectWithOptionalField.Validators.field("map_") + def validate_map_(map_: typing.Optional[typing.Dict[int, str]], values: ObjectWithOptionalField.Partial) -> typing.Optional[typing.Dict[int, str]]: + ... + + @ObjectWithOptionalField.Validators.field("bigint") + def validate_bigint(bigint: typing.Optional[str], values: ObjectWithOptionalField.Partial) -> typing.Optional[str]: + ... + """ + + _pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators._PreRootValidator] + ] = [] + _post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators._RootValidator] + ] = [] + _string_pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreStringValidator] + ] = [] + _string_post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.StringValidator] + ] = [] + _integer_pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreIntegerValidator] + ] = [] + _integer_post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.IntegerValidator] + ] = [] + _long__pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreLongValidator] + ] = [] + _long__post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.LongValidator] + ] = [] + _double_pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreDoubleValidator] + ] = [] + _double_post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.DoubleValidator] + ] = [] + _bool__pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreBoolValidator] + ] = [] + _bool__post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.BoolValidator] + ] = [] + _datetime_pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreDatetimeValidator] + ] = [] + _datetime_post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.DatetimeValidator] + ] = [] + _date_pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreDateValidator] + ] = [] + _date_post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.DateValidator] + ] = [] + _uuid__pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreUuidValidator] + ] = [] + _uuid__post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.UuidValidator] + ] = [] + _base_64_pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreBase64Validator] + ] = [] + _base_64_post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.Base64Validator] + ] = [] + _list__pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreListValidator] + ] = [] + _list__post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.ListValidator] + ] = [] + _set__pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreSetValidator] + ] = [] + _set__post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.SetValidator] + ] = [] + _map__pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreMapValidator] + ] = [] + _map__post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.MapValidator] + ] = [] + _bigint_pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreBigintValidator] + ] = [] + _bigint_post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.BigintValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators._RootValidator], + ObjectWithOptionalField.Validators._RootValidator, + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators._PreRootValidator], + ObjectWithOptionalField.Validators._PreRootValidator, + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreStringValidator], + ObjectWithOptionalField.Validators.PreStringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["string"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.StringValidator], + ObjectWithOptionalField.Validators.StringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["integer"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreIntegerValidator], + ObjectWithOptionalField.Validators.PreIntegerValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["integer"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.IntegerValidator], + ObjectWithOptionalField.Validators.IntegerValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["long_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreLongValidator], + ObjectWithOptionalField.Validators.PreLongValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["long_"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.LongValidator], + ObjectWithOptionalField.Validators.LongValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["double"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreDoubleValidator], + ObjectWithOptionalField.Validators.PreDoubleValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["double"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.DoubleValidator], + ObjectWithOptionalField.Validators.DoubleValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["bool_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreBoolValidator], + ObjectWithOptionalField.Validators.PreBoolValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["bool_"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.BoolValidator], + ObjectWithOptionalField.Validators.BoolValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["datetime"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreDatetimeValidator], + ObjectWithOptionalField.Validators.PreDatetimeValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["datetime"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.DatetimeValidator], + ObjectWithOptionalField.Validators.DatetimeValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["date"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreDateValidator], + ObjectWithOptionalField.Validators.PreDateValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["date"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.DateValidator], + ObjectWithOptionalField.Validators.DateValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["uuid_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreUuidValidator], + ObjectWithOptionalField.Validators.PreUuidValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["uuid_"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.UuidValidator], + ObjectWithOptionalField.Validators.UuidValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["base_64"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreBase64Validator], + ObjectWithOptionalField.Validators.PreBase64Validator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["base_64"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.Base64Validator], + ObjectWithOptionalField.Validators.Base64Validator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["list_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreListValidator], + ObjectWithOptionalField.Validators.PreListValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["list_"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.ListValidator], + ObjectWithOptionalField.Validators.ListValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["set_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreSetValidator], + ObjectWithOptionalField.Validators.PreSetValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["set_"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.SetValidator], + ObjectWithOptionalField.Validators.SetValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["map_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreMapValidator], + ObjectWithOptionalField.Validators.PreMapValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["map_"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.MapValidator], + ObjectWithOptionalField.Validators.MapValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["bigint"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreBigintValidator], + ObjectWithOptionalField.Validators.PreBigintValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["bigint"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.BigintValidator], + ObjectWithOptionalField.Validators.BigintValidator, + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "string": + if pre: + cls._string_pre_validators.append(validator) + else: + cls._string_post_validators.append(validator) + if field_name == "integer": + if pre: + cls._integer_pre_validators.append(validator) + else: + cls._integer_post_validators.append(validator) + if field_name == "long_": + if pre: + cls._long__pre_validators.append(validator) + else: + cls._long__post_validators.append(validator) + if field_name == "double": + if pre: + cls._double_pre_validators.append(validator) + else: + cls._double_post_validators.append(validator) + if field_name == "bool_": + if pre: + cls._bool__pre_validators.append(validator) + else: + cls._bool__post_validators.append(validator) + if field_name == "datetime": + if pre: + cls._datetime_pre_validators.append(validator) + else: + cls._datetime_post_validators.append(validator) + if field_name == "date": + if pre: + cls._date_pre_validators.append(validator) + else: + cls._date_post_validators.append(validator) + if field_name == "uuid_": + if pre: + cls._uuid__pre_validators.append(validator) + else: + cls._uuid__post_validators.append(validator) + if field_name == "base_64": + if pre: + cls._base_64_pre_validators.append(validator) + else: + cls._base_64_post_validators.append(validator) + if field_name == "list_": + if pre: + cls._list__pre_validators.append(validator) + else: + cls._list__post_validators.append(validator) + if field_name == "set_": + if pre: + cls._set__pre_validators.append(validator) + else: + cls._set__post_validators.append(validator) + if field_name == "map_": + if pre: + cls._map__pre_validators.append(validator) + else: + cls._map__post_validators.append(validator) + if field_name == "bigint": + if pre: + cls._bigint_pre_validators.append(validator) + else: + cls._bigint_post_validators.append(validator) + return validator + + return decorator + + class PreStringValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class StringValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[str], + __values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[str]: ... + + class PreIntegerValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class IntegerValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[int], + __values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[int]: ... + + class PreLongValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class LongValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[int], + __values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[int]: ... + + class PreDoubleValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class DoubleValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[float], + __values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[float]: ... + + class PreBoolValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class BoolValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[bool], + __values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[bool]: ... + + class PreDatetimeValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class DatetimeValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[dt.datetime], + __values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[dt.datetime]: ... + + class PreDateValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class DateValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[dt.date], + __values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[dt.date]: ... + + class PreUuidValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class UuidValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[uuid.UUID], + __values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[uuid.UUID]: ... + + class PreBase64Validator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class Base64Validator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[str], + __values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[str]: ... + + class PreListValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class ListValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[typing.List[str]], + __values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[typing.List[str]]: ... + + class PreSetValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class SetValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[typing.Set[str]], + __values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[typing.Set[str]]: ... + + class PreMapValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class MapValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[typing.Dict[int, str]], + __values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[typing.Dict[int, str]]: ... + + class PreBigintValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithOptionalField.Partial + ) -> typing.Any: ... + + class BigintValidator(typing.Protocol): + def __call__( + self, + __v: typing.Optional[str], + __values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[str]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__( + self, __values: ObjectWithOptionalField.Partial + ) -> ObjectWithOptionalField.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_object_with_optional_field( + cls, model: ObjectWithOptionalField + ) -> ObjectWithOptionalField: + for validator in ObjectWithOptionalField.Validators._pre_validators: + model = validator(model) + return model + + @pydantic.model_validator(mode="after") + def _post_validate_types_object_with_optional_field( + cls, model: ObjectWithOptionalField + ) -> ObjectWithOptionalField: + for validator in ObjectWithOptionalField.Validators._post_validators: + model = validator(model) # type: ignore + return model + + @universal_field_validator("string", pre=True) + def _pre_validate_string( + cls, v: typing.Optional[str], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in ObjectWithOptionalField.Validators._string_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("string", pre=False) + def _post_validate_string( + cls, v: typing.Optional[str], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in ObjectWithOptionalField.Validators._string_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("integer", pre=True) + def _pre_validate_integer( + cls, v: typing.Optional[int], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[int]: + for validator in ObjectWithOptionalField.Validators._integer_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("integer", pre=False) + def _post_validate_integer( + cls, v: typing.Optional[int], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[int]: + for validator in ObjectWithOptionalField.Validators._integer_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("long_", pre=True) + def _pre_validate_long_( + cls, v: typing.Optional[int], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[int]: + for validator in ObjectWithOptionalField.Validators._long__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("long_", pre=False) + def _post_validate_long_( + cls, v: typing.Optional[int], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[int]: + for validator in ObjectWithOptionalField.Validators._long__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("double", pre=True) + def _pre_validate_double( + cls, v: typing.Optional[float], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[float]: + for validator in ObjectWithOptionalField.Validators._double_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("double", pre=False) + def _post_validate_double( + cls, v: typing.Optional[float], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[float]: + for validator in ObjectWithOptionalField.Validators._double_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("bool_", pre=True) + def _pre_validate_bool_( + cls, v: typing.Optional[bool], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[bool]: + for validator in ObjectWithOptionalField.Validators._bool__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("bool_", pre=False) + def _post_validate_bool_( + cls, v: typing.Optional[bool], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[bool]: + for validator in ObjectWithOptionalField.Validators._bool__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("datetime", pre=True) + def _pre_validate_datetime( + cls, v: typing.Optional[dt.datetime], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.datetime]: + for validator in ObjectWithOptionalField.Validators._datetime_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("datetime", pre=False) + def _post_validate_datetime( + cls, v: typing.Optional[dt.datetime], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.datetime]: + for validator in ObjectWithOptionalField.Validators._datetime_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("date", pre=True) + def _pre_validate_date( + cls, v: typing.Optional[dt.date], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.date]: + for validator in ObjectWithOptionalField.Validators._date_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("date", pre=False) + def _post_validate_date( + cls, v: typing.Optional[dt.date], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.date]: + for validator in ObjectWithOptionalField.Validators._date_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("uuid_", pre=True) + def _pre_validate_uuid_( + cls, v: typing.Optional[uuid.UUID], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[uuid.UUID]: + for validator in ObjectWithOptionalField.Validators._uuid__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("uuid_", pre=False) + def _post_validate_uuid_( + cls, v: typing.Optional[uuid.UUID], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[uuid.UUID]: + for validator in ObjectWithOptionalField.Validators._uuid__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("base_64", pre=True) + def _pre_validate_base_64( + cls, v: typing.Optional[str], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in ObjectWithOptionalField.Validators._base_64_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("base_64", pre=False) + def _post_validate_base_64( + cls, v: typing.Optional[str], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in ObjectWithOptionalField.Validators._base_64_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("list_", pre=True) + def _pre_validate_list_( + cls, + v: typing.Optional[typing.List[str]], + values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[typing.List[str]]: + for validator in ObjectWithOptionalField.Validators._list__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("list_", pre=False) + def _post_validate_list_( + cls, + v: typing.Optional[typing.List[str]], + values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[typing.List[str]]: + for validator in ObjectWithOptionalField.Validators._list__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("set_", pre=True) + def _pre_validate_set_( + cls, + v: typing.Optional[typing.Set[str]], + values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[typing.Set[str]]: + for validator in ObjectWithOptionalField.Validators._set__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("set_", pre=False) + def _post_validate_set_( + cls, + v: typing.Optional[typing.Set[str]], + values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[typing.Set[str]]: + for validator in ObjectWithOptionalField.Validators._set__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("map_", pre=True) + def _pre_validate_map_( + cls, + v: typing.Optional[typing.Dict[int, str]], + values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[typing.Dict[int, str]]: + for validator in ObjectWithOptionalField.Validators._map__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("map_", pre=False) + def _post_validate_map_( + cls, + v: typing.Optional[typing.Dict[int, str]], + values: ObjectWithOptionalField.Partial, + ) -> typing.Optional[typing.Dict[int, str]]: + for validator in ObjectWithOptionalField.Validators._map__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("bigint", pre=True) + def _pre_validate_bigint( + cls, v: typing.Optional[str], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in ObjectWithOptionalField.Validators._bigint_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("bigint", pre=False) + def _post_validate_bigint( + cls, v: typing.Optional[str], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in ObjectWithOptionalField.Validators._bigint_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="forbid", frozen=True + ) # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/object_with_required_field.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/object_with_required_field.py new file mode 100644 index 00000000000..e368b342850 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/object_with_required_field.py @@ -0,0 +1,153 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ......core.pydantic_utilities import UniversalBaseModel +import typing +import typing_extensions +import pydantic +from ......core.pydantic_utilities import universal_field_validator + + +class ObjectWithRequiredField(UniversalBaseModel): + string: str + + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[str] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @ObjectWithRequiredField.Validators.root() + def validate(values: ObjectWithRequiredField.Partial) -> ObjectWithRequiredField.Partial: + ... + + @ObjectWithRequiredField.Validators.field("string") + def validate_string(string: str, values: ObjectWithRequiredField.Partial) -> str: + ... + """ + + _pre_validators: typing.ClassVar[ + typing.List[ObjectWithRequiredField.Validators._PreRootValidator] + ] = [] + _post_validators: typing.ClassVar[ + typing.List[ObjectWithRequiredField.Validators._RootValidator] + ] = [] + _string_pre_validators: typing.ClassVar[ + typing.List[ObjectWithRequiredField.Validators.PreStringValidator] + ] = [] + _string_post_validators: typing.ClassVar[ + typing.List[ObjectWithRequiredField.Validators.StringValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithRequiredField.Validators._RootValidator], + ObjectWithRequiredField.Validators._RootValidator, + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithRequiredField.Validators._PreRootValidator], + ObjectWithRequiredField.Validators._PreRootValidator, + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithRequiredField.Validators.PreStringValidator], + ObjectWithRequiredField.Validators.PreStringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["string"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [ObjectWithRequiredField.Validators.StringValidator], + ObjectWithRequiredField.Validators.StringValidator, + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "string": + if pre: + cls._string_pre_validators.append(validator) + else: + cls._string_post_validators.append(validator) + return validator + + return decorator + + class PreStringValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: ObjectWithRequiredField.Partial + ) -> typing.Any: ... + + class StringValidator(typing.Protocol): + def __call__( + self, __v: str, __values: ObjectWithRequiredField.Partial + ) -> str: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__( + self, __values: ObjectWithRequiredField.Partial + ) -> ObjectWithRequiredField.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_object_with_required_field( + cls, model: ObjectWithRequiredField + ) -> ObjectWithRequiredField: + for validator in ObjectWithRequiredField.Validators._pre_validators: + model = validator(model) + return model + + @pydantic.model_validator(mode="after") + def _post_validate_types_object_with_required_field( + cls, model: ObjectWithRequiredField + ) -> ObjectWithRequiredField: + for validator in ObjectWithRequiredField.Validators._post_validators: + model = validator(model) # type: ignore + return model + + @universal_field_validator("string", pre=True) + def _pre_validate_string( + cls, v: str, values: ObjectWithRequiredField.Partial + ) -> str: + for validator in ObjectWithRequiredField.Validators._string_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("string", pre=False) + def _post_validate_string( + cls, v: str, values: ObjectWithRequiredField.Partial + ) -> str: + for validator in ObjectWithRequiredField.Validators._string_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="forbid", frozen=True + ) # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/optional_alias.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/optional_alias.py new file mode 100644 index 00000000000..b75c54ca8b4 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/object/types/optional_alias.py @@ -0,0 +1,47 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +import pydantic +import typing + + +class OptionalAlias(pydantic.RootModel[typing.Optional[str]]): + root: typing.Optional[str] + + def get_as_str(self) -> typing.Optional[str]: + return self.root + + @staticmethod + def from_str(value: typing.Optional[str]) -> OptionalAlias: + return OptionalAlias(root=value) + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @OptionalAlias.Validators.validate + def validate(value: typing.Optional[str]) -> typing.Optional[str]: + ... + """ + + _validators: typing.ClassVar[ + typing.List[typing.Callable[[typing.Optional[str]], typing.Optional[str]]] + ] = [] + + @classmethod + def validate( + cls, + validator: typing.Callable[[typing.Optional[str]], typing.Optional[str]], + ) -> None: + cls._validators.append(validator) + + @pydantic.model_validator(mode="after") + def _validate(cls, model: OptionalAlias) -> OptionalAlias: + value = model.root + for validator in OptionalAlias.Validators._validators: + value = validator(value) + return model + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + frozen=True + ) # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/__init__.py new file mode 100644 index 00000000000..8033ac545f0 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/__init__.py @@ -0,0 +1,6 @@ +# This file was auto-generated by Fern from our API Definition. + +from .errors import ErrorWithUnionBody +from .types import Animal, Cat, Dog + +__all__ = ["Animal", "Cat", "Dog", "ErrorWithUnionBody"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/errors/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/errors/__init__.py new file mode 100644 index 00000000000..568a71fa3c4 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/errors/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .error_with_union_body import ErrorWithUnionBody + +__all__ = ["ErrorWithUnionBody"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/errors/error_with_union_body.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/errors/error_with_union_body.py new file mode 100644 index 00000000000..d4343a0aea5 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/errors/error_with_union_body.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ......core.exceptions.fern_http_exception import FernHTTPException +from ..types.animal import Animal + + +class ErrorWithUnionBody(FernHTTPException): + def __init__(self, error: Animal): + super().__init__(status_code=400, name="ErrorWithUnionBody", content=error) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/types/__init__.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/types/__init__.py new file mode 100644 index 00000000000..e8c68486eda --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/types/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +from .animal import Animal +from .cat import Cat +from .dog import Dog + +__all__ = ["Animal", "Cat", "Dog"] diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/types/animal.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/types/animal.py new file mode 100644 index 00000000000..03ad683b47d --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/types/animal.py @@ -0,0 +1,137 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from .dog import Dog as resources_types_resources_union_types_dog_Dog +from .cat import Cat as resources_types_resources_union_types_cat_Cat +import pydantic +import typing +import typing_extensions +from ......core.pydantic_utilities import update_forward_refs + +T_Result = typing.TypeVar("T_Result") + + +class _Factory: + def dog(self, value: resources_types_resources_union_types_dog_Dog) -> Animal: + return Animal(root=_Animal.Dog(**value.dict(exclude_unset=True), animal="dog")) # type: ignore + + def cat(self, value: resources_types_resources_union_types_cat_Cat) -> Animal: + return Animal(root=_Animal.Cat(**value.dict(exclude_unset=True), animal="cat")) # type: ignore + + +class Animal(pydantic.RootModel): + factory: typing.ClassVar[_Factory] = _Factory() + + root: typing_extensions.Annotated[ + typing.Union[_Animal.Dog, _Animal.Cat], pydantic.Field(discriminator="animal") + ] + + def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: + return self.root + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + return self.root.dict(**kwargs) + + def visit( + self, + dog: typing.Callable[[resources_types_resources_union_types_dog_Dog], T_Result], + cat: typing.Callable[[resources_types_resources_union_types_cat_Cat], T_Result], + ) -> T_Result: + unioned_value = self.get_as_union() + if unioned_value.animal == "dog": + return dog( + resources_types_resources_union_types_dog_Dog( + **unioned_value.dict(exclude_unset=True, exclude={"animal"}) + ) + ) + if unioned_value.animal == "cat": + return cat( + resources_types_resources_union_types_cat_Cat( + **unioned_value.dict(exclude_unset=True, exclude={"animal"}) + ) + ) + + class Partial(typing.TypedDict): + pass + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @Animal.Validators.root() + def validate(values: Animal.Partial) -> Animal.Partial: + ... + """ + + _pre_validators: typing.ClassVar[ + typing.List[Animal.Validators._PreRootValidator] + ] = [] + _post_validators: typing.ClassVar[ + typing.List[Animal.Validators._RootValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [Animal.Validators._RootValidator], Animal.Validators._RootValidator + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [Animal.Validators._PreRootValidator], Animal.Validators._PreRootValidator + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: Animal.Partial) -> Animal.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_animal(cls, model: Animal) -> Animal: + for validator in Animal.Validators._pre_validators: + model = validator(model) + return model + + @pydantic.model_validator(mode="after") + def _post_validate_types_animal(cls, model: Animal) -> Animal: + for validator in Animal.Validators._post_validators: + model = validator(model) # type: ignore + return model + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + frozen=True + ) # type: ignore # Pydantic v2 + + +class _Animal: + class Dog(resources_types_resources_union_types_dog_Dog): + animal: typing.Literal["dog"] = "dog" + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + frozen=True + ) # type: ignore # Pydantic v2 + + class Cat(resources_types_resources_union_types_cat_Cat): + animal: typing.Literal["cat"] = "cat" + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + frozen=True + ) # type: ignore # Pydantic v2 + + +update_forward_refs(Animal) diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/types/cat.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/types/cat.py new file mode 100644 index 00000000000..0d0753963c4 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/types/cat.py @@ -0,0 +1,195 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ......core.pydantic_utilities import UniversalBaseModel +import pydantic +import typing +import typing_extensions +from ......core.pydantic_utilities import universal_field_validator + + +class Cat(UniversalBaseModel): + name: str + likes_to_meow: bool = pydantic.Field(alias="likesToMeow") + + class Partial(typing.TypedDict): + name: typing_extensions.NotRequired[str] + likes_to_meow: typing_extensions.NotRequired[bool] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @Cat.Validators.root() + def validate(values: Cat.Partial) -> Cat.Partial: + ... + + @Cat.Validators.field("name") + def validate_name(name: str, values: Cat.Partial) -> str: + ... + + @Cat.Validators.field("likes_to_meow") + def validate_likes_to_meow(likes_to_meow: bool, values: Cat.Partial) -> bool: + ... + """ + + _pre_validators: typing.ClassVar[ + typing.List[Cat.Validators._PreRootValidator] + ] = [] + _post_validators: typing.ClassVar[ + typing.List[Cat.Validators._RootValidator] + ] = [] + _name_pre_validators: typing.ClassVar[ + typing.List[Cat.Validators.PreNameValidator] + ] = [] + _name_post_validators: typing.ClassVar[ + typing.List[Cat.Validators.NameValidator] + ] = [] + _likes_to_meow_pre_validators: typing.ClassVar[ + typing.List[Cat.Validators.PreLikesToMeowValidator] + ] = [] + _likes_to_meow_post_validators: typing.ClassVar[ + typing.List[Cat.Validators.LikesToMeowValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [Cat.Validators._RootValidator], Cat.Validators._RootValidator + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [Cat.Validators._PreRootValidator], Cat.Validators._PreRootValidator + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [Cat.Validators.PreNameValidator], Cat.Validators.PreNameValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["name"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [Cat.Validators.NameValidator], Cat.Validators.NameValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["likes_to_meow"], + *, + pre: typing.Literal[True], + ) -> typing.Callable[ + [Cat.Validators.PreLikesToMeowValidator], + Cat.Validators.PreLikesToMeowValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["likes_to_meow"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [Cat.Validators.LikesToMeowValidator], Cat.Validators.LikesToMeowValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "name": + if pre: + cls._name_pre_validators.append(validator) + else: + cls._name_post_validators.append(validator) + if field_name == "likes_to_meow": + if pre: + cls._likes_to_meow_pre_validators.append(validator) + else: + cls._likes_to_meow_post_validators.append(validator) + return validator + + return decorator + + class PreNameValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: Cat.Partial + ) -> typing.Any: ... + + class NameValidator(typing.Protocol): + def __call__(self, __v: str, __values: Cat.Partial) -> str: ... + + class PreLikesToMeowValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: Cat.Partial + ) -> typing.Any: ... + + class LikesToMeowValidator(typing.Protocol): + def __call__(self, __v: bool, __values: Cat.Partial) -> bool: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: Cat.Partial) -> Cat.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_cat(cls, model: Cat) -> Cat: + for validator in Cat.Validators._pre_validators: + model = validator(model) + return model + + @pydantic.model_validator(mode="after") + def _post_validate_types_cat(cls, model: Cat) -> Cat: + for validator in Cat.Validators._post_validators: + model = validator(model) # type: ignore + return model + + @universal_field_validator("name", pre=True) + def _pre_validate_name(cls, v: str, values: Cat.Partial) -> str: + for validator in Cat.Validators._name_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("name", pre=False) + def _post_validate_name(cls, v: str, values: Cat.Partial) -> str: + for validator in Cat.Validators._name_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_meow", pre=True) + def _pre_validate_likes_to_meow(cls, v: bool, values: Cat.Partial) -> bool: + for validator in Cat.Validators._likes_to_meow_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_meow", pre=False) + def _post_validate_likes_to_meow(cls, v: bool, values: Cat.Partial) -> bool: + for validator in Cat.Validators._likes_to_meow_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="forbid", frozen=True + ) # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/types/dog.py b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/types/dog.py new file mode 100644 index 00000000000..8dae4399fc4 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/resources/types/resources/union/types/dog.py @@ -0,0 +1,195 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ......core.pydantic_utilities import UniversalBaseModel +import pydantic +import typing +import typing_extensions +from ......core.pydantic_utilities import universal_field_validator + + +class Dog(UniversalBaseModel): + name: str + likes_to_woof: bool = pydantic.Field(alias="likesToWoof") + + class Partial(typing.TypedDict): + name: typing_extensions.NotRequired[str] + likes_to_woof: typing_extensions.NotRequired[bool] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @Dog.Validators.root() + def validate(values: Dog.Partial) -> Dog.Partial: + ... + + @Dog.Validators.field("name") + def validate_name(name: str, values: Dog.Partial) -> str: + ... + + @Dog.Validators.field("likes_to_woof") + def validate_likes_to_woof(likes_to_woof: bool, values: Dog.Partial) -> bool: + ... + """ + + _pre_validators: typing.ClassVar[ + typing.List[Dog.Validators._PreRootValidator] + ] = [] + _post_validators: typing.ClassVar[ + typing.List[Dog.Validators._RootValidator] + ] = [] + _name_pre_validators: typing.ClassVar[ + typing.List[Dog.Validators.PreNameValidator] + ] = [] + _name_post_validators: typing.ClassVar[ + typing.List[Dog.Validators.NameValidator] + ] = [] + _likes_to_woof_pre_validators: typing.ClassVar[ + typing.List[Dog.Validators.PreLikesToWoofValidator] + ] = [] + _likes_to_woof_post_validators: typing.ClassVar[ + typing.List[Dog.Validators.LikesToWoofValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [Dog.Validators._RootValidator], Dog.Validators._RootValidator + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [Dog.Validators._PreRootValidator], Dog.Validators._PreRootValidator + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [Dog.Validators.PreNameValidator], Dog.Validators.PreNameValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["name"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [Dog.Validators.NameValidator], Dog.Validators.NameValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["likes_to_woof"], + *, + pre: typing.Literal[True], + ) -> typing.Callable[ + [Dog.Validators.PreLikesToWoofValidator], + Dog.Validators.PreLikesToWoofValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, + field_name: typing.Literal["likes_to_woof"], + *, + pre: typing.Literal[False] = False, + ) -> typing.Callable[ + [Dog.Validators.LikesToWoofValidator], Dog.Validators.LikesToWoofValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "name": + if pre: + cls._name_pre_validators.append(validator) + else: + cls._name_post_validators.append(validator) + if field_name == "likes_to_woof": + if pre: + cls._likes_to_woof_pre_validators.append(validator) + else: + cls._likes_to_woof_post_validators.append(validator) + return validator + + return decorator + + class PreNameValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: Dog.Partial + ) -> typing.Any: ... + + class NameValidator(typing.Protocol): + def __call__(self, __v: str, __values: Dog.Partial) -> str: ... + + class PreLikesToWoofValidator(typing.Protocol): + def __call__( + self, __v: typing.Any, __values: Dog.Partial + ) -> typing.Any: ... + + class LikesToWoofValidator(typing.Protocol): + def __call__(self, __v: bool, __values: Dog.Partial) -> bool: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: Dog.Partial) -> Dog.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_dog(cls, model: Dog) -> Dog: + for validator in Dog.Validators._pre_validators: + model = validator(model) + return model + + @pydantic.model_validator(mode="after") + def _post_validate_types_dog(cls, model: Dog) -> Dog: + for validator in Dog.Validators._post_validators: + model = validator(model) # type: ignore + return model + + @universal_field_validator("name", pre=True) + def _pre_validate_name(cls, v: str, values: Dog.Partial) -> str: + for validator in Dog.Validators._name_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("name", pre=False) + def _post_validate_name(cls, v: str, values: Dog.Partial) -> str: + for validator in Dog.Validators._name_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_woof", pre=True) + def _pre_validate_likes_to_woof(cls, v: bool, values: Dog.Partial) -> bool: + for validator in Dog.Validators._likes_to_woof_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_woof", pre=False) + def _post_validate_likes_to_woof(cls, v: bool, values: Dog.Partial) -> bool: + for validator in Dog.Validators._likes_to_woof_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="forbid", frozen=True + ) # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/security.py b/seed/fastapi/exhaustive/pydantic-v2-validators/security.py new file mode 100644 index 00000000000..4ccabc21106 --- /dev/null +++ b/seed/fastapi/exhaustive/pydantic-v2-validators/security.py @@ -0,0 +1,11 @@ +# This file was auto-generated by Fern from our API Definition. + +from .core.security.bearer import BearerToken +import fastapi +from .core.security.bearer import HTTPBearer + +ApiAuth = BearerToken + + +def FernAuth(auth: BearerToken = fastapi.Depends(HTTPBearer)) -> BearerToken: + return auth diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/snippet-templates.json b/seed/fastapi/exhaustive/pydantic-v2-validators/snippet-templates.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/seed/fastapi/exhaustive/pydantic-v2-validators/snippet.json b/seed/fastapi/exhaustive/pydantic-v2-validators/snippet.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/seed/fastapi/seed.yml b/seed/fastapi/seed.yml index c17be4a6bc5..ddab63e1e01 100644 --- a/seed/fastapi/seed.yml +++ b/seed/fastapi/seed.yml @@ -45,6 +45,13 @@ fixtures: pydantic_config: version: v2 outputFolder: pydantic-v2 + - customConfig: + pydantic_config: + version: v2 + wrapped_aliases: true + frozen: true + include_validators: true + outputFolder: pydantic-v2-validators - customConfig: pydantic_config: frozen: True diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/general_errors/types/bad_object_request_info.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/general_errors/types/bad_object_request_info.py index 7ed200df046..797736616e3 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/general_errors/types/bad_object_request_info.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/general_errors/types/bad_object_request_info.py @@ -1,12 +1,129 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations from ...core.pydantic_utilities import UniversalBaseModel +import typing +import typing_extensions +from ...core.pydantic_utilities import universal_root_validator +from ...core.pydantic_utilities import universal_field_validator import pydantic class BadObjectRequestInfo(UniversalBaseModel): message: str + class Partial(typing.TypedDict): + message: typing_extensions.NotRequired[str] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @BadObjectRequestInfo.Validators.root() + def validate(values: BadObjectRequestInfo.Partial) -> BadObjectRequestInfo.Partial: + ... + + @BadObjectRequestInfo.Validators.field("message") + def validate_message(message: str, values: BadObjectRequestInfo.Partial) -> str: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[BadObjectRequestInfo.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[BadObjectRequestInfo.Validators._RootValidator]] = [] + _message_pre_validators: typing.ClassVar[typing.List[BadObjectRequestInfo.Validators.PreMessageValidator]] = [] + _message_post_validators: typing.ClassVar[typing.List[BadObjectRequestInfo.Validators.MessageValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [BadObjectRequestInfo.Validators._RootValidator], BadObjectRequestInfo.Validators._RootValidator + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [BadObjectRequestInfo.Validators._PreRootValidator], BadObjectRequestInfo.Validators._PreRootValidator + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["message"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [BadObjectRequestInfo.Validators.PreMessageValidator], BadObjectRequestInfo.Validators.PreMessageValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["message"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [BadObjectRequestInfo.Validators.MessageValidator], BadObjectRequestInfo.Validators.MessageValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "message": + if pre: + cls._message_pre_validators.append(validator) + else: + cls._message_post_validators.append(validator) + return validator + + return decorator + + class PreMessageValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: BadObjectRequestInfo.Partial) -> typing.Any: ... + + class MessageValidator(typing.Protocol): + def __call__(self, __v: str, __values: BadObjectRequestInfo.Partial) -> str: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: BadObjectRequestInfo.Partial) -> BadObjectRequestInfo.Partial: ... + + @universal_root_validator(pre=True) + def _pre_validate_bad_object_request_info( + cls, values: BadObjectRequestInfo.Partial + ) -> BadObjectRequestInfo.Partial: + for validator in BadObjectRequestInfo.Validators._pre_validators: + values = validator(values) + return values + + @universal_root_validator(pre=False) + def _post_validate_bad_object_request_info( + cls, values: BadObjectRequestInfo.Partial + ) -> BadObjectRequestInfo.Partial: + for validator in BadObjectRequestInfo.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("message", pre=True) + def _pre_validate_message(cls, v: str, values: BadObjectRequestInfo.Partial) -> str: + for validator in BadObjectRequestInfo.Validators._message_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("message", pre=False) + def _post_validate_message(cls, v: str, values: BadObjectRequestInfo.Partial) -> str: + for validator in BadObjectRequestInfo.Validators._message_post_validators: + v = validator(v, values) + return v + class Config: frozen = True smart_union = True diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/double_optional.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/double_optional.py index 60fd7675418..c297e56fd05 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/double_optional.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/double_optional.py @@ -1,10 +1,13 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations from ....core.pydantic_utilities import UniversalBaseModel import typing_extensions import typing from .optional_alias import OptionalAlias from ....core.serialization import FieldMetadata +from ....core.pydantic_utilities import universal_root_validator +from ....core.pydantic_utilities import universal_field_validator import pydantic @@ -13,6 +16,130 @@ class DoubleOptional(UniversalBaseModel): typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias") ] = None + class Partial(typing.TypedDict): + optional_alias: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @DoubleOptional.Validators.root() + def validate(values: DoubleOptional.Partial) -> DoubleOptional.Partial: + ... + + @DoubleOptional.Validators.field("optional_alias") + def validate_optional_alias(optional_alias: typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")], values: DoubleOptional.Partial) -> typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[DoubleOptional.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[DoubleOptional.Validators._RootValidator]] = [] + _optional_alias_pre_validators: typing.ClassVar[ + typing.List[DoubleOptional.Validators.PreOptionalAliasValidator] + ] = [] + _optional_alias_post_validators: typing.ClassVar[ + typing.List[DoubleOptional.Validators.OptionalAliasValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[[DoubleOptional.Validators._RootValidator], DoubleOptional.Validators._RootValidator]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [DoubleOptional.Validators._PreRootValidator], DoubleOptional.Validators._PreRootValidator + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["optional_alias"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [DoubleOptional.Validators.PreOptionalAliasValidator], DoubleOptional.Validators.PreOptionalAliasValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["optional_alias"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [DoubleOptional.Validators.OptionalAliasValidator], DoubleOptional.Validators.OptionalAliasValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "optional_alias": + if pre: + cls._optional_alias_pre_validators.append(validator) + else: + cls._optional_alias_post_validators.append(validator) + return validator + + return decorator + + class PreOptionalAliasValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: DoubleOptional.Partial) -> typing.Any: ... + + class OptionalAliasValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")], + __values: DoubleOptional.Partial, + ) -> typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: DoubleOptional.Partial) -> DoubleOptional.Partial: ... + + @universal_root_validator(pre=True) + def _pre_validate_types_double_optional(cls, values: DoubleOptional.Partial) -> DoubleOptional.Partial: + for validator in DoubleOptional.Validators._pre_validators: + values = validator(values) + return values + + @universal_root_validator(pre=False) + def _post_validate_types_double_optional(cls, values: DoubleOptional.Partial) -> DoubleOptional.Partial: + for validator in DoubleOptional.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("optional_alias", pre=True) + def _pre_validate_optional_alias( + cls, + v: typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")], + values: DoubleOptional.Partial, + ) -> typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")]: + for validator in DoubleOptional.Validators._optional_alias_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("optional_alias", pre=False) + def _post_validate_optional_alias( + cls, + v: typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")], + values: DoubleOptional.Partial, + ) -> typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")]: + for validator in DoubleOptional.Validators._optional_alias_post_validators: + v = validator(v, values) + return v + class Config: frozen = True smart_union = True diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/nested_object_with_optional_field.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/nested_object_with_optional_field.py index b2d7877e37d..c78b2d4048a 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/nested_object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/nested_object_with_optional_field.py @@ -1,10 +1,13 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations from ....core.pydantic_utilities import UniversalBaseModel import typing import typing_extensions from .object_with_optional_field import ObjectWithOptionalField from ....core.serialization import FieldMetadata +from ....core.pydantic_utilities import universal_root_validator +from ....core.pydantic_utilities import universal_field_validator import pydantic @@ -14,6 +17,202 @@ class NestedObjectWithOptionalField(UniversalBaseModel): typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject") ] = None + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[typing.Optional[str]] + nested_object: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @NestedObjectWithOptionalField.Validators.root() + def validate(values: NestedObjectWithOptionalField.Partial) -> NestedObjectWithOptionalField.Partial: + ... + + @NestedObjectWithOptionalField.Validators.field("string") + def validate_string(string: typing.Optional[str], values: NestedObjectWithOptionalField.Partial) -> typing.Optional[str]: + ... + + @NestedObjectWithOptionalField.Validators.field("nested_object") + def validate_nested_object(nested_object: typing_extensions.Annotated[typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject")], values: NestedObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[NestedObjectWithOptionalField.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[NestedObjectWithOptionalField.Validators._RootValidator]] = [] + _string_pre_validators: typing.ClassVar[ + typing.List[NestedObjectWithOptionalField.Validators.PreStringValidator] + ] = [] + _string_post_validators: typing.ClassVar[ + typing.List[NestedObjectWithOptionalField.Validators.StringValidator] + ] = [] + _nested_object_pre_validators: typing.ClassVar[ + typing.List[NestedObjectWithOptionalField.Validators.PreNestedObjectValidator] + ] = [] + _nested_object_post_validators: typing.ClassVar[ + typing.List[NestedObjectWithOptionalField.Validators.NestedObjectValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators._RootValidator], + NestedObjectWithOptionalField.Validators._RootValidator, + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators._PreRootValidator], + NestedObjectWithOptionalField.Validators._PreRootValidator, + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators.PreStringValidator], + NestedObjectWithOptionalField.Validators.PreStringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators.StringValidator], + NestedObjectWithOptionalField.Validators.StringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["nested_object"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators.PreNestedObjectValidator], + NestedObjectWithOptionalField.Validators.PreNestedObjectValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["nested_object"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators.NestedObjectValidator], + NestedObjectWithOptionalField.Validators.NestedObjectValidator, + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "string": + if pre: + cls._string_pre_validators.append(validator) + else: + cls._string_post_validators.append(validator) + if field_name == "nested_object": + if pre: + cls._nested_object_pre_validators.append(validator) + else: + cls._nested_object_post_validators.append(validator) + return validator + + return decorator + + class PreStringValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: NestedObjectWithOptionalField.Partial) -> typing.Any: ... + + class StringValidator(typing.Protocol): + def __call__( + self, __v: typing.Optional[str], __values: NestedObjectWithOptionalField.Partial + ) -> typing.Optional[str]: ... + + class PreNestedObjectValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: NestedObjectWithOptionalField.Partial) -> typing.Any: ... + + class NestedObjectValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[ + typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject") + ], + __values: NestedObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[ + typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject") + ]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__( + self, __values: NestedObjectWithOptionalField.Partial + ) -> NestedObjectWithOptionalField.Partial: ... + + @universal_root_validator(pre=True) + def _pre_validate_types_nested_object_with_optional_field( + cls, values: NestedObjectWithOptionalField.Partial + ) -> NestedObjectWithOptionalField.Partial: + for validator in NestedObjectWithOptionalField.Validators._pre_validators: + values = validator(values) + return values + + @universal_root_validator(pre=False) + def _post_validate_types_nested_object_with_optional_field( + cls, values: NestedObjectWithOptionalField.Partial + ) -> NestedObjectWithOptionalField.Partial: + for validator in NestedObjectWithOptionalField.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("string", pre=True) + def _pre_validate_string( + cls, v: typing.Optional[str], values: NestedObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in NestedObjectWithOptionalField.Validators._string_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("string", pre=False) + def _post_validate_string( + cls, v: typing.Optional[str], values: NestedObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in NestedObjectWithOptionalField.Validators._string_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("nested_object", pre=True) + def _pre_validate_nested_object( + cls, + v: typing_extensions.Annotated[typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject")], + values: NestedObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject")]: + for validator in NestedObjectWithOptionalField.Validators._nested_object_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("nested_object", pre=False) + def _post_validate_nested_object( + cls, + v: typing_extensions.Annotated[typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject")], + values: NestedObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject")]: + for validator in NestedObjectWithOptionalField.Validators._nested_object_post_validators: + v = validator(v, values) + return v + class Config: frozen = True smart_union = True diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/nested_object_with_required_field.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/nested_object_with_required_field.py index 64cf434cd47..6911fe19d58 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/nested_object_with_required_field.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/nested_object_with_required_field.py @@ -1,9 +1,13 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations from ....core.pydantic_utilities import UniversalBaseModel import typing_extensions from .object_with_optional_field import ObjectWithOptionalField from ....core.serialization import FieldMetadata +import typing +from ....core.pydantic_utilities import universal_root_validator +from ....core.pydantic_utilities import universal_field_validator import pydantic @@ -11,6 +15,192 @@ class NestedObjectWithRequiredField(UniversalBaseModel): string: str nested_object: typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")] + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[str] + nested_object: typing_extensions.NotRequired[ + typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @NestedObjectWithRequiredField.Validators.root() + def validate(values: NestedObjectWithRequiredField.Partial) -> NestedObjectWithRequiredField.Partial: + ... + + @NestedObjectWithRequiredField.Validators.field("string") + def validate_string(string: str, values: NestedObjectWithRequiredField.Partial) -> str: + ... + + @NestedObjectWithRequiredField.Validators.field("nested_object") + def validate_nested_object(nested_object: typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")], values: NestedObjectWithRequiredField.Partial) -> typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[NestedObjectWithRequiredField.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[NestedObjectWithRequiredField.Validators._RootValidator]] = [] + _string_pre_validators: typing.ClassVar[ + typing.List[NestedObjectWithRequiredField.Validators.PreStringValidator] + ] = [] + _string_post_validators: typing.ClassVar[ + typing.List[NestedObjectWithRequiredField.Validators.StringValidator] + ] = [] + _nested_object_pre_validators: typing.ClassVar[ + typing.List[NestedObjectWithRequiredField.Validators.PreNestedObjectValidator] + ] = [] + _nested_object_post_validators: typing.ClassVar[ + typing.List[NestedObjectWithRequiredField.Validators.NestedObjectValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators._RootValidator], + NestedObjectWithRequiredField.Validators._RootValidator, + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators._PreRootValidator], + NestedObjectWithRequiredField.Validators._PreRootValidator, + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators.PreStringValidator], + NestedObjectWithRequiredField.Validators.PreStringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators.StringValidator], + NestedObjectWithRequiredField.Validators.StringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["nested_object"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators.PreNestedObjectValidator], + NestedObjectWithRequiredField.Validators.PreNestedObjectValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["nested_object"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators.NestedObjectValidator], + NestedObjectWithRequiredField.Validators.NestedObjectValidator, + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "string": + if pre: + cls._string_pre_validators.append(validator) + else: + cls._string_post_validators.append(validator) + if field_name == "nested_object": + if pre: + cls._nested_object_pre_validators.append(validator) + else: + cls._nested_object_post_validators.append(validator) + return validator + + return decorator + + class PreStringValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: NestedObjectWithRequiredField.Partial) -> typing.Any: ... + + class StringValidator(typing.Protocol): + def __call__(self, __v: str, __values: NestedObjectWithRequiredField.Partial) -> str: ... + + class PreNestedObjectValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: NestedObjectWithRequiredField.Partial) -> typing.Any: ... + + class NestedObjectValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")], + __values: NestedObjectWithRequiredField.Partial, + ) -> typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__( + self, __values: NestedObjectWithRequiredField.Partial + ) -> NestedObjectWithRequiredField.Partial: ... + + @universal_root_validator(pre=True) + def _pre_validate_types_nested_object_with_required_field( + cls, values: NestedObjectWithRequiredField.Partial + ) -> NestedObjectWithRequiredField.Partial: + for validator in NestedObjectWithRequiredField.Validators._pre_validators: + values = validator(values) + return values + + @universal_root_validator(pre=False) + def _post_validate_types_nested_object_with_required_field( + cls, values: NestedObjectWithRequiredField.Partial + ) -> NestedObjectWithRequiredField.Partial: + for validator in NestedObjectWithRequiredField.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("string", pre=True) + def _pre_validate_string(cls, v: str, values: NestedObjectWithRequiredField.Partial) -> str: + for validator in NestedObjectWithRequiredField.Validators._string_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("string", pre=False) + def _post_validate_string(cls, v: str, values: NestedObjectWithRequiredField.Partial) -> str: + for validator in NestedObjectWithRequiredField.Validators._string_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("nested_object", pre=True) + def _pre_validate_nested_object( + cls, + v: typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")], + values: NestedObjectWithRequiredField.Partial, + ) -> typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")]: + for validator in NestedObjectWithRequiredField.Validators._nested_object_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("nested_object", pre=False) + def _post_validate_nested_object( + cls, + v: typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")], + values: NestedObjectWithRequiredField.Partial, + ) -> typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")]: + for validator in NestedObjectWithRequiredField.Validators._nested_object_post_validators: + v = validator(v, values) + return v + class Config: frozen = True smart_union = True diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/object_with_map_of_map.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/object_with_map_of_map.py index 6793464cd74..5feeeac978f 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/object_with_map_of_map.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/object_with_map_of_map.py @@ -1,15 +1,144 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations from ....core.pydantic_utilities import UniversalBaseModel import typing_extensions import typing from ....core.serialization import FieldMetadata +from ....core.pydantic_utilities import universal_root_validator +from ....core.pydantic_utilities import universal_field_validator import pydantic class ObjectWithMapOfMap(UniversalBaseModel): map_: typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")] + class Partial(typing.TypedDict): + map_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @ObjectWithMapOfMap.Validators.root() + def validate(values: ObjectWithMapOfMap.Partial) -> ObjectWithMapOfMap.Partial: + ... + + @ObjectWithMapOfMap.Validators.field("map_") + def validate_map_(map_: typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")], values: ObjectWithMapOfMap.Partial) -> typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[ObjectWithMapOfMap.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[ObjectWithMapOfMap.Validators._RootValidator]] = [] + _map__pre_validators: typing.ClassVar[typing.List[ObjectWithMapOfMap.Validators.PreMapValidator]] = [] + _map__post_validators: typing.ClassVar[typing.List[ObjectWithMapOfMap.Validators.MapValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithMapOfMap.Validators._RootValidator], ObjectWithMapOfMap.Validators._RootValidator + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithMapOfMap.Validators._PreRootValidator], ObjectWithMapOfMap.Validators._PreRootValidator + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["map_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithMapOfMap.Validators.PreMapValidator], ObjectWithMapOfMap.Validators.PreMapValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["map_"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithMapOfMap.Validators.MapValidator], ObjectWithMapOfMap.Validators.MapValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "map_": + if pre: + cls._map__pre_validators.append(validator) + else: + cls._map__post_validators.append(validator) + return validator + + return decorator + + class PreMapValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithMapOfMap.Partial) -> typing.Any: ... + + class MapValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")], + __values: ObjectWithMapOfMap.Partial, + ) -> typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: ObjectWithMapOfMap.Partial) -> ObjectWithMapOfMap.Partial: ... + + @universal_root_validator(pre=True) + def _pre_validate_types_object_with_map_of_map( + cls, values: ObjectWithMapOfMap.Partial + ) -> ObjectWithMapOfMap.Partial: + for validator in ObjectWithMapOfMap.Validators._pre_validators: + values = validator(values) + return values + + @universal_root_validator(pre=False) + def _post_validate_types_object_with_map_of_map( + cls, values: ObjectWithMapOfMap.Partial + ) -> ObjectWithMapOfMap.Partial: + for validator in ObjectWithMapOfMap.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("map_", pre=True) + def _pre_validate_map_( + cls, + v: typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")], + values: ObjectWithMapOfMap.Partial, + ) -> typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")]: + for validator in ObjectWithMapOfMap.Validators._map__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("map_", pre=False) + def _post_validate_map_( + cls, + v: typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")], + values: ObjectWithMapOfMap.Partial, + ) -> typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")]: + for validator in ObjectWithMapOfMap.Validators._map__post_validators: + v = validator(v, values) + return v + class Config: frozen = True smart_union = True diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/object_with_optional_field.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/object_with_optional_field.py index 4e8aa08f65e..2c68d9c0429 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/object_with_optional_field.py @@ -1,5 +1,6 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations from ....core.pydantic_utilities import UniversalBaseModel import typing import pydantic @@ -7,6 +8,8 @@ from ....core.serialization import FieldMetadata import datetime as dt import uuid +from ....core.pydantic_utilities import universal_root_validator +from ....core.pydantic_utilities import universal_field_validator class ObjectWithOptionalField(UniversalBaseModel): @@ -28,6 +31,794 @@ class ObjectWithOptionalField(UniversalBaseModel): map_: typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")] = None bigint: typing.Optional[str] = None + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[typing.Optional[str]] + integer: typing_extensions.NotRequired[typing.Optional[int]] + long_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")] + ] + double: typing_extensions.NotRequired[typing.Optional[float]] + bool_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")] + ] + datetime: typing_extensions.NotRequired[typing.Optional[dt.datetime]] + date: typing_extensions.NotRequired[typing.Optional[dt.date]] + uuid_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")] + ] + base_64: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")] + ] + list_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")] + ] + set_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")] + ] + map_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")] + ] + bigint: typing_extensions.NotRequired[typing.Optional[str]] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @ObjectWithOptionalField.Validators.root() + def validate(values: ObjectWithOptionalField.Partial) -> ObjectWithOptionalField.Partial: + ... + + @ObjectWithOptionalField.Validators.field("string") + def validate_string(string: typing.Optional[str], values: ObjectWithOptionalField.Partial) -> typing.Optional[str]: + ... + + @ObjectWithOptionalField.Validators.field("integer") + def validate_integer(integer: typing.Optional[int], values: ObjectWithOptionalField.Partial) -> typing.Optional[int]: + ... + + @ObjectWithOptionalField.Validators.field("long_") + def validate_long_(long_: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")], values: ObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")]: + ... + + @ObjectWithOptionalField.Validators.field("double") + def validate_double(double: typing.Optional[float], values: ObjectWithOptionalField.Partial) -> typing.Optional[float]: + ... + + @ObjectWithOptionalField.Validators.field("bool_") + def validate_bool_(bool_: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")], values: ObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")]: + ... + + @ObjectWithOptionalField.Validators.field("datetime") + def validate_datetime(datetime: typing.Optional[dt.datetime], values: ObjectWithOptionalField.Partial) -> typing.Optional[dt.datetime]: + ... + + @ObjectWithOptionalField.Validators.field("date") + def validate_date(date: typing.Optional[dt.date], values: ObjectWithOptionalField.Partial) -> typing.Optional[dt.date]: + ... + + @ObjectWithOptionalField.Validators.field("uuid_") + def validate_uuid_(uuid_: typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")], values: ObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")]: + ... + + @ObjectWithOptionalField.Validators.field("base_64") + def validate_base_64(base_64: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")], values: ObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")]: + ... + + @ObjectWithOptionalField.Validators.field("list_") + def validate_list_(list_: typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")], values: ObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")]: + ... + + @ObjectWithOptionalField.Validators.field("set_") + def validate_set_(set_: typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")], values: ObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")]: + ... + + @ObjectWithOptionalField.Validators.field("map_") + def validate_map_(map_: typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")], values: ObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")]: + ... + + @ObjectWithOptionalField.Validators.field("bigint") + def validate_bigint(bigint: typing.Optional[str], values: ObjectWithOptionalField.Partial) -> typing.Optional[str]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators._RootValidator]] = [] + _string_pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreStringValidator]] = [] + _string_post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.StringValidator]] = [] + _integer_pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreIntegerValidator] + ] = [] + _integer_post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.IntegerValidator]] = [] + _long__pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreLongValidator]] = [] + _long__post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.LongValidator]] = [] + _double_pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreDoubleValidator]] = [] + _double_post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.DoubleValidator]] = [] + _bool__pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreBoolValidator]] = [] + _bool__post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.BoolValidator]] = [] + _datetime_pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreDatetimeValidator] + ] = [] + _datetime_post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.DatetimeValidator] + ] = [] + _date_pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreDateValidator]] = [] + _date_post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.DateValidator]] = [] + _uuid__pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreUuidValidator]] = [] + _uuid__post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.UuidValidator]] = [] + _base_64_pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreBase64Validator] + ] = [] + _base_64_post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.Base64Validator]] = [] + _list__pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreListValidator]] = [] + _list__post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.ListValidator]] = [] + _set__pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreSetValidator]] = [] + _set__post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.SetValidator]] = [] + _map__pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreMapValidator]] = [] + _map__post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.MapValidator]] = [] + _bigint_pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreBigintValidator]] = [] + _bigint_post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.BigintValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators._RootValidator], ObjectWithOptionalField.Validators._RootValidator + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators._PreRootValidator], ObjectWithOptionalField.Validators._PreRootValidator + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreStringValidator], + ObjectWithOptionalField.Validators.PreStringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.StringValidator], ObjectWithOptionalField.Validators.StringValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["integer"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreIntegerValidator], + ObjectWithOptionalField.Validators.PreIntegerValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["integer"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.IntegerValidator], ObjectWithOptionalField.Validators.IntegerValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["long_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreLongValidator], ObjectWithOptionalField.Validators.PreLongValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["long_"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.LongValidator], ObjectWithOptionalField.Validators.LongValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["double"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreDoubleValidator], + ObjectWithOptionalField.Validators.PreDoubleValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["double"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.DoubleValidator], ObjectWithOptionalField.Validators.DoubleValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["bool_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreBoolValidator], ObjectWithOptionalField.Validators.PreBoolValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["bool_"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.BoolValidator], ObjectWithOptionalField.Validators.BoolValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["datetime"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreDatetimeValidator], + ObjectWithOptionalField.Validators.PreDatetimeValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["datetime"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.DatetimeValidator], ObjectWithOptionalField.Validators.DatetimeValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["date"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreDateValidator], ObjectWithOptionalField.Validators.PreDateValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["date"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.DateValidator], ObjectWithOptionalField.Validators.DateValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["uuid_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreUuidValidator], ObjectWithOptionalField.Validators.PreUuidValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["uuid_"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.UuidValidator], ObjectWithOptionalField.Validators.UuidValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["base_64"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreBase64Validator], + ObjectWithOptionalField.Validators.PreBase64Validator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["base_64"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.Base64Validator], ObjectWithOptionalField.Validators.Base64Validator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["list_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreListValidator], ObjectWithOptionalField.Validators.PreListValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["list_"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.ListValidator], ObjectWithOptionalField.Validators.ListValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["set_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreSetValidator], ObjectWithOptionalField.Validators.PreSetValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["set_"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.SetValidator], ObjectWithOptionalField.Validators.SetValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["map_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreMapValidator], ObjectWithOptionalField.Validators.PreMapValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["map_"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.MapValidator], ObjectWithOptionalField.Validators.MapValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["bigint"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreBigintValidator], + ObjectWithOptionalField.Validators.PreBigintValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["bigint"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.BigintValidator], ObjectWithOptionalField.Validators.BigintValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "string": + if pre: + cls._string_pre_validators.append(validator) + else: + cls._string_post_validators.append(validator) + if field_name == "integer": + if pre: + cls._integer_pre_validators.append(validator) + else: + cls._integer_post_validators.append(validator) + if field_name == "long_": + if pre: + cls._long__pre_validators.append(validator) + else: + cls._long__post_validators.append(validator) + if field_name == "double": + if pre: + cls._double_pre_validators.append(validator) + else: + cls._double_post_validators.append(validator) + if field_name == "bool_": + if pre: + cls._bool__pre_validators.append(validator) + else: + cls._bool__post_validators.append(validator) + if field_name == "datetime": + if pre: + cls._datetime_pre_validators.append(validator) + else: + cls._datetime_post_validators.append(validator) + if field_name == "date": + if pre: + cls._date_pre_validators.append(validator) + else: + cls._date_post_validators.append(validator) + if field_name == "uuid_": + if pre: + cls._uuid__pre_validators.append(validator) + else: + cls._uuid__post_validators.append(validator) + if field_name == "base_64": + if pre: + cls._base_64_pre_validators.append(validator) + else: + cls._base_64_post_validators.append(validator) + if field_name == "list_": + if pre: + cls._list__pre_validators.append(validator) + else: + cls._list__post_validators.append(validator) + if field_name == "set_": + if pre: + cls._set__pre_validators.append(validator) + else: + cls._set__post_validators.append(validator) + if field_name == "map_": + if pre: + cls._map__pre_validators.append(validator) + else: + cls._map__post_validators.append(validator) + if field_name == "bigint": + if pre: + cls._bigint_pre_validators.append(validator) + else: + cls._bigint_post_validators.append(validator) + return validator + + return decorator + + class PreStringValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class StringValidator(typing.Protocol): + def __call__( + self, __v: typing.Optional[str], __values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: ... + + class PreIntegerValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class IntegerValidator(typing.Protocol): + def __call__( + self, __v: typing.Optional[int], __values: ObjectWithOptionalField.Partial + ) -> typing.Optional[int]: ... + + class PreLongValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class LongValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")], + __values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")]: ... + + class PreDoubleValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class DoubleValidator(typing.Protocol): + def __call__( + self, __v: typing.Optional[float], __values: ObjectWithOptionalField.Partial + ) -> typing.Optional[float]: ... + + class PreBoolValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class BoolValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")], + __values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")]: ... + + class PreDatetimeValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class DatetimeValidator(typing.Protocol): + def __call__( + self, __v: typing.Optional[dt.datetime], __values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.datetime]: ... + + class PreDateValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class DateValidator(typing.Protocol): + def __call__( + self, __v: typing.Optional[dt.date], __values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.date]: ... + + class PreUuidValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class UuidValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")], + __values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")]: ... + + class PreBase64Validator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class Base64Validator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")], + __values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")]: ... + + class PreListValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class ListValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")], + __values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")]: ... + + class PreSetValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class SetValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")], + __values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")]: ... + + class PreMapValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class MapValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")], + __values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")]: ... + + class PreBigintValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class BigintValidator(typing.Protocol): + def __call__( + self, __v: typing.Optional[str], __values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: ObjectWithOptionalField.Partial) -> ObjectWithOptionalField.Partial: ... + + @universal_root_validator(pre=True) + def _pre_validate_types_object_with_optional_field( + cls, values: ObjectWithOptionalField.Partial + ) -> ObjectWithOptionalField.Partial: + for validator in ObjectWithOptionalField.Validators._pre_validators: + values = validator(values) + return values + + @universal_root_validator(pre=False) + def _post_validate_types_object_with_optional_field( + cls, values: ObjectWithOptionalField.Partial + ) -> ObjectWithOptionalField.Partial: + for validator in ObjectWithOptionalField.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("string", pre=True) + def _pre_validate_string( + cls, v: typing.Optional[str], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in ObjectWithOptionalField.Validators._string_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("string", pre=False) + def _post_validate_string( + cls, v: typing.Optional[str], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in ObjectWithOptionalField.Validators._string_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("integer", pre=True) + def _pre_validate_integer( + cls, v: typing.Optional[int], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[int]: + for validator in ObjectWithOptionalField.Validators._integer_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("integer", pre=False) + def _post_validate_integer( + cls, v: typing.Optional[int], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[int]: + for validator in ObjectWithOptionalField.Validators._integer_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("long_", pre=True) + def _pre_validate_long_( + cls, + v: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")]: + for validator in ObjectWithOptionalField.Validators._long__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("long_", pre=False) + def _post_validate_long_( + cls, + v: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")]: + for validator in ObjectWithOptionalField.Validators._long__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("double", pre=True) + def _pre_validate_double( + cls, v: typing.Optional[float], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[float]: + for validator in ObjectWithOptionalField.Validators._double_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("double", pre=False) + def _post_validate_double( + cls, v: typing.Optional[float], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[float]: + for validator in ObjectWithOptionalField.Validators._double_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("bool_", pre=True) + def _pre_validate_bool_( + cls, + v: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")]: + for validator in ObjectWithOptionalField.Validators._bool__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("bool_", pre=False) + def _post_validate_bool_( + cls, + v: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")]: + for validator in ObjectWithOptionalField.Validators._bool__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("datetime", pre=True) + def _pre_validate_datetime( + cls, v: typing.Optional[dt.datetime], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.datetime]: + for validator in ObjectWithOptionalField.Validators._datetime_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("datetime", pre=False) + def _post_validate_datetime( + cls, v: typing.Optional[dt.datetime], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.datetime]: + for validator in ObjectWithOptionalField.Validators._datetime_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("date", pre=True) + def _pre_validate_date( + cls, v: typing.Optional[dt.date], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.date]: + for validator in ObjectWithOptionalField.Validators._date_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("date", pre=False) + def _post_validate_date( + cls, v: typing.Optional[dt.date], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.date]: + for validator in ObjectWithOptionalField.Validators._date_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("uuid_", pre=True) + def _pre_validate_uuid_( + cls, + v: typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")]: + for validator in ObjectWithOptionalField.Validators._uuid__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("uuid_", pre=False) + def _post_validate_uuid_( + cls, + v: typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")]: + for validator in ObjectWithOptionalField.Validators._uuid__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("base_64", pre=True) + def _pre_validate_base_64( + cls, + v: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")]: + for validator in ObjectWithOptionalField.Validators._base_64_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("base_64", pre=False) + def _post_validate_base_64( + cls, + v: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")]: + for validator in ObjectWithOptionalField.Validators._base_64_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("list_", pre=True) + def _pre_validate_list_( + cls, + v: typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")]: + for validator in ObjectWithOptionalField.Validators._list__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("list_", pre=False) + def _post_validate_list_( + cls, + v: typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")]: + for validator in ObjectWithOptionalField.Validators._list__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("set_", pre=True) + def _pre_validate_set_( + cls, + v: typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")]: + for validator in ObjectWithOptionalField.Validators._set__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("set_", pre=False) + def _post_validate_set_( + cls, + v: typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")]: + for validator in ObjectWithOptionalField.Validators._set__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("map_", pre=True) + def _pre_validate_map_( + cls, + v: typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")]: + for validator in ObjectWithOptionalField.Validators._map__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("map_", pre=False) + def _post_validate_map_( + cls, + v: typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")]: + for validator in ObjectWithOptionalField.Validators._map__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("bigint", pre=True) + def _pre_validate_bigint( + cls, v: typing.Optional[str], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in ObjectWithOptionalField.Validators._bigint_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("bigint", pre=False) + def _post_validate_bigint( + cls, v: typing.Optional[str], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in ObjectWithOptionalField.Validators._bigint_post_validators: + v = validator(v, values) + return v + class Config: frozen = True smart_union = True diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/object_with_required_field.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/object_with_required_field.py index 25658d6cb6d..57abaa47b4f 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/object_with_required_field.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/object_with_required_field.py @@ -1,12 +1,130 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations from ....core.pydantic_utilities import UniversalBaseModel +import typing +import typing_extensions +from ....core.pydantic_utilities import universal_root_validator +from ....core.pydantic_utilities import universal_field_validator import pydantic class ObjectWithRequiredField(UniversalBaseModel): string: str + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[str] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @ObjectWithRequiredField.Validators.root() + def validate(values: ObjectWithRequiredField.Partial) -> ObjectWithRequiredField.Partial: + ... + + @ObjectWithRequiredField.Validators.field("string") + def validate_string(string: str, values: ObjectWithRequiredField.Partial) -> str: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[ObjectWithRequiredField.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[ObjectWithRequiredField.Validators._RootValidator]] = [] + _string_pre_validators: typing.ClassVar[typing.List[ObjectWithRequiredField.Validators.PreStringValidator]] = [] + _string_post_validators: typing.ClassVar[typing.List[ObjectWithRequiredField.Validators.StringValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithRequiredField.Validators._RootValidator], ObjectWithRequiredField.Validators._RootValidator + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithRequiredField.Validators._PreRootValidator], ObjectWithRequiredField.Validators._PreRootValidator + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithRequiredField.Validators.PreStringValidator], + ObjectWithRequiredField.Validators.PreStringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithRequiredField.Validators.StringValidator], ObjectWithRequiredField.Validators.StringValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "string": + if pre: + cls._string_pre_validators.append(validator) + else: + cls._string_post_validators.append(validator) + return validator + + return decorator + + class PreStringValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithRequiredField.Partial) -> typing.Any: ... + + class StringValidator(typing.Protocol): + def __call__(self, __v: str, __values: ObjectWithRequiredField.Partial) -> str: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: ObjectWithRequiredField.Partial) -> ObjectWithRequiredField.Partial: ... + + @universal_root_validator(pre=True) + def _pre_validate_types_object_with_required_field( + cls, values: ObjectWithRequiredField.Partial + ) -> ObjectWithRequiredField.Partial: + for validator in ObjectWithRequiredField.Validators._pre_validators: + values = validator(values) + return values + + @universal_root_validator(pre=False) + def _post_validate_types_object_with_required_field( + cls, values: ObjectWithRequiredField.Partial + ) -> ObjectWithRequiredField.Partial: + for validator in ObjectWithRequiredField.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("string", pre=True) + def _pre_validate_string(cls, v: str, values: ObjectWithRequiredField.Partial) -> str: + for validator in ObjectWithRequiredField.Validators._string_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("string", pre=False) + def _post_validate_string(cls, v: str, values: ObjectWithRequiredField.Partial) -> str: + for validator in ObjectWithRequiredField.Validators._string_post_validators: + v = validator(v, values) + return v + class Config: frozen = True smart_union = True diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/optional_alias.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/optional_alias.py index d410b58f8ad..f3cb94ed508 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/optional_alias.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/object/types/optional_alias.py @@ -3,6 +3,7 @@ from __future__ import annotations from ....core.pydantic_utilities import UniversalBaseModel import typing +from ....core.pydantic_utilities import universal_root_validator import pydantic @@ -16,6 +17,28 @@ def get_as_str(self) -> typing.Optional[str]: def from_str(value: typing.Optional[str]) -> OptionalAlias: return OptionalAlias(__root__=value) + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @OptionalAlias.Validators.validate + def validate(value: typing.Optional[str]) -> typing.Optional[str]: + ... + """ + + _validators: typing.ClassVar[typing.List[typing.Callable[[typing.Optional[str]], typing.Optional[str]]]] = [] + + @classmethod + def validate(cls, validator: typing.Callable[[typing.Optional[str]], typing.Optional[str]]) -> None: + cls._validators.append(validator) + + @universal_root_validator(pre=False) + def _validate(cls, values: typing.Dict[str, typing.Any]) -> typing.Dict[str, typing.Any]: + value = typing.cast(typing.Optional[str], values.get("__root__")) + for validator in OptionalAlias.Validators._validators: + value = validator(value) + return {**values, "__root__": value} + class Config: frozen = True smart_union = True diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/union/types/animal.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/union/types/animal.py index ce07ea3db5a..79e453e48ac 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/union/types/animal.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/union/types/animal.py @@ -5,6 +5,8 @@ import typing import typing_extensions from ....core.serialization import FieldMetadata +from ....core.pydantic_utilities import universal_root_validator +from ....core.pydantic_utilities import universal_field_validator import pydantic @@ -13,6 +15,200 @@ class Animal_Dog(UniversalBaseModel): name: str likes_to_woof: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")] + class Partial(typing.TypedDict): + animal: typing_extensions.NotRequired[typing.Literal["dog"]] + name: typing_extensions.NotRequired[str] + likes_to_woof: typing_extensions.NotRequired[ + typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @Animal_Dog.Validators.root() + def validate(values: Animal_Dog.Partial) -> Animal_Dog.Partial: + ... + + @Animal_Dog.Validators.field("animal") + def validate_animal(animal: typing.Literal["dog"], values: Animal_Dog.Partial) -> typing.Literal["dog"]: + ... + + @Animal_Dog.Validators.field("name") + def validate_name(name: str, values: Animal_Dog.Partial) -> str: + ... + + @Animal_Dog.Validators.field("likes_to_woof") + def validate_likes_to_woof(likes_to_woof: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], values: Animal_Dog.Partial) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[Animal_Dog.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[Animal_Dog.Validators._RootValidator]] = [] + _animal_pre_validators: typing.ClassVar[typing.List[Animal_Dog.Validators.PreAnimalValidator]] = [] + _animal_post_validators: typing.ClassVar[typing.List[Animal_Dog.Validators.AnimalValidator]] = [] + _name_pre_validators: typing.ClassVar[typing.List[Animal_Dog.Validators.PreNameValidator]] = [] + _name_post_validators: typing.ClassVar[typing.List[Animal_Dog.Validators.NameValidator]] = [] + _likes_to_woof_pre_validators: typing.ClassVar[typing.List[Animal_Dog.Validators.PreLikesToWoofValidator]] = [] + _likes_to_woof_post_validators: typing.ClassVar[typing.List[Animal_Dog.Validators.LikesToWoofValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Animal_Dog.Validators._RootValidator], Animal_Dog.Validators._RootValidator]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[[Animal_Dog.Validators._PreRootValidator], Animal_Dog.Validators._PreRootValidator]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["animal"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Animal_Dog.Validators.PreAnimalValidator], Animal_Dog.Validators.PreAnimalValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["animal"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Animal_Dog.Validators.AnimalValidator], Animal_Dog.Validators.AnimalValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Animal_Dog.Validators.PreNameValidator], Animal_Dog.Validators.PreNameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Animal_Dog.Validators.NameValidator], Animal_Dog.Validators.NameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_woof"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [Animal_Dog.Validators.PreLikesToWoofValidator], Animal_Dog.Validators.PreLikesToWoofValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_woof"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [Animal_Dog.Validators.LikesToWoofValidator], Animal_Dog.Validators.LikesToWoofValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "animal": + if pre: + cls._animal_pre_validators.append(validator) + else: + cls._animal_post_validators.append(validator) + if field_name == "name": + if pre: + cls._name_pre_validators.append(validator) + else: + cls._name_post_validators.append(validator) + if field_name == "likes_to_woof": + if pre: + cls._likes_to_woof_pre_validators.append(validator) + else: + cls._likes_to_woof_post_validators.append(validator) + return validator + + return decorator + + class PreAnimalValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Animal_Dog.Partial) -> typing.Any: ... + + class AnimalValidator(typing.Protocol): + def __call__(self, __v: typing.Literal["dog"], __values: Animal_Dog.Partial) -> typing.Literal["dog"]: ... + + class PreNameValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Animal_Dog.Partial) -> typing.Any: ... + + class NameValidator(typing.Protocol): + def __call__(self, __v: str, __values: Animal_Dog.Partial) -> str: ... + + class PreLikesToWoofValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Animal_Dog.Partial) -> typing.Any: ... + + class LikesToWoofValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], + __values: Animal_Dog.Partial, + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: Animal_Dog.Partial) -> Animal_Dog.Partial: ... + + @universal_root_validator(pre=True) + def _pre_validate(cls, values: Animal_Dog.Partial) -> Animal_Dog.Partial: + for validator in Animal_Dog.Validators._pre_validators: + values = validator(values) + return values + + @universal_root_validator(pre=False) + def _post_validate(cls, values: Animal_Dog.Partial) -> Animal_Dog.Partial: + for validator in Animal_Dog.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("animal", pre=True) + def _pre_validate_animal(cls, v: typing.Literal["dog"], values: Animal_Dog.Partial) -> typing.Literal["dog"]: + for validator in Animal_Dog.Validators._animal_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("animal", pre=False) + def _post_validate_animal(cls, v: typing.Literal["dog"], values: Animal_Dog.Partial) -> typing.Literal["dog"]: + for validator in Animal_Dog.Validators._animal_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("name", pre=True) + def _pre_validate_name(cls, v: str, values: Animal_Dog.Partial) -> str: + for validator in Animal_Dog.Validators._name_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("name", pre=False) + def _post_validate_name(cls, v: str, values: Animal_Dog.Partial) -> str: + for validator in Animal_Dog.Validators._name_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_woof", pre=True) + def _pre_validate_likes_to_woof( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], values: Animal_Dog.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: + for validator in Animal_Dog.Validators._likes_to_woof_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_woof", pre=False) + def _post_validate_likes_to_woof( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], values: Animal_Dog.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: + for validator in Animal_Dog.Validators._likes_to_woof_post_validators: + v = validator(v, values) + return v + class Config: frozen = True smart_union = True @@ -24,6 +220,200 @@ class Animal_Cat(UniversalBaseModel): name: str likes_to_meow: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")] + class Partial(typing.TypedDict): + animal: typing_extensions.NotRequired[typing.Literal["cat"]] + name: typing_extensions.NotRequired[str] + likes_to_meow: typing_extensions.NotRequired[ + typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @Animal_Cat.Validators.root() + def validate(values: Animal_Cat.Partial) -> Animal_Cat.Partial: + ... + + @Animal_Cat.Validators.field("animal") + def validate_animal(animal: typing.Literal["cat"], values: Animal_Cat.Partial) -> typing.Literal["cat"]: + ... + + @Animal_Cat.Validators.field("name") + def validate_name(name: str, values: Animal_Cat.Partial) -> str: + ... + + @Animal_Cat.Validators.field("likes_to_meow") + def validate_likes_to_meow(likes_to_meow: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], values: Animal_Cat.Partial) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[Animal_Cat.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[Animal_Cat.Validators._RootValidator]] = [] + _animal_pre_validators: typing.ClassVar[typing.List[Animal_Cat.Validators.PreAnimalValidator]] = [] + _animal_post_validators: typing.ClassVar[typing.List[Animal_Cat.Validators.AnimalValidator]] = [] + _name_pre_validators: typing.ClassVar[typing.List[Animal_Cat.Validators.PreNameValidator]] = [] + _name_post_validators: typing.ClassVar[typing.List[Animal_Cat.Validators.NameValidator]] = [] + _likes_to_meow_pre_validators: typing.ClassVar[typing.List[Animal_Cat.Validators.PreLikesToMeowValidator]] = [] + _likes_to_meow_post_validators: typing.ClassVar[typing.List[Animal_Cat.Validators.LikesToMeowValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Animal_Cat.Validators._RootValidator], Animal_Cat.Validators._RootValidator]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[[Animal_Cat.Validators._PreRootValidator], Animal_Cat.Validators._PreRootValidator]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["animal"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Animal_Cat.Validators.PreAnimalValidator], Animal_Cat.Validators.PreAnimalValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["animal"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Animal_Cat.Validators.AnimalValidator], Animal_Cat.Validators.AnimalValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Animal_Cat.Validators.PreNameValidator], Animal_Cat.Validators.PreNameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Animal_Cat.Validators.NameValidator], Animal_Cat.Validators.NameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_meow"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [Animal_Cat.Validators.PreLikesToMeowValidator], Animal_Cat.Validators.PreLikesToMeowValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_meow"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [Animal_Cat.Validators.LikesToMeowValidator], Animal_Cat.Validators.LikesToMeowValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "animal": + if pre: + cls._animal_pre_validators.append(validator) + else: + cls._animal_post_validators.append(validator) + if field_name == "name": + if pre: + cls._name_pre_validators.append(validator) + else: + cls._name_post_validators.append(validator) + if field_name == "likes_to_meow": + if pre: + cls._likes_to_meow_pre_validators.append(validator) + else: + cls._likes_to_meow_post_validators.append(validator) + return validator + + return decorator + + class PreAnimalValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Animal_Cat.Partial) -> typing.Any: ... + + class AnimalValidator(typing.Protocol): + def __call__(self, __v: typing.Literal["cat"], __values: Animal_Cat.Partial) -> typing.Literal["cat"]: ... + + class PreNameValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Animal_Cat.Partial) -> typing.Any: ... + + class NameValidator(typing.Protocol): + def __call__(self, __v: str, __values: Animal_Cat.Partial) -> str: ... + + class PreLikesToMeowValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Animal_Cat.Partial) -> typing.Any: ... + + class LikesToMeowValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], + __values: Animal_Cat.Partial, + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: Animal_Cat.Partial) -> Animal_Cat.Partial: ... + + @universal_root_validator(pre=True) + def _pre_validate(cls, values: Animal_Cat.Partial) -> Animal_Cat.Partial: + for validator in Animal_Cat.Validators._pre_validators: + values = validator(values) + return values + + @universal_root_validator(pre=False) + def _post_validate(cls, values: Animal_Cat.Partial) -> Animal_Cat.Partial: + for validator in Animal_Cat.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("animal", pre=True) + def _pre_validate_animal(cls, v: typing.Literal["cat"], values: Animal_Cat.Partial) -> typing.Literal["cat"]: + for validator in Animal_Cat.Validators._animal_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("animal", pre=False) + def _post_validate_animal(cls, v: typing.Literal["cat"], values: Animal_Cat.Partial) -> typing.Literal["cat"]: + for validator in Animal_Cat.Validators._animal_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("name", pre=True) + def _pre_validate_name(cls, v: str, values: Animal_Cat.Partial) -> str: + for validator in Animal_Cat.Validators._name_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("name", pre=False) + def _post_validate_name(cls, v: str, values: Animal_Cat.Partial) -> str: + for validator in Animal_Cat.Validators._name_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_meow", pre=True) + def _pre_validate_likes_to_meow( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], values: Animal_Cat.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: + for validator in Animal_Cat.Validators._likes_to_meow_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_meow", pre=False) + def _post_validate_likes_to_meow( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], values: Animal_Cat.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: + for validator in Animal_Cat.Validators._likes_to_meow_post_validators: + v = validator(v, values) + return v + class Config: frozen = True smart_union = True diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/union/types/cat.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/union/types/cat.py index c1fe5a97a0e..8b5951e086f 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/union/types/cat.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/union/types/cat.py @@ -1,8 +1,12 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations from ....core.pydantic_utilities import UniversalBaseModel import typing_extensions from ....core.serialization import FieldMetadata +import typing +from ....core.pydantic_utilities import universal_root_validator +from ....core.pydantic_utilities import universal_field_validator import pydantic @@ -10,6 +14,154 @@ class Cat(UniversalBaseModel): name: str likes_to_meow: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")] + class Partial(typing.TypedDict): + name: typing_extensions.NotRequired[str] + likes_to_meow: typing_extensions.NotRequired[ + typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @Cat.Validators.root() + def validate(values: Cat.Partial) -> Cat.Partial: + ... + + @Cat.Validators.field("name") + def validate_name(name: str, values: Cat.Partial) -> str: + ... + + @Cat.Validators.field("likes_to_meow") + def validate_likes_to_meow(likes_to_meow: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], values: Cat.Partial) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[Cat.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[Cat.Validators._RootValidator]] = [] + _name_pre_validators: typing.ClassVar[typing.List[Cat.Validators.PreNameValidator]] = [] + _name_post_validators: typing.ClassVar[typing.List[Cat.Validators.NameValidator]] = [] + _likes_to_meow_pre_validators: typing.ClassVar[typing.List[Cat.Validators.PreLikesToMeowValidator]] = [] + _likes_to_meow_post_validators: typing.ClassVar[typing.List[Cat.Validators.LikesToMeowValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Cat.Validators._RootValidator], Cat.Validators._RootValidator]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[[Cat.Validators._PreRootValidator], Cat.Validators._PreRootValidator]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Cat.Validators.PreNameValidator], Cat.Validators.PreNameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Cat.Validators.NameValidator], Cat.Validators.NameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_meow"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Cat.Validators.PreLikesToMeowValidator], Cat.Validators.PreLikesToMeowValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_meow"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Cat.Validators.LikesToMeowValidator], Cat.Validators.LikesToMeowValidator]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "name": + if pre: + cls._name_pre_validators.append(validator) + else: + cls._name_post_validators.append(validator) + if field_name == "likes_to_meow": + if pre: + cls._likes_to_meow_pre_validators.append(validator) + else: + cls._likes_to_meow_post_validators.append(validator) + return validator + + return decorator + + class PreNameValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Cat.Partial) -> typing.Any: ... + + class NameValidator(typing.Protocol): + def __call__(self, __v: str, __values: Cat.Partial) -> str: ... + + class PreLikesToMeowValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Cat.Partial) -> typing.Any: ... + + class LikesToMeowValidator(typing.Protocol): + def __call__( + self, __v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], __values: Cat.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: Cat.Partial) -> Cat.Partial: ... + + @universal_root_validator(pre=True) + def _pre_validate_types_cat(cls, values: Cat.Partial) -> Cat.Partial: + for validator in Cat.Validators._pre_validators: + values = validator(values) + return values + + @universal_root_validator(pre=False) + def _post_validate_types_cat(cls, values: Cat.Partial) -> Cat.Partial: + for validator in Cat.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("name", pre=True) + def _pre_validate_name(cls, v: str, values: Cat.Partial) -> str: + for validator in Cat.Validators._name_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("name", pre=False) + def _post_validate_name(cls, v: str, values: Cat.Partial) -> str: + for validator in Cat.Validators._name_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_meow", pre=True) + def _pre_validate_likes_to_meow( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], values: Cat.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: + for validator in Cat.Validators._likes_to_meow_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_meow", pre=False) + def _post_validate_likes_to_meow( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], values: Cat.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: + for validator in Cat.Validators._likes_to_meow_post_validators: + v = validator(v, values) + return v + class Config: frozen = True smart_union = True diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/union/types/dog.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/union/types/dog.py index ab9daa2c4ac..b028725dd24 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/union/types/dog.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/types/union/types/dog.py @@ -1,8 +1,12 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations from ....core.pydantic_utilities import UniversalBaseModel import typing_extensions from ....core.serialization import FieldMetadata +import typing +from ....core.pydantic_utilities import universal_root_validator +from ....core.pydantic_utilities import universal_field_validator import pydantic @@ -10,6 +14,154 @@ class Dog(UniversalBaseModel): name: str likes_to_woof: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")] + class Partial(typing.TypedDict): + name: typing_extensions.NotRequired[str] + likes_to_woof: typing_extensions.NotRequired[ + typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @Dog.Validators.root() + def validate(values: Dog.Partial) -> Dog.Partial: + ... + + @Dog.Validators.field("name") + def validate_name(name: str, values: Dog.Partial) -> str: + ... + + @Dog.Validators.field("likes_to_woof") + def validate_likes_to_woof(likes_to_woof: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], values: Dog.Partial) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[Dog.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[Dog.Validators._RootValidator]] = [] + _name_pre_validators: typing.ClassVar[typing.List[Dog.Validators.PreNameValidator]] = [] + _name_post_validators: typing.ClassVar[typing.List[Dog.Validators.NameValidator]] = [] + _likes_to_woof_pre_validators: typing.ClassVar[typing.List[Dog.Validators.PreLikesToWoofValidator]] = [] + _likes_to_woof_post_validators: typing.ClassVar[typing.List[Dog.Validators.LikesToWoofValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Dog.Validators._RootValidator], Dog.Validators._RootValidator]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[[Dog.Validators._PreRootValidator], Dog.Validators._PreRootValidator]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Dog.Validators.PreNameValidator], Dog.Validators.PreNameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Dog.Validators.NameValidator], Dog.Validators.NameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_woof"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Dog.Validators.PreLikesToWoofValidator], Dog.Validators.PreLikesToWoofValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_woof"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Dog.Validators.LikesToWoofValidator], Dog.Validators.LikesToWoofValidator]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "name": + if pre: + cls._name_pre_validators.append(validator) + else: + cls._name_post_validators.append(validator) + if field_name == "likes_to_woof": + if pre: + cls._likes_to_woof_pre_validators.append(validator) + else: + cls._likes_to_woof_post_validators.append(validator) + return validator + + return decorator + + class PreNameValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Dog.Partial) -> typing.Any: ... + + class NameValidator(typing.Protocol): + def __call__(self, __v: str, __values: Dog.Partial) -> str: ... + + class PreLikesToWoofValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Dog.Partial) -> typing.Any: ... + + class LikesToWoofValidator(typing.Protocol): + def __call__( + self, __v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], __values: Dog.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: Dog.Partial) -> Dog.Partial: ... + + @universal_root_validator(pre=True) + def _pre_validate_types_dog(cls, values: Dog.Partial) -> Dog.Partial: + for validator in Dog.Validators._pre_validators: + values = validator(values) + return values + + @universal_root_validator(pre=False) + def _post_validate_types_dog(cls, values: Dog.Partial) -> Dog.Partial: + for validator in Dog.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("name", pre=True) + def _pre_validate_name(cls, v: str, values: Dog.Partial) -> str: + for validator in Dog.Validators._name_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("name", pre=False) + def _post_validate_name(cls, v: str, values: Dog.Partial) -> str: + for validator in Dog.Validators._name_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_woof", pre=True) + def _pre_validate_likes_to_woof( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], values: Dog.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: + for validator in Dog.Validators._likes_to_woof_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_woof", pre=False) + def _post_validate_likes_to_woof( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], values: Dog.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: + for validator in Dog.Validators._likes_to_woof_post_validators: + v = validator(v, values) + return v + class Config: frozen = True smart_union = True diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.github/workflows/ci.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.github/workflows/ci.yml new file mode 100644 index 00000000000..b7316b8cab7 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.github/workflows/ci.yml @@ -0,0 +1,63 @@ +name: ci + +on: [push] +jobs: + compile: + runs-on: ubuntu-20.04 + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Set up python + uses: actions/setup-python@v4 + with: + python-version: 3.8 + - name: Bootstrap poetry + run: | + curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1 + - name: Install dependencies + run: poetry install + - name: Compile + run: poetry run mypy . + test: + runs-on: ubuntu-20.04 + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Set up python + uses: actions/setup-python@v4 + with: + python-version: 3.8 + - name: Bootstrap poetry + run: | + curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1 + - name: Install dependencies + run: poetry install + + - name: Install Fern + run: npm install -g fern-api + - name: Test + run: fern test --command "poetry run pytest -rP ." + + publish: + needs: [compile, test] + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ubuntu-20.04 + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Set up python + uses: actions/setup-python@v4 + with: + python-version: 3.8 + - name: Bootstrap poetry + run: | + curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1 + - name: Install dependencies + run: poetry install + - name: Publish to pypi + run: | + poetry config repositories.remote + poetry --no-interaction -v publish --build --repository remote --username "$" --password "$" + env: + : ${{ secrets. }} + : ${{ secrets. }} diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.gitignore b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.gitignore new file mode 100644 index 00000000000..0da665feeef --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.gitignore @@ -0,0 +1,5 @@ +dist/ +.mypy_cache/ +__pycache__/ +poetry.toml +.ruff_cache/ diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/api.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/api.yml new file mode 100644 index 00000000000..dd65915538f --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/api.yml @@ -0,0 +1,4 @@ +name: exhaustive +auth: bearer +error-discrimination: + strategy: status-code diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/container.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/container.yml new file mode 100644 index 00000000000..165a039dc65 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/container.yml @@ -0,0 +1,48 @@ +imports: + objects: ../types/object.yml + +service: + auth: true + base-path: /container + endpoints: + getAndReturnListOfPrimitives: + path: /list-of-primitives + method: POST + request: list + response: list + + getAndReturnListOfObjects: + path: /list-of-objects + method: POST + request: list + response: list + + getAndReturnSetOfPrimitives: + path: /set-of-primitives + method: POST + request: set + response: set + + getAndReturnSetOfObjects: + path: /set-of-objects + method: POST + request: set + response: set + + getAndReturnMapPrimToPrim: + path: /map-prim-to-prim + method: POST + request: map + response: map + + getAndReturnMapOfPrimToObject: + path: /map-prim-to-object + method: POST + request: map + response: map + + getAndReturnOptional: + path: /opt-objects + method: POST + request: optional + response: optional diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/enum.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/enum.yml new file mode 100644 index 00000000000..335a0889cc7 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/enum.yml @@ -0,0 +1,12 @@ +imports: + enums: ../types/enum.yml + +service: + auth: true + base-path: /enum + endpoints: + getAndReturnEnum: + method: POST + path: "" + request: enums.WeatherReport + response: enums.WeatherReport diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/http-methods.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/http-methods.yml new file mode 100644 index 00000000000..51a54c0802c --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/http-methods.yml @@ -0,0 +1,43 @@ +imports: + objects: ../types/object.yml + +service: + auth: true + base-path: /http-methods + + endpoints: + testGet: + method: GET + path: /{id} + path-parameters: + id: string + response: string + + testPost: + method: POST + path: "" + request: objects.ObjectWithRequiredField + response: objects.ObjectWithOptionalField + + testPut: + method: PUT + path: /{id} + path-parameters: + id: string + request: objects.ObjectWithRequiredField + response: objects.ObjectWithOptionalField + + testPatch: + method: PATCH + path: /{id} + path-parameters: + id: string + request: objects.ObjectWithOptionalField + response: objects.ObjectWithOptionalField + + testDelete: + method: DELETE + path: /{id} + path-parameters: + id: string + response: boolean diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/object.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/object.yml new file mode 100644 index 00000000000..9fad6aa2776 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/object.yml @@ -0,0 +1,44 @@ +imports: + objects: ../types/object.yml + +service: + auth: true + base-path: /object + endpoints: + getAndReturnWithOptionalField: + path: /get-and-return-with-optional-field + method: POST + request: objects.ObjectWithOptionalField + response: objects.ObjectWithOptionalField + + getAndReturnWithRequiredField: + path: /get-and-return-with-required-field + method: POST + request: objects.ObjectWithRequiredField + response: objects.ObjectWithRequiredField + + getAndReturnWithMapOfMap: + path: /get-and-return-with-map-of-map + method: POST + request: objects.ObjectWithMapOfMap + response: objects.ObjectWithMapOfMap + + getAndReturnNestedWithOptionalField: + path: /get-and-return-nested-with-optional-field + method: POST + request: objects.NestedObjectWithOptionalField + response: objects.NestedObjectWithOptionalField + + getAndReturnNestedWithRequiredField: + path: /get-and-return-nested-with-required-field/{string} + method: POST + path-parameters: + string: string + request: objects.NestedObjectWithRequiredField + response: objects.NestedObjectWithRequiredField + + getAndReturnNestedWithRequiredFieldAsList: + path: /get-and-return-nested-with-required-field-list + method: POST + request: list + response: objects.NestedObjectWithRequiredField diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/params.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/params.yml new file mode 100644 index 00000000000..7766547ad79 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/params.yml @@ -0,0 +1,57 @@ +service: + auth: true + base-path: /params + endpoints: + getWithPath: + docs: GET with path param + path: /path/{param} + path-parameters: + param: string + method: GET + response: string + + getWithQuery: + docs: GET with query param + path: "" + method: GET + request: + name: GetWithQuery + query-parameters: + query: string #mandatory for test + number: integer + + getWithAllowMultipleQuery: + docs: GET with multiple of same query param + path: "" + method: GET + request: + name: GetWithMultipleQuery + query-parameters: + query: + type: string + allow-multiple: true + numer: + type: integer + allow-multiple: true + + getWithPathAndQuery: + docs: GET with path and query params + path: /path-query/{param} + path-parameters: + param: string + method: GET + request: + name: GetWithPathAndQuery + query-parameters: + query: string #mandatory for test + + modifyWithPath: + docs: PUT to update with path param + path: /path/{param} + path-parameters: + param: string + method: PUT + request: + name: ModifyResourceAtPath + body: string + response: string diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/primitive.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/primitive.yml new file mode 100644 index 00000000000..8dd7674164c --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/primitive.yml @@ -0,0 +1,60 @@ +imports: + objects: ../types/object.yml + +service: + auth: true + base-path: /primitive + endpoints: + getAndReturnString: + path: /string + method: POST + request: string + response: string + + getAndReturnInt: + path: /integer + method: POST + request: integer + response: integer + + getAndReturnLong: + path: /long + method: POST + request: long + response: long + + getAndReturnDouble: + path: /double + method: POST + request: double + response: double + + getAndReturnBool: + path: /boolean + method: POST + request: boolean + response: boolean + + getAndReturnDatetime: + path: /datetime + method: POST + request: datetime + response: datetime + + getAndReturnDate: + path: /date + method: POST + request: date + response: date + + getAndReturnUUID: + path: /uuid + method: POST + request: uuid + response: uuid + + getAndReturnBase64: + path: /base64 + method: POST + request: base64 + response: base64 diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/union.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/union.yml new file mode 100644 index 00000000000..ce9021160d7 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/endpoints/union.yml @@ -0,0 +1,12 @@ +imports: + unions: ../types/union.yml + +service: + auth: true + base-path: /union + endpoints: + getAndReturnUnion: + method: POST + path: "" + request: unions.Animal + response: unions.Animal diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/general-errors.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/general-errors.yml new file mode 100644 index 00000000000..5fbf9cfc417 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/general-errors.yml @@ -0,0 +1,9 @@ +errors: + BadRequestBody: + status-code: 400 + type: BadObjectRequestInfo + +types: + BadObjectRequestInfo: + properties: + message: string diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/inlined-requests.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/inlined-requests.yml new file mode 100644 index 00000000000..9347fe7e335 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/inlined-requests.yml @@ -0,0 +1,25 @@ +imports: + objects: ./types/object.yml + errors: ./general-errors.yml + +# test req bodies, path params, query params, multiple query params, etc. +# test union and enum as well + +service: + auth: false + base-path: /req-bodies + endpoints: + postWithObjectBodyandResponse: + docs: POST with custom object in request body, response is an object + path: /object + method: POST + request: + name: PostWithObjectBody + body: + properties: + string: string + integer: integer + NestedObject: objects.ObjectWithOptionalField + response: objects.ObjectWithOptionalField + errors: + - errors.BadRequestBody diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/no-auth.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/no-auth.yml new file mode 100644 index 00000000000..e3c33ed7fab --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/no-auth.yml @@ -0,0 +1,20 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json + +imports: + general-errors: ./general-errors.yml + +service: + auth: false + base-path: /no-auth + endpoints: + postWithNoAuth: + auth: false + docs: POST request with no auth + path: "" + method: POST + request: + name: PostWithNoAuth + body: unknown + response: boolean + errors: + - general-errors.BadRequestBody diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/no-req-body.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/no-req-body.yml new file mode 100644 index 00000000000..daffd9a495c --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/no-req-body.yml @@ -0,0 +1,16 @@ +imports: + objects: ./types/object.yml + +service: + auth: true + base-path: /no-req-body + endpoints: + getWithNoRequestBody: + path: "" + method: GET + response: objects.ObjectWithOptionalField + + postWithNoRequestBody: + path: "" + method: POST + response: string diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/req-with-headers.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/req-with-headers.yml new file mode 100644 index 00000000000..9e49725782f --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/req-with-headers.yml @@ -0,0 +1,14 @@ +service: + base-path: /test-headers + auth: true + headers: + X-TEST-SERVICE-HEADER: string + endpoints: + getWithCustomHeader: + path: /custom-header + method: POST + request: + name: ReqWithHeaders + headers: + X-TEST-ENDPOINT-HEADER: string + body: string diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/types/enum.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/types/enum.yml new file mode 100644 index 00000000000..a90686092e9 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/types/enum.yml @@ -0,0 +1,12 @@ +types: + WeatherReport: + enum: + - SUNNY + - CLOUDY + - RAINING + - SNOWING + +errors: + ErrorWithEnumBody: + status-code: 400 + type: WeatherReport #does this even make sense? the type of the error body would be enum, and it could only be one of the 4 values? diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/types/object.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/types/object.yml new file mode 100644 index 00000000000..a165ed94cfe --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/types/object.yml @@ -0,0 +1,59 @@ +types: + ObjectWithOptionalField: #generic object that supports any type, makes it easier to use when testing + properties: + string: + type: optional + docs: This is a rather long descriptor of this single field in a more complex type. If you ask me I think this is a pretty good description for this field all things considered. + integer: optional + long: optional + double: optional + bool: optional + datetime: optional + date: optional + uuid: optional + base64: optional + list: optional> + set: optional> + map: optional> + bigint: optional + + ObjectWithRequiredField: + properties: + string: string + + ObjectWithMapOfMap: + properties: + map: map> + + NestedObjectWithOptionalField: + properties: + string: optional + NestedObject: optional + + NestedObjectWithRequiredField: + properties: + string: string + NestedObject: ObjectWithOptionalField + + DoubleOptional: + properties: + optionalAlias: optional + + OptionalAlias: optional + +errors: + ObjectWithOptionalFieldError: + status-code: 400 + type: ObjectWithOptionalField + + ObjectWithRequiredFieldError: + status-code: 400 + type: ObjectWithRequiredField + + NestedObjectWithOptionalFieldError: + status-code: 400 + type: NestedObjectWithOptionalField + + NestedObjectWithRequiredFieldError: + status-code: 400 + type: NestedObjectWithRequiredField diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/types/union.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/types/union.yml new file mode 100644 index 00000000000..99ce8c75ed0 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/definition/types/union.yml @@ -0,0 +1,21 @@ +types: + Animal: + discriminant: animal + union: + dog: Dog + cat: Cat + + Dog: + properties: + name: string + likesToWoof: boolean + + Cat: + properties: + name: string + likesToMeow: boolean + +errors: + ErrorWithUnionBody: + status-code: 400 + type: Animal #has to send either dog or cat object in error body diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/fern.config.json b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/fern.config.json new file mode 100644 index 00000000000..4c8e54ac313 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/fern.config.json @@ -0,0 +1 @@ +{"organization": "fern-test", "version": "*"} \ No newline at end of file diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/generators.yml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/generators.yml new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/.mock/generators.yml @@ -0,0 +1 @@ +{} diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/README.md b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/README.md new file mode 100644 index 00000000000..1088758f90b --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/README.md @@ -0,0 +1,140 @@ +# Seed Python Library + +[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=Seed%2FPython) +[![pypi](https://img.shields.io/pypi/v/fern_exhaustive)](https://pypi.python.org/pypi/fern_exhaustive) + +The Seed Python library provides convenient access to the Seed API from Python. + +## Installation + +```sh +pip install fern_exhaustive +``` + +## Reference + +A full reference for this library is available [here](./reference.md). + +## Usage + +Instantiate and use the client with the following: + +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.container.get_and_return_list_of_primitives( + request=["string", "string"], +) +``` + +## Async Client + +The SDK also exports an `async` client so that you can make non-blocking calls to our API. + +```python +import asyncio + +from seed import AsyncSeedExhaustive + +client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) + + +async def main() -> None: + await client.endpoints.container.get_and_return_list_of_primitives( + request=["string", "string"], + ) + + +asyncio.run(main()) +``` + +## Exception Handling + +When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error +will be thrown. + +```python +from seed.core.api_error import ApiError + +try: + client.endpoints.container.get_and_return_list_of_primitives(...) +except ApiError as e: + print(e.status_code) + print(e.body) +``` + +## Advanced + +### Retries + +The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long +as the request is deemed retriable and the number of retry attempts has not grown larger than the configured +retry limit (default: 2). + +A request is deemed retriable when any of the following HTTP status codes is returned: + +- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout) +- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests) +- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors) + +Use the `max_retries` request option to configure this behavior. + +```python +client.endpoints.container.get_and_return_list_of_primitives(..., request_options={ + "max_retries": 1 +}) +``` + +### Timeouts + +The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level. + +```python + +from seed import SeedExhaustive + +client = SeedExhaustive( + ..., + timeout=20.0, +) + + +# Override timeout for a specific method +client.endpoints.container.get_and_return_list_of_primitives(..., request_options={ + "timeout_in_seconds": 1 +}) +``` + +### Custom Client + +You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies +and transports. +```python +import httpx +from seed import SeedExhaustive + +client = SeedExhaustive( + ..., + httpx_client=httpx.Client( + proxies="http://my.test.proxy.example.com", + transport=httpx.HTTPTransport(local_address="0.0.0.0"), + ), +) +``` + +## Contributing + +While we value open-source contributions to this SDK, this library is generated programmatically. +Additions made directly to this library would have to be moved over to our generation code, +otherwise they would be overwritten upon the next generated release. Feel free to open a PR as +a proof of concept, but know that we will not be able to merge it as-is. We suggest opening +an issue first to discuss with us! + +On the other hand, contributions to the README are always very welcome! diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/pyproject.toml b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/pyproject.toml new file mode 100644 index 00000000000..e38c5c44634 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/pyproject.toml @@ -0,0 +1,61 @@ +[tool.poetry] +name = "fern_exhaustive" +version = "0.0.1" +description = "" +readme = "README.md" +authors = [] +keywords = [] + +classifiers = [ + "Intended Audience :: Developers", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Operating System :: OS Independent", + "Operating System :: POSIX", + "Operating System :: MacOS", + "Operating System :: POSIX :: Linux", + "Operating System :: Microsoft :: Windows", + "Topic :: Software Development :: Libraries :: Python Modules", + "Typing :: Typed" +] +packages = [ + { include = "seed", from = "src"} +] + +[project.urls] +Repository = 'https://github.com/exhaustive/fern' + +[tool.poetry.dependencies] +python = "^3.8" +httpx = ">=0.21.2" +pydantic = ">= 2.0.0" +pydantic-core = "^2.18.2" +typing_extensions = ">= 4.0.0" + +[tool.poetry.dev-dependencies] +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" ] +asyncio_mode = "auto" + +[tool.mypy] +plugins = ["pydantic.mypy"] + +[tool.ruff] +line-length = 120 + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/reference.md b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/reference.md new file mode 100644 index 00000000000..d7004e0c609 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/reference.md @@ -0,0 +1,2829 @@ +# Reference +## Endpoints Container +
client.endpoints.container.get_and_return_list_of_primitives(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.container.get_and_return_list_of_primitives( + request=["string", "string"], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `typing.Sequence[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.container.get_and_return_list_of_objects(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive +from seed.types.object import ObjectWithRequiredField + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.container.get_and_return_list_of_objects( + request=[ + ObjectWithRequiredField( + string="string", + ), + ObjectWithRequiredField( + string="string", + ), + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `typing.Sequence[ObjectWithRequiredField]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.container.get_and_return_set_of_primitives(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.container.get_and_return_set_of_primitives( + request={"string"}, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `typing.Set[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.container.get_and_return_set_of_objects(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive +from seed.types.object import ObjectWithRequiredField + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.container.get_and_return_set_of_objects( + request=[ + ObjectWithRequiredField( + string="string", + ) + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `typing.Sequence[ObjectWithRequiredField]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.container.get_and_return_map_prim_to_prim(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.container.get_and_return_map_prim_to_prim( + request={"string": "string"}, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `typing.Dict[str, str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.container.get_and_return_map_of_prim_to_object(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive +from seed.types.object import ObjectWithRequiredField + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.container.get_and_return_map_of_prim_to_object( + request={ + "string": ObjectWithRequiredField( + string="string", + ) + }, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `typing.Dict[str, ObjectWithRequiredField]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.container.get_and_return_optional(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive +from seed.types.object import ObjectWithRequiredField + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.container.get_and_return_optional( + request=ObjectWithRequiredField( + string="string", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `typing.Optional[ObjectWithRequiredField]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Endpoints Enum +
client.endpoints.enum.get_and_return_enum(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.enum.get_and_return_enum( + request="SUNNY", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `WeatherReport` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Endpoints HttpMethods +
client.endpoints.http_methods.test_get(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.http_methods.test_get( + id="id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.http_methods.test_post(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.http_methods.test_post( + string="string", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**string:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.http_methods.test_put(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.http_methods.test_put( + id="id", + string="string", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` + +
+
+ +
+
+ +**string:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.http_methods.test_patch(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime +import uuid + +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.http_methods.test_patch( + id="id", + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` + +
+
+ +
+
+ +**string:** `typing.Optional[str]` — This is a rather long descriptor of this single field in a more complex type. If you ask me I think this is a pretty good description for this field all things considered. + +
+
+ +
+
+ +**integer:** `typing.Optional[int]` + +
+
+ +
+
+ +**long_:** `typing.Optional[int]` + +
+
+ +
+
+ +**double:** `typing.Optional[float]` + +
+
+ +
+
+ +**bool_:** `typing.Optional[bool]` + +
+
+ +
+
+ +**datetime:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**date:** `typing.Optional[dt.date]` + +
+
+ +
+
+ +**uuid_:** `typing.Optional[uuid.UUID]` + +
+
+ +
+
+ +**base_64:** `typing.Optional[str]` + +
+
+ +
+
+ +**list_:** `typing.Optional[typing.Sequence[str]]` + +
+
+ +
+
+ +**set_:** `typing.Optional[typing.Set[str]]` + +
+
+ +
+
+ +**map_:** `typing.Optional[typing.Dict[int, str]]` + +
+
+ +
+
+ +**bigint:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.http_methods.test_delete(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.http_methods.test_delete( + id="id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Endpoints Object +
client.endpoints.object.get_and_return_with_optional_field(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime +import uuid + +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.object.get_and_return_with_optional_field( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**string:** `typing.Optional[str]` — This is a rather long descriptor of this single field in a more complex type. If you ask me I think this is a pretty good description for this field all things considered. + +
+
+ +
+
+ +**integer:** `typing.Optional[int]` + +
+
+ +
+
+ +**long_:** `typing.Optional[int]` + +
+
+ +
+
+ +**double:** `typing.Optional[float]` + +
+
+ +
+
+ +**bool_:** `typing.Optional[bool]` + +
+
+ +
+
+ +**datetime:** `typing.Optional[dt.datetime]` + +
+
+ +
+
+ +**date:** `typing.Optional[dt.date]` + +
+
+ +
+
+ +**uuid_:** `typing.Optional[uuid.UUID]` + +
+
+ +
+
+ +**base_64:** `typing.Optional[str]` + +
+
+ +
+
+ +**list_:** `typing.Optional[typing.Sequence[str]]` + +
+
+ +
+
+ +**set_:** `typing.Optional[typing.Set[str]]` + +
+
+ +
+
+ +**map_:** `typing.Optional[typing.Dict[int, str]]` + +
+
+ +
+
+ +**bigint:** `typing.Optional[str]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.object.get_and_return_with_required_field(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.object.get_and_return_with_required_field( + string="string", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**string:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.object.get_and_return_with_map_of_map(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.object.get_and_return_with_map_of_map( + map_={"map": {"map": "map"}}, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**map_:** `typing.Dict[str, typing.Dict[str, str]]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.object.get_and_return_nested_with_optional_field(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime +import uuid + +from seed import SeedExhaustive +from seed.types.object import ObjectWithOptionalField + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.object.get_and_return_nested_with_optional_field( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**string:** `typing.Optional[str]` + +
+
+ +
+
+ +**nested_object:** `typing.Optional[ObjectWithOptionalField]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.object.get_and_return_nested_with_required_field(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime +import uuid + +from seed import SeedExhaustive +from seed.types.object import ObjectWithOptionalField + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.object.get_and_return_nested_with_required_field( + string_="string", + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**string_:** `str` + +
+
+ +
+
+ +**string:** `str` + +
+
+ +
+
+ +**nested_object:** `ObjectWithOptionalField` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.object.get_and_return_nested_with_required_field_as_list(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime +import uuid + +from seed import SeedExhaustive +from seed.types.object import ( + NestedObjectWithRequiredField, + ObjectWithOptionalField, +) + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.object.get_and_return_nested_with_required_field_as_list( + request=[ + NestedObjectWithRequiredField( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ), + NestedObjectWithRequiredField( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ), + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `typing.Sequence[NestedObjectWithRequiredField]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Endpoints Params +
client.endpoints.params.get_with_path(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +GET with path param +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.params.get_with_path( + param="param", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**param:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.params.get_with_query(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +GET with query param +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.params.get_with_query( + query="query", + number=1, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**query:** `str` + +
+
+ +
+
+ +**number:** `int` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.params.get_with_allow_multiple_query(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +GET with multiple of same query param +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.params.get_with_allow_multiple_query( + query="query", + numer=1, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**query:** `typing.Union[str, typing.Sequence[str]]` + +
+
+ +
+
+ +**numer:** `typing.Union[int, typing.Sequence[int]]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.params.get_with_path_and_query(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +GET with path and query params +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.params.get_with_path_and_query( + param="param", + query="query", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**param:** `str` + +
+
+ +
+
+ +**query:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.params.modify_with_path(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +PUT to update with path param +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.params.modify_with_path( + param="param", + request="string", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**param:** `str` + +
+
+ +
+
+ +**request:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Endpoints Primitive +
client.endpoints.primitive.get_and_return_string(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.primitive.get_and_return_string( + request="string", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.primitive.get_and_return_int(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.primitive.get_and_return_int( + request=1, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `int` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.primitive.get_and_return_long(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.primitive.get_and_return_long( + request=1000000, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `int` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.primitive.get_and_return_double(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.primitive.get_and_return_double( + request=1.1, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `float` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.primitive.get_and_return_bool(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.primitive.get_and_return_bool( + request=True, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `bool` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.primitive.get_and_return_datetime(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime + +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.primitive.get_and_return_datetime( + request=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `dt.datetime` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.primitive.get_and_return_date(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime + +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.primitive.get_and_return_date( + request=datetime.date.fromisoformat( + "2023-01-15", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `dt.date` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.primitive.get_and_return_uuid(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import uuid + +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.primitive.get_and_return_uuid( + request=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `uuid.UUID` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.endpoints.primitive.get_and_return_base_64(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.primitive.get_and_return_base_64( + request="SGVsbG8gd29ybGQh", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Endpoints Union +
client.endpoints.union.get_and_return_union(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive +from seed.types.union import Animal_Dog + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.endpoints.union.get_and_return_union( + request=Animal_Dog( + name="name", + likes_to_woof=True, + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Animal` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## InlinedRequests +
client.inlined_requests.post_with_object_bodyand_response(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +POST with custom object in request body, response is an object +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +import datetime +import uuid + +from seed import SeedExhaustive +from seed.types.object import ObjectWithOptionalField + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.inlined_requests.post_with_object_bodyand_response( + string="string", + integer=1, + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**string:** `str` + +
+
+ +
+
+ +**integer:** `int` + +
+
+ +
+
+ +**nested_object:** `ObjectWithOptionalField` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## NoAuth +
client.no_auth.post_with_no_auth(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +POST request with no auth +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.no_auth.post_with_no_auth( + request={"key": "value"}, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `typing.Optional[typing.Any]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## NoReqBody +
client.no_req_body.get_with_no_request_body() +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.no_req_body.get_with_no_request_body() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.no_req_body.post_with_no_request_body() +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.no_req_body.post_with_no_request_body() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## ReqWithHeaders +
client.req_with_headers.get_with_custom_header(...) +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from seed import SeedExhaustive + +client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", +) +client.req_with_headers.get_with_custom_header( + x_test_service_header="X-TEST-SERVICE-HEADER", + x_test_endpoint_header="X-TEST-ENDPOINT-HEADER", + request="string", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**x_test_service_header:** `str` + +
+
+ +
+
+ +**x_test_endpoint_header:** `str` + +
+
+ +
+
+ +**request:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/resolved-snippet-templates.md b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/resolved-snippet-templates.md new file mode 100644 index 00000000000..df18e904d60 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/resolved-snippet-templates.md @@ -0,0 +1,593 @@ +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.container.get_and_return_list_of_primitives( + request=[ + "string", + "string" + ] +) + +``` + + +```python +from seed import SeedExhaustive +from seed.types.object import ObjectWithRequiredField + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.container.get_and_return_list_of_objects( + request=[ + ObjectWithRequiredField( + string="string" + ), + ObjectWithRequiredField( + string="string" + ) + ] +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.container.get_and_return_set_of_primitives( + +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.container.get_and_return_set_of_objects( + +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.container.get_and_return_map_prim_to_prim( + request={ + "string": "string" + } +) + +``` + + +```python +from seed import SeedExhaustive +from seed.types.object import ObjectWithRequiredField + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.container.get_and_return_map_of_prim_to_object( + request={ + "string": ObjectWithRequiredField( + string="string" + ) + } +) + +``` + + +```python +from seed import SeedExhaustive +from seed.types.object import ObjectWithRequiredField + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.container.get_and_return_optional( + request=ObjectWithRequiredField( + string="string" + ) +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +undefined + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.http_methods.test_get( + id="id" +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.http_methods.test_post( + string="string" +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.http_methods.test_put( + id="id", + string="string" +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.http_methods.test_patch( + id="id", + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=true, + datetime="2024-01-15T09:30:00Z", + date="2023-01-15", + uuid_="d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + base_64="SGVsbG8gd29ybGQh", + list_=[ + "list", + "list" + ], + map_={ + "1": "map" + }, + bigint="1000000" +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.http_methods.test_delete( + id="id" +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.object.get_and_return_with_optional_field( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=true, + datetime="2024-01-15T09:30:00Z", + date="2023-01-15", + uuid_="d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + base_64="SGVsbG8gd29ybGQh", + list_=[ + "list", + "list" + ], + map_={ + "1": "map" + }, + bigint="1000000" +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.object.get_and_return_with_required_field( + string="string" +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.object.get_and_return_with_map_of_map( + map_={ + "map": { + "map": "map" + } + } +) + +``` + + +```python +from seed import SeedExhaustive +from seed.types.object import ObjectWithOptionalField + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.object.get_and_return_nested_with_optional_field( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=true, + datetime="2024-01-15T09:30:00Z", + date="2023-01-15", + uuid_="d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + base_64="SGVsbG8gd29ybGQh", + list_=[ + "list", + "list" + ], + map_={ + "1": "map" + }, + bigint="1000000" + ) +) + +``` + + +```python +from seed import SeedExhaustive +from seed.types.object import ObjectWithOptionalField + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.object.get_and_return_nested_with_required_field( + string="string", + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=true, + datetime="2024-01-15T09:30:00Z", + date="2023-01-15", + uuid_="d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + base_64="SGVsbG8gd29ybGQh", + list_=[ + "list", + "list" + ], + map_={ + "1": "map" + }, + bigint="1000000" + ) +) + +``` + + +```python +from seed import SeedExhaustive +from seed.types.object import NestedObjectWithRequiredField +from seed.types.object import ObjectWithOptionalField + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.object.get_and_return_nested_with_required_field_as_list( + request=[ + NestedObjectWithRequiredField( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=true, + datetime="2024-01-15T09:30:00Z", + date="2023-01-15", + uuid_="d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + base_64="SGVsbG8gd29ybGQh", + map_={ + "1": "map" + }, + bigint="1000000" + ) + ), + NestedObjectWithRequiredField( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=true, + datetime="2024-01-15T09:30:00Z", + date="2023-01-15", + uuid_="d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + base_64="SGVsbG8gd29ybGQh", + map_={ + "1": "map" + }, + bigint="1000000" + ) + ) + ] +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.params.get_with_path( + param="param" +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.params.get_with_query( + query="query", + number=1 +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.params.get_with_allow_multiple_query( + query="query", + numer=1 +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.params.get_with_path_and_query( + param="param", + query="query" +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.params.modify_with_path( + param="param", + request="string" +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.primitive.get_and_return_string( + request="string" +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.primitive.get_and_return_int( + request=1 +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.primitive.get_and_return_long( + request=1000000 +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.primitive.get_and_return_double( + request=1.1 +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.primitive.get_and_return_bool( + request=true +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.primitive.get_and_return_datetime( + request="2024-01-15T09:30:00Z" +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.primitive.get_and_return_date( + request="2023-01-15" +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.primitive.get_and_return_uuid( + request="d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32" +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.primitive.get_and_return_base_64( + request="SGVsbG8gd29ybGQh" +) + +``` + + +```python +from seed import SeedExhaustive +from seed.types.union import Animal_Dog + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.endpoints.union.get_and_return_union( + request=request=Animal_Dog(name="name", likes_to_woof=true, ) +) + +``` + + +```python +from seed import SeedExhaustive +from seed.types.object import ObjectWithOptionalField + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.inlined_requests.post_with_object_bodyand_response( + string="string", + integer=1, + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=true, + datetime="2024-01-15T09:30:00Z", + date="2023-01-15", + uuid_="d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + base_64="SGVsbG8gd29ybGQh", + list_=[ + "list", + "list" + ], + map_={ + "1": "map" + }, + bigint="1000000" + ) +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.no_auth.post_with_no_auth( + request={"key":"value"} +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.no_req_body.get_with_no_request_body( + +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.no_req_body.post_with_no_request_body( + +) + +``` + + +```python +from seed import SeedExhaustive + +client = SeedExhaustive(base_url="https://yourhost.com/path/to/api", token="YOUR_TOKEN", ) +client.req_with_headers.get_with_custom_header( + x_test_endpoint_header="X-TEST-ENDPOINT-HEADER", + request="string" +) + +``` + + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/snippet-templates.json b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/snippet-templates.json new file mode 100644 index 00000000000..65dfae3aba5 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/snippet-templates.json @@ -0,0 +1,8324 @@ +[ + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/container/list-of-primitives", + "method": "POST", + "identifierOverride": "endpoint_endpoints/container.getAndReturnListOfPrimitives" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.container.get_and_return_list_of_primitives(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "request=[\n\t\t$FERN_INPUT\n\t]", + "delimiter": ",\n\t\t", + "innerTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": null + }, + "type": "iterable" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.container.get_and_return_list_of_primitives(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "request=[\n\t\t$FERN_INPUT\n\t]", + "delimiter": ",\n\t\t", + "innerTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": null + }, + "type": "iterable" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/container/list-of-objects", + "method": "POST", + "identifierOverride": "endpoint_endpoints/container.getAndReturnListOfObjects" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.container.get_and_return_list_of_objects(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "request=[\n\t\t$FERN_INPUT\n\t]", + "delimiter": ",\n\t\t", + "innerTemplate": { + "imports": [ + "from seed.types.object import ObjectWithRequiredField" + ], + "isOptional": true, + "templateString": "ObjectWithRequiredField(\n\t\t\t$FERN_INPUT\n\t\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t\t", + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": null + }, + "type": "iterable" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.container.get_and_return_list_of_objects(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "request=[\n\t\t$FERN_INPUT\n\t]", + "delimiter": ",\n\t\t", + "innerTemplate": { + "imports": [ + "from seed.types.object import ObjectWithRequiredField" + ], + "isOptional": true, + "templateString": "ObjectWithRequiredField(\n\t\t\t$FERN_INPUT\n\t\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t\t", + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": null + }, + "type": "iterable" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/container/set-of-primitives", + "method": "POST", + "identifierOverride": "endpoint_endpoints/container.getAndReturnSetOfPrimitives" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.container.get_and_return_set_of_primitives(\n\t$FERN_INPUT\n)", + "templateInputs": [], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.container.get_and_return_set_of_primitives(\n\t$FERN_INPUT\n)", + "templateInputs": [], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/container/set-of-objects", + "method": "POST", + "identifierOverride": "endpoint_endpoints/container.getAndReturnSetOfObjects" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.container.get_and_return_set_of_objects(\n\t$FERN_INPUT\n)", + "templateInputs": [], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.container.get_and_return_set_of_objects(\n\t$FERN_INPUT\n)", + "templateInputs": [], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/container/map-prim-to-prim", + "method": "POST", + "identifierOverride": "endpoint_endpoints/container.getAndReturnMapPrimToPrim" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.container.get_and_return_map_prim_to_prim(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "request={\n\t\t$FERN_INPUT\n\t}", + "delimiter": ",\n\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": null + }, + "type": "dict" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.container.get_and_return_map_prim_to_prim(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "request={\n\t\t$FERN_INPUT\n\t}", + "delimiter": ",\n\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": null + }, + "type": "dict" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/container/map-prim-to-object", + "method": "POST", + "identifierOverride": "endpoint_endpoints/container.getAndReturnMapOfPrimToObject" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.container.get_and_return_map_of_prim_to_object(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "request={\n\t\t$FERN_INPUT\n\t}", + "delimiter": ",\n\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [ + "from seed.types.object import ObjectWithRequiredField" + ], + "isOptional": true, + "templateString": "ObjectWithRequiredField(\n\t\t\t$FERN_INPUT\n\t\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t\t", + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": null + }, + "type": "dict" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.container.get_and_return_map_of_prim_to_object(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "request={\n\t\t$FERN_INPUT\n\t}", + "delimiter": ",\n\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [ + "from seed.types.object import ObjectWithRequiredField" + ], + "isOptional": true, + "templateString": "ObjectWithRequiredField(\n\t\t\t$FERN_INPUT\n\t\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t\t", + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": null + }, + "type": "dict" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/container/opt-objects", + "method": "POST", + "identifierOverride": "endpoint_endpoints/container.getAndReturnOptional" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.container.get_and_return_optional(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [ + "from seed.types.object import ObjectWithRequiredField" + ], + "isOptional": true, + "templateString": "request=ObjectWithRequiredField(\n\t\t$FERN_INPUT\n\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t", + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.container.get_and_return_optional(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [ + "from seed.types.object import ObjectWithRequiredField" + ], + "isOptional": true, + "templateString": "request=ObjectWithRequiredField(\n\t\t$FERN_INPUT\n\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t", + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/enum", + "method": "POST", + "identifierOverride": "endpoint_endpoints/enum.getAndReturnEnum" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.enum.get_and_return_enum(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "values": { + "SUNNY": "\"SUNNY\"", + "CLOUDY": "\"CLOUDY\"", + "RAINING": "\"RAINING\"", + "SNOWING": "\"SNOWING\"" + }, + "templateInput": { + "location": "BODY", + "path": null + }, + "type": "enum" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.enum.get_and_return_enum(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "values": { + "SUNNY": "\"SUNNY\"", + "CLOUDY": "\"CLOUDY\"", + "RAINING": "\"RAINING\"", + "SNOWING": "\"SNOWING\"" + }, + "templateInput": { + "location": "BODY", + "path": null + }, + "type": "enum" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/http-methods/{id}", + "method": "GET", + "identifierOverride": "endpoint_endpoints/http-methods.testGet" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.http_methods.test_get(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "id=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "id", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.http_methods.test_get(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "id=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "id", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/http-methods", + "method": "POST", + "identifierOverride": "endpoint_endpoints/http-methods.testPost" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.http_methods.test_post(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.http_methods.test_post(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/http-methods/{id}", + "method": "PUT", + "identifierOverride": "endpoint_endpoints/http-methods.testPut" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.http_methods.test_put(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "id=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "id", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.http_methods.test_put(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "id=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "id", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/http-methods/{id}", + "method": "PATCH", + "identifierOverride": "endpoint_endpoints/http-methods.testPatch" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.http_methods.test_patch(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "id=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "id", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "integer=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "integer", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "long_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "long", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "double=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "double", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bool_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "bool", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "datetime=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "datetime", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "date=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "date", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "uuid_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "uuid", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "base_64=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "base64", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "list_=[\n\t\t$FERN_INPUT\n\t]", + "delimiter": ",\n\t\t", + "innerTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": "list" + }, + "type": "iterable" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "map_={\n\t\t$FERN_INPUT\n\t}", + "delimiter": ",\n\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": "map" + }, + "type": "dict" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bigint=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "bigint", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.http_methods.test_patch(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "id=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "id", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "integer=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "integer", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "long_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "long", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "double=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "double", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bool_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "bool", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "datetime=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "datetime", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "date=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "date", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "uuid_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "uuid", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "base_64=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "base64", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "list_=[\n\t\t$FERN_INPUT\n\t]", + "delimiter": ",\n\t\t", + "innerTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": "list" + }, + "type": "iterable" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "map_={\n\t\t$FERN_INPUT\n\t}", + "delimiter": ",\n\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": "map" + }, + "type": "dict" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bigint=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "bigint", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/http-methods/{id}", + "method": "DELETE", + "identifierOverride": "endpoint_endpoints/http-methods.testDelete" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.http_methods.test_delete(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "id=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "id", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.http_methods.test_delete(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "id=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "id", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/object/get-and-return-with-optional-field", + "method": "POST", + "identifierOverride": "endpoint_endpoints/object.getAndReturnWithOptionalField" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.object.get_and_return_with_optional_field(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "integer=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "integer", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "long_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "long", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "double=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "double", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bool_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "bool", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "datetime=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "datetime", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "date=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "date", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "uuid_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "uuid", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "base_64=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "base64", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "list_=[\n\t\t$FERN_INPUT\n\t]", + "delimiter": ",\n\t\t", + "innerTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": "list" + }, + "type": "iterable" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "map_={\n\t\t$FERN_INPUT\n\t}", + "delimiter": ",\n\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": "map" + }, + "type": "dict" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bigint=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "bigint", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.object.get_and_return_with_optional_field(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "integer=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "integer", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "long_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "long", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "double=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "double", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bool_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "bool", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "datetime=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "datetime", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "date=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "date", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "uuid_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "uuid", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "base_64=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "base64", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "list_=[\n\t\t$FERN_INPUT\n\t]", + "delimiter": ",\n\t\t", + "innerTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": "list" + }, + "type": "iterable" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "map_={\n\t\t$FERN_INPUT\n\t}", + "delimiter": ",\n\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": "map" + }, + "type": "dict" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bigint=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "bigint", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/object/get-and-return-with-required-field", + "method": "POST", + "identifierOverride": "endpoint_endpoints/object.getAndReturnWithRequiredField" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.object.get_and_return_with_required_field(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.object.get_and_return_with_required_field(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/object/get-and-return-with-map-of-map", + "method": "POST", + "identifierOverride": "endpoint_endpoints/object.getAndReturnWithMapOfMap" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.object.get_and_return_with_map_of_map(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "map_={\n\t\t$FERN_INPUT\n\t}", + "delimiter": ",\n\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "containerTemplateString": "{\n\t\t\t$FERN_INPUT\n\t\t}", + "delimiter": ",\n\t\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "RELATIVE", + "path": null + }, + "type": "dict" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": "map" + }, + "type": "dict" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.object.get_and_return_with_map_of_map(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "map_={\n\t\t$FERN_INPUT\n\t}", + "delimiter": ",\n\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "containerTemplateString": "{\n\t\t\t$FERN_INPUT\n\t\t}", + "delimiter": ",\n\t\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "RELATIVE", + "path": null + }, + "type": "dict" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": "map" + }, + "type": "dict" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/object/get-and-return-nested-with-optional-field", + "method": "POST", + "identifierOverride": "endpoint_endpoints/object.getAndReturnNestedWithOptionalField" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.object.get_and_return_nested_with_optional_field(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [ + "from seed.types.object import ObjectWithOptionalField" + ], + "isOptional": true, + "templateString": "nested_object=ObjectWithOptionalField(\n\t\t$FERN_INPUT\n\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "integer=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.integer", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "long_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.long", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "double=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.double", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bool_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.bool", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "datetime=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.datetime", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "date=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.date", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "uuid_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.uuid", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "base_64=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.base64", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "list_=[\n\t\t\t$FERN_INPUT\n\t\t]", + "delimiter": ",\n\t\t\t", + "innerTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": "NestedObject.list" + }, + "type": "iterable" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "map_={\n\t\t\t$FERN_INPUT\n\t\t}", + "delimiter": ",\n\t\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": "NestedObject.map" + }, + "type": "dict" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bigint=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.bigint", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t", + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.object.get_and_return_nested_with_optional_field(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [ + "from seed.types.object import ObjectWithOptionalField" + ], + "isOptional": true, + "templateString": "nested_object=ObjectWithOptionalField(\n\t\t$FERN_INPUT\n\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "integer=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.integer", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "long_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.long", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "double=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.double", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bool_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.bool", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "datetime=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.datetime", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "date=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.date", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "uuid_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.uuid", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "base_64=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.base64", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "list_=[\n\t\t\t$FERN_INPUT\n\t\t]", + "delimiter": ",\n\t\t\t", + "innerTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": "NestedObject.list" + }, + "type": "iterable" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "map_={\n\t\t\t$FERN_INPUT\n\t\t}", + "delimiter": ",\n\t\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": "NestedObject.map" + }, + "type": "dict" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bigint=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.bigint", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t", + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/object/get-and-return-nested-with-required-field/{string}", + "method": "POST", + "identifierOverride": "endpoint_endpoints/object.getAndReturnNestedWithRequiredField" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.object.get_and_return_nested_with_required_field(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [ + "from seed.types.object import ObjectWithOptionalField" + ], + "isOptional": true, + "templateString": "nested_object=ObjectWithOptionalField(\n\t\t$FERN_INPUT\n\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "integer=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.integer", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "long_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.long", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "double=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.double", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bool_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.bool", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "datetime=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.datetime", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "date=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.date", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "uuid_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.uuid", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "base_64=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.base64", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "list_=[\n\t\t\t$FERN_INPUT\n\t\t]", + "delimiter": ",\n\t\t\t", + "innerTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": "NestedObject.list" + }, + "type": "iterable" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "map_={\n\t\t\t$FERN_INPUT\n\t\t}", + "delimiter": ",\n\t\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": "NestedObject.map" + }, + "type": "dict" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bigint=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.bigint", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t", + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.object.get_and_return_nested_with_required_field(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [ + "from seed.types.object import ObjectWithOptionalField" + ], + "isOptional": true, + "templateString": "nested_object=ObjectWithOptionalField(\n\t\t$FERN_INPUT\n\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "integer=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.integer", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "long_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.long", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "double=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.double", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bool_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.bool", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "datetime=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.datetime", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "date=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.date", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "uuid_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.uuid", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "base_64=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.base64", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "list_=[\n\t\t\t$FERN_INPUT\n\t\t]", + "delimiter": ",\n\t\t\t", + "innerTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": "NestedObject.list" + }, + "type": "iterable" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "map_={\n\t\t\t$FERN_INPUT\n\t\t}", + "delimiter": ",\n\t\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": "NestedObject.map" + }, + "type": "dict" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bigint=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.bigint", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t", + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/object/get-and-return-nested-with-required-field-list", + "method": "POST", + "identifierOverride": "endpoint_endpoints/object.getAndReturnNestedWithRequiredFieldAsList" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.object.get_and_return_nested_with_required_field_as_list(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "request=[\n\t\t$FERN_INPUT\n\t]", + "delimiter": ",\n\t\t", + "innerTemplate": { + "imports": [ + "from seed.types.object import NestedObjectWithRequiredField" + ], + "isOptional": true, + "templateString": "NestedObjectWithRequiredField(\n\t\t\t$FERN_INPUT\n\t\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [ + "from seed.types.object import ObjectWithOptionalField" + ], + "isOptional": true, + "templateString": "nested_object=ObjectWithOptionalField(\n\t\t\t\t$FERN_INPUT\n\t\t\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "integer=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.integer", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "long_=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.long", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "double=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.double", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bool_=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.bool", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "datetime=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.datetime", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "date=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.date", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "uuid_=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.uuid", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "base_64=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.base64", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "list_=[\n\t\t\t\t\t$FERN_INPUT\n\t\t\t\t]", + "delimiter": ",\n\t\t\t\t\t", + "innerTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "templateInput": { + "location": "RELATIVE", + "path": "NestedObject.list" + }, + "type": "iterable" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "map_={\n\t\t\t\t\t$FERN_INPUT\n\t\t\t\t}", + "delimiter": ",\n\t\t\t\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "RELATIVE", + "path": "NestedObject.map" + }, + "type": "dict" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bigint=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.bigint", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t\t\t", + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t\t", + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": null + }, + "type": "iterable" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.object.get_and_return_nested_with_required_field_as_list(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "request=[\n\t\t$FERN_INPUT\n\t]", + "delimiter": ",\n\t\t", + "innerTemplate": { + "imports": [ + "from seed.types.object import NestedObjectWithRequiredField" + ], + "isOptional": true, + "templateString": "NestedObjectWithRequiredField(\n\t\t\t$FERN_INPUT\n\t\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [ + "from seed.types.object import ObjectWithOptionalField" + ], + "isOptional": true, + "templateString": "nested_object=ObjectWithOptionalField(\n\t\t\t\t$FERN_INPUT\n\t\t\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "integer=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.integer", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "long_=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.long", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "double=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.double", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bool_=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.bool", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "datetime=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.datetime", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "date=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.date", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "uuid_=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.uuid", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "base_64=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.base64", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "list_=[\n\t\t\t\t\t$FERN_INPUT\n\t\t\t\t]", + "delimiter": ",\n\t\t\t\t\t", + "innerTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "templateInput": { + "location": "RELATIVE", + "path": "NestedObject.list" + }, + "type": "iterable" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "map_={\n\t\t\t\t\t$FERN_INPUT\n\t\t\t\t}", + "delimiter": ",\n\t\t\t\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "RELATIVE", + "path": "NestedObject.map" + }, + "type": "dict" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bigint=$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": "NestedObject.bigint", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t\t\t", + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t\t", + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": null + }, + "type": "iterable" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/params/path/{param}", + "method": "GET", + "identifierOverride": "endpoint_endpoints/params.getWithPath" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.params.get_with_path(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "param=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "param", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.params.get_with_path(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "param=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "param", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/params", + "method": "GET", + "identifierOverride": "endpoint_endpoints/params.getWithQuery" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.params.get_with_query(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "query=$FERN_INPUT", + "templateInputs": [ + { + "location": "QUERY", + "path": "query", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "number=$FERN_INPUT", + "templateInputs": [ + { + "location": "QUERY", + "path": "number", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.params.get_with_query(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "query=$FERN_INPUT", + "templateInputs": [ + { + "location": "QUERY", + "path": "query", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "number=$FERN_INPUT", + "templateInputs": [ + { + "location": "QUERY", + "path": "number", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/params", + "method": "GET", + "identifierOverride": "endpoint_endpoints/params.getWithAllowMultipleQuery" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.params.get_with_allow_multiple_query(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "query=$FERN_INPUT", + "templateInputs": [ + { + "location": "QUERY", + "path": "query", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "numer=$FERN_INPUT", + "templateInputs": [ + { + "location": "QUERY", + "path": "numer", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.params.get_with_allow_multiple_query(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "query=$FERN_INPUT", + "templateInputs": [ + { + "location": "QUERY", + "path": "query", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "numer=$FERN_INPUT", + "templateInputs": [ + { + "location": "QUERY", + "path": "numer", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/params/path-query/{param}", + "method": "GET", + "identifierOverride": "endpoint_endpoints/params.getWithPathAndQuery" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.params.get_with_path_and_query(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "param=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "param", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "query=$FERN_INPUT", + "templateInputs": [ + { + "location": "QUERY", + "path": "query", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.params.get_with_path_and_query(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "param=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "param", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "query=$FERN_INPUT", + "templateInputs": [ + { + "location": "QUERY", + "path": "query", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/params/path/{param}", + "method": "PUT", + "identifierOverride": "endpoint_endpoints/params.modifyWithPath" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.params.modify_with_path(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "param=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "param", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.params.modify_with_path(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "param=$FERN_INPUT", + "templateInputs": [ + { + "location": "PATH", + "path": "param", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/primitive/string", + "method": "POST", + "identifierOverride": "endpoint_endpoints/primitive.getAndReturnString" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.primitive.get_and_return_string(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.primitive.get_and_return_string(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/primitive/integer", + "method": "POST", + "identifierOverride": "endpoint_endpoints/primitive.getAndReturnInt" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.primitive.get_and_return_int(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.primitive.get_and_return_int(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/primitive/long", + "method": "POST", + "identifierOverride": "endpoint_endpoints/primitive.getAndReturnLong" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.primitive.get_and_return_long(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.primitive.get_and_return_long(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/primitive/double", + "method": "POST", + "identifierOverride": "endpoint_endpoints/primitive.getAndReturnDouble" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.primitive.get_and_return_double(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.primitive.get_and_return_double(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/primitive/boolean", + "method": "POST", + "identifierOverride": "endpoint_endpoints/primitive.getAndReturnBool" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.primitive.get_and_return_bool(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.primitive.get_and_return_bool(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/primitive/datetime", + "method": "POST", + "identifierOverride": "endpoint_endpoints/primitive.getAndReturnDatetime" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.primitive.get_and_return_datetime(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.primitive.get_and_return_datetime(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/primitive/date", + "method": "POST", + "identifierOverride": "endpoint_endpoints/primitive.getAndReturnDate" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.primitive.get_and_return_date(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.primitive.get_and_return_date(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/primitive/uuid", + "method": "POST", + "identifierOverride": "endpoint_endpoints/primitive.getAndReturnUUID" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.primitive.get_and_return_uuid(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.primitive.get_and_return_uuid(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/primitive/base64", + "method": "POST", + "identifierOverride": "endpoint_endpoints/primitive.getAndReturnBase64" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.primitive.get_and_return_base_64(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.primitive.get_and_return_base_64(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/union", + "method": "POST", + "identifierOverride": "endpoint_endpoints/union.getAndReturnUnion" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.endpoints.union.get_and_return_union(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "discriminantField": "animal", + "members": { + "dog": { + "imports": [ + "from seed.types.union import Animal_Dog" + ], + "isOptional": true, + "templateString": "request=Animal_Dog($FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "name=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "name", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "likes_to_woof=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "likesToWoof", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "type": "generic" + }, + "cat": { + "imports": [ + "from seed.types.union import Animal_Cat" + ], + "isOptional": true, + "templateString": "request=Animal_Cat($FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "name=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "name", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "likes_to_meow=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "likesToMeow", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "type": "generic" + } + }, + "templateInput": { + "location": "RELATIVE" + }, + "type": "discriminatedUnion" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.endpoints.union.get_and_return_union(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "discriminantField": "animal", + "members": { + "dog": { + "imports": [ + "from seed.types.union import Animal_Dog" + ], + "isOptional": true, + "templateString": "request=Animal_Dog($FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "name=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "name", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "likes_to_woof=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "likesToWoof", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "type": "generic" + }, + "cat": { + "imports": [ + "from seed.types.union import Animal_Cat" + ], + "isOptional": true, + "templateString": "request=Animal_Cat($FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "name=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "name", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "likes_to_meow=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "likesToMeow", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "type": "generic" + } + }, + "templateInput": { + "location": "RELATIVE" + }, + "type": "discriminatedUnion" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/req-bodies/object", + "method": "POST", + "identifierOverride": "endpoint_inlined-requests.postWithObjectBodyandResponse" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.inlined_requests.post_with_object_bodyand_response(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "integer=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "integer", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [ + "from seed.types.object import ObjectWithOptionalField" + ], + "isOptional": true, + "templateString": "nested_object=ObjectWithOptionalField(\n\t\t$FERN_INPUT\n\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "integer=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.integer", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "long_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.long", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "double=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.double", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bool_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.bool", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "datetime=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.datetime", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "date=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.date", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "uuid_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.uuid", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "base_64=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.base64", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "list_=[\n\t\t\t$FERN_INPUT\n\t\t]", + "delimiter": ",\n\t\t\t", + "innerTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": "NestedObject.list" + }, + "type": "iterable" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "map_={\n\t\t\t$FERN_INPUT\n\t\t}", + "delimiter": ",\n\t\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": "NestedObject.map" + }, + "type": "dict" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bigint=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.bigint", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t", + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.inlined_requests.post_with_object_bodyand_response(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "integer=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "integer", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [ + "from seed.types.object import ObjectWithOptionalField" + ], + "isOptional": true, + "templateString": "nested_object=ObjectWithOptionalField(\n\t\t$FERN_INPUT\n\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "string=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.string", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "integer=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.integer", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "long_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.long", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "double=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.double", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bool_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.bool", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "datetime=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.datetime", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "date=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.date", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "uuid_=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.uuid", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "base_64=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.base64", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "list_=[\n\t\t\t$FERN_INPUT\n\t\t]", + "delimiter": ",\n\t\t\t", + "innerTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "templateInput": { + "location": "BODY", + "path": "NestedObject.list" + }, + "type": "iterable" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "containerTemplateString": "map_={\n\t\t\t$FERN_INPUT\n\t\t}", + "delimiter": ",\n\t\t\t", + "keyTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "valueTemplate": { + "imports": [], + "isOptional": true, + "templateString": "$FERN_INPUT", + "templateInputs": [ + { + "location": "RELATIVE", + "path": null, + "type": "payload" + } + ], + "type": "generic" + }, + "keyValueSeparator": ": ", + "templateInput": { + "location": "BODY", + "path": "NestedObject.map" + }, + "type": "dict" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "bigint=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": "NestedObject.bigint", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t", + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/no-auth", + "method": "POST", + "identifierOverride": "endpoint_no-auth.postWithNoAuth" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.no_auth.post_with_no_auth(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.no_auth.post_with_no_auth(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/no-req-body", + "method": "GET", + "identifierOverride": "endpoint_no-req-body.getWithNoRequestBody" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.no_req_body.get_with_no_request_body(\n\t$FERN_INPUT\n)", + "templateInputs": [], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.no_req_body.get_with_no_request_body(\n\t$FERN_INPUT\n)", + "templateInputs": [], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/no-req-body", + "method": "POST", + "identifierOverride": "endpoint_no-req-body.postWithNoRequestBody" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.no_req_body.post_with_no_request_body(\n\t$FERN_INPUT\n)", + "templateInputs": [], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.no_req_body.post_with_no_request_body(\n\t$FERN_INPUT\n)", + "templateInputs": [], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + }, + { + "sdk": { + "package": "fern_exhaustive", + "version": "0.0.1", + "type": "python" + }, + "endpointId": { + "path": "/test-headers/custom-header", + "method": "POST", + "identifierOverride": "endpoint_req-with-headers.getWithCustomHeader" + }, + "snippetTemplate": { + "clientInstantiation": { + "imports": [ + "from seed import SeedExhaustive" + ], + "isOptional": true, + "templateString": "client = SeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "client.req_with_headers.get_with_custom_header(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "x_test_endpoint_header=$FERN_INPUT", + "templateInputs": [ + { + "location": "HEADERS", + "path": "X-TEST-ENDPOINT-HEADER", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + }, + "additionalTemplates": { + "async": { + "clientInstantiation": { + "imports": [ + "from seed import AsyncSeedExhaustive" + ], + "isOptional": true, + "templateString": "client = AsyncSeedExhaustive(base_url=\"https://yourhost.com/path/to/api\", $FERN_INPUT, )", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": false, + "templateString": "token=$FERN_INPUT", + "templateInputs": [ + { + "location": "AUTH", + "path": "token", + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",", + "type": "generic" + }, + "functionInvocation": { + "imports": [], + "isOptional": true, + "templateString": "await client.req_with_headers.get_with_custom_header(\n\t$FERN_INPUT\n)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "x_test_endpoint_header=$FERN_INPUT", + "templateInputs": [ + { + "location": "HEADERS", + "path": "X-TEST-ENDPOINT-HEADER", + "type": "payload" + } + ], + "type": "generic" + } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "request=$FERN_INPUT", + "templateInputs": [ + { + "location": "BODY", + "path": null, + "type": "payload" + } + ], + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t", + "type": "generic" + }, + "type": "v1" + } + } + } +] \ No newline at end of file diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/snippet.json b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/snippet.json new file mode 100644 index 00000000000..62ecc67b879 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/snippet.json @@ -0,0 +1,512 @@ +{ + "types": {}, + "endpoints": [ + { + "example_identifier": "default", + "id": { + "path": "/container/list-of-primitives", + "method": "POST", + "identifier_override": "endpoint_endpoints/container.getAndReturnListOfPrimitives" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.container.get_and_return_list_of_primitives(\n request=[\"string\", \"string\"],\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.container.get_and_return_list_of_primitives(\n request=[\"string\", \"string\"],\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/container/list-of-objects", + "method": "POST", + "identifier_override": "endpoint_endpoints/container.getAndReturnListOfObjects" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\nfrom seed.types.object import ObjectWithRequiredField\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.container.get_and_return_list_of_objects(\n request=[\n ObjectWithRequiredField(\n string=\"string\",\n ),\n ObjectWithRequiredField(\n string=\"string\",\n ),\n ],\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\nfrom seed.types.object import ObjectWithRequiredField\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.container.get_and_return_list_of_objects(\n request=[\n ObjectWithRequiredField(\n string=\"string\",\n ),\n ObjectWithRequiredField(\n string=\"string\",\n ),\n ],\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/container/set-of-primitives", + "method": "POST", + "identifier_override": "endpoint_endpoints/container.getAndReturnSetOfPrimitives" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.container.get_and_return_set_of_primitives(\n request={\"string\"},\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.container.get_and_return_set_of_primitives(\n request={\"string\"},\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/container/set-of-objects", + "method": "POST", + "identifier_override": "endpoint_endpoints/container.getAndReturnSetOfObjects" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\nfrom seed.types.object import ObjectWithRequiredField\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.container.get_and_return_set_of_objects(\n request=[\n ObjectWithRequiredField(\n string=\"string\",\n )\n ],\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\nfrom seed.types.object import ObjectWithRequiredField\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.container.get_and_return_set_of_objects(\n request=[\n ObjectWithRequiredField(\n string=\"string\",\n )\n ],\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/container/map-prim-to-prim", + "method": "POST", + "identifier_override": "endpoint_endpoints/container.getAndReturnMapPrimToPrim" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.container.get_and_return_map_prim_to_prim(\n request={\"string\": \"string\"},\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.container.get_and_return_map_prim_to_prim(\n request={\"string\": \"string\"},\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/container/map-prim-to-object", + "method": "POST", + "identifier_override": "endpoint_endpoints/container.getAndReturnMapOfPrimToObject" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\nfrom seed.types.object import ObjectWithRequiredField\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.container.get_and_return_map_of_prim_to_object(\n request={\n \"string\": ObjectWithRequiredField(\n string=\"string\",\n )\n },\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\nfrom seed.types.object import ObjectWithRequiredField\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.container.get_and_return_map_of_prim_to_object(\n request={\n \"string\": ObjectWithRequiredField(\n string=\"string\",\n )\n },\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/container/opt-objects", + "method": "POST", + "identifier_override": "endpoint_endpoints/container.getAndReturnOptional" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\nfrom seed.types.object import ObjectWithRequiredField\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.container.get_and_return_optional(\n request=ObjectWithRequiredField(\n string=\"string\",\n ),\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\nfrom seed.types.object import ObjectWithRequiredField\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.container.get_and_return_optional(\n request=ObjectWithRequiredField(\n string=\"string\",\n ),\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/enum", + "method": "POST", + "identifier_override": "endpoint_endpoints/enum.getAndReturnEnum" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.enum.get_and_return_enum(\n request=\"SUNNY\",\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.enum.get_and_return_enum(\n request=\"SUNNY\",\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/http-methods/{id}", + "method": "GET", + "identifier_override": "endpoint_endpoints/http-methods.testGet" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.http_methods.test_get(\n id=\"id\",\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.http_methods.test_get(\n id=\"id\",\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/http-methods", + "method": "POST", + "identifier_override": "endpoint_endpoints/http-methods.testPost" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.http_methods.test_post(\n string=\"string\",\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.http_methods.test_post(\n string=\"string\",\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/http-methods/{id}", + "method": "PUT", + "identifier_override": "endpoint_endpoints/http-methods.testPut" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.http_methods.test_put(\n id=\"id\",\n string=\"string\",\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.http_methods.test_put(\n id=\"id\",\n string=\"string\",\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/http-methods/{id}", + "method": "PATCH", + "identifier_override": "endpoint_endpoints/http-methods.testPatch" + }, + "snippet": { + "sync_client": "import datetime\nimport uuid\n\nfrom seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.http_methods.test_patch(\n id=\"id\",\n string=\"string\",\n integer=1,\n long_=1000000,\n double=1.1,\n bool_=True,\n datetime=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n date=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n uuid_=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n base_64=\"SGVsbG8gd29ybGQh\",\n list_=[\"list\", \"list\"],\n set_={\"set\"},\n map_={1: \"map\"},\n bigint=1000000,\n)\n", + "async_client": "import asyncio\nimport datetime\nimport uuid\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.http_methods.test_patch(\n id=\"id\",\n string=\"string\",\n integer=1,\n long_=1000000,\n double=1.1,\n bool_=True,\n datetime=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n date=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n uuid_=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n base_64=\"SGVsbG8gd29ybGQh\",\n list_=[\"list\", \"list\"],\n set_={\"set\"},\n map_={1: \"map\"},\n bigint=1000000,\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/http-methods/{id}", + "method": "DELETE", + "identifier_override": "endpoint_endpoints/http-methods.testDelete" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.http_methods.test_delete(\n id=\"id\",\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.http_methods.test_delete(\n id=\"id\",\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/object/get-and-return-with-optional-field", + "method": "POST", + "identifier_override": "endpoint_endpoints/object.getAndReturnWithOptionalField" + }, + "snippet": { + "sync_client": "import datetime\nimport uuid\n\nfrom seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.object.get_and_return_with_optional_field(\n string=\"string\",\n integer=1,\n long_=1000000,\n double=1.1,\n bool_=True,\n datetime=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n date=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n uuid_=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n base_64=\"SGVsbG8gd29ybGQh\",\n list_=[\"list\", \"list\"],\n set_={\"set\"},\n map_={1: \"map\"},\n bigint=1000000,\n)\n", + "async_client": "import asyncio\nimport datetime\nimport uuid\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.object.get_and_return_with_optional_field(\n string=\"string\",\n integer=1,\n long_=1000000,\n double=1.1,\n bool_=True,\n datetime=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n date=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n uuid_=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n base_64=\"SGVsbG8gd29ybGQh\",\n list_=[\"list\", \"list\"],\n set_={\"set\"},\n map_={1: \"map\"},\n bigint=1000000,\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/object/get-and-return-with-required-field", + "method": "POST", + "identifier_override": "endpoint_endpoints/object.getAndReturnWithRequiredField" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.object.get_and_return_with_required_field(\n string=\"string\",\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.object.get_and_return_with_required_field(\n string=\"string\",\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/object/get-and-return-with-map-of-map", + "method": "POST", + "identifier_override": "endpoint_endpoints/object.getAndReturnWithMapOfMap" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.object.get_and_return_with_map_of_map(\n map_={\"map\": {\"map\": \"map\"}},\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.object.get_and_return_with_map_of_map(\n map_={\"map\": {\"map\": \"map\"}},\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/object/get-and-return-nested-with-optional-field", + "method": "POST", + "identifier_override": "endpoint_endpoints/object.getAndReturnNestedWithOptionalField" + }, + "snippet": { + "sync_client": "import datetime\nimport uuid\n\nfrom seed import SeedExhaustive\nfrom seed.types.object import ObjectWithOptionalField\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.object.get_and_return_nested_with_optional_field(\n string=\"string\",\n nested_object=ObjectWithOptionalField(\n string=\"string\",\n integer=1,\n long_=1000000,\n double=1.1,\n bool_=True,\n datetime=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n date=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n uuid_=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n base_64=\"SGVsbG8gd29ybGQh\",\n list_=[\"list\", \"list\"],\n set_={\"set\"},\n map_={1: \"map\"},\n bigint=1000000,\n ),\n)\n", + "async_client": "import asyncio\nimport datetime\nimport uuid\n\nfrom seed import AsyncSeedExhaustive\nfrom seed.types.object import ObjectWithOptionalField\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.object.get_and_return_nested_with_optional_field(\n string=\"string\",\n nested_object=ObjectWithOptionalField(\n string=\"string\",\n integer=1,\n long_=1000000,\n double=1.1,\n bool_=True,\n datetime=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n date=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n uuid_=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n base_64=\"SGVsbG8gd29ybGQh\",\n list_=[\"list\", \"list\"],\n set_={\"set\"},\n map_={1: \"map\"},\n bigint=1000000,\n ),\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/object/get-and-return-nested-with-required-field/{string}", + "method": "POST", + "identifier_override": "endpoint_endpoints/object.getAndReturnNestedWithRequiredField" + }, + "snippet": { + "sync_client": "import datetime\nimport uuid\n\nfrom seed import SeedExhaustive\nfrom seed.types.object import ObjectWithOptionalField\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.object.get_and_return_nested_with_required_field(\n string_=\"string\",\n string=\"string\",\n nested_object=ObjectWithOptionalField(\n string=\"string\",\n integer=1,\n long_=1000000,\n double=1.1,\n bool_=True,\n datetime=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n date=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n uuid_=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n base_64=\"SGVsbG8gd29ybGQh\",\n list_=[\"list\", \"list\"],\n set_={\"set\"},\n map_={1: \"map\"},\n bigint=1000000,\n ),\n)\n", + "async_client": "import asyncio\nimport datetime\nimport uuid\n\nfrom seed import AsyncSeedExhaustive\nfrom seed.types.object import ObjectWithOptionalField\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.object.get_and_return_nested_with_required_field(\n string_=\"string\",\n string=\"string\",\n nested_object=ObjectWithOptionalField(\n string=\"string\",\n integer=1,\n long_=1000000,\n double=1.1,\n bool_=True,\n datetime=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n date=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n uuid_=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n base_64=\"SGVsbG8gd29ybGQh\",\n list_=[\"list\", \"list\"],\n set_={\"set\"},\n map_={1: \"map\"},\n bigint=1000000,\n ),\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/object/get-and-return-nested-with-required-field-list", + "method": "POST", + "identifier_override": "endpoint_endpoints/object.getAndReturnNestedWithRequiredFieldAsList" + }, + "snippet": { + "sync_client": "import datetime\nimport uuid\n\nfrom seed import SeedExhaustive\nfrom seed.types.object import (\n NestedObjectWithRequiredField,\n ObjectWithOptionalField,\n)\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.object.get_and_return_nested_with_required_field_as_list(\n request=[\n NestedObjectWithRequiredField(\n string=\"string\",\n nested_object=ObjectWithOptionalField(\n string=\"string\",\n integer=1,\n long_=1000000,\n double=1.1,\n bool_=True,\n datetime=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n date=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n uuid_=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n base_64=\"SGVsbG8gd29ybGQh\",\n list_=[\"list\", \"list\"],\n set_={\"set\"},\n map_={1: \"map\"},\n bigint=1000000,\n ),\n ),\n NestedObjectWithRequiredField(\n string=\"string\",\n nested_object=ObjectWithOptionalField(\n string=\"string\",\n integer=1,\n long_=1000000,\n double=1.1,\n bool_=True,\n datetime=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n date=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n uuid_=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n base_64=\"SGVsbG8gd29ybGQh\",\n list_=[\"list\", \"list\"],\n set_={\"set\"},\n map_={1: \"map\"},\n bigint=1000000,\n ),\n ),\n ],\n)\n", + "async_client": "import asyncio\nimport datetime\nimport uuid\n\nfrom seed import AsyncSeedExhaustive\nfrom seed.types.object import (\n NestedObjectWithRequiredField,\n ObjectWithOptionalField,\n)\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.object.get_and_return_nested_with_required_field_as_list(\n request=[\n NestedObjectWithRequiredField(\n string=\"string\",\n nested_object=ObjectWithOptionalField(\n string=\"string\",\n integer=1,\n long_=1000000,\n double=1.1,\n bool_=True,\n datetime=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n date=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n uuid_=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n base_64=\"SGVsbG8gd29ybGQh\",\n list_=[\"list\", \"list\"],\n set_={\"set\"},\n map_={1: \"map\"},\n bigint=1000000,\n ),\n ),\n NestedObjectWithRequiredField(\n string=\"string\",\n nested_object=ObjectWithOptionalField(\n string=\"string\",\n integer=1,\n long_=1000000,\n double=1.1,\n bool_=True,\n datetime=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n date=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n uuid_=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n base_64=\"SGVsbG8gd29ybGQh\",\n list_=[\"list\", \"list\"],\n set_={\"set\"},\n map_={1: \"map\"},\n bigint=1000000,\n ),\n ),\n ],\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/params/path/{param}", + "method": "GET", + "identifier_override": "endpoint_endpoints/params.getWithPath" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.params.get_with_path(\n param=\"param\",\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.params.get_with_path(\n param=\"param\",\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/params", + "method": "GET", + "identifier_override": "endpoint_endpoints/params.getWithQuery" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.params.get_with_query(\n query=\"query\",\n number=1,\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.params.get_with_query(\n query=\"query\",\n number=1,\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/params", + "method": "GET", + "identifier_override": "endpoint_endpoints/params.getWithAllowMultipleQuery" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.params.get_with_allow_multiple_query(\n query=\"query\",\n numer=1,\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.params.get_with_allow_multiple_query(\n query=\"query\",\n numer=1,\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/params/path-query/{param}", + "method": "GET", + "identifier_override": "endpoint_endpoints/params.getWithPathAndQuery" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.params.get_with_path_and_query(\n param=\"param\",\n query=\"query\",\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.params.get_with_path_and_query(\n param=\"param\",\n query=\"query\",\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/params/path/{param}", + "method": "PUT", + "identifier_override": "endpoint_endpoints/params.modifyWithPath" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.params.modify_with_path(\n param=\"param\",\n request=\"string\",\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.params.modify_with_path(\n param=\"param\",\n request=\"string\",\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/primitive/string", + "method": "POST", + "identifier_override": "endpoint_endpoints/primitive.getAndReturnString" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.primitive.get_and_return_string(\n request=\"string\",\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.primitive.get_and_return_string(\n request=\"string\",\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/primitive/integer", + "method": "POST", + "identifier_override": "endpoint_endpoints/primitive.getAndReturnInt" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.primitive.get_and_return_int(\n request=1,\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.primitive.get_and_return_int(\n request=1,\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/primitive/long", + "method": "POST", + "identifier_override": "endpoint_endpoints/primitive.getAndReturnLong" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.primitive.get_and_return_long(\n request=1000000,\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.primitive.get_and_return_long(\n request=1000000,\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/primitive/double", + "method": "POST", + "identifier_override": "endpoint_endpoints/primitive.getAndReturnDouble" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.primitive.get_and_return_double(\n request=1.1,\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.primitive.get_and_return_double(\n request=1.1,\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/primitive/boolean", + "method": "POST", + "identifier_override": "endpoint_endpoints/primitive.getAndReturnBool" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.primitive.get_and_return_bool(\n request=True,\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.primitive.get_and_return_bool(\n request=True,\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/primitive/datetime", + "method": "POST", + "identifier_override": "endpoint_endpoints/primitive.getAndReturnDatetime" + }, + "snippet": { + "sync_client": "import datetime\n\nfrom seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.primitive.get_and_return_datetime(\n request=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n)\n", + "async_client": "import asyncio\nimport datetime\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.primitive.get_and_return_datetime(\n request=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/primitive/date", + "method": "POST", + "identifier_override": "endpoint_endpoints/primitive.getAndReturnDate" + }, + "snippet": { + "sync_client": "import datetime\n\nfrom seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.primitive.get_and_return_date(\n request=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n)\n", + "async_client": "import asyncio\nimport datetime\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.primitive.get_and_return_date(\n request=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/primitive/uuid", + "method": "POST", + "identifier_override": "endpoint_endpoints/primitive.getAndReturnUUID" + }, + "snippet": { + "sync_client": "import uuid\n\nfrom seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.primitive.get_and_return_uuid(\n request=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n)\n", + "async_client": "import asyncio\nimport uuid\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.primitive.get_and_return_uuid(\n request=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/primitive/base64", + "method": "POST", + "identifier_override": "endpoint_endpoints/primitive.getAndReturnBase64" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.primitive.get_and_return_base_64(\n request=\"SGVsbG8gd29ybGQh\",\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.primitive.get_and_return_base_64(\n request=\"SGVsbG8gd29ybGQh\",\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/union", + "method": "POST", + "identifier_override": "endpoint_endpoints/union.getAndReturnUnion" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\nfrom seed.types.union import Animal_Dog\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.endpoints.union.get_and_return_union(\n request=Animal_Dog(\n name=\"name\",\n likes_to_woof=True,\n ),\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\nfrom seed.types.union import Animal_Dog\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.endpoints.union.get_and_return_union(\n request=Animal_Dog(\n name=\"name\",\n likes_to_woof=True,\n ),\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/req-bodies/object", + "method": "POST", + "identifier_override": "endpoint_inlined-requests.postWithObjectBodyandResponse" + }, + "snippet": { + "sync_client": "import datetime\nimport uuid\n\nfrom seed import SeedExhaustive\nfrom seed.types.object import ObjectWithOptionalField\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.inlined_requests.post_with_object_bodyand_response(\n string=\"string\",\n integer=1,\n nested_object=ObjectWithOptionalField(\n string=\"string\",\n integer=1,\n long_=1000000,\n double=1.1,\n bool_=True,\n datetime=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n date=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n uuid_=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n base_64=\"SGVsbG8gd29ybGQh\",\n list_=[\"list\", \"list\"],\n set_={\"set\"},\n map_={1: \"map\"},\n bigint=1000000,\n ),\n)\n", + "async_client": "import asyncio\nimport datetime\nimport uuid\n\nfrom seed import AsyncSeedExhaustive\nfrom seed.types.object import ObjectWithOptionalField\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.inlined_requests.post_with_object_bodyand_response(\n string=\"string\",\n integer=1,\n nested_object=ObjectWithOptionalField(\n string=\"string\",\n integer=1,\n long_=1000000,\n double=1.1,\n bool_=True,\n datetime=datetime.datetime.fromisoformat(\n \"2024-01-15 09:30:00+00:00\",\n ),\n date=datetime.date.fromisoformat(\n \"2023-01-15\",\n ),\n uuid_=uuid.UUID(\n \"d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32\",\n ),\n base_64=\"SGVsbG8gd29ybGQh\",\n list_=[\"list\", \"list\"],\n set_={\"set\"},\n map_={1: \"map\"},\n bigint=1000000,\n ),\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/no-auth", + "method": "POST", + "identifier_override": "endpoint_no-auth.postWithNoAuth" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.no_auth.post_with_no_auth(\n request={\"key\": \"value\"},\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.no_auth.post_with_no_auth(\n request={\"key\": \"value\"},\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/no-req-body", + "method": "GET", + "identifier_override": "endpoint_no-req-body.getWithNoRequestBody" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.no_req_body.get_with_no_request_body()\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.no_req_body.get_with_no_request_body()\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/no-req-body", + "method": "POST", + "identifier_override": "endpoint_no-req-body.postWithNoRequestBody" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.no_req_body.post_with_no_request_body()\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.no_req_body.post_with_no_request_body()\n\n\nasyncio.run(main())\n", + "type": "python" + } + }, + { + "example_identifier": "default", + "id": { + "path": "/test-headers/custom-header", + "method": "POST", + "identifier_override": "endpoint_req-with-headers.getWithCustomHeader" + }, + "snippet": { + "sync_client": "from seed import SeedExhaustive\n\nclient = SeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.req_with_headers.get_with_custom_header(\n x_test_service_header=\"X-TEST-SERVICE-HEADER\",\n x_test_endpoint_header=\"X-TEST-ENDPOINT-HEADER\",\n request=\"string\",\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedExhaustive\n\nclient = AsyncSeedExhaustive(\n token=\"YOUR_TOKEN\",\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.req_with_headers.get_with_custom_header(\n x_test_service_header=\"X-TEST-SERVICE-HEADER\",\n x_test_endpoint_header=\"X-TEST-ENDPOINT-HEADER\",\n request=\"string\",\n )\n\n\nasyncio.run(main())\n", + "type": "python" + } + } + ] +} \ No newline at end of file diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/__init__.py new file mode 100644 index 00000000000..eb56b0ce275 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/__init__.py @@ -0,0 +1,21 @@ +# This file was auto-generated by Fern from our API Definition. + +from . import endpoints, general_errors, inlined_requests, no_auth, no_req_body, req_with_headers, types +from .client import AsyncSeedExhaustive, SeedExhaustive +from .general_errors import BadObjectRequestInfo, BadRequestBody +from .version import __version__ + +__all__ = [ + "AsyncSeedExhaustive", + "BadObjectRequestInfo", + "BadRequestBody", + "SeedExhaustive", + "__version__", + "endpoints", + "general_errors", + "inlined_requests", + "no_auth", + "no_req_body", + "req_with_headers", + "types", +] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/client.py new file mode 100644 index 00000000000..ab22df2044f --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/client.py @@ -0,0 +1,128 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +import httpx +from .core.client_wrapper import SyncClientWrapper +from .endpoints.client import EndpointsClient +from .inlined_requests.client import InlinedRequestsClient +from .no_auth.client import NoAuthClient +from .no_req_body.client import NoReqBodyClient +from .req_with_headers.client import ReqWithHeadersClient +from .core.client_wrapper import AsyncClientWrapper +from .endpoints.client import AsyncEndpointsClient +from .inlined_requests.client import AsyncInlinedRequestsClient +from .no_auth.client import AsyncNoAuthClient +from .no_req_body.client import AsyncNoReqBodyClient +from .req_with_headers.client import AsyncReqWithHeadersClient + + +class SeedExhaustive: + """ + 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 + ---------- + base_url : str + The base url to use for requests from the client. + + token : typing.Optional[typing.Union[str, typing.Callable[[], 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 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. + + httpx_client : typing.Optional[httpx.Client] + The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration. + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + """ + + def __init__( + self, + *, + base_url: str, + token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, + timeout: typing.Optional[float] = None, + follow_redirects: typing.Optional[bool] = True, + 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( + base_url=base_url, + token=token, + httpx_client=httpx_client + if httpx_client is not None + else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects) + if follow_redirects is not None + else httpx.Client(timeout=_defaulted_timeout), + timeout=_defaulted_timeout, + ) + self.endpoints = EndpointsClient(client_wrapper=self._client_wrapper) + self.inlined_requests = InlinedRequestsClient(client_wrapper=self._client_wrapper) + self.no_auth = NoAuthClient(client_wrapper=self._client_wrapper) + self.no_req_body = NoReqBodyClient(client_wrapper=self._client_wrapper) + self.req_with_headers = ReqWithHeadersClient(client_wrapper=self._client_wrapper) + + +class AsyncSeedExhaustive: + """ + 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 + ---------- + base_url : str + The base url to use for requests from the client. + + token : typing.Optional[typing.Union[str, typing.Callable[[], 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 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. + + httpx_client : typing.Optional[httpx.AsyncClient] + The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration. + + Examples + -------- + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + """ + + def __init__( + self, + *, + base_url: str, + token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, + timeout: typing.Optional[float] = None, + follow_redirects: typing.Optional[bool] = True, + 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( + base_url=base_url, + token=token, + httpx_client=httpx_client + if httpx_client is not None + else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects) + if follow_redirects is not None + else httpx.AsyncClient(timeout=_defaulted_timeout), + timeout=_defaulted_timeout, + ) + self.endpoints = AsyncEndpointsClient(client_wrapper=self._client_wrapper) + self.inlined_requests = AsyncInlinedRequestsClient(client_wrapper=self._client_wrapper) + self.no_auth = AsyncNoAuthClient(client_wrapper=self._client_wrapper) + self.no_req_body = AsyncNoReqBodyClient(client_wrapper=self._client_wrapper) + self.req_with_headers = AsyncReqWithHeadersClient(client_wrapper=self._client_wrapper) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/__init__.py new file mode 100644 index 00000000000..f03aecbfe18 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/__init__.py @@ -0,0 +1,47 @@ +# This file was auto-generated by Fern from our API Definition. + +from .api_error import ApiError +from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper +from .datetime_utils import serialize_datetime +from .file import File, convert_file_dict_to_httpx_tuples, with_content_type +from .http_client import AsyncHttpClient, HttpClient +from .jsonable_encoder import jsonable_encoder +from .pydantic_utilities import ( + IS_PYDANTIC_V2, + UniversalBaseModel, + UniversalRootModel, + parse_obj_as, + universal_field_validator, + universal_root_validator, + update_forward_refs, +) +from .query_encoder import encode_query +from .remove_none_from_dict import remove_none_from_dict +from .request_options import RequestOptions +from .serialization import FieldMetadata, convert_and_respect_annotation_metadata + +__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", + "encode_query", + "jsonable_encoder", + "parse_obj_as", + "remove_none_from_dict", + "serialize_datetime", + "universal_field_validator", + "universal_root_validator", + "update_forward_refs", + "with_content_type", +] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/api_error.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/api_error.py new file mode 100644 index 00000000000..2e9fc5431cd --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/api_error.py @@ -0,0 +1,15 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + + +class ApiError(Exception): + status_code: typing.Optional[int] + body: typing.Any + + def __init__(self, *, status_code: typing.Optional[int] = None, body: typing.Any = None): + self.status_code = status_code + self.body = body + + def __str__(self) -> str: + return f"status_code: {self.status_code}, body: {self.body}" diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/client_wrapper.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/client_wrapper.py new file mode 100644 index 00000000000..010885d377e --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/client_wrapper.py @@ -0,0 +1,78 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +import httpx +from .http_client import HttpClient +from .http_client import AsyncHttpClient + + +class BaseClientWrapper: + def __init__( + self, + *, + token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, + base_url: str, + timeout: typing.Optional[float] = None, + ): + self._token = token + self._base_url = base_url + self._timeout = timeout + + def get_headers(self) -> typing.Dict[str, str]: + headers: typing.Dict[str, str] = { + "X-Fern-Language": "Python", + "X-Fern-SDK-Name": "fern_exhaustive", + "X-Fern-SDK-Version": "0.0.1", + } + token = self._get_token() + if token is not None: + headers["Authorization"] = f"Bearer {token}" + return headers + + def _get_token(self) -> typing.Optional[str]: + if isinstance(self._token, str) or self._token is None: + return self._token + else: + return self._token() + + def get_base_url(self) -> str: + return self._base_url + + def get_timeout(self) -> typing.Optional[float]: + return self._timeout + + +class SyncClientWrapper(BaseClientWrapper): + def __init__( + self, + *, + token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, + base_url: str, + timeout: typing.Optional[float] = None, + httpx_client: httpx.Client, + ): + super().__init__(token=token, base_url=base_url, timeout=timeout) + 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): + def __init__( + self, + *, + token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None, + base_url: str, + timeout: typing.Optional[float] = None, + httpx_client: httpx.AsyncClient, + ): + super().__init__(token=token, base_url=base_url, timeout=timeout) + 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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/datetime_utils.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/datetime_utils.py new file mode 100644 index 00000000000..7c9864a944c --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/datetime_utils.py @@ -0,0 +1,28 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt + + +def serialize_datetime(v: dt.datetime) -> str: + """ + Serialize a datetime including timezone info. + + Uses the timezone info provided if present, otherwise uses the current runtime's timezone info. + + UTC datetimes end in "Z" while all other timezones are represented as offset from UTC, e.g. +05:00. + """ + + def _serialize_zoned_datetime(v: dt.datetime) -> str: + if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None): + # UTC is a special case where we use "Z" at the end instead of "+00:00" + return v.isoformat().replace("+00:00", "Z") + else: + # Delegate to the typical +/- offset format + return v.isoformat() + + if v.tzinfo is not None: + return _serialize_zoned_datetime(v) + else: + local_tz = dt.datetime.now().astimezone().tzinfo + localized_dt = v.replace(tzinfo=local_tz) + return _serialize_zoned_datetime(localized_dt) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/file.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/file.py new file mode 100644 index 00000000000..b4cbba30f73 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/file.py @@ -0,0 +1,62 @@ +# This file was auto-generated by Fern from our API Definition. + +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 = Union[IO[bytes], bytes, str] +File = Union[ + # file (or bytes) + FileContent, + # (filename, file (or bytes)) + Tuple[Optional[str], FileContent], + # (filename, file (or bytes), content_type) + Tuple[Optional[str], FileContent, Optional[str]], + # (filename, file (or bytes), content_type, headers) + Tuple[ + Optional[str], + FileContent, + Optional[str], + Mapping[str, str], + ], +] + + +def convert_file_dict_to_httpx_tuples( + 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 + a dict, but to be able to send lists of files, you have to use the list + approach (which also works for non-lists) + https://github.com/encode/httpx/pull/1032 + """ + + httpx_tuples = [] + for key, file_like in d.items(): + if isinstance(file_like, list): + for file_like_item in file_like: + httpx_tuples.append((key, file_like_item)) + 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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/http_client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/http_client.py new file mode 100644 index 00000000000..eb4e8943cec --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/http_client.py @@ -0,0 +1,487 @@ +# This file was auto-generated by Fern from our API Definition. + +import asyncio +import email.utils +import json +import re +import time +import typing +import urllib.parse +from contextlib import asynccontextmanager, contextmanager +from random import random + +import httpx + +from .file import File, convert_file_dict_to_httpx_tuples +from .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 + + +def _parse_retry_after(response_headers: httpx.Headers) -> typing.Optional[float]: + """ + This function parses the `Retry-After` header in a HTTP response and returns the number of seconds to wait. + + Inspired by the urllib3 retry implementation. + """ + retry_after_ms = response_headers.get("retry-after-ms") + if retry_after_ms is not None: + try: + return int(retry_after_ms) / 1000 if retry_after_ms > 0 else 0 + except Exception: + pass + + retry_after = response_headers.get("retry-after") + if retry_after is None: + return None + + # Attempt to parse the header as an int. + if re.match(r"^\s*[0-9]+\s*$", retry_after): + seconds = float(retry_after) + # Fallback to parsing it as a date. + else: + retry_date_tuple = email.utils.parsedate_tz(retry_after) + if retry_date_tuple is None: + return None + if retry_date_tuple[9] is None: # Python 2 + # Assume UTC if no timezone was specified + # On Python2.7, parsedate_tz returns None for a timezone offset + # instead of 0 if no timezone is given, where mktime_tz treats + # a None timezone offset as local time. + retry_date_tuple = retry_date_tuple[:9] + (0,) + retry_date_tuple[10:] + + retry_date = email.utils.mktime_tz(retry_date_tuple) + seconds = retry_date - time.time() + + if seconds < 0: + seconds = 0 + + return seconds + + +def _retry_timeout(response: httpx.Response, retries: int) -> float: + """ + Determine the amount of time to wait before retrying a request. + This function begins by trying to parse a retry-after header from the response, and then proceeds to use exponential backoff + with a jitter to determine the number of seconds to wait. + """ + + # If the API asks us to wait a certain amount of time (and it's a reasonable amount), just do what it says. + retry_after = _parse_retry_after(response.headers) + if retry_after is not None and retry_after <= MAX_RETRY_DELAY_SECONDS_FROM_HEADER: + return retry_after + + # Apply exponential backoff, capped at MAX_RETRY_DELAY_SECONDS. + retry_delay = min(INITIAL_RETRY_DELAY_SECONDS * pow(2.0, retries), MAX_RETRY_DELAY_SECONDS) + + # Add a randomness / jitter to the retry delay to avoid overwhelming the server with retries. + timeout = retry_delay * (1 - 0.25 * random()) + return timeout if timeout >= 0 else 0 + + +def _should_retry(response: httpx.Response) -> bool: + retriable_400s = [429, 408, 409] + 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, + 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 + + 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, + 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: + 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( + 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 + + @contextmanager + 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, + 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 + + 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, + 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: + 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( + 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 + + @asynccontextmanager + async 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.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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/jsonable_encoder.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/jsonable_encoder.py new file mode 100644 index 00000000000..1b631e9017c --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/jsonable_encoder.py @@ -0,0 +1,101 @@ +# This file was auto-generated by Fern from our API Definition. + +""" +jsonable_encoder converts a Python object to a JSON-friendly dict +(e.g. datetimes to strings, Pydantic models to dicts). + +Taken from FastAPI, and made a bit simpler +https://github.com/tiangolo/fastapi/blob/master/fastapi/encoders.py +""" + +import base64 +import dataclasses +import datetime as dt +from enum import Enum +from pathlib import PurePath +from types import GeneratorType +from typing import Any, Callable, Dict, List, Optional, Set, Union + +import pydantic + +from .datetime_utils import serialize_datetime +from .pydantic_utilities import ( + IS_PYDANTIC_V2, + encode_by_type, + to_jsonable_with_fallback, +) + +SetIntStr = Set[Union[int, str]] +DictIntStrAny = Dict[Union[int, str], Any] + + +def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any: + custom_encoder = custom_encoder or {} + if custom_encoder: + if type(obj) in custom_encoder: + return custom_encoder[type(obj)](obj) + else: + for encoder_type, encoder_instance in custom_encoder.items(): + if isinstance(obj, encoder_type): + return encoder_instance(obj) + 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) # 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): + return str(obj) + if isinstance(obj, (str, int, float, type(None))): + return obj + if isinstance(obj, dt.datetime): + return serialize_datetime(obj) + if isinstance(obj, dt.date): + return str(obj) + if isinstance(obj, dict): + encoded_dict = {} + allowed_keys = set(obj.keys()) + for key, value in obj.items(): + if key in allowed_keys: + encoded_key = jsonable_encoder(key, custom_encoder=custom_encoder) + encoded_value = jsonable_encoder(value, custom_encoder=custom_encoder) + encoded_dict[encoded_key] = encoded_value + return encoded_dict + if isinstance(obj, (list, set, frozenset, GeneratorType, tuple)): + encoded_list = [] + for item in obj: + encoded_list.append(jsonable_encoder(item, custom_encoder=custom_encoder)) + return encoded_list + + def fallback_serializer(o: Any) -> Any: + attempt_encode = encode_by_type(o) + if attempt_encode is not None: + return attempt_encode + + try: + data = dict(o) + except Exception as e: + errors: List[Exception] = [] + errors.append(e) + 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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/pydantic_utilities.py new file mode 100644 index 00000000000..ee8f0e4105f --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/pydantic_utilities.py @@ -0,0 +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: + # 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: + 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): + 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 + + +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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/query_encoder.py new file mode 100644 index 00000000000..3183001d404 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/query_encoder.py @@ -0,0 +1,58 @@ +# This file was auto-generated by Fern from our API Definition. + +from typing import Any, Dict, List, Optional, Tuple + +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) -> 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.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.append((key, v)) + return result + + +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 + + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + + return encoded_values + + 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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/remove_none_from_dict.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/remove_none_from_dict.py new file mode 100644 index 00000000000..c2298143f14 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/remove_none_from_dict.py @@ -0,0 +1,11 @@ +# This file was auto-generated by Fern from our API Definition. + +from typing import Any, Dict, Mapping, Optional + + +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: + new[key] = value + return new diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/request_options.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/request_options.py new file mode 100644 index 00000000000..1b38804432b --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/request_options.py @@ -0,0 +1,35 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +try: + from typing import NotRequired # type: ignore +except ImportError: + from typing_extensions import NotRequired + + +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. + + Attributes: + - timeout_in_seconds: int. The number of seconds to await an API call before timing out. + + - max_retries: int. The max number of retries to attempt if the API call fails. + + - additional_headers: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's header dict + + - additional_query_parameters: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's query parameters dict + + - additional_body_parameters: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's body parameters dict + + - chunk_size: int. The size, in bytes, to process each chunk of data being streamed back within the response. This equates to leveraging `chunk_size` within `requests` or `httpx`, and is only leveraged for file downloads. + """ + + timeout_in_seconds: NotRequired[int] + max_retries: NotRequired[int] + additional_headers: NotRequired[typing.Dict[str, typing.Any]] + additional_query_parameters: NotRequired[typing.Dict[str, typing.Any]] + additional_body_parameters: NotRequired[typing.Dict[str, typing.Any]] + chunk_size: NotRequired[int] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/serialization.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/core/serialization.py new file mode 100644 index 00000000000..cb5dcbf93a9 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/__init__.py new file mode 100644 index 00000000000..92307cab7fe --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from . import container, enum, http_methods, object, params, primitive, union + +__all__ = ["container", "enum", "http_methods", "object", "params", "primitive", "union"] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/client.py new file mode 100644 index 00000000000..69930de54d7 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/client.py @@ -0,0 +1,42 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.client_wrapper import SyncClientWrapper +from .container.client import ContainerClient +from .enum.client import EnumClient +from .http_methods.client import HttpMethodsClient +from .object.client import ObjectClient +from .params.client import ParamsClient +from .primitive.client import PrimitiveClient +from .union.client import UnionClient +from ..core.client_wrapper import AsyncClientWrapper +from .container.client import AsyncContainerClient +from .enum.client import AsyncEnumClient +from .http_methods.client import AsyncHttpMethodsClient +from .object.client import AsyncObjectClient +from .params.client import AsyncParamsClient +from .primitive.client import AsyncPrimitiveClient +from .union.client import AsyncUnionClient + + +class EndpointsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + self.container = ContainerClient(client_wrapper=self._client_wrapper) + self.enum = EnumClient(client_wrapper=self._client_wrapper) + self.http_methods = HttpMethodsClient(client_wrapper=self._client_wrapper) + self.object = ObjectClient(client_wrapper=self._client_wrapper) + self.params = ParamsClient(client_wrapper=self._client_wrapper) + self.primitive = PrimitiveClient(client_wrapper=self._client_wrapper) + self.union = UnionClient(client_wrapper=self._client_wrapper) + + +class AsyncEndpointsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + self.container = AsyncContainerClient(client_wrapper=self._client_wrapper) + self.enum = AsyncEnumClient(client_wrapper=self._client_wrapper) + self.http_methods = AsyncHttpMethodsClient(client_wrapper=self._client_wrapper) + self.object = AsyncObjectClient(client_wrapper=self._client_wrapper) + self.params = AsyncParamsClient(client_wrapper=self._client_wrapper) + self.primitive = AsyncPrimitiveClient(client_wrapper=self._client_wrapper) + self.union = AsyncUnionClient(client_wrapper=self._client_wrapper) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/container/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/container/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/container/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/container/client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/container/client.py new file mode 100644 index 00000000000..e9a91f68d59 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/container/client.py @@ -0,0 +1,834 @@ +# 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 ...core.pydantic_utilities import parse_obj_as +from json.decoder import JSONDecodeError +from ...core.api_error import ApiError +from ...types.object.types.object_with_required_field import ObjectWithRequiredField +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, ...) + + +class ContainerClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_and_return_list_of_primitives( + self, *, request: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> typing.List[str]: + """ + Parameters + ---------- + request : typing.Sequence[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[str] + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.container.get_and_return_list_of_primitives( + request=["string", "string"], + ) + """ + _response = self._client_wrapper.httpx_client.request( + "container/list-of-primitives", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + typing.List[str], + parse_obj_as( + type_=typing.List[str], # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_list_of_objects( + self, + *, + request: typing.Sequence[ObjectWithRequiredField], + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.List[ObjectWithRequiredField]: + """ + Parameters + ---------- + request : typing.Sequence[ObjectWithRequiredField] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[ObjectWithRequiredField] + + Examples + -------- + from seed import SeedExhaustive + from seed.types.object import ObjectWithRequiredField + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.container.get_and_return_list_of_objects( + request=[ + ObjectWithRequiredField( + string="string", + ), + ObjectWithRequiredField( + string="string", + ), + ], + ) + """ + _response = self._client_wrapper.httpx_client.request( + "container/list-of-objects", + method="POST", + json=convert_and_respect_annotation_metadata( + object_=request, annotation=typing.Sequence[ObjectWithRequiredField], direction="write" + ), + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + typing.List[ObjectWithRequiredField], + parse_obj_as( + type_=typing.List[ObjectWithRequiredField], # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_set_of_primitives( + self, *, request: typing.Set[str], request_options: typing.Optional[RequestOptions] = None + ) -> typing.Set[str]: + """ + Parameters + ---------- + request : typing.Set[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Set[str] + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.container.get_and_return_set_of_primitives( + request={"string"}, + ) + """ + _response = self._client_wrapper.httpx_client.request( + "container/set-of-primitives", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + typing.Set[str], + parse_obj_as( + type_=typing.Set[str], # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_set_of_objects( + self, + *, + request: typing.Sequence[ObjectWithRequiredField], + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.List[ObjectWithRequiredField]: + """ + Parameters + ---------- + request : typing.Sequence[ObjectWithRequiredField] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[ObjectWithRequiredField] + + Examples + -------- + from seed import SeedExhaustive + from seed.types.object import ObjectWithRequiredField + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.container.get_and_return_set_of_objects( + request=[ + ObjectWithRequiredField( + string="string", + ) + ], + ) + """ + _response = self._client_wrapper.httpx_client.request( + "container/set-of-objects", + method="POST", + json=convert_and_respect_annotation_metadata( + object_=request, annotation=typing.Sequence[ObjectWithRequiredField], direction="write" + ), + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + typing.List[ObjectWithRequiredField], + parse_obj_as( + type_=typing.List[ObjectWithRequiredField], # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_map_prim_to_prim( + self, *, request: typing.Dict[str, str], request_options: typing.Optional[RequestOptions] = None + ) -> typing.Dict[str, str]: + """ + Parameters + ---------- + request : typing.Dict[str, str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Dict[str, str] + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.container.get_and_return_map_prim_to_prim( + request={"string": "string"}, + ) + """ + _response = self._client_wrapper.httpx_client.request( + "container/map-prim-to-prim", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + typing.Dict[str, str], + parse_obj_as( + type_=typing.Dict[str, str], # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_map_of_prim_to_object( + self, + *, + request: typing.Dict[str, ObjectWithRequiredField], + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Dict[str, ObjectWithRequiredField]: + """ + Parameters + ---------- + request : typing.Dict[str, ObjectWithRequiredField] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Dict[str, ObjectWithRequiredField] + + Examples + -------- + from seed import SeedExhaustive + from seed.types.object import ObjectWithRequiredField + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.container.get_and_return_map_of_prim_to_object( + request={ + "string": ObjectWithRequiredField( + string="string", + ) + }, + ) + """ + _response = self._client_wrapper.httpx_client.request( + "container/map-prim-to-object", + method="POST", + json=convert_and_respect_annotation_metadata( + object_=request, annotation=typing.Dict[str, ObjectWithRequiredField], direction="write" + ), + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + typing.Dict[str, ObjectWithRequiredField], + parse_obj_as( + type_=typing.Dict[str, ObjectWithRequiredField], # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_optional( + self, + *, + request: typing.Optional[ObjectWithRequiredField] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Optional[ObjectWithRequiredField]: + """ + Parameters + ---------- + request : typing.Optional[ObjectWithRequiredField] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[ObjectWithRequiredField] + + Examples + -------- + from seed import SeedExhaustive + from seed.types.object import ObjectWithRequiredField + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.container.get_and_return_optional( + request=ObjectWithRequiredField( + string="string", + ), + ) + """ + _response = self._client_wrapper.httpx_client.request( + "container/opt-objects", + method="POST", + json=convert_and_respect_annotation_metadata( + object_=request, annotation=ObjectWithRequiredField, direction="write" + ), + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + typing.Optional[ObjectWithRequiredField], + parse_obj_as( + type_=typing.Optional[ObjectWithRequiredField], # type: ignore + object_=_response.json(), + ), + ) + _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 AsyncContainerClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_and_return_list_of_primitives( + self, *, request: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> typing.List[str]: + """ + Parameters + ---------- + request : typing.Sequence[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[str] + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.container.get_and_return_list_of_primitives( + request=["string", "string"], + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "container/list-of-primitives", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + typing.List[str], + parse_obj_as( + type_=typing.List[str], # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_list_of_objects( + self, + *, + request: typing.Sequence[ObjectWithRequiredField], + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.List[ObjectWithRequiredField]: + """ + Parameters + ---------- + request : typing.Sequence[ObjectWithRequiredField] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[ObjectWithRequiredField] + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + from seed.types.object import ObjectWithRequiredField + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.container.get_and_return_list_of_objects( + request=[ + ObjectWithRequiredField( + string="string", + ), + ObjectWithRequiredField( + string="string", + ), + ], + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "container/list-of-objects", + method="POST", + json=convert_and_respect_annotation_metadata( + object_=request, annotation=typing.Sequence[ObjectWithRequiredField], direction="write" + ), + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + typing.List[ObjectWithRequiredField], + parse_obj_as( + type_=typing.List[ObjectWithRequiredField], # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_set_of_primitives( + self, *, request: typing.Set[str], request_options: typing.Optional[RequestOptions] = None + ) -> typing.Set[str]: + """ + Parameters + ---------- + request : typing.Set[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Set[str] + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.container.get_and_return_set_of_primitives( + request={"string"}, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "container/set-of-primitives", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + typing.Set[str], + parse_obj_as( + type_=typing.Set[str], # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_set_of_objects( + self, + *, + request: typing.Sequence[ObjectWithRequiredField], + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.List[ObjectWithRequiredField]: + """ + Parameters + ---------- + request : typing.Sequence[ObjectWithRequiredField] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[ObjectWithRequiredField] + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + from seed.types.object import ObjectWithRequiredField + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.container.get_and_return_set_of_objects( + request=[ + ObjectWithRequiredField( + string="string", + ) + ], + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "container/set-of-objects", + method="POST", + json=convert_and_respect_annotation_metadata( + object_=request, annotation=typing.Sequence[ObjectWithRequiredField], direction="write" + ), + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + typing.List[ObjectWithRequiredField], + parse_obj_as( + type_=typing.List[ObjectWithRequiredField], # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_map_prim_to_prim( + self, *, request: typing.Dict[str, str], request_options: typing.Optional[RequestOptions] = None + ) -> typing.Dict[str, str]: + """ + Parameters + ---------- + request : typing.Dict[str, str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Dict[str, str] + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.container.get_and_return_map_prim_to_prim( + request={"string": "string"}, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "container/map-prim-to-prim", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + typing.Dict[str, str], + parse_obj_as( + type_=typing.Dict[str, str], # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_map_of_prim_to_object( + self, + *, + request: typing.Dict[str, ObjectWithRequiredField], + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Dict[str, ObjectWithRequiredField]: + """ + Parameters + ---------- + request : typing.Dict[str, ObjectWithRequiredField] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Dict[str, ObjectWithRequiredField] + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + from seed.types.object import ObjectWithRequiredField + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.container.get_and_return_map_of_prim_to_object( + request={ + "string": ObjectWithRequiredField( + string="string", + ) + }, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "container/map-prim-to-object", + method="POST", + json=convert_and_respect_annotation_metadata( + object_=request, annotation=typing.Dict[str, ObjectWithRequiredField], direction="write" + ), + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + typing.Dict[str, ObjectWithRequiredField], + parse_obj_as( + type_=typing.Dict[str, ObjectWithRequiredField], # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_optional( + self, + *, + request: typing.Optional[ObjectWithRequiredField] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Optional[ObjectWithRequiredField]: + """ + Parameters + ---------- + request : typing.Optional[ObjectWithRequiredField] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[ObjectWithRequiredField] + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + from seed.types.object import ObjectWithRequiredField + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.container.get_and_return_optional( + request=ObjectWithRequiredField( + string="string", + ), + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "container/opt-objects", + method="POST", + json=convert_and_respect_annotation_metadata( + object_=request, annotation=ObjectWithRequiredField, direction="write" + ), + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + typing.Optional[ObjectWithRequiredField], + parse_obj_as( + type_=typing.Optional[ObjectWithRequiredField], # type: ignore + object_=_response.json(), + ), + ) + _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) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/enum/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/enum/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/enum/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/enum/client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/enum/client.py new file mode 100644 index 00000000000..50e6ca5530f --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/enum/client.py @@ -0,0 +1,127 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from ...core.client_wrapper import SyncClientWrapper +from ...types.enum.types.weather_report import WeatherReport +from ...core.request_options import RequestOptions +from ...core.pydantic_utilities import parse_obj_as +from json.decoder import JSONDecodeError +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class EnumClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_and_return_enum( + self, *, request: WeatherReport, request_options: typing.Optional[RequestOptions] = None + ) -> WeatherReport: + """ + Parameters + ---------- + request : WeatherReport + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + WeatherReport + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.enum.get_and_return_enum( + request="SUNNY", + ) + """ + _response = self._client_wrapper.httpx_client.request( + "enum", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + WeatherReport, + parse_obj_as( + type_=WeatherReport, # type: ignore + object_=_response.json(), + ), + ) + _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 AsyncEnumClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_and_return_enum( + self, *, request: WeatherReport, request_options: typing.Optional[RequestOptions] = None + ) -> WeatherReport: + """ + Parameters + ---------- + request : WeatherReport + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + WeatherReport + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.enum.get_and_return_enum( + request="SUNNY", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "enum", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + WeatherReport, + parse_obj_as( + type_=WeatherReport, # type: ignore + object_=_response.json(), + ), + ) + _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) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/http_methods/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/http_methods/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/http_methods/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/http_methods/client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/http_methods/client.py new file mode 100644 index 00000000000..8cf8adae3b8 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/http_methods/client.py @@ -0,0 +1,701 @@ +# 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 ...core.jsonable_encoder import jsonable_encoder +from ...core.pydantic_utilities import parse_obj_as +from json.decoder import JSONDecodeError +from ...core.api_error import ApiError +from ...types.object.types.object_with_optional_field import ObjectWithOptionalField +import datetime as dt +import uuid +from ...core.client_wrapper import AsyncClientWrapper + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class HttpMethodsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def test_get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> str: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.http_methods.test_get( + id="id", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"http-methods/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + str, + parse_obj_as( + type_=str, # type: ignore + object_=_response.json(), + ), + ) + _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 test_post( + self, *, string: str, request_options: typing.Optional[RequestOptions] = None + ) -> ObjectWithOptionalField: + """ + Parameters + ---------- + string : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithOptionalField + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.http_methods.test_post( + string="string", + ) + """ + _response = self._client_wrapper.httpx_client.request( + "http-methods", + method="POST", + json={ + "string": string, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithOptionalField, + parse_obj_as( + type_=ObjectWithOptionalField, # type: ignore + object_=_response.json(), + ), + ) + _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 test_put( + self, id: str, *, string: str, request_options: typing.Optional[RequestOptions] = None + ) -> ObjectWithOptionalField: + """ + Parameters + ---------- + id : str + + string : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithOptionalField + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.http_methods.test_put( + id="id", + string="string", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"http-methods/{jsonable_encoder(id)}", + method="PUT", + json={ + "string": string, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithOptionalField, + parse_obj_as( + type_=ObjectWithOptionalField, # type: ignore + object_=_response.json(), + ), + ) + _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 test_patch( + self, + id: str, + *, + string: typing.Optional[str] = OMIT, + integer: typing.Optional[int] = OMIT, + long_: typing.Optional[int] = OMIT, + double: typing.Optional[float] = OMIT, + bool_: typing.Optional[bool] = OMIT, + datetime: typing.Optional[dt.datetime] = OMIT, + date: typing.Optional[dt.date] = OMIT, + uuid_: typing.Optional[uuid.UUID] = OMIT, + base_64: typing.Optional[str] = OMIT, + list_: typing.Optional[typing.Sequence[str]] = OMIT, + set_: typing.Optional[typing.Set[str]] = OMIT, + map_: typing.Optional[typing.Dict[int, str]] = OMIT, + bigint: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ObjectWithOptionalField: + """ + Parameters + ---------- + id : str + + string : typing.Optional[str] + This is a rather long descriptor of this single field in a more complex type. If you ask me I think this is a pretty good description for this field all things considered. + + integer : typing.Optional[int] + + long_ : typing.Optional[int] + + double : typing.Optional[float] + + bool_ : typing.Optional[bool] + + datetime : typing.Optional[dt.datetime] + + date : typing.Optional[dt.date] + + uuid_ : typing.Optional[uuid.UUID] + + base_64 : typing.Optional[str] + + list_ : typing.Optional[typing.Sequence[str]] + + set_ : typing.Optional[typing.Set[str]] + + map_ : typing.Optional[typing.Dict[int, str]] + + bigint : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithOptionalField + + Examples + -------- + import datetime + import uuid + + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.http_methods.test_patch( + id="id", + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"http-methods/{jsonable_encoder(id)}", + method="PATCH", + json={ + "string": string, + "integer": integer, + "long": long_, + "double": double, + "bool": bool_, + "datetime": datetime, + "date": date, + "uuid": uuid_, + "base64": base_64, + "list": list_, + "set": set_, + "map": map_, + "bigint": bigint, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithOptionalField, + parse_obj_as( + type_=ObjectWithOptionalField, # type: ignore + object_=_response.json(), + ), + ) + _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 test_delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> bool: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + bool + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.http_methods.test_delete( + id="id", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"http-methods/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + bool, + parse_obj_as( + type_=bool, # type: ignore + object_=_response.json(), + ), + ) + _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 AsyncHttpMethodsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def test_get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> str: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.http_methods.test_get( + id="id", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"http-methods/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + str, + parse_obj_as( + type_=str, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def test_post( + self, *, string: str, request_options: typing.Optional[RequestOptions] = None + ) -> ObjectWithOptionalField: + """ + Parameters + ---------- + string : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithOptionalField + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.http_methods.test_post( + string="string", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "http-methods", + method="POST", + json={ + "string": string, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithOptionalField, + parse_obj_as( + type_=ObjectWithOptionalField, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def test_put( + self, id: str, *, string: str, request_options: typing.Optional[RequestOptions] = None + ) -> ObjectWithOptionalField: + """ + Parameters + ---------- + id : str + + string : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithOptionalField + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.http_methods.test_put( + id="id", + string="string", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"http-methods/{jsonable_encoder(id)}", + method="PUT", + json={ + "string": string, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithOptionalField, + parse_obj_as( + type_=ObjectWithOptionalField, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def test_patch( + self, + id: str, + *, + string: typing.Optional[str] = OMIT, + integer: typing.Optional[int] = OMIT, + long_: typing.Optional[int] = OMIT, + double: typing.Optional[float] = OMIT, + bool_: typing.Optional[bool] = OMIT, + datetime: typing.Optional[dt.datetime] = OMIT, + date: typing.Optional[dt.date] = OMIT, + uuid_: typing.Optional[uuid.UUID] = OMIT, + base_64: typing.Optional[str] = OMIT, + list_: typing.Optional[typing.Sequence[str]] = OMIT, + set_: typing.Optional[typing.Set[str]] = OMIT, + map_: typing.Optional[typing.Dict[int, str]] = OMIT, + bigint: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ObjectWithOptionalField: + """ + Parameters + ---------- + id : str + + string : typing.Optional[str] + This is a rather long descriptor of this single field in a more complex type. If you ask me I think this is a pretty good description for this field all things considered. + + integer : typing.Optional[int] + + long_ : typing.Optional[int] + + double : typing.Optional[float] + + bool_ : typing.Optional[bool] + + datetime : typing.Optional[dt.datetime] + + date : typing.Optional[dt.date] + + uuid_ : typing.Optional[uuid.UUID] + + base_64 : typing.Optional[str] + + list_ : typing.Optional[typing.Sequence[str]] + + set_ : typing.Optional[typing.Set[str]] + + map_ : typing.Optional[typing.Dict[int, str]] + + bigint : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithOptionalField + + Examples + -------- + import asyncio + import datetime + import uuid + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.http_methods.test_patch( + id="id", + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"http-methods/{jsonable_encoder(id)}", + method="PATCH", + json={ + "string": string, + "integer": integer, + "long": long_, + "double": double, + "bool": bool_, + "datetime": datetime, + "date": date, + "uuid": uuid_, + "base64": base_64, + "list": list_, + "set": set_, + "map": map_, + "bigint": bigint, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithOptionalField, + parse_obj_as( + type_=ObjectWithOptionalField, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def test_delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> bool: + """ + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + bool + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.http_methods.test_delete( + id="id", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"http-methods/{jsonable_encoder(id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + bool, + parse_obj_as( + type_=bool, # type: ignore + object_=_response.json(), + ), + ) + _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) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/object/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/object/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/object/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/object/client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/object/client.py new file mode 100644 index 00000000000..53ac56a9f1e --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/object/client.py @@ -0,0 +1,1083 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from ...core.client_wrapper import SyncClientWrapper +import datetime as dt +import uuid +from ...core.request_options import RequestOptions +from ...types.object.types.object_with_optional_field import ObjectWithOptionalField +from ...core.pydantic_utilities import parse_obj_as +from json.decoder import JSONDecodeError +from ...core.api_error import ApiError +from ...types.object.types.object_with_required_field import ObjectWithRequiredField +from ...types.object.types.object_with_map_of_map import ObjectWithMapOfMap +from ...types.object.types.nested_object_with_optional_field import NestedObjectWithOptionalField +from ...core.serialization import convert_and_respect_annotation_metadata +from ...types.object.types.nested_object_with_required_field import NestedObjectWithRequiredField +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 ObjectClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_and_return_with_optional_field( + self, + *, + string: typing.Optional[str] = OMIT, + integer: typing.Optional[int] = OMIT, + long_: typing.Optional[int] = OMIT, + double: typing.Optional[float] = OMIT, + bool_: typing.Optional[bool] = OMIT, + datetime: typing.Optional[dt.datetime] = OMIT, + date: typing.Optional[dt.date] = OMIT, + uuid_: typing.Optional[uuid.UUID] = OMIT, + base_64: typing.Optional[str] = OMIT, + list_: typing.Optional[typing.Sequence[str]] = OMIT, + set_: typing.Optional[typing.Set[str]] = OMIT, + map_: typing.Optional[typing.Dict[int, str]] = OMIT, + bigint: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ObjectWithOptionalField: + """ + Parameters + ---------- + string : typing.Optional[str] + This is a rather long descriptor of this single field in a more complex type. If you ask me I think this is a pretty good description for this field all things considered. + + integer : typing.Optional[int] + + long_ : typing.Optional[int] + + double : typing.Optional[float] + + bool_ : typing.Optional[bool] + + datetime : typing.Optional[dt.datetime] + + date : typing.Optional[dt.date] + + uuid_ : typing.Optional[uuid.UUID] + + base_64 : typing.Optional[str] + + list_ : typing.Optional[typing.Sequence[str]] + + set_ : typing.Optional[typing.Set[str]] + + map_ : typing.Optional[typing.Dict[int, str]] + + bigint : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithOptionalField + + Examples + -------- + import datetime + import uuid + + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.object.get_and_return_with_optional_field( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ) + """ + _response = self._client_wrapper.httpx_client.request( + "object/get-and-return-with-optional-field", + method="POST", + json={ + "string": string, + "integer": integer, + "long": long_, + "double": double, + "bool": bool_, + "datetime": datetime, + "date": date, + "uuid": uuid_, + "base64": base_64, + "list": list_, + "set": set_, + "map": map_, + "bigint": bigint, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithOptionalField, + parse_obj_as( + type_=ObjectWithOptionalField, # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_with_required_field( + self, *, string: str, request_options: typing.Optional[RequestOptions] = None + ) -> ObjectWithRequiredField: + """ + Parameters + ---------- + string : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithRequiredField + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.object.get_and_return_with_required_field( + string="string", + ) + """ + _response = self._client_wrapper.httpx_client.request( + "object/get-and-return-with-required-field", + method="POST", + json={ + "string": string, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithRequiredField, + parse_obj_as( + type_=ObjectWithRequiredField, # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_with_map_of_map( + self, *, map_: typing.Dict[str, typing.Dict[str, str]], request_options: typing.Optional[RequestOptions] = None + ) -> ObjectWithMapOfMap: + """ + Parameters + ---------- + map_ : typing.Dict[str, typing.Dict[str, str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithMapOfMap + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.object.get_and_return_with_map_of_map( + map_={"map": {"map": "map"}}, + ) + """ + _response = self._client_wrapper.httpx_client.request( + "object/get-and-return-with-map-of-map", + method="POST", + json={ + "map": map_, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithMapOfMap, + parse_obj_as( + type_=ObjectWithMapOfMap, # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_nested_with_optional_field( + self, + *, + string: typing.Optional[str] = OMIT, + nested_object: typing.Optional[ObjectWithOptionalField] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> NestedObjectWithOptionalField: + """ + Parameters + ---------- + string : typing.Optional[str] + + nested_object : typing.Optional[ObjectWithOptionalField] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + NestedObjectWithOptionalField + + Examples + -------- + import datetime + import uuid + + from seed import SeedExhaustive + from seed.types.object import ObjectWithOptionalField + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.object.get_and_return_nested_with_optional_field( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ) + """ + _response = self._client_wrapper.httpx_client.request( + "object/get-and-return-nested-with-optional-field", + method="POST", + json={ + "string": string, + "NestedObject": convert_and_respect_annotation_metadata( + object_=nested_object, annotation=ObjectWithOptionalField, direction="write" + ), + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + NestedObjectWithOptionalField, + parse_obj_as( + type_=NestedObjectWithOptionalField, # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_nested_with_required_field( + self, + string_: str, + *, + string: str, + nested_object: ObjectWithOptionalField, + request_options: typing.Optional[RequestOptions] = None, + ) -> NestedObjectWithRequiredField: + """ + Parameters + ---------- + string_ : str + + string : str + + nested_object : ObjectWithOptionalField + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + NestedObjectWithRequiredField + + Examples + -------- + import datetime + import uuid + + from seed import SeedExhaustive + from seed.types.object import ObjectWithOptionalField + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.object.get_and_return_nested_with_required_field( + string_="string", + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"object/get-and-return-nested-with-required-field/{jsonable_encoder(string_)}", + method="POST", + json={ + "string": string, + "NestedObject": convert_and_respect_annotation_metadata( + object_=nested_object, annotation=ObjectWithOptionalField, direction="write" + ), + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + NestedObjectWithRequiredField, + parse_obj_as( + type_=NestedObjectWithRequiredField, # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_nested_with_required_field_as_list( + self, + *, + request: typing.Sequence[NestedObjectWithRequiredField], + request_options: typing.Optional[RequestOptions] = None, + ) -> NestedObjectWithRequiredField: + """ + Parameters + ---------- + request : typing.Sequence[NestedObjectWithRequiredField] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + NestedObjectWithRequiredField + + Examples + -------- + import datetime + import uuid + + from seed import SeedExhaustive + from seed.types.object import ( + NestedObjectWithRequiredField, + ObjectWithOptionalField, + ) + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.object.get_and_return_nested_with_required_field_as_list( + request=[ + NestedObjectWithRequiredField( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ), + NestedObjectWithRequiredField( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ), + ], + ) + """ + _response = self._client_wrapper.httpx_client.request( + "object/get-and-return-nested-with-required-field-list", + method="POST", + json=convert_and_respect_annotation_metadata( + object_=request, annotation=typing.Sequence[NestedObjectWithRequiredField], direction="write" + ), + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + NestedObjectWithRequiredField, + parse_obj_as( + type_=NestedObjectWithRequiredField, # type: ignore + object_=_response.json(), + ), + ) + _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 AsyncObjectClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_and_return_with_optional_field( + self, + *, + string: typing.Optional[str] = OMIT, + integer: typing.Optional[int] = OMIT, + long_: typing.Optional[int] = OMIT, + double: typing.Optional[float] = OMIT, + bool_: typing.Optional[bool] = OMIT, + datetime: typing.Optional[dt.datetime] = OMIT, + date: typing.Optional[dt.date] = OMIT, + uuid_: typing.Optional[uuid.UUID] = OMIT, + base_64: typing.Optional[str] = OMIT, + list_: typing.Optional[typing.Sequence[str]] = OMIT, + set_: typing.Optional[typing.Set[str]] = OMIT, + map_: typing.Optional[typing.Dict[int, str]] = OMIT, + bigint: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ObjectWithOptionalField: + """ + Parameters + ---------- + string : typing.Optional[str] + This is a rather long descriptor of this single field in a more complex type. If you ask me I think this is a pretty good description for this field all things considered. + + integer : typing.Optional[int] + + long_ : typing.Optional[int] + + double : typing.Optional[float] + + bool_ : typing.Optional[bool] + + datetime : typing.Optional[dt.datetime] + + date : typing.Optional[dt.date] + + uuid_ : typing.Optional[uuid.UUID] + + base_64 : typing.Optional[str] + + list_ : typing.Optional[typing.Sequence[str]] + + set_ : typing.Optional[typing.Set[str]] + + map_ : typing.Optional[typing.Dict[int, str]] + + bigint : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithOptionalField + + Examples + -------- + import asyncio + import datetime + import uuid + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.object.get_and_return_with_optional_field( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "object/get-and-return-with-optional-field", + method="POST", + json={ + "string": string, + "integer": integer, + "long": long_, + "double": double, + "bool": bool_, + "datetime": datetime, + "date": date, + "uuid": uuid_, + "base64": base_64, + "list": list_, + "set": set_, + "map": map_, + "bigint": bigint, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithOptionalField, + parse_obj_as( + type_=ObjectWithOptionalField, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_with_required_field( + self, *, string: str, request_options: typing.Optional[RequestOptions] = None + ) -> ObjectWithRequiredField: + """ + Parameters + ---------- + string : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithRequiredField + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.object.get_and_return_with_required_field( + string="string", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "object/get-and-return-with-required-field", + method="POST", + json={ + "string": string, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithRequiredField, + parse_obj_as( + type_=ObjectWithRequiredField, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_with_map_of_map( + self, *, map_: typing.Dict[str, typing.Dict[str, str]], request_options: typing.Optional[RequestOptions] = None + ) -> ObjectWithMapOfMap: + """ + Parameters + ---------- + map_ : typing.Dict[str, typing.Dict[str, str]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithMapOfMap + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.object.get_and_return_with_map_of_map( + map_={"map": {"map": "map"}}, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "object/get-and-return-with-map-of-map", + method="POST", + json={ + "map": map_, + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithMapOfMap, + parse_obj_as( + type_=ObjectWithMapOfMap, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_nested_with_optional_field( + self, + *, + string: typing.Optional[str] = OMIT, + nested_object: typing.Optional[ObjectWithOptionalField] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> NestedObjectWithOptionalField: + """ + Parameters + ---------- + string : typing.Optional[str] + + nested_object : typing.Optional[ObjectWithOptionalField] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + NestedObjectWithOptionalField + + Examples + -------- + import asyncio + import datetime + import uuid + + from seed import AsyncSeedExhaustive + from seed.types.object import ObjectWithOptionalField + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.object.get_and_return_nested_with_optional_field( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "object/get-and-return-nested-with-optional-field", + method="POST", + json={ + "string": string, + "NestedObject": convert_and_respect_annotation_metadata( + object_=nested_object, annotation=ObjectWithOptionalField, direction="write" + ), + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + NestedObjectWithOptionalField, + parse_obj_as( + type_=NestedObjectWithOptionalField, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_nested_with_required_field( + self, + string_: str, + *, + string: str, + nested_object: ObjectWithOptionalField, + request_options: typing.Optional[RequestOptions] = None, + ) -> NestedObjectWithRequiredField: + """ + Parameters + ---------- + string_ : str + + string : str + + nested_object : ObjectWithOptionalField + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + NestedObjectWithRequiredField + + Examples + -------- + import asyncio + import datetime + import uuid + + from seed import AsyncSeedExhaustive + from seed.types.object import ObjectWithOptionalField + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.object.get_and_return_nested_with_required_field( + string_="string", + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"object/get-and-return-nested-with-required-field/{jsonable_encoder(string_)}", + method="POST", + json={ + "string": string, + "NestedObject": convert_and_respect_annotation_metadata( + object_=nested_object, annotation=ObjectWithOptionalField, direction="write" + ), + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + NestedObjectWithRequiredField, + parse_obj_as( + type_=NestedObjectWithRequiredField, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_nested_with_required_field_as_list( + self, + *, + request: typing.Sequence[NestedObjectWithRequiredField], + request_options: typing.Optional[RequestOptions] = None, + ) -> NestedObjectWithRequiredField: + """ + Parameters + ---------- + request : typing.Sequence[NestedObjectWithRequiredField] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + NestedObjectWithRequiredField + + Examples + -------- + import asyncio + import datetime + import uuid + + from seed import AsyncSeedExhaustive + from seed.types.object import ( + NestedObjectWithRequiredField, + ObjectWithOptionalField, + ) + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.object.get_and_return_nested_with_required_field_as_list( + request=[ + NestedObjectWithRequiredField( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ), + NestedObjectWithRequiredField( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ), + ], + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "object/get-and-return-nested-with-required-field-list", + method="POST", + json=convert_and_respect_annotation_metadata( + object_=request, annotation=typing.Sequence[NestedObjectWithRequiredField], direction="write" + ), + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + NestedObjectWithRequiredField, + parse_obj_as( + type_=NestedObjectWithRequiredField, # type: ignore + object_=_response.json(), + ), + ) + _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) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/params/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/params/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/params/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/params/client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/params/client.py new file mode 100644 index 00000000000..677c2c61aee --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/params/client.py @@ -0,0 +1,561 @@ +# 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 ...core.jsonable_encoder import jsonable_encoder +from ...core.pydantic_utilities import parse_obj_as +from json.decoder import JSONDecodeError +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class ParamsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_with_path(self, param: str, *, request_options: typing.Optional[RequestOptions] = None) -> str: + """ + GET with path param + + Parameters + ---------- + param : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.params.get_with_path( + param="param", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"params/path/{jsonable_encoder(param)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + str, + parse_obj_as( + type_=str, # type: ignore + object_=_response.json(), + ), + ) + _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_with_query( + self, *, query: str, number: int, request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + GET with query param + + Parameters + ---------- + query : str + + number : int + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.params.get_with_query( + query="query", + number=1, + ) + """ + _response = self._client_wrapper.httpx_client.request( + "params", + method="GET", + params={ + "query": query, + "number": number, + }, + 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_with_allow_multiple_query( + self, + *, + query: typing.Union[str, typing.Sequence[str]], + numer: typing.Union[int, typing.Sequence[int]], + request_options: typing.Optional[RequestOptions] = None, + ) -> None: + """ + GET with multiple of same query param + + Parameters + ---------- + query : typing.Union[str, typing.Sequence[str]] + + numer : typing.Union[int, typing.Sequence[int]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.params.get_with_allow_multiple_query( + query="query", + numer=1, + ) + """ + _response = self._client_wrapper.httpx_client.request( + "params", + method="GET", + params={ + "query": query, + "numer": numer, + }, + 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_with_path_and_query( + self, param: str, *, query: str, request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + GET with path and query params + + Parameters + ---------- + param : str + + query : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.params.get_with_path_and_query( + param="param", + query="query", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"params/path-query/{jsonable_encoder(param)}", + method="GET", + params={ + "query": query, + }, + 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 modify_with_path( + self, param: str, *, request: str, request_options: typing.Optional[RequestOptions] = None + ) -> str: + """ + PUT to update with path param + + Parameters + ---------- + param : str + + request : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.params.modify_with_path( + param="param", + request="string", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"params/path/{jsonable_encoder(param)}", + method="PUT", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + str, + parse_obj_as( + type_=str, # type: ignore + object_=_response.json(), + ), + ) + _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 AsyncParamsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_with_path(self, param: str, *, request_options: typing.Optional[RequestOptions] = None) -> str: + """ + GET with path param + + Parameters + ---------- + param : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.params.get_with_path( + param="param", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"params/path/{jsonable_encoder(param)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + str, + parse_obj_as( + type_=str, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_with_query( + self, *, query: str, number: int, request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + GET with query param + + Parameters + ---------- + query : str + + number : int + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.params.get_with_query( + query="query", + number=1, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "params", + method="GET", + params={ + "query": query, + "number": number, + }, + 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) + + async def get_with_allow_multiple_query( + self, + *, + query: typing.Union[str, typing.Sequence[str]], + numer: typing.Union[int, typing.Sequence[int]], + request_options: typing.Optional[RequestOptions] = None, + ) -> None: + """ + GET with multiple of same query param + + Parameters + ---------- + query : typing.Union[str, typing.Sequence[str]] + + numer : typing.Union[int, typing.Sequence[int]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.params.get_with_allow_multiple_query( + query="query", + numer=1, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "params", + method="GET", + params={ + "query": query, + "numer": numer, + }, + 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) + + async def get_with_path_and_query( + self, param: str, *, query: str, request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + GET with path and query params + + Parameters + ---------- + param : str + + query : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.params.get_with_path_and_query( + param="param", + query="query", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"params/path-query/{jsonable_encoder(param)}", + method="GET", + params={ + "query": query, + }, + 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) + + async def modify_with_path( + self, param: str, *, request: str, request_options: typing.Optional[RequestOptions] = None + ) -> str: + """ + PUT to update with path param + + Parameters + ---------- + param : str + + request : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.params.modify_with_path( + param="param", + request="string", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"params/path/{jsonable_encoder(param)}", + method="PUT", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + str, + parse_obj_as( + type_=str, # type: ignore + object_=_response.json(), + ), + ) + _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) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/primitive/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/primitive/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/primitive/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/primitive/client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/primitive/client.py new file mode 100644 index 00000000000..5e18f184482 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/primitive/client.py @@ -0,0 +1,969 @@ +# 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 ...core.pydantic_utilities import parse_obj_as +from json.decoder import JSONDecodeError +from ...core.api_error import ApiError +import datetime as dt +import uuid +from ...core.client_wrapper import AsyncClientWrapper + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class PrimitiveClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_and_return_string(self, *, request: str, request_options: typing.Optional[RequestOptions] = None) -> str: + """ + Parameters + ---------- + request : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.primitive.get_and_return_string( + request="string", + ) + """ + _response = self._client_wrapper.httpx_client.request( + "primitive/string", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + str, + parse_obj_as( + type_=str, # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_int(self, *, request: int, request_options: typing.Optional[RequestOptions] = None) -> int: + """ + Parameters + ---------- + request : int + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + int + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.primitive.get_and_return_int( + request=1, + ) + """ + _response = self._client_wrapper.httpx_client.request( + "primitive/integer", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + int, + parse_obj_as( + type_=int, # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_long(self, *, request: int, request_options: typing.Optional[RequestOptions] = None) -> int: + """ + Parameters + ---------- + request : int + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + int + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.primitive.get_and_return_long( + request=1000000, + ) + """ + _response = self._client_wrapper.httpx_client.request( + "primitive/long", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + int, + parse_obj_as( + type_=int, # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_double( + self, *, request: float, request_options: typing.Optional[RequestOptions] = None + ) -> float: + """ + Parameters + ---------- + request : float + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + float + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.primitive.get_and_return_double( + request=1.1, + ) + """ + _response = self._client_wrapper.httpx_client.request( + "primitive/double", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + float, + parse_obj_as( + type_=float, # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_bool(self, *, request: bool, request_options: typing.Optional[RequestOptions] = None) -> bool: + """ + Parameters + ---------- + request : bool + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + bool + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.primitive.get_and_return_bool( + request=True, + ) + """ + _response = self._client_wrapper.httpx_client.request( + "primitive/boolean", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + bool, + parse_obj_as( + type_=bool, # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_datetime( + self, *, request: dt.datetime, request_options: typing.Optional[RequestOptions] = None + ) -> dt.datetime: + """ + Parameters + ---------- + request : dt.datetime + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + dt.datetime + + Examples + -------- + import datetime + + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.primitive.get_and_return_datetime( + request=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + ) + """ + _response = self._client_wrapper.httpx_client.request( + "primitive/datetime", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + dt.datetime, + parse_obj_as( + type_=dt.datetime, # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_date( + self, *, request: dt.date, request_options: typing.Optional[RequestOptions] = None + ) -> dt.date: + """ + Parameters + ---------- + request : dt.date + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + dt.date + + Examples + -------- + import datetime + + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.primitive.get_and_return_date( + request=datetime.date.fromisoformat( + "2023-01-15", + ), + ) + """ + _response = self._client_wrapper.httpx_client.request( + "primitive/date", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + dt.date, + parse_obj_as( + type_=dt.date, # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_uuid( + self, *, request: uuid.UUID, request_options: typing.Optional[RequestOptions] = None + ) -> uuid.UUID: + """ + Parameters + ---------- + request : uuid.UUID + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + uuid.UUID + + Examples + -------- + import uuid + + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.primitive.get_and_return_uuid( + request=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + ) + """ + _response = self._client_wrapper.httpx_client.request( + "primitive/uuid", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + uuid.UUID, + parse_obj_as( + type_=uuid.UUID, # type: ignore + object_=_response.json(), + ), + ) + _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_and_return_base_64(self, *, request: str, request_options: typing.Optional[RequestOptions] = None) -> str: + """ + Parameters + ---------- + request : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.primitive.get_and_return_base_64( + request="SGVsbG8gd29ybGQh", + ) + """ + _response = self._client_wrapper.httpx_client.request( + "primitive/base64", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + str, + parse_obj_as( + type_=str, # type: ignore + object_=_response.json(), + ), + ) + _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 AsyncPrimitiveClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_and_return_string( + self, *, request: str, request_options: typing.Optional[RequestOptions] = None + ) -> str: + """ + Parameters + ---------- + request : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.primitive.get_and_return_string( + request="string", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "primitive/string", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + str, + parse_obj_as( + type_=str, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_int(self, *, request: int, request_options: typing.Optional[RequestOptions] = None) -> int: + """ + Parameters + ---------- + request : int + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + int + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.primitive.get_and_return_int( + request=1, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "primitive/integer", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + int, + parse_obj_as( + type_=int, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_long( + self, *, request: int, request_options: typing.Optional[RequestOptions] = None + ) -> int: + """ + Parameters + ---------- + request : int + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + int + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.primitive.get_and_return_long( + request=1000000, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "primitive/long", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + int, + parse_obj_as( + type_=int, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_double( + self, *, request: float, request_options: typing.Optional[RequestOptions] = None + ) -> float: + """ + Parameters + ---------- + request : float + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + float + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.primitive.get_and_return_double( + request=1.1, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "primitive/double", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + float, + parse_obj_as( + type_=float, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_bool( + self, *, request: bool, request_options: typing.Optional[RequestOptions] = None + ) -> bool: + """ + Parameters + ---------- + request : bool + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + bool + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.primitive.get_and_return_bool( + request=True, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "primitive/boolean", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + bool, + parse_obj_as( + type_=bool, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_datetime( + self, *, request: dt.datetime, request_options: typing.Optional[RequestOptions] = None + ) -> dt.datetime: + """ + Parameters + ---------- + request : dt.datetime + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + dt.datetime + + Examples + -------- + import asyncio + import datetime + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.primitive.get_and_return_datetime( + request=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "primitive/datetime", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + dt.datetime, + parse_obj_as( + type_=dt.datetime, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_date( + self, *, request: dt.date, request_options: typing.Optional[RequestOptions] = None + ) -> dt.date: + """ + Parameters + ---------- + request : dt.date + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + dt.date + + Examples + -------- + import asyncio + import datetime + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.primitive.get_and_return_date( + request=datetime.date.fromisoformat( + "2023-01-15", + ), + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "primitive/date", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + dt.date, + parse_obj_as( + type_=dt.date, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_uuid( + self, *, request: uuid.UUID, request_options: typing.Optional[RequestOptions] = None + ) -> uuid.UUID: + """ + Parameters + ---------- + request : uuid.UUID + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + uuid.UUID + + Examples + -------- + import asyncio + import uuid + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.primitive.get_and_return_uuid( + request=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "primitive/uuid", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + uuid.UUID, + parse_obj_as( + type_=uuid.UUID, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def get_and_return_base_64( + self, *, request: str, request_options: typing.Optional[RequestOptions] = None + ) -> str: + """ + Parameters + ---------- + request : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.primitive.get_and_return_base_64( + request="SGVsbG8gd29ybGQh", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "primitive/base64", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + str, + parse_obj_as( + type_=str, # type: ignore + object_=_response.json(), + ), + ) + _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) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/union/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/union/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/union/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/union/client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/union/client.py new file mode 100644 index 00000000000..f469c0814a8 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/endpoints/union/client.py @@ -0,0 +1,136 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from ...core.client_wrapper import SyncClientWrapper +from ...types.union.types.animal import Animal +from ...core.request_options import RequestOptions +from ...core.serialization import convert_and_respect_annotation_metadata +from ...core.pydantic_utilities import parse_obj_as +from json.decoder import JSONDecodeError +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class UnionClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_and_return_union( + self, *, request: Animal, request_options: typing.Optional[RequestOptions] = None + ) -> Animal: + """ + Parameters + ---------- + request : Animal + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Animal + + Examples + -------- + from seed import SeedExhaustive + from seed.types.union import Animal_Dog + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.endpoints.union.get_and_return_union( + request=Animal_Dog( + name="name", + likes_to_woof=True, + ), + ) + """ + _response = self._client_wrapper.httpx_client.request( + "union", + method="POST", + json=convert_and_respect_annotation_metadata(object_=request, annotation=Animal, direction="write"), + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + Animal, + parse_obj_as( + type_=Animal, # type: ignore + object_=_response.json(), + ), + ) + _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 AsyncUnionClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_and_return_union( + self, *, request: Animal, request_options: typing.Optional[RequestOptions] = None + ) -> Animal: + """ + Parameters + ---------- + request : Animal + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Animal + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + from seed.types.union import Animal_Dog + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.endpoints.union.get_and_return_union( + request=Animal_Dog( + name="name", + likes_to_woof=True, + ), + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "union", + method="POST", + json=convert_and_respect_annotation_metadata(object_=request, annotation=Animal, direction="write"), + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + Animal, + parse_obj_as( + type_=Animal, # type: ignore + object_=_response.json(), + ), + ) + _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) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/__init__.py new file mode 100644 index 00000000000..57de0a862e9 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/__init__.py @@ -0,0 +1,6 @@ +# This file was auto-generated by Fern from our API Definition. + +from .types import BadObjectRequestInfo +from .errors import BadRequestBody + +__all__ = ["BadObjectRequestInfo", "BadRequestBody"] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/errors/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/errors/__init__.py new file mode 100644 index 00000000000..04eaf8e383b --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/errors/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .bad_request_body import BadRequestBody + +__all__ = ["BadRequestBody"] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/errors/bad_request_body.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/errors/bad_request_body.py new file mode 100644 index 00000000000..f8518e355d0 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/errors/bad_request_body.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.api_error import ApiError +from ..types.bad_object_request_info import BadObjectRequestInfo + + +class BadRequestBody(ApiError): + def __init__(self, body: BadObjectRequestInfo): + super().__init__(status_code=400, body=body) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/types/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/types/__init__.py new file mode 100644 index 00000000000..b6788a57056 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/types/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .bad_object_request_info import BadObjectRequestInfo + +__all__ = ["BadObjectRequestInfo"] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/types/bad_object_request_info.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/types/bad_object_request_info.py new file mode 100644 index 00000000000..7e1e0e7be39 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/general_errors/types/bad_object_request_info.py @@ -0,0 +1,126 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ...core.pydantic_utilities import UniversalBaseModel +import typing +import typing_extensions +import pydantic +from ...core.pydantic_utilities import universal_field_validator + + +class BadObjectRequestInfo(UniversalBaseModel): + message: str + + class Partial(typing.TypedDict): + message: typing_extensions.NotRequired[str] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @BadObjectRequestInfo.Validators.root() + def validate(values: BadObjectRequestInfo.Partial) -> BadObjectRequestInfo.Partial: + ... + + @BadObjectRequestInfo.Validators.field("message") + def validate_message(message: str, values: BadObjectRequestInfo.Partial) -> str: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[BadObjectRequestInfo.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[BadObjectRequestInfo.Validators._RootValidator]] = [] + _message_pre_validators: typing.ClassVar[typing.List[BadObjectRequestInfo.Validators.PreMessageValidator]] = [] + _message_post_validators: typing.ClassVar[typing.List[BadObjectRequestInfo.Validators.MessageValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [BadObjectRequestInfo.Validators._RootValidator], BadObjectRequestInfo.Validators._RootValidator + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [BadObjectRequestInfo.Validators._PreRootValidator], BadObjectRequestInfo.Validators._PreRootValidator + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["message"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [BadObjectRequestInfo.Validators.PreMessageValidator], BadObjectRequestInfo.Validators.PreMessageValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["message"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [BadObjectRequestInfo.Validators.MessageValidator], BadObjectRequestInfo.Validators.MessageValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "message": + if pre: + cls._message_pre_validators.append(validator) + else: + cls._message_post_validators.append(validator) + return validator + + return decorator + + class PreMessageValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: BadObjectRequestInfo.Partial) -> typing.Any: ... + + class MessageValidator(typing.Protocol): + def __call__(self, __v: str, __values: BadObjectRequestInfo.Partial) -> str: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: BadObjectRequestInfo.Partial) -> BadObjectRequestInfo.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_bad_object_request_info( + cls, values: BadObjectRequestInfo.Partial + ) -> BadObjectRequestInfo.Partial: + for validator in BadObjectRequestInfo.Validators._pre_validators: + values = validator(values) + return values + + @pydantic.model_validator(mode="after") + def _post_validate_bad_object_request_info( + cls, values: BadObjectRequestInfo.Partial + ) -> BadObjectRequestInfo.Partial: + for validator in BadObjectRequestInfo.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("message", pre=True) + def _pre_validate_message(cls, v: str, values: BadObjectRequestInfo.Partial) -> str: + for validator in BadObjectRequestInfo.Validators._message_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("message", pre=False) + def _post_validate_message(cls, v: str, values: BadObjectRequestInfo.Partial) -> str: + for validator in BadObjectRequestInfo.Validators._message_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/inlined_requests/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/inlined_requests/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/inlined_requests/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/inlined_requests/client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/inlined_requests/client.py new file mode 100644 index 00000000000..096f1dc8f93 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/inlined_requests/client.py @@ -0,0 +1,235 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from ..core.client_wrapper import SyncClientWrapper +from ..types.object.types.object_with_optional_field import ObjectWithOptionalField +from ..core.request_options import RequestOptions +from ..core.serialization import convert_and_respect_annotation_metadata +from ..core.pydantic_utilities import parse_obj_as +from ..general_errors.errors.bad_request_body import BadRequestBody +from ..general_errors.types.bad_object_request_info import BadObjectRequestInfo +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class InlinedRequestsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def post_with_object_bodyand_response( + self, + *, + string: str, + integer: int, + nested_object: ObjectWithOptionalField, + request_options: typing.Optional[RequestOptions] = None, + ) -> ObjectWithOptionalField: + """ + POST with custom object in request body, response is an object + + Parameters + ---------- + string : str + + integer : int + + nested_object : ObjectWithOptionalField + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithOptionalField + + Examples + -------- + import datetime + import uuid + + from seed import SeedExhaustive + from seed.types.object import ObjectWithOptionalField + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.inlined_requests.post_with_object_bodyand_response( + string="string", + integer=1, + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ) + """ + _response = self._client_wrapper.httpx_client.request( + "req-bodies/object", + method="POST", + json={ + "string": string, + "integer": integer, + "NestedObject": convert_and_respect_annotation_metadata( + object_=nested_object, annotation=ObjectWithOptionalField, direction="write" + ), + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithOptionalField, + parse_obj_as( + type_=ObjectWithOptionalField, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 400: + raise BadRequestBody( + typing.cast( + BadObjectRequestInfo, + parse_obj_as( + type_=BadObjectRequestInfo, # type: ignore + object_=_response.json(), + ), + ) + ) + _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 AsyncInlinedRequestsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def post_with_object_bodyand_response( + self, + *, + string: str, + integer: int, + nested_object: ObjectWithOptionalField, + request_options: typing.Optional[RequestOptions] = None, + ) -> ObjectWithOptionalField: + """ + POST with custom object in request body, response is an object + + Parameters + ---------- + string : str + + integer : int + + nested_object : ObjectWithOptionalField + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithOptionalField + + Examples + -------- + import asyncio + import datetime + import uuid + + from seed import AsyncSeedExhaustive + from seed.types.object import ObjectWithOptionalField + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.inlined_requests.post_with_object_bodyand_response( + string="string", + integer=1, + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat( + "2024-01-15 09:30:00+00:00", + ), + date=datetime.date.fromisoformat( + "2023-01-15", + ), + uuid_=uuid.UUID( + "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + ), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "req-bodies/object", + method="POST", + json={ + "string": string, + "integer": integer, + "NestedObject": convert_and_respect_annotation_metadata( + object_=nested_object, annotation=ObjectWithOptionalField, direction="write" + ), + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithOptionalField, + parse_obj_as( + type_=ObjectWithOptionalField, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 400: + raise BadRequestBody( + typing.cast( + BadObjectRequestInfo, + parse_obj_as( + type_=BadObjectRequestInfo, # type: ignore + object_=_response.json(), + ), + ) + ) + _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) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/no_auth/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/no_auth/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/no_auth/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/no_auth/client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/no_auth/client.py new file mode 100644 index 00000000000..886ef5803e9 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/no_auth/client.py @@ -0,0 +1,152 @@ +# 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 ..core.pydantic_utilities import parse_obj_as +from ..general_errors.errors.bad_request_body import BadRequestBody +from ..general_errors.types.bad_object_request_info import BadObjectRequestInfo +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class NoAuthClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def post_with_no_auth( + self, *, request: typing.Optional[typing.Any] = None, request_options: typing.Optional[RequestOptions] = None + ) -> bool: + """ + POST request with no auth + + Parameters + ---------- + request : typing.Optional[typing.Any] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + bool + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.no_auth.post_with_no_auth( + request={"key": "value"}, + ) + """ + _response = self._client_wrapper.httpx_client.request( + "no-auth", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + bool, + parse_obj_as( + type_=bool, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 400: + raise BadRequestBody( + typing.cast( + BadObjectRequestInfo, + parse_obj_as( + type_=BadObjectRequestInfo, # type: ignore + object_=_response.json(), + ), + ) + ) + _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 AsyncNoAuthClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def post_with_no_auth( + self, *, request: typing.Optional[typing.Any] = None, request_options: typing.Optional[RequestOptions] = None + ) -> bool: + """ + POST request with no auth + + Parameters + ---------- + request : typing.Optional[typing.Any] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + bool + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.no_auth.post_with_no_auth( + request={"key": "value"}, + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "no-auth", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + bool, + parse_obj_as( + type_=bool, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 400: + raise BadRequestBody( + typing.cast( + BadObjectRequestInfo, + parse_obj_as( + type_=BadObjectRequestInfo, # type: ignore + object_=_response.json(), + ), + ) + ) + _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) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/no_req_body/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/no_req_body/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/no_req_body/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/no_req_body/client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/no_req_body/client.py new file mode 100644 index 00000000000..f6408c8c391 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/no_req_body/client.py @@ -0,0 +1,200 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.client_wrapper import SyncClientWrapper +import typing +from ..core.request_options import RequestOptions +from ..types.object.types.object_with_optional_field import ObjectWithOptionalField +from ..core.pydantic_utilities import parse_obj_as +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper + + +class NoReqBodyClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_with_no_request_body( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> ObjectWithOptionalField: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithOptionalField + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.no_req_body.get_with_no_request_body() + """ + _response = self._client_wrapper.httpx_client.request( + "no-req-body", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithOptionalField, + parse_obj_as( + type_=ObjectWithOptionalField, # type: ignore + object_=_response.json(), + ), + ) + _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 post_with_no_request_body(self, *, request_options: typing.Optional[RequestOptions] = None) -> str: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.no_req_body.post_with_no_request_body() + """ + _response = self._client_wrapper.httpx_client.request( + "no-req-body", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + str, + parse_obj_as( + type_=str, # type: ignore + object_=_response.json(), + ), + ) + _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 AsyncNoReqBodyClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_with_no_request_body( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> ObjectWithOptionalField: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ObjectWithOptionalField + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.no_req_body.get_with_no_request_body() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "no-req-body", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ObjectWithOptionalField, + parse_obj_as( + type_=ObjectWithOptionalField, # type: ignore + object_=_response.json(), + ), + ) + _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) + + async def post_with_no_request_body(self, *, request_options: typing.Optional[RequestOptions] = None) -> str: + """ + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.no_req_body.post_with_no_request_body() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "no-req-body", + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + str, + parse_obj_as( + type_=str, # type: ignore + object_=_response.json(), + ), + ) + _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) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/py.typed b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/req_with_headers/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/req_with_headers/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/req_with_headers/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/req_with_headers/client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/req_with_headers/client.py new file mode 100644 index 00000000000..98e03a9b5fe --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/req_with_headers/client.py @@ -0,0 +1,143 @@ +# 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 json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class ReqWithHeadersClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_with_custom_header( + self, + *, + x_test_service_header: str, + x_test_endpoint_header: str, + request: str, + request_options: typing.Optional[RequestOptions] = None, + ) -> None: + """ + Parameters + ---------- + x_test_service_header : str + + x_test_endpoint_header : str + + request : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from seed import SeedExhaustive + + client = SeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + client.req_with_headers.get_with_custom_header( + x_test_service_header="X-TEST-SERVICE-HEADER", + x_test_endpoint_header="X-TEST-ENDPOINT-HEADER", + request="string", + ) + """ + _response = self._client_wrapper.httpx_client.request( + "test-headers/custom-header", + method="POST", + json=request, + headers={ + "X-TEST-SERVICE-HEADER": str(x_test_service_header) if x_test_service_header is not None else None, + "X-TEST-ENDPOINT-HEADER": str(x_test_endpoint_header) if x_test_endpoint_header is not None else None, + }, + request_options=request_options, + omit=OMIT, + ) + 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 AsyncReqWithHeadersClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_with_custom_header( + self, + *, + x_test_service_header: str, + x_test_endpoint_header: str, + request: str, + request_options: typing.Optional[RequestOptions] = None, + ) -> None: + """ + Parameters + ---------- + x_test_service_header : str + + x_test_endpoint_header : str + + request : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from seed import AsyncSeedExhaustive + + client = AsyncSeedExhaustive( + token="YOUR_TOKEN", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.req_with_headers.get_with_custom_header( + x_test_service_header="X-TEST-SERVICE-HEADER", + x_test_endpoint_header="X-TEST-ENDPOINT-HEADER", + request="string", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "test-headers/custom-header", + method="POST", + json=request, + headers={ + "X-TEST-SERVICE-HEADER": str(x_test_service_header) if x_test_service_header is not None else None, + "X-TEST-ENDPOINT-HEADER": str(x_test_endpoint_header) if x_test_endpoint_header is not None else None, + }, + request_options=request_options, + omit=OMIT, + ) + 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) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/__init__.py new file mode 100644 index 00000000000..e7a49db5142 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/__init__.py @@ -0,0 +1,43 @@ +# This file was auto-generated by Fern from our API Definition. + +from . import enum, object, union +from .enum import ErrorWithEnumBody, WeatherReport +from .object import ( + DoubleOptional, + NestedObjectWithOptionalField, + NestedObjectWithOptionalFieldError, + NestedObjectWithRequiredField, + NestedObjectWithRequiredFieldError, + ObjectWithMapOfMap, + ObjectWithOptionalField, + ObjectWithOptionalFieldError, + ObjectWithRequiredField, + ObjectWithRequiredFieldError, + OptionalAlias, +) +from .union import Animal, Animal_Cat, Animal_Dog, Cat, Dog, ErrorWithUnionBody + +__all__ = [ + "Animal", + "Animal_Cat", + "Animal_Dog", + "Cat", + "Dog", + "DoubleOptional", + "ErrorWithEnumBody", + "ErrorWithUnionBody", + "NestedObjectWithOptionalField", + "NestedObjectWithOptionalFieldError", + "NestedObjectWithRequiredField", + "NestedObjectWithRequiredFieldError", + "ObjectWithMapOfMap", + "ObjectWithOptionalField", + "ObjectWithOptionalFieldError", + "ObjectWithRequiredField", + "ObjectWithRequiredFieldError", + "OptionalAlias", + "WeatherReport", + "enum", + "object", + "union", +] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/__init__.py new file mode 100644 index 00000000000..b1c48999a72 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/__init__.py @@ -0,0 +1,6 @@ +# This file was auto-generated by Fern from our API Definition. + +from .types import WeatherReport +from .errors import ErrorWithEnumBody + +__all__ = ["ErrorWithEnumBody", "WeatherReport"] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/errors/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/errors/__init__.py new file mode 100644 index 00000000000..f5945e36d9d --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/errors/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .error_with_enum_body import ErrorWithEnumBody + +__all__ = ["ErrorWithEnumBody"] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/errors/error_with_enum_body.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/errors/error_with_enum_body.py new file mode 100644 index 00000000000..dfdc65ac0a2 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/errors/error_with_enum_body.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.api_error import ApiError +from ..types.weather_report import WeatherReport + + +class ErrorWithEnumBody(ApiError): + def __init__(self, body: WeatherReport): + super().__init__(status_code=400, body=body) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/types/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/types/__init__.py new file mode 100644 index 00000000000..7a47d1fefc6 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/types/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .weather_report import WeatherReport + +__all__ = ["WeatherReport"] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/types/weather_report.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/types/weather_report.py new file mode 100644 index 00000000000..2d54965dc22 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/enum/types/weather_report.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +WeatherReport = typing.Union[typing.Literal["SUNNY", "CLOUDY", "RAINING", "SNOWING"], typing.Any] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/__init__.py new file mode 100644 index 00000000000..e3a774b5a05 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/__init__.py @@ -0,0 +1,31 @@ +# This file was auto-generated by Fern from our API Definition. + +from .types import ( + DoubleOptional, + NestedObjectWithOptionalField, + NestedObjectWithRequiredField, + ObjectWithMapOfMap, + ObjectWithOptionalField, + ObjectWithRequiredField, + OptionalAlias, +) +from .errors import ( + NestedObjectWithOptionalFieldError, + NestedObjectWithRequiredFieldError, + ObjectWithOptionalFieldError, + ObjectWithRequiredFieldError, +) + +__all__ = [ + "DoubleOptional", + "NestedObjectWithOptionalField", + "NestedObjectWithOptionalFieldError", + "NestedObjectWithRequiredField", + "NestedObjectWithRequiredFieldError", + "ObjectWithMapOfMap", + "ObjectWithOptionalField", + "ObjectWithOptionalFieldError", + "ObjectWithRequiredField", + "ObjectWithRequiredFieldError", + "OptionalAlias", +] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/__init__.py new file mode 100644 index 00000000000..7e7e4c63aa8 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/__init__.py @@ -0,0 +1,13 @@ +# This file was auto-generated by Fern from our API Definition. + +from .nested_object_with_optional_field_error import NestedObjectWithOptionalFieldError +from .nested_object_with_required_field_error import NestedObjectWithRequiredFieldError +from .object_with_optional_field_error import ObjectWithOptionalFieldError +from .object_with_required_field_error import ObjectWithRequiredFieldError + +__all__ = [ + "NestedObjectWithOptionalFieldError", + "NestedObjectWithRequiredFieldError", + "ObjectWithOptionalFieldError", + "ObjectWithRequiredFieldError", +] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/nested_object_with_optional_field_error.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/nested_object_with_optional_field_error.py new file mode 100644 index 00000000000..a3886c45b34 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/nested_object_with_optional_field_error.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.api_error import ApiError +from ..types.nested_object_with_optional_field import NestedObjectWithOptionalField + + +class NestedObjectWithOptionalFieldError(ApiError): + def __init__(self, body: NestedObjectWithOptionalField): + super().__init__(status_code=400, body=body) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/nested_object_with_required_field_error.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/nested_object_with_required_field_error.py new file mode 100644 index 00000000000..3b6b788d492 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/nested_object_with_required_field_error.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.api_error import ApiError +from ..types.nested_object_with_required_field import NestedObjectWithRequiredField + + +class NestedObjectWithRequiredFieldError(ApiError): + def __init__(self, body: NestedObjectWithRequiredField): + super().__init__(status_code=400, body=body) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/object_with_optional_field_error.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/object_with_optional_field_error.py new file mode 100644 index 00000000000..3652a448b6e --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/object_with_optional_field_error.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.api_error import ApiError +from ..types.object_with_optional_field import ObjectWithOptionalField + + +class ObjectWithOptionalFieldError(ApiError): + def __init__(self, body: ObjectWithOptionalField): + super().__init__(status_code=400, body=body) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/object_with_required_field_error.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/object_with_required_field_error.py new file mode 100644 index 00000000000..ee17778fd26 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/errors/object_with_required_field_error.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.api_error import ApiError +from ..types.object_with_required_field import ObjectWithRequiredField + + +class ObjectWithRequiredFieldError(ApiError): + def __init__(self, body: ObjectWithRequiredField): + super().__init__(status_code=400, body=body) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/__init__.py new file mode 100644 index 00000000000..2620e6eea12 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/__init__.py @@ -0,0 +1,19 @@ +# This file was auto-generated by Fern from our API Definition. + +from .double_optional import DoubleOptional +from .nested_object_with_optional_field import NestedObjectWithOptionalField +from .nested_object_with_required_field import NestedObjectWithRequiredField +from .object_with_map_of_map import ObjectWithMapOfMap +from .object_with_optional_field import ObjectWithOptionalField +from .object_with_required_field import ObjectWithRequiredField +from .optional_alias import OptionalAlias + +__all__ = [ + "DoubleOptional", + "NestedObjectWithOptionalField", + "NestedObjectWithRequiredField", + "ObjectWithMapOfMap", + "ObjectWithOptionalField", + "ObjectWithRequiredField", + "OptionalAlias", +] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/double_optional.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/double_optional.py new file mode 100644 index 00000000000..eb3461caf6d --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/double_optional.py @@ -0,0 +1,142 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ....core.pydantic_utilities import UniversalBaseModel +import typing_extensions +import typing +from .optional_alias import OptionalAlias +from ....core.serialization import FieldMetadata +import pydantic +from ....core.pydantic_utilities import universal_field_validator + + +class DoubleOptional(UniversalBaseModel): + optional_alias: typing_extensions.Annotated[ + typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias") + ] = None + + class Partial(typing.TypedDict): + optional_alias: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @DoubleOptional.Validators.root() + def validate(values: DoubleOptional.Partial) -> DoubleOptional.Partial: + ... + + @DoubleOptional.Validators.field("optional_alias") + def validate_optional_alias(optional_alias: typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")], values: DoubleOptional.Partial) -> typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[DoubleOptional.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[DoubleOptional.Validators._RootValidator]] = [] + _optional_alias_pre_validators: typing.ClassVar[ + typing.List[DoubleOptional.Validators.PreOptionalAliasValidator] + ] = [] + _optional_alias_post_validators: typing.ClassVar[ + typing.List[DoubleOptional.Validators.OptionalAliasValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[[DoubleOptional.Validators._RootValidator], DoubleOptional.Validators._RootValidator]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [DoubleOptional.Validators._PreRootValidator], DoubleOptional.Validators._PreRootValidator + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["optional_alias"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [DoubleOptional.Validators.PreOptionalAliasValidator], DoubleOptional.Validators.PreOptionalAliasValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["optional_alias"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [DoubleOptional.Validators.OptionalAliasValidator], DoubleOptional.Validators.OptionalAliasValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "optional_alias": + if pre: + cls._optional_alias_pre_validators.append(validator) + else: + cls._optional_alias_post_validators.append(validator) + return validator + + return decorator + + class PreOptionalAliasValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: DoubleOptional.Partial) -> typing.Any: ... + + class OptionalAliasValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")], + __values: DoubleOptional.Partial, + ) -> typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: DoubleOptional.Partial) -> DoubleOptional.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_double_optional(cls, values: DoubleOptional.Partial) -> DoubleOptional.Partial: + for validator in DoubleOptional.Validators._pre_validators: + values = validator(values) + return values + + @pydantic.model_validator(mode="after") + def _post_validate_types_double_optional(cls, values: DoubleOptional.Partial) -> DoubleOptional.Partial: + for validator in DoubleOptional.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("optional_alias", pre=True) + def _pre_validate_optional_alias( + cls, + v: typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")], + values: DoubleOptional.Partial, + ) -> typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")]: + for validator in DoubleOptional.Validators._optional_alias_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("optional_alias", pre=False) + def _post_validate_optional_alias( + cls, + v: typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")], + values: DoubleOptional.Partial, + ) -> typing_extensions.Annotated[typing.Optional[OptionalAlias], FieldMetadata(alias="optionalAlias")]: + for validator in DoubleOptional.Validators._optional_alias_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/nested_object_with_optional_field.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/nested_object_with_optional_field.py new file mode 100644 index 00000000000..ec4f22d7281 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/nested_object_with_optional_field.py @@ -0,0 +1,215 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ....core.pydantic_utilities import UniversalBaseModel +import typing +import typing_extensions +from .object_with_optional_field import ObjectWithOptionalField +from ....core.serialization import FieldMetadata +import pydantic +from ....core.pydantic_utilities import universal_field_validator + + +class NestedObjectWithOptionalField(UniversalBaseModel): + string: typing.Optional[str] = None + nested_object: typing_extensions.Annotated[ + typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject") + ] = None + + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[typing.Optional[str]] + nested_object: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @NestedObjectWithOptionalField.Validators.root() + def validate(values: NestedObjectWithOptionalField.Partial) -> NestedObjectWithOptionalField.Partial: + ... + + @NestedObjectWithOptionalField.Validators.field("string") + def validate_string(string: typing.Optional[str], values: NestedObjectWithOptionalField.Partial) -> typing.Optional[str]: + ... + + @NestedObjectWithOptionalField.Validators.field("nested_object") + def validate_nested_object(nested_object: typing_extensions.Annotated[typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject")], values: NestedObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[NestedObjectWithOptionalField.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[NestedObjectWithOptionalField.Validators._RootValidator]] = [] + _string_pre_validators: typing.ClassVar[ + typing.List[NestedObjectWithOptionalField.Validators.PreStringValidator] + ] = [] + _string_post_validators: typing.ClassVar[ + typing.List[NestedObjectWithOptionalField.Validators.StringValidator] + ] = [] + _nested_object_pre_validators: typing.ClassVar[ + typing.List[NestedObjectWithOptionalField.Validators.PreNestedObjectValidator] + ] = [] + _nested_object_post_validators: typing.ClassVar[ + typing.List[NestedObjectWithOptionalField.Validators.NestedObjectValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators._RootValidator], + NestedObjectWithOptionalField.Validators._RootValidator, + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators._PreRootValidator], + NestedObjectWithOptionalField.Validators._PreRootValidator, + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators.PreStringValidator], + NestedObjectWithOptionalField.Validators.PreStringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators.StringValidator], + NestedObjectWithOptionalField.Validators.StringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["nested_object"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators.PreNestedObjectValidator], + NestedObjectWithOptionalField.Validators.PreNestedObjectValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["nested_object"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [NestedObjectWithOptionalField.Validators.NestedObjectValidator], + NestedObjectWithOptionalField.Validators.NestedObjectValidator, + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "string": + if pre: + cls._string_pre_validators.append(validator) + else: + cls._string_post_validators.append(validator) + if field_name == "nested_object": + if pre: + cls._nested_object_pre_validators.append(validator) + else: + cls._nested_object_post_validators.append(validator) + return validator + + return decorator + + class PreStringValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: NestedObjectWithOptionalField.Partial) -> typing.Any: ... + + class StringValidator(typing.Protocol): + def __call__( + self, __v: typing.Optional[str], __values: NestedObjectWithOptionalField.Partial + ) -> typing.Optional[str]: ... + + class PreNestedObjectValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: NestedObjectWithOptionalField.Partial) -> typing.Any: ... + + class NestedObjectValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[ + typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject") + ], + __values: NestedObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[ + typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject") + ]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__( + self, __values: NestedObjectWithOptionalField.Partial + ) -> NestedObjectWithOptionalField.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_nested_object_with_optional_field( + cls, values: NestedObjectWithOptionalField.Partial + ) -> NestedObjectWithOptionalField.Partial: + for validator in NestedObjectWithOptionalField.Validators._pre_validators: + values = validator(values) + return values + + @pydantic.model_validator(mode="after") + def _post_validate_types_nested_object_with_optional_field( + cls, values: NestedObjectWithOptionalField.Partial + ) -> NestedObjectWithOptionalField.Partial: + for validator in NestedObjectWithOptionalField.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("string", pre=True) + def _pre_validate_string( + cls, v: typing.Optional[str], values: NestedObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in NestedObjectWithOptionalField.Validators._string_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("string", pre=False) + def _post_validate_string( + cls, v: typing.Optional[str], values: NestedObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in NestedObjectWithOptionalField.Validators._string_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("nested_object", pre=True) + def _pre_validate_nested_object( + cls, + v: typing_extensions.Annotated[typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject")], + values: NestedObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject")]: + for validator in NestedObjectWithOptionalField.Validators._nested_object_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("nested_object", pre=False) + def _post_validate_nested_object( + cls, + v: typing_extensions.Annotated[typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject")], + values: NestedObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[ObjectWithOptionalField], FieldMetadata(alias="NestedObject")]: + for validator in NestedObjectWithOptionalField.Validators._nested_object_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/nested_object_with_required_field.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/nested_object_with_required_field.py new file mode 100644 index 00000000000..b08532939a5 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/nested_object_with_required_field.py @@ -0,0 +1,203 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ....core.pydantic_utilities import UniversalBaseModel +import typing_extensions +from .object_with_optional_field import ObjectWithOptionalField +from ....core.serialization import FieldMetadata +import typing +import pydantic +from ....core.pydantic_utilities import universal_field_validator + + +class NestedObjectWithRequiredField(UniversalBaseModel): + string: str + nested_object: typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")] + + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[str] + nested_object: typing_extensions.NotRequired[ + typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @NestedObjectWithRequiredField.Validators.root() + def validate(values: NestedObjectWithRequiredField.Partial) -> NestedObjectWithRequiredField.Partial: + ... + + @NestedObjectWithRequiredField.Validators.field("string") + def validate_string(string: str, values: NestedObjectWithRequiredField.Partial) -> str: + ... + + @NestedObjectWithRequiredField.Validators.field("nested_object") + def validate_nested_object(nested_object: typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")], values: NestedObjectWithRequiredField.Partial) -> typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[NestedObjectWithRequiredField.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[NestedObjectWithRequiredField.Validators._RootValidator]] = [] + _string_pre_validators: typing.ClassVar[ + typing.List[NestedObjectWithRequiredField.Validators.PreStringValidator] + ] = [] + _string_post_validators: typing.ClassVar[ + typing.List[NestedObjectWithRequiredField.Validators.StringValidator] + ] = [] + _nested_object_pre_validators: typing.ClassVar[ + typing.List[NestedObjectWithRequiredField.Validators.PreNestedObjectValidator] + ] = [] + _nested_object_post_validators: typing.ClassVar[ + typing.List[NestedObjectWithRequiredField.Validators.NestedObjectValidator] + ] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators._RootValidator], + NestedObjectWithRequiredField.Validators._RootValidator, + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators._PreRootValidator], + NestedObjectWithRequiredField.Validators._PreRootValidator, + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators.PreStringValidator], + NestedObjectWithRequiredField.Validators.PreStringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators.StringValidator], + NestedObjectWithRequiredField.Validators.StringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["nested_object"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators.PreNestedObjectValidator], + NestedObjectWithRequiredField.Validators.PreNestedObjectValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["nested_object"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [NestedObjectWithRequiredField.Validators.NestedObjectValidator], + NestedObjectWithRequiredField.Validators.NestedObjectValidator, + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "string": + if pre: + cls._string_pre_validators.append(validator) + else: + cls._string_post_validators.append(validator) + if field_name == "nested_object": + if pre: + cls._nested_object_pre_validators.append(validator) + else: + cls._nested_object_post_validators.append(validator) + return validator + + return decorator + + class PreStringValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: NestedObjectWithRequiredField.Partial) -> typing.Any: ... + + class StringValidator(typing.Protocol): + def __call__(self, __v: str, __values: NestedObjectWithRequiredField.Partial) -> str: ... + + class PreNestedObjectValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: NestedObjectWithRequiredField.Partial) -> typing.Any: ... + + class NestedObjectValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")], + __values: NestedObjectWithRequiredField.Partial, + ) -> typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__( + self, __values: NestedObjectWithRequiredField.Partial + ) -> NestedObjectWithRequiredField.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_nested_object_with_required_field( + cls, values: NestedObjectWithRequiredField.Partial + ) -> NestedObjectWithRequiredField.Partial: + for validator in NestedObjectWithRequiredField.Validators._pre_validators: + values = validator(values) + return values + + @pydantic.model_validator(mode="after") + def _post_validate_types_nested_object_with_required_field( + cls, values: NestedObjectWithRequiredField.Partial + ) -> NestedObjectWithRequiredField.Partial: + for validator in NestedObjectWithRequiredField.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("string", pre=True) + def _pre_validate_string(cls, v: str, values: NestedObjectWithRequiredField.Partial) -> str: + for validator in NestedObjectWithRequiredField.Validators._string_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("string", pre=False) + def _post_validate_string(cls, v: str, values: NestedObjectWithRequiredField.Partial) -> str: + for validator in NestedObjectWithRequiredField.Validators._string_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("nested_object", pre=True) + def _pre_validate_nested_object( + cls, + v: typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")], + values: NestedObjectWithRequiredField.Partial, + ) -> typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")]: + for validator in NestedObjectWithRequiredField.Validators._nested_object_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("nested_object", pre=False) + def _post_validate_nested_object( + cls, + v: typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")], + values: NestedObjectWithRequiredField.Partial, + ) -> typing_extensions.Annotated[ObjectWithOptionalField, FieldMetadata(alias="NestedObject")]: + for validator in NestedObjectWithRequiredField.Validators._nested_object_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/object_with_map_of_map.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/object_with_map_of_map.py new file mode 100644 index 00000000000..f50a818a23b --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/object_with_map_of_map.py @@ -0,0 +1,141 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ....core.pydantic_utilities import UniversalBaseModel +import typing_extensions +import typing +from ....core.serialization import FieldMetadata +import pydantic +from ....core.pydantic_utilities import universal_field_validator + + +class ObjectWithMapOfMap(UniversalBaseModel): + map_: typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")] + + class Partial(typing.TypedDict): + map_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @ObjectWithMapOfMap.Validators.root() + def validate(values: ObjectWithMapOfMap.Partial) -> ObjectWithMapOfMap.Partial: + ... + + @ObjectWithMapOfMap.Validators.field("map_") + def validate_map_(map_: typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")], values: ObjectWithMapOfMap.Partial) -> typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[ObjectWithMapOfMap.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[ObjectWithMapOfMap.Validators._RootValidator]] = [] + _map__pre_validators: typing.ClassVar[typing.List[ObjectWithMapOfMap.Validators.PreMapValidator]] = [] + _map__post_validators: typing.ClassVar[typing.List[ObjectWithMapOfMap.Validators.MapValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithMapOfMap.Validators._RootValidator], ObjectWithMapOfMap.Validators._RootValidator + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithMapOfMap.Validators._PreRootValidator], ObjectWithMapOfMap.Validators._PreRootValidator + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["map_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithMapOfMap.Validators.PreMapValidator], ObjectWithMapOfMap.Validators.PreMapValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["map_"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithMapOfMap.Validators.MapValidator], ObjectWithMapOfMap.Validators.MapValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "map_": + if pre: + cls._map__pre_validators.append(validator) + else: + cls._map__post_validators.append(validator) + return validator + + return decorator + + class PreMapValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithMapOfMap.Partial) -> typing.Any: ... + + class MapValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")], + __values: ObjectWithMapOfMap.Partial, + ) -> typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: ObjectWithMapOfMap.Partial) -> ObjectWithMapOfMap.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_object_with_map_of_map( + cls, values: ObjectWithMapOfMap.Partial + ) -> ObjectWithMapOfMap.Partial: + for validator in ObjectWithMapOfMap.Validators._pre_validators: + values = validator(values) + return values + + @pydantic.model_validator(mode="after") + def _post_validate_types_object_with_map_of_map( + cls, values: ObjectWithMapOfMap.Partial + ) -> ObjectWithMapOfMap.Partial: + for validator in ObjectWithMapOfMap.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("map_", pre=True) + def _pre_validate_map_( + cls, + v: typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")], + values: ObjectWithMapOfMap.Partial, + ) -> typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")]: + for validator in ObjectWithMapOfMap.Validators._map__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("map_", pre=False) + def _post_validate_map_( + cls, + v: typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")], + values: ObjectWithMapOfMap.Partial, + ) -> typing_extensions.Annotated[typing.Dict[str, typing.Dict[str, str]], FieldMetadata(alias="map")]: + for validator in ObjectWithMapOfMap.Validators._map__post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/object_with_optional_field.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/object_with_optional_field.py new file mode 100644 index 00000000000..4e39b68c8cb --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/object_with_optional_field.py @@ -0,0 +1,821 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ....core.pydantic_utilities import UniversalBaseModel +import typing +import pydantic +import typing_extensions +from ....core.serialization import FieldMetadata +import datetime as dt +import uuid +from ....core.pydantic_utilities import universal_field_validator + + +class ObjectWithOptionalField(UniversalBaseModel): + string: typing.Optional[str] = pydantic.Field(default=None) + """ + This is a rather long descriptor of this single field in a more complex type. If you ask me I think this is a pretty good description for this field all things considered. + """ + + integer: typing.Optional[int] = None + long_: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")] = None + double: typing.Optional[float] = None + bool_: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")] = None + datetime: typing.Optional[dt.datetime] = None + date: typing.Optional[dt.date] = None + uuid_: typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")] = None + base_64: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")] = None + list_: typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")] = None + set_: typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")] = None + map_: typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")] = None + bigint: typing.Optional[str] = None + + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[typing.Optional[str]] + integer: typing_extensions.NotRequired[typing.Optional[int]] + long_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")] + ] + double: typing_extensions.NotRequired[typing.Optional[float]] + bool_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")] + ] + datetime: typing_extensions.NotRequired[typing.Optional[dt.datetime]] + date: typing_extensions.NotRequired[typing.Optional[dt.date]] + uuid_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")] + ] + base_64: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")] + ] + list_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")] + ] + set_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")] + ] + map_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")] + ] + bigint: typing_extensions.NotRequired[typing.Optional[str]] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @ObjectWithOptionalField.Validators.root() + def validate(values: ObjectWithOptionalField.Partial) -> ObjectWithOptionalField.Partial: + ... + + @ObjectWithOptionalField.Validators.field("string") + def validate_string(string: typing.Optional[str], values: ObjectWithOptionalField.Partial) -> typing.Optional[str]: + ... + + @ObjectWithOptionalField.Validators.field("integer") + def validate_integer(integer: typing.Optional[int], values: ObjectWithOptionalField.Partial) -> typing.Optional[int]: + ... + + @ObjectWithOptionalField.Validators.field("long_") + def validate_long_(long_: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")], values: ObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")]: + ... + + @ObjectWithOptionalField.Validators.field("double") + def validate_double(double: typing.Optional[float], values: ObjectWithOptionalField.Partial) -> typing.Optional[float]: + ... + + @ObjectWithOptionalField.Validators.field("bool_") + def validate_bool_(bool_: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")], values: ObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")]: + ... + + @ObjectWithOptionalField.Validators.field("datetime") + def validate_datetime(datetime: typing.Optional[dt.datetime], values: ObjectWithOptionalField.Partial) -> typing.Optional[dt.datetime]: + ... + + @ObjectWithOptionalField.Validators.field("date") + def validate_date(date: typing.Optional[dt.date], values: ObjectWithOptionalField.Partial) -> typing.Optional[dt.date]: + ... + + @ObjectWithOptionalField.Validators.field("uuid_") + def validate_uuid_(uuid_: typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")], values: ObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")]: + ... + + @ObjectWithOptionalField.Validators.field("base_64") + def validate_base_64(base_64: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")], values: ObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")]: + ... + + @ObjectWithOptionalField.Validators.field("list_") + def validate_list_(list_: typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")], values: ObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")]: + ... + + @ObjectWithOptionalField.Validators.field("set_") + def validate_set_(set_: typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")], values: ObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")]: + ... + + @ObjectWithOptionalField.Validators.field("map_") + def validate_map_(map_: typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")], values: ObjectWithOptionalField.Partial) -> typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")]: + ... + + @ObjectWithOptionalField.Validators.field("bigint") + def validate_bigint(bigint: typing.Optional[str], values: ObjectWithOptionalField.Partial) -> typing.Optional[str]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators._RootValidator]] = [] + _string_pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreStringValidator]] = [] + _string_post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.StringValidator]] = [] + _integer_pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreIntegerValidator] + ] = [] + _integer_post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.IntegerValidator]] = [] + _long__pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreLongValidator]] = [] + _long__post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.LongValidator]] = [] + _double_pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreDoubleValidator]] = [] + _double_post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.DoubleValidator]] = [] + _bool__pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreBoolValidator]] = [] + _bool__post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.BoolValidator]] = [] + _datetime_pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreDatetimeValidator] + ] = [] + _datetime_post_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.DatetimeValidator] + ] = [] + _date_pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreDateValidator]] = [] + _date_post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.DateValidator]] = [] + _uuid__pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreUuidValidator]] = [] + _uuid__post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.UuidValidator]] = [] + _base_64_pre_validators: typing.ClassVar[ + typing.List[ObjectWithOptionalField.Validators.PreBase64Validator] + ] = [] + _base_64_post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.Base64Validator]] = [] + _list__pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreListValidator]] = [] + _list__post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.ListValidator]] = [] + _set__pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreSetValidator]] = [] + _set__post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.SetValidator]] = [] + _map__pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreMapValidator]] = [] + _map__post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.MapValidator]] = [] + _bigint_pre_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.PreBigintValidator]] = [] + _bigint_post_validators: typing.ClassVar[typing.List[ObjectWithOptionalField.Validators.BigintValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators._RootValidator], ObjectWithOptionalField.Validators._RootValidator + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators._PreRootValidator], ObjectWithOptionalField.Validators._PreRootValidator + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreStringValidator], + ObjectWithOptionalField.Validators.PreStringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.StringValidator], ObjectWithOptionalField.Validators.StringValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["integer"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreIntegerValidator], + ObjectWithOptionalField.Validators.PreIntegerValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["integer"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.IntegerValidator], ObjectWithOptionalField.Validators.IntegerValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["long_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreLongValidator], ObjectWithOptionalField.Validators.PreLongValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["long_"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.LongValidator], ObjectWithOptionalField.Validators.LongValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["double"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreDoubleValidator], + ObjectWithOptionalField.Validators.PreDoubleValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["double"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.DoubleValidator], ObjectWithOptionalField.Validators.DoubleValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["bool_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreBoolValidator], ObjectWithOptionalField.Validators.PreBoolValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["bool_"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.BoolValidator], ObjectWithOptionalField.Validators.BoolValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["datetime"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreDatetimeValidator], + ObjectWithOptionalField.Validators.PreDatetimeValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["datetime"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.DatetimeValidator], ObjectWithOptionalField.Validators.DatetimeValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["date"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreDateValidator], ObjectWithOptionalField.Validators.PreDateValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["date"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.DateValidator], ObjectWithOptionalField.Validators.DateValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["uuid_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreUuidValidator], ObjectWithOptionalField.Validators.PreUuidValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["uuid_"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.UuidValidator], ObjectWithOptionalField.Validators.UuidValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["base_64"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreBase64Validator], + ObjectWithOptionalField.Validators.PreBase64Validator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["base_64"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.Base64Validator], ObjectWithOptionalField.Validators.Base64Validator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["list_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreListValidator], ObjectWithOptionalField.Validators.PreListValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["list_"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.ListValidator], ObjectWithOptionalField.Validators.ListValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["set_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreSetValidator], ObjectWithOptionalField.Validators.PreSetValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["set_"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.SetValidator], ObjectWithOptionalField.Validators.SetValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["map_"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreMapValidator], ObjectWithOptionalField.Validators.PreMapValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["map_"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.MapValidator], ObjectWithOptionalField.Validators.MapValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["bigint"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.PreBigintValidator], + ObjectWithOptionalField.Validators.PreBigintValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["bigint"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithOptionalField.Validators.BigintValidator], ObjectWithOptionalField.Validators.BigintValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "string": + if pre: + cls._string_pre_validators.append(validator) + else: + cls._string_post_validators.append(validator) + if field_name == "integer": + if pre: + cls._integer_pre_validators.append(validator) + else: + cls._integer_post_validators.append(validator) + if field_name == "long_": + if pre: + cls._long__pre_validators.append(validator) + else: + cls._long__post_validators.append(validator) + if field_name == "double": + if pre: + cls._double_pre_validators.append(validator) + else: + cls._double_post_validators.append(validator) + if field_name == "bool_": + if pre: + cls._bool__pre_validators.append(validator) + else: + cls._bool__post_validators.append(validator) + if field_name == "datetime": + if pre: + cls._datetime_pre_validators.append(validator) + else: + cls._datetime_post_validators.append(validator) + if field_name == "date": + if pre: + cls._date_pre_validators.append(validator) + else: + cls._date_post_validators.append(validator) + if field_name == "uuid_": + if pre: + cls._uuid__pre_validators.append(validator) + else: + cls._uuid__post_validators.append(validator) + if field_name == "base_64": + if pre: + cls._base_64_pre_validators.append(validator) + else: + cls._base_64_post_validators.append(validator) + if field_name == "list_": + if pre: + cls._list__pre_validators.append(validator) + else: + cls._list__post_validators.append(validator) + if field_name == "set_": + if pre: + cls._set__pre_validators.append(validator) + else: + cls._set__post_validators.append(validator) + if field_name == "map_": + if pre: + cls._map__pre_validators.append(validator) + else: + cls._map__post_validators.append(validator) + if field_name == "bigint": + if pre: + cls._bigint_pre_validators.append(validator) + else: + cls._bigint_post_validators.append(validator) + return validator + + return decorator + + class PreStringValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class StringValidator(typing.Protocol): + def __call__( + self, __v: typing.Optional[str], __values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: ... + + class PreIntegerValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class IntegerValidator(typing.Protocol): + def __call__( + self, __v: typing.Optional[int], __values: ObjectWithOptionalField.Partial + ) -> typing.Optional[int]: ... + + class PreLongValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class LongValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")], + __values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")]: ... + + class PreDoubleValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class DoubleValidator(typing.Protocol): + def __call__( + self, __v: typing.Optional[float], __values: ObjectWithOptionalField.Partial + ) -> typing.Optional[float]: ... + + class PreBoolValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class BoolValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")], + __values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")]: ... + + class PreDatetimeValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class DatetimeValidator(typing.Protocol): + def __call__( + self, __v: typing.Optional[dt.datetime], __values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.datetime]: ... + + class PreDateValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class DateValidator(typing.Protocol): + def __call__( + self, __v: typing.Optional[dt.date], __values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.date]: ... + + class PreUuidValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class UuidValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")], + __values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")]: ... + + class PreBase64Validator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class Base64Validator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")], + __values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")]: ... + + class PreListValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class ListValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")], + __values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")]: ... + + class PreSetValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class SetValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")], + __values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")]: ... + + class PreMapValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class MapValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")], + __values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")]: ... + + class PreBigintValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithOptionalField.Partial) -> typing.Any: ... + + class BigintValidator(typing.Protocol): + def __call__( + self, __v: typing.Optional[str], __values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: ObjectWithOptionalField.Partial) -> ObjectWithOptionalField.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_object_with_optional_field( + cls, values: ObjectWithOptionalField.Partial + ) -> ObjectWithOptionalField.Partial: + for validator in ObjectWithOptionalField.Validators._pre_validators: + values = validator(values) + return values + + @pydantic.model_validator(mode="after") + def _post_validate_types_object_with_optional_field( + cls, values: ObjectWithOptionalField.Partial + ) -> ObjectWithOptionalField.Partial: + for validator in ObjectWithOptionalField.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("string", pre=True) + def _pre_validate_string( + cls, v: typing.Optional[str], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in ObjectWithOptionalField.Validators._string_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("string", pre=False) + def _post_validate_string( + cls, v: typing.Optional[str], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in ObjectWithOptionalField.Validators._string_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("integer", pre=True) + def _pre_validate_integer( + cls, v: typing.Optional[int], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[int]: + for validator in ObjectWithOptionalField.Validators._integer_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("integer", pre=False) + def _post_validate_integer( + cls, v: typing.Optional[int], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[int]: + for validator in ObjectWithOptionalField.Validators._integer_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("long_", pre=True) + def _pre_validate_long_( + cls, + v: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")]: + for validator in ObjectWithOptionalField.Validators._long__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("long_", pre=False) + def _post_validate_long_( + cls, + v: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="long")]: + for validator in ObjectWithOptionalField.Validators._long__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("double", pre=True) + def _pre_validate_double( + cls, v: typing.Optional[float], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[float]: + for validator in ObjectWithOptionalField.Validators._double_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("double", pre=False) + def _post_validate_double( + cls, v: typing.Optional[float], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[float]: + for validator in ObjectWithOptionalField.Validators._double_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("bool_", pre=True) + def _pre_validate_bool_( + cls, + v: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")]: + for validator in ObjectWithOptionalField.Validators._bool__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("bool_", pre=False) + def _post_validate_bool_( + cls, + v: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="bool")]: + for validator in ObjectWithOptionalField.Validators._bool__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("datetime", pre=True) + def _pre_validate_datetime( + cls, v: typing.Optional[dt.datetime], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.datetime]: + for validator in ObjectWithOptionalField.Validators._datetime_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("datetime", pre=False) + def _post_validate_datetime( + cls, v: typing.Optional[dt.datetime], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.datetime]: + for validator in ObjectWithOptionalField.Validators._datetime_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("date", pre=True) + def _pre_validate_date( + cls, v: typing.Optional[dt.date], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.date]: + for validator in ObjectWithOptionalField.Validators._date_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("date", pre=False) + def _post_validate_date( + cls, v: typing.Optional[dt.date], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[dt.date]: + for validator in ObjectWithOptionalField.Validators._date_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("uuid_", pre=True) + def _pre_validate_uuid_( + cls, + v: typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")]: + for validator in ObjectWithOptionalField.Validators._uuid__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("uuid_", pre=False) + def _post_validate_uuid_( + cls, + v: typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[uuid.UUID], FieldMetadata(alias="uuid")]: + for validator in ObjectWithOptionalField.Validators._uuid__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("base_64", pre=True) + def _pre_validate_base_64( + cls, + v: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")]: + for validator in ObjectWithOptionalField.Validators._base_64_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("base_64", pre=False) + def _post_validate_base_64( + cls, + v: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="base64")]: + for validator in ObjectWithOptionalField.Validators._base_64_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("list_", pre=True) + def _pre_validate_list_( + cls, + v: typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")]: + for validator in ObjectWithOptionalField.Validators._list__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("list_", pre=False) + def _post_validate_list_( + cls, + v: typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="list")]: + for validator in ObjectWithOptionalField.Validators._list__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("set_", pre=True) + def _pre_validate_set_( + cls, + v: typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")]: + for validator in ObjectWithOptionalField.Validators._set__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("set_", pre=False) + def _post_validate_set_( + cls, + v: typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.Set[str]], FieldMetadata(alias="set")]: + for validator in ObjectWithOptionalField.Validators._set__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("map_", pre=True) + def _pre_validate_map_( + cls, + v: typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")]: + for validator in ObjectWithOptionalField.Validators._map__pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("map_", pre=False) + def _post_validate_map_( + cls, + v: typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")], + values: ObjectWithOptionalField.Partial, + ) -> typing_extensions.Annotated[typing.Optional[typing.Dict[int, str]], FieldMetadata(alias="map")]: + for validator in ObjectWithOptionalField.Validators._map__post_validators: + v = validator(v, values) + return v + + @universal_field_validator("bigint", pre=True) + def _pre_validate_bigint( + cls, v: typing.Optional[str], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in ObjectWithOptionalField.Validators._bigint_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("bigint", pre=False) + def _post_validate_bigint( + cls, v: typing.Optional[str], values: ObjectWithOptionalField.Partial + ) -> typing.Optional[str]: + for validator in ObjectWithOptionalField.Validators._bigint_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/object_with_required_field.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/object_with_required_field.py new file mode 100644 index 00000000000..7a0913fbf2d --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/object_with_required_field.py @@ -0,0 +1,127 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ....core.pydantic_utilities import UniversalBaseModel +import typing +import typing_extensions +import pydantic +from ....core.pydantic_utilities import universal_field_validator + + +class ObjectWithRequiredField(UniversalBaseModel): + string: str + + class Partial(typing.TypedDict): + string: typing_extensions.NotRequired[str] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @ObjectWithRequiredField.Validators.root() + def validate(values: ObjectWithRequiredField.Partial) -> ObjectWithRequiredField.Partial: + ... + + @ObjectWithRequiredField.Validators.field("string") + def validate_string(string: str, values: ObjectWithRequiredField.Partial) -> str: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[ObjectWithRequiredField.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[ObjectWithRequiredField.Validators._RootValidator]] = [] + _string_pre_validators: typing.ClassVar[typing.List[ObjectWithRequiredField.Validators.PreStringValidator]] = [] + _string_post_validators: typing.ClassVar[typing.List[ObjectWithRequiredField.Validators.StringValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithRequiredField.Validators._RootValidator], ObjectWithRequiredField.Validators._RootValidator + ]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithRequiredField.Validators._PreRootValidator], ObjectWithRequiredField.Validators._PreRootValidator + ]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [ObjectWithRequiredField.Validators.PreStringValidator], + ObjectWithRequiredField.Validators.PreStringValidator, + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["string"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [ObjectWithRequiredField.Validators.StringValidator], ObjectWithRequiredField.Validators.StringValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "string": + if pre: + cls._string_pre_validators.append(validator) + else: + cls._string_post_validators.append(validator) + return validator + + return decorator + + class PreStringValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: ObjectWithRequiredField.Partial) -> typing.Any: ... + + class StringValidator(typing.Protocol): + def __call__(self, __v: str, __values: ObjectWithRequiredField.Partial) -> str: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: ObjectWithRequiredField.Partial) -> ObjectWithRequiredField.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_object_with_required_field( + cls, values: ObjectWithRequiredField.Partial + ) -> ObjectWithRequiredField.Partial: + for validator in ObjectWithRequiredField.Validators._pre_validators: + values = validator(values) + return values + + @pydantic.model_validator(mode="after") + def _post_validate_types_object_with_required_field( + cls, values: ObjectWithRequiredField.Partial + ) -> ObjectWithRequiredField.Partial: + for validator in ObjectWithRequiredField.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("string", pre=True) + def _pre_validate_string(cls, v: str, values: ObjectWithRequiredField.Partial) -> str: + for validator in ObjectWithRequiredField.Validators._string_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("string", pre=False) + def _post_validate_string(cls, v: str, values: ObjectWithRequiredField.Partial) -> str: + for validator in ObjectWithRequiredField.Validators._string_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/optional_alias.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/optional_alias.py new file mode 100644 index 00000000000..e9f9da6ff8c --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/object/types/optional_alias.py @@ -0,0 +1,38 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +import pydantic +import typing + + +class OptionalAlias(pydantic.RootModel): + root: typing.Optional[str] + + def get_as_str(self) -> typing.Optional[str]: + return self.root + + @staticmethod + def from_str(value: typing.Optional[str]) -> OptionalAlias: + return OptionalAlias(root=value) + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @OptionalAlias.Validators.validate + def validate(value: typing.Optional[str]) -> typing.Optional[str]: + ... + """ + + _validators: typing.ClassVar[typing.List[typing.Callable[[typing.Optional[str]], typing.Optional[str]]]] = [] + + @classmethod + def validate(cls, validator: typing.Callable[[typing.Optional[str]], typing.Optional[str]]) -> None: + cls._validators.append(validator) + + @pydantic.model_validator(mode="after") + def _validate(cls, values: typing.Dict[str, typing.Any]) -> typing.Dict[str, typing.Any]: + value = typing.cast(typing.Optional[str], values.get("root")) + for validator in OptionalAlias.Validators._validators: + value = validator(value) + return {**values, "root": value} diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/__init__.py new file mode 100644 index 00000000000..30187ae029e --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/__init__.py @@ -0,0 +1,6 @@ +# This file was auto-generated by Fern from our API Definition. + +from .types import Animal, Animal_Cat, Animal_Dog, Cat, Dog +from .errors import ErrorWithUnionBody + +__all__ = ["Animal", "Animal_Cat", "Animal_Dog", "Cat", "Dog", "ErrorWithUnionBody"] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/errors/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/errors/__init__.py new file mode 100644 index 00000000000..568a71fa3c4 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/errors/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .error_with_union_body import ErrorWithUnionBody + +__all__ = ["ErrorWithUnionBody"] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/errors/error_with_union_body.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/errors/error_with_union_body.py new file mode 100644 index 00000000000..3ead0383351 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/errors/error_with_union_body.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.api_error import ApiError +from ..types.animal import Animal + + +class ErrorWithUnionBody(ApiError): + def __init__(self, body: Animal): + super().__init__(status_code=400, body=body) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/types/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/types/__init__.py new file mode 100644 index 00000000000..44ff66be5d9 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/types/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +from .animal import Animal, Animal_Cat, Animal_Dog +from .cat import Cat +from .dog import Dog + +__all__ = ["Animal", "Animal_Cat", "Animal_Dog", "Cat", "Dog"] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/types/animal.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/types/animal.py new file mode 100644 index 00000000000..8e711db32e3 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/types/animal.py @@ -0,0 +1,416 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ....core.pydantic_utilities import UniversalBaseModel +import typing +import typing_extensions +from ....core.serialization import FieldMetadata +import pydantic +from ....core.pydantic_utilities import universal_field_validator + + +class Animal_Dog(UniversalBaseModel): + animal: typing.Literal["dog"] = "dog" + name: str + likes_to_woof: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")] + + class Partial(typing.TypedDict): + animal: typing_extensions.NotRequired[typing.Literal["dog"]] + name: typing_extensions.NotRequired[str] + likes_to_woof: typing_extensions.NotRequired[ + typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @Animal_Dog.Validators.root() + def validate(values: Animal_Dog.Partial) -> Animal_Dog.Partial: + ... + + @Animal_Dog.Validators.field("animal") + def validate_animal(animal: typing.Literal["dog"], values: Animal_Dog.Partial) -> typing.Literal["dog"]: + ... + + @Animal_Dog.Validators.field("name") + def validate_name(name: str, values: Animal_Dog.Partial) -> str: + ... + + @Animal_Dog.Validators.field("likes_to_woof") + def validate_likes_to_woof(likes_to_woof: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], values: Animal_Dog.Partial) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[Animal_Dog.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[Animal_Dog.Validators._RootValidator]] = [] + _animal_pre_validators: typing.ClassVar[typing.List[Animal_Dog.Validators.PreAnimalValidator]] = [] + _animal_post_validators: typing.ClassVar[typing.List[Animal_Dog.Validators.AnimalValidator]] = [] + _name_pre_validators: typing.ClassVar[typing.List[Animal_Dog.Validators.PreNameValidator]] = [] + _name_post_validators: typing.ClassVar[typing.List[Animal_Dog.Validators.NameValidator]] = [] + _likes_to_woof_pre_validators: typing.ClassVar[typing.List[Animal_Dog.Validators.PreLikesToWoofValidator]] = [] + _likes_to_woof_post_validators: typing.ClassVar[typing.List[Animal_Dog.Validators.LikesToWoofValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Animal_Dog.Validators._RootValidator], Animal_Dog.Validators._RootValidator]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[[Animal_Dog.Validators._PreRootValidator], Animal_Dog.Validators._PreRootValidator]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["animal"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Animal_Dog.Validators.PreAnimalValidator], Animal_Dog.Validators.PreAnimalValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["animal"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Animal_Dog.Validators.AnimalValidator], Animal_Dog.Validators.AnimalValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Animal_Dog.Validators.PreNameValidator], Animal_Dog.Validators.PreNameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Animal_Dog.Validators.NameValidator], Animal_Dog.Validators.NameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_woof"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [Animal_Dog.Validators.PreLikesToWoofValidator], Animal_Dog.Validators.PreLikesToWoofValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_woof"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [Animal_Dog.Validators.LikesToWoofValidator], Animal_Dog.Validators.LikesToWoofValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "animal": + if pre: + cls._animal_pre_validators.append(validator) + else: + cls._animal_post_validators.append(validator) + if field_name == "name": + if pre: + cls._name_pre_validators.append(validator) + else: + cls._name_post_validators.append(validator) + if field_name == "likes_to_woof": + if pre: + cls._likes_to_woof_pre_validators.append(validator) + else: + cls._likes_to_woof_post_validators.append(validator) + return validator + + return decorator + + class PreAnimalValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Animal_Dog.Partial) -> typing.Any: ... + + class AnimalValidator(typing.Protocol): + def __call__(self, __v: typing.Literal["dog"], __values: Animal_Dog.Partial) -> typing.Literal["dog"]: ... + + class PreNameValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Animal_Dog.Partial) -> typing.Any: ... + + class NameValidator(typing.Protocol): + def __call__(self, __v: str, __values: Animal_Dog.Partial) -> str: ... + + class PreLikesToWoofValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Animal_Dog.Partial) -> typing.Any: ... + + class LikesToWoofValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], + __values: Animal_Dog.Partial, + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: Animal_Dog.Partial) -> Animal_Dog.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate(cls, values: Animal_Dog.Partial) -> Animal_Dog.Partial: + for validator in Animal_Dog.Validators._pre_validators: + values = validator(values) + return values + + @pydantic.model_validator(mode="after") + def _post_validate(cls, values: Animal_Dog.Partial) -> Animal_Dog.Partial: + for validator in Animal_Dog.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("animal", pre=True) + def _pre_validate_animal(cls, v: typing.Literal["dog"], values: Animal_Dog.Partial) -> typing.Literal["dog"]: + for validator in Animal_Dog.Validators._animal_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("animal", pre=False) + def _post_validate_animal(cls, v: typing.Literal["dog"], values: Animal_Dog.Partial) -> typing.Literal["dog"]: + for validator in Animal_Dog.Validators._animal_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("name", pre=True) + def _pre_validate_name(cls, v: str, values: Animal_Dog.Partial) -> str: + for validator in Animal_Dog.Validators._name_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("name", pre=False) + def _post_validate_name(cls, v: str, values: Animal_Dog.Partial) -> str: + for validator in Animal_Dog.Validators._name_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_woof", pre=True) + def _pre_validate_likes_to_woof( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], values: Animal_Dog.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: + for validator in Animal_Dog.Validators._likes_to_woof_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_woof", pre=False) + def _post_validate_likes_to_woof( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], values: Animal_Dog.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: + for validator in Animal_Dog.Validators._likes_to_woof_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + + +class Animal_Cat(UniversalBaseModel): + animal: typing.Literal["cat"] = "cat" + name: str + likes_to_meow: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")] + + class Partial(typing.TypedDict): + animal: typing_extensions.NotRequired[typing.Literal["cat"]] + name: typing_extensions.NotRequired[str] + likes_to_meow: typing_extensions.NotRequired[ + typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @Animal_Cat.Validators.root() + def validate(values: Animal_Cat.Partial) -> Animal_Cat.Partial: + ... + + @Animal_Cat.Validators.field("animal") + def validate_animal(animal: typing.Literal["cat"], values: Animal_Cat.Partial) -> typing.Literal["cat"]: + ... + + @Animal_Cat.Validators.field("name") + def validate_name(name: str, values: Animal_Cat.Partial) -> str: + ... + + @Animal_Cat.Validators.field("likes_to_meow") + def validate_likes_to_meow(likes_to_meow: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], values: Animal_Cat.Partial) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[Animal_Cat.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[Animal_Cat.Validators._RootValidator]] = [] + _animal_pre_validators: typing.ClassVar[typing.List[Animal_Cat.Validators.PreAnimalValidator]] = [] + _animal_post_validators: typing.ClassVar[typing.List[Animal_Cat.Validators.AnimalValidator]] = [] + _name_pre_validators: typing.ClassVar[typing.List[Animal_Cat.Validators.PreNameValidator]] = [] + _name_post_validators: typing.ClassVar[typing.List[Animal_Cat.Validators.NameValidator]] = [] + _likes_to_meow_pre_validators: typing.ClassVar[typing.List[Animal_Cat.Validators.PreLikesToMeowValidator]] = [] + _likes_to_meow_post_validators: typing.ClassVar[typing.List[Animal_Cat.Validators.LikesToMeowValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Animal_Cat.Validators._RootValidator], Animal_Cat.Validators._RootValidator]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[[Animal_Cat.Validators._PreRootValidator], Animal_Cat.Validators._PreRootValidator]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["animal"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Animal_Cat.Validators.PreAnimalValidator], Animal_Cat.Validators.PreAnimalValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["animal"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Animal_Cat.Validators.AnimalValidator], Animal_Cat.Validators.AnimalValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Animal_Cat.Validators.PreNameValidator], Animal_Cat.Validators.PreNameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Animal_Cat.Validators.NameValidator], Animal_Cat.Validators.NameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_meow"], *, pre: typing.Literal[True] + ) -> typing.Callable[ + [Animal_Cat.Validators.PreLikesToMeowValidator], Animal_Cat.Validators.PreLikesToMeowValidator + ]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_meow"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[ + [Animal_Cat.Validators.LikesToMeowValidator], Animal_Cat.Validators.LikesToMeowValidator + ]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "animal": + if pre: + cls._animal_pre_validators.append(validator) + else: + cls._animal_post_validators.append(validator) + if field_name == "name": + if pre: + cls._name_pre_validators.append(validator) + else: + cls._name_post_validators.append(validator) + if field_name == "likes_to_meow": + if pre: + cls._likes_to_meow_pre_validators.append(validator) + else: + cls._likes_to_meow_post_validators.append(validator) + return validator + + return decorator + + class PreAnimalValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Animal_Cat.Partial) -> typing.Any: ... + + class AnimalValidator(typing.Protocol): + def __call__(self, __v: typing.Literal["cat"], __values: Animal_Cat.Partial) -> typing.Literal["cat"]: ... + + class PreNameValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Animal_Cat.Partial) -> typing.Any: ... + + class NameValidator(typing.Protocol): + def __call__(self, __v: str, __values: Animal_Cat.Partial) -> str: ... + + class PreLikesToMeowValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Animal_Cat.Partial) -> typing.Any: ... + + class LikesToMeowValidator(typing.Protocol): + def __call__( + self, + __v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], + __values: Animal_Cat.Partial, + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: Animal_Cat.Partial) -> Animal_Cat.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate(cls, values: Animal_Cat.Partial) -> Animal_Cat.Partial: + for validator in Animal_Cat.Validators._pre_validators: + values = validator(values) + return values + + @pydantic.model_validator(mode="after") + def _post_validate(cls, values: Animal_Cat.Partial) -> Animal_Cat.Partial: + for validator in Animal_Cat.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("animal", pre=True) + def _pre_validate_animal(cls, v: typing.Literal["cat"], values: Animal_Cat.Partial) -> typing.Literal["cat"]: + for validator in Animal_Cat.Validators._animal_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("animal", pre=False) + def _post_validate_animal(cls, v: typing.Literal["cat"], values: Animal_Cat.Partial) -> typing.Literal["cat"]: + for validator in Animal_Cat.Validators._animal_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("name", pre=True) + def _pre_validate_name(cls, v: str, values: Animal_Cat.Partial) -> str: + for validator in Animal_Cat.Validators._name_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("name", pre=False) + def _post_validate_name(cls, v: str, values: Animal_Cat.Partial) -> str: + for validator in Animal_Cat.Validators._name_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_meow", pre=True) + def _pre_validate_likes_to_meow( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], values: Animal_Cat.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: + for validator in Animal_Cat.Validators._likes_to_meow_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_meow", pre=False) + def _post_validate_likes_to_meow( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], values: Animal_Cat.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: + for validator in Animal_Cat.Validators._likes_to_meow_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + + +Animal = typing.Union[Animal_Dog, Animal_Cat] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/types/cat.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/types/cat.py new file mode 100644 index 00000000000..6cb6e45d846 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/types/cat.py @@ -0,0 +1,164 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ....core.pydantic_utilities import UniversalBaseModel +import typing_extensions +from ....core.serialization import FieldMetadata +import typing +import pydantic +from ....core.pydantic_utilities import universal_field_validator + + +class Cat(UniversalBaseModel): + name: str + likes_to_meow: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")] + + class Partial(typing.TypedDict): + name: typing_extensions.NotRequired[str] + likes_to_meow: typing_extensions.NotRequired[ + typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @Cat.Validators.root() + def validate(values: Cat.Partial) -> Cat.Partial: + ... + + @Cat.Validators.field("name") + def validate_name(name: str, values: Cat.Partial) -> str: + ... + + @Cat.Validators.field("likes_to_meow") + def validate_likes_to_meow(likes_to_meow: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], values: Cat.Partial) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[Cat.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[Cat.Validators._RootValidator]] = [] + _name_pre_validators: typing.ClassVar[typing.List[Cat.Validators.PreNameValidator]] = [] + _name_post_validators: typing.ClassVar[typing.List[Cat.Validators.NameValidator]] = [] + _likes_to_meow_pre_validators: typing.ClassVar[typing.List[Cat.Validators.PreLikesToMeowValidator]] = [] + _likes_to_meow_post_validators: typing.ClassVar[typing.List[Cat.Validators.LikesToMeowValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Cat.Validators._RootValidator], Cat.Validators._RootValidator]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[[Cat.Validators._PreRootValidator], Cat.Validators._PreRootValidator]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Cat.Validators.PreNameValidator], Cat.Validators.PreNameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Cat.Validators.NameValidator], Cat.Validators.NameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_meow"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Cat.Validators.PreLikesToMeowValidator], Cat.Validators.PreLikesToMeowValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_meow"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Cat.Validators.LikesToMeowValidator], Cat.Validators.LikesToMeowValidator]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "name": + if pre: + cls._name_pre_validators.append(validator) + else: + cls._name_post_validators.append(validator) + if field_name == "likes_to_meow": + if pre: + cls._likes_to_meow_pre_validators.append(validator) + else: + cls._likes_to_meow_post_validators.append(validator) + return validator + + return decorator + + class PreNameValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Cat.Partial) -> typing.Any: ... + + class NameValidator(typing.Protocol): + def __call__(self, __v: str, __values: Cat.Partial) -> str: ... + + class PreLikesToMeowValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Cat.Partial) -> typing.Any: ... + + class LikesToMeowValidator(typing.Protocol): + def __call__( + self, __v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], __values: Cat.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: Cat.Partial) -> Cat.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_cat(cls, values: Cat.Partial) -> Cat.Partial: + for validator in Cat.Validators._pre_validators: + values = validator(values) + return values + + @pydantic.model_validator(mode="after") + def _post_validate_types_cat(cls, values: Cat.Partial) -> Cat.Partial: + for validator in Cat.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("name", pre=True) + def _pre_validate_name(cls, v: str, values: Cat.Partial) -> str: + for validator in Cat.Validators._name_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("name", pre=False) + def _post_validate_name(cls, v: str, values: Cat.Partial) -> str: + for validator in Cat.Validators._name_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_meow", pre=True) + def _pre_validate_likes_to_meow( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], values: Cat.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: + for validator in Cat.Validators._likes_to_meow_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_meow", pre=False) + def _post_validate_likes_to_meow( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")], values: Cat.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToMeow")]: + for validator in Cat.Validators._likes_to_meow_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/types/dog.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/types/dog.py new file mode 100644 index 00000000000..d702fc58458 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/types/union/types/dog.py @@ -0,0 +1,164 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ....core.pydantic_utilities import UniversalBaseModel +import typing_extensions +from ....core.serialization import FieldMetadata +import typing +import pydantic +from ....core.pydantic_utilities import universal_field_validator + + +class Dog(UniversalBaseModel): + name: str + likes_to_woof: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")] + + class Partial(typing.TypedDict): + name: typing_extensions.NotRequired[str] + likes_to_woof: typing_extensions.NotRequired[ + typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")] + ] + + class Validators: + """ + Use this class to add validators to the Pydantic model. + + @Dog.Validators.root() + def validate(values: Dog.Partial) -> Dog.Partial: + ... + + @Dog.Validators.field("name") + def validate_name(name: str, values: Dog.Partial) -> str: + ... + + @Dog.Validators.field("likes_to_woof") + def validate_likes_to_woof(likes_to_woof: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], values: Dog.Partial) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: + ... + """ + + _pre_validators: typing.ClassVar[typing.List[Dog.Validators._PreRootValidator]] = [] + _post_validators: typing.ClassVar[typing.List[Dog.Validators._RootValidator]] = [] + _name_pre_validators: typing.ClassVar[typing.List[Dog.Validators.PreNameValidator]] = [] + _name_post_validators: typing.ClassVar[typing.List[Dog.Validators.NameValidator]] = [] + _likes_to_woof_pre_validators: typing.ClassVar[typing.List[Dog.Validators.PreLikesToWoofValidator]] = [] + _likes_to_woof_post_validators: typing.ClassVar[typing.List[Dog.Validators.LikesToWoofValidator]] = [] + + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Dog.Validators._RootValidator], Dog.Validators._RootValidator]: ... + @typing.overload + @classmethod + def root( + cls, *, pre: typing.Literal[True] + ) -> typing.Callable[[Dog.Validators._PreRootValidator], Dog.Validators._PreRootValidator]: ... + @classmethod + def root(cls, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if pre: + cls._pre_validators.append(validator) + else: + cls._post_validators.append(validator) + return validator + + return decorator + + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Dog.Validators.PreNameValidator], Dog.Validators.PreNameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["name"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Dog.Validators.NameValidator], Dog.Validators.NameValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_woof"], *, pre: typing.Literal[True] + ) -> typing.Callable[[Dog.Validators.PreLikesToWoofValidator], Dog.Validators.PreLikesToWoofValidator]: ... + @typing.overload + @classmethod + def field( + cls, field_name: typing.Literal["likes_to_woof"], *, pre: typing.Literal[False] = False + ) -> typing.Callable[[Dog.Validators.LikesToWoofValidator], Dog.Validators.LikesToWoofValidator]: ... + @classmethod + def field(cls, field_name: str, *, pre: bool = False) -> typing.Any: + def decorator(validator: typing.Any) -> typing.Any: + if field_name == "name": + if pre: + cls._name_pre_validators.append(validator) + else: + cls._name_post_validators.append(validator) + if field_name == "likes_to_woof": + if pre: + cls._likes_to_woof_pre_validators.append(validator) + else: + cls._likes_to_woof_post_validators.append(validator) + return validator + + return decorator + + class PreNameValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Dog.Partial) -> typing.Any: ... + + class NameValidator(typing.Protocol): + def __call__(self, __v: str, __values: Dog.Partial) -> str: ... + + class PreLikesToWoofValidator(typing.Protocol): + def __call__(self, __v: typing.Any, __values: Dog.Partial) -> typing.Any: ... + + class LikesToWoofValidator(typing.Protocol): + def __call__( + self, __v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], __values: Dog.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: ... + + class _PreRootValidator(typing.Protocol): + def __call__(self, __values: typing.Any) -> typing.Any: ... + + class _RootValidator(typing.Protocol): + def __call__(self, __values: Dog.Partial) -> Dog.Partial: ... + + @pydantic.model_validator(mode="before") + def _pre_validate_types_dog(cls, values: Dog.Partial) -> Dog.Partial: + for validator in Dog.Validators._pre_validators: + values = validator(values) + return values + + @pydantic.model_validator(mode="after") + def _post_validate_types_dog(cls, values: Dog.Partial) -> Dog.Partial: + for validator in Dog.Validators._post_validators: + values = validator(values) + return values + + @universal_field_validator("name", pre=True) + def _pre_validate_name(cls, v: str, values: Dog.Partial) -> str: + for validator in Dog.Validators._name_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("name", pre=False) + def _post_validate_name(cls, v: str, values: Dog.Partial) -> str: + for validator in Dog.Validators._name_post_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_woof", pre=True) + def _pre_validate_likes_to_woof( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], values: Dog.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: + for validator in Dog.Validators._likes_to_woof_pre_validators: + v = validator(v, values) + return v + + @universal_field_validator("likes_to_woof", pre=False) + def _post_validate_likes_to_woof( + cls, v: typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")], values: Dog.Partial + ) -> typing_extensions.Annotated[bool, FieldMetadata(alias="likesToWoof")]: + for validator in Dog.Validators._likes_to_woof_post_validators: + v = validator(v, values) + return v + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/version.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/version.py new file mode 100644 index 00000000000..ac44536abdb --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/src/seed/version.py @@ -0,0 +1,3 @@ +from importlib import metadata + +__version__ = metadata.version("fern_exhaustive") diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/conftest.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/conftest.py new file mode 100644 index 00000000000..54c31d3dab5 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/conftest.py @@ -0,0 +1,16 @@ +# This file was auto-generated by Fern from our API Definition. + +from seed import SeedExhaustive +import os +import pytest +from seed import AsyncSeedExhaustive + + +@pytest.fixture +def client() -> SeedExhaustive: + return SeedExhaustive(token=os.getenv("ENV_TOKEN", "token"), base_url=os.getenv("TESTS_BASE_URL", "base_url")) + + +@pytest.fixture +def async_client() -> AsyncSeedExhaustive: + return AsyncSeedExhaustive(token=os.getenv("ENV_TOKEN", "token"), base_url=os.getenv("TESTS_BASE_URL", "base_url")) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/custom/test_client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/custom/test_client.py new file mode 100644 index 00000000000..73f811f5ede --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/custom/test_client.py @@ -0,0 +1,7 @@ +import pytest + + +# Get started with writing tests with pytest at https://docs.pytest.org +@pytest.mark.skip(reason="Unimplemented") +def test_client() -> None: + assert True == True diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_container.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_container.py new file mode 100644 index 00000000000..bbd90d449bc --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_container.py @@ -0,0 +1,95 @@ +# This file was auto-generated by Fern from our API Definition. + +from seed import SeedExhaustive +from seed import AsyncSeedExhaustive +import typing +from ..utilities import validate_response +from seed.types.object import ObjectWithRequiredField + + +async def test_get_and_return_list_of_primitives(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = ["string", "string"] + expected_types: typing.Tuple[typing.Any, typing.Any] = ("list", {0: None, 1: None}) + response = client.endpoints.container.get_and_return_list_of_primitives(request=["string", "string"]) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.container.get_and_return_list_of_primitives( + request=["string", "string"] + ) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_list_of_objects(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = [{"string": "string"}, {"string": "string"}] + expected_types: typing.Tuple[typing.Any, typing.Any] = ("list", {0: {"string": None}, 1: {"string": None}}) + response = client.endpoints.container.get_and_return_list_of_objects( + request=[ObjectWithRequiredField(string="string"), ObjectWithRequiredField(string="string")] + ) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.container.get_and_return_list_of_objects( + request=[ObjectWithRequiredField(string="string"), ObjectWithRequiredField(string="string")] + ) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_set_of_primitives(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = ["string"] + expected_types: typing.Tuple[typing.Any, typing.Any] = ("set", {0: None}) + response = client.endpoints.container.get_and_return_set_of_primitives(request={"string"}) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.container.get_and_return_set_of_primitives(request={"string"}) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_set_of_objects(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = [{"string": "string"}] + expected_types: typing.Tuple[typing.Any, typing.Any] = ("set", {0: {"string": None}}) + response = client.endpoints.container.get_and_return_set_of_objects( + request=[ObjectWithRequiredField(string="string")] + ) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.container.get_and_return_set_of_objects( + request=[ObjectWithRequiredField(string="string")] + ) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_map_prim_to_prim(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = {"string": "string"} + expected_types: typing.Tuple[typing.Any, typing.Any] = ("dict", {0: (None, None)}) + response = client.endpoints.container.get_and_return_map_prim_to_prim(request={"string": "string"}) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.container.get_and_return_map_prim_to_prim( + request={"string": "string"} + ) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_map_of_prim_to_object(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = {"string": {"string": "string"}} + expected_types: typing.Tuple[typing.Any, typing.Any] = ("dict", {0: (None, {"string": None})}) + response = client.endpoints.container.get_and_return_map_of_prim_to_object( + request={"string": ObjectWithRequiredField(string="string")} + ) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.container.get_and_return_map_of_prim_to_object( + request={"string": ObjectWithRequiredField(string="string")} + ) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_optional(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = {"string": "string"} + expected_types: typing.Any = {"string": None} + response = client.endpoints.container.get_and_return_optional(request=ObjectWithRequiredField(string="string")) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.container.get_and_return_optional( + request=ObjectWithRequiredField(string="string") + ) + validate_response(async_response, expected_response, expected_types) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_enum.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_enum.py new file mode 100644 index 00000000000..9e65f445a59 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_enum.py @@ -0,0 +1,16 @@ +# This file was auto-generated by Fern from our API Definition. + +from seed import SeedExhaustive +from seed import AsyncSeedExhaustive +import typing +from ..utilities import validate_response + + +async def test_get_and_return_enum(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = "SUNNY" + expected_types: typing.Any = None + response = client.endpoints.enum.get_and_return_enum(request="SUNNY") + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.enum.get_and_return_enum(request="SUNNY") + validate_response(async_response, expected_response, expected_types) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_http_methods.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_http_methods.py new file mode 100644 index 00000000000..537a9114284 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_http_methods.py @@ -0,0 +1,172 @@ +# This file was auto-generated by Fern from our API Definition. + +from seed import SeedExhaustive +from seed import AsyncSeedExhaustive +import typing +from ..utilities import validate_response +import datetime +import uuid + + +async def test_test_get(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = "string" + expected_types: typing.Any = None + response = client.endpoints.http_methods.test_get(id="id") + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.http_methods.test_get(id="id") + validate_response(async_response, expected_response, expected_types) + + +async def test_test_post(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = { + "string": "string", + "integer": 1, + "long": 1000000, + "double": 1.1, + "bool": True, + "datetime": "2024-01-15T09:30:00Z", + "date": "2023-01-15", + "uuid": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + "base64": "SGVsbG8gd29ybGQh", + "list": ["list", "list"], + "set": ["set"], + "map": {"1": "map"}, + "bigint": "1000000", + } + expected_types: typing.Any = { + "string": None, + "integer": "integer", + "long": None, + "double": None, + "bool": None, + "datetime": "datetime", + "date": "date", + "uuid": "uuid", + "base64": None, + "list": ("list", {0: None, 1: None}), + "set": ("set", {0: None}), + "map": ("dict", {0: ("integer", None)}), + "bigint": None, + } + response = client.endpoints.http_methods.test_post(string="string") + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.http_methods.test_post(string="string") + validate_response(async_response, expected_response, expected_types) + + +async def test_test_put(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = { + "string": "string", + "integer": 1, + "long": 1000000, + "double": 1.1, + "bool": True, + "datetime": "2024-01-15T09:30:00Z", + "date": "2023-01-15", + "uuid": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + "base64": "SGVsbG8gd29ybGQh", + "list": ["list", "list"], + "set": ["set"], + "map": {"1": "map"}, + "bigint": "1000000", + } + expected_types: typing.Any = { + "string": None, + "integer": "integer", + "long": None, + "double": None, + "bool": None, + "datetime": "datetime", + "date": "date", + "uuid": "uuid", + "base64": None, + "list": ("list", {0: None, 1: None}), + "set": ("set", {0: None}), + "map": ("dict", {0: ("integer", None)}), + "bigint": None, + } + response = client.endpoints.http_methods.test_put(id="id", string="string") + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.http_methods.test_put(id="id", string="string") + validate_response(async_response, expected_response, expected_types) + + +async def test_test_patch(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = { + "string": "string", + "integer": 1, + "long": 1000000, + "double": 1.1, + "bool": True, + "datetime": "2024-01-15T09:30:00Z", + "date": "2023-01-15", + "uuid": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + "base64": "SGVsbG8gd29ybGQh", + "list": ["list", "list"], + "set": ["set"], + "map": {"1": "map"}, + "bigint": "1000000", + } + expected_types: typing.Any = { + "string": None, + "integer": "integer", + "long": None, + "double": None, + "bool": None, + "datetime": "datetime", + "date": "date", + "uuid": "uuid", + "base64": None, + "list": ("list", {0: None, 1: None}), + "set": ("set", {0: None}), + "map": ("dict", {0: ("integer", None)}), + "bigint": None, + } + response = client.endpoints.http_methods.test_patch( + id="id", + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"), + date=datetime.date.fromisoformat("2023-01-15"), + uuid_=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.http_methods.test_patch( + id="id", + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"), + date=datetime.date.fromisoformat("2023-01-15"), + uuid_=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ) + validate_response(async_response, expected_response, expected_types) + + +async def test_test_delete(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = True + expected_types: typing.Any = None + response = client.endpoints.http_methods.test_delete(id="id") + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.http_methods.test_delete(id="id") + validate_response(async_response, expected_response, expected_types) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_object.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_object.py new file mode 100644 index 00000000000..91f189d3598 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_object.py @@ -0,0 +1,382 @@ +# This file was auto-generated by Fern from our API Definition. + +from seed import SeedExhaustive +from seed import AsyncSeedExhaustive +import typing +import datetime +import uuid +from ..utilities import validate_response +from seed.types.object import ObjectWithOptionalField +from seed.types.object import NestedObjectWithRequiredField + + +async def test_get_and_return_with_optional_field(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = { + "string": "string", + "integer": 1, + "long": 1000000, + "double": 1.1, + "bool": True, + "datetime": "2024-01-15T09:30:00Z", + "date": "2023-01-15", + "uuid": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + "base64": "SGVsbG8gd29ybGQh", + "list": ["list", "list"], + "set": ["set"], + "map": {"1": "map"}, + "bigint": "1000000", + } + expected_types: typing.Any = { + "string": None, + "integer": "integer", + "long": None, + "double": None, + "bool": None, + "datetime": "datetime", + "date": "date", + "uuid": "uuid", + "base64": None, + "list": ("list", {0: None, 1: None}), + "set": ("set", {0: None}), + "map": ("dict", {0: ("integer", None)}), + "bigint": None, + } + response = client.endpoints.object.get_and_return_with_optional_field( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"), + date=datetime.date.fromisoformat("2023-01-15"), + uuid_=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.object.get_and_return_with_optional_field( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"), + date=datetime.date.fromisoformat("2023-01-15"), + uuid_=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_with_required_field(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = {"string": "string"} + expected_types: typing.Any = {"string": None} + response = client.endpoints.object.get_and_return_with_required_field(string="string") + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.object.get_and_return_with_required_field(string="string") + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_with_map_of_map(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = {"map": {"map": {"map": "map"}}} + expected_types: typing.Any = {"map": ("dict", {0: (None, ("dict", {0: (None, None)}))})} + response = client.endpoints.object.get_and_return_with_map_of_map(map_={"map": {"map": "map"}}) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.object.get_and_return_with_map_of_map(map_={"map": {"map": "map"}}) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_nested_with_optional_field( + client: SeedExhaustive, async_client: AsyncSeedExhaustive +) -> None: + expected_response: typing.Any = { + "string": "string", + "NestedObject": { + "string": "string", + "integer": 1, + "long": 1000000, + "double": 1.1, + "bool": True, + "datetime": "2024-01-15T09:30:00Z", + "date": "2023-01-15", + "uuid": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + "base64": "SGVsbG8gd29ybGQh", + "list": ["list", "list"], + "set": ["set"], + "map": {"1": "map"}, + "bigint": "1000000", + }, + } + expected_types: typing.Any = { + "string": None, + "NestedObject": { + "string": None, + "integer": "integer", + "long": None, + "double": None, + "bool": None, + "datetime": "datetime", + "date": "date", + "uuid": "uuid", + "base64": None, + "list": ("list", {0: None, 1: None}), + "set": ("set", {0: None}), + "map": ("dict", {0: ("integer", None)}), + "bigint": None, + }, + } + response = client.endpoints.object.get_and_return_nested_with_optional_field( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"), + date=datetime.date.fromisoformat("2023-01-15"), + uuid_=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.object.get_and_return_nested_with_optional_field( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"), + date=datetime.date.fromisoformat("2023-01-15"), + uuid_=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_nested_with_required_field( + client: SeedExhaustive, async_client: AsyncSeedExhaustive +) -> None: + expected_response: typing.Any = { + "string": "string", + "NestedObject": { + "string": "string", + "integer": 1, + "long": 1000000, + "double": 1.1, + "bool": True, + "datetime": "2024-01-15T09:30:00Z", + "date": "2023-01-15", + "uuid": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + "base64": "SGVsbG8gd29ybGQh", + "list": ["list", "list"], + "set": ["set"], + "map": {"1": "map"}, + "bigint": "1000000", + }, + } + expected_types: typing.Any = { + "string": None, + "NestedObject": { + "string": None, + "integer": "integer", + "long": None, + "double": None, + "bool": None, + "datetime": "datetime", + "date": "date", + "uuid": "uuid", + "base64": None, + "list": ("list", {0: None, 1: None}), + "set": ("set", {0: None}), + "map": ("dict", {0: ("integer", None)}), + "bigint": None, + }, + } + response = client.endpoints.object.get_and_return_nested_with_required_field( + string_="string", + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"), + date=datetime.date.fromisoformat("2023-01-15"), + uuid_=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.object.get_and_return_nested_with_required_field( + string_="string", + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"), + date=datetime.date.fromisoformat("2023-01-15"), + uuid_=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_nested_with_required_field_as_list( + client: SeedExhaustive, async_client: AsyncSeedExhaustive +) -> None: + expected_response: typing.Any = { + "string": "string", + "NestedObject": { + "string": "string", + "integer": 1, + "long": 1000000, + "double": 1.1, + "bool": True, + "datetime": "2024-01-15T09:30:00Z", + "date": "2023-01-15", + "uuid": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + "base64": "SGVsbG8gd29ybGQh", + "list": ["list", "list"], + "set": ["set"], + "map": {"1": "map"}, + "bigint": "1000000", + }, + } + expected_types: typing.Any = { + "string": None, + "NestedObject": { + "string": None, + "integer": "integer", + "long": None, + "double": None, + "bool": None, + "datetime": "datetime", + "date": "date", + "uuid": "uuid", + "base64": None, + "list": ("list", {0: None, 1: None}), + "set": ("set", {0: None}), + "map": ("dict", {0: ("integer", None)}), + "bigint": None, + }, + } + response = client.endpoints.object.get_and_return_nested_with_required_field_as_list( + request=[ + NestedObjectWithRequiredField( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"), + date=datetime.date.fromisoformat("2023-01-15"), + uuid_=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ), + NestedObjectWithRequiredField( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"), + date=datetime.date.fromisoformat("2023-01-15"), + uuid_=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ), + ] + ) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.object.get_and_return_nested_with_required_field_as_list( + request=[ + NestedObjectWithRequiredField( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"), + date=datetime.date.fromisoformat("2023-01-15"), + uuid_=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ), + NestedObjectWithRequiredField( + string="string", + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"), + date=datetime.date.fromisoformat("2023-01-15"), + uuid_=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ), + ] + ) + validate_response(async_response, expected_response, expected_types) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_params.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_params.py new file mode 100644 index 00000000000..de637feba72 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_params.py @@ -0,0 +1,65 @@ +# This file was auto-generated by Fern from our API Definition. + +from seed import SeedExhaustive +from seed import AsyncSeedExhaustive +import typing +from ..utilities import validate_response + + +async def test_get_with_path(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = "string" + expected_types: typing.Any = None + response = client.endpoints.params.get_with_path(param="param") + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.params.get_with_path(param="param") + validate_response(async_response, expected_response, expected_types) + + +async def test_get_with_query(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + # Type ignore to avoid mypy complaining about the function not being meant to return a value + assert ( + client.endpoints.params.get_with_query(query="query", number=1) # type: ignore[func-returns-value] + is None + ) + + assert ( + await async_client.endpoints.params.get_with_query(query="query", number=1) # type: ignore[func-returns-value] + is None + ) + + +async def test_get_with_allow_multiple_query(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + # Type ignore to avoid mypy complaining about the function not being meant to return a value + assert ( + client.endpoints.params.get_with_allow_multiple_query(query="query", numer=1) # type: ignore[func-returns-value] + is None + ) + + assert ( + await async_client.endpoints.params.get_with_allow_multiple_query(query="query", numer=1) # type: ignore[func-returns-value] + is None + ) + + +async def test_get_with_path_and_query(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + # Type ignore to avoid mypy complaining about the function not being meant to return a value + assert ( + client.endpoints.params.get_with_path_and_query(param="param", query="query") # type: ignore[func-returns-value] + is None + ) + + assert ( + await async_client.endpoints.params.get_with_path_and_query(param="param", query="query") # type: ignore[func-returns-value] + is None + ) + + +async def test_modify_with_path(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = "string" + expected_types: typing.Any = None + response = client.endpoints.params.modify_with_path(param="param", request="string") + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.params.modify_with_path(param="param", request="string") + validate_response(async_response, expected_response, expected_types) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_primitive.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_primitive.py new file mode 100644 index 00000000000..ad943784420 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_primitive.py @@ -0,0 +1,106 @@ +# This file was auto-generated by Fern from our API Definition. + +from seed import SeedExhaustive +from seed import AsyncSeedExhaustive +import typing +from ..utilities import validate_response +import datetime +import uuid + + +async def test_get_and_return_string(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = "string" + expected_types: typing.Any = None + response = client.endpoints.primitive.get_and_return_string(request="string") + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.primitive.get_and_return_string(request="string") + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_int(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = 1 + expected_types: typing.Any = "integer" + response = client.endpoints.primitive.get_and_return_int(request=1) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.primitive.get_and_return_int(request=1) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_long(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = 1000000 + expected_types: typing.Any = None + response = client.endpoints.primitive.get_and_return_long(request=1000000) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.primitive.get_and_return_long(request=1000000) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_double(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = 1.1 + expected_types: typing.Any = None + response = client.endpoints.primitive.get_and_return_double(request=1.1) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.primitive.get_and_return_double(request=1.1) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_bool(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = True + expected_types: typing.Any = None + response = client.endpoints.primitive.get_and_return_bool(request=True) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.primitive.get_and_return_bool(request=True) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_datetime(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = "2024-01-15T09:30:00Z" + expected_types: typing.Any = "datetime" + response = client.endpoints.primitive.get_and_return_datetime( + request=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00") + ) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.primitive.get_and_return_datetime( + request=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00") + ) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_date(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = "2023-01-15" + expected_types: typing.Any = "date" + response = client.endpoints.primitive.get_and_return_date(request=datetime.date.fromisoformat("2023-01-15")) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.primitive.get_and_return_date( + request=datetime.date.fromisoformat("2023-01-15") + ) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_uuid(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32" + expected_types: typing.Any = "uuid" + response = client.endpoints.primitive.get_and_return_uuid(request=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.primitive.get_and_return_uuid( + request=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32") + ) + validate_response(async_response, expected_response, expected_types) + + +async def test_get_and_return_base_64(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = "SGVsbG8gd29ybGQh" + expected_types: typing.Any = None + response = client.endpoints.primitive.get_and_return_base_64(request="SGVsbG8gd29ybGQh") + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.primitive.get_and_return_base_64(request="SGVsbG8gd29ybGQh") + validate_response(async_response, expected_response, expected_types) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_union.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_union.py new file mode 100644 index 00000000000..47567726350 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/endpoints/test_union.py @@ -0,0 +1,19 @@ +# This file was auto-generated by Fern from our API Definition. + +from seed import SeedExhaustive +from seed import AsyncSeedExhaustive +import typing +from seed.types.union import Animal_Dog +from ..utilities import validate_response + + +async def test_get_and_return_union(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = {"animal": "dog", "name": "name", "likesToWoof": True} + expected_types: typing.Any = "no_validate" + response = client.endpoints.union.get_and_return_union(request=Animal_Dog(name="name", likes_to_woof=True)) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.endpoints.union.get_and_return_union( + request=Animal_Dog(name="name", likes_to_woof=True) + ) + validate_response(async_response, expected_response, expected_types) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/test_inlined_requests.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/test_inlined_requests.py new file mode 100644 index 00000000000..9668eb1aac9 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/test_inlined_requests.py @@ -0,0 +1,83 @@ +# This file was auto-generated by Fern from our API Definition. + +from seed import SeedExhaustive +from seed import AsyncSeedExhaustive +import typing +from seed.types.object import ObjectWithOptionalField +import datetime +import uuid +from .utilities import validate_response + + +async def test_post_with_object_bodyand_response(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = { + "string": "string", + "integer": 1, + "long": 1000000, + "double": 1.1, + "bool": True, + "datetime": "2024-01-15T09:30:00Z", + "date": "2023-01-15", + "uuid": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + "base64": "SGVsbG8gd29ybGQh", + "list": ["list", "list"], + "set": ["set"], + "map": {"1": "map"}, + "bigint": "1000000", + } + expected_types: typing.Any = { + "string": None, + "integer": "integer", + "long": None, + "double": None, + "bool": None, + "datetime": "datetime", + "date": "date", + "uuid": "uuid", + "base64": None, + "list": ("list", {0: None, 1: None}), + "set": ("set", {0: None}), + "map": ("dict", {0: ("integer", None)}), + "bigint": None, + } + response = client.inlined_requests.post_with_object_bodyand_response( + string="string", + integer=1, + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"), + date=datetime.date.fromisoformat("2023-01-15"), + uuid_=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.inlined_requests.post_with_object_bodyand_response( + string="string", + integer=1, + nested_object=ObjectWithOptionalField( + string="string", + integer=1, + long_=1000000, + double=1.1, + bool_=True, + datetime=datetime.datetime.fromisoformat("2024-01-15 09:30:00+00:00"), + date=datetime.date.fromisoformat("2023-01-15"), + uuid_=uuid.UUID("d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"), + base_64="SGVsbG8gd29ybGQh", + list_=["list", "list"], + set_={"set"}, + map_={1: "map"}, + bigint=1000000, + ), + ) + validate_response(async_response, expected_response, expected_types) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/test_no_auth.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/test_no_auth.py new file mode 100644 index 00000000000..667b7545590 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/test_no_auth.py @@ -0,0 +1,16 @@ +# This file was auto-generated by Fern from our API Definition. + +from seed import SeedExhaustive +from seed import AsyncSeedExhaustive +import typing +from .utilities import validate_response + + +async def test_post_with_no_auth(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = True + expected_types: typing.Any = None + response = client.no_auth.post_with_no_auth(request={"key": "value"}) + validate_response(response, expected_response, expected_types) + + async_response = await async_client.no_auth.post_with_no_auth(request={"key": "value"}) + validate_response(async_response, expected_response, expected_types) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/test_no_req_body.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/test_no_req_body.py new file mode 100644 index 00000000000..d0f467bb431 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/test_no_req_body.py @@ -0,0 +1,54 @@ +# This file was auto-generated by Fern from our API Definition. + +from seed import SeedExhaustive +from seed import AsyncSeedExhaustive +import typing +from .utilities import validate_response + + +async def test_get_with_no_request_body(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = { + "string": "string", + "integer": 1, + "long": 1000000, + "double": 1.1, + "bool": True, + "datetime": "2024-01-15T09:30:00Z", + "date": "2023-01-15", + "uuid": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + "base64": "SGVsbG8gd29ybGQh", + "list": ["list", "list"], + "set": ["set"], + "map": {"1": "map"}, + "bigint": "1000000", + } + expected_types: typing.Any = { + "string": None, + "integer": "integer", + "long": None, + "double": None, + "bool": None, + "datetime": "datetime", + "date": "date", + "uuid": "uuid", + "base64": None, + "list": ("list", {0: None, 1: None}), + "set": ("set", {0: None}), + "map": ("dict", {0: ("integer", None)}), + "bigint": None, + } + response = client.no_req_body.get_with_no_request_body() + validate_response(response, expected_response, expected_types) + + async_response = await async_client.no_req_body.get_with_no_request_body() + validate_response(async_response, expected_response, expected_types) + + +async def test_post_with_no_request_body(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + expected_response: typing.Any = "string" + expected_types: typing.Any = None + response = client.no_req_body.post_with_no_request_body() + validate_response(response, expected_response, expected_types) + + async_response = await async_client.no_req_body.post_with_no_request_body() + validate_response(async_response, expected_response, expected_types) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/test_req_with_headers.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/test_req_with_headers.py new file mode 100644 index 00000000000..4105ce39190 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/test_req_with_headers.py @@ -0,0 +1,25 @@ +# This file was auto-generated by Fern from our API Definition. + +from seed import SeedExhaustive +from seed import AsyncSeedExhaustive + + +async def test_get_with_custom_header(client: SeedExhaustive, async_client: AsyncSeedExhaustive) -> None: + # Type ignore to avoid mypy complaining about the function not being meant to return a value + assert ( + client.req_with_headers.get_with_custom_header( + x_test_service_header="X-TEST-SERVICE-HEADER", + x_test_endpoint_header="X-TEST-ENDPOINT-HEADER", + request="string", + ) # type: ignore[func-returns-value] + is None + ) + + assert ( + await async_client.req_with_headers.get_with_custom_header( + x_test_service_header="X-TEST-SERVICE-HEADER", + x_test_endpoint_header="X-TEST-ENDPOINT-HEADER", + request="string", + ) # type: ignore[func-returns-value] + is None + ) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utilities.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utilities.py new file mode 100644 index 00000000000..3d228806a9c --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utilities.py @@ -0,0 +1,162 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +import uuid + +from dateutil import parser + +import pydantic + + +def cast_field(json_expectation: typing.Any, type_expectation: typing.Any) -> typing.Any: + # Cast these specific types which come through as string and expect our + # models to cast to the correct type. + if type_expectation == "uuid": + return uuid.UUID(json_expectation) + elif type_expectation == "date": + return parser.parse(json_expectation).date() + elif type_expectation == "datetime": + return parser.parse(json_expectation) + elif type_expectation == "set": + return set(json_expectation) + elif type_expectation == "integer": + # Necessary as we allow numeric keys, but JSON makes them strings + return int(json_expectation) + + return json_expectation + + +def validate_field(response: typing.Any, json_expectation: typing.Any, type_expectation: typing.Any) -> None: + # Allow for an escape hatch if the object cannot be validated + if type_expectation == "no_validate": + return + + is_container_of_complex_type = False + # Parse types in containers, note that dicts are handled within `validate_response` + if isinstance(json_expectation, list): + if isinstance(type_expectation, tuple): + container_expectation = type_expectation[0] + contents_expectation = type_expectation[1] + + cast_json_expectation = [] + for idx, ex in enumerate(json_expectation): + if isinstance(contents_expectation, dict): + entry_expectation = contents_expectation.get(idx) + if isinstance(entry_expectation, dict): + is_container_of_complex_type = True + validate_response( + response=response[idx], + json_expectation=ex, + type_expectations=entry_expectation, + ) + else: + cast_json_expectation.append(cast_field(ex, entry_expectation)) + else: + cast_json_expectation.append(ex) + json_expectation = cast_json_expectation + + # Note that we explicitly do not allow for sets of pydantic models as they are not hashable, so + # if any of the values of the set have a type_expectation of a dict, we're assuming it's a pydantic + # model and keeping it a list. + if container_expectation != "set" or not any( + map( + lambda value: isinstance(value, dict), + list(contents_expectation.values()), + ) + ): + json_expectation = cast_field(json_expectation, container_expectation) + elif isinstance(type_expectation, tuple): + container_expectation = type_expectation[0] + contents_expectation = type_expectation[1] + if isinstance(contents_expectation, dict): + json_expectation = { + cast_field( + key, + contents_expectation.get(idx)[0] # type: ignore + if contents_expectation.get(idx) is not None + else None, + ): cast_field( + value, + contents_expectation.get(idx)[1] # type: ignore + if contents_expectation.get(idx) is not None + else None, + ) + for idx, (key, value) in enumerate(json_expectation.items()) + } + else: + json_expectation = cast_field(json_expectation, container_expectation) + elif type_expectation is not None: + json_expectation = cast_field(json_expectation, type_expectation) + + # When dealing with containers of models, etc. we're validating them implicitly, so no need to check the resultant list + if not is_container_of_complex_type: + assert ( + json_expectation == response + ), "Primitives found, expected: {0} (type: {1}), Actual: {2} (type: {3})".format( + json_expectation, type(json_expectation), response, type(response) + ) + + +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: + # Allow for an escape hatch if the object cannot be validated + if type_expectations == "no_validate": + return + + if ( + not isinstance(response, list) + and not isinstance(response, dict) + and not issubclass(type(response), pydantic.BaseModel) + ): + validate_field( + response=response, + json_expectation=json_expectation, + type_expectation=type_expectations, + ) + return + + if isinstance(response, list): + assert len(response) == len(json_expectation), "Length mismatch, expected: {0}, Actual: {1}".format( + len(response), len(json_expectation) + ) + content_expectation = type_expectations + if isinstance(type_expectations, tuple): + content_expectation = type_expectations[1] + for idx, item in enumerate(response): + validate_response( + response=item, + json_expectation=json_expectation[idx], + type_expectations=content_expectation[idx], + ) + else: + response_json = response + if issubclass(type(response), pydantic.BaseModel): + response_json = response.dict(by_alias=True) + + for key, value in json_expectation.items(): + assert key in response_json, "Field {0} not found within the response object: {1}".format( + key, response_json + ) + + type_expectation = None + if type_expectations is not None and isinstance(type_expectations, dict): + type_expectation = type_expectations.get(key) + + # If your type_expectation is a tuple then you have a container field, process it as such + # Otherwise, we're just validating a single field that's a pydantic model. + if isinstance(value, dict) and not isinstance(type_expectation, tuple): + validate_response( + response=response_json[key], + json_expectation=value, + type_expectations=type_expectation, + ) + else: + validate_field( + response=response_json[key], + json_expectation=value, + type_expectation=type_expectation, + ) + + # Ensure there are no additional fields here either + del response_json[key] + assert len(response_json) == 0, "Additional fields found, expected None: {0}".format(response_json) diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/__init__.py new file mode 100644 index 00000000000..f3ea2659bb1 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/__init__.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/__init__.py new file mode 100644 index 00000000000..3a1c852e71e --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/circle.py new file mode 100644 index 00000000000..6522dc58c5a --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/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 seed.core.serialization import FieldMetadata + + +class CircleParams(typing_extensions.TypedDict): + radius_measurement: typing_extensions.Annotated[float, FieldMetadata(alias="radiusMeasurement")] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/color.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/color.py new file mode 100644 index 00000000000..2aa2c4c52f0 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/object_with_defaults.py new file mode 100644 index 00000000000..ef14f7b2c9d --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/object_with_optional_field.py new file mode 100644 index 00000000000..fc5a379b967 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/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 seed.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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/shape.py new file mode 100644 index 00000000000..ae113ae0609 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/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 seed.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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/square.py new file mode 100644 index 00000000000..7f6f79a3ddc --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/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 seed.core.serialization import FieldMetadata + + +class SquareParams(typing_extensions.TypedDict): + length_measurement: typing_extensions.Annotated[float, FieldMetadata(alias="lengthMeasurement")] diff --git a/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/assets/models/undiscriminated_shape.py new file mode 100644 index 00000000000..68876a23c38 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/test_http_client.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/test_http_client.py new file mode 100644 index 00000000000..a541bae6531 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/test_http_client.py @@ -0,0 +1,61 @@ +# This file was auto-generated by Fern from our API Definition. + +from seed.core.http_client import get_request_body +from seed.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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/test_query_encoding.py new file mode 100644 index 00000000000..e075394a502 --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/test_query_encoding.py @@ -0,0 +1,37 @@ +# This file was auto-generated by Fern from our API Definition. + + +from seed.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/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/test_serialization.py b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/tests/utils/test_serialization.py new file mode 100644 index 00000000000..dd74836366c --- /dev/null +++ b/seed/python-sdk/exhaustive/pydantic-v2-wrapped/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 seed.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 diff --git a/seed/python-sdk/seed.yml b/seed/python-sdk/seed.yml index bc917ac1789..90ed58a7f9b 100644 --- a/seed/python-sdk/seed.yml +++ b/seed/python-sdk/seed.yml @@ -114,7 +114,14 @@ fixtures: pydantic_config: version: v1 wrapped_aliases: True + include_validators: True outputFolder: pydantic-v1-wrapped + - customConfig: + pydantic_config: + version: v2 + wrapped_aliases: True + include_validators: True + outputFolder: pydantic-v2-wrapped - customConfig: pydantic_config: version: v1