@@ -99,8 +99,7 @@ def get(
9999 GitlabAuthenticationError: If authentication is not correct
100100 GitlabGetError: If the server cannot perform the request
101101 """
102- if not isinstance (id , int ):
103- id = utils ._url_encode (id )
102+ id = utils ._url_encode (id )
104103 path = f"{ self .path } /{ id } "
105104 if TYPE_CHECKING :
106105 assert self ._obj_cls is not None
@@ -173,7 +172,7 @@ def refresh(self, **kwargs: Any) -> None:
173172 GitlabGetError: If the server cannot perform the request
174173 """
175174 if self ._id_attr :
176- path = f"{ self .manager .path } /{ self .id } "
175+ path = f"{ self .manager .path } /{ self .encoded_id } "
177176 else :
178177 if TYPE_CHECKING :
179178 assert self .manager .path is not None
@@ -391,7 +390,7 @@ def update(
391390 if id is None :
392391 path = self .path
393392 else :
394- path = f"{ self .path } /{ id } "
393+ path = f"{ self .path } /{ utils . _url_encode ( id ) } "
395394
396395 self ._check_missing_update_attrs (new_data )
397396 files = {}
@@ -477,9 +476,7 @@ def delete(self, id: Union[str, int], **kwargs: Any) -> None:
477476 if id is None :
478477 path = self .path
479478 else :
480- if not isinstance (id , int ):
481- id = utils ._url_encode (id )
482- path = f"{ self .path } /{ id } "
479+ path = f"{ self .path } /{ utils ._url_encode (id )} "
483480 self .gitlab .http_delete (path , ** kwargs )
484481
485482
@@ -545,7 +542,7 @@ def save(self, **kwargs: Any) -> None:
545542 return
546543
547544 # call the manager
548- obj_id = self .get_id ()
545+ obj_id = self .encoded_id
549546 if TYPE_CHECKING :
550547 assert isinstance (self .manager , UpdateMixin )
551548 server_data = self .manager .update (obj_id , updated_data , ** kwargs )
@@ -575,6 +572,7 @@ def delete(self, **kwargs: Any) -> None:
575572 """
576573 if TYPE_CHECKING :
577574 assert isinstance (self .manager , DeleteMixin )
575+ # Don't use `self.encoded_id` here as `self.manager.delete()` will encode it.
578576 self .manager .delete (self .get_id (), ** kwargs )
579577
580578
@@ -598,7 +596,7 @@ def user_agent_detail(self, **kwargs: Any) -> Dict[str, Any]:
598596 GitlabAuthenticationError: If authentication is not correct
599597 GitlabGetError: If the server cannot perform the request
600598 """
601- path = f"{ self .manager .path } /{ self .get_id () } /user_agent_detail"
599+ path = f"{ self .manager .path } /{ self .encoded_id } /user_agent_detail"
602600 result = self .manager .gitlab .http_get (path , ** kwargs )
603601 if TYPE_CHECKING :
604602 assert not isinstance (result , requests .Response )
@@ -631,7 +629,7 @@ def approve(
631629 GitlabUpdateError: If the server fails to perform the request
632630 """
633631
634- path = f"{ self .manager .path } /{ self .id } /approve"
632+ path = f"{ self .manager .path } /{ self .encoded_id } /approve"
635633 data = {"access_level" : access_level }
636634 server_data = self .manager .gitlab .http_put (path , post_data = data , ** kwargs )
637635 if TYPE_CHECKING :
@@ -705,7 +703,7 @@ def subscribe(self, **kwargs: Any) -> None:
705703 GitlabAuthenticationError: If authentication is not correct
706704 GitlabSubscribeError: If the subscription cannot be done
707705 """
708- path = f"{ self .manager .path } /{ self .get_id () } /subscribe"
706+ path = f"{ self .manager .path } /{ self .encoded_id } /subscribe"
709707 server_data = self .manager .gitlab .http_post (path , ** kwargs )
710708 if TYPE_CHECKING :
711709 assert not isinstance (server_data , requests .Response )
@@ -725,7 +723,7 @@ def unsubscribe(self, **kwargs: Any) -> None:
725723 GitlabAuthenticationError: If authentication is not correct
726724 GitlabUnsubscribeError: If the unsubscription cannot be done
727725 """
728- path = f"{ self .manager .path } /{ self .get_id () } /unsubscribe"
726+ path = f"{ self .manager .path } /{ self .encoded_id } /unsubscribe"
729727 server_data = self .manager .gitlab .http_post (path , ** kwargs )
730728 if TYPE_CHECKING :
731729 assert not isinstance (server_data , requests .Response )
@@ -752,7 +750,7 @@ def todo(self, **kwargs: Any) -> None:
752750 GitlabAuthenticationError: If authentication is not correct
753751 GitlabTodoError: If the todo cannot be set
754752 """
755- path = f"{ self .manager .path } /{ self .get_id () } /todo"
753+ path = f"{ self .manager .path } /{ self .encoded_id } /todo"
756754 self .manager .gitlab .http_post (path , ** kwargs )
757755
758756
@@ -781,7 +779,7 @@ def time_stats(self, **kwargs: Any) -> Dict[str, Any]:
781779 if "time_stats" in self .attributes :
782780 return self .attributes ["time_stats" ]
783781
784- path = f"{ self .manager .path } /{ self .get_id () } /time_stats"
782+ path = f"{ self .manager .path } /{ self .encoded_id } /time_stats"
785783 result = self .manager .gitlab .http_get (path , ** kwargs )
786784 if TYPE_CHECKING :
787785 assert not isinstance (result , requests .Response )
@@ -800,7 +798,7 @@ def time_estimate(self, duration: str, **kwargs: Any) -> Dict[str, Any]:
800798 GitlabAuthenticationError: If authentication is not correct
801799 GitlabTimeTrackingError: If the time tracking update cannot be done
802800 """
803- path = f"{ self .manager .path } /{ self .get_id () } /time_estimate"
801+ path = f"{ self .manager .path } /{ self .encoded_id } /time_estimate"
804802 data = {"duration" : duration }
805803 result = self .manager .gitlab .http_post (path , post_data = data , ** kwargs )
806804 if TYPE_CHECKING :
@@ -819,7 +817,7 @@ def reset_time_estimate(self, **kwargs: Any) -> Dict[str, Any]:
819817 GitlabAuthenticationError: If authentication is not correct
820818 GitlabTimeTrackingError: If the time tracking update cannot be done
821819 """
822- path = f"{ self .manager .path } /{ self .get_id () } /reset_time_estimate"
820+ path = f"{ self .manager .path } /{ self .encoded_id } /reset_time_estimate"
823821 result = self .manager .gitlab .http_post (path , ** kwargs )
824822 if TYPE_CHECKING :
825823 assert not isinstance (result , requests .Response )
@@ -838,7 +836,7 @@ def add_spent_time(self, duration: str, **kwargs: Any) -> Dict[str, Any]:
838836 GitlabAuthenticationError: If authentication is not correct
839837 GitlabTimeTrackingError: If the time tracking update cannot be done
840838 """
841- path = f"{ self .manager .path } /{ self .get_id () } /add_spent_time"
839+ path = f"{ self .manager .path } /{ self .encoded_id } /add_spent_time"
842840 data = {"duration" : duration }
843841 result = self .manager .gitlab .http_post (path , post_data = data , ** kwargs )
844842 if TYPE_CHECKING :
@@ -857,7 +855,7 @@ def reset_spent_time(self, **kwargs: Any) -> Dict[str, Any]:
857855 GitlabAuthenticationError: If authentication is not correct
858856 GitlabTimeTrackingError: If the time tracking update cannot be done
859857 """
860- path = f"{ self .manager .path } /{ self .get_id () } /reset_spent_time"
858+ path = f"{ self .manager .path } /{ self .encoded_id } /reset_spent_time"
861859 result = self .manager .gitlab .http_post (path , ** kwargs )
862860 if TYPE_CHECKING :
863861 assert not isinstance (result , requests .Response )
@@ -893,7 +891,7 @@ def participants(self, **kwargs: Any) -> Dict[str, Any]:
893891 The list of participants
894892 """
895893
896- path = f"{ self .manager .path } /{ self .get_id () } /participants"
894+ path = f"{ self .manager .path } /{ self .encoded_id } /participants"
897895 result = self .manager .gitlab .http_get (path , ** kwargs )
898896 if TYPE_CHECKING :
899897 assert not isinstance (result , requests .Response )
@@ -967,7 +965,7 @@ def promote(self, **kwargs: Any) -> Dict[str, Any]:
967965 The updated object data (*not* a RESTObject)
968966 """
969967
970- path = f"{ self .manager .path } /{ self .id } /promote"
968+ path = f"{ self .manager .path } /{ self .encoded_id } /promote"
971969 http_method = self ._get_update_method ()
972970 result = http_method (path , ** kwargs )
973971 if TYPE_CHECKING :
0 commit comments