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

Commitd509da6

Browse files
JohnVillalovosnejch
authored andcommitted
docs: document how to usesudo if modifying an object
Add a warning about using `sudo` when saving.Give an example of how to `get` an object, modify it, and then `save`it using `sudo`Closes:#532
1 parent6b37811 commitd509da6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎docs/api-usage.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,27 @@ user. For example:
411411
412412
p= gl.projects.create({'name':'awesome_project'},sudo='user1')
413413
414+
..warning::
415+
When using ``sudo``, its usage is not remembered. If you use ``sudo`` to
416+
retrieve an object and then later use ``save()`` to modify the object, it
417+
will not use ``sudo``. You should use ``save(sudo='user1')`` if you want to
418+
perform subsequent actions as the user.
419+
420+
Updating with ``sudo``
421+
----------------------
422+
423+
An example of how to ``get`` an object (using ``sudo``), modify the object, and
424+
then ``save`` the object (using ``sudo``):
425+
426+
..code-block::python
427+
428+
group= gl.groups.get('example-group')
429+
notification_setting= group.notificationsettings.get(sudo='user1')
430+
notification_setting.level= gitlab.const.NOTIFICATION_LEVEL_GLOBAL
431+
# Must use `sudo` again when doing the save.
432+
notification_setting.save(sudo='user1')
433+
434+
414435
Logging
415436
=======
416437

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp