工作区 - 成员
修改权限
修改 workspace 成员的权限。
PATCH
/
v2
/
workspaces
/
members
修改权限
curl --request PATCH \
--url https://api.squarecloud.app/v2/workspaces/members \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"workspaceId": "<string>",
"memberId": "<string>",
"group": "<string>"
}
'import requests
url = "https://api.squarecloud.app/v2/workspaces/members"
payload = {
"workspaceId": "<string>",
"memberId": "<string>",
"group": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({workspaceId: '<string>', memberId: '<string>', group: '<string>'})
};
fetch('https://api.squarecloud.app/v2/workspaces/members', 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.squarecloud.app/v2/workspaces/members",
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([
'workspaceId' => '<string>',
'memberId' => '<string>',
'group' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.squarecloud.app/v2/workspaces/members"
payload := strings.NewReader("{\n \"workspaceId\": \"<string>\",\n \"memberId\": \"<string>\",\n \"group\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.squarecloud.app/v2/workspaces/members")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"workspaceId\": \"<string>\",\n \"memberId\": \"<string>\",\n \"group\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.squarecloud.app/v2/workspaces/members")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"workspaceId\": \"<string>\",\n \"memberId\": \"<string>\",\n \"group\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success"
}
更改现有 workspace 成员的角色,变更会立即对该成员在 workspace 共享应用上的访问权限生效。四个角色分别为:
view(只读)、manager(应用操作与部署信息)、maintain(增加文件、DNS、缓存清除和提交权限)、admin(增加环境变量、快照、自定义域名和部署 webhook 权限)。
只有 workspace 拥有者可以调用此端点,且拥有者不能更改自己的角色,因为拥有者始终拥有完整权限。若要添加新成员而不是更改现有成员,请参阅邀请成员。速率限制为每个用户每 15 秒 3 次修改操作。
参数
string
workspace 的 ID。
string
成员 ID。
string
该成员对 workspace 应用的权限。
响应
string
指示调用是否成功。成功时为
success,否则为 error。{
"status": "success"
}
常见错误
| 代码 | HTTP | 说明 |
|---|---|---|
INVALID_ID | 400 | 缺少 workspaceId。 |
MEMBER_NOT_FOUND | 400 | 缺少 memberId,或该 ID 不属于此 workspace。 |
CANNOT_EDIT_OWNER | 400 | 调用者尝试更改自己的角色。 |
INVALID_GROUP | 400 | group 不是 view、manager、maintain、admin 之一。 |
WORKSPACE_NOT_FOUND | 404 | 该 workspace 不存在。 |
⌘I
修改权限
curl --request PATCH \
--url https://api.squarecloud.app/v2/workspaces/members \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"workspaceId": "<string>",
"memberId": "<string>",
"group": "<string>"
}
'import requests
url = "https://api.squarecloud.app/v2/workspaces/members"
payload = {
"workspaceId": "<string>",
"memberId": "<string>",
"group": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({workspaceId: '<string>', memberId: '<string>', group: '<string>'})
};
fetch('https://api.squarecloud.app/v2/workspaces/members', 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.squarecloud.app/v2/workspaces/members",
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([
'workspaceId' => '<string>',
'memberId' => '<string>',
'group' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.squarecloud.app/v2/workspaces/members"
payload := strings.NewReader("{\n \"workspaceId\": \"<string>\",\n \"memberId\": \"<string>\",\n \"group\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.squarecloud.app/v2/workspaces/members")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"workspaceId\": \"<string>\",\n \"memberId\": \"<string>\",\n \"group\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.squarecloud.app/v2/workspaces/members")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"workspaceId\": \"<string>\",\n \"memberId\": \"<string>\",\n \"group\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success"
}

