diff options
Diffstat (limited to 'doc/api/snippets.md')
-rw-r--r-- | doc/api/snippets.md | 105 |
1 files changed, 103 insertions, 2 deletions
diff --git a/doc/api/snippets.md b/doc/api/snippets.md index 578c72a0502..6fa6be3a43b 100644 --- a/doc/api/snippets.md +++ b/doc/api/snippets.md @@ -4,7 +4,7 @@ group: Source Code info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments --- -# Snippets API **(FREE)** +# Snippets API **(FREE ALL)** Snippets API operates on [snippets](../user/snippets.md). Related APIs exist for [project snippets](project_snippets.md) and @@ -23,7 +23,7 @@ Valid values for snippet visibility levels are: | `internal` | Snippet is visible for any authenticated user except [external users](../administration/external_users.md). | | `public` | Snippet can be accessed without any authentication. | -## List all snippets for a user +## List all snippets for current user Get a list of the current user's snippets. @@ -455,6 +455,107 @@ Example response: ] ``` +## List all snippets + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/419640) in GitLab 16.3. + +List all snippets the current user has access to. +Users with the Administrator or Auditor access levels can see all snippets +(both personal and project). + +```plaintext +GET /snippets/all +``` + +Parameters: + +| Attribute | Type | Required | Description | +|------------------|----------|----------|----------------------------------------| +| `created_after` | datetime | no | Return snippets created after the given time. Expected in ISO 8601 format (`2019-03-15T08:00:00Z`). | +| `created_before` | datetime | no | Return snippets created before the given time. Expected in ISO 8601 format (`2019-03-15T08:00:00Z`). | +| `page` | integer | no | Page to retrieve. | +| `per_page` | integer | no | Number of snippets to return per page. | +| `repository_storage` | string | no | Filter by repository storage used by the snippet _(administrators only)_. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/419640) in GitLab 16.3 | + +Example request: + +```shell +curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/snippets/all?per_page=2&page=1" +``` + +Example response: + +```json +[ + { + "id": 113, + "title": "Internal Project Snippet", + "description": null, + "visibility": "internal", + "author": { + "id": 17, + "username": "tim_kreiger", + "name": "Tim Kreiger", + "state": "active", + "avatar_url": "http://www.gravatar.com/avatar/edaf55a9e363ea263e3b981d09e0f7f7?s=80&d=identicon", + "web_url": "http://example.com/tim_kreiger" + }, + "created_at": "2023-08-03T10:21:02.480Z", + "updated_at": "2023-08-03T10:21:02.480Z", + "project_id": 35, + "web_url": "http://example.com/tim_kreiger/internal_project/-/snippets/113", + "raw_url": "http://example.com/tim_kreiger/internal_project/-/snippets/113/raw", + "file_name": "", + "files": [], + "repository_storage": "default" + }, + { + "id": 112, + "title": "Private Personal Snippet", + "description": null, + "visibility": "private", + "author": { + "id": 1, + "username": "root", + "name": "Administrator", + "state": "active", + "avatar_url": "http://www.gravatar.com/avatar/edaf55a9e363ea263e3b981d09e0f7f7?s=80&d=identicon", + "web_url": "http://example.com/root" + }, + "created_at": "2023-08-03T10:20:59.994Z", + "updated_at": "2023-08-03T10:20:59.994Z", + "project_id": null, + "web_url": "http://example.com/-/snippets/112", + "raw_url": "http://example.com/-/snippets/112/raw", + "file_name": "", + "files": [], + "repository_storage": "default" + }, + { + "id": 111, + "title": "Public Personal Snippet", + "description": null, + "visibility": "public", + "author": { + "id": 17, + "username": "tim_kreiger", + "name": "Tim Kreiger", + "state": "active", + "avatar_url": "http://www.gravatar.com/avatar/edaf55a9e363ea263e3b981d09e0f7f7?s=80&d=identicon", + "web_url": "http://example.com/tim_kreiger" + }, + "created_at": "2023-08-03T10:21:01.312Z", + "updated_at": "2023-08-03T10:21:01.312Z", + "project_id": null, + "web_url": "http://example.com/-/snippets/111", + "raw_url": "http://example.com/-/snippets/111/raw", + "file_name": "", + "files": [], + "repository_storage": "default" + }, +] +``` + ## Get user agent details NOTE: |