@@ -205,7 +205,7 @@ def _to_generated(self) -> _SearchField:
205
205
)
206
206
207
207
@classmethod
208
- def _from_generated (cls , search_field ):
208
+ def _from_generated (cls , search_field ) -> Optional [ "SearchField" ] :
209
209
if not search_field :
210
210
return None
211
211
# pylint:disable=protected-access
@@ -243,15 +243,63 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> MutableMappin
243
243
return self ._to_generated ().serialize (keep_readonly = keep_readonly , ** kwargs )
244
244
245
245
@classmethod
246
- def deserialize (cls , data : Any , content_type : Optional [str ] = None ) -> "SearchField" :
246
+ def deserialize (cls , data : Any , content_type : Optional [str ] = None ) -> Optional [ "SearchField" ] :
247
247
"""Parse a str using the RestAPI syntax and return a SearchField instance.
248
248
249
249
:param str data: A str using RestAPI structure. JSON by default.
250
250
:param str content_type: JSON by default, set application/xml if XML.
251
251
:returns: A SearchField instance
252
252
:raises: DeserializationError if something went wrong
253
253
"""
254
- return cls ._from_generated (_SearchField .deserialize (data , content_type = content_type )) # type: ignore
254
+ return cls ._from_generated (_SearchField .deserialize (data , content_type = content_type ))
255
+
256
+ def as_dict (self , keep_readonly : bool = True , ** kwargs : Any ) -> MutableMapping [str , Any ]:
257
+ """Return a dict that can be serialized using json.dump.
258
+
259
+ :param bool keep_readonly: If you want to serialize the readonly attributes
260
+ :returns: A dict JSON compatible object
261
+ :rtype: dict
262
+ """
263
+ return self ._to_generated ().as_dict (keep_readonly = keep_readonly , ** kwargs ) # type: ignore
264
+
265
+ @classmethod
266
+ def from_dict (
267
+ cls ,
268
+ data : Any ,
269
+ content_type : Optional [str ] = None ,
270
+ ) -> Optional ["SearchField" ]:
271
+ """Parse a dict using given key extractor return a model.
272
+
273
+ :param dict data: A dict using RestAPI structure
274
+ :param str content_type: JSON by default, set application/xml if XML.
275
+ :returns: A SearchField instance
276
+ :rtype: SearchField
277
+ :raises: DeserializationError if something went wrong
278
+ """
279
+ return cls ._from_generated (_SearchField .from_dict (data , content_type = content_type ))
280
+
281
+ def __eq__ (self , other : Any ) -> bool :
282
+ """Compare objects by comparing all attributes.
283
+
284
+ :param Any other: the object to compare with
285
+ :returns: True if all attributes are equal, else False
286
+ :rtype: bool
287
+ """
288
+ if isinstance (other , self .__class__ ):
289
+ return self .__dict__ == other .__dict__
290
+ return False
291
+
292
+ def __ne__ (self , other : Any ) -> bool :
293
+ """Compare objects by comparing all attributes.
294
+
295
+ :param Any other: the object to compare with
296
+ :returns: False if all attributes are equal, else True
297
+ :rtype: bool
298
+ """
299
+ return not self .__eq__ (other )
300
+
301
+ def __str__ (self ) -> str :
302
+ return str (self .__dict__ )
255
303
256
304
257
305
def SimpleField (
@@ -674,6 +722,54 @@ def deserialize(cls, data: Any, content_type: Optional[str] = None) -> "SearchIn
674
722
"""
675
723
return cls ._from_generated (_SearchIndex .deserialize (data , content_type = content_type ))
676
724
725
+ def as_dict (self , keep_readonly : bool = True , ** kwargs : Any ) -> MutableMapping [str , Any ]:
726
+ """Return a dict that can be serialized using json.dump.
727
+
728
+ :param bool keep_readonly: If you want to serialize the readonly attributes
729
+ :returns: A dict JSON compatible object
730
+ :rtype: dict
731
+ """
732
+ return self ._to_generated ().as_dict (keep_readonly = keep_readonly , ** kwargs ) # type: ignore
733
+
734
+ @classmethod
735
+ def from_dict (
736
+ cls ,
737
+ data : Any ,
738
+ content_type : Optional [str ] = None ,
739
+ ) -> "SearchIndex" :
740
+ """Parse a dict using given key extractor return a model.
741
+
742
+ :param dict data: A dict using RestAPI structure
743
+ :param str content_type: JSON by default, set application/xml if XML.
744
+ :returns: A SearchIndex instance
745
+ :rtype: SearchIndex
746
+ :raises: DeserializationError if something went wrong
747
+ """
748
+ return cls ._from_generated (_SearchIndex .from_dict (data , content_type = content_type ))
749
+
750
+ def __eq__ (self , other : Any ) -> bool :
751
+ """Compare objects by comparing all attributes.
752
+
753
+ :param Any other: the object to compare with
754
+ :returns: True if all attributes are equal, else False
755
+ :rtype: bool
756
+ """
757
+ if isinstance (other , self .__class__ ):
758
+ return self .__dict__ == other .__dict__
759
+ return False
760
+
761
+ def __ne__ (self , other : Any ) -> bool :
762
+ """Compare objects by comparing all attributes.
763
+
764
+ :param Any other: the object to compare with
765
+ :returns: False if all attributes are equal, else True
766
+ :rtype: bool
767
+ """
768
+ return not self .__eq__ (other )
769
+
770
+ def __str__ (self ) -> str :
771
+ return str (self .__dict__ )
772
+
677
773
678
774
def pack_search_field (search_field : SearchField ) -> _SearchField :
679
775
if isinstance (search_field , dict ):
0 commit comments