315.md 5.2 KB
Newer Older
Lab机器人's avatar
readme  
Lab机器人 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
# Freeze Periods API

> 原文:[https://docs.gitlab.com/ee/api/freeze_periods.html](https://docs.gitlab.com/ee/api/freeze_periods.html)

*   [Permissions and security](#permissions-and-security)
*   [List Freeze Periods](#list-freeze-periods)
*   [Get a Freeze Period by a `freeze_period_id`](#get-a-freeze-period-by-a-freeze_period_id)
*   [Create a Freeze Period](#create-a-freeze-period)
*   [Update a Freeze Period](#update-a-freeze-period)
*   [Delete a Freeze Period](#delete-a-freeze-period)

# Freeze Periods API[](#freeze-periods-api "Permalink")

在 GitLab 13.0 中[引入](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/29382) .

您可以使用 Freeze Periods API 来操纵 GitLab 的[Freeze Period](../user/project/releases/index.html#prevent-unintentional-releases-by-setting-a-deploy-freeze)条目.

## Permissions and security[](#permissions-and-security "Permalink")

只有具有维护者[权限的](../user/permissions.html)用户才能与 Freeze Period API 端点进行交互.

## List Freeze Periods[](#list-freeze-periods "Permalink")

冻结期间的分页列表,按`created_at`升序排序.

```
GET /projects/:id/freeze_periods 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) . |

请求示例:

```
curl --header "PRIVATE-TOKEN: gVWYVHDRzXiRpN1rUC8T" "https://gitlab.example.com/api/v4/projects/19/freeze_periods" 
```

响应示例:

```
[  {  "id":1,  "freeze_start":"0 23 * * 5",  "freeze_end":"0 8 * * 1",  "cron_timezone":"UTC",  "created_at":"2020-05-15T17:03:35.702Z",  "updated_at":"2020-05-15T17:06:41.566Z"  }  ] 
```

## Get a Freeze Period by a `freeze_period_id`[](#get-a-freeze-period-by-a-freeze_period_id "Permalink")

获取给定的`freeze_period_id`的冻结期.

```
GET /projects/:id/freeze_periods/:freeze_period_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | 整数或字符串 | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) . |
| `freeze_period_id` | string | yes | 冻结期的数据库 ID. |

请求示例:

```
curl --header "PRIVATE-TOKEN: gVWYVHDRzXiRpN1rUC8T" "https://gitlab.example.com/api/v4/projects/19/freeze_periods/1" 
```

响应示例:

```
{  "id":1,  "freeze_start":"0 23 * * 5",  "freeze_end":"0 8 * * 1",  "cron_timezone":"UTC",  "created_at":"2020-05-15T17:03:35.702Z",  "updated_at":"2020-05-15T17:06:41.566Z"  } 
```

## Create a Freeze Period[](#create-a-freeze-period "Permalink")

创建冻结期.

```
POST /projects/:id/freeze_periods 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | 整数或字符串 | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) . |
| `freeze_start` | string | yes | [Cron](https://crontab.guru/)格式的冻结期开始. |
| `freeze_end` | string | yes | [Cron](https://crontab.guru/)格式的冻结期结束. |
| `cron_timezone` | string | no | cron 字段的时区,如果未提供,则默认为 UTC. |

请求示例:

```
curl --header 'Content-Type: application/json' --header "PRIVATE-TOKEN: gVWYVHDRzXiRpN1rUC8T" \
     --data '{ "freeze_start": "0 23 * * 5", "freeze_end": "0 7 * * 1", "cron_timezone": "UTC" }' \
     --request POST https://gitlab.example.com/api/v4/projects/19/freeze_periods 
```

响应示例:

```
{  "id":1,  "freeze_start":"0 23 * * 5",  "freeze_end":"0 7 * * 1",  "cron_timezone":"UTC",  "created_at":"2020-05-15T17:03:35.702Z",  "updated_at":"2020-05-15T17:03:35.702Z"  } 
```

## Update a Freeze Period[](#update-a-freeze-period "Permalink")

为给定的`freeze_period_id`更新冻结期.

```
PUT /projects/:id/freeze_periods/:tag_name 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | 整数或字符串 | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) . |
| `freeze_period_id` | 整数或字符串 | yes | 冻结期的数据库 ID. |
| `freeze_start` | string | no | [Cron](https://crontab.guru/)格式的冻结期开始. |
| `freeze_end` | string | no | [Cron](https://crontab.guru/)格式的冻结期结束. |
| `cron_timezone` | string | no | cron 字段的时区. |

请求示例:

```
curl --header 'Content-Type: application/json' --header "PRIVATE-TOKEN: gVWYVHDRzXiRpN1rUC8T" \
     --data '{ "freeze_end": "0 8 * * 1" }' \
     --request PUT https://gitlab.example.com/api/v4/projects/19/freeze_periods/1 
```

响应示例:

```
{  "id":1,  "freeze_start":"0 23 * * 5",  "freeze_end":"0 8 * * 1",  "cron_timezone":"UTC",  "created_at":"2020-05-15T17:03:35.702Z",  "updated_at":"2020-05-15T17:06:41.566Z"  } 
```

## Delete a Freeze Period[](#delete-a-freeze-period "Permalink")

删除给定的`freeze_period_id`的冻结期.

```
DELETE /projects/:id/freeze_periods/:freeze_period_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | 整数或字符串 | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) . |
| `freeze_period_id` | string | yes | 冻结期的数据库 ID. |

请求示例:

```
curl --request DELETE --header "PRIVATE-TOKEN: gVWYVHDRzXiRpN1rUC8T" "https://gitlab.example.com/api/v4/projects/19/freeze_periods/1" 
```