summaryrefslogtreecommitdiff
path: root/doc/api/repository_files.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/api/repository_files.md')
-rw-r--r--doc/api/repository_files.md102
1 files changed, 54 insertions, 48 deletions
diff --git a/doc/api/repository_files.md b/doc/api/repository_files.md
index cc210eacd49..fd024240e90 100644
--- a/doc/api/repository_files.md
+++ b/doc/api/repository_files.md
@@ -35,6 +35,12 @@ GET /projects/:id/repository/files/:file_path
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fmodels%2Fkey%2Erb?ref=master"
```
+| Attribute | Type | Required | Description |
+|-------------|----------------|----------|-----------------------------------------------------------------------------------------------------------------|
+| `id` | integer or string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
+| `file_path` | string | yes | URL encoded full path to new file. Ex. `lib%2Fclass%2Erb`. |
+| `ref` | string | yes | The name of branch, tag or commit |
+
Example response:
```json
@@ -52,11 +58,6 @@ Example response:
}
```
-Parameters:
-
-- `file_path` (required) - URL encoded full path to new file. Ex. lib%2Fclass%2Erb
-- `ref` (required) - The name of branch, tag or commit
-
NOTE:
`blob_id` is the blob SHA, see [repositories - Get a blob from repository](repositories.md#get-a-blob-from-repository)
@@ -95,6 +96,12 @@ Allows you to receive blame information. Each blame range contains lines and cor
GET /projects/:id/repository/files/:file_path/blame
```
+| Attribute | Type | Required | Description |
+|-------------|----------------|----------|-----------------------------------------------------------------------------------------------------------------|
+| `id` | integer or string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
+| `file_path` | string | yes | URL encoded full path to new file. Ex. `lib%2Fclass%2Erb`. |
+| `ref` | string | yes | The name of branch, tag or commit |
+
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/13083/repository/files/path%2Fto%2Ffile.rb/blame?ref=master"
```
@@ -127,11 +134,6 @@ Example response:
]
```
-Parameters:
-
-- `file_path` (required) - URL encoded full path to new file. Ex. lib%2Fclass%2Erb
-- `ref` (required) - The name of branch, tag or commit
-
NOTE:
`HEAD` method return just file metadata as in [Get file from repository](repository_files.md#get-file-from-repository).
@@ -162,15 +164,16 @@ X-Gitlab-Size: 1476
GET /projects/:id/repository/files/:file_path/raw
```
+| Attribute | Type | Required | Description |
+|-------------|----------------|----------|-----------------------------------------------------------------------------------------------------------------|
+| `id` | integer or string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
+| `file_path` | string | yes | URL encoded full path to new file. Ex. `lib%2Fclass%2Erb`. |
+| `ref` | string | yes | The name of branch, tag or commit. Default is the `HEAD` of the project. |
+
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fmodels%2Fkey%2Erb/raw?ref=master"
```
-Parameters:
-
-- `file_path` (required) - URL encoded full path to new file, such as lib%2Fclass%2Erb.
-- `ref` (optional) - The name of branch, tag or commit. Default is the `HEAD` of the project.
-
NOTE:
Like [Get file from repository](repository_files.md#get-file-from-repository) you can use `HEAD` to get just file metadata.
@@ -182,6 +185,18 @@ This allows you to create a single file. For creating multiple files with a sing
POST /projects/:id/repository/files/:file_path
```
+| Attribute | Type | Required | Description |
+|------------------|----------------|----------|-----------------------------------------------------------------------------------------------------------------|
+| `id` | integer or string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
+| `file_path` | string | yes | URL encoded full path to new file. Ex. `lib%2Fclass%2Erb`. |
+| `branch` | string | yes | Name of the branch |
+| `start_branch` | string | no | Name of the branch to start the new commit from |
+| `encoding` | string | no | Change encoding to `base64`. Default is `text`. |
+| `author_email` | string | no | Specify the commit author's email address |
+| `author_name` | string | no | Specify the commit author's name |
+| `content` | string | yes | File content |
+| `commit_message` | string | yes | Commit message |
+
```shell
curl --request POST --header 'PRIVATE-TOKEN: <your_access_token>' \
--header "Content-Type: application/json" \
@@ -199,17 +214,6 @@ Example response:
}
```
-Parameters:
-
-- `file_path` (required) - URL encoded full path to new file. Ex. lib%2Fclass%2Erb
-- `branch` (required) - Name of the branch
-- `start_branch` (optional) - Name of the branch to start the new commit from
-- `encoding` (optional) - Change encoding to `base64`. Default is `text`.
-- `author_email` (optional) - Specify the commit author's email address
-- `author_name` (optional) - Specify the commit author's name
-- `content` (required) - File content
-- `commit_message` (required) - Commit message
-
## Update existing file in repository
This allows you to update a single file. For updating multiple files with a single request see the [commits API](commits.md#create-a-commit-with-multiple-files-and-actions).
@@ -218,6 +222,19 @@ This allows you to update a single file. For updating multiple files with a sing
PUT /projects/:id/repository/files/:file_path
```
+| Attribute | Type | Required | Description |
+|------------------|----------------|----------|-----------------------------------------------------------------------------------------------------------------|
+| `id` | integer or string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
+| `file_path` | string | yes | URL encoded full path to new file. Ex. `lib%2Fclass%2Erb`. |
+| `branch` | string | yes | Name of the branch |
+| `start_branch` | string | no | Name of the branch to start the new commit from |
+| `encoding` | string | no | Change encoding to `base64`. Default is `text`. |
+| `author_email` | string | no | Specify the commit author's email address |
+| `author_name` | string | no | Specify the commit author's name |
+| `content` | string | yes | File content |
+| `commit_message` | string | yes | Commit message |
+| `last_commit_id` | string | no | Last known file commit ID |
+
```shell
curl --request PUT --header 'PRIVATE-TOKEN: <your_access_token>' \
--header "Content-Type: application/json" \
@@ -235,18 +252,6 @@ Example response:
}
```
-Parameters:
-
-- `file_path` (required) - URL encoded full path to new file. Ex. lib%2Fclass%2Erb
-- `branch` (required) - Name of the branch
-- `start_branch` (optional) - Name of the branch to start the new commit from
-- `encoding` (optional) - Change encoding to `base64`. Default is `text`.
-- `author_email` (optional) - Specify the commit author's email address
-- `author_name` (optional) - Specify the commit author's name
-- `content` (required) - New file content
-- `commit_message` (required) - Commit message
-- `last_commit_id` (optional) - Last known file commit ID
-
If the commit fails for any reason we return a 400 error with a non-specific
error message. Possible causes for a failed commit include:
@@ -265,6 +270,17 @@ This allows you to delete a single file. For deleting multiple files with a sing
DELETE /projects/:id/repository/files/:file_path
```
+| Attribute | Type | Required | Description |
+|------------------|----------------|----------|-----------------------------------------------------------------------------------------------------------------|
+| `id` | integer or string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
+| `file_path` | string | yes | URL encoded full path to new file. Ex. `lib%2Fclass%2Erb`. |
+| `branch` | string | yes | Name of the branch |
+| `start_branch` | string | no | Name of the branch to start the new commit from |
+| `author_email` | string | no | Specify the commit author's email address. |
+| `author_name` | string | no | Specify the commit author's name. |
+| `commit_message` | string | yes | Commit message. |
+| `last_commit_id` | string | no | Last known file commit ID. |
+
```shell
curl --request DELETE --header 'PRIVATE-TOKEN: <your_access_token>' \
--header "Content-Type: application/json" \
@@ -272,13 +288,3 @@ curl --request DELETE --header 'PRIVATE-TOKEN: <your_access_token>' \
"commit_message": "delete file"}' \
"https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fproject%2Erb"
```
-
-Parameters:
-
-- `file_path` (required) - URL encoded full path to new file. Ex. lib%2Fclass%2Erb
-- `branch` (required) - Name of the branch
-- `start_branch` (optional) - Name of the branch to start the new commit from
-- `author_email` (optional) - Specify the commit author's email address
-- `author_name` (optional) - Specify the commit author's name
-- `commit_message` (required) - Commit message
-- `last_commit_id` (optional) - Last known file commit ID