Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite30f39d

Browse files
nejchJohnVillalovos
authored andcommitted
fix(services): use slug for id_attr instead of custom methods
1 parent2adf31d commite30f39d

File tree

1 file changed

+3
-49
lines changed

1 file changed

+3
-49
lines changed

‎gitlab/v4/objects/services.py

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
https://docs.gitlab.com/ee/api/integrations.html
44
"""
55

6-
fromtypingimportAny,cast,Dict,List,Optional,Union
6+
fromtypingimportAny,cast,List,Union
77

88
fromgitlabimportcli
99
fromgitlab.baseimportRESTManager,RESTObject
@@ -23,7 +23,7 @@
2323

2424

2525
classProjectService(SaveMixin,ObjectDeleteMixin,RESTObject):
26-
pass
26+
_id_attr="slug"
2727

2828

2929
classProjectServiceManager(GetMixin,UpdateMixin,DeleteMixin,ListMixin,RESTManager):
@@ -264,53 +264,7 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM
264264
defget(
265265
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
266266
)->ProjectService:
267-
"""Retrieve a single object.
268-
269-
Args:
270-
id: ID of the object to retrieve
271-
lazy: If True, don't request the server, but create a
272-
shallow object giving access to the managers. This is
273-
useful if you want to avoid useless calls to the API.
274-
**kwargs: Extra options to send to the server (e.g. sudo)
275-
276-
Returns:
277-
The generated RESTObject.
278-
279-
Raises:
280-
GitlabAuthenticationError: If authentication is not correct
281-
GitlabGetError: If the server cannot perform the request
282-
"""
283-
obj=cast(
284-
ProjectService,
285-
super().get(id,lazy=lazy,**kwargs),
286-
)
287-
obj.id=id
288-
returnobj
289-
290-
defupdate(
291-
self,
292-
id:Optional[Union[str,int]]=None,
293-
new_data:Optional[Dict[str,Any]]=None,
294-
**kwargs:Any
295-
)->Dict[str,Any]:
296-
"""Update an object on the server.
297-
298-
Args:
299-
id: ID of the object to update (can be None if not required)
300-
new_data: the update data for the object
301-
**kwargs: Extra options to send to the server (e.g. sudo)
302-
303-
Returns:
304-
The new object data (*not* a RESTObject)
305-
306-
Raises:
307-
GitlabAuthenticationError: If authentication is not correct
308-
GitlabUpdateError: If the server cannot perform the request
309-
"""
310-
new_data=new_dataor {}
311-
result=super().update(id,new_data,**kwargs)
312-
self.id=id
313-
returnresult
267+
returncast(ProjectService,super().get(id=id,lazy=lazy,**kwargs))
314268

315269
@cli.register_custom_action("ProjectServiceManager")
316270
defavailable(self,**kwargs:Any)->List[str]:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp