BigW Consortium Gitlab

project_snippets.md 2.01 KB
Newer Older
1 2
# Project snippets

3 4
## List snippets

5 6 7 8 9 10 11 12
Get a list of project snippets.

```
GET /projects/:id/snippets
```

Parameters:

13
- `id` (required) - The ID of a project
14

15 16
## Single snippet

17
Get a single project snippet.
18 19 20 21 22 23 24

```
GET /projects/:id/snippets/:snippet_id
```

Parameters:

25 26
- `id` (required) - The ID of a project
- `snippet_id` (required) - The ID of a project's snippet
27 28 29 30 31 32 33 34

```json
{
  "id": 1,
  "title": "test",
  "file_name": "add.rb",
  "author": {
    "id": 1,
35
    "username": "john_smith",
36 37
    "email": "john@example.com",
    "name": "John Smith",
38
    "state": "active",
39 40 41 42 43 44 45 46
    "created_at": "2012-05-23T08:00:58Z"
  },
  "expires_at": null,
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z"
}
```

47
## Create new snippet
48

49
Creates a new project snippet. The user must have permission to create new snippets.
50 51 52 53 54 55 56

```
POST /projects/:id/snippets
```

Parameters:

57 58 59 60
- `id` (required) - The ID of a project
- `title` (required) - The title of a snippet
- `file_name` (required) - The name of a snippet file
- `code` (required) - The content of a snippet
61

62
## Update snippet
63

64
Updates an existing project snippet. The user must have permission to change an existing snippet.
65 66 67 68 69 70 71

```
PUT /projects/:id/snippets/:snippet_id
```

Parameters:

72 73 74 75 76
- `id` (required) - The ID of a project
- `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
- `code` (optional) - The content of a snippet
77 78 79

## Delete snippet

80
Deletes an existing project snippet. This is an idempotent function and deleting a non-existent
81
snippet still returns a `200 OK` status code.
82 83 84 85 86 87 88

```
DELETE /projects/:id/snippets/:snippet_id
```

Parameters:

89 90
- `id` (required) - The ID of a project
- `snippet_id` (required) - The ID of a project's snippet
91 92 93

## Snippet content

94
Returns the raw project snippet as plain text.
95 96 97 98 99 100 101

```
GET /projects/:id/snippets/:snippet_id/raw
```

Parameters:

102 103
- `id` (required) - The ID of a project
- `snippet_id` (required) - The ID of a project's snippet