FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-gitlab/gitlab/v4/objects/users.py at v7.1.0 · python-gitlab/python-gitlab · GitHub
python-gitlab
python-gitlab
Repository navigation
Code
Issues
16
(16)
Pull requests
15
(15)
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-gitlab
/
gitlab
/
v4
/
objects
/
users.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
732 lines (596 loc) · 20.5 KB
Breadcrumbs
python-gitlab
/
gitlab
/
v4
/
objects
/
users.py
Copy path
File metadata and controls
732 lines (596 loc) · 20.5 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
"""
GitLab API:
https://docs.gitlab.com/ee/api/users.html
https://docs.gitlab.com/ee/api/projects.html#list-projects-starred-by-a-user
"""
from
__future__
import
annotations
from
typing
import
Any
,
cast
,
Literal
,
Optional
,
overload
import
requests
from
gitlab
import
cli
from
gitlab
import
exceptions
as
exc
from
gitlab
import
types
from
gitlab
.
base
import
RESTObject
,
RESTObjectList
from
gitlab
.
mixins
import
(
CreateMixin
,
CRUDMixin
,
DeleteMixin
,
GetWithoutIdMixin
,
ListMixin
,
NoUpdateMixin
,
ObjectDeleteMixin
,
RetrieveMixin
,
SaveMixin
,
UpdateMixin
,
)
from
gitlab
.
types
import
ArrayAttribute
,
RequiredOptional
from
.
custom_attributes
import
UserCustomAttributeManager
# noqa: F401
from
.
events
import
UserEventManager
# noqa: F401
from
.
personal_access_tokens
import
UserPersonalAccessTokenManager
# noqa: F401
__all__
=
[
"CurrentUserEmail"
,
"CurrentUserEmailManager"
,
"CurrentUserGPGKey"
,
"CurrentUserGPGKeyManager"
,
"CurrentUserKey"
,
"CurrentUserKeyManager"
,
"CurrentUserRunner"
,
"CurrentUserRunnerManager"
,
"CurrentUserStatus"
,
"CurrentUserStatusManager"
,
"CurrentUser"
,
"CurrentUserManager"
,
"User"
,
"UserManager"
,
"ProjectUser"
,
"ProjectUserManager"
,
"StarredProject"
,
"StarredProjectManager"
,
"UserEmail"
,
"UserEmailManager"
,
"UserActivities"
,
"UserStatus"
,
"UserStatusManager"
,
"UserActivitiesManager"
,
"UserGPGKey"
,
"UserGPGKeyManager"
,
"UserKey"
,
"UserKeyManager"
,
"UserIdentityProviderManager"
,
"UserImpersonationToken"
,
"UserImpersonationTokenManager"
,
"UserMembership"
,
"UserMembershipManager"
,
"UserProject"
,
"UserProjectManager"
,
"UserContributedProject"
,
"UserContributedProjectManager"
,
]
class
CurrentUserEmail
(
ObjectDeleteMixin
,
RESTObject
):
_repr_attr
=
"email"
class
CurrentUserEmailManager
(
RetrieveMixin
[
CurrentUserEmail
],
CreateMixin
[
CurrentUserEmail
],
DeleteMixin
[
CurrentUserEmail
],
):
_path
=
"/user/emails"
_obj_cls
=
CurrentUserEmail
_create_attrs
=
RequiredOptional
(
required
=
(
"email"
,))
class
CurrentUserGPGKey
(
ObjectDeleteMixin
,
RESTObject
):
pass
class
CurrentUserGPGKeyManager
(
RetrieveMixin
[
CurrentUserGPGKey
],
CreateMixin
[
CurrentUserGPGKey
],
DeleteMixin
[
CurrentUserGPGKey
],
):
_path
=
"/user/gpg_keys"
_obj_cls
=
CurrentUserGPGKey
_create_attrs
=
RequiredOptional
(
required
=
(
"key"
,))
class
CurrentUserKey
(
ObjectDeleteMixin
,
RESTObject
):
_repr_attr
=
"title"
class
CurrentUserKeyManager
(
RetrieveMixin
[
CurrentUserKey
],
CreateMixin
[
CurrentUserKey
],
DeleteMixin
[
CurrentUserKey
],
):
_path
=
"/user/keys"
_obj_cls
=
CurrentUserKey
_create_attrs
=
RequiredOptional
(
required
=
(
"title"
,
"key"
))
class
CurrentUserRunner
(
RESTObject
):
pass
class
CurrentUserRunnerManager
(
CreateMixin
[
CurrentUserRunner
]):
_path
=
"/user/runners"
_obj_cls
=
CurrentUserRunner
_types
=
{
"tag_list"
:
types
.
CommaSeparatedListAttribute
}
_create_attrs
=
RequiredOptional
(
required
=
(
"runner_type"
,),
optional
=
(
"group_id"
,
"project_id"
,
"description"
,
"paused"
,
"locked"
,
"run_untagged"
,
"tag_list"
,
"access_level"
,
"maximum_timeout"
,
"maintenance_note"
,
),
)
class
CurrentUserStatus
(
SaveMixin
,
RESTObject
):
_id_attr
=
None
_repr_attr
=
"message"
class
CurrentUserStatusManager
(
GetWithoutIdMixin
[
CurrentUserStatus
],
UpdateMixin
[
CurrentUserStatus
]
):
_path
=
"/user/status"
_obj_cls
=
CurrentUserStatus
_update_attrs
=
RequiredOptional
(
optional
=
(
"emoji"
,
"message"
))
class
CurrentUser
(
RESTObject
):
_id_attr
=
None
_repr_attr
=
"username"
emails
:
CurrentUserEmailManager
gpgkeys
:
CurrentUserGPGKeyManager
keys
:
CurrentUserKeyManager
runners
:
CurrentUserRunnerManager
status
:
CurrentUserStatusManager
class
CurrentUserManager
(
GetWithoutIdMixin
[
CurrentUser
]):
_path
=
"/user"
_obj_cls
=
CurrentUser
class
User
(
SaveMixin
,
ObjectDeleteMixin
,
RESTObject
):
_repr_attr
=
"username"
customattributes
:
UserCustomAttributeManager
emails
:
UserEmailManager
events
:
UserEventManager
followers_users
:
UserFollowersManager
following_users
:
UserFollowingManager
gpgkeys
:
UserGPGKeyManager
identityproviders
:
UserIdentityProviderManager
impersonationtokens
:
UserImpersonationTokenManager
keys
:
UserKeyManager
memberships
:
UserMembershipManager
personal_access_tokens
:
UserPersonalAccessTokenManager
projects
:
UserProjectManager
contributed_projects
:
UserContributedProjectManager
starred_projects
:
StarredProjectManager
status
:
UserStatusManager
@
cli
.
register_custom_action
(
cls_names
=
"User"
)
@
exc
.
on_http_error
(
exc
.
GitlabBlockError
)
def
block
(
self
,
**
kwargs
:
Any
)
->
bool
|
None
:
"""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:
Whether the user status has been changed
"""
path
=
f"/users/
{
self
.
encoded_id
}
/block"
# NOTE: Undocumented behavior of the GitLab API is that it returns a
# boolean or None
server_data
=
cast
(
Optional
[
bool
],
self
.
manager
.
gitlab
.
http_post
(
path
,
**
kwargs
)
)
if
server_data
is
True
:
self
.
_attrs
[
"state"
]
=
"blocked"
return
server_data
@
cli
.
register_custom_action
(
cls_names
=
"User"
)
@
exc
.
on_http_error
(
exc
.
GitlabFollowError
)
def
follow
(
self
,
**
kwargs
:
Any
)
->
dict
[
str
,
Any
]
|
requests
.
Response
:
"""Follow the user.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabFollowError: If the user could not be followed
Returns:
The new object data (*not* a RESTObject)
"""
path
=
f"/users/
{
self
.
encoded_id
}
/follow"
return
self
.
manager
.
gitlab
.
http_post
(
path
,
**
kwargs
)
@
cli
.
register_custom_action
(
cls_names
=
"User"
)
@
exc
.
on_http_error
(
exc
.
GitlabUnfollowError
)
def
unfollow
(
self
,
**
kwargs
:
Any
)
->
dict
[
str
,
Any
]
|
requests
.
Response
:
"""Unfollow the user.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabUnfollowError: If the user could not be followed
Returns:
The new object data (*not* a RESTObject)
"""
path
=
f"/users/
{
self
.
encoded_id
}
/unfollow"
return
self
.
manager
.
gitlab
.
http_post
(
path
,
**
kwargs
)
@
cli
.
register_custom_action
(
cls_names
=
"User"
)
@
exc
.
on_http_error
(
exc
.
GitlabUnblockError
)
def
unblock
(
self
,
**
kwargs
:
Any
)
->
bool
|
None
:
"""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:
Whether the user status has been changed
"""
path
=
f"/users/
{
self
.
encoded_id
}
/unblock"
# NOTE: Undocumented behavior of the GitLab API is that it returns a
# boolean or None
server_data
=
cast
(
Optional
[
bool
],
self
.
manager
.
gitlab
.
http_post
(
path
,
**
kwargs
)
)
if
server_data
is
True
:
self
.
_attrs
[
"state"
]
=
"active"
return
server_data
@
cli
.
register_custom_action
(
cls_names
=
"User"
)
@
exc
.
on_http_error
(
exc
.
GitlabDeactivateError
)
def
deactivate
(
self
,
**
kwargs
:
Any
)
->
dict
[
str
,
Any
]
|
requests
.
Response
:
"""Deactivate the user.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabDeactivateError: If the user could not be deactivated
Returns:
Whether the user status has been changed
"""
path
=
f"/users/
{
self
.
encoded_id
}
/deactivate"
server_data
=
self
.
manager
.
gitlab
.
http_post
(
path
,
**
kwargs
)
if
server_data
:
self
.
_attrs
[
"state"
]
=
"deactivated"
return
server_data
@
cli
.
register_custom_action
(
cls_names
=
"User"
)
@
exc
.
on_http_error
(
exc
.
GitlabActivateError
)
def
activate
(
self
,
**
kwargs
:
Any
)
->
dict
[
str
,
Any
]
|
requests
.
Response
:
"""Activate the user.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabActivateError: If the user could not be activated
Returns:
Whether the user status has been changed
"""
path
=
f"/users/
{
self
.
encoded_id
}
/activate"
server_data
=
self
.
manager
.
gitlab
.
http_post
(
path
,
**
kwargs
)
if
server_data
:
self
.
_attrs
[
"state"
]
=
"active"
return
server_data
@
cli
.
register_custom_action
(
cls_names
=
"User"
)
@
exc
.
on_http_error
(
exc
.
GitlabUserApproveError
)
def
approve
(
self
,
**
kwargs
:
Any
)
->
dict
[
str
,
Any
]
|
requests
.
Response
:
"""Approve a user creation request.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabUserApproveError: If the user could not be activated
Returns:
The new object data (*not* a RESTObject)
"""
path
=
f"/users/
{
self
.
encoded_id
}
/approve"
return
self
.
manager
.
gitlab
.
http_post
(
path
,
**
kwargs
)
@
cli
.
register_custom_action
(
cls_names
=
"User"
)
@
exc
.
on_http_error
(
exc
.
GitlabUserRejectError
)
def
reject
(
self
,
**
kwargs
:
Any
)
->
dict
[
str
,
Any
]
|
requests
.
Response
:
"""Reject a user creation request.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabUserRejectError: If the user could not be rejected
Returns:
The new object data (*not* a RESTObject)
"""
path
=
f"/users/
{
self
.
encoded_id
}
/reject"
return
self
.
manager
.
gitlab
.
http_post
(
path
,
**
kwargs
)
@
cli
.
register_custom_action
(
cls_names
=
"User"
)
@
exc
.
on_http_error
(
exc
.
GitlabBanError
)
def
ban
(
self
,
**
kwargs
:
Any
)
->
dict
[
str
,
Any
]
|
requests
.
Response
:
"""Ban the user.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabBanError: If the user could not be banned
Returns:
Whether the user has been banned
"""
path
=
f"/users/
{
self
.
encoded_id
}
/ban"
server_data
=
self
.
manager
.
gitlab
.
http_post
(
path
,
**
kwargs
)
if
server_data
:
self
.
_attrs
[
"state"
]
=
"banned"
return
server_data
@
cli
.
register_custom_action
(
cls_names
=
"User"
)
@
exc
.
on_http_error
(
exc
.
GitlabUnbanError
)
def
unban
(
self
,
**
kwargs
:
Any
)
->
dict
[
str
,
Any
]
|
requests
.
Response
:
"""Unban the user.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabUnbanError: If the user could not be unbanned
Returns:
Whether the user has been unbanned
"""
path
=
f"/users/
{
self
.
encoded_id
}
/unban"
server_data
=
self
.
manager
.
gitlab
.
http_post
(
path
,
**
kwargs
)
if
server_data
:
self
.
_attrs
[
"state"
]
=
"active"
return
server_data
class
UserManager
(
CRUDMixin
[
User
]):
_path
=
"/users"
_obj_cls
=
User
_list_filters
=
(
"username"
,
"public_email"
,
"search"
,
"active"
,
"external"
,
"blocked"
,
"humans"
,
"created_after"
,
"created_before"
,
"exclude_active"
,
"exclude_external"
,
"exclude_humans"
,
"exclude_internal"
,
"without_project_bots"
,
"extern_uid"
,
"provider"
,
"two_factor"
,
"without_projects"
,
"admins"
,
"auditors"
,
"skip_ldap"
,
"custom_attributes"
,
"status"
,
)
_create_attrs
=
RequiredOptional
(
optional
=
(
"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"
,
"public_email"
,
"private_profile"
,
"color_scheme_id"
,
"theme_id"
,
)
)
_update_attrs
=
RequiredOptional
(
required
=
(
"email"
,
"username"
,
"name"
),
optional
=
(
"password"
,
"skype"
,
"linkedin"
,
"twitter"
,
"projects_limit"
,
"extern_uid"
,
"provider"
,
"bio"
,
"admin"
,
"can_create_group"
,
"website_url"
,
"skip_reconfirmation"
,
"external"
,
"organization"
,
"location"
,
"avatar"
,
"public_email"
,
"private_profile"
,
"color_scheme_id"
,
"theme_id"
,
),
)
_types
=
{
"confirm"
:
types
.
LowercaseStringAttribute
,
"avatar"
:
types
.
ImageAttribute
}
class
ProjectUser
(
RESTObject
):
pass
class
ProjectUserManager
(
ListMixin
[
ProjectUser
]):
_path
=
"/projects/{project_id}/users"
_obj_cls
=
ProjectUser
_from_parent_attrs
=
{
"project_id"
:
"id"
}
_list_filters
=
(
"search"
,
"skip_users"
)
_types
=
{
"skip_users"
:
types
.
ArrayAttribute
}
class
UserEmail
(
ObjectDeleteMixin
,
RESTObject
):
_repr_attr
=
"email"
class
UserEmailManager
(
RetrieveMixin
[
UserEmail
],
CreateMixin
[
UserEmail
],
DeleteMixin
[
UserEmail
]
):
_path
=
"/users/{user_id}/emails"
_obj_cls
=
UserEmail
_from_parent_attrs
=
{
"user_id"
:
"id"
}
_create_attrs
=
RequiredOptional
(
required
=
(
"email"
,),
optional
=
(
"skip_confirmation"
,)
)
class
UserActivities
(
RESTObject
):
_id_attr
=
"username"
class
UserStatus
(
RESTObject
):
_id_attr
=
None
_repr_attr
=
"message"
class
UserStatusManager
(
GetWithoutIdMixin
[
UserStatus
]):
_path
=
"/users/{user_id}/status"
_obj_cls
=
UserStatus
_from_parent_attrs
=
{
"user_id"
:
"id"
}
class
UserActivitiesManager
(
ListMixin
[
UserActivities
]):
_path
=
"/user/activities"
_obj_cls
=
UserActivities
class
UserGPGKey
(
ObjectDeleteMixin
,
RESTObject
):
pass
class
UserGPGKeyManager
(
RetrieveMixin
[
UserGPGKey
],
CreateMixin
[
UserGPGKey
],
DeleteMixin
[
UserGPGKey
]
):
_path
=
"/users/{user_id}/gpg_keys"
_obj_cls
=
UserGPGKey
_from_parent_attrs
=
{
"user_id"
:
"id"
}
_create_attrs
=
RequiredOptional
(
required
=
(
"key"
,))
class
UserKey
(
ObjectDeleteMixin
,
RESTObject
):
pass
class
UserKeyManager
(
RetrieveMixin
[
UserKey
],
CreateMixin
[
UserKey
],
DeleteMixin
[
UserKey
]
):
_path
=
"/users/{user_id}/keys"
_obj_cls
=
UserKey
_from_parent_attrs
=
{
"user_id"
:
"id"
}
_create_attrs
=
RequiredOptional
(
required
=
(
"title"
,
"key"
))
class
UserIdentityProviderManager
(
DeleteMixin
[
User
]):
"""Manager for user identities.
This manager does not actually manage objects but enables
functionality for deletion of user identities by provider.
"""
_path
=
"/users/{user_id}/identities"
_obj_cls
=
User
_from_parent_attrs
=
{
"user_id"
:
"id"
}
class
UserImpersonationToken
(
ObjectDeleteMixin
,
RESTObject
):
pass
class
UserImpersonationTokenManager
(
NoUpdateMixin
[
UserImpersonationToken
]):
_path
=
"/users/{user_id}/impersonation_tokens"
_obj_cls
=
UserImpersonationToken
_from_parent_attrs
=
{
"user_id"
:
"id"
}
_create_attrs
=
RequiredOptional
(
required
=
(
"name"
,
"scopes"
),
optional
=
(
"expires_at"
,)
)
_list_filters
=
(
"state"
,)
_types
=
{
"scopes"
:
ArrayAttribute
}
class
UserMembership
(
RESTObject
):
_id_attr
=
"source_id"
class
UserMembershipManager
(
RetrieveMixin
[
UserMembership
]):
_path
=
"/users/{user_id}/memberships"
_obj_cls
=
UserMembership
_from_parent_attrs
=
{
"user_id"
:
"id"
}
_list_filters
=
(
"type"
,)
# Having this outside projects avoids circular imports due to ProjectUser
class
UserProject
(
RESTObject
):
pass
class
UserProjectManager
(
ListMixin
[
UserProject
],
CreateMixin
[
UserProject
]):
_path
=
"/projects/user/{user_id}"
_obj_cls
=
UserProject
_from_parent_attrs
=
{
"user_id"
:
"id"
}
_create_attrs
=
RequiredOptional
(
required
=
(
"name"
,),
optional
=
(
"default_branch"
,
"issues_enabled"
,
"wall_enabled"
,
"merge_requests_enabled"
,
"wiki_enabled"
,
"snippets_enabled"
,
"squash_option"
,
"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"
,
"with_custom_attributes"
,
"with_programming_language"
,
"wiki_checksum_failed"
,
"repository_checksum_failed"
,
"min_access_level"
,
"id_after"
,
"id_before"
,
)
@
overload
def
list
(
self
,
*
,
iterator
:
Literal
[
False
]
=
False
,
**
kwargs
:
Any
)
->
list
[
UserProject
]: ...
@
overload
def
list
(
self
,
*
,
iterator
:
Literal
[
True
]
=
True
,
**
kwargs
:
Any
)
->
RESTObjectList
[
UserProject
]: ...
@
overload
def
list
(
self
,
*
,
iterator
:
bool
=
False
,
**
kwargs
:
Any
)
->
RESTObjectList
[
UserProject
]
|
list
[
UserProject
]: ...
def
list
(
self
,
*
,
iterator
:
bool
=
False
,
**
kwargs
:
Any
)
->
RESTObjectList
[
UserProject
]
|
list
[
UserProject
]:
"""Retrieve a list of objects.
Args:
get_all: If True, return all the items, without pagination
per_page: Number of items to retrieve per request
page: ID of the page to return (starts with page 1)
iterator: If set to True 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:
The list of objects, or a generator if `iterator` is True
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabListError: If the server cannot perform the request
"""
if
self
.
_parent
:
path
=
f"/users/
{
self
.
_parent
.
id
}
/projects"
else
:
path
=
f"/users/
{
self
.
_from_parent_attrs
[
'user_id'
]
}
/projects"
return
super
().
list
(
path
=
path
,
iterator
=
iterator
,
**
kwargs
)
class
UserContributedProject
(
RESTObject
):
_id_attr
=
"id"
_repr_attr
=
"path_with_namespace"
class
UserContributedProjectManager
(
ListMixin
[
UserContributedProject
]):
_path
=
"/users/{user_id}/contributed_projects"
_obj_cls
=
UserContributedProject
_from_parent_attrs
=
{
"user_id"
:
"id"
}
class
StarredProject
(
RESTObject
):
pass
class
StarredProjectManager
(
ListMixin
[
StarredProject
]):
_path
=
"/users/{user_id}/starred_projects"
_obj_cls
=
StarredProject
_from_parent_attrs
=
{
"user_id"
:
"id"
}
_list_filters
=
(
"archived"
,
"membership"
,
"min_access_level"
,
"order_by"
,
"owned"
,
"search"
,
"simple"
,
"sort"
,
"starred"
,
"statistics"
,
"visibility"
,
"with_custom_attributes"
,
"with_issues_enabled"
,
"with_merge_requests_enabled"
,
)
class
UserFollowersManager
(
ListMixin
[
User
]):
_path
=
"/users/{user_id}/followers"
_obj_cls
=
User
_from_parent_attrs
=
{
"user_id"
:
"id"
}
class
UserFollowingManager
(
ListMixin
[
User
]):
_path
=
"/users/{user_id}/following"
_obj_cls
=
User
_from_parent_attrs
=
{
"user_id"
:
"id"
}
Back
|
FazBrowse Home
|
New Git URL