@@ -62,16 +62,16 @@ def _headers(self) -> Dict[str, str]:
6262 "OData-Version" : "4.0" ,
6363 }
6464
65- def _request (self , method : str , url : str , ** kwargs ):
65+ def _raw_request (self , method : str , url : str , ** kwargs ):
6666 return self ._http .request (method , url , ** kwargs )
6767
68- def _send (self , method : str , url : str , * , expected : tuple [int , ...] = (200 , 201 , 202 , 204 ), ** kwargs ):
68+ def _request (self , method : str , url : str , * , expected : tuple [int , ...] = (200 , 201 , 202 , 204 ), ** kwargs ):
6969 """Execute HTTP request; raise HttpError with structured details on failure.
7070
7171 Returns the raw response for success codes; raises HttpError with extracted
7272 Dataverse error payload fields and correlation identifiers otherwise.
7373 """
74- r = self ._request (method , url , ** kwargs )
74+ r = self ._raw_request (method , url , ** kwargs )
7575 if r .status_code in expected :
7676 return r
7777 payload = {}
@@ -150,7 +150,7 @@ def _create_single(self, entity_set: str, logical_name: str, record: Dict[str, A
150150 record = self ._convert_labels_to_ints (logical_name , record )
151151 url = f"{ self .api } /{ entity_set } "
152152 headers = self ._headers ().copy ()
153- r = self ._send ("post" , url , headers = headers , json = record )
153+ r = self ._request ("post" , url , headers = headers , json = record )
154154
155155 ent_loc = r .headers .get ("OData-EntityId" ) or r .headers .get ("OData-EntityID" )
156156 if ent_loc :
@@ -185,7 +185,7 @@ def _create_multiple(self, entity_set: str, logical_name: str, records: List[Dic
185185 url = f"{ self .api } /{ entity_set } /Microsoft.Dynamics.CRM.CreateMultiple"
186186 # The action currently returns only Ids; no need to request representation.
187187 headers = self ._headers ().copy ()
188- r = self ._send ("post" , url , headers = headers , json = payload )
188+ r = self ._request ("post" , url , headers = headers , json = payload )
189189 try :
190190 body = r .json () if r .text else {}
191191 except ValueError :
@@ -304,7 +304,7 @@ def _update(self, logical_name: str, key: str, data: Dict[str, Any]) -> None:
304304 url = f"{ self .api } /{ entity_set } { self ._format_key (key )} "
305305 headers = self ._headers ().copy ()
306306 headers ["If-Match" ] = "*"
307- r = self ._send ("patch" , url , headers = headers , json = data )
307+ r = self ._request ("patch" , url , headers = headers , json = data )
308308
309309 def _update_multiple (self , entity_set : str , logical_name : str , records : List [Dict [str , Any ]]) -> None :
310310 """Bulk update existing records via the collection-bound UpdateMultiple action.
@@ -354,7 +354,7 @@ def _update_multiple(self, entity_set: str, logical_name: str, records: List[Dic
354354 payload = {"Targets" : enriched }
355355 url = f"{ self .api } /{ entity_set } /Microsoft.Dynamics.CRM.UpdateMultiple"
356356 headers = self ._headers ().copy ()
357- r = self ._send ("post" , url , headers = headers , json = payload )
357+ r = self ._request ("post" , url , headers = headers , json = payload )
358358 # Intentionally ignore response content: no stable contract for IDs across environments.
359359 return None
360360
@@ -364,7 +364,7 @@ def _delete(self, logical_name: str, key: str) -> None:
364364 url = f"{ self .api } /{ entity_set } { self ._format_key (key )} "
365365 headers = self ._headers ().copy ()
366366 headers ["If-Match" ] = "*"
367- self ._send ("delete" , url , headers = headers )
367+ self ._request ("delete" , url , headers = headers )
368368
369369 def _get (self , logical_name : str , key : str , select : Optional [str ] = None ) -> Dict [str , Any ]:
370370 """Retrieve a single record.
@@ -383,7 +383,7 @@ def _get(self, logical_name: str, key: str, select: Optional[str] = None) -> Dic
383383 params ["$select" ] = select
384384 entity_set = self ._entity_set_from_logical (logical_name )
385385 url = f"{ self .api } /{ entity_set } { self ._format_key (key )} "
386- r = self ._send ("get" , url , headers = self ._headers (), params = params )
386+ r = self ._request ("get" , url , headers = self ._headers (), params = params )
387387 return r .json ()
388388
389389 def _get_multiple (
@@ -428,7 +428,7 @@ def _get_multiple(
428428 headers ["Prefer" ] = f"odata.maxpagesize={ ps } "
429429
430430 def _do_request (url : str , * , params : Optional [Dict [str , Any ]] = None ) -> Dict [str , Any ]:
431- r = self ._send ("get" , url , headers = headers , params = params )
431+ r = self ._request ("get" , url , headers = headers , params = params )
432432 try :
433433 return r .json ()
434434 except ValueError :
@@ -503,7 +503,7 @@ def _query_sql(self, sql: str) -> list[dict[str, Any]]:
503503 headers = self ._headers ().copy ()
504504 url = f"{ self .api } /{ entity_set } "
505505 params = {"sql" : sql }
506- r = self ._send ("get" , url , headers = headers , params = params )
506+ r = self ._request ("get" , url , headers = headers , params = params )
507507 try :
508508 body = r .json ()
509509 except ValueError :
@@ -554,7 +554,7 @@ def _entity_set_from_logical(self, logical: str) -> str:
554554 "$select" : "LogicalName,EntitySetName,PrimaryIdAttribute" ,
555555 "$filter" : f"LogicalName eq '{ logical_escaped } '" ,
556556 }
557- r = self ._send ("get" , url , headers = self ._headers (), params = params )
557+ r = self ._request ("get" , url , headers = self ._headers (), params = params )
558558 try :
559559 body = r .json ()
560560 items = body .get ("value" , []) if isinstance (body , dict ) else []
@@ -599,7 +599,7 @@ def _get_entity_by_schema(self, schema_name: str) -> Optional[Dict[str, Any]]:
599599 "$select" : "MetadataId,LogicalName,SchemaName,EntitySetName" ,
600600 "$filter" : f"SchemaName eq '{ schema_escaped } '" ,
601601 }
602- r = self ._send ("get" , url , headers = self ._headers (), params = params )
602+ r = self ._request ("get" , url , headers = self ._headers (), params = params )
603603 items = r .json ().get ("value" , [])
604604 return items [0 ] if items else None
605605
@@ -618,7 +618,7 @@ def _create_entity(self, schema_name: str, display_name: str, attributes: List[D
618618 "Attributes" : attributes ,
619619 }
620620 headers = self ._headers ()
621- r = self ._send ("post" , url , headers = headers , json = payload )
621+ r = self ._request ("post" , url , headers = headers , json = payload )
622622 ent = self ._wait_for_entity_ready (schema_name )
623623 if not ent or not ent .get ("EntitySetName" ):
624624 raise RuntimeError (
@@ -791,7 +791,7 @@ def _optionset_map(self, logical_name: str, attr_logical: str) -> Optional[Dict[
791791 # Retry up to 3 times on 404 (new or not-yet-published attribute metadata). If still 404, raise.
792792 r_type = None
793793 for attempt in range (3 ):
794- r_type = self ._request ("get" , url_type , headers = self ._headers ())
794+ r_type = self ._raw_request ("get" , url_type , headers = self ._headers ())
795795 if r_type .status_code != 404 :
796796 break
797797 if attempt < 2 :
@@ -804,7 +804,7 @@ def _optionset_map(self, logical_name: str, attr_logical: str) -> Optional[Dict[
804804 )
805805 if not (200 <= r_type .status_code < 300 ):
806806 # Re-issue via _send to raise structured HttpError (rare path)
807- self ._send ("get" , url_type , headers = self ._headers ())
807+ self ._request ("get" , url_type , headers = self ._headers ())
808808
809809 body_type = r_type .json ()
810810 items = body_type .get ("value" , []) if isinstance (body_type , dict ) else []
@@ -824,15 +824,15 @@ def _optionset_map(self, logical_name: str, attr_logical: str) -> Optional[Dict[
824824 # Step 2 fetch with retries: expanded OptionSet (cast form first)
825825 r_opts = None
826826 for attempt in range (3 ):
827- r_opts = self ._request ("get" , cast_url , headers = self ._headers ())
827+ r_opts = self ._raw_request ("get" , cast_url , headers = self ._headers ())
828828 if r_opts .status_code != 404 :
829829 break
830830 if attempt < 2 :
831831 time .sleep (0.4 * (2 ** attempt )) # 0.4s, 0.8s
832832 if r_opts .status_code == 404 :
833833 raise RuntimeError (f"Picklist OptionSet metadata not found after retries: entity='{ logical_name } ' attribute='{ attr_logical } ' (404)" )
834834 if not (200 <= r_opts .status_code < 300 ):
835- self ._send ("get" , cast_url , headers = self ._headers ())
835+ self ._request ("get" , cast_url , headers = self ._headers ())
836836
837837 attr_full = {}
838838 try :
@@ -993,7 +993,7 @@ def _list_tables(self) -> List[Dict[str, Any]]:
993993 params = {
994994 "$filter" : "IsPrivate eq false"
995995 }
996- r = self ._send ("get" , url , headers = self ._headers (), params = params )
996+ r = self ._request ("get" , url , headers = self ._headers (), params = params )
997997 return r .json ().get ("value" , [])
998998
999999 def _delete_table (self , tablename : str ) -> None :
@@ -1005,7 +1005,7 @@ def _delete_table(self, tablename: str) -> None:
10051005 metadata_id = ent ["MetadataId" ]
10061006 url = f"{ self .api } /EntityDefinitions({ metadata_id } )"
10071007 headers = self ._headers ()
1008- r = self ._send ("delete" , url , headers = headers )
1008+ r = self ._request ("delete" , url , headers = headers )
10091009
10101010 def _create_table (self , tablename : str , schema : Dict [str , Any ]) -> Dict [str , Any ]:
10111011 # Accept a friendly name and construct a default schema under 'new_'.
0 commit comments