@@ -99,8 +99,8 @@ 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
+ if isinstance (id , str ):
103
+ id = utils .EncodedId (id )
104
104
path = f"{ self .path } /{ id } "
105
105
if TYPE_CHECKING :
106
106
assert self ._obj_cls is not None
@@ -173,7 +173,7 @@ def refresh(self, **kwargs: Any) -> None:
173
173
GitlabGetError: If the server cannot perform the request
174
174
"""
175
175
if self ._id_attr :
176
- path = f"{ self .manager .path } /{ self .id } "
176
+ path = f"{ self .manager .path } /{ self .encoded_id } "
177
177
else :
178
178
if TYPE_CHECKING :
179
179
assert self .manager .path is not None
@@ -391,7 +391,7 @@ def update(
391
391
if id is None :
392
392
path = self .path
393
393
else :
394
- path = f"{ self .path } /{ id } "
394
+ path = f"{ self .path } /{ utils . EncodedId ( id ) } "
395
395
396
396
self ._check_missing_update_attrs (new_data )
397
397
files = {}
@@ -444,7 +444,7 @@ def set(self, key: str, value: str, **kwargs: Any) -> base.RESTObject:
444
444
Returns:
445
445
The created/updated attribute
446
446
"""
447
- path = f"{ self .path } /{ utils ._url_encode (key )} "
447
+ path = f"{ self .path } /{ utils .EncodedId (key )} "
448
448
data = {"value" : value }
449
449
server_data = self .gitlab .http_put (path , post_data = data , ** kwargs )
450
450
if TYPE_CHECKING :
@@ -477,9 +477,7 @@ def delete(self, id: Union[str, int], **kwargs: Any) -> None:
477
477
if id is None :
478
478
path = self .path
479
479
else :
480
- if not isinstance (id , int ):
481
- id = utils ._url_encode (id )
482
- path = f"{ self .path } /{ id } "
480
+ path = f"{ self .path } /{ utils .EncodedId (id )} "
483
481
self .gitlab .http_delete (path , ** kwargs )
484
482
485
483
@@ -545,7 +543,7 @@ def save(self, **kwargs: Any) -> None:
545
543
return
546
544
547
545
# call the manager
548
- obj_id = self .get_id ()
546
+ obj_id = self .encoded_id
549
547
if TYPE_CHECKING :
550
548
assert isinstance (self .manager , UpdateMixin )
551
549
server_data = self .manager .update (obj_id , updated_data , ** kwargs )
@@ -575,7 +573,7 @@ def delete(self, **kwargs: Any) -> None:
575
573
"""
576
574
if TYPE_CHECKING :
577
575
assert isinstance (self .manager , DeleteMixin )
578
- self .manager .delete (self .get_id () , ** kwargs )
576
+ self .manager .delete (self .encoded_id , ** kwargs )
579
577
580
578
581
579
class UserAgentDetailMixin (_RestObjectBase ):
@@ -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