12
12
from pydantic import BaseModel , ValidationError , model_serializer
13
13
14
14
from algoliasearch .ingestion .models .destination_index_name import DestinationIndexName
15
- from algoliasearch .ingestion .models .destination_index_prefix import (
16
- DestinationIndexPrefix ,
17
- )
18
15
19
16
20
17
class DestinationInput (BaseModel ):
21
18
"""
22
19
DestinationInput
23
20
"""
24
21
25
- oneof_schema_1_validator : Optional [DestinationIndexPrefix ] = None
26
- oneof_schema_2_validator : Optional [DestinationIndexName ] = None
27
- actual_instance : Optional [Union [DestinationIndexName , DestinationIndexPrefix ]] = (
28
- None
29
- )
22
+ oneof_schema_1_validator : Optional [DestinationIndexName ] = None
23
+ actual_instance : Optional [Union [DestinationIndexName ]] = None
30
24
31
25
def __init__ (self , * args , ** kwargs ) -> None :
32
26
if args :
@@ -43,9 +37,7 @@ def __init__(self, *args, **kwargs) -> None:
43
37
super ().__init__ (** kwargs )
44
38
45
39
@model_serializer
46
- def unwrap_actual_instance (
47
- self ,
48
- ) -> Optional [Union [DestinationIndexName , DestinationIndexPrefix ]]:
40
+ def unwrap_actual_instance (self ) -> Optional [Union [DestinationIndexName ]]:
49
41
"""
50
42
Unwraps the `actual_instance` when calling the `to_json` method.
51
43
"""
@@ -61,12 +53,6 @@ def from_json(cls, json_str: str) -> Self:
61
53
instance = cls .model_construct ()
62
54
error_messages = []
63
55
64
- try :
65
- instance .actual_instance = DestinationIndexPrefix .from_json (json_str )
66
-
67
- return instance
68
- except (ValidationError , ValueError ) as e :
69
- error_messages .append (str (e ))
70
56
try :
71
57
instance .actual_instance = DestinationIndexName .from_json (json_str )
72
58
@@ -75,7 +61,7 @@ def from_json(cls, json_str: str) -> Self:
75
61
error_messages .append (str (e ))
76
62
77
63
raise ValueError (
78
- "No match found when deserializing the JSON string into DestinationInput with oneOf schemas: DestinationIndexName, DestinationIndexPrefix . Details: "
64
+ "No match found when deserializing the JSON string into DestinationInput with oneOf schemas: DestinationIndexName. Details: "
79
65
+ ", " .join (error_messages )
80
66
)
81
67
0 commit comments