diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a144b9725..c974f3a45 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -24,7 +24,7 @@ jobs: steps: - uses: actions/checkout@v4.2.2 - name: Set up Python - uses: actions/setup-python@v5.5.0 + uses: actions/setup-python@v5.6.0 with: python-version: "3.13" - name: Install dependencies @@ -39,7 +39,7 @@ jobs: steps: - uses: actions/checkout@v4.2.2 - name: Set up Python - uses: actions/setup-python@v5.5.0 + uses: actions/setup-python@v5.6.0 with: python-version: "3.13" - name: Install dependencies diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f2d3c57f0..d16f7fe09 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,7 +25,7 @@ jobs: - uses: actions/checkout@v4.2.2 with: fetch-depth: 0 - - uses: actions/setup-python@v5.5.0 + - uses: actions/setup-python@v5.6.0 with: python-version: "3.13" - run: pip install --upgrade tox diff --git a/.github/workflows/pre_commit.yml b/.github/workflows/pre_commit.yml index ae331e4bc..9fadeca81 100644 --- a/.github/workflows/pre_commit.yml +++ b/.github/workflows/pre_commit.yml @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.2.2 - - uses: actions/setup-python@v5.5.0 + - uses: actions/setup-python@v5.6.0 with: python-version: "3.13" - name: install tox diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 890b562b0..3acee16f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: - name: Python Semantic Release id: release - uses: python-semantic-release/python-semantic-release@v9.21.0 + uses: python-semantic-release/python-semantic-release@v10.1.0 with: github_token: ${{ secrets.RELEASE_GITHUB_TOKEN }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index cdfaee27b..e65835c30 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -20,16 +20,56 @@ jobs: stale-issue-label: "stale" stale-pr-label: "stale" - any-of-labels: 'need info,Waiting for response,stale' + # If an issue/PR has an assignee it won't be marked as stale + exempt-all-assignees: true stale-issue-message: > - This issue was marked stale because it has been open 60 days with no - activity. Please remove the stale label or comment on this issue. Otherwise, - it will be closed in 15 days. + This issue was marked stale because it has been open 60 days with + no activity. Please remove the stale label or comment on this + issue. Otherwise, it will be closed in 15 days. + + As an open-source project, we rely on community contributions to + address many of the reported issues. Without a proposed fix or + active work towards a solution it is our policy to close inactive + issues. This is documented in CONTRIBUTING.rst + + **How to keep this issue open:** + * If you are still experiencing this issue and are willing to + investigate a fix, please comment and let us know. + * If you (or someone else) can propose a pull request with a + solution, that would be fantastic. + * Any significant update or active discussion indicating progress + will also prevent closure. + + We value your input. If you can help provide a fix, we'd be happy + to keep this issue open and support your efforts. + days-before-issue-stale: 60 days-before-issue-close: 15 close-issue-message: > - This issue was closed because it has been marked stale for 15 days with no - activity. If this issue is still valid, please re-open. + This issue was closed because it has been marked stale for 15 days + with no activity. + + This open-source project relies on community contributions, and + while we value all feedback, we have a limited capacity to address + every issue without a clear path forward. + + Currently, this issue hasn't received a proposed fix, and there + hasn't been recent active discussion indicating someone is planning + to work on it. To maintain a manageable backlog and focus our + efforts, we will be closing this issue for now. + + **This doesn't mean the issue isn't valid or important.** If you or + anyone else in the community is willing to investigate and propose + a solution (e.g., by submitting a pull request), please do. + + We believe that those who feel a bug is important enough to fix + should ideally be part of the solution. Your contributions are + highly welcome. + + Thank you for your understanding and potential future + contributions. + + This is documented in CONTRIBUTING.rst stale-pr-message: > This Pull Request (PR) was marked stale because it has been open 90 days @@ -40,4 +80,3 @@ jobs: close-pr-message: > This PR was closed because it has been marked stale for 15 days with no activity. If this PR is still valid, please re-open. - diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2ce6a33d0..17d514b11 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,7 +50,7 @@ jobs: steps: - uses: actions/checkout@v4.2.2 - name: Set up Python ${{ matrix.python.version }} - uses: actions/setup-python@v5.5.0 + uses: actions/setup-python@v5.6.0 with: python-version: ${{ matrix.python.version }} - name: Install dependencies @@ -69,7 +69,7 @@ jobs: steps: - uses: actions/checkout@v4.2.2 - name: Set up Python - uses: actions/setup-python@v5.5.0 + uses: actions/setup-python@v5.6.0 with: python-version: "3.13" - name: Install dependencies @@ -79,7 +79,7 @@ jobs: TOXENV: ${{ matrix.toxenv }} run: tox -- --override-ini='log_cli=True' - name: Upload codecov coverage - uses: codecov/codecov-action@v5.4.0 + uses: codecov/codecov-action@v5.4.3 with: files: ./coverage.xml flags: ${{ matrix.toxenv }} @@ -91,7 +91,7 @@ jobs: steps: - uses: actions/checkout@v4.2.2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5.5.0 + uses: actions/setup-python@v5.6.0 with: python-version: "3.13" - name: Install dependencies @@ -102,7 +102,7 @@ jobs: TOXENV: cover run: tox - name: Upload codecov coverage - uses: codecov/codecov-action@v5.4.0 + uses: codecov/codecov-action@v5.4.3 with: files: ./coverage.xml flags: unit @@ -114,7 +114,7 @@ jobs: name: Python wheel steps: - uses: actions/checkout@v4.2.2 - - uses: actions/setup-python@v5.5.0 + - uses: actions/setup-python@v5.6.0 with: python-version: "3.13" - name: Install dependencies @@ -133,10 +133,10 @@ jobs: steps: - uses: actions/checkout@v4.2.2 - name: Set up Python - uses: actions/setup-python@v5.5.0 + uses: actions/setup-python@v5.6.0 with: python-version: '3.13' - - uses: actions/download-artifact@v4.2.1 + - uses: actions/download-artifact@v4.3.0 with: name: dist path: dist diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4cc11b7cd..3dda94ccf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: hooks: - id: black - repo: https://github.com/commitizen-tools/commitizen - rev: v4.5.0 + rev: v4.8.3 hooks: - id: commitizen stages: [commit-msg] @@ -20,7 +20,7 @@ repos: hooks: - id: isort - repo: https://github.com/pycqa/pylint - rev: v3.3.6 + rev: v3.3.7 hooks: - id: pylint additional_dependencies: @@ -32,7 +32,7 @@ repos: - requests-toolbelt==1.0.0 files: 'gitlab/' - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.15.0 + rev: v1.16.0 hooks: - id: mypy args: [] @@ -51,6 +51,6 @@ repos: - id: rst-directive-colons - id: rst-inline-touching-normal - repo: https://github.com/maxbrunet/pre-commit-renovate - rev: 39.227.2 + rev: 40.57.1 hooks: - id: renovate-config-validator diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 90c6c1e70..9b07ada11 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -9,6 +9,42 @@ You can contribute to the project in multiple ways: * Add unit and functional tests * Everything else you can think of +Issue Management and Our Approach to Contributions +-------------------------------------------------- + +We value every contribution and bug report. However, as an open-source project +with limited maintainer resources, we rely heavily on the community to help us +move forward. + +**Our Policy on Inactive Issues:** + +To keep our issue tracker manageable and focused on actionable items, we have +the following approach: + +* **We encourage reporters to propose solutions:** If you report an issue, we + strongly encourage you to also think about how it might be fixed and try to + implement that fix. +* **Community interest is key:** Issues that garner interest from the community + (e.g., multiple users confirming, discussions on solutions, offers to help) + are more likely to be addressed. +* **Closing inactive issues:** If an issue report doesn't receive a proposed + fix from the original reporter or anyone else in the community, and there's + no active discussion or indication that someone is willing to work on it + after a reasonable period, it may be closed. + + * When closing such an issue, we will typically leave a comment explaining + that it's being closed due to inactivity and a lack of a proposed fix. + +* **Reopening issues:** This doesn't mean the issue isn't valid. If you (or + someone else) are interested in working on a fix for a closed issue, please + comment on the issue. We are more than happy to reopen it and discuss your + proposed pull request or solution. We greatly appreciate it when community + members take ownership of fixing issues they care about. + +We believe this approach helps us focus our efforts effectively and empowers +the community to contribute directly to the areas they are most passionate +about. + Development workflow -------------------- diff --git a/docs/api-usage-graphql.rst b/docs/api-usage-graphql.rst index 539b7ca3d..d20aeeef1 100644 --- a/docs/api-usage-graphql.rst +++ b/docs/api-usage-graphql.rst @@ -49,12 +49,12 @@ Get the result of a query: .. code-block:: python - query = """{ - query { - currentUser { + query = """ + { + currentUser { name - } } + } """ result = gq.execute(query) @@ -63,12 +63,12 @@ Get the result of a query using the async client: .. code-block:: python - query = """{ - query { - currentUser { + query = """ + { + currentUser { name - } } + } """ result = await async_gq.execute(query) diff --git a/docs/api-usage.rst b/docs/api-usage.rst index eca02d483..38836f20f 100644 --- a/docs/api-usage.rst +++ b/docs/api-usage.rst @@ -16,7 +16,7 @@ To connect to GitLab.com or another GitLab instance, create a ``gitlab.Gitlab`` access token. For the full list of available options and how to obtain these tokens, please see - https://docs.gitlab.com/ee/api/rest/authentication.html. + https://docs.gitlab.com/api/rest/authentication/. .. code-block:: python @@ -39,7 +39,7 @@ To connect to GitLab.com or another GitLab instance, create a ``gitlab.Gitlab`` # job token authentication (to be used in CI) # bear in mind the limitations of the API endpoints it supports: - # https://docs.gitlab.com/ee/ci/jobs/ci_job_token.html + # https://docs.gitlab.com/ci/jobs/ci_job_token import os gl = gitlab.Gitlab('https://gitlab.example.com', job_token=os.environ['CI_JOB_TOKEN']) @@ -83,7 +83,7 @@ Note on password authentication ------------------------------- GitLab has long removed password-based basic authentication. You can currently still use the -`resource owner password credentials `_ +`resource owner password credentials `_ flow to obtain an OAuth token. However, we do not recommend this as it will not work with 2FA enabled, and GitLab is removing @@ -364,7 +364,7 @@ order options. At the time of writing, only ``order_by="id"`` works. gl.projects.list(get_all=True) Reference: -https://docs.gitlab.com/ce/api/README.html#keyset-based-pagination +https://docs.gitlab.com/api/rest/#keyset-based-pagination ``list()`` methods can also return a generator object, by passing the argument ``iterator=True``, which will handle the next calls to the API when required. This @@ -392,7 +392,7 @@ The generator exposes extra listing information as received from the server: ``total_pages`` and ``total`` will have a value of ``None``. For more information see: - https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers + https://docs.gitlab.com/user/gitlab_com/index#pagination-response-headers .. note:: Prior to python-gitlab 3.6.0 the argument ``as_list`` was used instead of diff --git a/docs/cli-usage.rst b/docs/cli-usage.rst index 0be22f5e2..d56388e37 100644 --- a/docs/cli-usage.rst +++ b/docs/cli-usage.rst @@ -165,14 +165,14 @@ We recommend that you use `Credential helpers`_ to securely store your tokens. * - ``private_token`` - Your user token. Login/password is not supported. Refer to `the official documentation - `__ + `__ to learn how to obtain a token. * - ``oauth_token`` - An Oauth token for authentication. The Gitlab server must be configured to support this authentication method. * - ``job_token`` - Your job token. See `the official documentation - `__ + `__ to learn how to obtain a token. * - ``api_version`` - GitLab API version to use. Only ``4`` is available since 1.5.0. diff --git a/docs/gl_objects/access_requests.rst b/docs/gl_objects/access_requests.rst index 339c7d172..c997fe0d7 100644 --- a/docs/gl_objects/access_requests.rst +++ b/docs/gl_objects/access_requests.rst @@ -25,7 +25,7 @@ References + :class:`gitlab.v4.objects.GroupAccessRequestManager` + :attr:`gitlab.v4.objects.Group.accessrequests` -* GitLab API: https://docs.gitlab.com/ce/api/access_requests.html +* GitLab API: https://docs.gitlab.com/api/access_requests Examples -------- diff --git a/docs/gl_objects/appearance.rst b/docs/gl_objects/appearance.rst index 0c0526817..611413d73 100644 --- a/docs/gl_objects/appearance.rst +++ b/docs/gl_objects/appearance.rst @@ -11,7 +11,7 @@ Reference + :class:`gitlab.v4.objects.ApplicationAppearanceManager` + :attr:`gitlab.Gitlab.appearance` -* GitLab API: https://docs.gitlab.com/ce/api/appearance.html +* GitLab API: https://docs.gitlab.com/api/appearance Examples -------- diff --git a/docs/gl_objects/applications.rst b/docs/gl_objects/applications.rst index 24de3b2ba..fea051b25 100644 --- a/docs/gl_objects/applications.rst +++ b/docs/gl_objects/applications.rst @@ -11,7 +11,7 @@ Reference + :class:`gitlab.v4.objects.ApplicationManager` + :attr:`gitlab.Gitlab.applications` -* GitLab API: https://docs.gitlab.com/ce/api/applications.html +* GitLab API: https://docs.gitlab.com/api/applications Examples -------- diff --git a/docs/gl_objects/badges.rst b/docs/gl_objects/badges.rst index 0f650d460..c84308032 100644 --- a/docs/gl_objects/badges.rst +++ b/docs/gl_objects/badges.rst @@ -18,8 +18,8 @@ Reference * GitLab API: - + https://docs.gitlab.com/ce/api/group_badges.html - + https://docs.gitlab.com/ce/api/project_badges.html + + https://docs.gitlab.com/api/group_badges + + https://docs.gitlab.com/api/project_badges Examples -------- diff --git a/docs/gl_objects/boards.rst b/docs/gl_objects/boards.rst index abab5b91b..5031e4bd5 100644 --- a/docs/gl_objects/boards.rst +++ b/docs/gl_objects/boards.rst @@ -23,8 +23,8 @@ Reference * GitLab API: - + https://docs.gitlab.com/ce/api/boards.html - + https://docs.gitlab.com/ce/api/group_boards.html + + https://docs.gitlab.com/api/boards + + https://docs.gitlab.com/api/group_boards Examples -------- @@ -72,8 +72,8 @@ Reference * GitLab API: - + https://docs.gitlab.com/ce/api/boards.html - + https://docs.gitlab.com/ce/api/group_boards.html + + https://docs.gitlab.com/api/boards + + https://docs.gitlab.com/api/group_boards Examples -------- diff --git a/docs/gl_objects/branches.rst b/docs/gl_objects/branches.rst index 1c0d89d0b..823d98b85 100644 --- a/docs/gl_objects/branches.rst +++ b/docs/gl_objects/branches.rst @@ -11,7 +11,7 @@ References + :class:`gitlab.v4.objects.ProjectBranchManager` + :attr:`gitlab.v4.objects.Project.branches` -* GitLab API: https://docs.gitlab.com/ce/api/branches.html +* GitLab API: https://docs.gitlab.com/api/branches Examples -------- diff --git a/docs/gl_objects/bulk_imports.rst b/docs/gl_objects/bulk_imports.rst index b5b3ef89c..6b1458a13 100644 --- a/docs/gl_objects/bulk_imports.rst +++ b/docs/gl_objects/bulk_imports.rst @@ -17,7 +17,7 @@ References + :class:`gitlab.v4.objects.BulkImportEntityManager` + :attr:`gitlab.v4.objects.BulkImport.entities` -* GitLab API: https://docs.gitlab.com/ee/api/bulk_imports.html +* GitLab API: https://docs.gitlab.com/api/bulk_imports Examples -------- diff --git a/docs/gl_objects/ci_lint.rst b/docs/gl_objects/ci_lint.rst index ad2d875e9..b44b09486 100644 --- a/docs/gl_objects/ci_lint.rst +++ b/docs/gl_objects/ci_lint.rst @@ -14,7 +14,7 @@ Reference + :class:`gitlab.v4.objects.ProjectCiLintManager` + :attr:`gitlab.v4.objects.Project.ci_lint` -* GitLab API: https://docs.gitlab.com/ee/api/lint.html +* GitLab API: https://docs.gitlab.com/api/lint Examples --------- diff --git a/docs/gl_objects/cluster_agents.rst b/docs/gl_objects/cluster_agents.rst index 9e050b1ed..b9810959d 100644 --- a/docs/gl_objects/cluster_agents.rst +++ b/docs/gl_objects/cluster_agents.rst @@ -17,7 +17,7 @@ Reference + :class:`gitlab.v4.objects.ProjectClusterAgentManager` + :attr:`gitlab.v4.objects.Project.cluster_agents` -* GitLab API: https://docs.gitlab.com/ee/api/cluster_agents.html +* GitLab API: https://docs.gitlab.com/api/cluster_agents Examples -------- diff --git a/docs/gl_objects/clusters.rst b/docs/gl_objects/clusters.rst index 14b64818c..7cf413bc2 100644 --- a/docs/gl_objects/clusters.rst +++ b/docs/gl_objects/clusters.rst @@ -19,8 +19,8 @@ Reference + :class:`gitlab.v4.objects.GroupClusterManager` + :attr:`gitlab.v4.objects.Group.clusters` -* GitLab API: https://docs.gitlab.com/ee/api/project_clusters.html -* GitLab API: https://docs.gitlab.com/ee/api/group_clusters.html +* GitLab API: https://docs.gitlab.com/api/project_clusters +* GitLab API: https://docs.gitlab.com/api/group_clusters Examples -------- diff --git a/docs/gl_objects/commits.rst b/docs/gl_objects/commits.rst index c810442c8..0c612f3de 100644 --- a/docs/gl_objects/commits.rst +++ b/docs/gl_objects/commits.rst @@ -33,7 +33,7 @@ List all commits for a project (see :ref:`pagination`) on all branches: Create a commit:: - # See https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions + # See https://docs.gitlab.com/api/commits#create-a-commit-with-multiple-files-and-actions # for actions detail data = { 'branch': 'main', @@ -98,7 +98,7 @@ Reference + :class:`gitlab.v4.objects.ProjectCommitCommentManager` + :attr:`gitlab.v4.objects.ProjectCommit.comments` -* GitLab API: https://docs.gitlab.com/ce/api/commits.html +* GitLab API: https://docs.gitlab.com/api/commits Examples -------- @@ -129,7 +129,7 @@ Reference + :class:`gitlab.v4.objects.ProjectCommitStatusManager` + :attr:`gitlab.v4.objects.ProjectCommit.statuses` -* GitLab API: https://docs.gitlab.com/ce/api/commits.html +* GitLab API: https://docs.gitlab.com/api/commits Examples -------- diff --git a/docs/gl_objects/deploy_keys.rst b/docs/gl_objects/deploy_keys.rst index 65fa01a3d..9f91fea0f 100644 --- a/docs/gl_objects/deploy_keys.rst +++ b/docs/gl_objects/deploy_keys.rst @@ -14,7 +14,7 @@ Reference + :class:`gitlab.v4.objects.DeployKeyManager` + :attr:`gitlab.Gitlab.deploykeys` -* GitLab API: https://docs.gitlab.com/ce/api/deploy_keys.html +* GitLab API: https://docs.gitlab.com/api/deploy_keys Examples -------- @@ -41,7 +41,7 @@ Reference + :class:`gitlab.v4.objects.ProjectKeyManager` + :attr:`gitlab.v4.objects.Project.keys` -* GitLab API: https://docs.gitlab.com/ce/api/deploy_keys.html +* GitLab API: https://docs.gitlab.com/api/deploy_keys Examples -------- diff --git a/docs/gl_objects/deploy_tokens.rst b/docs/gl_objects/deploy_tokens.rst index 8f06254d2..80c00803a 100644 --- a/docs/gl_objects/deploy_tokens.rst +++ b/docs/gl_objects/deploy_tokens.rst @@ -19,7 +19,7 @@ Reference + :class:`gitlab.v4.objects.DeployTokenManager` + :attr:`gitlab.Gitlab.deploytokens` -* GitLab API: https://docs.gitlab.com/ce/api/deploy_tokens.html +* GitLab API: https://docs.gitlab.com/api/deploy_tokens Examples -------- @@ -45,7 +45,7 @@ Reference + :class:`gitlab.v4.objects.ProjectDeployTokenManager` + :attr:`gitlab.v4.objects.Project.deploytokens` -* GitLab API: https://docs.gitlab.com/ce/api/deploy_tokens.html#project-deploy-tokens +* GitLab API: https://docs.gitlab.com/api/deploy_tokens#project-deploy-tokens Examples -------- @@ -102,7 +102,7 @@ Reference + :class:`gitlab.v4.objects.GroupDeployTokenManager` + :attr:`gitlab.v4.objects.Group.deploytokens` -* GitLab API: https://docs.gitlab.com/ce/api/deploy_tokens.html#group-deploy-tokens +* GitLab API: https://docs.gitlab.com/api/deploy_tokens#group-deploy-tokens Examples -------- diff --git a/docs/gl_objects/deployments.rst b/docs/gl_objects/deployments.rst index 10de426c2..4be927af7 100644 --- a/docs/gl_objects/deployments.rst +++ b/docs/gl_objects/deployments.rst @@ -11,7 +11,7 @@ Reference + :class:`gitlab.v4.objects.ProjectDeploymentManager` + :attr:`gitlab.v4.objects.Project.deployments` -* GitLab API: https://docs.gitlab.com/ce/api/deployments.html +* GitLab API: https://docs.gitlab.com/api/deployments Examples -------- @@ -64,7 +64,7 @@ Reference + :class:`gitlab.v4.objects.ProjectDeploymentMergeRequestManager` + :attr:`gitlab.v4.objects.ProjectDeployment.mergerequests` -* GitLab API: https://docs.gitlab.com/ee/api/deployments.html#list-of-merge-requests-associated-with-a-deployment +* GitLab API: https://docs.gitlab.com/api/deployments#list-of-merge-requests-associated-with-a-deployment Examples -------- diff --git a/docs/gl_objects/discussions.rst b/docs/gl_objects/discussions.rst index 6d493044b..f64a98b3d 100644 --- a/docs/gl_objects/discussions.rst +++ b/docs/gl_objects/discussions.rst @@ -37,7 +37,7 @@ Reference + :class:`gitlab.v4.objects.ProjectSnippetDiscussionNoteManager` + :attr:`gitlab.v4.objects.ProjectSnippet.notes` -* GitLab API: https://docs.gitlab.com/ce/api/discussions.html +* GitLab API: https://docs.gitlab.com/api/discussions Examples ======== diff --git a/docs/gl_objects/draft_notes.rst b/docs/gl_objects/draft_notes.rst index 5cc84eeb2..8f33de6e6 100644 --- a/docs/gl_objects/draft_notes.rst +++ b/docs/gl_objects/draft_notes.rst @@ -18,7 +18,7 @@ Reference + :attr:`gitlab.v4.objects.ProjectMergeRequest.draft_notes` -* GitLab API: https://docs.gitlab.com/ee/api/draft_notes.html +* GitLab API: https://docs.gitlab.com/api/draft_notes Examples -------- diff --git a/docs/gl_objects/emojis.rst b/docs/gl_objects/emojis.rst index f19f3b1d0..1675916e1 100644 --- a/docs/gl_objects/emojis.rst +++ b/docs/gl_objects/emojis.rst @@ -21,7 +21,7 @@ Reference + :class:`gitlab.v4.objects.ProjectSnippetNoteAwardEmojiManager` -* GitLab API: https://docs.gitlab.com/ce/api/award_emoji.html +* GitLab API: https://docs.gitlab.com/api/emoji_reactions/ Examples -------- diff --git a/docs/gl_objects/environments.rst b/docs/gl_objects/environments.rst index 164a9c9a0..382820b76 100644 --- a/docs/gl_objects/environments.rst +++ b/docs/gl_objects/environments.rst @@ -11,7 +11,7 @@ Reference + :class:`gitlab.v4.objects.ProjectEnvironmentManager` + :attr:`gitlab.v4.objects.Project.environments` -* GitLab API: https://docs.gitlab.com/ce/api/environments.html +* GitLab API: https://docs.gitlab.com/api/environments Examples -------- diff --git a/docs/gl_objects/epics.rst b/docs/gl_objects/epics.rst index 33ef2b848..7e43aaa8e 100644 --- a/docs/gl_objects/epics.rst +++ b/docs/gl_objects/epics.rst @@ -14,7 +14,7 @@ Reference + :class:`gitlab.v4.objects.GroupEpicManager` + :attr:`gitlab.Gitlab.Group.epics` -* GitLab API: https://docs.gitlab.com/ee/api/epics.html (EE feature) +* GitLab API: https://docs.gitlab.com/api/epics (EE feature) Examples -------- @@ -53,7 +53,7 @@ Reference + :class:`gitlab.v4.objects.GroupEpicIssueManager` + :attr:`gitlab.Gitlab.GroupEpic.issues` -* GitLab API: https://docs.gitlab.com/ee/api/epic_issues.html (EE feature) +* GitLab API: https://docs.gitlab.com/api/epic_issues (EE feature) Examples -------- diff --git a/docs/gl_objects/events.rst b/docs/gl_objects/events.rst index 68a55b92f..108f6cedb 100644 --- a/docs/gl_objects/events.rst +++ b/docs/gl_objects/events.rst @@ -20,7 +20,7 @@ Reference + :class:`gitlab.v4.objects.UserEventManager` + :attr:`gitlab.v4.objects.User.events` -* GitLab API: https://docs.gitlab.com/ce/api/events.html +* GitLab API: https://docs.gitlab.com/api/events/ Examples -------- @@ -29,7 +29,7 @@ You can list events for an entire Gitlab instance (admin), users and projects. You can filter you events you want to retrieve using the ``action`` and ``target_type`` attributes. The possible values for these attributes are available on `the gitlab documentation -`_. +`_. List all the events (paginated):: @@ -58,7 +58,7 @@ Reference + :class:`gitlab.v4.objects.ProjectMergeRequestResourceStateEventManager` + :attr:`gitlab.v4.objects.ProjectMergeRequest.resourcestateevents` -* GitLab API: https://docs.gitlab.com/ee/api/resource_state_events.html +* GitLab API: https://docs.gitlab.com/api/resource_state_events Examples -------- diff --git a/docs/gl_objects/features.rst b/docs/gl_objects/features.rst index 6ed758e97..d7552041d 100644 --- a/docs/gl_objects/features.rst +++ b/docs/gl_objects/features.rst @@ -11,7 +11,7 @@ Reference + :class:`gitlab.v4.objects.FeatureManager` + :attr:`gitlab.Gitlab.features` -* GitLab API: https://docs.gitlab.com/ce/api/features.html +* GitLab API: https://docs.gitlab.com/api/features Examples -------- diff --git a/docs/gl_objects/geo_nodes.rst b/docs/gl_objects/geo_nodes.rst index 878798262..4eb1932ed 100644 --- a/docs/gl_objects/geo_nodes.rst +++ b/docs/gl_objects/geo_nodes.rst @@ -11,7 +11,7 @@ Reference + :class:`gitlab.v4.objects.GeoNodeManager` + :attr:`gitlab.Gitlab.geonodes` -* GitLab API: https://docs.gitlab.com/ee/api/geo_nodes.html (EE feature) +* GitLab API: https://docs.gitlab.com/api/geo_nodes (EE feature) Examples -------- diff --git a/docs/gl_objects/group_access_tokens.rst b/docs/gl_objects/group_access_tokens.rst index b3b0132d4..26c694e5b 100644 --- a/docs/gl_objects/group_access_tokens.rst +++ b/docs/gl_objects/group_access_tokens.rst @@ -13,7 +13,7 @@ References + :class:`gitlab.v4.objects.GroupAccessTokenManager` + :attr:`gitlab.Gitlab.group_access_tokens` -* GitLab API: https://docs.gitlab.com/ee/api/group_access_tokens.html +* GitLab API: https://docs.gitlab.com/api/group_access_tokens Examples -------- @@ -46,3 +46,9 @@ Rotate a group access token and retrieve its new value:: # or directly using a token ID new_token = group.access_tokens.rotate(42) print(new_token.token) + +Self-Rotate the group access token you are using to authenticate the request and retrieve its new value:: + + token = group.access_tokens.get(42, lazy=True) + token.rotate(self_rotate=True) + print(token.token) \ No newline at end of file diff --git a/docs/gl_objects/groups.rst b/docs/gl_objects/groups.rst index 2acc57d9e..7824ef31b 100644 --- a/docs/gl_objects/groups.rst +++ b/docs/gl_objects/groups.rst @@ -14,7 +14,7 @@ Reference + :class:`gitlab.v4.objects.GroupManager` + :attr:`gitlab.Gitlab.groups` -* GitLab API: https://docs.gitlab.com/ce/api/groups.html +* GitLab API: https://docs.gitlab.com/api/groups Examples -------- @@ -63,7 +63,7 @@ Create a group:: .. warning:: On GitLab.com, creating top-level groups is currently - `not permitted using the API `_. + `not permitted using the API `_. You can only use the API to create subgroups. Create a subgroup under an existing group:: @@ -82,6 +82,11 @@ Set the avatar image for a group:: group.avatar = open('path/to/file.png', 'rb') group.save() +Remove the avatar image for a group:: + + group.avatar = "" + group.save() + Remove a group:: gl.groups.delete(group_id) @@ -116,7 +121,7 @@ Reference + :attr:`gitlab.v4.objects.Group.imports` + :attr:`gitlab.v4.objects.GroupManager.import_group` -* GitLab API: https://docs.gitlab.com/ce/api/group_import_export.html +* GitLab API: https://docs.gitlab.com/api/group_import_export Examples -------- @@ -219,7 +224,7 @@ Reference + :class:`gitlab.v4.objects.GroupCustomAttributeManager` + :attr:`gitlab.v4.objects.Group.customattributes` -* GitLab API: https://docs.gitlab.com/ce/api/custom_attributes.html +* GitLab API: https://docs.gitlab.com/api/custom_attributes Examples -------- @@ -272,7 +277,7 @@ Reference + :attr:`gitlab.v4.objects.Group.members_all` + :attr:`gitlab.v4.objects.Group.billable_members` -* GitLab API: https://docs.gitlab.com/ce/api/members.html +* GitLab API: https://docs.gitlab.com/api/members Billable group members are only available in GitLab EE. @@ -397,7 +402,7 @@ Reference + :class:`gitlab.v4.objects.GroupHookManager` + :attr:`gitlab.v4.objects.Group.hooks` -* GitLab API: https://docs.gitlab.com/ce/api/groups.html#hooks +* GitLab API: https://docs.gitlab.com/api/groups#hooks Examples -------- @@ -441,7 +446,7 @@ Reference + :class:`gitlab.v4.objects.GroupPushRulesManager` + :attr:`gitlab.v4.objects.Group.pushrules` -* GitLab API: https://docs.gitlab.com/ee/api/groups.html#push-rules +* GitLab API: https://docs.gitlab.com/api/groups#push-rules Examples --------- @@ -475,7 +480,7 @@ Reference + :class:`gitlab.v4.objects.GroupServiceAccountManager` + :attr:`gitlab.v4.objects.Group.serviceaccounts` -* GitLab API: https://docs.gitlab.com/ee/api/groups.html#service-accounts +* GitLab API: https://docs.gitlab.com/api/groups#service-accounts Examples --------- diff --git a/docs/gl_objects/invitations.rst b/docs/gl_objects/invitations.rst index 795828b3c..e88564f6d 100644 --- a/docs/gl_objects/invitations.rst +++ b/docs/gl_objects/invitations.rst @@ -16,7 +16,7 @@ Reference + :class:`gitlab.v4.objects.ProjectInvitationManager` + :attr:`gitlab.v4.objects.Project.invitations` -* GitLab API: https://docs.gitlab.com/ce/api/invitations.html +* GitLab API: https://docs.gitlab.com/api/invitations Examples -------- diff --git a/docs/gl_objects/issues.rst b/docs/gl_objects/issues.rst index 1b7e6472e..ea17af728 100644 --- a/docs/gl_objects/issues.rst +++ b/docs/gl_objects/issues.rst @@ -16,7 +16,7 @@ Reference + :class:`gitlab.v4.objects.IssueManager` + :attr:`gitlab.Gitlab.issues` -* GitLab API: https://docs.gitlab.com/ce/api/issues.html +* GitLab API: https://docs.gitlab.com/api/issues Examples -------- @@ -55,7 +55,7 @@ Reference + :class:`gitlab.v4.objects.GroupIssueManager` + :attr:`gitlab.v4.objects.Group.issues` -* GitLab API: https://docs.gitlab.com/ce/api/issues.html +* GitLab API: https://docs.gitlab.com/api/issues Examples -------- @@ -91,7 +91,7 @@ Reference + :class:`gitlab.v4.objects.ProjectIssueManager` + :attr:`gitlab.v4.objects.Project.issues` -* GitLab API: https://docs.gitlab.com/ce/api/issues.html +* GitLab API: https://docs.gitlab.com/api/issues Examples -------- @@ -223,7 +223,7 @@ Reference + :class:`gitlab.v4.objects.ProjectIssueLinkManager` + :attr:`gitlab.v4.objects.ProjectIssue.links` -* GitLab API: https://docs.gitlab.com/ee/api/issue_links.html +* GitLab API: https://docs.gitlab.com/api/issue_links Examples -------- @@ -268,7 +268,7 @@ Reference + :attr:`gitlab.v4.objects.Project.issues_statistics` -* GitLab API: https://docs.gitlab.com/ce/api/issues_statistics.htm +* GitLab API: https://docs.gitlab.com/api/issues_statistics/ Examples --------- diff --git a/docs/gl_objects/iterations.rst b/docs/gl_objects/iterations.rst index 812dece6d..3f5e763bf 100644 --- a/docs/gl_objects/iterations.rst +++ b/docs/gl_objects/iterations.rst @@ -14,7 +14,7 @@ Reference + :class:`gitlab.v4.objects.ProjectIterationManager` + :attr:`gitlab.v4.objects.Project.iterations` -* GitLab API: https://docs.gitlab.com/ee/api/iterations.html +* GitLab API: https://docs.gitlab.com/api/iterations Examples -------- diff --git a/docs/gl_objects/job_token_scope.rst b/docs/gl_objects/job_token_scope.rst index 22fbbccea..8857e2251 100644 --- a/docs/gl_objects/job_token_scope.rst +++ b/docs/gl_objects/job_token_scope.rst @@ -11,7 +11,7 @@ Reference + :class:`gitlab.v4.objects.ProjectJobTokenScopeManager` + :attr:`gitlab.v4.objects.Project.job_token_scope` -* GitLab API: https://docs.gitlab.com/ee/api/project_job_token_scopes.html +* GitLab API: https://docs.gitlab.com/api/project_job_token_scopes Examples -------- @@ -82,13 +82,13 @@ Get a project's CI/CD job token inbound groups allowlist:: allowlist = scope.groups_allowlist.list(get_all=True) -Add a project to the project's inbound groups allowlist:: +Add a group to the project's inbound groups allowlist:: - allowed_project = scope.groups_allowlist.create({"target_project_id": 42}) + allowed_group = scope.groups_allowlist.create({"target_group_id": 42}) -Remove a project from the project's inbound agroups llowlist:: +Remove a group from the project's inbound groups allowlist:: - allowed_project.delete() + allowed_group.delete() # or directly using a Group ID scope.groups_allowlist.delete(42) @@ -97,4 +97,3 @@ Remove a project from the project's inbound agroups llowlist:: Similar to above, the ID attributes you receive from the create and list APIs are not consistent. To safely retrieve the ID of the allowlisted group regardless of how the object was created, always use its ``.get_id()`` method. - diff --git a/docs/gl_objects/keys.rst b/docs/gl_objects/keys.rst index 6d3521809..4450ed708 100644 --- a/docs/gl_objects/keys.rst +++ b/docs/gl_objects/keys.rst @@ -14,7 +14,7 @@ Reference + :class:`gitlab.v4.objects.KeyManager` + :attr:`gitlab.Gitlab.keys` -* GitLab API: https://docs.gitlab.com/ce/api/keys.html +* GitLab API: https://docs.gitlab.com/api/keys Examples -------- diff --git a/docs/gl_objects/labels.rst b/docs/gl_objects/labels.rst index b3ae9562b..7fa042fab 100644 --- a/docs/gl_objects/labels.rst +++ b/docs/gl_objects/labels.rst @@ -14,7 +14,7 @@ Reference + :class:`gitlab.v4.objects.ProjectLabelManager` + :attr:`gitlab.v4.objects.Project.labels` -* GitLab API: https://docs.gitlab.com/ce/api/labels.html +* GitLab API: https://docs.gitlab.com/api/labels Examples -------- @@ -79,7 +79,7 @@ Reference + :class:`gitlab.v4.objects.GroupEpicResourceLabelEventManager` + :attr:`gitlab.v4.objects.GroupEpic.resourcelabelevents` -* GitLab API: https://docs.gitlab.com/ee/api/resource_label_events.html +* GitLab API: https://docs.gitlab.com/api/resource_label_events Examples -------- diff --git a/docs/gl_objects/member_roles.rst b/docs/gl_objects/member_roles.rst index ffcd3f847..1c4aa07c5 100644 --- a/docs/gl_objects/member_roles.rst +++ b/docs/gl_objects/member_roles.rst @@ -21,7 +21,7 @@ Reference * GitLab API - + https://docs.gitlab.com/ee/api/member_roles.html#manage-instance-member-roles + + https://docs.gitlab.com/api/member_roles#manage-instance-member-roles Examples -------- @@ -52,7 +52,7 @@ Reference * GitLab API - + https://docs.gitlab.com/ee/api/member_roles.html#manage-group-member-roles + + https://docs.gitlab.com/api/member_roles#manage-group-member-roles Examples -------- diff --git a/docs/gl_objects/merge_request_approvals.rst b/docs/gl_objects/merge_request_approvals.rst index 5925b1a4d..4f9d561bb 100644 --- a/docs/gl_objects/merge_request_approvals.rst +++ b/docs/gl_objects/merge_request_approvals.rst @@ -15,7 +15,7 @@ References + :class:`gitlab.v4.objects.GroupApprovalRule` + :class:`gitlab.v4.objects.GroupApprovalRuleManager` -* GitLab API: https://docs.gitlab.com/ee/api/merge_request_approvals.html +* GitLab API: https://docs.gitlab.com/api/merge_request_approvals Examples -------- @@ -55,7 +55,7 @@ References + :class:`gitlab.v4.objects.ProjectApprovalRuleManager` + :attr:`gitlab.v4.objects.Project.approvals` -* GitLab API: https://docs.gitlab.com/ee/api/merge_request_approvals.html +* GitLab API: https://docs.gitlab.com/api/merge_request_approvals Examples -------- @@ -101,7 +101,7 @@ References + :class:`gitlab.v4.objects.ProjectMergeRequestApprovalStateManager` + :attr:`gitlab.v4.objects.ProjectMergeRequest.approval_state` -* GitLab API: https://docs.gitlab.com/ee/api/merge_request_approvals.html +* GitLab API: https://docs.gitlab.com/api/merge_request_approvals Examples -------- diff --git a/docs/gl_objects/merge_requests.rst b/docs/gl_objects/merge_requests.rst index 716b0e5e3..0bb861c72 100644 --- a/docs/gl_objects/merge_requests.rst +++ b/docs/gl_objects/merge_requests.rst @@ -25,7 +25,7 @@ Reference + :class:`gitlab.v4.objects.MergeRequestManager` + :attr:`gitlab.Gitlab.mergerequests` -* GitLab API: https://docs.gitlab.com/ce/api/merge_requests.html +* GitLab API: https://docs.gitlab.com/api/merge_requests Examples -------- @@ -67,7 +67,7 @@ Reference + :class:`gitlab.v4.objects.ProjectMergeRequestManager` + :attr:`gitlab.v4.objects.Project.mergerequests` -* GitLab API: https://docs.gitlab.com/ce/api/merge_requests.html +* GitLab API: https://docs.gitlab.com/api/merge_requests Examples -------- @@ -84,7 +84,7 @@ You can filter and sort the returned list with the following parameters: * ``sort``: sort order (``asc`` or ``desc``) You can find a full updated list of parameters here: -https://docs.gitlab.com/ee/api/merge_requests.html#list-merge-requests +https://docs.gitlab.com/api/merge_requests#list-merge-requests For example:: @@ -221,7 +221,7 @@ Get status of a rebase for an MR:: print(mr.rebase_in_progress, mr.merge_error) For more info see: -https://docs.gitlab.com/ee/api/merge_requests.html#rebase-a-merge-request +https://docs.gitlab.com/api/merge_requests#rebase-a-merge-request Attempt to merge changes between source and target branch:: @@ -240,7 +240,7 @@ Reference + :class:`gitlab.v4.objects.ProjectMergeRequestPipelineManager` + :attr:`gitlab.v4.objects.ProjectMergeRequest.pipelines` -* GitLab API: https://docs.gitlab.com/ee/api/merge_requests.html#list-mr-pipelines +* GitLab API: https://docs.gitlab.com/api/merge_requests#list-mr-pipelines Examples -------- diff --git a/docs/gl_objects/merge_trains.rst b/docs/gl_objects/merge_trains.rst index c7754727d..6d98e04d8 100644 --- a/docs/gl_objects/merge_trains.rst +++ b/docs/gl_objects/merge_trains.rst @@ -11,7 +11,7 @@ Reference + :class:`gitlab.v4.objects.ProjectMergeTrainManager` + :attr:`gitlab.v4.objects.Project.merge_trains` -* GitLab API: https://docs.gitlab.com/ee/api/merge_trains.html +* GitLab API: https://docs.gitlab.com/api/merge_trains Examples -------- diff --git a/docs/gl_objects/messages.rst b/docs/gl_objects/messages.rst index fa9c229fd..a7dbabbe7 100644 --- a/docs/gl_objects/messages.rst +++ b/docs/gl_objects/messages.rst @@ -15,7 +15,7 @@ References + :class:`gitlab.v4.objects.BroadcastMessageManager` + :attr:`gitlab.Gitlab.broadcastmessages` -* GitLab API: https://docs.gitlab.com/ce/api/broadcast_messages.html +* GitLab API: https://docs.gitlab.com/api/broadcast_messages Examples -------- diff --git a/docs/gl_objects/milestones.rst b/docs/gl_objects/milestones.rst index 4a1a5971e..7a02859db 100644 --- a/docs/gl_objects/milestones.rst +++ b/docs/gl_objects/milestones.rst @@ -20,8 +20,8 @@ Reference * GitLab API: - + https://docs.gitlab.com/ce/api/milestones.html - + https://docs.gitlab.com/ce/api/group_milestones.html + + https://docs.gitlab.com/api/milestones + + https://docs.gitlab.com/api/group_milestones Examples -------- @@ -95,7 +95,7 @@ Reference + :class:`gitlab.v4.objects.ProjectMergeRequestResourceMilestoneEventManager` + :attr:`gitlab.v4.objects.ProjectMergeRequest.resourcemilestoneevents` -* GitLab API: https://docs.gitlab.com/ee/api/resource_milestone_events.html +* GitLab API: https://docs.gitlab.com/api/resource_milestone_events Examples -------- diff --git a/docs/gl_objects/namespaces.rst b/docs/gl_objects/namespaces.rst index bcfa5d2db..7c8eeb5e6 100644 --- a/docs/gl_objects/namespaces.rst +++ b/docs/gl_objects/namespaces.rst @@ -11,7 +11,7 @@ Reference + :class:`gitlab.v4.objects.NamespaceManager` + :attr:`gitlab.Gitlab.namespaces` -* GitLab API: https://docs.gitlab.com/ce/api/namespaces.html +* GitLab API: https://docs.gitlab.com/api/namespaces Examples -------- diff --git a/docs/gl_objects/notes.rst b/docs/gl_objects/notes.rst index 86c8b324d..d9c3d6824 100644 --- a/docs/gl_objects/notes.rst +++ b/docs/gl_objects/notes.rst @@ -36,7 +36,7 @@ Reference + :class:`gitlab.v4.objects.ProjectSnippetNoteManager` + :attr:`gitlab.v4.objects.ProjectSnippet.notes` -* GitLab API: https://docs.gitlab.com/ce/api/notes.html +* GitLab API: https://docs.gitlab.com/api/notes Examples -------- diff --git a/docs/gl_objects/notifications.rst b/docs/gl_objects/notifications.rst index bc97b1ae9..3c5c7bd33 100644 --- a/docs/gl_objects/notifications.rst +++ b/docs/gl_objects/notifications.rst @@ -30,7 +30,7 @@ Reference + :class:`gitlab.v4.objects.ProjectNotificationSettingsManager` + :attr:`gitlab.v4.objects.Project.notificationsettings` -* GitLab API: https://docs.gitlab.com/ce/api/notification_settings.html +* GitLab API: https://docs.gitlab.com/api/notification_settings Examples -------- diff --git a/docs/gl_objects/packages.rst b/docs/gl_objects/packages.rst index cd101500f..369f8f9f4 100644 --- a/docs/gl_objects/packages.rst +++ b/docs/gl_objects/packages.rst @@ -17,7 +17,7 @@ Reference + :class:`gitlab.v4.objects.ProjectPackageManager` + :attr:`gitlab.v4.objects.Project.packages` -* GitLab API: https://docs.gitlab.com/ee/api/packages.html#within-a-project +* GitLab API: https://docs.gitlab.com/api/packages#within-a-project Examples -------- @@ -53,7 +53,7 @@ Reference + :class:`gitlab.v4.objects.GroupPackageManager` + :attr:`gitlab.v4.objects.Group.packages` -* GitLab API: https://docs.gitlab.com/ee/api/packages.html#within-a-group +* GitLab API: https://docs.gitlab.com/api/packages#within-a-group Examples -------- @@ -79,7 +79,7 @@ Reference + :class:`gitlab.v4.objects.ProjectPackageFileManager` + :attr:`gitlab.v4.objects.ProjectPackage.package_files` -* GitLab API: https://docs.gitlab.com/ee/api/packages.html#list-package-files +* GitLab API: https://docs.gitlab.com/api/packages#list-package-files Examples -------- @@ -107,7 +107,7 @@ Reference + :class:`gitlab.v4.objects.ProjectPackagePipelineManager` + :attr:`gitlab.v4.objects.ProjectPackage.pipelines` -* GitLab API: https://docs.gitlab.com/ee/api/packages.html#list-package-pipelines +* GitLab API: https://docs.gitlab.com/api/packages#list-package-pipelines Examples -------- @@ -131,7 +131,7 @@ Reference + :class:`gitlab.v4.objects.GenericPackageManager` + :attr:`gitlab.v4.objects.Project.generic_packages` -* GitLab API: https://docs.gitlab.com/ee/user/packages/generic_packages +* GitLab API: https://docs.gitlab.com/user/packages/generic_packages Examples -------- diff --git a/docs/gl_objects/pagesdomains.rst b/docs/gl_objects/pagesdomains.rst index f6c1e7696..85887cf02 100644 --- a/docs/gl_objects/pagesdomains.rst +++ b/docs/gl_objects/pagesdomains.rst @@ -14,7 +14,7 @@ References + :class:`gitlab.v4.objects.ProjectPagesManager` + :attr:`gitlab.v4.objects.Project.pages` -* GitLab API: https://docs.gitlab.com/ee/api/pages.html +* GitLab API: https://docs.gitlab.com/api/pages Examples -------- @@ -43,7 +43,7 @@ References + :class:`gitlab.v4.objects.PagesDomainManager` + :attr:`gitlab.Gitlab.pagesdomains` -* GitLab API: https://docs.gitlab.com/ce/api/pages_domains.html#list-all-pages-domains +* GitLab API: https://docs.gitlab.com/api/pages_domains#list-all-pages-domains Examples -------- @@ -64,7 +64,7 @@ References + :class:`gitlab.v4.objects.ProjectPagesDomainManager` + :attr:`gitlab.v4.objects.Project.pagesdomains` -* GitLab API: https://docs.gitlab.com/ce/api/pages_domains.html#list-pages-domains +* GitLab API: https://docs.gitlab.com/api/pages_domains#list-pages-domains Examples -------- diff --git a/docs/gl_objects/personal_access_tokens.rst b/docs/gl_objects/personal_access_tokens.rst index ad6778175..d9d54b596 100644 --- a/docs/gl_objects/personal_access_tokens.rst +++ b/docs/gl_objects/personal_access_tokens.rst @@ -16,8 +16,8 @@ References * GitLab API: - + https://docs.gitlab.com/ee/api/personal_access_tokens.html - + https://docs.gitlab.com/ee/api/users.html#create-a-personal-access-token + + https://docs.gitlab.com/api/personal_access_tokens + + https://docs.gitlab.com/api/users#create-a-personal-access-token Examples -------- @@ -61,6 +61,12 @@ Rotate a personal access token and retrieve its new value:: new_token_dict = gl.personal_access_tokens.rotate(42) print(new_token_dict) +Self-Rotate the personal access token you are using to authenticate the request and retrieve its new value:: + + token = gl.personal_access_tokens.get(42, lazy=True) + token.rotate(self_rotate=True) + print(token.token) + Create a personal access token for a user (admin only):: user = gl.users.get(25, lazy=True) diff --git a/docs/gl_objects/pipelines_and_jobs.rst b/docs/gl_objects/pipelines_and_jobs.rst index 9315142cf..8b533b407 100644 --- a/docs/gl_objects/pipelines_and_jobs.rst +++ b/docs/gl_objects/pipelines_and_jobs.rst @@ -16,7 +16,7 @@ Reference + :class:`gitlab.v4.objects.ProjectPipelineManager` + :attr:`gitlab.v4.objects.Project.pipelines` -* GitLab API: https://docs.gitlab.com/ce/api/pipelines.html +* GitLab API: https://docs.gitlab.com/api/pipelines Examples -------- @@ -69,7 +69,7 @@ Reference + :class:`gitlab.v4.objects.ProjectTriggerManager` + :attr:`gitlab.v4.objects.Project.triggers` -* GitLab API: https://docs.gitlab.com/ce/api/pipeline_triggers.html +* GitLab API: https://docs.gitlab.com/api/pipeline_triggers Examples -------- @@ -115,7 +115,7 @@ objects to get the associated project:: project = gl.projects.get(project_id, lazy=True) # no API call project.trigger_pipeline('main', trigger_token) -Reference: https://docs.gitlab.com/ee/ci/triggers/#trigger-token +Reference: https://docs.gitlab.com/ci/triggers/#trigger-token Pipeline schedules ================== @@ -138,7 +138,7 @@ Reference + :class:`gitlab.v4.objects.ProjectPipelineSchedulePipelineManager` + :attr:`gitlab.v4.objects.ProjectPipelineSchedule.pipelines` -* GitLab API: https://docs.gitlab.com/ce/api/pipeline_schedules.html +* GitLab API: https://docs.gitlab.com/api/pipeline_schedules Examples -------- @@ -216,7 +216,7 @@ Reference + :class:`gitlab.v4.objects.ProjectJobManager` + :attr:`gitlab.v4.objects.Project.jobs` -* GitLab API: https://docs.gitlab.com/ce/api/jobs.html +* GitLab API: https://docs.gitlab.com/api/jobs Examples -------- @@ -350,7 +350,7 @@ Reference + :class:`gitlab.v4.objects.ProjectPipelineBridgeManager` + :attr:`gitlab.v4.objects.ProjectPipeline.bridges` -* GitLab API: https://docs.gitlab.com/ee/api/jobs.html#list-pipeline-bridges +* GitLab API: https://docs.gitlab.com/api/jobs#list-pipeline-bridges Examples -------- @@ -373,7 +373,7 @@ Reference + :class:`gitlab.v4.objects.ProjectPipelineTestReportManager` + :attr:`gitlab.v4.objects.ProjectPipeline.test_report` -* GitLab API: https://docs.gitlab.com/ee/api/pipelines.html#get-a-pipelines-test-report +* GitLab API: https://docs.gitlab.com/api/pipelines#get-a-pipelines-test-report Examples -------- @@ -396,7 +396,7 @@ Reference + :class:`gitlab.v4.objects.ProjectPipelineTestReportSummaryManager` + :attr:`gitlab.v4.objects.ProjectPipeline.test_report_summary` -* GitLab API: https://docs.gitlab.com/ee/api/pipelines.html#get-a-pipelines-test-report-summary +* GitLab API: https://docs.gitlab.com/api/pipelines#get-a-pipelines-test-report-summary Examples -------- diff --git a/docs/gl_objects/project_access_tokens.rst b/docs/gl_objects/project_access_tokens.rst index 8d89f886d..6088e4d55 100644 --- a/docs/gl_objects/project_access_tokens.rst +++ b/docs/gl_objects/project_access_tokens.rst @@ -13,7 +13,7 @@ References + :class:`gitlab.v4.objects.ProjectAccessTokenManager` + :attr:`gitlab.Gitlab.project_access_tokens` -* GitLab API: https://docs.gitlab.com/ee/api/project_access_tokens.html +* GitLab API: https://docs.gitlab.com/api/project_access_tokens Examples -------- @@ -46,3 +46,9 @@ Rotate a project access token and retrieve its new value:: # or directly using a token ID new_token = project.access_tokens.rotate(42) print(new_token.token) + +Self-Rotate the project access token you are using to authenticate the request and retrieve its new value:: + + token = project.access_tokens.get(42, lazy=True) + token.rotate(self_rotate=True) + print(new_token.token) \ No newline at end of file diff --git a/docs/gl_objects/projects.rst b/docs/gl_objects/projects.rst index 335bf0603..8305a6b0b 100644 --- a/docs/gl_objects/projects.rst +++ b/docs/gl_objects/projects.rst @@ -14,7 +14,7 @@ Reference + :class:`gitlab.v4.objects.ProjectManager` + :attr:`gitlab.Gitlab.projects` -* GitLab API: https://docs.gitlab.com/ce/api/projects.html +* GitLab API: https://docs.gitlab.com/api/projects Examples -------- @@ -109,6 +109,11 @@ Set the avatar image for a project:: project.avatar = open('path/to/file.png', 'rb') project.save() +Remove the avatar image for a project:: + + project.avatar = "" + project.save() + Delete a project:: gl.projects.delete(project_id) @@ -190,7 +195,7 @@ Get the repository archive:: .. note:: For the formats available, refer to - https://docs.gitlab.com/ce/api/repositories.html#get-file-archive + https://docs.gitlab.com/api/repositories#get-file-archive .. warning:: @@ -265,7 +270,7 @@ Reference + :attr:`gitlab.v4.objects.Project.imports` + :attr:`gitlab.v4.objects.ProjectManager.import_project` -* GitLab API: https://docs.gitlab.com/ce/api/project_import_export.html +* GitLab API: https://docs.gitlab.com/api/project_import_export .. _project_import_export: @@ -376,7 +381,7 @@ Reference + :class:`gitlab.v4.objects.ProjectCustomAttributeManager` + :attr:`gitlab.v4.objects.Project.customattributes` -* GitLab API: https://docs.gitlab.com/ce/api/custom_attributes.html +* GitLab API: https://docs.gitlab.com/api/custom_attributes Examples -------- @@ -416,7 +421,7 @@ Reference + :class:`gitlab.v4.objects.ProjectFileManager` + :attr:`gitlab.v4.objects.Project.files` -* GitLab API: https://docs.gitlab.com/ce/api/repository_files.html +* GitLab API: https://docs.gitlab.com/api/repository_files Examples -------- @@ -437,7 +442,7 @@ Get file details from headers, without fetching its entire content:: # Get the file size: # For a full list of headers returned, see upstream documentation. - # https://docs.gitlab.com/ee/api/repository_files.html#get-file-from-repository + # https://docs.gitlab.com/api/repository_files#get-file-from-repository print(headers["X-Gitlab-Size"]) Get a raw file:: @@ -490,7 +495,7 @@ Reference + :class:`gitlab.v4.objects.ProjectTagManager` + :attr:`gitlab.v4.objects.Project.tags` -* GitLab API: https://docs.gitlab.com/ce/api/tags.html +* GitLab API: https://docs.gitlab.com/api/tags Examples -------- @@ -533,7 +538,7 @@ Reference + :class:`gitlab.v4.objects.ProjectSnippetManager` + :attr:`gitlab.v4.objects.Project.files` -* GitLab API: https://docs.gitlab.com/ce/api/project_snippets.html +* GitLab API: https://docs.gitlab.com/api/project_snippets Examples -------- @@ -599,7 +604,7 @@ Reference + :attr:`gitlab.v4.objects.Project.members` + :attr:`gitlab.v4.objects.Project.members_all` -* GitLab API: https://docs.gitlab.com/ce/api/members.html +* GitLab API: https://docs.gitlab.com/api/members Examples -------- @@ -659,7 +664,7 @@ Reference + :class:`gitlab.v4.objects.ProjectHookManager` + :attr:`gitlab.v4.objects.Project.hooks` -* GitLab API: https://docs.gitlab.com/ce/api/projects.html#hooks +* GitLab API: https://docs.gitlab.com/api/projects#hooks Examples -------- @@ -703,7 +708,7 @@ Reference + :class:`gitlab.v4.objects.ProjectIntegrationManager` + :attr:`gitlab.v4.objects.Project.integrations` -* GitLab API: https://docs.gitlab.com/ce/api/integrations.html +* GitLab API: https://docs.gitlab.com/api/integrations Examples --------- @@ -752,7 +757,7 @@ Reference + :attr:`gitlab.v4.objects.Project.upload` -* Gitlab API: https://docs.gitlab.com/ce/api/projects.html#upload-a-file +* Gitlab API: https://docs.gitlab.com/api/projects#upload-a-file Examples -------- @@ -795,7 +800,7 @@ Reference + :class:`gitlab.v4.objects.ProjectPushRulesManager` + :attr:`gitlab.v4.objects.Project.pushrules` -* GitLab API: https://docs.gitlab.com/ee/api/projects.html#push-rules +* GitLab API: https://docs.gitlab.com/api/projects#push-rules Examples --------- @@ -829,7 +834,7 @@ Reference + :class:`gitlab.v4.objects.ProjectProtectedTagManager` + :attr:`gitlab.v4.objects.Project.protectedtags` -* GitLab API: https://docs.gitlab.com/ce/api/protected_tags.html +* GitLab API: https://docs.gitlab.com/api/protected_tags Examples --------- @@ -862,7 +867,7 @@ Reference + :class:`gitlab.v4.objects.ProjectAdditionalStatisticsManager` + :attr:`gitlab.v4.objects.Project.additionalstatistics` -* GitLab API: https://docs.gitlab.com/ce/api/project_statistics.html +* GitLab API: https://docs.gitlab.com/api/project_statistics Examples --------- @@ -889,7 +894,7 @@ Reference + :class:`gitlab.v4.objects.ProjectStorageManager` + :attr:`gitlab.v4.objects.Project.storage` -* GitLab API: https://docs.gitlab.com/ee/api/projects.html#get-the-path-to-repository-storage +* GitLab API: https://docs.gitlab.com/api/projects#get-the-path-to-repository-storage Examples --------- diff --git a/docs/gl_objects/protected_branches.rst b/docs/gl_objects/protected_branches.rst index 2a8ccf7d9..a1b1ef5c5 100644 --- a/docs/gl_objects/protected_branches.rst +++ b/docs/gl_objects/protected_branches.rst @@ -2,8 +2,8 @@ Protected branches ################## -You can define a list of protected branch names on a repository. Names can use -wildcards (``*``). +You can define a list of protected branch names on a repository or group. +Names can use wildcards (``*``). References ---------- @@ -13,19 +13,24 @@ References + :class:`gitlab.v4.objects.ProjectProtectedBranch` + :class:`gitlab.v4.objects.ProjectProtectedBranchManager` + :attr:`gitlab.v4.objects.Project.protectedbranches` + + :class:`gitlab.v4.objects.GroupProtectedBranch` + + :class:`gitlab.v4.objects.GroupProtectedBranchManager` + + :attr:`gitlab.v4.objects.Group.protectedbranches` -* GitLab API: https://docs.gitlab.com/ce/api/protected_branches.html#protected-branches-api +* GitLab API: https://docs.gitlab.com/api/protected_branches#protected-branches-api Examples -------- -Get the list of protected branches for a project:: +Get the list of protected branches for a project or group:: - p_branches = project.protectedbranches.list(get_all=True) + p_branches = project.protectedbranches.list() + p_branches = group.protectedbranches.list() Get a single protected branch:: p_branch = project.protectedbranches.get('main') + p_branch = group.protectedbranches.get('main') Update a protected branch:: diff --git a/docs/gl_objects/protected_container_repositories.rst b/docs/gl_objects/protected_container_repositories.rst index ea0d24511..bc37c6138 100644 --- a/docs/gl_objects/protected_container_repositories.rst +++ b/docs/gl_objects/protected_container_repositories.rst @@ -13,7 +13,7 @@ References + :class:`gitlab.v4.objects.ProjectRegistryRepositoryProtectionRuleRuleManager` + :attr:`gitlab.v4.objects.Project.registry_protection_repository_rules` -* GitLab API: https://docs.gitlab.com/ee/api/container_repository_protection_rules.html +* GitLab API: https://docs.gitlab.com/api/container_repository_protection_rules Examples -------- diff --git a/docs/gl_objects/protected_environments.rst b/docs/gl_objects/protected_environments.rst index 1a81a5de8..e36c1fad0 100644 --- a/docs/gl_objects/protected_environments.rst +++ b/docs/gl_objects/protected_environments.rst @@ -13,7 +13,7 @@ References + :class:`gitlab.v4.objects.ProjectProtectedEnvironmentManager` + :attr:`gitlab.v4.objects.Project.protected_environment` -* GitLab API: https://docs.gitlab.com/ee/api/protected_environments.html +* GitLab API: https://docs.gitlab.com/api/protected_environments Examples -------- diff --git a/docs/gl_objects/protected_packages.rst b/docs/gl_objects/protected_packages.rst index 108a91fd9..6865b6992 100644 --- a/docs/gl_objects/protected_packages.rst +++ b/docs/gl_objects/protected_packages.rst @@ -13,7 +13,7 @@ References + :class:`gitlab.v4.objects.ProjectPackageProtectionRuleManager` + :attr:`gitlab.v4.objects.Project.package_protection_rules` -* GitLab API: https://docs.gitlab.com/ee/api/project_packages_protection_rules.html +* GitLab API: https://docs.gitlab.com/api/project_packages_protection_rules Examples -------- diff --git a/docs/gl_objects/pull_mirror.rst b/docs/gl_objects/pull_mirror.rst index e62cd6a4e..bc83ba36d 100644 --- a/docs/gl_objects/pull_mirror.rst +++ b/docs/gl_objects/pull_mirror.rst @@ -13,7 +13,7 @@ References + :class:`gitlab.v4.objects.ProjectPullMirrorManager` + :attr:`gitlab.v4.objects.Project.pull_mirror` -* GitLab API: https://docs.gitlab.com/ce/api/pull_mirror.html +* GitLab API: https://docs.gitlab.com/api/project_pull_mirroring/ Examples -------- diff --git a/docs/gl_objects/releases.rst b/docs/gl_objects/releases.rst index 662966067..99be7ce9f 100644 --- a/docs/gl_objects/releases.rst +++ b/docs/gl_objects/releases.rst @@ -14,7 +14,7 @@ Reference + :class:`gitlab.v4.objects.ProjectReleaseManager` + :attr:`gitlab.v4.objects.Project.releases` -* Gitlab API: https://docs.gitlab.com/ee/api/releases/index.html +* Gitlab API: https://docs.gitlab.com/api/releases/index Examples -------- @@ -66,7 +66,7 @@ Reference + :class:`gitlab.v4.objects.ProjectReleaseLinkManager` + :attr:`gitlab.v4.objects.ProjectRelease.links` -* Gitlab API: https://docs.gitlab.com/ee/api/releases/links.html +* Gitlab API: https://docs.gitlab.com/api/releases/links Examples -------- diff --git a/docs/gl_objects/remote_mirrors.rst b/docs/gl_objects/remote_mirrors.rst index 505131aed..b4610117d 100644 --- a/docs/gl_objects/remote_mirrors.rst +++ b/docs/gl_objects/remote_mirrors.rst @@ -13,7 +13,7 @@ References + :class:`gitlab.v4.objects.ProjectRemoteMirrorManager` + :attr:`gitlab.v4.objects.Project.remote_mirrors` -* GitLab API: https://docs.gitlab.com/ce/api/remote_mirrors.html +* GitLab API: https://docs.gitlab.com/api/remote_mirrors Examples -------- diff --git a/docs/gl_objects/repositories.rst b/docs/gl_objects/repositories.rst index 6541228b4..b0c049bd2 100644 --- a/docs/gl_objects/repositories.rst +++ b/docs/gl_objects/repositories.rst @@ -11,7 +11,7 @@ References + :class:`gitlab.v4.objects.ProjectRegistryRepositoryManager` + :attr:`gitlab.v4.objects.Project.repositories` -* Gitlab API: https://docs.gitlab.com/ce/api/container_registry.html +* Gitlab API: https://docs.gitlab.com/api/container_registry Examples -------- diff --git a/docs/gl_objects/repository_tags.rst b/docs/gl_objects/repository_tags.rst index 8e71eeb91..a8e4be33f 100644 --- a/docs/gl_objects/repository_tags.rst +++ b/docs/gl_objects/repository_tags.rst @@ -11,7 +11,7 @@ References + :class:`gitlab.v4.objects.ProjectRegistryTagManager` + :attr:`gitlab.v4.objects.Repository.tags` -* Gitlab API: https://docs.gitlab.com/ce/api/container_registry.html +* Gitlab API: https://docs.gitlab.com/api/container_registry Examples -------- @@ -44,4 +44,4 @@ Delete tag in bulk:: .. note:: Delete in bulk is asynchronous operation and may take a while. - Refer to: https://docs.gitlab.com/ce/api/container_registry.html#delete-repository-tags-in-bulk + Refer to: https://docs.gitlab.com/api/container_registry#delete-repository-tags-in-bulk diff --git a/docs/gl_objects/resource_groups.rst b/docs/gl_objects/resource_groups.rst index 89d8998ac..4b1a9693f 100644 --- a/docs/gl_objects/resource_groups.rst +++ b/docs/gl_objects/resource_groups.rst @@ -14,7 +14,7 @@ Reference + :class:`gitlab.v4.objects.ProjectResourceGroupUpcomingJobManager` + :attr:`gitlab.v4.objects.ProjectResourceGroup.upcoming_jobs` -* Gitlab API: https://docs.gitlab.com/ee/api/resource_groups.html +* Gitlab API: https://docs.gitlab.com/api/resource_groups Examples -------- diff --git a/docs/gl_objects/runners.rst b/docs/gl_objects/runners.rst index eda71e557..4d0686a4c 100644 --- a/docs/gl_objects/runners.rst +++ b/docs/gl_objects/runners.rst @@ -23,7 +23,7 @@ Reference + :class:`gitlab.v4.objects.RunnerAllManager` + :attr:`gitlab.Gitlab.runners_all` -* GitLab API: https://docs.gitlab.com/ce/api/runners.html +* GitLab API: https://docs.gitlab.com/api/runners Examples -------- @@ -119,7 +119,7 @@ Reference + :class:`gitlab.v4.objects.GroupRunnerManager` + :attr:`gitlab.v4.objects.Group.runners` -* GitLab API: https://docs.gitlab.com/ce/api/runners.html +* GitLab API: https://docs.gitlab.com/api/runners Examples -------- @@ -148,7 +148,7 @@ Reference + :class:`gitlab.v4.objects.RunnerJobManager` + :attr:`gitlab.v4.objects.Runner.jobs` -* GitLab API: https://docs.gitlab.com/ce/api/runners.html +* GitLab API: https://docs.gitlab.com/api/runners Examples -------- diff --git a/docs/gl_objects/search.rst b/docs/gl_objects/search.rst index 2720dc445..78ec83785 100644 --- a/docs/gl_objects/search.rst +++ b/docs/gl_objects/search.rst @@ -38,7 +38,7 @@ Reference + :attr:`gitlab.v4.objects.Group.search` + :attr:`gitlab.v4.objects.Project.search` -* GitLab API: https://docs.gitlab.com/ce/api/search.html +* GitLab API: https://docs.gitlab.com/api/search Examples -------- diff --git a/docs/gl_objects/secure_files.rst b/docs/gl_objects/secure_files.rst index 56f525a18..62d6c4b12 100644 --- a/docs/gl_objects/secure_files.rst +++ b/docs/gl_objects/secure_files.rst @@ -14,7 +14,7 @@ References + :class:`gitlab.v4.objects.ProjectSecureFileManager` + :attr:`gitlab.v4.objects.Project.secure_files` -* GitLab API: https://docs.gitlab.com/ee/api/secure_files.html +* GitLab API: https://docs.gitlab.com/api/secure_files Examples -------- diff --git a/docs/gl_objects/settings.rst b/docs/gl_objects/settings.rst index 4accfe0f0..a0ab7f012 100644 --- a/docs/gl_objects/settings.rst +++ b/docs/gl_objects/settings.rst @@ -11,7 +11,7 @@ Reference + :class:`gitlab.v4.objects.ApplicationSettingsManager` + :attr:`gitlab.Gitlab.settings` -* GitLab API: https://docs.gitlab.com/ce/api/settings.html +* GitLab API: https://docs.gitlab.com/api/settings Examples -------- diff --git a/docs/gl_objects/sidekiq.rst b/docs/gl_objects/sidekiq.rst index 5f44762e2..870de8745 100644 --- a/docs/gl_objects/sidekiq.rst +++ b/docs/gl_objects/sidekiq.rst @@ -10,7 +10,7 @@ Reference + :class:`gitlab.v4.objects.SidekiqManager` + :attr:`gitlab.Gitlab.sidekiq` -* GitLab API: https://docs.gitlab.com/ce/api/sidekiq_metrics.html +* GitLab API: https://docs.gitlab.com/api/sidekiq_metrics Examples -------- diff --git a/docs/gl_objects/snippets.rst b/docs/gl_objects/snippets.rst index 63cfd4feb..3633ec142 100644 --- a/docs/gl_objects/snippets.rst +++ b/docs/gl_objects/snippets.rst @@ -11,7 +11,7 @@ Reference + :class:`gitlab.v4.objects.SnipptManager` + :attr:`gitlab.Gitlab.snippets` -* GitLab API: https://docs.gitlab.com/ce/api/snippets.html +* GitLab API: https://docs.gitlab.com/api/snippets Examples ======== diff --git a/docs/gl_objects/statistics.rst b/docs/gl_objects/statistics.rst index d1d72eb9e..fd49372bb 100644 --- a/docs/gl_objects/statistics.rst +++ b/docs/gl_objects/statistics.rst @@ -11,7 +11,7 @@ Reference + :class:`gitlab.v4.objects.ApplicationStatisticsManager` + :attr:`gitlab.Gitlab.statistics` -* GitLab API: https://docs.gitlab.com/ee/api/statistics.html +* GitLab API: https://docs.gitlab.com/api/statistics Examples -------- diff --git a/docs/gl_objects/status_checks.rst b/docs/gl_objects/status_checks.rst index 9ac90db85..062231216 100644 --- a/docs/gl_objects/status_checks.rst +++ b/docs/gl_objects/status_checks.rst @@ -17,7 +17,7 @@ Reference + :class:`gitlab.v4.objects.ProjectExternalStatusCheckManager` + :attr:`gitlab.v4.objects.Project.external_status_checks` -* GitLab API: https://docs.gitlab.com/ee/api/status_checks.html +* GitLab API: https://docs.gitlab.com/api/status_checks Examples --------- diff --git a/docs/gl_objects/system_hooks.rst b/docs/gl_objects/system_hooks.rst index 088338004..7acba56a3 100644 --- a/docs/gl_objects/system_hooks.rst +++ b/docs/gl_objects/system_hooks.rst @@ -11,7 +11,7 @@ Reference + :class:`gitlab.v4.objects.HookManager` + :attr:`gitlab.Gitlab.hooks` -* GitLab API: https://docs.gitlab.com/ce/api/system_hooks.html +* GitLab API: https://docs.gitlab.com/api/system_hooks Examples -------- diff --git a/docs/gl_objects/templates.rst b/docs/gl_objects/templates.rst index b4a731b4b..6a03a7d1a 100644 --- a/docs/gl_objects/templates.rst +++ b/docs/gl_objects/templates.rst @@ -21,7 +21,7 @@ Reference + :class:`gitlab.v4.objects.LicenseManager` + :attr:`gitlab.Gitlab.licenses` -* GitLab API: https://docs.gitlab.com/ce/api/templates/licenses.html +* GitLab API: https://docs.gitlab.com/api/templates/licenses Examples -------- @@ -47,7 +47,7 @@ Reference + :class:`gitlab.v4.objects.GitignoreManager` + :attr:`gitlab.Gitlab.gitignores` -* GitLab API: https://docs.gitlab.com/ce/api/templates/gitignores.html +* GitLab API: https://docs.gitlab.com/api/templates/gitignores Examples -------- @@ -73,7 +73,7 @@ Reference + :class:`gitlab.v4.objects.GitlabciymlManager` + :attr:`gitlab.Gitlab.gitlabciymls` -* GitLab API: https://docs.gitlab.com/ce/api/templates/gitlab_ci_ymls.html +* GitLab API: https://docs.gitlab.com/api/templates/gitlab_ci_ymls Examples -------- @@ -99,7 +99,7 @@ Reference + :class:`gitlab.v4.objects.DockerfileManager` + :attr:`gitlab.Gitlab.gitlabciymls` -* GitLab API: https://docs.gitlab.com/ce/api/templates/dockerfiles.html +* GitLab API: https://docs.gitlab.com/api/templates/dockerfiles Examples -------- @@ -143,7 +143,7 @@ Reference + :class:`gitlab.v4.objects.ProjectMergeRequestTemplateManager` + :attr:`gitlab.v4.objects.Project.merge_request_templates` -* GitLab API: https://docs.gitlab.com/ce/api/project_templates.html +* GitLab API: https://docs.gitlab.com/api/project_templates Examples -------- diff --git a/docs/gl_objects/todos.rst b/docs/gl_objects/todos.rst index 88c80030b..821c60636 100644 --- a/docs/gl_objects/todos.rst +++ b/docs/gl_objects/todos.rst @@ -11,7 +11,7 @@ Reference + :class:`~gitlab.objects.TodoManager` + :attr:`gitlab.Gitlab.todos` -* GitLab API: https://docs.gitlab.com/ce/api/todos.html +* GitLab API: https://docs.gitlab.com/api/todos Examples -------- diff --git a/docs/gl_objects/topics.rst b/docs/gl_objects/topics.rst index d34c0ecac..35e12d838 100644 --- a/docs/gl_objects/topics.rst +++ b/docs/gl_objects/topics.rst @@ -13,7 +13,7 @@ Reference + :class:`gitlab.v4.objects.TopicManager` + :attr:`gitlab.Gitlab.topics` -* GitLab API: https://docs.gitlab.com/ce/api/topics.html +* GitLab API: https://docs.gitlab.com/api/topics This endpoint requires admin access for creating, updating and deleting objects. @@ -50,3 +50,16 @@ Delete a topic:: Merge a source topic into a target topic:: gl.topics.merge(topic_id, target_topic_id) + +Set the avatar image for a topic:: + + # the avatar image can be passed as data (content of the file) or as a file + # object opened in binary mode + topic.avatar = open('path/to/file.png', 'rb') + topic.save() + +Remove the avatar image for a topic:: + + topic.avatar = "" + topic.save() + diff --git a/docs/gl_objects/users.rst b/docs/gl_objects/users.rst index e855fd29c..5ebfa296b 100644 --- a/docs/gl_objects/users.rst +++ b/docs/gl_objects/users.rst @@ -23,8 +23,8 @@ References * GitLab API: - + https://docs.gitlab.com/ee/api/users.html - + https://docs.gitlab.com/ee/api/projects.html#list-projects-starred-by-a-user + + https://docs.gitlab.com/api/users + + https://docs.gitlab.com/api/projects#list-projects-starred-by-a-user Examples -------- @@ -107,6 +107,10 @@ Get the followings of a user:: user.following_users.list(get_all=True) +List a user's contributed projects:: + + user.contributed_projects.list(get_all=True) + List a user's starred projects:: user.starred_projects.list(get_all=True) @@ -130,7 +134,7 @@ References + :class:`gitlab.v4.objects.UserCustomAttributeManager` + :attr:`gitlab.v4.objects.User.customattributes` -* GitLab API: https://docs.gitlab.com/ce/api/custom_attributes.html +* GitLab API: https://docs.gitlab.com/api/custom_attributes Examples -------- @@ -170,7 +174,7 @@ References + :class:`gitlab.v4.objects.UserImpersonationTokenManager` + :attr:`gitlab.v4.objects.User.impersonationtokens` -* GitLab API: https://docs.gitlab.com/ee/api/user_tokens.html#get-all-impersonation-tokens-of-a-user +* GitLab API: https://docs.gitlab.com/api/user_tokens#get-all-impersonation-tokens-of-a-user List impersonation tokens for a user:: @@ -204,7 +208,7 @@ References + :class:`gitlab.v4.objects.UserProjectManager` + :attr:`gitlab.v4.objects.User.projects` -* GitLab API: https://docs.gitlab.com/ee/api/projects.html#list-a-users-projects +* GitLab API: https://docs.gitlab.com/api/projects#list-a-users-projects List visible projects in the user's namespace:: @@ -229,7 +233,7 @@ References + :class:`gitlab.v4.objects.UserMembershipManager` + :attr:`gitlab.v4.objects.User.memberships` -* GitLab API: https://docs.gitlab.com/ee/api/users.html#list-projects-and-groups-that-a-user-is-a-member-of +* GitLab API: https://docs.gitlab.com/api/users#list-projects-and-groups-that-a-user-is-a-member-of List direct memberships for a user:: @@ -259,7 +263,7 @@ References + :class:`gitlab.v4.objects.CurrentUserManager` + :attr:`gitlab.Gitlab.user` -* GitLab API: https://docs.gitlab.com/ee/api/users.html +* GitLab API: https://docs.gitlab.com/api/users Examples -------- @@ -287,7 +291,7 @@ are admin. + :class:`gitlab.v4.objects.UserGPGKeyManager` + :attr:`gitlab.v4.objects.User.gpgkeys` -* GitLab API: https://docs.gitlab.com/ee/api/user_keys.html#list-your-gpg-keys +* GitLab API: https://docs.gitlab.com/api/user_keys#list-your-gpg-keys Examples -------- @@ -329,7 +333,7 @@ are admin. + :class:`gitlab.v4.objects.UserKeyManager` + :attr:`gitlab.v4.objects.User.keys` -* GitLab API: https://docs.gitlab.com/ee/api/user_keys.html#get-a-single-ssh-key +* GitLab API: https://docs.gitlab.com/api/user_keys#get-a-single-ssh-key Examples -------- @@ -370,7 +374,7 @@ You can manipulate the status for the current user and you can read the status o + :class:`gitlab.v4.objects.UserStatusManager` + :attr:`gitlab.v4.objects.User.status` -* GitLab API: https://docs.gitlab.com/ee/api/users.html#get-the-status-of-a-user +* GitLab API: https://docs.gitlab.com/api/users#get-the-status-of-a-user Examples -------- @@ -408,7 +412,7 @@ are admin. + :class:`gitlab.v4.objects.UserEmailManager` + :attr:`gitlab.v4.objects.User.emails` -* GitLab API: https://docs.gitlab.com/ee/api/user_email_addresses.html +* GitLab API: https://docs.gitlab.com/api/user_email_addresses Examples -------- @@ -445,7 +449,7 @@ References + :class:`gitlab.v4.objects.UserActivitiesManager` + :attr:`gitlab.Gitlab.user_activities` -* GitLab API: https://docs.gitlab.com/ee/api/users.html#list-a-users-activity +* GitLab API: https://docs.gitlab.com/api/users#list-a-users-activity Examples -------- @@ -463,7 +467,7 @@ Create new runner References ---------- -* New runner registration API endpoint (see `Migrating to the new runner registration workflow `_) +* New runner registration API endpoint (see `Migrating to the new runner registration workflow `_) * v4 API: @@ -471,7 +475,7 @@ References + :class:`gitlab.v4.objects.CurrentUserRunnerManager` + :attr:`gitlab.Gitlab.user.runners` -* GitLab API : https://docs.gitlab.com/ee/api/users.html#create-a-runner-linked-to-a-user +* GitLab API : https://docs.gitlab.com/api/users#create-a-runner-linked-to-a-user Examples -------- diff --git a/docs/gl_objects/variables.rst b/docs/gl_objects/variables.rst index ef28a8bea..4fd3255a2 100644 --- a/docs/gl_objects/variables.rst +++ b/docs/gl_objects/variables.rst @@ -10,7 +10,7 @@ variables to projects and groups, to modify pipeline/job scripts behavior. Please always follow GitLab's `rules for CI/CD variables`_, especially for values in masked variables. If you do not, your variables may silently fail to save. -.. _rules for CI/CD variables: https://docs.gitlab.com/ee/ci/variables/#add-a-cicd-variable-to-a-project +.. _rules for CI/CD variables: https://docs.gitlab.com/ci/variables/#add-a-cicd-variable-to-a-project Instance-level variables ======================== @@ -28,7 +28,7 @@ Reference * GitLab API - + https://docs.gitlab.com/ce/api/instance_level_ci_variables.html + + https://docs.gitlab.com/api/instance_level_ci_variables Examples -------- @@ -73,9 +73,9 @@ Reference * GitLab API - + https://docs.gitlab.com/ce/api/instance_level_ci_variables.html - + https://docs.gitlab.com/ce/api/project_level_variables.html - + https://docs.gitlab.com/ce/api/group_level_variables.html + + https://docs.gitlab.com/api/instance_level_ci_variables + + https://docs.gitlab.com/api/project_level_variables + + https://docs.gitlab.com/api/group_level_variables Examples -------- diff --git a/docs/gl_objects/wikis.rst b/docs/gl_objects/wikis.rst index 955132b24..d9b747eb5 100644 --- a/docs/gl_objects/wikis.rst +++ b/docs/gl_objects/wikis.rst @@ -15,8 +15,8 @@ References + :class:`gitlab.v4.objects.GroupWikiManager` + :attr:`gitlab.v4.objects.Group.wikis` -* GitLab API for Projects: https://docs.gitlab.com/ce/api/wikis.html -* GitLab API for Groups: https://docs.gitlab.com/ee/api/group_wikis.html +* GitLab API for Projects: https://docs.gitlab.com/api/wikis +* GitLab API for Groups: https://docs.gitlab.com/api/group_wikis Examples -------- @@ -68,8 +68,8 @@ Reference + :attr:`gitlab.v4.objects.GrouptWiki.upload` -* Gitlab API for Projects: https://docs.gitlab.com/ee/api/wikis.html#upload-an-attachment-to-the-wiki-repository -* Gitlab API for Groups: https://docs.gitlab.com/ee/api/group_wikis.html#upload-an-attachment-to-the-wiki-repository +* Gitlab API for Projects: https://docs.gitlab.com/api/wikis#upload-an-attachment-to-the-wiki-repository +* Gitlab API for Groups: https://docs.gitlab.com/api/group_wikis#upload-an-attachment-to-the-wiki-repository Examples -------- diff --git a/gitlab/_version.py b/gitlab/_version.py index 695245ebb..24f57a764 100644 --- a/gitlab/_version.py +++ b/gitlab/_version.py @@ -3,4 +3,4 @@ __email__ = "gauvainpocentek@gmail.com" __license__ = "LGPL3" __title__ = "python-gitlab" -__version__ = "5.6.0" +__version__ = "6.0.0" diff --git a/gitlab/cli.py b/gitlab/cli.py index a3ff5b5b4..ca4734190 100644 --- a/gitlab/cli.py +++ b/gitlab/cli.py @@ -107,7 +107,7 @@ def gitlab_resource_to_cls( return class_type -def cls_to_gitlab_resource(cls: RESTObject) -> str: +def cls_to_gitlab_resource(cls: type[RESTObject]) -> str: dasherized_uppercase = camel_upperlower_regex.sub(r"\1-\2", cls.__name__) dasherized_lowercase = camel_lowerupper_regex.sub(r"\1-\2", dasherized_uppercase) return dasherized_lowercase.lower() diff --git a/gitlab/const.py b/gitlab/const.py index 9e0b766ea..7a0492e64 100644 --- a/gitlab/const.py +++ b/gitlab/const.py @@ -93,6 +93,7 @@ class PipelineStatus(GitlabEnum): NO_ACCESS = AccessLevel.NO_ACCESS.value MINIMAL_ACCESS = AccessLevel.MINIMAL_ACCESS.value GUEST_ACCESS = AccessLevel.GUEST.value +PLANNER_ACCESS = AccessLevel.PLANNER.value REPORTER_ACCESS = AccessLevel.REPORTER.value DEVELOPER_ACCESS = AccessLevel.DEVELOPER.value MAINTAINER_ACCESS = AccessLevel.MAINTAINER.value @@ -151,6 +152,7 @@ class PipelineStatus(GitlabEnum): "NOTIFICATION_LEVEL_PARTICIPATING", "NOTIFICATION_LEVEL_WATCH", "OWNER_ACCESS", + "PLANNER_ACCESS", "REPORTER_ACCESS", "SEARCH_SCOPE_BLOBS", "SEARCH_SCOPE_COMMITS", diff --git a/gitlab/mixins.py b/gitlab/mixins.py index ff99abdf6..51de97876 100644 --- a/gitlab/mixins.py +++ b/gitlab/mixins.py @@ -660,10 +660,11 @@ class ObjectRotateMixin(_RestObjectBase): optional=("expires_at",), ) @exc.on_http_error(exc.GitlabRotateError) - def rotate(self, **kwargs: Any) -> dict[str, Any]: + def rotate(self, *, self_rotate: bool = False, **kwargs: Any) -> dict[str, Any]: """Rotate the current access token object. Args: + self_rotate: If True, the current access token object will be rotated. **kwargs: Extra options to send to the server (e.g. sudo) Raises: @@ -673,7 +674,8 @@ def rotate(self, **kwargs: Any) -> dict[str, Any]: if TYPE_CHECKING: assert isinstance(self.manager, RotateMixin) assert self.encoded_id is not None - server_data = self.manager.rotate(self.encoded_id, **kwargs) + token_id = "self" if self_rotate else self.encoded_id + server_data = self.manager.rotate(token_id, **kwargs) self._update_attrs(server_data) return server_data diff --git a/gitlab/utils.py b/gitlab/utils.py index 400793e24..bf37e09a5 100644 --- a/gitlab/utils.py +++ b/gitlab/utils.py @@ -188,6 +188,12 @@ def _transform_types( # if the type is FileAttribute we need to pass the data as file if isinstance(gitlab_attribute, types.FileAttribute) and transform_files: + # The GitLab API accepts mixed types + # (e.g. a file for avatar image or empty string for removing the avatar) + # So if string is empty, keep it in data dict + if isinstance(data[attr_name], str) and data[attr_name] == "": + continue + key = gitlab_attribute.get_file_name(attr_name) files[attr_name] = (key, data.pop(attr_name)) continue diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py index 067a0a155..87fcaf261 100644 --- a/gitlab/v4/cli.py +++ b/gitlab/v4/cli.py @@ -394,7 +394,7 @@ def extend_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser: subparsers.required = True # populate argparse for all Gitlab Object - classes = set() + classes: set[type[gitlab.base.RESTObject]] = set() for cls in gitlab.v4.objects.__dict__.values(): if not isinstance(cls, type): continue diff --git a/gitlab/v4/objects/boards.py b/gitlab/v4/objects/boards.py index 861b09046..1683a5fe1 100644 --- a/gitlab/v4/objects/boards.py +++ b/gitlab/v4/objects/boards.py @@ -23,7 +23,7 @@ class GroupBoardListManager(CRUDMixin[GroupBoardList]): _obj_cls = GroupBoardList _from_parent_attrs = {"group_id": "group_id", "board_id": "id"} _create_attrs = RequiredOptional( - exclusive=("label_id", "assignee_id", "milestone_id") + exclusive=("label_id", "assignee_id", "milestone_id", "iteration_id") ) _update_attrs = RequiredOptional(required=("position",)) @@ -48,7 +48,7 @@ class ProjectBoardListManager(CRUDMixin[ProjectBoardList]): _obj_cls = ProjectBoardList _from_parent_attrs = {"project_id": "project_id", "board_id": "id"} _create_attrs = RequiredOptional( - exclusive=("label_id", "assignee_id", "milestone_id") + exclusive=("label_id", "assignee_id", "milestone_id", "iteration_id") ) _update_attrs = RequiredOptional(required=("position",)) diff --git a/gitlab/v4/objects/branches.py b/gitlab/v4/objects/branches.py index 0724476a6..12dbf8848 100644 --- a/gitlab/v4/objects/branches.py +++ b/gitlab/v4/objects/branches.py @@ -49,3 +49,27 @@ class ProjectProtectedBranchManager(CRUDMixin[ProjectProtectedBranch]): ), ) _update_method = UpdateMethod.PATCH + + +class GroupProtectedBranch(SaveMixin, ObjectDeleteMixin, RESTObject): + _id_attr = "name" + + +class GroupProtectedBranchManager(CRUDMixin[GroupProtectedBranch]): + _path = "/groups/{group_id}/protected_branches" + _obj_cls = GroupProtectedBranch + _from_parent_attrs = {"group_id": "id"} + _create_attrs = RequiredOptional( + required=("name",), + optional=( + "push_access_level", + "merge_access_level", + "unprotect_access_level", + "allow_force_push", + "allowed_to_push", + "allowed_to_merge", + "allowed_to_unprotect", + "code_owner_approval_required", + ), + ) + _update_method = UpdateMethod.PATCH diff --git a/gitlab/v4/objects/groups.py b/gitlab/v4/objects/groups.py index 473b40391..7a1767817 100644 --- a/gitlab/v4/objects/groups.py +++ b/gitlab/v4/objects/groups.py @@ -24,6 +24,7 @@ from .audit_events import GroupAuditEventManager # noqa: F401 from .badges import GroupBadgeManager # noqa: F401 from .boards import GroupBoardManager # noqa: F401 +from .branches import GroupProtectedBranchManager # noqa: F401 from .clusters import GroupClusterManager # noqa: F401 from .container_registry import GroupRegistryRepositoryManager # noqa: F401 from .custom_attributes import GroupCustomAttributeManager # noqa: F401 @@ -102,6 +103,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): packages: GroupPackageManager projects: GroupProjectManager shared_projects: SharedProjectManager + protectedbranches: GroupProtectedBranchManager pushrules: GroupPushRulesManager registry_repositories: GroupRegistryRepositoryManager runners: GroupRunnerManager diff --git a/gitlab/v4/objects/projects.py b/gitlab/v4/objects/projects.py index 0eaceb5a6..b415a8b98 100644 --- a/gitlab/v4/objects/projects.py +++ b/gitlab/v4/objects/projects.py @@ -429,6 +429,7 @@ def trigger_pipeline( ref: str, token: str, variables: dict[str, Any] | None = None, + inputs: dict[str, Any] | None = None, **kwargs: Any, ) -> ProjectPipeline: """Trigger a CI build. @@ -439,6 +440,7 @@ def trigger_pipeline( ref: Commit to build; can be a branch name or a tag token: The trigger token variables: Variables passed to the build script + inputs: Inputs passed to the build script **kwargs: Extra options to send to the server (e.g. sudo) Raises: @@ -446,8 +448,14 @@ def trigger_pipeline( GitlabCreateError: If the server failed to perform the request """ variables = variables or {} + inputs = inputs or {} path = f"/projects/{self.encoded_id}/trigger/pipeline" - post_data = {"ref": ref, "token": token, "variables": variables} + post_data = { + "ref": ref, + "token": token, + "variables": variables, + "inputs": inputs, + } attrs = self.manager.gitlab.http_post(path, post_data=post_data, **kwargs) if TYPE_CHECKING: assert isinstance(attrs, dict) diff --git a/gitlab/v4/objects/settings.py b/gitlab/v4/objects/settings.py index 41d820647..fd8629b36 100644 --- a/gitlab/v4/objects/settings.py +++ b/gitlab/v4/objects/settings.py @@ -25,6 +25,7 @@ class ApplicationSettingsManager( "id", "default_projects_limit", "signup_enabled", + "silent_mode_enabled", "password_authentication_enabled_for_web", "gravatar_enabled", "sign_in_text", diff --git a/gitlab/v4/objects/tags.py b/gitlab/v4/objects/tags.py index 7a559daa7..ad04b4928 100644 --- a/gitlab/v4/objects/tags.py +++ b/gitlab/v4/objects/tags.py @@ -19,6 +19,7 @@ class ProjectTagManager(NoUpdateMixin[ProjectTag]): _path = "/projects/{project_id}/repository/tags" _obj_cls = ProjectTag _from_parent_attrs = {"project_id": "id"} + _list_filters = ("order_by", "sort", "search") _create_attrs = RequiredOptional( required=("tag_name", "ref"), optional=("message",) ) diff --git a/gitlab/v4/objects/users.py b/gitlab/v4/objects/users.py index 2c7c28a2c..dec0b375d 100644 --- a/gitlab/v4/objects/users.py +++ b/gitlab/v4/objects/users.py @@ -68,6 +68,8 @@ "UserMembershipManager", "UserProject", "UserProjectManager", + "UserContributedProject", + "UserContributedProjectManager", ] @@ -182,6 +184,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject): memberships: UserMembershipManager personal_access_tokens: UserPersonalAccessTokenManager projects: UserProjectManager + contributed_projects: UserContributedProjectManager starred_projects: StarredProjectManager status: UserStatusManager @@ -665,6 +668,17 @@ def list( return super().list(path=path, iterator=iterator, **kwargs) +class UserContributedProject(RESTObject): + _id_attr = "id" + _repr_attr = "path_with_namespace" + + +class UserContributedProjectManager(ListMixin[UserContributedProject]): + _path = "/users/{user_id}/contributed_projects" + _obj_cls = UserContributedProject + _from_parent_attrs = {"user_id": "id"} + + class StarredProject(RESTObject): pass diff --git a/requirements-docker.txt b/requirements-docker.txt index 30c190b42..ee34d1fba 100644 --- a/requirements-docker.txt +++ b/requirements-docker.txt @@ -1,3 +1,3 @@ -r requirements.txt -r requirements-test.txt -pytest-docker==3.2.0 +pytest-docker==3.2.2 diff --git a/requirements-lint.txt b/requirements-lint.txt index 3af7a1554..1281b5c87 100644 --- a/requirements-lint.txt +++ b/requirements-lint.txt @@ -1,14 +1,14 @@ -r requirements.txt argcomplete==2.0.0 black==25.1.0 -commitizen==4.5.0 +commitizen==4.8.3 flake8==7.2.0 isort==6.0.1 -mypy==1.15.0 -pylint==3.3.6 -pytest==8.3.5 +mypy==1.16.0 +pylint==3.3.7 +pytest==8.4.0 responses==0.25.7 respx==0.22.0 -types-PyYAML==6.0.12.20250402 -types-requests==2.32.0.20250328 -types-setuptools==78.1.0.20250329 +types-PyYAML==6.0.12.20250516 +types-requests==2.32.4.20250611 +types-setuptools==80.9.0.20250529 diff --git a/requirements-test.txt b/requirements-test.txt index 6beca2666..307f83782 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,13 +1,13 @@ -r requirements.txt anyio==4.9.0 build==1.2.2.post1 -coverage==7.8.0 +coverage==7.9.1 pytest-console-scripts==1.4.1 -pytest-cov==6.1.1 +pytest-cov==6.2.1 pytest-github-actions-annotate-failures==0.3.0 -pytest==8.3.5 +pytest==8.4.0 PyYaml==6.0.2 responses==0.25.7 respx==0.22.0 -trio==0.29.0 +trio==0.30.0 wheel==0.45.1 diff --git a/requirements.txt b/requirements.txt index f2b6882f1..7941900de 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -gql==3.5.2 +gql==3.5.3 httpx==0.28.1 -requests==2.32.3 +requests==2.32.4 requests-toolbelt==1.0.0 diff --git a/tests/functional/api/test_groups.py b/tests/functional/api/test_groups.py index 93200241a..301fea6a2 100644 --- a/tests/functional/api/test_groups.py +++ b/tests/functional/api/test_groups.py @@ -138,6 +138,34 @@ def test_group_labels(group): label.delete() +def test_group_avatar_upload(gl, group, fixture_dir): + """Test uploading an avatar to a group.""" + # Upload avatar + with open(fixture_dir / "avatar.png", "rb") as avatar_file: + group.avatar = avatar_file + group.save() + + # Verify the avatar was set + updated_group = gl.groups.get(group.id) + assert updated_group.avatar_url is not None + + +def test_group_avatar_remove(gl, group, fixture_dir): + """Test removing an avatar from a group.""" + # First set an avatar + with open(fixture_dir / "avatar.png", "rb") as avatar_file: + group.avatar = avatar_file + group.save() + + # Now remove the avatar + group.avatar = "" + group.save() + + # Verify the avatar was removed + updated_group = gl.groups.get(group.id) + assert updated_group.avatar_url is None + + @pytest.mark.gitlab_premium @pytest.mark.xfail(reason="/ldap/groups endpoint not documented") def test_ldap_groups(gl): @@ -284,6 +312,31 @@ def test_group_hooks(group): hook.delete() +def test_group_protected_branches(group, gitlab_version): + # Updating a protected branch at the group level is possible from Gitlab 15.9 + # https://docs.gitlab.com/api/group_protected_branches/ + can_update_prot_branch = gitlab_version.major > 15 or ( + gitlab_version.major == 15 and gitlab_version.minor >= 9 + ) + + p_b = group.protectedbranches.create( + {"name": "*-stable", "allow_force_push": False} + ) + assert p_b.name == "*-stable" + assert not p_b.allow_force_push + assert p_b in group.protectedbranches.list() + + if can_update_prot_branch: + p_b.allow_force_push = True + p_b.save() + + p_b = group.protectedbranches.get("*-stable") + if can_update_prot_branch: + assert p_b.allow_force_push + + p_b.delete() + + def test_group_transfer(gl, group): transfer_group = gl.groups.create( {"name": "transfer-test-group", "path": "transfer-test-group"} diff --git a/tests/functional/api/test_projects.py b/tests/functional/api/test_projects.py index 3572c6115..760f95336 100644 --- a/tests/functional/api/test_projects.py +++ b/tests/functional/api/test_projects.py @@ -48,6 +48,29 @@ def test_project_members(user, project): member.delete() +def test_project_avatar_upload(gl, project, fixture_dir): + """Test uploading an avatar to a project.""" + with open(fixture_dir / "avatar.png", "rb") as avatar_file: + project.avatar = avatar_file + project.save() + + updated_project = gl.projects.get(project.id) + assert updated_project.avatar_url is not None + + +def test_project_avatar_remove(gl, project, fixture_dir): + """Test removing an avatar from a project.""" + with open(fixture_dir / "avatar.png", "rb") as avatar_file: + project.avatar = avatar_file + project.save() + + project.avatar = "" + project.save() + + updated_project = gl.projects.get(project.id) + assert updated_project.avatar_url is None + + def test_project_badges(project): badge_image = "http://example.com" badge_link = "http://example/img.svg" diff --git a/tests/functional/api/test_topics.py b/tests/functional/api/test_topics.py index 1fb7c8d63..0ac318458 100644 --- a/tests/functional/api/test_topics.py +++ b/tests/functional/api/test_topics.py @@ -31,3 +31,48 @@ def test_topics(gl, gitlab_version): assert merged_topic["id"] == topic2.id topic2.delete() + + +def test_topic_avatar_upload(gl, fixture_dir): + """Test uploading an avatar to a topic.""" + + topic = gl.topics.create( + { + "name": "avatar-topic", + "description": "Topic with avatar", + "title": "Avatar Topic", + } + ) + + with open(fixture_dir / "avatar.png", "rb") as avatar_file: + topic.avatar = avatar_file + topic.save() + + updated_topic = gl.topics.get(topic.id) + assert updated_topic.avatar_url is not None + + topic.delete() + + +def test_topic_avatar_remove(gl, fixture_dir): + """Test removing an avatar from a topic.""" + + topic = gl.topics.create( + { + "name": "avatar-topic-remove", + "description": "Remove avatar", + "title": "Remove Avatar", + } + ) + + with open(fixture_dir / "avatar.png", "rb") as avatar_file: + topic.avatar = avatar_file + topic.save() + + topic.avatar = "" + topic.save() + + updated_topic = gl.topics.get(topic.id) + assert updated_topic.avatar_url is None + + topic.delete() diff --git a/tests/functional/fixtures/.env b/tests/functional/fixtures/.env index e3723b892..e85f85e6f 100644 --- a/tests/functional/fixtures/.env +++ b/tests/functional/fixtures/.env @@ -1,4 +1,4 @@ GITLAB_IMAGE=gitlab/gitlab-ee GITLAB_TAG=17.8.2-ee.0 GITLAB_RUNNER_IMAGE=gitlab/gitlab-runner -GITLAB_RUNNER_TAG=92594782 +GITLAB_RUNNER_TAG=96856197 diff --git a/tests/unit/objects/test_group_access_tokens.py b/tests/unit/objects/test_group_access_tokens.py index 53b636284..c09ed8e12 100644 --- a/tests/unit/objects/test_group_access_tokens.py +++ b/tests/unit/objects/test_group_access_tokens.py @@ -91,6 +91,19 @@ def resp_rotate_group_access_token(token_content): yield rsps +@pytest.fixture +def resp_self_rotate_group_access_token(token_content): + with responses.RequestsMock() as rsps: + rsps.add( + method=responses.POST, + url="http://localhost/api/v4/groups/1/access_tokens/self/rotate", + json=token_content, + content_type="application/json", + status=200, + ) + yield rsps + + def test_list_group_access_tokens(gl, resp_list_group_access_token): access_tokens = gl.groups.get(1, lazy=True).access_tokens.list() assert len(access_tokens) == 1 @@ -127,3 +140,15 @@ def test_rotate_group_access_token(group, resp_rotate_group_access_token): access_token.rotate() assert isinstance(access_token, GroupAccessToken) assert access_token.token == "s3cr3t" + + +def test_self_rotate_group_access_token(group, resp_self_rotate_group_access_token): + access_token = group.access_tokens.get(1, lazy=True) + access_token.rotate(self_rotate=True) + assert isinstance(access_token, GroupAccessToken) + assert access_token.token == "s3cr3t" + + # Verify that the url contains "self" + rotation_calls = resp_self_rotate_group_access_token.calls + assert len(rotation_calls) == 1 + assert "self/rotate" in rotation_calls[0].request.url diff --git a/tests/unit/objects/test_personal_access_tokens.py b/tests/unit/objects/test_personal_access_tokens.py index 1301f5ffb..6272cecc1 100644 --- a/tests/unit/objects/test_personal_access_tokens.py +++ b/tests/unit/objects/test_personal_access_tokens.py @@ -102,6 +102,19 @@ def resp_rotate_personal_access_token(token_content): yield rsps +@pytest.fixture +def resp_self_rotate_personal_access_token(token_content): + with responses.RequestsMock() as rsps: + rsps.add( + method=responses.POST, + url="http://localhost/api/v4/personal_access_tokens/self/rotate", + json=token_content, + content_type="application/json", + status=200, + ) + yield rsps + + def test_create_personal_access_token(gl, resp_create_user_personal_access_token): user = gl.users.get(1, lazy=True) access_token = user.personal_access_tokens.create( @@ -148,8 +161,20 @@ def test_revoke_personal_access_token_by_id(gl, resp_delete_personal_access_toke gl.personal_access_tokens.delete(token_id) -def test_rotate_project_access_token(gl, resp_rotate_personal_access_token): +def test_rotate_personal_access_token(gl, resp_rotate_personal_access_token): access_token = gl.personal_access_tokens.get(1, lazy=True) access_token.rotate() assert isinstance(access_token, PersonalAccessToken) assert access_token.token == "s3cr3t" + + +def test_self_rotate_personal_access_token(gl, resp_self_rotate_personal_access_token): + access_token = gl.personal_access_tokens.get(1, lazy=True) + access_token.rotate(self_rotate=True) + assert isinstance(access_token, PersonalAccessToken) + assert access_token.token == "s3cr3t" + + # Verify that the url contains "self" + rotation_calls = resp_self_rotate_personal_access_token.calls + assert len(rotation_calls) == 1 + assert "self/rotate" in rotation_calls[0].request.url diff --git a/tests/unit/objects/test_project_access_tokens.py b/tests/unit/objects/test_project_access_tokens.py index b63eeaa32..77b5108fe 100644 --- a/tests/unit/objects/test_project_access_tokens.py +++ b/tests/unit/objects/test_project_access_tokens.py @@ -91,6 +91,19 @@ def resp_rotate_project_access_token(token_content): yield rsps +@pytest.fixture +def resp_self_rotate_project_access_token(token_content): + with responses.RequestsMock() as rsps: + rsps.add( + method=responses.POST, + url="http://localhost/api/v4/projects/1/access_tokens/self/rotate", + json=token_content, + content_type="application/json", + status=200, + ) + yield rsps + + def test_list_project_access_tokens(gl, resp_list_project_access_token): access_tokens = gl.projects.get(1, lazy=True).access_tokens.list() assert len(access_tokens) == 1 @@ -127,3 +140,17 @@ def test_rotate_project_access_token(project, resp_rotate_project_access_token): access_token.rotate() assert isinstance(access_token, ProjectAccessToken) assert access_token.token == "s3cr3t" + + +def test_self_rotate_project_access_token( + project, resp_self_rotate_project_access_token +): + access_token = project.access_tokens.get(1, lazy=True) + access_token.rotate(self_rotate=True) + assert isinstance(access_token, ProjectAccessToken) + assert access_token.token == "s3cr3t" + + # Verify that the url contains "self" + rotation_calls = resp_self_rotate_project_access_token.calls + assert len(rotation_calls) == 1 + assert "self/rotate" in rotation_calls[0].request.url diff --git a/tests/unit/objects/test_users.py b/tests/unit/objects/test_users.py index c120581fe..ff8c4479d 100644 --- a/tests/unit/objects/test_users.py +++ b/tests/unit/objects/test_users.py @@ -7,7 +7,13 @@ import pytest import responses -from gitlab.v4.objects import StarredProject, User, UserMembership, UserStatus +from gitlab.v4.objects import ( + StarredProject, + User, + UserContributedProject, + UserMembership, + UserStatus, +) from .test_projects import project_content @@ -242,6 +248,19 @@ def resp_starred_projects(): yield rsps +@pytest.fixture +def resp_contributed_projects(): + with responses.RequestsMock() as rsps: + rsps.add( + method=responses.GET, + url="http://localhost/api/v4/users/1/contributed_projects", + json=[project_content], + content_type="application/json", + status=200, + ) + yield rsps + + @pytest.fixture def resp_runner_create(): with responses.RequestsMock() as rsps: @@ -314,6 +333,12 @@ def test_list_followers(user, resp_followers_following): assert followings[1].id == 4 +def test_list_contributed_projects(user, resp_contributed_projects): + projects = user.contributed_projects.list() + assert isinstance(projects[0], UserContributedProject) + assert projects[0].id == project_content["id"] + + def test_list_starred_projects(user, resp_starred_projects): projects = user.starred_projects.list() assert isinstance(projects[0], StarredProject) diff --git a/tests/unit/test_cli.py b/tests/unit/test_cli.py index af3dd3380..cad27afba 100644 --- a/tests/unit/test_cli.py +++ b/tests/unit/test_cli.py @@ -161,7 +161,7 @@ def error(self, message): "Raise error instead of exiting on invalid arguments, to make testing easier" raise ValueError(message) - class Fake: + class Fake(gitlab.base.RESTObject): _id_attr = None class FakeManager(CreateMixin, UpdateMixin, gitlab.base.RESTManager):