创建、替换或删除默认审查者触发器
curl --request PATCH \
--url https://api.devin.ai/v3beta1/organizations/{org_id}/review-settings/default-reviewer/triggers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"deletes": [
{
"entity_id": "<string>",
"expected_version_id": "<string>"
}
],
"upserts": [
{
"conditions": {
"clauses": [
{
"users": [
{
"value": "<string>"
}
],
"negate": false
}
]
},
"entity_id": "<string>",
"expected_version_id": "<string>",
"repository": "<string>",
"user_id": "<string>"
}
]
}
'import requests
url = "https://api.devin.ai/v3beta1/organizations/{org_id}/review-settings/default-reviewer/triggers"
payload = {
"deletes": [
{
"entity_id": "<string>",
"expected_version_id": "<string>"
}
],
"upserts": [
{
"conditions": { "clauses": [
{
"users": [{ "value": "<string>" }],
"negate": False
}
] },
"entity_id": "<string>",
"expected_version_id": "<string>",
"repository": "<string>",
"user_id": "<string>"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
deletes: [{entity_id: '<string>', expected_version_id: '<string>'}],
upserts: [
{
conditions: {clauses: [{users: [{value: '<string>'}], negate: false}]},
entity_id: '<string>',
expected_version_id: '<string>',
repository: '<string>',
user_id: '<string>'
}
]
})
};
fetch('https://api.devin.ai/v3beta1/organizations/{org_id}/review-settings/default-reviewer/triggers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.devin.ai/v3beta1/organizations/{org_id}/review-settings/default-reviewer/triggers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'deletes' => [
[
'entity_id' => '<string>',
'expected_version_id' => '<string>'
]
],
'upserts' => [
[
'conditions' => [
'clauses' => [
[
'users' => [
[
'value' => '<string>'
]
],
'negate' => false
]
]
],
'entity_id' => '<string>',
'expected_version_id' => '<string>',
'repository' => '<string>',
'user_id' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.devin.ai/v3beta1/organizations/{org_id}/review-settings/default-reviewer/triggers"
payload := strings.NewReader("{\n \"deletes\": [\n {\n \"entity_id\": \"<string>\",\n \"expected_version_id\": \"<string>\"\n }\n ],\n \"upserts\": [\n {\n \"conditions\": {\n \"clauses\": [\n {\n \"users\": [\n {\n \"value\": \"<string>\"\n }\n ],\n \"negate\": false\n }\n ]\n },\n \"entity_id\": \"<string>\",\n \"expected_version_id\": \"<string>\",\n \"repository\": \"<string>\",\n \"user_id\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.devin.ai/v3beta1/organizations/{org_id}/review-settings/default-reviewer/triggers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"deletes\": [\n {\n \"entity_id\": \"<string>\",\n \"expected_version_id\": \"<string>\"\n }\n ],\n \"upserts\": [\n {\n \"conditions\": {\n \"clauses\": [\n {\n \"users\": [\n {\n \"value\": \"<string>\"\n }\n ],\n \"negate\": false\n }\n ]\n },\n \"entity_id\": \"<string>\",\n \"expected_version_id\": \"<string>\",\n \"repository\": \"<string>\",\n \"user_id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.devin.ai/v3beta1/organizations/{org_id}/review-settings/default-reviewer/triggers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"deletes\": [\n {\n \"entity_id\": \"<string>\",\n \"expected_version_id\": \"<string>\"\n }\n ],\n \"upserts\": [\n {\n \"conditions\": {\n \"clauses\": [\n {\n \"users\": [\n {\n \"value\": \"<string>\"\n }\n ],\n \"negate\": false\n }\n ]\n },\n \"entity_id\": \"<string>\",\n \"expected_version_id\": \"<string>\",\n \"repository\": \"<string>\",\n \"user_id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"deleted_entity_ids": [
"<string>"
],
"upserted": [
{
"cadence": "once",
"conditions": {
"clauses": [
{
"kind": "author",
"users": [
{
"kind": "devin",
"value": "<string>"
}
],
"negate": false
}
],
"match": "all"
},
"created_at": 123,
"effort": "default",
"entity_id": "<string>",
"kind": "rule",
"modified_by_user_id": "<string>",
"readonly": true,
"removable": true,
"scope": {
"kind": "account",
"target": "<string>",
"user_id": "<string>"
},
"start": "pr_open",
"version_id": "<string>"
}
]
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}审查触发条件(组织)[测试版]
更新 Devin Review 触发器
通过一次原子性 API 调用,为组织创建、替换和删除 Devin Review auto-review 规则及排除规则。
PATCH
/
v3beta1
/
organizations
/
{org_id}
/
review-settings
/
default-reviewer
/
triggers
创建、替换或删除默认审查者触发器
curl --request PATCH \
--url https://api.devin.ai/v3beta1/organizations/{org_id}/review-settings/default-reviewer/triggers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"deletes": [
{
"entity_id": "<string>",
"expected_version_id": "<string>"
}
],
"upserts": [
{
"conditions": {
"clauses": [
{
"users": [
{
"value": "<string>"
}
],
"negate": false
}
]
},
"entity_id": "<string>",
"expected_version_id": "<string>",
"repository": "<string>",
"user_id": "<string>"
}
]
}
'import requests
url = "https://api.devin.ai/v3beta1/organizations/{org_id}/review-settings/default-reviewer/triggers"
payload = {
"deletes": [
{
"entity_id": "<string>",
"expected_version_id": "<string>"
}
],
"upserts": [
{
"conditions": { "clauses": [
{
"users": [{ "value": "<string>" }],
"negate": False
}
] },
"entity_id": "<string>",
"expected_version_id": "<string>",
"repository": "<string>",
"user_id": "<string>"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
deletes: [{entity_id: '<string>', expected_version_id: '<string>'}],
upserts: [
{
conditions: {clauses: [{users: [{value: '<string>'}], negate: false}]},
entity_id: '<string>',
expected_version_id: '<string>',
repository: '<string>',
user_id: '<string>'
}
]
})
};
fetch('https://api.devin.ai/v3beta1/organizations/{org_id}/review-settings/default-reviewer/triggers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.devin.ai/v3beta1/organizations/{org_id}/review-settings/default-reviewer/triggers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'deletes' => [
[
'entity_id' => '<string>',
'expected_version_id' => '<string>'
]
],
'upserts' => [
[
'conditions' => [
'clauses' => [
[
'users' => [
[
'value' => '<string>'
]
],
'negate' => false
]
]
],
'entity_id' => '<string>',
'expected_version_id' => '<string>',
'repository' => '<string>',
'user_id' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.devin.ai/v3beta1/organizations/{org_id}/review-settings/default-reviewer/triggers"
payload := strings.NewReader("{\n \"deletes\": [\n {\n \"entity_id\": \"<string>\",\n \"expected_version_id\": \"<string>\"\n }\n ],\n \"upserts\": [\n {\n \"conditions\": {\n \"clauses\": [\n {\n \"users\": [\n {\n \"value\": \"<string>\"\n }\n ],\n \"negate\": false\n }\n ]\n },\n \"entity_id\": \"<string>\",\n \"expected_version_id\": \"<string>\",\n \"repository\": \"<string>\",\n \"user_id\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.devin.ai/v3beta1/organizations/{org_id}/review-settings/default-reviewer/triggers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"deletes\": [\n {\n \"entity_id\": \"<string>\",\n \"expected_version_id\": \"<string>\"\n }\n ],\n \"upserts\": [\n {\n \"conditions\": {\n \"clauses\": [\n {\n \"users\": [\n {\n \"value\": \"<string>\"\n }\n ],\n \"negate\": false\n }\n ]\n },\n \"entity_id\": \"<string>\",\n \"expected_version_id\": \"<string>\",\n \"repository\": \"<string>\",\n \"user_id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.devin.ai/v3beta1/organizations/{org_id}/review-settings/default-reviewer/triggers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"deletes\": [\n {\n \"entity_id\": \"<string>\",\n \"expected_version_id\": \"<string>\"\n }\n ],\n \"upserts\": [\n {\n \"conditions\": {\n \"clauses\": [\n {\n \"users\": [\n {\n \"value\": \"<string>\"\n }\n ],\n \"negate\": false\n }\n ]\n },\n \"entity_id\": \"<string>\",\n \"expected_version_id\": \"<string>\",\n \"repository\": \"<string>\",\n \"user_id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"deleted_entity_ids": [
"<string>"
],
"upserted": [
{
"cadence": "once",
"conditions": {
"clauses": [
{
"kind": "author",
"users": [
{
"kind": "devin",
"value": "<string>"
}
],
"negate": false
}
],
"match": "all"
},
"created_at": 123,
"effort": "default",
"entity_id": "<string>",
"kind": "rule",
"modified_by_user_id": "<string>",
"readonly": true,
"removable": true,
"scope": {
"kind": "account",
"target": "<string>",
"user_id": "<string>"
},
"start": "pr_open",
"version_id": "<string>"
}
]
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}以单个原子批次创建、替换和删除 Devin Review auto-review 规则及排除规则。如需查看现有触发器,请使用列出 Review 触发器;如需查找可作为目标的代码仓库,请使用列出 Review 触发器作用域。
权限
需要使用在组织中具有ManageReview 权限的服务用户或个人访问令牌。个人访问令牌以其所属用户的身份执行操作。账户级 ManageReview 权限允许调用方管理所有作用域;组织级 ManageReview 权限仅适用于该组织可访问的代码仓库。
行为
upserts中不带entity_id的条目会创建一个触发器。带有entity_id的条目会替换对应的触发器,且必须包含expected_version_id,即最近一次读取到的version_id。省略的字段将保留其已存储的值。kind为rule(自动运行 Review) 或exclusion(跳过匹配的拉取请求) 。scope为account(Review 可访问的所有代码仓库) 、repository(需同时提供repository,在 github.com 上格式为owner/repo,其他平台为host/path) 或user(需同时提供user_id,适用于该成员本人的拉取请求) 。- 对于规则,
start为pr_open或pr_ready(默认) ,cadence为once或every_push(默认) ,effort为default、normal或ultra。 conditions用于将触发器限定于匹配的拉取请求;创建时省略该字段,即匹配作用域内的所有拉取请求。替换时省略该字段会保留已存储的条件;传入null可清除条件。deletes中的条目通过entity_id和expected_version_id指定要删除的触发器。- 批量操作具有原子性:要么全部成功,要么全部失败。批次为空时返回
400;任一条目指向调用方无权管理的作用域时返回403;expected_version_id已过期时返回409。遇到最后一种情况时,请重新读取触发器后重试。 - 如果组织未启用 Review 触发器,则返回
404。
示例
curl -X PATCH "https://api.devin.ai/v3beta1/organizations/$ORG_ID/review-settings/default-reviewer/triggers" \
-H "Authorization: Bearer $DEVIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"upserts": [
{
"kind": "rule",
"scope": "repository",
"repository": "acme/web",
"start": "pr_ready",
"cadence": "every_push"
}
]
}'
请求体
application/json

