Skip to content

Commit 4065903

Browse files
committed
Merge branch 'python-gitlab:master' into master
2 parents d2c1744 + fbbc0d4 commit 4065903

File tree

12 files changed

+220
-34
lines changed

12 files changed

+220
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ MANIFEST
99
coverage.xml
1010
docs/_build
1111
.coverage
12+
.python-version
1213
.tox
1314
.venv/
1415
venv/

docs/gl_objects/deployments.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,25 @@ Update a deployment::
3939
deployment = project.deployments.get(42)
4040
deployment.status = "failed"
4141
deployment.save()
42+
43+
Merge requests associated with a deployment
44+
===========================================
45+
46+
Reference
47+
----------
48+
49+
* v4 API:
50+
51+
+ :class:`gitlab.v4.objects.ProjectDeploymentMergeRequest`
52+
+ :class:`gitlab.v4.objects.ProjectDeploymentMergeRequestManager`
53+
+ :attr:`gitlab.v4.objects.ProjectDeployment.mergerequests`
54+
55+
* GitLab API: https://docs.gitlab.com/ee/api/deployments.html#list-of-merge-requests-associated-with-a-deployment
56+
57+
Examples
58+
--------
59+
60+
List the merge requests associated with a deployment::
61+
62+
deployment = project.deployments.get(42, lazy=True)
63+
mrs = deployment.mergerequests.list()

docs/gl_objects/issues.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,55 @@ Link issue ``i1`` to issue ``i2``::
225225
Delete a link::
226226

227227
i1.links.delete(issue_link_id)
228+
229+
Issues statistics
230+
=========================
231+
232+
Reference
233+
---------
234+
235+
* v4 API:
236+
237+
+ :class:`gitlab.v4.objects.IssuesStatistics`
238+
+ :class:`gitlab.v4.objects.IssuesStatisticsManager`
239+
+ :attr:`gitlab.issues_statistics`
240+
+ :class:`gitlab.v4.objects.GroupIssuesStatistics`
241+
+ :class:`gitlab.v4.objects.GroupIssuesStatisticsManager`
242+
+ :attr:`gitlab.v4.objects.Group.issues_statistics`
243+
+ :class:`gitlab.v4.objects.ProjectIssuesStatistics`
244+
+ :class:`gitlab.v4.objects.ProjectIssuesStatisticsManager`
245+
+ :attr:`gitlab.v4.objects.Project.issues_statistics`
246+
247+
248+
* GitLab API: https://docs.gitlab.com/ce/api/issues_statistics.htm
249+
250+
Examples
251+
---------
252+
253+
Get statistics of all issues created by the current user::
254+
255+
statistics = gl.issues_statistics.get()
256+
257+
Get statistics of all issues the user has access to::
258+
259+
statistics = gl.issues_statistics.get(scope='all')
260+
261+
Get statistics of issues for the user with ``foobar`` in the ``title`` or the ``description``::
262+
263+
statistics = gl.issues_statistics.get(search='foobar')
264+
265+
Get statistics of all issues in a group::
266+
267+
statistics = group.issues_statistics.get()
268+
269+
Get statistics of issues in a group with ``foobar`` in the ``title`` or the ``description``::
270+
271+
statistics = group.issues_statistics.get(search='foobar')
272+
273+
Get statistics of all issues in a project::
274+
275+
statistics = project.issues_statistics.get()
276+
277+
Get statistics of issues in a project with ``foobar`` in the ``title`` or the ``description``::
278+
279+
statistics = project.issues_statistics.get(search='foobar')

docs/gl_objects/projects.rst

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -768,29 +768,3 @@ Get all additional statistics of a project::
768768
Get total fetches in last 30 days of a project::
769769

770770
total_fetches = project.additionalstatistics.get().fetches['total']
771-
772-
Project issues statistics
773-
=========================
774-
775-
Reference
776-
---------
777-
778-
* v4 API:
779-
780-
+ :class:`gitlab.v4.objects.ProjectIssuesStatistics`
781-
+ :class:`gitlab.v4.objects.ProjectIssuesStatisticsManager`
782-
+ :attr:`gitlab.v4.objects.Project.issuesstatistics`
783-
784-
* GitLab API: https://docs.gitlab.com/ce/api/issues_statistics.html#get-project-issues-statistics
785-
786-
Examples
787-
---------
788-
789-
Get statistics of all issues in a project::
790-
791-
statistics = project.issuesstatistics.get()
792-
793-
Get statistics of issues in a project with ``foobar`` in ``title`` and
794-
``description``::
795-
796-
statistics = project.issuesstatistics.get(search='foobar')

gitlab/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def __init__(
118118
self.groups = objects.GroupManager(self)
119119
self.hooks = objects.HookManager(self)
120120
self.issues = objects.IssueManager(self)
121+
self.issues_statistics = objects.IssuesStatisticsManager(self)
121122
self.ldapgroups = objects.LDAPGroupManager(self)
122123
self.licenses = objects.LicenseManager(self)
123124
self.namespaces = objects.NamespaceManager(self)

gitlab/v4/objects/deployments.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
from gitlab.base import RequiredOptional, RESTManager, RESTObject
22
from gitlab.mixins import CreateMixin, RetrieveMixin, SaveMixin, UpdateMixin
33

4+
from .merge_requests import ProjectDeploymentMergeRequestManager # noqa: F401
5+
46
__all__ = [
57
"ProjectDeployment",
68
"ProjectDeploymentManager",
79
]
810

911

1012
class ProjectDeployment(SaveMixin, RESTObject):
11-
pass
13+
_managers = (("mergerequests", "ProjectDeploymentMergeRequestManager"),)
1214

1315

1416
class ProjectDeploymentManager(RetrieveMixin, CreateMixin, UpdateMixin, RESTManager):
1517
_path = "/projects/%(project_id)s/deployments"
1618
_obj_cls = ProjectDeployment
1719
_from_parent_attrs = {"project_id": "id"}
18-
_list_filters = ("order_by", "sort")
20+
_list_filters = (
21+
"order_by",
22+
"sort",
23+
"updated_after",
24+
"updated_before",
25+
"environment",
26+
"status",
27+
)
1928
_create_attrs = RequiredOptional(
2029
required=("sha", "ref", "tag", "status", "environment")
2130
)

gitlab/v4/objects/groups.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from .packages import GroupPackageManager # noqa: F401
2727
from .projects import GroupProjectManager # noqa: F401
2828
from .runners import GroupRunnerManager # noqa: F401
29+
from .statistics import GroupIssuesStatisticsManager # noqa: F401
2930
from .variables import GroupVariableManager # noqa: F401
3031
from .wikis import GroupWikiManager # noqa: F401
3132

@@ -53,6 +54,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
5354
("epics", "GroupEpicManager"),
5455
("imports", "GroupImportManager"),
5556
("issues", "GroupIssueManager"),
57+
("issues_statistics", "GroupIssuesStatisticsManager"),
5658
("labels", "GroupLabelManager"),
5759
("members", "GroupMemberManager"),
5860
("members_all", "GroupMemberAllManager"),

gitlab/v4/objects/merge_requests.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
"GroupMergeRequestManager",
3737
"ProjectMergeRequest",
3838
"ProjectMergeRequestManager",
39+
"ProjectDeploymentMergeRequest",
40+
"ProjectDeploymentMergeRequestManager",
3941
"ProjectMergeRequestDiff",
4042
"ProjectMergeRequestDiffManager",
4143
]
@@ -48,32 +50,42 @@ class MergeRequest(RESTObject):
4850
class MergeRequestManager(ListMixin, RESTManager):
4951
_path = "/merge_requests"
5052
_obj_cls = MergeRequest
51-
_from_parent_attrs = {"group_id": "id"}
5253
_list_filters = (
5354
"state",
5455
"order_by",
5556
"sort",
5657
"milestone",
5758
"view",
5859
"labels",
60+
"with_labels_details",
61+
"with_merge_status_recheck",
5962
"created_after",
6063
"created_before",
6164
"updated_after",
6265
"updated_before",
6366
"scope",
6467
"author_id",
68+
"author_username",
6569
"assignee_id",
6670
"approver_ids",
6771
"approved_by_ids",
72+
"reviewer_id",
73+
"reviewer_username",
6874
"my_reaction_emoji",
6975
"source_branch",
7076
"target_branch",
7177
"search",
78+
"in",
7279
"wip",
80+
"not",
81+
"environment",
82+
"deployed_before",
83+
"deployed_after",
7384
)
7485
_types = {
7586
"approver_ids": types.ListAttribute,
7687
"approved_by_ids": types.ListAttribute,
88+
"in": types.ListAttribute,
7789
"labels": types.ListAttribute,
7890
}
7991

@@ -409,6 +421,16 @@ class ProjectMergeRequestManager(CRUDMixin, RESTManager):
409421
}
410422

411423

424+
class ProjectDeploymentMergeRequest(MergeRequest):
425+
pass
426+
427+
428+
class ProjectDeploymentMergeRequestManager(MergeRequestManager):
429+
_path = "/projects/%(project_id)s/deployments/%(deployment_id)s/merge_requests"
430+
_obj_cls = ProjectDeploymentMergeRequest
431+
_from_parent_attrs = {"deployment_id": "id", "project_id": "project_id"}
432+
433+
412434
class ProjectMergeRequestDiff(RESTObject):
413435
pass
414436

gitlab/v4/objects/projects.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
155155
("wikis", "ProjectWikiManager"),
156156
("clusters", "ProjectClusterManager"),
157157
("additionalstatistics", "ProjectAdditionalStatisticsManager"),
158-
("issuesstatistics", "ProjectIssuesStatisticsManager"),
158+
("issues_statistics", "ProjectIssuesStatisticsManager"),
159+
("issuesstatistics", "ProjectIssuesStatisticsManager"), # Deprecated
159160
("deploytokens", "ProjectDeployTokenManager"),
160161
)
161162

gitlab/v4/objects/statistics.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
from gitlab.mixins import GetWithoutIdMixin, RefreshMixin
33

44
__all__ = [
5+
"GroupIssuesStatistics",
6+
"GroupIssuesStatisticsManager",
57
"ProjectAdditionalStatistics",
68
"ProjectAdditionalStatisticsManager",
9+
"IssuesStatistics",
10+
"IssuesStatisticsManager",
711
"ProjectIssuesStatistics",
812
"ProjectIssuesStatisticsManager",
913
]
@@ -19,6 +23,25 @@ class ProjectAdditionalStatisticsManager(GetWithoutIdMixin, RESTManager):
1923
_from_parent_attrs = {"project_id": "id"}
2024

2125

26+
class IssuesStatistics(RefreshMixin, RESTObject):
27+
_id_attr = None
28+
29+
30+
class IssuesStatisticsManager(GetWithoutIdMixin, RESTManager):
31+
_path = "/issues_statistics"
32+
_obj_cls = IssuesStatistics
33+
34+
35+
class GroupIssuesStatistics(RefreshMixin, RESTObject):
36+
_id_attr = None
37+
38+
39+
class GroupIssuesStatisticsManager(GetWithoutIdMixin, RESTManager):
40+
_path = "/groups/%(group_id)s/issues_statistics"
41+
_obj_cls = GroupIssuesStatistics
42+
_from_parent_attrs = {"group_id": "id"}
43+
44+
2245
class ProjectIssuesStatistics(RefreshMixin, RESTObject):
2346
_id_attr = None
2447

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy