summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axil@gitlab.com>2019-08-27 17:23:15 +0000
committerAchilleas Pipinellis <axil@gitlab.com>2019-08-27 17:23:15 +0000
commitde385eee8507a35f1c01ca784ba9aab9bc38e11d (patch)
tree222c6474170cf6c5cbfc08178dfea44edd3bdbb7
parentca5724be5d7ec899a9624827f9a471b4b554a640 (diff)
parentc9ed3d738dbda33997c73fe314e1e00bd17c19b6 (diff)
downloadgitlab-ce-de385eee8507a35f1c01ca784ba9aab9bc38e11d.tar.gz
Merge branch 'docs/update-api-snippets' into 'master'
Add example requests for snippets API See merge request gitlab-org/gitlab-ce!31964
-rw-r--r--doc/api/project_snippets.md58
1 files changed, 58 insertions, 0 deletions
diff --git a/doc/api/project_snippets.md b/doc/api/project_snippets.md
index c1588f2292a..bc8219077e4 100644
--- a/doc/api/project_snippets.md
+++ b/doc/api/project_snippets.md
@@ -81,6 +81,27 @@ Parameters:
- `code` (required) - The content of a snippet
- `visibility` (required) - The snippet's visibility
+Example request:
+
+```bash
+curl --request POST https://gitlab.com/api/v4/projects/:id/snippets \
+ --header "PRIVATE-TOKEN: <your access token>" \
+ --header "Content-Type: application/json" \
+ -d @snippet.json
+```
+
+`snippet.json` used in the above example request:
+
+```json
+{
+ "title" : "Example Snippet Title",
+ "description" : "More verbose snippet description",
+ "file_name" : "example.txt",
+ "code" : "source code \n with multiple lines\n",
+ "visibility" : "private"
+}
+```
+
## Update snippet
Updates an existing project snippet. The user must have permission to change an existing snippet.
@@ -99,6 +120,27 @@ Parameters:
- `code` (optional) - The content of a snippet
- `visibility` (optional) - The snippet's visibility
+Example request:
+
+```bash
+curl --request PUT https://gitlab.com/api/v4/projects/:id/snippets \
+ --header "PRIVATE-TOKEN: <your_access_token>" \
+ --header "Content-Type: application/json" \
+ -d @snippet.json
+```
+
+`snippet.json` used in the above example request:
+
+```json
+{
+ "title" : "Updated Snippet Title",
+ "description" : "More verbose snippet description",
+ "file_name" : "new_filename.txt",
+ "code" : "updated source code \n with multiple lines\n",
+ "visibility" : "private"
+}
+```
+
## Delete snippet
Deletes an existing project snippet. This returns a `204 No Content` status code if the operation was successfully or `404` if the resource was not found.
@@ -112,6 +154,13 @@ Parameters:
- `id` (required) - The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user
- `snippet_id` (required) - The ID of a project's snippet
+Example request:
+
+```bash
+curl --request DELETE https://gitlab.com/api/v4/projects/:id/snippets \
+ --header "PRIVATE-TOKEN: <your_access_token>"
+```
+
## Snippet content
Returns the raw project snippet as plain text.
@@ -125,6 +174,13 @@ Parameters:
- `id` (required) - The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user
- `snippet_id` (required) - The ID of a project's snippet
+Example request:
+
+```bash
+curl --request GET https://gitlab.com/api/v4/projects/:id/snippets/:snippet_id/raw \
+ --header "PRIVATE-TOKEN: <your_access_token>"
+```
+
## Get user agent details
> [Introduced][ce-29508] in GitLab 9.4.
@@ -140,6 +196,8 @@ GET /projects/:id/snippets/:snippet_id/user_agent_detail
| `id` | Integer | yes | The ID of a project |
| `snippet_id` | Integer | yes | The ID of a snippet |
+Example request:
+
```bash
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/1/snippets/2/user_agent_detail
```