Add API support for 'pages_access_level' for project features
What does this MR do?
I've been helping a user on the community forums with my little knowledge about the API and its internals. We've found out that e.g. wiki_access_level
is exposed via the API for project features, but apparently pages_access_level
is not. Actually its exposure within the API is not implemented. This MR implements the missing attribute, adds spec tests and updates the docs.
Issues to solve:
- #33880 (closed) is assigned to @eurie
- #30972 (closed) needs this MR to be completed.
Community Topic
Example with GitLab Python API
https://gitlab.com/dnsmichi/api-playground/tree/master/python
Preparations
pip install python-gitlab
vim $HOME/.python-gitlab.cfg
[global]
default = gitlab.com
[gitlab.com]
url = https://gitlab.com
private_token = xxx
api_version = 4
ssl_verify = true
Simple query
#!/usr/bin/env python
import gitlab
PROJECT_ID=15013654
gl = gitlab.Gitlab.from_config('gitlab.com', ['/Users/michi/.python-gitlab.cfg'])
print("Project attributes required for creation")
print(gl.projects.get_create_attrs())
project = gl.projects.get(PROJECT_ID)
print("All project attributes")
print(project.attributes)
print("Project attributes matching access_level")
for a in project.attributes:
if "access_level" in a:
print(a)
Tests
The last loop names it, the pages_access_level is not there, but the feature is actually there and enabled.
Project attributes matching access_level
builds_access_level
snippets_access_level
repository_access_level
issues_access_level
merge_requests_access_level
wiki_access_level
References
#33880 (closed) #30972 (closed)
Inspired by gitlab-foss!28327 (diffs)
Screenshots
Within Chrome's dev console, one can see the config form attribute names and use that as inspiration to grep the source code for this and other attributes.
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team