BigW Consortium Gitlab

group_level_variables.md 3.64 KB
Newer Older
Shinya Maeda committed
1
# Group-level Variables  API
Tomasz Maczukin committed
2

Shinya Maeda committed
3
## List group variables
Tomasz Maczukin committed
4

Shinya Maeda committed
5
Get list of a group's variables.
Tomasz Maczukin committed
6 7

```
Shinya Maeda committed
8
GET /groups/:id/variables
Tomasz Maczukin committed
9 10
```

11 12
| Attribute | Type    | required | Description         |
|-----------|---------|----------|---------------------|
Shinya Maeda committed
13
| `id`      | integer/string | yes      | The ID of a group or [URL-encoded path of the group](README.md#namespaced-path-encoding) owned by the authenticated user |
14 15

```
Shinya Maeda committed
16
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/groups/1/variables"
17
```
Tomasz Maczukin committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

```json
[
    {
        "key": "TEST_VARIABLE_1",
        "value": "TEST_1"
    },
    {
        "key": "TEST_VARIABLE_2",
        "value": "TEST_2"
    }
]
```

## Show variable details

Shinya Maeda committed
34
Get the details of a group's specific variable.
Tomasz Maczukin committed
35 36

```
Shinya Maeda committed
37
GET /groups/:id/variables/:key
Tomasz Maczukin committed
38 39
```

40 41
| Attribute | Type    | required | Description           |
|-----------|---------|----------|-----------------------|
Shinya Maeda committed
42
| `id`      | integer/string | yes      | The ID of a group or [URL-encoded path of the group](README.md#namespaced-path-encoding) owned by the authenticated user   |
43
| `key`     | string  | yes      | The `key` of a variable |
44 45

```
Shinya Maeda committed
46
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/groups/1/variables/TEST_VARIABLE_1"
47 48
```

Tomasz Maczukin committed
49 50 51 52 53 54 55 56 57
```json
{
    "key": "TEST_VARIABLE_1",
    "value": "TEST_1"
}
```

## Create variable

Shinya Maeda committed
58
Create a new variable.
Tomasz Maczukin committed
59 60

```
Shinya Maeda committed
61
POST /groups/:id/variables
Tomasz Maczukin committed
62 63
```

64 65
| Attribute   | Type    | required | Description           |
|-------------|---------|----------|-----------------------|
Shinya Maeda committed
66
| `id`        | integer/string | yes      | The ID of a group or [URL-encoded path of the group](README.md#namespaced-path-encoding) owned by the authenticated user   |
67 68 69
| `key`       | string  | yes      | The `key` of a variable; must have no more than 255 characters; only `A-Z`, `a-z`, `0-9`, and `_` are allowed |
| `value`     | string  | yes      | The `value` of a variable |
| `protected` | boolean | no       | Whether the variable is protected |
70 71

```
Shinya Maeda committed
72
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/groups/1/variables" --form "key=NEW_VARIABLE" --form "value=new value"
73 74
```

Tomasz Maczukin committed
75 76 77
```json
{
    "key": "NEW_VARIABLE",
78 79
    "value": "new value",
    "protected": false
Tomasz Maczukin committed
80 81 82 83 84
}
```

## Update variable

Shinya Maeda committed
85
Update a group's variable.
Tomasz Maczukin committed
86 87

```
Shinya Maeda committed
88
PUT /groups/:id/variables/:key
Tomasz Maczukin committed
89 90
```

91 92
| Attribute   | Type    | required | Description             |
|-------------|---------|----------|-------------------------|
Shinya Maeda committed
93
| `id`        | integer/string | yes      | The ID of a group or [URL-encoded path of the group](README.md#namespaced-path-encoding) owned by the authenticated user     |
94 95 96
| `key`       | string  | yes      | The `key` of a variable   |
| `value`     | string  | yes      | The `value` of a variable |
| `protected` | boolean | no       | Whether the variable is protected |
97 98

```
Shinya Maeda committed
99
curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/groups/1/variables/NEW_VARIABLE" --form "value=updated value"
100 101
```

Tomasz Maczukin committed
102 103 104
```json
{
    "key": "NEW_VARIABLE",
105 106
    "value": "updated value",
    "protected": true
Tomasz Maczukin committed
107 108 109 110 111
}
```

## Remove variable

Shinya Maeda committed
112
Remove a group's variable.
Tomasz Maczukin committed
113 114

```
Shinya Maeda committed
115
DELETE /groups/:id/variables/:key
Tomasz Maczukin committed
116 117
```

118 119
| Attribute | Type    | required | Description             |
|-----------|---------|----------|-------------------------|
Shinya Maeda committed
120
| `id`      | integer/string | yes      | The ID of a group or [URL-encoded path of the group](README.md#namespaced-path-encoding) owned by the authenticated user     |
121
| `key`     | string  | yes      | The `key` of a variable |
122 123

```
Shinya Maeda committed
124
curl --request DELETE --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/groups/1/variables/VARIABLE_1"
125
```