INNER CODE UNIT · Python
list_gitlab_projects
phasehq/console · backend/api/utils/syncing/gitlab/main.py:94
def list_gitlab_projects(credential_id):
"""
List all GitLab repositories the user has access to with CRUD permissions on CI/CD variables.
This function paginates through the GitLab API to fetch all projects accessible to the user.
It checks for project access levels to determine if the user can CRUD CI/CD variables.
"""
if not validate_auth(credential_id):
raise Exception(
"Could not authenticate with GitLab. Please check that your credentials are valid"
)
GITLAB_HOST, GITLAB_TOKEN = get_gitlab_credentials(credential_id)
GITLAB_PROJECTS_BASE_URL = f"{GITLAB_HOST}/api/v4/projects?membership=true&min_access_level=30&per_page=100"
headers = {"Private-Token": GITLAB_TOKEN}
url = f"{GITLAB_HOST}/api/v4/projects?membership=true&min_access_level=30&per_page=100"