diff options
Diffstat (limited to 'doc/api/project_snippets.md')
-rw-r--r-- | doc/api/project_snippets.md | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/doc/api/project_snippets.md b/doc/api/project_snippets.md index eccc8b4212d..cc8bb20b003 100644 --- a/doc/api/project_snippets.md +++ b/doc/api/project_snippets.md @@ -83,12 +83,17 @@ POST /projects/:id/snippets Parameters: -- `id` (required) - The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user -- `title` (required) - The title of a snippet -- `file_name` (required) - The name of a snippet file -- `description` (optional) - The description of a snippet -- `content` (required) - The content of a snippet -- `visibility` (required) - The snippet's visibility +| Attribute | Type | Required | Description | +|:------------------|:----------------|:---------|:----------------------------------------------------------------------------------------------------------------| +| `id` | integer | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | +| `title` | string | yes | Title of a snippet | +| `file_name` | string | no | Deprecated: Use `files` instead. Name of a snippet file | +| `content` | string | no | Deprecated: Use `files` instead. Content of a snippet | +| `description` | string | no | Description of a snippet | +| `visibility` | string | no | Snippet's [visibility](#snippet-visibility-level) | +| `files` | array of hashes | no | An array of snippet files | +| `files:file_path` | string | yes | File path of the snippet file | +| `files:content` | string | yes | Content of the snippet file | Example request: @@ -105,9 +110,13 @@ curl --request POST "https://gitlab.com/api/v4/projects/:id/snippets" \ { "title" : "Example Snippet Title", "description" : "More verbose snippet description", - "file_name" : "example.txt", - "content" : "source code \n with multiple lines\n", - "visibility" : "private" + "visibility" : "private", + "files": [ + { + "file_path": "example.txt", + "content" : "source code \n with multiple lines\n", + } + ] } ``` @@ -121,13 +130,22 @@ PUT /projects/:id/snippets/:snippet_id 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 -- `title` (optional) - The title of a snippet -- `file_name` (optional) - The name of a snippet file -- `description` (optional) - The description of a snippet -- `content` (optional) - The content of a snippet -- `visibility` (optional) - The snippet's visibility +| Attribute | Type | Required | Description | +|:----------------------|:----------------|:---------|:----------------------------------------------------------------------------------------------------------------| +| `id` | integer | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | +| `snippet_id` | integer | yes | The ID of a project's snippet | +| `title` | string | no | Title of a snippet | +| `file_name` | string | no | Deprecated: Use `files` instead. Name of a snippet file | +| `content` | string | no | Deprecated: Use `files` instead. Content of a snippet | +| `description` | string | no | Description of a snippet | +| `visibility` | string | no | Snippet's [visibility](#snippet-visibility-level) | +| `files` | array of hashes | no | An array of snippet files | +| `files:action` | string | yes | Type of action to perform on the file, one of: 'create', 'update', 'delete', 'move' | +| `files:file_path` | string | no | File path of the snippet file | +| `files:previous_path` | string | no | Previous path of the snippet file | +| `files:content` | string | no | Content of the snippet file | + +Updates to snippets with multiple files *must* use the `files` attribute. Example request: @@ -144,9 +162,14 @@ curl --request PUT "https://gitlab.com/api/v4/projects/:id/snippets/:snippet_id" { "title" : "Updated Snippet Title", "description" : "More verbose snippet description", - "file_name" : "new_filename.txt", - "content" : "updated source code \n with multiple lines\n", - "visibility" : "private" + "visibility" : "private", + "files": [ + { + "action": "update", + "file_path": "example.txt", + "content" : "updated source code \n with multiple lines\n" + } + ] } ``` |