FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-gitlab/gitlab/v4/objects.py at docs/commit-message · saifjunaid/python-gitlab · GitHub
python-gitlab/gitlab/v4/objects.py at docs/commit-message · saifjunaid/python-gitlab · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
saifjunaid
python-gitlab
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-gitlab
/
gitlab
/
v4
/
objects.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
3994 lines (3113 loc) · 147 KB
Breadcrumbs
python-gitlab
/
gitlab
/
v4
/
objects.py
Copy path
File metadata and controls
3994 lines (3113 loc) · 147 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
#
# Copyright (C) 2013-2017 Gauvain Pocentek <gauvain@pocentek.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
__future__
import
print_function
from
__future__
import
absolute_import
import
base64
from
gitlab
.
base
import
*
# noqa
from
gitlab
import
cli
from
gitlab
.
exceptions
import
*
# noqa
from
gitlab
.
mixins
import
*
# noqa
from
gitlab
import
types
from
gitlab
import
utils
VISIBILITY_PRIVATE
=
'private'
VISIBILITY_INTERNAL
=
'internal'
VISIBILITY_PUBLIC
=
'public'
ACCESS_GUEST
=
10
ACCESS_REPORTER
=
20
ACCESS_DEVELOPER
=
30
ACCESS_MASTER
=
40
ACCESS_OWNER
=
50
class
SidekiqManager
(
RESTManager
):
"""Manager for the Sidekiq methods.
This manager doesn't actually manage objects but provides helper fonction
for the sidekiq metrics API.
"""
@
cli
.
register_custom_action
(
'SidekiqManager'
)
@
exc
.
on_http_error
(
exc
.
GitlabGetError
)
def
queue_metrics
(
self
,
**
kwargs
):
"""Return the registred queues information.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabGetError: If the information couldn't be retrieved
Returns:
dict: Information about the Sidekiq queues
"""
return
self
.
gitlab
.
http_get
(
'/sidekiq/queue_metrics'
,
**
kwargs
)
@
cli
.
register_custom_action
(
'SidekiqManager'
)
@
exc
.
on_http_error
(
exc
.
GitlabGetError
)
def
process_metrics
(
self
,
**
kwargs
):
"""Return the registred sidekiq workers.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabGetError: If the information couldn't be retrieved
Returns:
dict: Information about the register Sidekiq worker
"""
return
self
.
gitlab
.
http_get
(
'/sidekiq/process_metrics'
,
**
kwargs
)
@
cli
.
register_custom_action
(
'SidekiqManager'
)
@
exc
.
on_http_error
(
exc
.
GitlabGetError
)
def
job_stats
(
self
,
**
kwargs
):
"""Return statistics about the jobs performed.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabGetError: If the information couldn't be retrieved
Returns:
dict: Statistics about the Sidekiq jobs performed
"""
return
self
.
gitlab
.
http_get
(
'/sidekiq/job_stats'
,
**
kwargs
)
@
cli
.
register_custom_action
(
'SidekiqManager'
)
@
exc
.
on_http_error
(
exc
.
GitlabGetError
)
def
compound_metrics
(
self
,
**
kwargs
):
"""Return all available metrics and statistics.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabGetError: If the information couldn't be retrieved
Returns:
dict: All available Sidekiq metrics and statistics
"""
return
self
.
gitlab
.
http_get
(
'/sidekiq/compound_metrics'
,
**
kwargs
)
class
Event
(
RESTObject
):
_id_attr
=
None
_short_print_attr
=
'target_title'
class
EventManager
(
ListMixin
,
RESTManager
):
_path
=
'/events'
_obj_cls
=
Event
_list_filters
=
(
'action'
,
'target_type'
,
'before'
,
'after'
,
'sort'
)
class
UserActivities
(
RESTObject
):
_id_attr
=
'username'
class
UserActivitiesManager
(
ListMixin
,
RESTManager
):
_path
=
'/user/activities'
_obj_cls
=
UserActivities
class
UserCustomAttribute
(
ObjectDeleteMixin
,
RESTObject
):
_id_attr
=
'key'
class
UserCustomAttributeManager
(
RetrieveMixin
,
SetMixin
,
DeleteMixin
,
RESTManager
):
_path
=
'/users/%(user_id)s/custom_attributes'
_obj_cls
=
UserCustomAttribute
_from_parent_attrs
=
{
'user_id'
:
'id'
}
class
UserEmail
(
ObjectDeleteMixin
,
RESTObject
):
_short_print_attr
=
'email'
class
UserEmailManager
(
RetrieveMixin
,
CreateMixin
,
DeleteMixin
,
RESTManager
):
_path
=
'/users/%(user_id)s/emails'
_obj_cls
=
UserEmail
_from_parent_attrs
=
{
'user_id'
:
'id'
}
_create_attrs
=
((
'email'
, ),
tuple
())
class
UserEvent
(
Event
):
pass
class
UserEventManager
(
EventManager
):
_path
=
'/users/%(user_id)s/events'
_obj_cls
=
UserEvent
_from_parent_attrs
=
{
'user_id'
:
'id'
}
class
UserGPGKey
(
ObjectDeleteMixin
,
RESTObject
):
pass
class
UserGPGKeyManager
(
RetrieveMixin
,
CreateMixin
,
DeleteMixin
,
RESTManager
):
_path
=
'/users/%(user_id)s/gpg_keys'
_obj_cls
=
UserGPGKey
_from_parent_attrs
=
{
'user_id'
:
'id'
}
_create_attrs
=
((
'key'
,),
tuple
())
class
UserKey
(
ObjectDeleteMixin
,
RESTObject
):
pass
class
UserKeyManager
(
ListMixin
,
CreateMixin
,
DeleteMixin
,
RESTManager
):
_path
=
'/users/%(user_id)s/keys'
_obj_cls
=
UserKey
_from_parent_attrs
=
{
'user_id'
:
'id'
}
_create_attrs
=
((
'title'
,
'key'
),
tuple
())
class
UserImpersonationToken
(
ObjectDeleteMixin
,
RESTObject
):
pass
class
UserImpersonationTokenManager
(
NoUpdateMixin
,
RESTManager
):
_path
=
'/users/%(user_id)s/impersonation_tokens'
_obj_cls
=
UserImpersonationToken
_from_parent_attrs
=
{
'user_id'
:
'id'
}
_create_attrs
=
((
'name'
,
'scopes'
), (
'expires_at'
,))
_list_filters
=
(
'state'
,)
class
UserProject
(
RESTObject
):
pass
class
UserProjectManager
(
ListMixin
,
CreateMixin
,
RESTManager
):
_path
=
'/projects/user/%(user_id)s'
_obj_cls
=
UserProject
_from_parent_attrs
=
{
'user_id'
:
'id'
}
_create_attrs
=
(
(
'name'
, ),
(
'default_branch'
,
'issues_enabled'
,
'wall_enabled'
,
'merge_requests_enabled'
,
'wiki_enabled'
,
'snippets_enabled'
,
'public'
,
'visibility'
,
'description'
,
'builds_enabled'
,
'public_builds'
,
'import_url'
,
'only_allow_merge_if_build_succeeds'
)
)
_list_filters
=
(
'archived'
,
'visibility'
,
'order_by'
,
'sort'
,
'search'
,
'simple'
,
'owned'
,
'membership'
,
'starred'
,
'statistics'
,
'with_issues_enabled'
,
'with_merge_requests_enabled'
)
def
list
(
self
,
**
kwargs
):
"""Retrieve a list of objects.
Args:
all (bool): If True, return all the items, without pagination
per_page (int): Number of items to retrieve per request
page (int): ID of the page to return (starts with page 1)
as_list (bool): If set to False and no pagination option is
defined, return a generator instead of a list
**kwargs: Extra options to send to the server (e.g. sudo)
Returns:
list: The list of objects, or a generator if `as_list` is False
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabListError: If the server cannot perform the request
"""
path
=
'/users/%s/projects'
%
self
.
_parent
.
id
return
ListMixin
.
list
(
self
,
path
=
path
,
**
kwargs
)
class
User
(
SaveMixin
,
ObjectDeleteMixin
,
RESTObject
):
_short_print_attr
=
'username'
_managers
=
(
(
'customattributes'
,
'UserCustomAttributeManager'
),
(
'emails'
,
'UserEmailManager'
),
(
'events'
,
'UserEventManager'
),
(
'gpgkeys'
,
'UserGPGKeyManager'
),
(
'impersonationtokens'
,
'UserImpersonationTokenManager'
),
(
'keys'
,
'UserKeyManager'
),
(
'projects'
,
'UserProjectManager'
),
)
@
cli
.
register_custom_action
(
'User'
)
@
exc
.
on_http_error
(
exc
.
GitlabBlockError
)
def
block
(
self
,
**
kwargs
):
"""Block the user.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabBlockError: If the user could not be blocked
Returns:
bool: Whether the user status has been changed
"""
path
=
'/users/%s/block'
%
self
.
id
server_data
=
self
.
manager
.
gitlab
.
http_post
(
path
,
**
kwargs
)
if
server_data
is
True
:
self
.
_attrs
[
'state'
]
=
'blocked'
return
server_data
@
cli
.
register_custom_action
(
'User'
)
@
exc
.
on_http_error
(
exc
.
GitlabUnblockError
)
def
unblock
(
self
,
**
kwargs
):
"""Unblock the user.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabUnblockError: If the user could not be unblocked
Returns:
bool: Whether the user status has been changed
"""
path
=
'/users/%s/unblock'
%
self
.
id
server_data
=
self
.
manager
.
gitlab
.
http_post
(
path
,
**
kwargs
)
if
server_data
is
True
:
self
.
_attrs
[
'state'
]
=
'active'
return
server_data
class
UserManager
(
CRUDMixin
,
RESTManager
):
_path
=
'/users'
_obj_cls
=
User
_list_filters
=
(
'active'
,
'blocked'
,
'username'
,
'extern_uid'
,
'provider'
,
'external'
,
'search'
,
'custom_attributes'
)
_create_attrs
=
(
tuple
(),
(
'email'
,
'username'
,
'name'
,
'password'
,
'reset_password'
,
'skype'
,
'linkedin'
,
'twitter'
,
'projects_limit'
,
'extern_uid'
,
'provider'
,
'bio'
,
'admin'
,
'can_create_group'
,
'website_url'
,
'skip_confirmation'
,
'external'
,
'organization'
,
'location'
,
'avatar'
)
)
_update_attrs
=
(
(
'email'
,
'username'
,
'name'
),
(
'password'
,
'skype'
,
'linkedin'
,
'twitter'
,
'projects_limit'
,
'extern_uid'
,
'provider'
,
'bio'
,
'admin'
,
'can_create_group'
,
'website_url'
,
'skip_confirmation'
,
'external'
,
'organization'
,
'location'
,
'avatar'
)
)
_types
=
{
'confirm'
:
types
.
LowercaseStringAttribute
,
'avatar'
:
types
.
ImageAttribute
,
}
class
CurrentUserEmail
(
ObjectDeleteMixin
,
RESTObject
):
_short_print_attr
=
'email'
class
CurrentUserEmailManager
(
RetrieveMixin
,
CreateMixin
,
DeleteMixin
,
RESTManager
):
_path
=
'/user/emails'
_obj_cls
=
CurrentUserEmail
_create_attrs
=
((
'email'
, ),
tuple
())
class
CurrentUserGPGKey
(
ObjectDeleteMixin
,
RESTObject
):
pass
class
CurrentUserGPGKeyManager
(
RetrieveMixin
,
CreateMixin
,
DeleteMixin
,
RESTManager
):
_path
=
'/user/gpg_keys'
_obj_cls
=
CurrentUserGPGKey
_create_attrs
=
((
'key'
,),
tuple
())
class
CurrentUserKey
(
ObjectDeleteMixin
,
RESTObject
):
_short_print_attr
=
'title'
class
CurrentUserKeyManager
(
RetrieveMixin
,
CreateMixin
,
DeleteMixin
,
RESTManager
):
_path
=
'/user/keys'
_obj_cls
=
CurrentUserKey
_create_attrs
=
((
'title'
,
'key'
),
tuple
())
class
CurrentUser
(
RESTObject
):
_id_attr
=
None
_short_print_attr
=
'username'
_managers
=
(
(
'emails'
,
'CurrentUserEmailManager'
),
(
'gpgkeys'
,
'CurrentUserGPGKeyManager'
),
(
'keys'
,
'CurrentUserKeyManager'
),
)
class
CurrentUserManager
(
GetWithoutIdMixin
,
RESTManager
):
_path
=
'/user'
_obj_cls
=
CurrentUser
class
ApplicationSettings
(
SaveMixin
,
RESTObject
):
_id_attr
=
None
class
ApplicationSettingsManager
(
GetWithoutIdMixin
,
UpdateMixin
,
RESTManager
):
_path
=
'/application/settings'
_obj_cls
=
ApplicationSettings
_update_attrs
=
(
tuple
(),
(
'admin_notification_email'
,
'after_sign_out_path'
,
'after_sign_up_text'
,
'akismet_api_key'
,
'akismet_enabled'
,
'circuitbreaker_access_retries'
,
'circuitbreaker_check_interval'
,
'circuitbreaker_failure_count_threshold'
,
'circuitbreaker_failure_reset_time'
,
'circuitbreaker_storage_timeout'
,
'clientside_sentry_dsn'
,
'clientside_sentry_enabled'
,
'container_registry_token_expire_delay'
,
'default_artifacts_expire_in'
,
'default_branch_protection'
,
'default_group_visibility'
,
'default_project_visibility'
,
'default_projects_limit'
,
'default_snippet_visibility'
,
'disabled_oauth_sign_in_sources'
,
'domain_blacklist_enabled'
,
'domain_blacklist'
,
'domain_whitelist'
,
'dsa_key_restriction'
,
'ecdsa_key_restriction'
,
'ed25519_key_restriction'
,
'email_author_in_body'
,
'enabled_git_access_protocol'
,
'gravatar_enabled'
,
'help_page_hide_commercial_content'
,
'help_page_support_url'
,
'home_page_url'
,
'housekeeping_bitmaps_enabled'
,
'housekeeping_enabled'
,
'housekeeping_full_repack_period'
,
'housekeeping_gc_period'
,
'housekeeping_incremental_repack_period'
,
'html_emails_enabled'
,
'import_sources'
,
'koding_enabled'
,
'koding_url'
,
'max_artifacts_size'
,
'max_attachment_size'
,
'max_pages_size'
,
'metrics_enabled'
,
'metrics_host'
,
'metrics_method_call_threshold'
,
'metrics_packet_size'
,
'metrics_pool_size'
,
'metrics_port'
,
'metrics_sample_interval'
,
'metrics_timeout'
,
'password_authentication_enabled_for_web'
,
'password_authentication_enabled_for_git'
,
'performance_bar_allowed_group_id'
,
'performance_bar_enabled'
,
'plantuml_enabled'
,
'plantuml_url'
,
'polling_interval_multiplier'
,
'project_export_enabled'
,
'prometheus_metrics_enabled'
,
'recaptcha_enabled'
,
'recaptcha_private_key'
,
'recaptcha_site_key'
,
'repository_checks_enabled'
,
'repository_storages'
,
'require_two_factor_authentication'
,
'restricted_visibility_levels'
,
'rsa_key_restriction'
,
'send_user_confirmation_email'
,
'sentry_dsn'
,
'sentry_enabled'
,
'session_expire_delay'
,
'shared_runners_enabled'
,
'shared_runners_text'
,
'sidekiq_throttling_enabled'
,
'sidekiq_throttling_factor'
,
'sidekiq_throttling_queues'
,
'sign_in_text'
,
'signup_enabled'
,
'terminal_max_session_time'
,
'two_factor_grace_period'
,
'unique_ips_limit_enabled'
,
'unique_ips_limit_per_user'
,
'unique_ips_limit_time_window'
,
'usage_ping_enabled'
,
'user_default_external'
,
'user_oauth_applications'
,
'version_check_enabled'
,
'enforce_terms'
,
'terms'
)
)
@
exc
.
on_http_error
(
exc
.
GitlabUpdateError
)
def
update
(
self
,
id
=
None
,
new_data
=
{},
**
kwargs
):
"""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:
dict: The new object data (*not* a RESTObject)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabUpdateError: If the server cannot perform the request
"""
data
=
new_data
.
copy
()
if
'domain_whitelist'
in
data
and
data
[
'domain_whitelist'
]
is
None
:
data
.
pop
(
'domain_whitelist'
)
super
(
ApplicationSettingsManager
,
self
).
update
(
id
,
data
,
**
kwargs
)
class
BroadcastMessage
(
SaveMixin
,
ObjectDeleteMixin
,
RESTObject
):
pass
class
BroadcastMessageManager
(
CRUDMixin
,
RESTManager
):
_path
=
'/broadcast_messages'
_obj_cls
=
BroadcastMessage
_create_attrs
=
((
'message'
, ), (
'starts_at'
,
'ends_at'
,
'color'
,
'font'
))
_update_attrs
=
(
tuple
(), (
'message'
,
'starts_at'
,
'ends_at'
,
'color'
,
'font'
))
class
DeployKey
(
RESTObject
):
pass
class
DeployKeyManager
(
ListMixin
,
RESTManager
):
_path
=
'/deploy_keys'
_obj_cls
=
DeployKey
class
NotificationSettings
(
SaveMixin
,
RESTObject
):
_id_attr
=
None
class
NotificationSettingsManager
(
GetWithoutIdMixin
,
UpdateMixin
,
RESTManager
):
_path
=
'/notification_settings'
_obj_cls
=
NotificationSettings
_update_attrs
=
(
tuple
(),
(
'level'
,
'notification_email'
,
'new_note'
,
'new_issue'
,
'reopen_issue'
,
'close_issue'
,
'reassign_issue'
,
'new_merge_request'
,
'reopen_merge_request'
,
'close_merge_request'
,
'reassign_merge_request'
,
'merge_merge_request'
)
)
class
Dockerfile
(
RESTObject
):
_id_attr
=
'name'
class
DockerfileManager
(
RetrieveMixin
,
RESTManager
):
_path
=
'/templates/dockerfiles'
_obj_cls
=
Dockerfile
class
Feature
(
ObjectDeleteMixin
,
RESTObject
):
_id_attr
=
'name'
class
FeatureManager
(
ListMixin
,
DeleteMixin
,
RESTManager
):
_path
=
'/features/'
_obj_cls
=
Feature
@
exc
.
on_http_error
(
exc
.
GitlabSetError
)
def
set
(
self
,
name
,
value
,
feature_group
=
None
,
user
=
None
,
**
kwargs
):
"""Create or update the object.
Args:
name (str): The value to set for the object
value (bool/int): The value to set for the object
feature_group (str): A feature group name
user (str): A GitLab username
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabSetError: If an error occured
Returns:
obj: The created/updated attribute
"""
path
=
'%s/%s'
%
(
self
.
path
,
name
.
replace
(
'/'
,
'%2F'
))
data
=
{
'value'
:
value
,
'feature_group'
:
feature_group
,
'user'
:
user
}
server_data
=
self
.
gitlab
.
http_post
(
path
,
post_data
=
data
,
**
kwargs
)
return
self
.
_obj_cls
(
self
,
server_data
)
class
Gitignore
(
RESTObject
):
_id_attr
=
'name'
class
GitignoreManager
(
RetrieveMixin
,
RESTManager
):
_path
=
'/templates/gitignores'
_obj_cls
=
Gitignore
class
Gitlabciyml
(
RESTObject
):
_id_attr
=
'name'
class
GitlabciymlManager
(
RetrieveMixin
,
RESTManager
):
_path
=
'/templates/gitlab_ci_ymls'
_obj_cls
=
Gitlabciyml
class
GroupAccessRequest
(
AccessRequestMixin
,
ObjectDeleteMixin
,
RESTObject
):
pass
class
GroupAccessRequestManager
(
ListMixin
,
CreateMixin
,
DeleteMixin
,
RESTManager
):
_path
=
'/groups/%(group_id)s/access_requests'
_obj_cls
=
GroupAccessRequest
_from_parent_attrs
=
{
'group_id'
:
'id'
}
class
GroupBadge
(
SaveMixin
,
ObjectDeleteMixin
,
RESTObject
):
pass
class
GroupBadgeManager
(
BadgeRenderMixin
,
CRUDMixin
,
RESTManager
):
_path
=
'/groups/%(group_id)s/badges'
_obj_cls
=
GroupBadge
_from_parent_attrs
=
{
'group_id'
:
'id'
}
_create_attrs
=
((
'link_url'
,
'image_url'
),
tuple
())
_update_attrs
=
(
tuple
(), (
'link_url'
,
'image_url'
))
class
GroupBoardList
(
SaveMixin
,
ObjectDeleteMixin
,
RESTObject
):
pass
class
GroupBoardListManager
(
CRUDMixin
,
RESTManager
):
_path
=
'/groups/%(group_id)s/boards/%(board_id)s/lists'
_obj_cls
=
GroupBoardList
_from_parent_attrs
=
{
'group_id'
:
'group_id'
,
'board_id'
:
'id'
}
_create_attrs
=
((
'label_id'
, ),
tuple
())
_update_attrs
=
((
'position'
, ),
tuple
())
class
GroupBoard
(
ObjectDeleteMixin
,
RESTObject
):
_managers
=
((
'lists'
,
'GroupBoardListManager'
), )
class
GroupBoardManager
(
NoUpdateMixin
,
RESTManager
):
_path
=
'/groups/%(group_id)s/boards'
_obj_cls
=
GroupBoard
_from_parent_attrs
=
{
'group_id'
:
'id'
}
_create_attrs
=
((
'name'
, ),
tuple
())
class
GroupCustomAttribute
(
ObjectDeleteMixin
,
RESTObject
):
_id_attr
=
'key'
class
GroupCustomAttributeManager
(
RetrieveMixin
,
SetMixin
,
DeleteMixin
,
RESTManager
):
_path
=
'/groups/%(group_id)s/custom_attributes'
_obj_cls
=
GroupCustomAttribute
_from_parent_attrs
=
{
'group_id'
:
'id'
}
class
GroupEpicIssue
(
ObjectDeleteMixin
,
SaveMixin
,
RESTObject
):
_id_attr
=
'epic_issue_id'
def
save
(
self
,
**
kwargs
):
"""Save the changes made to the object to the server.
The object is updated to match what the server returns.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raise:
GitlabAuthenticationError: If authentication is not correct
GitlabUpdateError: If the server cannot perform the request
"""
updated_data
=
self
.
_get_updated_data
()
# Nothing to update. Server fails if sent an empty dict.
if
not
updated_data
:
return
# call the manager
obj_id
=
self
.
get_id
()
self
.
manager
.
update
(
obj_id
,
updated_data
,
**
kwargs
)
class
GroupEpicIssueManager
(
ListMixin
,
CreateMixin
,
UpdateMixin
,
DeleteMixin
,
RESTManager
):
_path
=
'/groups/%(group_id)s/epics/%(epic_iid)s/issues'
_obj_cls
=
GroupEpicIssue
_from_parent_attrs
=
{
'group_id'
:
'group_id'
,
'epic_iid'
:
'iid'
}
_create_attrs
=
((
'issue_id'
,),
tuple
())
_update_attrs
=
(
tuple
(), (
'move_before_id'
,
'move_after_id'
))
@
exc
.
on_http_error
(
exc
.
GitlabCreateError
)
def
create
(
self
,
data
,
**
kwargs
):
"""Create a new object.
Args:
data (dict): Parameters to send to the server to create the
resource
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the server cannot perform the request
Returns:
RESTObject: A new instance of the manage object class build with
the data sent by the server
"""
CreateMixin
.
_check_missing_create_attrs
(
self
,
data
)
path
=
'%s/%s'
%
(
self
.
path
,
data
.
pop
(
'issue_id'
))
server_data
=
self
.
gitlab
.
http_post
(
path
,
**
kwargs
)
# The epic_issue_id attribute doesn't exist when creating the resource,
# but is used everywhere elese. Let's create it to be consistent client
# side
server_data
[
'epic_issue_id'
]
=
server_data
[
'id'
]
return
self
.
_obj_cls
(
self
,
server_data
)
class
GroupEpicResourceLabelEvent
(
RESTObject
):
pass
class
GroupEpicResourceLabelEventManager
(
RetrieveMixin
,
RESTManager
):
_path
=
(
'/groups/%(group_id)s/epics/%(epic_id)s/resource_label_events'
)
_obj_cls
=
GroupEpicResourceLabelEvent
_from_parent_attrs
=
{
'group_id'
:
'group_id'
,
'epic_id'
:
'id'
}
class
GroupEpic
(
ObjectDeleteMixin
,
SaveMixin
,
RESTObject
):
_id_attr
=
'iid'
_managers
=
(
(
'issues'
,
'GroupEpicIssueManager'
),
(
'resourcelabelevents'
,
'GroupEpicResourceLabelEventManager'
),
)
class
GroupEpicManager
(
CRUDMixin
,
RESTManager
):
_path
=
'/groups/%(group_id)s/epics'
_obj_cls
=
GroupEpic
_from_parent_attrs
=
{
'group_id'
:
'id'
}
_list_filters
=
(
'author_id'
,
'labels'
,
'order_by'
,
'sort'
,
'search'
)
_create_attrs
=
((
'title'
,),
(
'labels'
,
'description'
,
'start_date'
,
'end_date'
))
_update_attrs
=
(
tuple
(), (
'title'
,
'labels'
,
'description'
,
'start_date'
,
'end_date'
))
_types
=
{
'labels'
:
types
.
ListAttribute
}
class
GroupIssue
(
RESTObject
):
pass
class
GroupIssueManager
(
ListMixin
,
RESTManager
):
_path
=
'/groups/%(group_id)s/issues'
_obj_cls
=
GroupIssue
_from_parent_attrs
=
{
'group_id'
:
'id'
}
_list_filters
=
(
'state'
,
'labels'
,
'milestone'
,
'order_by'
,
'sort'
,
'iids'
,
'author_id'
,
'assignee_id'
,
'my_reaction_emoji'
,
'search'
,
'created_after'
,
'created_before'
,
'updated_after'
,
'updated_before'
)
_types
=
{
'labels'
:
types
.
ListAttribute
}
class
GroupMember
(
SaveMixin
,
ObjectDeleteMixin
,
RESTObject
):
_short_print_attr
=
'username'
class
GroupMemberManager
(
CRUDMixin
,
RESTManager
):
_path
=
'/groups/%(group_id)s/members'
_obj_cls
=
GroupMember
_from_parent_attrs
=
{
'group_id'
:
'id'
}
_create_attrs
=
((
'access_level'
,
'user_id'
), (
'expires_at'
, ))
_update_attrs
=
((
'access_level'
, ), (
'expires_at'
, ))
@
cli
.
register_custom_action
(
'GroupMemberManager'
)
@
exc
.
on_http_error
(
exc
.
GitlabListError
)
def
all
(
self
,
**
kwargs
):
"""List all the members, included inherited ones.
Args:
all (bool): If True, return all the items, without pagination
per_page (int): Number of items to retrieve per request
page (int): ID of the page to return (starts with page 1)
as_list (bool): If set to False and no pagination option is
defined, return a generator instead of a list
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabListError: If the list could not be retrieved
Returns:
RESTObjectList: The list of members
"""
path
=
'%s/all'
%
self
.
path
return
self
.
gitlab
.
http_list
(
path
,
**
kwargs
)
class
GroupMergeRequest
(
RESTObject
):
pass
class
GroupMergeRequestManager
(
ListMixin
,
RESTManager
):
_path
=
'/groups/%(group_id)s/merge_requests'
_obj_cls
=
GroupMergeRequest
_from_parent_attrs
=
{
'group_id'
:
'id'
}
_list_filters
=
(
'state'
,
'order_by'
,
'sort'
,
'milestone'
,
'view'
,
'labels'
,
'created_after'
,
'created_before'
,
'updated_after'
,
'updated_before'
,
'scope'
,
'author_id'
,
'assignee_id'
,
'my_reaction_emoji'
,
'source_branch'
,
'target_branch'
,
'search'
)
_types
=
{
'labels'
:
types
.
ListAttribute
}
class
GroupMilestone
(
SaveMixin
,
ObjectDeleteMixin
,
RESTObject
):
_short_print_attr
=
'title'
@
cli
.
register_custom_action
(
'GroupMilestone'
)
@
exc
.
on_http_error
(
exc
.
GitlabListError
)
def
issues
(
self
,
**
kwargs
):
"""List issues related to this milestone.
Args:
all (bool): If True, return all the items, without pagination
per_page (int): Number of items to retrieve per request
page (int): ID of the page to return (starts with page 1)
as_list (bool): If set to False and no pagination option is
defined, return a generator instead of a list
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabListError: If the list could not be retrieved
Returns:
RESTObjectList: The list of issues
"""
path
=
'%s/%s/issues'
%
(
self
.
manager
.
path
,
self
.
get_id
())
data_list
=
self
.
manager
.
gitlab
.
http_list
(
path
,
as_list
=
False
,
**
kwargs
)
manager
=
GroupIssueManager
(
self
.
manager
.
gitlab
,
parent
=
self
.
manager
.
_parent
)
# FIXME(gpocentek): the computed manager path is not correct
return
RESTObjectList
(
manager
,
GroupIssue
,
data_list
)
@
cli
.
register_custom_action
(
'GroupMilestone'
)
@
exc
.
on_http_error
(
exc
.
GitlabListError
)
def
merge_requests
(
self
,
**
kwargs
):
"""List the merge requests related to this milestone.
Args:
all (bool): If True, return all the items, without pagination
per_page (int): Number of items to retrieve per request
page (int): ID of the page to return (starts with page 1)
as_list (bool): If set to False and no pagination option is
defined, return a generator instead of a list
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabListError: If the list could not be retrieved
Returns:
RESTObjectList: The list of merge requests
"""
path
=
'%s/%s/merge_requests'
%
(
self
.
manager
.
path
,
self
.
get_id
())
data_list
=
self
.
manager
.
gitlab
.
http_list
(
path
,
as_list
=
False
,
**
kwargs
)
manager
=
GroupIssueManager
(
self
.
manager
.
gitlab
,
parent
=
self
.
manager
.
_parent
)
# FIXME(gpocentek): the computed manager path is not correct
return
RESTObjectList
(
manager
,
GroupMergeRequest
,
data_list
)
class
GroupMilestoneManager
(
CRUDMixin
,
RESTManager
):
_path
=
'/groups/%(group_id)s/milestones'
_obj_cls
=
GroupMilestone
_from_parent_attrs
=
{
'group_id'
:
'id'
}
_create_attrs
=
((
'title'
, ), (
'description'
,
'due_date'
,
'start_date'
))
_update_attrs
=
(
tuple
(), (
'title'
,
'description'
,
'due_date'
,
'start_date'
,
'state_event'
))
_list_filters
=
(
'iids'
,
'state'
,
'search'
)
class
GroupNotificationSettings
(
NotificationSettings
):
pass
class
GroupNotificationSettingsManager
(
NotificationSettingsManager
):
_path
=
'/groups/%(group_id)s/notification_settings'
_obj_cls
=
GroupNotificationSettings
_from_parent_attrs
=
{
'group_id'
:
'id'
}
class
GroupProject
(
RESTObject
):
pass
class
GroupProjectManager
(
ListMixin
,
RESTManager
):
_path
=
'/groups/%(group_id)s/projects'
_obj_cls
=
GroupProject
_from_parent_attrs
=
{
'group_id'
:
'id'
}
_list_filters
=
(
'archived'
,
'visibility'
,
'order_by'
,
'sort'
,
'search'
,
'ci_enabled_first'
,
'simple'
,
'owned'
,
'starred'
,
'with_custom_attributes'
)
class
GroupSubgroup
(
RESTObject
):
pass
class
GroupSubgroupManager
(
ListMixin
,
RESTManager
):
_path
=
'/groups/%(group_id)s/subgroups'
_obj_cls
=
GroupSubgroup
_from_parent_attrs
=
{
'group_id'
:
'id'
}
_list_filters
=
(
'skip_groups'
,
'all_available'
,
'search'
,
'order_by'
,
'sort'
,
'statistics'
,
'owned'
,
'with_custom_attributes'
)
class
GroupVariable
(
SaveMixin
,
ObjectDeleteMixin
,
RESTObject
):
_id_attr
=
'key'
class
GroupVariableManager
(
CRUDMixin
,
RESTManager
):
_path
=
'/groups/%(group_id)s/variables'
_obj_cls
=
GroupVariable
_from_parent_attrs
=
{
'group_id'
:
'id'
}
_create_attrs
=
((
'key'
,
'value'
), (
'protected'
,))
_update_attrs
=
((
'key'
,
'value'
), (
'protected'
,))
class
Group
(
SaveMixin
,
ObjectDeleteMixin
,
RESTObject
):
_short_print_attr
=
'name'
_managers
=
(
(
'accessrequests'
,
'GroupAccessRequestManager'
),
(
'badges'
,
'GroupBadgeManager'
),
(
'boards'
,
'GroupBoardManager'
),
(
'customattributes'
,
'GroupCustomAttributeManager'
),
(
'epics'
,
'GroupEpicManager'
),
(
'issues'
,
'GroupIssueManager'
),
(
'members'
,
'GroupMemberManager'
),
(
'mergerequests'
,
'GroupMergeRequestManager'
),
(
'milestones'
,
'GroupMilestoneManager'
),
(
'notificationsettings'
,
'GroupNotificationSettingsManager'
),
(
'projects'
,
'GroupProjectManager'
),
(
'subgroups'
,
'GroupSubgroupManager'
),
(
'variables'
,
'GroupVariableManager'
),
)
@
cli
.
register_custom_action
(
'Group'
, (
'to_project_id'
, ))
@
exc
.
on_http_error
(
exc
.
GitlabTransferProjectError
)
def
transfer_project
(
self
,
to_project_id
,
**
kwargs
):
"""Transfer a project to this group.
Args:
to_project_id (int): ID of the project to transfer
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabTransferProjectError: If the project could not be transfered
"""
path
=
'/groups/%d/projects/%d'
%
(
self
.
id
,
to_project_id
)
self
.
manager
.
gitlab
.
http_post
(
path
,
**
kwargs
)
@
cli
.
register_custom_action
(
'Group'
, (
'scope'
,
'search'
))
@
exc
.
on_http_error
(
exc
.
GitlabSearchError
)
def
search
(
self
,
scope
,
search
,
**
kwargs
):
"""Search the group resources matching the provided string.'
Args:
scope (str): Scope of the search
search (str): Search string
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabSearchError: If the server failed to perform the request
Returns:
GitlabList: A list of dicts describing the resources found.
"""
data
=
{
'scope'
:
scope
,
'search'
:
search
}
path
=
'/groups/%d/search'
%
self
.
get_id
()
return
self
.
manager
.
gitlab
.
http_list
(
path
,
query_data
=
data
,
**
kwargs
)
@
cli
.
register_custom_action
(
'Group'
, (
'cn'
,
'group_access'
,
'provider'
))
@
exc
.
on_http_error
(
exc
.
GitlabCreateError
)
def
add_ldap_group_link
(
self
,
cn
,
group_access
,
provider
,
**
kwargs
):
"""Add an LDAP group link.
Args:
cn (str): CN of the LDAP group
group_access (int): Minimum access level for members of the LDAP
group
provider (str): LDAP provider for the LDAP group
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the server cannot perform the request
"""
path
=
'/groups/%d/ldap_group_links'
%
self
.
get_id
()
data
=
{
'cn'
:
cn
,
'group_access'
:
group_access
,
'provider'
:
provider
}
self
.
manager
.
gitlab
.
http_post
(
path
,
post_data
=
data
,
**
kwargs
)
@
cli
.
register_custom_action
(
'Group'
, (
'cn'
,), (
'provider'
,))
@
exc
.
on_http_error
(
exc
.
GitlabDeleteError
)
def
delete_ldap_group_link
(
self
,
cn
,
provider
=
None
,
**
kwargs
):
"""Delete an LDAP group link.
Args:
cn (str): CN of the LDAP group
provider (str): LDAP provider for the LDAP group
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabDeleteError: If the server cannot perform the request
"""
path
=
'/groups/%d/ldap_group_links'
%
self
.
get_id
()
if
provider
is
not
None
:
path
+=
'/%s'
%
provider
path
+=
'/%s'
%
cn
self
.
manager
.
gitlab
.
http_delete
(
path
)
@
cli
.
register_custom_action
(
'Group'
)
@
exc
.
on_http_error
(
exc
.
GitlabCreateError
)
def
ldap_sync
(
self
,
**
kwargs
):
"""Sync LDAP groups.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the server cannot perform the request
"""
path
=
'/groups/%d/ldap_sync'
%
self
.
get_id
()
self
.
manager
.
gitlab
.
http_post
(
path
,
**
kwargs
)
class
GroupManager
(
CRUDMixin
,
RESTManager
):
_path
=
'/groups'
_obj_cls
=
Group
_list_filters
=
(
'skip_groups'
,
'all_available'
,
'search'
,
'order_by'
,
'sort'
,
'statistics'
,
'owned'
,
'with_custom_attributes'
)
_create_attrs
=
(
(
'name'
,
'path'
),
(
'description'
,
'visibility'
,
'parent_id'
,
'lfs_enabled'
,
'request_access_enabled'
)
)
View remainder of file in raw view
Footer
© 2026 GitHub, Inc.
Footer navigation
Terms
Privacy
Security
Status
Community
Docs
Contact
You can’t perform that action at this time.
Back
|
FazBrowse Home
|
New Git URL