@@ -512,13 +512,18 @@ class EntityModifyRequest(ODataHttpRequest):
512512 Call execute() to send the update-request to the OData service
513513 and get the modified entity."""
514514
515- def __init__ (self , url , connection , handler , entity_set , entity_key ):
515+ def __init__ (self , url , connection , handler , entity_set , entity_key , method = "PATCH" ):
516516 super (EntityModifyRequest , self ).__init__ (url , connection , handler )
517517 self ._logger = logging .getLogger (LOGGER_NAME )
518518 self ._entity_set = entity_set
519519 self ._entity_type = entity_set .entity_type
520520 self ._entity_key = entity_key
521521
522+ if method .upper () not in ["PATCH" , "PUT" ]:
523+ raise ValueError ("Method must be either PATCH or PUT" )
524+
525+ self ._method = method
526+
522527 self ._values = {}
523528
524529 # get all properties declared by entity type
@@ -531,7 +536,7 @@ def get_path(self):
531536
532537 def get_method (self ):
533538 # pylint: disable=no-self-use
534- return 'PATCH'
539+ return self . _method
535540
536541 def get_body (self ):
537542 # pylint: disable=no-self-use
@@ -1152,7 +1157,7 @@ def create_entity_handler(response):
11521157 return EntityCreateRequest (self ._service .url , self ._service .connection , create_entity_handler , self ._entity_set ,
11531158 self .last_segment )
11541159
1155- def update_entity (self , key = None , ** kwargs ):
1160+ def update_entity (self , key = None , method = "PATCH" , ** kwargs ):
11561161 """Updates an existing entity in the given entity-set."""
11571162
11581163 def update_entity_handler (response ):
@@ -1170,7 +1175,7 @@ def update_entity_handler(response):
11701175 self ._logger .info ('Updating entity %s for key %s and args %s' , self ._entity_set .entity_type .name , key , kwargs )
11711176
11721177 return EntityModifyRequest (self ._service .url , self ._service .connection , update_entity_handler , self ._entity_set ,
1173- entity_key )
1178+ entity_key , method = method )
11741179
11751180 def delete_entity (self , key : EntityKey = None , ** kwargs ):
11761181 """Delete the entity"""
0 commit comments