2222import os
2323import re
2424import tempfile
25+ import uuid
2526
2627from urllib .parse import quote
2728from typing import Tuple , Optional , List , Dict , Union
@@ -312,7 +313,7 @@ def response_deserialize(
312313 return_data = self .__deserialize_file (response_data )
313314 elif response_type is not None :
314315 match = None
315- content_type = response_data .getheader ('content-type' )
316+ content_type = response_data .headers . get ('content-type' )
316317 if content_type is not None :
317318 match = re .search (r"charset=([a-zA-Z\-\d]+)[\s;]?" , content_type )
318319 encoding = match .group (1 ) if match else "utf-8"
@@ -329,7 +330,7 @@ def response_deserialize(
329330 return ApiResponse (
330331 status_code = response_data .status ,
331332 data = return_data ,
332- headers = response_data .getheaders () ,
333+ headers = response_data .headers ,
333334 raw_data = response_data .data
334335 )
335336
@@ -357,6 +358,8 @@ def sanitize_for_serialization(self, obj):
357358 return obj .get_secret_value ()
358359 elif isinstance (obj , self .PRIMITIVE_TYPES ):
359360 return obj
361+ elif isinstance (obj , uuid .UUID ):
362+ return str (obj )
360363 elif isinstance (obj , list ):
361364 return [
362365 self .sanitize_for_serialization (sub_obj ) for sub_obj in obj
@@ -409,7 +412,7 @@ def deserialize(self, response_text: str, response_type: str, content_type: Opti
409412 data = json .loads (response_text )
410413 except ValueError :
411414 data = response_text
412- elif re .match (r'^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)' , content_type , re .IGNORECASE ):
415+ elif re .match (r'^application/(json|[\w!#$&.+\ -^_]+\+json)\s*(;|$)' , content_type , re .IGNORECASE ):
413416 if response_text == "" :
414417 data = ""
415418 else :
@@ -458,13 +461,13 @@ def __deserialize(self, data, klass):
458461
459462 if klass in self .PRIMITIVE_TYPES :
460463 return self .__deserialize_primitive (data , klass )
461- elif klass == object :
464+ elif klass is object :
462465 return self .__deserialize_object (data )
463- elif klass == datetime .date :
466+ elif klass is datetime .date :
464467 return self .__deserialize_date (data )
465- elif klass == datetime .datetime :
468+ elif klass is datetime .datetime :
466469 return self .__deserialize_datetime (data )
467- elif klass == decimal .Decimal :
470+ elif klass is decimal .Decimal :
468471 return decimal .Decimal (data )
469472 elif issubclass (klass , Enum ):
470473 return self .__deserialize_enum (data , klass )
@@ -699,7 +702,7 @@ def __deserialize_file(self, response):
699702 os .close (fd )
700703 os .remove (path )
701704
702- content_disposition = response .getheader ("Content-Disposition" )
705+ content_disposition = response .headers . get ("Content-Disposition" )
703706 if content_disposition :
704707 m = re .search (
705708 r'filename=[\'"]?([^\'"\s]+)[\'"]?' ,
0 commit comments