summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects
diff options
context:
space:
mode:
authorNejc Habjan <nejc.habjan@siemens.com>2022-02-02 01:44:52 +0100
committerJohn Villalovos <john@sodarock.com>2022-02-03 15:43:35 -0800
commite30f39dff5726266222b0f56c94f4ccfe38ba527 (patch)
tree8b3aaf1b060928a43eada6b8015f2ba1f071ece6 /gitlab/v4/objects
parent2adf31dff04cd9b037d8727ab1b48385248bbabd (diff)
downloadgitlab-e30f39dff5726266222b0f56c94f4ccfe38ba527.tar.gz
fix(services): use slug for id_attr instead of custom methods
Diffstat (limited to 'gitlab/v4/objects')
-rw-r--r--gitlab/v4/objects/services.py52
1 files changed, 3 insertions, 49 deletions
diff --git a/gitlab/v4/objects/services.py b/gitlab/v4/objects/services.py
index 9b8e7f3..424d085 100644
--- a/gitlab/v4/objects/services.py
+++ b/gitlab/v4/objects/services.py
@@ -3,7 +3,7 @@ GitLab API:
https://docs.gitlab.com/ee/api/integrations.html
"""
-from typing import Any, cast, Dict, List, Optional, Union
+from typing import Any, cast, List, Union
from gitlab import cli
from gitlab.base import RESTManager, RESTObject
@@ -23,7 +23,7 @@ __all__ = [
class ProjectService(SaveMixin, ObjectDeleteMixin, RESTObject):
- pass
+ _id_attr = "slug"
class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTManager):
@@ -264,53 +264,7 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
) -> ProjectService:
- """Retrieve a single object.
-
- Args:
- id: ID of the object to retrieve
- lazy: If True, don't request the server, but create a
- shallow object giving access to the managers. This is
- useful if you want to avoid useless calls to the API.
- **kwargs: Extra options to send to the server (e.g. sudo)
-
- Returns:
- The generated RESTObject.
-
- Raises:
- GitlabAuthenticationError: If authentication is not correct
- GitlabGetError: If the server cannot perform the request
- """
- obj = cast(
- ProjectService,
- super().get(id, lazy=lazy, **kwargs),
- )
- obj.id = id
- return obj
-
- def update(
- self,
- id: Optional[Union[str, int]] = None,
- new_data: Optional[Dict[str, Any]] = None,
- **kwargs: Any
- ) -> Dict[str, Any]:
- """Update an object on the server.
-
- Args:
- id: ID of the object to update (can be None if not required)
- new_data: the update data for the object
- **kwargs: Extra options to send to the server (e.g. sudo)
-
- Returns:
- The new object data (*not* a RESTObject)
-
- Raises:
- GitlabAuthenticationError: If authentication is not correct
- GitlabUpdateError: If the server cannot perform the request
- """
- new_data = new_data or {}
- result = super().update(id, new_data, **kwargs)
- self.id = id
- return result
+ return cast(ProjectService, super().get(id=id, lazy=lazy, **kwargs))
@cli.register_custom_action("ProjectServiceManager")
def available(self, **kwargs: Any) -> List[str]: