@@ -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,7 +542,7 @@ def save(self, **kwargs: Any) -> None:
545
542
return
546
543
547
544
# call the manager
548
- obj_id = self .get_id ()
545
+ obj_id = self .encoded_id
549
546
if TYPE_CHECKING :
550
547
assert isinstance (self .manager , UpdateMixin )
551
548
server_data = self .manager .update (obj_id , updated_data , ** kwargs )
@@ -575,6 +572,7 @@ def delete(self, **kwargs: Any) -> None:
575
572
"""
576
573
if TYPE_CHECKING :
577
574
assert isinstance (self .manager , DeleteMixin )
575
+ # Don't use `self.encoded_id` here as `self.manager.delete()` will encode it.
578
576
self .manager .delete (self .get_id (), ** kwargs )
579
577
580
578
@@ -598,7 +596,7 @@ def user_agent_detail(self, **kwargs: Any) -> Dict[str, Any]:
598
596
GitlabAuthenticationError: If authentication is not correct
599
597
GitlabGetError: If the server cannot perform the request
600
598
"""
601
- path = f"{ self .manager .path } /{ self .get_id () } /user_agent_detail"
599
+ path = f"{ self .manager .path } /{ self .encoded_id } /user_agent_detail"
602
600
result = self .manager .gitlab .http_get (path , ** kwargs )
603
601
if TYPE_CHECKING :
604
602
assert not isinstance (result , requests .Response )
@@ -631,7 +629,7 @@ def approve(
631
629
GitlabUpdateError: If the server fails to perform the request
632
630
"""
633
631
634
- path = f"{ self .manager .path } /{ self .id } /approve"
632
+ path = f"{ self .manager .path } /{ self .encoded_id } /approve"
635
633
data = {"access_level" : access_level }
636
634
server_data = self .manager .gitlab .http_put (path , post_data = data , ** kwargs )
637
635
if TYPE_CHECKING :
@@ -705,7 +703,7 @@ def subscribe(self, **kwargs: Any) -> None:
705
703
GitlabAuthenticationError: If authentication is not correct
706
704
GitlabSubscribeError: If the subscription cannot be done
707
705
"""
708
- path = f"{ self .manager .path } /{ self .get_id () } /subscribe"
706
+ path = f"{ self .manager .path } /{ self .encoded_id } /subscribe"
709
707
server_data = self .manager .gitlab .http_post (path , ** kwargs )
710
708
if TYPE_CHECKING :
711
709
assert not isinstance (server_data , requests .Response )
@@ -725,7 +723,7 @@ def unsubscribe(self, **kwargs: Any) -> None:
725
723
GitlabAuthenticationError: If authentication is not correct
726
724
GitlabUnsubscribeError: If the unsubscription cannot be done
727
725
"""
728
- path = f"{ self .manager .path } /{ self .get_id () } /unsubscribe"
726
+ path = f"{ self .manager .path } /{ self .encoded_id } /unsubscribe"
729
727
server_data = self .manager .gitlab .http_post (path , ** kwargs )
730
728
if TYPE_CHECKING :
731
729
assert not isinstance (server_data , requests .Response )
@@ -752,7 +750,7 @@ def todo(self, **kwargs: Any) -> None:
752
750
GitlabAuthenticationError: If authentication is not correct
753
751
GitlabTodoError: If the todo cannot be set
754
752
"""
755
- path = f"{ self .manager .path } /{ self .get_id () } /todo"
753
+ path = f"{ self .manager .path } /{ self .encoded_id } /todo"
756
754
self .manager .gitlab .http_post (path , ** kwargs )
757
755
758
756
@@ -781,7 +779,7 @@ def time_stats(self, **kwargs: Any) -> Dict[str, Any]:
781
779
if "time_stats" in self .attributes :
782
780
return self .attributes ["time_stats" ]
783
781
784
- path = f"{ self .manager .path } /{ self .get_id () } /time_stats"
782
+ path = f"{ self .manager .path } /{ self .encoded_id } /time_stats"
785
783
result = self .manager .gitlab .http_get (path , ** kwargs )
786
784
if TYPE_CHECKING :
787
785
assert not isinstance (result , requests .Response )
@@ -800,7 +798,7 @@ def time_estimate(self, duration: str, **kwargs: Any) -> Dict[str, Any]:
800
798
GitlabAuthenticationError: If authentication is not correct
801
799
GitlabTimeTrackingError: If the time tracking update cannot be done
802
800
"""
803
- path = f"{ self .manager .path } /{ self .get_id () } /time_estimate"
801
+ path = f"{ self .manager .path } /{ self .encoded_id } /time_estimate"
804
802
data = {"duration" : duration }
805
803
result = self .manager .gitlab .http_post (path , post_data = data , ** kwargs )
806
804
if TYPE_CHECKING :
@@ -819,7 +817,7 @@ def reset_time_estimate(self, **kwargs: Any) -> Dict[str, Any]:
819
817
GitlabAuthenticationError: If authentication is not correct
820
818
GitlabTimeTrackingError: If the time tracking update cannot be done
821
819
"""
822
- path = f"{ self .manager .path } /{ self .get_id () } /reset_time_estimate"
820
+ path = f"{ self .manager .path } /{ self .encoded_id } /reset_time_estimate"
823
821
result = self .manager .gitlab .http_post (path , ** kwargs )
824
822
if TYPE_CHECKING :
825
823
assert not isinstance (result , requests .Response )
@@ -838,7 +836,7 @@ def add_spent_time(self, duration: str, **kwargs: Any) -> Dict[str, Any]:
838
836
GitlabAuthenticationError: If authentication is not correct
839
837
GitlabTimeTrackingError: If the time tracking update cannot be done
840
838
"""
841
- path = f"{ self .manager .path } /{ self .get_id () } /add_spent_time"
839
+ path = f"{ self .manager .path } /{ self .encoded_id } /add_spent_time"
842
840
data = {"duration" : duration }
843
841
result = self .manager .gitlab .http_post (path , post_data = data , ** kwargs )
844
842
if TYPE_CHECKING :
@@ -857,7 +855,7 @@ def reset_spent_time(self, **kwargs: Any) -> Dict[str, Any]:
857
855
GitlabAuthenticationError: If authentication is not correct
858
856
GitlabTimeTrackingError: If the time tracking update cannot be done
859
857
"""
860
- path = f"{ self .manager .path } /{ self .get_id () } /reset_spent_time"
858
+ path = f"{ self .manager .path } /{ self .encoded_id } /reset_spent_time"
861
859
result = self .manager .gitlab .http_post (path , ** kwargs )
862
860
if TYPE_CHECKING :
863
861
assert not isinstance (result , requests .Response )
@@ -893,7 +891,7 @@ def participants(self, **kwargs: Any) -> Dict[str, Any]:
893
891
The list of participants
894
892
"""
895
893
896
- path = f"{ self .manager .path } /{ self .get_id () } /participants"
894
+ path = f"{ self .manager .path } /{ self .encoded_id } /participants"
897
895
result = self .manager .gitlab .http_get (path , ** kwargs )
898
896
if TYPE_CHECKING :
899
897
assert not isinstance (result , requests .Response )
@@ -967,7 +965,7 @@ def promote(self, **kwargs: Any) -> Dict[str, Any]:
967
965
The updated object data (*not* a RESTObject)
968
966
"""
969
967
970
- path = f"{ self .manager .path } /{ self .id } /promote"
968
+ path = f"{ self .manager .path } /{ self .encoded_id } /promote"
971
969
http_method = self ._get_update_method ()
972
970
result = http_method (path , ** kwargs )
973
971
if TYPE_CHECKING :
0 commit comments