@@ -99,9 +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 )
104
- path = f"{ self .path } /{ id } "
102
+ path = f"{ self .path } /{ utils .EncodedId (id )} "
105
103
if TYPE_CHECKING :
106
104
assert self ._obj_cls is not None
107
105
if lazy is True :
@@ -444,7 +442,7 @@ def set(self, key: str, value: str, **kwargs: Any) -> base.RESTObject:
444
442
Returns:
445
443
The created/updated attribute
446
444
"""
447
- path = f"{ self .path } /{ utils ._url_encode (key )} "
445
+ path = f"{ self .path } /{ utils .EncodedId (key )} "
448
446
data = {"value" : value }
449
447
server_data = self .gitlab .http_put (path , post_data = data , ** kwargs )
450
448
if TYPE_CHECKING :
@@ -477,9 +475,7 @@ def delete(self, id: Union[str, int], **kwargs: Any) -> None:
477
475
if id is None :
478
476
path = self .path
479
477
else :
480
- if not isinstance (id , int ):
481
- id = utils ._url_encode (id )
482
- path = f"{ self .path } /{ id } "
478
+ path = f"{ self .path } /{ utils .EncodedId (id )} "
483
479
self .gitlab .http_delete (path , ** kwargs )
484
480
485
481
@@ -545,7 +541,7 @@ def save(self, **kwargs: Any) -> None:
545
541
return
546
542
547
543
# call the manager
548
- obj_id = self .get_id ()
544
+ obj_id = self .encoded_id
549
545
if TYPE_CHECKING :
550
546
assert isinstance (self .manager , UpdateMixin )
551
547
server_data = self .manager .update (obj_id , updated_data , ** kwargs )
@@ -575,7 +571,7 @@ def delete(self, **kwargs: Any) -> None:
575
571
"""
576
572
if TYPE_CHECKING :
577
573
assert isinstance (self .manager , DeleteMixin )
578
- self .manager .delete (self .get_id () , ** kwargs )
574
+ self .manager .delete (self .encoded_id , ** kwargs )
579
575
580
576
581
577
class UserAgentDetailMixin (_RestObjectBase ):
@@ -598,7 +594,7 @@ def user_agent_detail(self, **kwargs: Any) -> Dict[str, Any]:
598
594
GitlabAuthenticationError: If authentication is not correct
599
595
GitlabGetError: If the server cannot perform the request
600
596
"""
601
- path = f"{ self .manager .path } /{ self .get_id () } /user_agent_detail"
597
+ path = f"{ self .manager .path } /{ self .encoded_id } /user_agent_detail"
602
598
result = self .manager .gitlab .http_get (path , ** kwargs )
603
599
if TYPE_CHECKING :
604
600
assert not isinstance (result , requests .Response )
@@ -705,7 +701,7 @@ def subscribe(self, **kwargs: Any) -> None:
705
701
GitlabAuthenticationError: If authentication is not correct
706
702
GitlabSubscribeError: If the subscription cannot be done
707
703
"""
708
- path = f"{ self .manager .path } /{ self .get_id () } /subscribe"
704
+ path = f"{ self .manager .path } /{ self .encoded_id } /subscribe"
709
705
server_data = self .manager .gitlab .http_post (path , ** kwargs )
710
706
if TYPE_CHECKING :
711
707
assert not isinstance (server_data , requests .Response )
@@ -725,7 +721,7 @@ def unsubscribe(self, **kwargs: Any) -> None:
725
721
GitlabAuthenticationError: If authentication is not correct
726
722
GitlabUnsubscribeError: If the unsubscription cannot be done
727
723
"""
728
- path = f"{ self .manager .path } /{ self .get_id () } /unsubscribe"
724
+ path = f"{ self .manager .path } /{ self .encoded_id } /unsubscribe"
729
725
server_data = self .manager .gitlab .http_post (path , ** kwargs )
730
726
if TYPE_CHECKING :
731
727
assert not isinstance (server_data , requests .Response )
@@ -752,7 +748,7 @@ def todo(self, **kwargs: Any) -> None:
752
748
GitlabAuthenticationError: If authentication is not correct
753
749
GitlabTodoError: If the todo cannot be set
754
750
"""
755
- path = f"{ self .manager .path } /{ self .get_id () } /todo"
751
+ path = f"{ self .manager .path } /{ self .encoded_id } /todo"
756
752
self .manager .gitlab .http_post (path , ** kwargs )
757
753
758
754
@@ -781,7 +777,7 @@ def time_stats(self, **kwargs: Any) -> Dict[str, Any]:
781
777
if "time_stats" in self .attributes :
782
778
return self .attributes ["time_stats" ]
783
779
784
- path = f"{ self .manager .path } /{ self .get_id () } /time_stats"
780
+ path = f"{ self .manager .path } /{ self .encoded_id } /time_stats"
785
781
result = self .manager .gitlab .http_get (path , ** kwargs )
786
782
if TYPE_CHECKING :
787
783
assert not isinstance (result , requests .Response )
@@ -800,7 +796,7 @@ def time_estimate(self, duration: str, **kwargs: Any) -> Dict[str, Any]:
800
796
GitlabAuthenticationError: If authentication is not correct
801
797
GitlabTimeTrackingError: If the time tracking update cannot be done
802
798
"""
803
- path = f"{ self .manager .path } /{ self .get_id () } /time_estimate"
799
+ path = f"{ self .manager .path } /{ self .encoded_id } /time_estimate"
804
800
data = {"duration" : duration }
805
801
result = self .manager .gitlab .http_post (path , post_data = data , ** kwargs )
806
802
if TYPE_CHECKING :
@@ -819,7 +815,7 @@ def reset_time_estimate(self, **kwargs: Any) -> Dict[str, Any]:
819
815
GitlabAuthenticationError: If authentication is not correct
820
816
GitlabTimeTrackingError: If the time tracking update cannot be done
821
817
"""
822
- path = f"{ self .manager .path } /{ self .get_id () } /reset_time_estimate"
818
+ path = f"{ self .manager .path } /{ self .encoded_id } /reset_time_estimate"
823
819
result = self .manager .gitlab .http_post (path , ** kwargs )
824
820
if TYPE_CHECKING :
825
821
assert not isinstance (result , requests .Response )
@@ -838,7 +834,7 @@ def add_spent_time(self, duration: str, **kwargs: Any) -> Dict[str, Any]:
838
834
GitlabAuthenticationError: If authentication is not correct
839
835
GitlabTimeTrackingError: If the time tracking update cannot be done
840
836
"""
841
- path = f"{ self .manager .path } /{ self .get_id () } /add_spent_time"
837
+ path = f"{ self .manager .path } /{ self .encoded_id } /add_spent_time"
842
838
data = {"duration" : duration }
843
839
result = self .manager .gitlab .http_post (path , post_data = data , ** kwargs )
844
840
if TYPE_CHECKING :
@@ -857,7 +853,7 @@ def reset_spent_time(self, **kwargs: Any) -> Dict[str, Any]:
857
853
GitlabAuthenticationError: If authentication is not correct
858
854
GitlabTimeTrackingError: If the time tracking update cannot be done
859
855
"""
860
- path = f"{ self .manager .path } /{ self .get_id () } /reset_spent_time"
856
+ path = f"{ self .manager .path } /{ self .encoded_id } /reset_spent_time"
861
857
result = self .manager .gitlab .http_post (path , ** kwargs )
862
858
if TYPE_CHECKING :
863
859
assert not isinstance (result , requests .Response )
@@ -893,7 +889,7 @@ def participants(self, **kwargs: Any) -> Dict[str, Any]:
893
889
The list of participants
894
890
"""
895
891
896
- path = f"{ self .manager .path } /{ self .get_id () } /participants"
892
+ path = f"{ self .manager .path } /{ self .encoded_id } /participants"
897
893
result = self .manager .gitlab .http_get (path , ** kwargs )
898
894
if TYPE_CHECKING :
899
895
assert not isinstance (result , requests .Response )
0 commit comments