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

Commita428051

Browse files
nejchJohnVillalovos
authored andcommitted
refactor: migrate services to integrations
1 parentc6dd57c commita428051

File tree

5 files changed

+79
-55
lines changed

5 files changed

+79
-55
lines changed

‎docs/gl_objects/projects.rst‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -643,56 +643,56 @@ Delete a project hook::
643643
# or
644644
hook.delete()
645645

646-
ProjectServices
647-
================
646+
ProjectIntegrations
647+
====================
648648

649649
Reference
650650
---------
651651

652652
* v4 API:
653653

654-
+:class:`gitlab.v4.objects.ProjectService`
655-
+:class:`gitlab.v4.objects.ProjectServiceManager`
656-
+:attr:`gitlab.v4.objects.Project.services`
654+
+:class:`gitlab.v4.objects.ProjectIntegration`
655+
+:class:`gitlab.v4.objects.ProjectIntegrationManager`
656+
+:attr:`gitlab.v4.objects.Project.integrations`
657657

658-
* GitLab API: https://docs.gitlab.com/ce/api/services.html
658+
* GitLab API: https://docs.gitlab.com/ce/api/integrations.html
659659

660660
Examples
661661
---------
662662

663663
..danger::
664664

665-
Since GitLab 13.12, ``get()`` calls to projectservices return a
665+
Since GitLab 13.12, ``get()`` calls to projectintegrations return a
666666
``404 Not Found`` response until they have been activated the first time.
667667

668668
To avoid this, we recommend using `lazy=True` to prevent making
669-
the initial call when activating newservices unless they have
669+
the initial call when activating newintegrations unless they have
670670
previously already been activated.
671671

672-
Configure and enablea service for the first time::
672+
Configure and enablean integration for the first time::
673673

674-
service = project.services.get('asana', lazy=True)
674+
integration = project.integrations.get('asana', lazy=True)
675675

676-
service.api_key = 'randomkey'
677-
service.save()
676+
integration.api_key = 'randomkey'
677+
integration.save()
678678

679-
Get an existingservice::
679+
Get an existingintegration::
680680

681-
service = project.services.get('asana')
681+
integration = project.integrations.get('asana')
682682
# display its status (enabled/disabled)
683-
print(service.active)
683+
print(integration.active)
684684

685-
List active projectservices::
685+
List active projectintegrations::
686686

687-
service = project.services.list()
687+
integration = project.integrations.list()
688688

689-
List the code names of availableservices (doesn't return objects)::
689+
List the code names of availableintegrations (doesn't return objects)::
690690

691-
services = project.services.available()
691+
integrations = project.integrations.available()
692692

693-
Disablea service::
693+
Disablean integration::
694694

695-
service.delete()
695+
integration.delete()
696696

697697
File uploads
698698
============

‎gitlab/v4/objects/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from .group_access_tokensimport*
4545
from .groupsimport*
4646
from .hooksimport*
47+
from .integrationsimport*
4748
from .issuesimport*
4849
from .jobsimport*
4950
from .keysimport*
@@ -67,7 +68,6 @@
6768
from .releasesimport*
6869
from .repositoriesimport*
6970
from .runnersimport*
70-
from .servicesimport*
7171
from .settingsimport*
7272
from .sidekiqimport*
7373
from .snippetsimport*

‎gitlab/v4/objects/services.py‎renamed to ‎gitlab/v4/objects/integrations.py‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,23 @@
1717
)
1818

1919
__all__= [
20+
"ProjectIntegration",
21+
"ProjectIntegrationManager",
2022
"ProjectService",
2123
"ProjectServiceManager",
2224
]
2325

2426

25-
classProjectService(SaveMixin,ObjectDeleteMixin,RESTObject):
27+
classProjectIntegration(SaveMixin,ObjectDeleteMixin,RESTObject):
2628
_id_attr="slug"
2729

2830

29-
classProjectServiceManager(GetMixin,UpdateMixin,DeleteMixin,ListMixin,RESTManager):
30-
_path="/projects/{project_id}/services"
31+
classProjectIntegrationManager(
32+
GetMixin,UpdateMixin,DeleteMixin,ListMixin,RESTManager
33+
):
34+
_path="/projects/{project_id}/integrations"
3135
_from_parent_attrs= {"project_id":"id"}
32-
_obj_cls=ProjectService
36+
_obj_cls=ProjectIntegration
3337

3438
_service_attrs= {
3539
"asana": (("api_key",), ("restrict_to_branch","push_events")),
@@ -263,14 +267,27 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM
263267

264268
defget(
265269
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
266-
)->ProjectService:
267-
returncast(ProjectService,super().get(id=id,lazy=lazy,**kwargs))
270+
)->ProjectIntegration:
271+
returncast(ProjectIntegration,super().get(id=id,lazy=lazy,**kwargs))
268272

269-
@cli.register_custom_action("ProjectServiceManager")
273+
@cli.register_custom_action(("ProjectIntegrationManager","ProjectServiceManager"))
270274
defavailable(self)->List[str]:
271275
"""List the services known by python-gitlab.
272276
273277
Returns:
274278
The list of service code names.
275279
"""
276280
returnlist(self._service_attrs.keys())
281+
282+
283+
classProjectService(ProjectIntegration):
284+
pass
285+
286+
287+
classProjectServiceManager(ProjectIntegrationManager):
288+
_obj_cls=ProjectService
289+
290+
defget(
291+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
292+
)->ProjectService:
293+
returncast(ProjectService,super().get(id=id,lazy=lazy,**kwargs))

‎gitlab/v4/objects/projects.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
from .export_importimportProjectExportManager,ProjectImportManager# noqa: F401
5555
from .filesimportProjectFileManager# noqa: F401
5656
from .hooksimportProjectHookManager# noqa: F401
57+
from .integrationsimportProjectIntegrationManager,ProjectServiceManager# noqa: F401
5758
from .issuesimportProjectIssueManager# noqa: F401
5859
from .jobsimportProjectJobManager# noqa: F401
5960
from .labelsimportProjectLabelManager# noqa: F401
@@ -79,7 +80,6 @@
7980
from .releasesimportProjectReleaseManager# noqa: F401
8081
from .repositoriesimportRepositoryMixin
8182
from .runnersimportProjectRunnerManager# noqa: F401
82-
from .servicesimportProjectServiceManager# noqa: F401
8383
from .snippetsimportProjectSnippetManager# noqa: F401
8484
from .statisticsimport (# noqa: F401
8585
ProjectAdditionalStatisticsManager,
@@ -178,6 +178,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
178178
groups:ProjectGroupManager
179179
hooks:ProjectHookManager
180180
imports:ProjectImportManager
181+
integrations:ProjectIntegrationManager
181182
issues:ProjectIssueManager
182183
issues_statistics:ProjectIssuesStatisticsManager
183184
jobs:ProjectJobManager
Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
"""
2-
GitLab API: https://docs.gitlab.com/ce/api/services.html
2+
GitLab API: https://docs.gitlab.com/ce/api/integrations.html
33
"""
44

55
importpytest
66
importresponses
77

8-
fromgitlab.v4.objectsimportProjectService
8+
fromgitlab.v4.objectsimportProjectIntegration,ProjectService
99

1010

1111
@pytest.fixture
12-
defresp_service():
12+
defresp_integration():
1313
content= {
1414
"id":100152,
1515
"title":"Pipelines emails",
@@ -35,21 +35,21 @@ def resp_service():
3535
withresponses.RequestsMock(assert_all_requests_are_fired=False)asrsps:
3636
rsps.add(
3737
method=responses.GET,
38-
url="http://localhost/api/v4/projects/1/services",
38+
url="http://localhost/api/v4/projects/1/integrations",
3939
json=[content],
4040
content_type="application/json",
4141
status=200,
4242
)
4343
rsps.add(
4444
method=responses.GET,
45-
url="http://localhost/api/v4/projects/1/services",
45+
url="http://localhost/api/v4/projects/1/integrations",
4646
json=content,
4747
content_type="application/json",
4848
status=200,
4949
)
5050
rsps.add(
5151
method=responses.GET,
52-
url="http://localhost/api/v4/projects/1/services/pipelines-email",
52+
url="http://localhost/api/v4/projects/1/integrations/pipelines-email",
5353
json=content,
5454
content_type="application/json",
5555
status=200,
@@ -58,36 +58,42 @@ def resp_service():
5858
updated_content["issues_events"]=False
5959
rsps.add(
6060
method=responses.PUT,
61-
url="http://localhost/api/v4/projects/1/services/pipelines-email",
61+
url="http://localhost/api/v4/projects/1/integrations/pipelines-email",
6262
json=updated_content,
6363
content_type="application/json",
6464
status=200,
6565
)
6666
yieldrsps
6767

6868

69-
deftest_list_active_services(project,resp_service):
70-
services=project.services.list()
71-
assertisinstance(services,list)
72-
assertisinstance(services[0],ProjectService)
73-
assertservices[0].active
74-
assertservices[0].push_events
69+
deftest_list_active_integrations(project,resp_integration):
70+
integrations=project.integrations.list()
71+
assertisinstance(integrations,list)
72+
assertisinstance(integrations[0],ProjectIntegration)
73+
assertintegrations[0].active
74+
assertintegrations[0].push_events
7575

7676

77-
deftest_list_available_services(project,resp_service):
78-
services=project.services.available()
79-
assertisinstance(services,list)
80-
assertisinstance(services[0],str)
77+
deftest_list_available_integrations(project,resp_integration):
78+
integrations=project.integrations.available()
79+
assertisinstance(integrations,list)
80+
assertisinstance(integrations[0],str)
8181

8282

83-
deftest_get_service(project,resp_service):
84-
service=project.services.get("pipelines-email")
85-
assertisinstance(service,ProjectService)
86-
assertservice.push_eventsisTrue
83+
deftest_get_integration(project,resp_integration):
84+
integration=project.integrations.get("pipelines-email")
85+
assertisinstance(integration,ProjectIntegration)
86+
assertintegration.push_eventsisTrue
87+
8788

89+
deftest_update_integration(project,resp_integration):
90+
integration=project.integrations.get("pipelines-email")
91+
integration.issues_events=False
92+
integration.save()
93+
assertintegration.issues_eventsisFalse
8894

89-
deftest_update_service(project,resp_service):
95+
96+
deftest_get_service_returns_service(project,resp_integration):
97+
# todo: remove when services are removed
9098
service=project.services.get("pipelines-email")
91-
service.issues_events=False
92-
service.save()
93-
assertservice.issues_eventsisFalse
99+
assertisinstance(service,ProjectService)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp