@@ -99,8 +99,7 @@ def get(
99
99
GitlabAuthenticationError: If authentication is not correct
100
100
GitlabGetError: If the server cannot perform the request
101
101
"""
102
- if not isinstance (id , int ):
103
- id = utils ._url_encode (id )
102
+ id = utils ._url_encode (id )
104
103
path = f"{ self .path } /{ id } "
105
104
if TYPE_CHECKING :
106
105
assert self ._obj_cls is not None
@@ -173,7 +172,7 @@ def refresh(self, **kwargs: Any) -> None:
173
172
GitlabGetError: If the server cannot perform the request
174
173
"""
175
174
if self ._id_attr :
176
- path = f"{ self .manager .path } /{ self .id } "
175
+ path = f"{ self .manager .path } /{ self .encoded_id } "
177
176
else :
178
177
if TYPE_CHECKING :
179
178
assert self .manager .path is not None
@@ -391,7 +390,7 @@ def update(
391
390
if id is None :
392
391
path = self .path
393
392
else :
394
- path = f"{ self .path } /{ id } "
393
+ path = f"{ self .path } /{ utils . _url_encode ( id ) } "
395
394
396
395
self ._check_missing_update_attrs (new_data )
397
396
files = {}
@@ -477,9 +476,7 @@ def delete(self, id: Union[str, int], **kwargs: Any) -> None:
477
476
if id is None :
478
477
path = self .path
479
478
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 )} "
483
480
self .gitlab .http_delete (path , ** kwargs )
484
481
485
482
@@ -545,6 +542,7 @@ def save(self, **kwargs: Any) -> None:
545
542
return
546
543
547
544
# call the manager
545
+ # Don't use `self.encoded_id` here as `self.manager.update()` will encode it.
548
546
obj_id = self .get_id ()
549
547
if TYPE_CHECKING :
550
548
assert isinstance (self .manager , UpdateMixin )
@@ -575,6 +573,7 @@ def delete(self, **kwargs: Any) -> None:
575
573
"""
576
574
if TYPE_CHECKING :
577
575
assert isinstance (self .manager , DeleteMixin )
576
+ # Don't use `self.encoded_id` here as `self.manager.delete()` will encode it.
578
577
self .manager .delete (self .get_id (), ** kwargs )
579
578
580
579
@@ -598,7 +597,7 @@ def user_agent_detail(self, **kwargs: Any) -> Dict[str, Any]:
598
597
GitlabAuthenticationError: If authentication is not correct
599
598
GitlabGetError: If the server cannot perform the request
600
599
"""
601
- path = f"{ self .manager .path } /{ self .get_id () } /user_agent_detail"
600
+ path = f"{ self .manager .path } /{ self .encoded_id } /user_agent_detail"
602
601
result = self .manager .gitlab .http_get (path , ** kwargs )
603
602
if TYPE_CHECKING :
604
603
assert not isinstance (result , requests .Response )
@@ -631,7 +630,7 @@ def approve(
631
630
GitlabUpdateError: If the server fails to perform the request
632
631
"""
633
632
634
- path = f"{ self .manager .path } /{ self .id } /approve"
633
+ path = f"{ self .manager .path } /{ self .encoded_id } /approve"
635
634
data = {"access_level" : access_level }
636
635
server_data = self .manager .gitlab .http_put (path , post_data = data , ** kwargs )
637
636
if TYPE_CHECKING :
@@ -705,7 +704,7 @@ def subscribe(self, **kwargs: Any) -> None:
705
704
GitlabAuthenticationError: If authentication is not correct
706
705
GitlabSubscribeError: If the subscription cannot be done
707
706
"""
708
- path = f"{ self .manager .path } /{ self .get_id () } /subscribe"
707
+ path = f"{ self .manager .path } /{ self .encoded_id } /subscribe"
709
708
server_data = self .manager .gitlab .http_post (path , ** kwargs )
710
709
if TYPE_CHECKING :
711
710
assert not isinstance (server_data , requests .Response )
@@ -725,7 +724,7 @@ def unsubscribe(self, **kwargs: Any) -> None:
725
724
GitlabAuthenticationError: If authentication is not correct
726
725
GitlabUnsubscribeError: If the unsubscription cannot be done
727
726
"""
728
- path = f"{ self .manager .path } /{ self .get_id () } /unsubscribe"
727
+ path = f"{ self .manager .path } /{ self .encoded_id } /unsubscribe"
729
728
server_data = self .manager .gitlab .http_post (path , ** kwargs )
730
729
if TYPE_CHECKING :
731
730
assert not isinstance (server_data , requests .Response )
@@ -752,7 +751,7 @@ def todo(self, **kwargs: Any) -> None:
752
751
GitlabAuthenticationError: If authentication is not correct
753
752
GitlabTodoError: If the todo cannot be set
754
753
"""
755
- path = f"{ self .manager .path } /{ self .get_id () } /todo"
754
+ path = f"{ self .manager .path } /{ self .encoded_id } /todo"
756
755
self .manager .gitlab .http_post (path , ** kwargs )
757
756
758
757
@@ -781,7 +780,7 @@ def time_stats(self, **kwargs: Any) -> Dict[str, Any]:
781
780
if "time_stats" in self .attributes :
782
781
return self .attributes ["time_stats" ]
783
782
784
- path = f"{ self .manager .path } /{ self .get_id () } /time_stats"
783
+ path = f"{ self .manager .path } /{ self .encoded_id } /time_stats"
785
784
result = self .manager .gitlab .http_get (path , ** kwargs )
786
785
if TYPE_CHECKING :
787
786
assert not isinstance (result , requests .Response )
@@ -800,7 +799,7 @@ def time_estimate(self, duration: str, **kwargs: Any) -> Dict[str, Any]:
800
799
GitlabAuthenticationError: If authentication is not correct
801
800
GitlabTimeTrackingError: If the time tracking update cannot be done
802
801
"""
803
- path = f"{ self .manager .path } /{ self .get_id () } /time_estimate"
802
+ path = f"{ self .manager .path } /{ self .encoded_id } /time_estimate"
804
803
data = {"duration" : duration }
805
804
result = self .manager .gitlab .http_post (path , post_data = data , ** kwargs )
806
805
if TYPE_CHECKING :
@@ -819,7 +818,7 @@ def reset_time_estimate(self, **kwargs: Any) -> Dict[str, Any]:
819
818
GitlabAuthenticationError: If authentication is not correct
820
819
GitlabTimeTrackingError: If the time tracking update cannot be done
821
820
"""
822
- path = f"{ self .manager .path } /{ self .get_id () } /reset_time_estimate"
821
+ path = f"{ self .manager .path } /{ self .encoded_id } /reset_time_estimate"
823
822
result = self .manager .gitlab .http_post (path , ** kwargs )
824
823
if TYPE_CHECKING :
825
824
assert not isinstance (result , requests .Response )
@@ -838,7 +837,7 @@ def add_spent_time(self, duration: str, **kwargs: Any) -> Dict[str, Any]:
838
837
GitlabAuthenticationError: If authentication is not correct
839
838
GitlabTimeTrackingError: If the time tracking update cannot be done
840
839
"""
841
- path = f"{ self .manager .path } /{ self .get_id () } /add_spent_time"
840
+ path = f"{ self .manager .path } /{ self .encoded_id } /add_spent_time"
842
841
data = {"duration" : duration }
843
842
result = self .manager .gitlab .http_post (path , post_data = data , ** kwargs )
844
843
if TYPE_CHECKING :
@@ -857,7 +856,7 @@ def reset_spent_time(self, **kwargs: Any) -> Dict[str, Any]:
857
856
GitlabAuthenticationError: If authentication is not correct
858
857
GitlabTimeTrackingError: If the time tracking update cannot be done
859
858
"""
860
- path = f"{ self .manager .path } /{ self .get_id () } /reset_spent_time"
859
+ path = f"{ self .manager .path } /{ self .encoded_id } /reset_spent_time"
861
860
result = self .manager .gitlab .http_post (path , ** kwargs )
862
861
if TYPE_CHECKING :
863
862
assert not isinstance (result , requests .Response )
@@ -893,7 +892,7 @@ def participants(self, **kwargs: Any) -> Dict[str, Any]:
893
892
The list of participants
894
893
"""
895
894
896
- path = f"{ self .manager .path } /{ self .get_id () } /participants"
895
+ path = f"{ self .manager .path } /{ self .encoded_id } /participants"
897
896
result = self .manager .gitlab .http_get (path , ** kwargs )
898
897
if TYPE_CHECKING :
899
898
assert not isinstance (result , requests .Response )
@@ -967,7 +966,7 @@ def promote(self, **kwargs: Any) -> Dict[str, Any]:
967
966
The updated object data (*not* a RESTObject)
968
967
"""
969
968
970
- path = f"{ self .manager .path } /{ self .id } /promote"
969
+ path = f"{ self .manager .path } /{ self .encoded_id } /promote"
971
970
http_method = self ._get_update_method ()
972
971
result = http_method (path , ** kwargs )
973
972
if TYPE_CHECKING :
0 commit comments