變更應用程式的存取權限設定

information

本頁面使用機器翻譯而成。
機器翻譯免責聲明 (External link)

目錄

變更應用程式的存取權限設定

變更應用程式的存取權限設定。

URL

在正式環境中更新應用時,URL 與在測試環境中更新應用時不同。

如果要在正式版中更新應用

運行此 API 時,測試環境中應用的所有設置都會反映在生產應用中,而不僅僅是應用程式的存取權限。

常規應用程式
https://sample.cybozu.com/k/v1/app/acl.json
訪客空間的應用程式
https://sample.cybozu.com/k/guest/GUEST_SPACE_ID/v1/app/acl.json
如果要在測試環境中更新應用
常規應用程式
https://sample.cybozu.com/k/v1/preview/app/acl.json
訪客空間的應用程式
https://sample.cybozu.com/k/guest/GUEST_SPACE_ID/v1/preview/app/acl.json

HTTP 方法

PUT

所需存取權限

  • 應用程式管理權限

請求

參數

如果設置了以下許可權,則還必須允許相關許可權。

  • 如果允許「編輯記錄」或「刪除記錄」則還必須允許「查看記錄」。
  • 如果允許「檔案的匯入」則還必須允許「新增記錄」。
參數名稱 類型 必須 說明
app 數值或字串 必須 應用ID
rights 陣列 必須 存取權限清單
按優先順序排序。
即使您為「Everyone」(所有使用者)指定了優先順序,與其他設置相比,它的優先順序也是最低的。
rights[].entity 物件 必須 設置存取權限的內容
rights[].entity.type 字串 必須 訪問許可權的類型
  • USER:使用者
  • GROUP:群組
  • ORGANIZATION:組織
  • CREATOR:建立應用程式
rights[].entity.code 字串 條件必填項 要為其設置許可權的代碼

這取決於entity.type值。
  • 對於「USER」:用戶的登入名稱
  • 對於「GROUP」:群組代碼
  • 對於「ORGANIZATION」:組織代碼
  • 對於「CREATOR」:不需要規範。
如果未指定「everyone」,則不允許對Everyone(所有使用者)進行所有操作。
如果要指定訪客,請在登入名稱前加上「guest/」。
rights[].includeSubs 布爾值或字串 可省略 設置是否由子單位繼承
  • true:繼承時
  • false:不繼承
僅當entity.type在 中指定了「ORGANIZATION」時才有效。
如果省略,則設置「false」。
rights[].appEditable 布爾值或字串 可省略 是否可以管理應用
  • true:允許應用管理
  • false:不允許應用程式管理
如果省略,則設置「false」。
rights[].recordViewable 布爾值或字串 可省略 是否可以查看記錄
  • true:允許查看
  • false:不允許查看
如果省略,則設置「false」。
rights[].recordAddable 布爾值或字串 可省略 是否可以新增記錄
  • true:允許添加記錄
  • false:不允許添加
如果省略,則設置「false」。
rights[].recordEditable 布爾值或字串 可省略 是否可以編輯記錄
  • true:允許編輯
  • false:不允許編輯
如果省略,則設置「false」。
rights[].recordDeletable 布爾值或字串 可省略 是否可以刪除記錄
  • true:允許刪除
  • false:不允許刪除
如果省略,則設置「false」。
rights[].recordImportable 布爾值或字串 可省略 是否可以檔案的匯入
  • true:允許讀取檔
  • false:不允許讀取檔
如果省略,則設置「false」。
rights[].recordExportable 布爾值或字串 可省略 是否可以檔案的匯出
  • true:允許檔案匯出
  • false:不允許檔匯出
如果省略,則設置「false」。
revision 數值或字串 可省略 預期修訂號
如果與實際修訂號不匹配,則會發生錯誤,並且不會變更設置。
如果指定值「-1」或未指定值,則不會驗證修訂號。
請求範例
標頭
1
2
3
4
{
  "X-Cybozu-API-Token": "API_TOKEN",
  "Content-Type": "application/json"
}

有關請求頭的詳細資訊,請參閱通用規格。
kintone REST API通用規範

內文
 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
{
  "app": 1,
  "rights": [
    {
      "entity": {
        "type": "USER",
        "code": "user1"
      },
      "appEditable": true,
      "recordViewable": true,
      "recordAddable": true,
      "recordEditable": true,
      "recordDeletable": true,
      "recordImportable": true,
      "recordExportable": true
    },
    {
      "entity": {
        "type": "GROUP",
        "code": "group1"
      },
      "appEditable": false,
      "recordViewable": false,
      "recordAddable": false,
      "recordEditable": false,
      "recordDeletable": false,
      "recordImportable": false,
      "recordExportable": false
    },
    {
      "entity": {
        "type": "ORGANIZATION",
        "code": "org1"
      },
      "includeSubs": true,
      "appEditable": false,
      "recordViewable": true,
      "recordAddable": true,
      "recordEditable": true,
      "recordDeletable": true,
      "recordImportable": true,
      "recordExportable": true
    },
    {
      "entity": {
        "type": "CREATOR"
      },
      "appEditable": true,
      "recordViewable": true,
      "recordAddable": true,
      "recordEditable": true,
      "recordDeletable": true,
      "recordImportable": true,
      "recordExportable": true
    }
  ],
  "revision": 2
}

回應

屬性
屬性名稱 類型 說明
revision 字串 變更應用設置后的修訂號
應答範例
1
2
3
{
  "revision": "3"
}

示例代碼

使用 curl 的請求
 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
curl -X PUT 'https://sample.cybozu.com/k/v1/app/acl.json' \
  -H 'X-Cybozu-API-Token: API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "app": 1,
    "rights" [
      {
        "entity": {
          "type": "USER",
          "code": "user1"
        },
        "appEditable": true,
        "recordViewable": true,
        "recordAddable": true,
        "recordEditable": true,
        "recordDeletable": true,
        "recordImportable": true,
        "recordExportable": true
      }, {
        "entity": {
          "type": "GROUP",
          "code": "everyone"
        },
        "includeSubs": true,
        "appEditable": true,
        "recordViewable": true,
        "recordAddable": true,
        "recordEditable": true,
        "recordDeletable": true,
        "recordImportable": false,
        "recordExportable": false
      }, {
        "entity": {
          "type": "CREATOR"
        },
        "appEditable": true,
        "recordViewable": true,
        "recordAddable": true,
        "recordEditable": true,
        "recordDeletable": true,
        "recordImportable": true,
        "recordExportable": true
      }
    ]
  }'
kintone.api()請求使用

有關詳細的kintone.api(),請參閱以下頁面。
發送kintone REST API請求

 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
const body = {
  app: kintone.app.getId(),
  rights: [
    {
      entity: {
        type: 'USER',
        code: 'user1'
      },
      appEditable: true,
      recordViewable: true,
      recordAddable: true,
      recordEditable: true,
      recordDeletable: true,
      recordImportable: true,
      recordExportable: true
    }, {
      entity: {
        type: 'GROUP',
        code: 'everyone'
      },
      includeSubs: true,
      appEditable: true,
      recordViewable: true,
      recordAddable: true,
      recordEditable: true,
      recordDeletable: true,
      recordImportable: false,
      recordExportable: false
    }, {
      entity: {
        type: 'CREATOR'
      },
      appEditable: true,
      recordViewable: true,
      recordAddable: true,
      recordEditable: true,
      recordDeletable: true,
      recordImportable: true,
      recordExportable: true
    }
  ]
};
await kintone.api(kintone.api.url('/k/v1/app/acl.json', true), 'PUT', body);