| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c6dd57c commit a428051
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -643,56 +643,56 @@ Delete a project hook:: | |||
| 643 | 643 | # or | |
| 644 | 644 | hook.delete() | |
| 645 | 645 | ||
| 646 | - Project Services | ||
| 647 | - ================ | ||
| 646 | + Project Integrations | ||
| 647 | + ==================== | ||
| 648 | 648 | ||
| 649 | 649 | Reference | |
| 650 | 650 | --------- | |
| 651 | 651 | ||
| 652 | 652 | * v4 API: | |
| 653 | 653 | ||
| 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` | ||
| 657 | 657 | ||
| 658 | - * GitLab API: https://docs.gitlab.com/ce/api/services.html | ||
| 658 | + * GitLab API: https://docs.gitlab.com/ce/api/integrations.html | ||
| 659 | 659 | ||
| 660 | 660 | Examples | |
| 661 | 661 | --------- | |
| 662 | 662 | ||
| 663 | 663 | .. danger:: | |
| 664 | 664 | ||
| 665 | - Since GitLab 13.12, ``get()`` calls to project services return a | ||
| 665 | + Since GitLab 13.12, ``get()`` calls to project integrations return a | ||
| 666 | 666 | ``404 Not Found`` response until they have been activated the first time. | |
| 667 | 667 | ||
| 668 | 668 | To avoid this, we recommend using `lazy=True` to prevent making | |
| 669 | - the initial call when activating new services unless they have | ||
| 669 | + the initial call when activating new integrations unless they have | ||
| 670 | 670 | previously already been activated. | |
| 671 | 671 | ||
| 672 | - Configure and enable a service for the first time:: | ||
| 672 | + Configure and enable an integration for the first time:: | ||
| 673 | 673 | ||
| 674 | - service = project.services.get('asana', lazy=True) | ||
| 674 | + integration = project.integrations.get('asana', lazy=True) | ||
| 675 | 675 | ||
| 676 | - service.api_key = 'randomkey' | ||
| 677 | - service.save() | ||
| 676 | + integration.api_key = 'randomkey' | ||
| 677 | + integration.save() | ||
| 678 | 678 | ||
| 679 | - Get an existing service:: | ||
| 679 | + Get an existing integration:: | ||
| 680 | 680 | ||
| 681 | - service = project.services.get('asana') | ||
| 681 | + integration = project.integrations.get('asana') | ||
| 682 | 682 | # display its status (enabled/disabled) | |
| 683 | - print(service.active) | ||
| 683 | + print(integration.active) | ||
| 684 | 684 | ||
| 685 | - List active project services:: | ||
| 685 | + List active project integrations:: | ||
| 686 | 686 | ||
| 687 | - service = project.services.list() | ||
| 687 | + integration = project.integrations.list() | ||
| 688 | 688 | ||
| 689 | - List the code names of available services (doesn't return objects):: | ||
| 689 | + List the code names of available integrations (doesn't return objects):: | ||
| 690 | 690 | ||
| 691 | - services = project.services.available() | ||
| 691 | + integrations = project.integrations.available() | ||
| 692 | 692 | ||
| 693 | - Disable a service:: | ||
| 693 | + Disable an integration:: | ||
| 694 | 694 | ||
| 695 | - service.delete() | ||
| 695 | + integration.delete() | ||
| 696 | 696 | ||
| 697 | 697 | File uploads | |
| 698 | 698 | ============ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,6 +44,7 @@ | |||
| 44 | 44 | from .group_access_tokens import * | |
| 45 | 45 | from .groups import * | |
| 46 | 46 | from .hooks import * | |
| 47 | + from .integrations import * | ||
| 47 | 48 | from .issues import * | |
| 48 | 49 | from .jobs import * | |
| 49 | 50 | from .keys import * | |
@@ -67,7 +68,6 @@ | |||
| 67 | 68 | from .releases import * | |
| 68 | 69 | from .repositories import * | |
| 69 | 70 | from .runners import * | |
| 70 | - from .services import * | ||
| 71 | 71 | from .settings import * | |
| 72 | 72 | from .sidekiq import * | |
| 73 | 73 | from .snippets import * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,19 +17,23 @@ | |||
| 17 | 17 | ) | |
| 18 | 18 | ||
| 19 | 19 | __all__ = [ | |
| 20 | + "ProjectIntegration", | ||
| 21 | + "ProjectIntegrationManager", | ||
| 20 | 22 | "ProjectService", | |
| 21 | 23 | "ProjectServiceManager", | |
| 22 | 24 | ] | |
| 23 | 25 | ||
| 24 | 26 | ||
| 25 | - class ProjectService(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 27 | + class ProjectIntegration(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 26 | 28 | _id_attr = "slug" | |
| 27 | 29 | ||
| 28 | 30 | ||
| 29 | - class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTManager): | ||
| 30 | - _path = "/projects/{project_id}/services" | ||
| 31 | + class ProjectIntegrationManager( | ||
| 32 | + GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTManager | ||
| 33 | + ): | ||
| 34 | + _path = "/projects/{project_id}/integrations" | ||
| 31 | 35 | _from_parent_attrs = {"project_id": "id"} | |
| 32 | - _obj_cls = ProjectService | ||
| 36 | + _obj_cls = ProjectIntegration | ||
| 33 | 37 | ||
| 34 | 38 | _service_attrs = { | |
| 35 | 39 | "asana": (("api_key",), ("restrict_to_branch", "push_events")), | |
@@ -263,14 +267,27 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM | |||
| 263 | 267 | ||
| 264 | 268 | def get( | |
| 265 | 269 | self, id: Union[str, int], lazy: bool = False, **kwargs: Any | |
| 266 | - ) -> ProjectService: | ||
| 267 | - return cast(ProjectService, super().get(id=id, lazy=lazy, **kwargs)) | ||
| 270 | + ) -> ProjectIntegration: | ||
| 271 | + return cast(ProjectIntegration, super().get(id=id, lazy=lazy, **kwargs)) | ||
| 268 | 272 | ||
| 269 | - @cli.register_custom_action("ProjectServiceManager") | ||
| 273 | + @cli.register_custom_action(("ProjectIntegrationManager", "ProjectServiceManager")) | ||
| 270 | 274 | def available(self) -> List[str]: | |
| 271 | 275 | """List the services known by python-gitlab. | |
| 272 | 276 | ||
| 273 | 277 | Returns: | |
| 274 | 278 | The list of service code names. | |
| 275 | 279 | """ | |
| 276 | 280 | return list(self._service_attrs.keys()) | |
| 281 | + | ||
| 282 | + | ||
| 283 | + class ProjectService(ProjectIntegration): | ||
| 284 | + pass | ||
| 285 | + | ||
| 286 | + | ||
| 287 | + class ProjectServiceManager(ProjectIntegrationManager): | ||
| 288 | + _obj_cls = ProjectService | ||
| 289 | + | ||
| 290 | + def get( | ||
| 291 | + self, id: Union[str, int], lazy: bool = False, **kwargs: Any | ||
| 292 | + ) -> ProjectService: | ||
| 293 | + return cast(ProjectService, super().get(id=id, lazy=lazy, **kwargs)) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,6 +54,7 @@ | |||
| 54 | 54 | from .export_import import ProjectExportManager, ProjectImportManager # noqa: F401 | |
| 55 | 55 | from .files import ProjectFileManager # noqa: F401 | |
| 56 | 56 | from .hooks import ProjectHookManager # noqa: F401 | |
| 57 | + from .integrations import ProjectIntegrationManager, ProjectServiceManager # noqa: F401 | ||
| 57 | 58 | from .issues import ProjectIssueManager # noqa: F401 | |
| 58 | 59 | from .jobs import ProjectJobManager # noqa: F401 | |
| 59 | 60 | from .labels import ProjectLabelManager # noqa: F401 | |
@@ -79,7 +80,6 @@ | |||
| 79 | 80 | from .releases import ProjectReleaseManager # noqa: F401 | |
| 80 | 81 | from .repositories import RepositoryMixin | |
| 81 | 82 | from .runners import ProjectRunnerManager # noqa: F401 | |
| 82 | - from .services import ProjectServiceManager # noqa: F401 | ||
| 83 | 83 | from .snippets import ProjectSnippetManager # noqa: F401 | |
| 84 | 84 | from .statistics import ( # noqa: F401 | |
| 85 | 85 | ProjectAdditionalStatisticsManager, | |
@@ -178,6 +178,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO | |||
| 178 | 178 | groups: ProjectGroupManager | |
| 179 | 179 | hooks: ProjectHookManager | |
| 180 | 180 | imports: ProjectImportManager | |
| 181 | + integrations: ProjectIntegrationManager | ||
| 181 | 182 | issues: ProjectIssueManager | |
| 182 | 183 | issues_statistics: ProjectIssuesStatisticsManager | |
| 183 | 184 | jobs: ProjectJobManager | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,15 +1,15 @@ | |||
| 1 | 1 | """ | |
| 2 | - GitLab API: https://docs.gitlab.com/ce/api/services.html | ||
| 2 | + GitLab API: https://docs.gitlab.com/ce/api/integrations.html | ||
| 3 | 3 | """ | |
| 4 | 4 | ||
| 5 | 5 | import pytest | |
| 6 | 6 | import responses | |
| 7 | 7 | ||
| 8 | - from gitlab.v4.objects import ProjectService | ||
| 8 | + from gitlab.v4.objects import ProjectIntegration, ProjectService | ||
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | 11 | @pytest.fixture | |
| 12 | - def resp_service(): | ||
| 12 | + def resp_integration(): | ||
| 13 | 13 | content = { | |
| 14 | 14 | "id": 100152, | |
| 15 | 15 | "title": "Pipelines emails", | |
@@ -35,21 +35,21 @@ def resp_service(): | |||
| 35 | 35 | with responses.RequestsMock(assert_all_requests_are_fired=False) as rsps: | |
| 36 | 36 | rsps.add( | |
| 37 | 37 | method=responses.GET, | |
| 38 | - url="http://localhost/api/v4/projects/1/services", | ||
| 38 | + url="http://localhost/api/v4/projects/1/integrations", | ||
| 39 | 39 | json=[content], | |
| 40 | 40 | content_type="application/json", | |
| 41 | 41 | status=200, | |
| 42 | 42 | ) | |
| 43 | 43 | rsps.add( | |
| 44 | 44 | method=responses.GET, | |
| 45 | - url="http://localhost/api/v4/projects/1/services", | ||
| 45 | + url="http://localhost/api/v4/projects/1/integrations", | ||
| 46 | 46 | json=content, | |
| 47 | 47 | content_type="application/json", | |
| 48 | 48 | status=200, | |
| 49 | 49 | ) | |
| 50 | 50 | rsps.add( | |
| 51 | 51 | 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", | ||
| 53 | 53 | json=content, | |
| 54 | 54 | content_type="application/json", | |
| 55 | 55 | status=200, | |
@@ -58,36 +58,42 @@ def resp_service(): | |||
| 58 | 58 | updated_content["issues_events"] = False | |
| 59 | 59 | rsps.add( | |
| 60 | 60 | 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", | ||
| 62 | 62 | json=updated_content, | |
| 63 | 63 | content_type="application/json", | |
| 64 | 64 | status=200, | |
| 65 | 65 | ) | |
| 66 | 66 | yield rsps | |
| 67 | 67 | ||
| 68 | 68 | ||
| 69 | - def test_list_active_services(project, resp_service): | ||
| 70 | - services = project.services.list() | ||
| 71 | - assert isinstance(services, list) | ||
| 72 | - assert isinstance(services[0], ProjectService) | ||
| 73 | - assert services[0].active | ||
| 74 | - assert services[0].push_events | ||
| 69 | + def test_list_active_integrations(project, resp_integration): | ||
| 70 | + integrations = project.integrations.list() | ||
| 71 | + assert isinstance(integrations, list) | ||
| 72 | + assert isinstance(integrations[0], ProjectIntegration) | ||
| 73 | + assert integrations[0].active | ||
| 74 | + assert integrations[0].push_events | ||
| 75 | 75 | ||
| 76 | 76 | ||
| 77 | - def test_list_available_services(project, resp_service): | ||
| 78 | - services = project.services.available() | ||
| 79 | - assert isinstance(services, list) | ||
| 80 | - assert isinstance(services[0], str) | ||
| 77 | + def test_list_available_integrations(project, resp_integration): | ||
| 78 | + integrations = project.integrations.available() | ||
| 79 | + assert isinstance(integrations, list) | ||
| 80 | + assert isinstance(integrations[0], str) | ||
| 81 | 81 | ||
| 82 | 82 | ||
| 83 | - def test_get_service(project, resp_service): | ||
| 84 | - service = project.services.get("pipelines-email") | ||
| 85 | - assert isinstance(service, ProjectService) | ||
| 86 | - assert service.push_events is True | ||
| 83 | + def test_get_integration(project, resp_integration): | ||
| 84 | + integration = project.integrations.get("pipelines-email") | ||
| 85 | + assert isinstance(integration, ProjectIntegration) | ||
| 86 | + assert integration.push_events is True | ||
| 87 | + | ||
| 87 | 88 | ||
| 89 | + def test_update_integration(project, resp_integration): | ||
| 90 | + integration = project.integrations.get("pipelines-email") | ||
| 91 | + integration.issues_events = False | ||
| 92 | + integration.save() | ||
| 93 | + assert integration.issues_events is False | ||
| 88 | 94 | ||
| 89 | - def test_update_service(project, resp_service): | ||
| 95 | + | ||
| 96 | + def test_get_service_returns_service(project, resp_integration): | ||
| 97 | + # todo: remove when services are removed | ||
| 90 | 98 | service = project.services.get("pipelines-email") | |
| 91 | - service.issues_events = False | ||
| 92 | - service.save() | ||
| 93 | - assert service.issues_events is False | ||
| 99 | + assert isinstance(service, ProjectService) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments