| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6b8067e commit b3b0b5f
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,11 +7,11 @@ Users can request access to groups and projects. | |||
| 7 | 7 | When access is granted the user should be given a numerical access level. The | |
| 8 | 8 | following constants are provided to represent the access levels: | |
| 9 | 9 | ||
| 10 | - * ``gitlab.GUEST_ACCESS``: ``10`` | ||
| 11 | - * ``gitlab.REPORTER_ACCESS``: ``20`` | ||
| 12 | - * ``gitlab.DEVELOPER_ACCESS``: ``30`` | ||
| 13 | - * ``gitlab.MAINTAINER_ACCESS``: ``40`` | ||
| 14 | - * ``gitlab.OWNER_ACCESS``: ``50`` | ||
| 10 | + * ``gitlab.const.GUEST_ACCESS``: ``10`` | ||
| 11 | + * ``gitlab.const.REPORTER_ACCESS``: ``20`` | ||
| 12 | + * ``gitlab.const.DEVELOPER_ACCESS``: ``30`` | ||
| 13 | + * ``gitlab.const.MAINTAINER_ACCESS``: ``40`` | ||
| 14 | + * ``gitlab.const.OWNER_ACCESS``: ``50`` | ||
| 15 | 15 | ||
| 16 | 16 | References | |
| 17 | 17 | ---------- | |
@@ -43,7 +43,7 @@ Create an access request:: | |||
| 43 | 43 | Approve an access request:: | |
| 44 | 44 | ||
| 45 | 45 | ar.approve() # defaults to DEVELOPER level | |
| 46 | - ar.approve(access_level=gitlab.MAINTAINER_ACCESS) # explicitly set access level | ||
| 46 | + ar.approve(access_level=gitlab.const.MAINTAINER_ACCESS) # explicitly set access level | ||
| 47 | 47 | ||
| 48 | 48 | Deny (delete) an access request:: | |
| 49 | 49 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -80,7 +80,7 @@ Remove a group:: | |||
| 80 | 80 | ||
| 81 | 81 | Share/unshare the group with a group:: | |
| 82 | 82 | ||
| 83 | - group.share(group2.id, gitlab.DEVELOPER_ACCESS) | ||
| 83 | + group.share(group2.id, gitlab.const.DEVELOPER_ACCESS) | ||
| 84 | 84 | group.unshare(group2.id) | |
| 85 | 85 | ||
| 86 | 86 | Import / Export | |
@@ -237,11 +237,11 @@ Group members | |||
| 237 | 237 | ||
| 238 | 238 | The following constants define the supported access levels: | |
| 239 | 239 | ||
| 240 | - * ``gitlab.GUEST_ACCESS = 10`` | ||
| 241 | - * ``gitlab.REPORTER_ACCESS = 20`` | ||
| 242 | - * ``gitlab.DEVELOPER_ACCESS = 30`` | ||
| 243 | - * ``gitlab.MAINTAINER_ACCESS = 40`` | ||
| 244 | - * ``gitlab.OWNER_ACCESS = 50`` | ||
| 240 | + * ``gitlab.const.GUEST_ACCESS = 10`` | ||
| 241 | + * ``gitlab.const.REPORTER_ACCESS = 20`` | ||
| 242 | + * ``gitlab.const.DEVELOPER_ACCESS = 30`` | ||
| 243 | + * ``gitlab.const.MAINTAINER_ACCESS = 40`` | ||
| 244 | + * ``gitlab.const.OWNER_ACCESS = 50`` | ||
| 245 | 245 | ||
| 246 | 246 | Reference | |
| 247 | 247 | --------- | |
@@ -284,11 +284,11 @@ Get a member of a group, including members inherited through ancestor groups:: | |||
| 284 | 284 | Add a member to the group:: | |
| 285 | 285 | ||
| 286 | 286 | member = group.members.create({'user_id': user_id, | |
| 287 | - 'access_level': gitlab.GUEST_ACCESS}) | ||
| 287 | + 'access_level': gitlab.const.GUEST_ACCESS}) | ||
| 288 | 288 | ||
| 289 | 289 | Update a member (change the access level):: | |
| 290 | 290 | ||
| 291 | - member.access_level = gitlab.DEVELOPER_ACCESS | ||
| 291 | + member.access_level = gitlab.const.DEVELOPER_ACCESS | ||
| 292 | 292 | member.save() | |
| 293 | 293 | ||
| 294 | 294 | Remove a member from the group:: | |
@@ -316,7 +316,7 @@ LDAP group links | |||
| 316 | 316 | ||
| 317 | 317 | Add an LDAP group link to an existing GitLab group:: | |
| 318 | 318 | ||
| 319 | - group.add_ldap_group_link(ldap_group_cn, gitlab.DEVELOPER_ACCESS, 'ldapmain') | ||
| 319 | + group.add_ldap_group_link(ldap_group_cn, gitlab.const.DEVELOPER_ACCESS, 'ldapmain') | ||
| 320 | 320 | ||
| 321 | 321 | Remove a link:: | |
| 322 | 322 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,12 +5,12 @@ Notification settings | |||
| 5 | 5 | You can define notification settings globally, for groups and for projects. | |
| 6 | 6 | Valid levels are defined as constants: | |
| 7 | 7 | ||
| 8 | - * ``gitlab.NOTIFICATION_LEVEL_DISABLED`` | ||
| 9 | - * ``gitlab.NOTIFICATION_LEVEL_PARTICIPATING`` | ||
| 10 | - * ``gitlab.NOTIFICATION_LEVEL_WATCH`` | ||
| 11 | - * ``gitlab.NOTIFICATION_LEVEL_GLOBAL`` | ||
| 12 | - * ``gitlab.NOTIFICATION_LEVEL_MENTION`` | ||
| 13 | - * ``gitlab.NOTIFICATION_LEVEL_CUSTOM`` | ||
| 8 | + * ``gitlab.const.NOTIFICATION_LEVEL_DISABLED`` | ||
| 9 | + * ``gitlab.const.NOTIFICATION_LEVEL_PARTICIPATING`` | ||
| 10 | + * ``gitlab.const.NOTIFICATION_LEVEL_WATCH`` | ||
| 11 | + * ``gitlab.const.NOTIFICATION_LEVEL_GLOBAL`` | ||
| 12 | + * ``gitlab.const.NOTIFICATION_LEVEL_MENTION`` | ||
| 13 | + * ``gitlab.const.NOTIFICATION_LEVEL_CUSTOM`` | ||
| 14 | 14 | ||
| 15 | 15 | You get access to fine-grained settings if you use the | |
| 16 | 16 | ``NOTIFICATION_LEVEL_CUSTOM`` level. | |
@@ -47,10 +47,10 @@ Get the notifications settings:: | |||
| 47 | 47 | Update the notifications settings:: | |
| 48 | 48 | ||
| 49 | 49 | # use a predefined level | |
| 50 | - settings.level = gitlab.NOTIFICATION_LEVEL_WATCH | ||
| 50 | + settings.level = gitlab.const.NOTIFICATION_LEVEL_WATCH | ||
| 51 | 51 | ||
| 52 | 52 | # create a custom setup | |
| 53 | - settings.level = gitlab.NOTIFICATION_LEVEL_CUSTOM | ||
| 53 | + settings.level = gitlab.const.NOTIFICATION_LEVEL_CUSTOM | ||
| 54 | 54 | settings.save() # will create additional attributes, but not mandatory | |
| 55 | 55 | ||
| 56 | 56 | settings.new_merge_request = True | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -439,9 +439,9 @@ Project snippets | |||
| 439 | 439 | ||
| 440 | 440 | The snippet visibility can be defined using the following constants: | |
| 441 | 441 | ||
| 442 | - * ``gitlab.VISIBILITY_PRIVATE`` | ||
| 443 | - * ``gitlab.VISIBILITY_INTERNAL`` | ||
| 444 | - * ``gitlab.VISIBILITY_PUBLIC`` | ||
| 442 | + * ``gitlab.const.VISIBILITY_PRIVATE`` | ||
| 443 | + * ``gitlab.const.VISIBILITY_INTERNAL`` | ||
| 444 | + * ``gitlab.const.VISIBILITY_PUBLIC`` | ||
| 445 | 445 | ||
| 446 | 446 | Reference | |
| 447 | 447 | --------- | |
@@ -480,7 +480,7 @@ Create a snippet:: | |||
| 480 | 480 | 'file_name': 'foo.py', | |
| 481 | 481 | 'code': 'import gitlab', | |
| 482 | 482 | 'visibility_level': | |
| 483 | - gitlab.VISIBILITY_PRIVATE}) | ||
| 483 | + gitlab.const.VISIBILITY_PRIVATE}) | ||
| 484 | 484 | ||
| 485 | 485 | Update a snippet:: | |
| 486 | 486 | ||
@@ -546,11 +546,11 @@ Get a member of a project, including members inherited through ancestor groups:: | |||
| 546 | 546 | Add a project member:: | |
| 547 | 547 | ||
| 548 | 548 | member = project.members.create({'user_id': user.id, 'access_level': | |
| 549 | - gitlab.DEVELOPER_ACCESS}) | ||
| 549 | + gitlab.const.DEVELOPER_ACCESS}) | ||
| 550 | 550 | ||
| 551 | 551 | Modify a project member (change the access level):: | |
| 552 | 552 | ||
| 553 | - member.access_level = gitlab.MAINTAINER_ACCESS | ||
| 553 | + member.access_level = gitlab.const.MAINTAINER_ACCESS | ||
| 554 | 554 | member.save() | |
| 555 | 555 | ||
| 556 | 556 | Remove a member from the project team:: | |
@@ -561,7 +561,7 @@ Remove a member from the project team:: | |||
| 561 | 561 | ||
| 562 | 562 | Share/unshare the project with a group:: | |
| 563 | 563 | ||
| 564 | - project.share(group.id, gitlab.DEVELOPER_ACCESS) | ||
| 564 | + project.share(group.id, gitlab.const.DEVELOPER_ACCESS) | ||
| 565 | 565 | project.unshare(group.id) | |
| 566 | 566 | ||
| 567 | 567 | Project hooks | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,8 +31,8 @@ Create a protected branch:: | |||
| 31 | 31 | ||
| 32 | 32 | p_branch = project.protectedbranches.create({ | |
| 33 | 33 | 'name': '*-stable', | |
| 34 | - 'merge_access_level': gitlab.DEVELOPER_ACCESS, | ||
| 35 | - 'push_access_level': gitlab.MAINTAINER_ACCESS | ||
| 34 | + 'merge_access_level': gitlab.const.DEVELOPER_ACCESS, | ||
| 35 | + 'push_access_level': gitlab.const.MAINTAINER_ACCESS | ||
| 36 | 36 | }) | |
| 37 | 37 | ||
| 38 | 38 | Create a protected branch with more granular access control:: | |
@@ -41,7 +41,7 @@ Create a protected branch with more granular access control:: | |||
| 41 | 41 | 'name': '*-stable', | |
| 42 | 42 | 'allowed_to_push': [{"user_id": 99}, {"user_id": 98}], | |
| 43 | 43 | 'allowed_to_merge': [{"group_id": 653}], | |
| 44 | - 'allowed_to_unprotect': [{"access_level": gitlab.MAINTAINER_ACCESS}] | ||
| 44 | + 'allowed_to_unprotect': [{"access_level": gitlab.const.MAINTAINER_ACCESS}] | ||
| 45 | 45 | }) | |
| 46 | 46 | ||
| 47 | 47 | Delete a protected branch:: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,24 +9,24 @@ string. The following constants are provided to represent the possible scopes: | |||
| 9 | 9 | ||
| 10 | 10 | * Shared scopes (global, group and project): | |
| 11 | 11 | ||
| 12 | - + ``gitlab.SEARCH_SCOPE_PROJECTS``: ``projects`` | ||
| 13 | - + ``gitlab.SEARCH_SCOPE_ISSUES``: ``issues`` | ||
| 14 | - + ``gitlab.SEARCH_SCOPE_MERGE_REQUESTS``: ``merge_requests`` | ||
| 15 | - + ``gitlab.SEARCH_SCOPE_MILESTONES``: ``milestones`` | ||
| 16 | - + ``gitlab.SEARCH_SCOPE_WIKI_BLOBS``: ``wiki_blobs`` | ||
| 17 | - + ``gitlab.SEARCH_SCOPE_COMMITS``: ``commits`` | ||
| 18 | - + ``gitlab.SEARCH_SCOPE_BLOBS``: ``blobs`` | ||
| 19 | - + ``gitlab.SEARCH_SCOPE_USERS``: ``users`` | ||
| 12 | + + ``gitlab.const.SEARCH_SCOPE_PROJECTS``: ``projects`` | ||
| 13 | + + ``gitlab.const.SEARCH_SCOPE_ISSUES``: ``issues`` | ||
| 14 | + + ``gitlab.const.SEARCH_SCOPE_MERGE_REQUESTS``: ``merge_requests`` | ||
| 15 | + + ``gitlab.const.SEARCH_SCOPE_MILESTONES``: ``milestones`` | ||
| 16 | + + ``gitlab.const.SEARCH_SCOPE_WIKI_BLOBS``: ``wiki_blobs`` | ||
| 17 | + + ``gitlab.const.SEARCH_SCOPE_COMMITS``: ``commits`` | ||
| 18 | + + ``gitlab.const.SEARCH_SCOPE_BLOBS``: ``blobs`` | ||
| 19 | + + ``gitlab.const.SEARCH_SCOPE_USERS``: ``users`` | ||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | 22 | * specific global scope: | |
| 23 | 23 | ||
| 24 | - + ``gitlab.SEARCH_SCOPE_GLOBAL_SNIPPET_TITLES``: ``snippet_titles`` | ||
| 24 | + + ``gitlab.const.SEARCH_SCOPE_GLOBAL_SNIPPET_TITLES``: ``snippet_titles`` | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | 27 | * specific project scope: | |
| 28 | 28 | ||
| 29 | - + ``gitlab.SEARCH_SCOPE_PROJECT_NOTES``: ``notes`` | ||
| 29 | + + ``gitlab.const.SEARCH_SCOPE_PROJECT_NOTES``: ``notes`` | ||
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | 32 | Reference | |
@@ -46,30 +46,30 @@ Examples | |||
| 46 | 46 | Search for issues matching a specific string:: | |
| 47 | 47 | ||
| 48 | 48 | # global search | |
| 49 | - gl.search(gitlab.SEARCH_SCOPE_ISSUES, 'regression') | ||
| 49 | + gl.search(gitlab.const.SEARCH_SCOPE_ISSUES, 'regression') | ||
| 50 | 50 | ||
| 51 | 51 | # group search | |
| 52 | 52 | group = gl.groups.get('mygroup') | |
| 53 | - group.search(gitlab.SEARCH_SCOPE_ISSUES, 'regression') | ||
| 53 | + group.search(gitlab.const.SEARCH_SCOPE_ISSUES, 'regression') | ||
| 54 | 54 | ||
| 55 | 55 | # project search | |
| 56 | 56 | project = gl.projects.get('myproject') | |
| 57 | - project.search(gitlab.SEARCH_SCOPE_ISSUES, 'regression') | ||
| 57 | + project.search(gitlab.const.SEARCH_SCOPE_ISSUES, 'regression') | ||
| 58 | 58 | ||
| 59 | 59 | The ``search()`` methods implement the pagination support:: | |
| 60 | 60 | ||
| 61 | 61 | # get lists of 10 items, and start at page 2 | |
| 62 | - gl.search(gitlab.SEARCH_SCOPE_ISSUES, search_str, page=2, per_page=10) | ||
| 62 | + gl.search(gitlab.const.SEARCH_SCOPE_ISSUES, search_str, page=2, per_page=10) | ||
| 63 | 63 | ||
| 64 | 64 | # get a generator that will automatically make required API calls for | |
| 65 | 65 | # pagination | |
| 66 | - for item in gl.search(gitlab.SEARCH_SCOPE_ISSUES, search_str, as_list=False): | ||
| 66 | + for item in gl.search(gitlab.const.SEARCH_SCOPE_ISSUES, search_str, as_list=False): | ||
| 67 | 67 | do_something(item) | |
| 68 | 68 | ||
| 69 | 69 | The search API doesn't return objects, but dicts. If you need to act on | |
| 70 | 70 | objects, you need to create them explicitly:: | |
| 71 | 71 | ||
| 72 | - for item in gl.search(gitlab.SEARCH_SCOPE_ISSUES, search_str, as_list=False): | ||
| 72 | + for item in gl.search(gitlab.const.SEARCH_SCOPE_ISSUES, search_str, as_list=False): | ||
| 73 | 73 | issue_project = gl.projects.get(item['project_id'], lazy=True) | |
| 74 | 74 | issue = issue_project.issues.get(item['iid']) | |
| 75 | 75 | issue.state = 'closed' | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,7 +44,7 @@ Create a snippet:: | |||
| 44 | 44 | ||
| 45 | 45 | Update the snippet attributes:: | |
| 46 | 46 | ||
| 47 | - snippet.visibility_level = gitlab.VISIBILITY_PUBLIC | ||
| 47 | + snippet.visibility_level = gitlab.const.VISIBILITY_PUBLIC | ||
| 48 | 48 | snippet.save() | |
| 49 | 49 | ||
| 50 | 50 | To update a snippet code you need to create a ``ProjectSnippet`` object:: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments