Skip to content

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:

Community Topic

https://forum.gitlab.com/t/project-visibility-project-features-permissions-settings-api/32242/8?u=dnsmichi

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.

Screen_Shot_2019-12-06_at_21.56.29

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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

Merge request reports