@@ -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,6 +542,7 @@ def save(self, **kwargs: Any) -> None:
545542 return
546543
547544 # call the manager
545+ # Don't use `self.encoded_id` here as `self.manager.update()` will encode it.
548546 obj_id = self .get_id ()
549547 if TYPE_CHECKING :
550548 assert isinstance (self .manager , UpdateMixin )
@@ -575,6 +573,7 @@ def delete(self, **kwargs: Any) -> None:
575573 """
576574 if TYPE_CHECKING :
577575 assert isinstance (self .manager , DeleteMixin )
576+ # Don't use `self.encoded_id` here as `self.manager.delete()` will encode it.
578577 self .manager .delete (self .get_id (), ** kwargs )
579578
580579
@@ -598,7 +597,7 @@ def user_agent_detail(self, **kwargs: Any) -> Dict[str, Any]:
598597 GitlabAuthenticationError: If authentication is not correct
599598 GitlabGetError: If the server cannot perform the request
600599 """
601- path = f"{ self .manager .path } /{ self .get_id () } /user_agent_detail"
600+ path = f"{ self .manager .path } /{ self .encoded_id } /user_agent_detail"
602601 result = self .manager .gitlab .http_get (path , ** kwargs )
603602 if TYPE_CHECKING :
604603 assert not isinstance (result , requests .Response )
@@ -631,7 +630,7 @@ def approve(
631630 GitlabUpdateError: If the server fails to perform the request
632631 """
633632
634- path = f"{ self .manager .path } /{ self .id } /approve"
633+ path = f"{ self .manager .path } /{ self .encoded_id } /approve"
635634 data = {"access_level" : access_level }
636635 server_data = self .manager .gitlab .http_put (path , post_data = data , ** kwargs )
637636 if TYPE_CHECKING :
@@ -705,7 +704,7 @@ def subscribe(self, **kwargs: Any) -> None:
705704 GitlabAuthenticationError: If authentication is not correct
706705 GitlabSubscribeError: If the subscription cannot be done
707706 """
708- path = f"{ self .manager .path } /{ self .get_id () } /subscribe"
707+ path = f"{ self .manager .path } /{ self .encoded_id } /subscribe"
709708 server_data = self .manager .gitlab .http_post (path , ** kwargs )
710709 if TYPE_CHECKING :
711710 assert not isinstance (server_data , requests .Response )
@@ -725,7 +724,7 @@ def unsubscribe(self, **kwargs: Any) -> None:
725724 GitlabAuthenticationError: If authentication is not correct
726725 GitlabUnsubscribeError: If the unsubscription cannot be done
727726 """
728- path = f"{ self .manager .path } /{ self .get_id () } /unsubscribe"
727+ path = f"{ self .manager .path } /{ self .encoded_id } /unsubscribe"
729728 server_data = self .manager .gitlab .http_post (path , ** kwargs )
730729 if TYPE_CHECKING :
731730 assert not isinstance (server_data , requests .Response )
@@ -752,7 +751,7 @@ def todo(self, **kwargs: Any) -> None:
752751 GitlabAuthenticationError: If authentication is not correct
753752 GitlabTodoError: If the todo cannot be set
754753 """
755- path = f"{ self .manager .path } /{ self .get_id () } /todo"
754+ path = f"{ self .manager .path } /{ self .encoded_id } /todo"
756755 self .manager .gitlab .http_post (path , ** kwargs )
757756
758757
@@ -781,7 +780,7 @@ def time_stats(self, **kwargs: Any) -> Dict[str, Any]:
781780 if "time_stats" in self .attributes :
782781 return self .attributes ["time_stats" ]
783782
784- path = f"{ self .manager .path } /{ self .get_id () } /time_stats"
783+ path = f"{ self .manager .path } /{ self .encoded_id } /time_stats"
785784 result = self .manager .gitlab .http_get (path , ** kwargs )
786785 if TYPE_CHECKING :
787786 assert not isinstance (result , requests .Response )
@@ -800,7 +799,7 @@ def time_estimate(self, duration: str, **kwargs: Any) -> Dict[str, Any]:
800799 GitlabAuthenticationError: If authentication is not correct
801800 GitlabTimeTrackingError: If the time tracking update cannot be done
802801 """
803- path = f"{ self .manager .path } /{ self .get_id () } /time_estimate"
802+ path = f"{ self .manager .path } /{ self .encoded_id } /time_estimate"
804803 data = {"duration" : duration }
805804 result = self .manager .gitlab .http_post (path , post_data = data , ** kwargs )
806805 if TYPE_CHECKING :
@@ -819,7 +818,7 @@ def reset_time_estimate(self, **kwargs: Any) -> Dict[str, Any]:
819818 GitlabAuthenticationError: If authentication is not correct
820819 GitlabTimeTrackingError: If the time tracking update cannot be done
821820 """
822- path = f"{ self .manager .path } /{ self .get_id () } /reset_time_estimate"
821+ path = f"{ self .manager .path } /{ self .encoded_id } /reset_time_estimate"
823822 result = self .manager .gitlab .http_post (path , ** kwargs )
824823 if TYPE_CHECKING :
825824 assert not isinstance (result , requests .Response )
@@ -838,7 +837,7 @@ def add_spent_time(self, duration: str, **kwargs: Any) -> Dict[str, Any]:
838837 GitlabAuthenticationError: If authentication is not correct
839838 GitlabTimeTrackingError: If the time tracking update cannot be done
840839 """
841- path = f"{ self .manager .path } /{ self .get_id () } /add_spent_time"
840+ path = f"{ self .manager .path } /{ self .encoded_id } /add_spent_time"
842841 data = {"duration" : duration }
843842 result = self .manager .gitlab .http_post (path , post_data = data , ** kwargs )
844843 if TYPE_CHECKING :
@@ -857,7 +856,7 @@ def reset_spent_time(self, **kwargs: Any) -> Dict[str, Any]:
857856 GitlabAuthenticationError: If authentication is not correct
858857 GitlabTimeTrackingError: If the time tracking update cannot be done
859858 """
860- path = f"{ self .manager .path } /{ self .get_id () } /reset_spent_time"
859+ path = f"{ self .manager .path } /{ self .encoded_id } /reset_spent_time"
861860 result = self .manager .gitlab .http_post (path , ** kwargs )
862861 if TYPE_CHECKING :
863862 assert not isinstance (result , requests .Response )
@@ -893,7 +892,7 @@ def participants(self, **kwargs: Any) -> Dict[str, Any]:
893892 The list of participants
894893 """
895894
896- path = f"{ self .manager .path } /{ self .get_id () } /participants"
895+ path = f"{ self .manager .path } /{ self .encoded_id } /participants"
897896 result = self .manager .gitlab .http_get (path , ** kwargs )
898897 if TYPE_CHECKING :
899898 assert not isinstance (result , requests .Response )
@@ -967,7 +966,7 @@ def promote(self, **kwargs: Any) -> Dict[str, Any]:
967966 The updated object data (*not* a RESTObject)
968967 """
969968
970- path = f"{ self .manager .path } /{ self .id } /promote"
969+ path = f"{ self .manager .path } /{ self .encoded_id } /promote"
971970 http_method = self ._get_update_method ()
972971 result = http_method (path , ** kwargs )
973972 if TYPE_CHECKING :
0 commit comments