คำขอด้านล่างแสดงการจัดการนโยบายด้วย Policy API โดยใช้ นโยบายแอปเป็นตัวอย่าง ก่อนเริ่มต้น โปรดอ่าน ภาพรวมของ Chrome Policy API และ คู่มือสคีมานโยบาย
คำขอทั้งหมดที่แสดงด้านล่างใช้ตัวแปรต่อไปนี้
- $TOKEN- โทเค็น OAuth 2
- $CUSTOMER- รหัสของลูกค้าหรือรหัสของลูกค้า- my_customer
บังคับติดตั้งแอป
ตัวอย่างต่อไปนี้เป็นตัวอย่างสำหรับหน่วยขององค์กร คำขอแบบกลุ่มจะเป็น ตัวเดียวกันยกเว้น targetResource ซึ่งจะมี "groups/" แทนที่จะเป็น "orgunits/" ข้างหน้ารหัส
ในส่วนนี้ เราจะตั้งค่าแอป Google วาดเขียนให้บังคับติดตั้ง
curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
        requests: [{
                policyTargetKey: {
                        targetResource: "orgunits/04fatzly4jbjho9",
                        additionalTargetKeys: {"app_id": "chrome:mkaakpdehdafacodkgkpghoibnmamcme"}
                        },
                policyValue: {
                        policySchema: "chrome.users.apps.InstallType",
                        value: {appInstallType: "FORCED"}
                        },
                updateMask: {paths: "appInstallType"}
                }]
      }' \
  "https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchModify"
การตอบกลับที่สำเร็จควรว่างเปล่า:
{}
ตัวอย่างนี้มีไว้สำหรับแอปของผู้ใช้ คำขอเซสชันผู้มาเยือนที่มีการจัดการจะเป็น
เหมือนกัน เว้นแต่ว่าสคีมานโยบายจะ
chrome.devices.managedguest.apps.InstallType นโยบายแอปคีออสก์ที่เทียบเท่า
ดังนี้
curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
        requests: [{
                policyTargetKey: {
                        targetResource: "orgunits/04fatzly4jbjho9",
                        additionalTargetKeys: {"app_id": "chrome:mkaakpdehdafacodkgkpghoibnmamcme"}
                        },
                policyValue: {
                        policySchema: "chrome.devices.kiosk.apps.ForceInstall",
                        value: {forceInstall: false}
                        },
                updateMask: {paths: "forceInstall"}
                }]
      }' \
  "https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchModify"
การตอบกลับที่สำเร็จควรว่างเปล่า:
{}
การลบแอป
การลบแอปจะต้องทำในหน่วยขององค์กรที่ใช้แอปนั้นอยู่
เพิ่มสำหรับการจัดการอย่างชัดเจน เมื่อเรียกใช้การแก้ไข ฟิลด์
addedSourceKey มีหน่วยขององค์กรที่เพิ่มให้
การจัดการ กล่าวคือ ควรเรียก delete สำหรับแอปที่
หน่วยขององค์กรใน addedSourceKey เท่ากับ 1 ใน
policyTargetKey
คุณควรส่งหากต้องการลบแอป (นำออกจากการจัดการอย่างชัดเจน)
คำขอ batchInherit ซึ่ง policySchema เป็นสคีมาสำหรับ
ประเภทแอปที่มีเครื่องหมายดอกจัน (*) แทนนโยบายที่เจาะจง ในตัวอย่างนี้
เรากำลังจะลบแอป Google วาดเขียน ซึ่งติดตั้งที่
"04fatzly4jbjho9" หน่วยขององค์กร:
curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
        requests: [{
                policyTargetKey: {
                        targetResource: "orgunits/04fatzly4jbjho9",
                        additionalTargetKeys: {"app_id": "chrome:gbchcmhmhahfdphkhkmpfmihenigjmpp"}
                        },
                policySchema: "chrome.users.apps.*",
                }]
      }' \
  "https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchInherit"
การตอบกลับที่สำเร็จควรว่างเปล่า:
{}
คำขอลบแอปคีออสก์และแอปเซสชันผู้เยี่ยมชมที่มีการจัดการจะใช้
chrome.devices.kiosk.apps.\* และ chrome.devices.managedguest.apps.\*
สคีมาตามลำดับ 
รับนโยบายการติดตั้งแอปสำหรับแอปในหน่วยขององค์กร
หากต้องการรับนโยบายสำหรับแอปใดแอปหนึ่ง คุณต้องระบุทั้งนโยบายและรหัสแอป ในคำขอ ในตัวอย่างนี้ เราจะอ่านค่าของ installType นโยบายสำหรับแอป Google วาดเขียน
ส่งคำขอ
  curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
        policyTargetKey: {
          targetResource: "orgunits/04fatzly4jbjho9",
          additionalTargetKeys: {"app_id": "chrome:mkaakpdehdafacodkgkpghoibnmamcme"}
        },
        policySchemaFilter: "chrome.users.apps.InstallType"
    }' \
  "https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/C02l1chq7/policies:resolve"
คำตอบ
{
  "resolvedPolicies": [
    {
      "targetKey": {
        "targetResource": "orgunits/04fatzly4jbjho9",
        "additionalTargetKeys": {
          "app_id": "chrome:mkaakpdehdafacodkgkpghoibnmamcme"
        }
      },
      "value": {
        "policySchema": "chrome.users.apps.InstallType",
        "value": {
          "appInstallType": "FORCED"
        }
      },
      "sourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      },
      "addedSourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      }
    }
  ]
}
รับนโยบายการติดตั้งแอปสำหรับทุกแอปในหน่วยขององค์กร
หากไม่ได้ระบุรหัสแอปจากคำขอในตัวอย่างก่อนหน้านี้ ระบบจะดำเนินการ กลายเป็นคำขอสำหรับค่าของนโยบาย installType สำหรับแอปทั้งหมดภายใต้ OU นั้น
ส่งคำขอ
  curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
        policyTargetKey: {
          targetResource: "orgunits/04fatzly4jbjho9",
        },
        policySchemaFilter: "chrome.users.apps.InstallType"
    }' \
  "https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/C02l1chq7/policies:resolve"
คำตอบ
{
  "resolvedPolicies": [
    {
      "targetKey": {
        "targetResource": "orgunits/04fatzly4jbjho9",
        "additionalTargetKeys": {
          "app_id": "chrome:mkaakpdehdafacodkgkpghoibnmamcme"
        }
      },
      "value": {
        "policySchema": "chrome.users.apps.InstallType",
        "value": {
          "appInstallType": "FORCED"
        }
      },
      "sourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      },
      "addedSourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      }
    },
    {
      "targetKey": {
        "targetResource": "orgunits/04fatzly4jbjho9",
        "additionalTargetKeys": {
          "app_id": "chrome:fhcfdhnmhdkemdfdncjmgnanbekfmbab"
        }
      },
      "value": {
        "policySchema": "chrome.users.apps.InstallType",
        "value": {
          "appInstallType": "ALLOWED"
        }
      },
      "sourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      },
      "addedSourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      }
    },
    ...
  ]
}
แสดงรายการนโยบายทั้งหมดสำหรับแอปในหน่วยขององค์กร
เช่นเดียวกับที่คุณสามารถละเว้นรหัสแอปจากคำขอเพื่อเรียกนโยบายสำหรับ คุณสามารถดูนโยบายทั้งหมดสำหรับแอปเดียวได้โดยใช้ไวลด์การ์ดในส่วน ในตัวอย่างนี้ เราได้รับค่าต่างๆ ของนโยบายทั้งหมดสำหรับฟิลด์ แอป Google วาดเขียน
ส่งคำขอ
  curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
        policyTargetKey: {
          targetResource: "orgunits/04fatzly4jbjho9",
          additionalTargetKeys: {"app_id": "chrome:mkaakpdehdafacodkgkpghoibnmamcme"}
        },
        policySchemaFilter: "chrome.users.apps.*"
    }' \
  "https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/C02l1chq7/policies:resolve"
คำตอบ
{
  "resolvedPolicies": [
    {
      "targetKey": {
        "targetResource": "orgunits/04fatzly4jbjho9",
        "additionalTargetKeys": {
          "app_id": "chrome:mkaakpdehdafacodkgkpghoibnmamcme"
        }
      },
      "value": {
        "policySchema": "chrome.users.apps.InstallType",
        "value": {
          "appInstallType": "FORCED"
        }
      },
      "sourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      },
      "addedSourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      }
    },
    {
      "targetKey": {
        "targetResource": "orgunits/04fatzly4jbjho9",
        "additionalTargetKeys": {
          "app_id": "chrome:mkaakpdehdafacodkgkpghoibnmamcme"
        }
      },
      "value": {
        "policySchema": "chrome.users.apps.IncludeInChromeWebStoreCollection",
        "value": {
          "includeInCollection": true
        }
      },
      "sourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      },
      "addedSourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      }
    },
    ...
  ]
}
แสดงรายการนโยบายทั้งหมดสำหรับแอปทั้งหมดในหน่วยขององค์กร
คุณละเว้นรหัสแอปและใช้ไวลด์การ์ดในนโยบายเพื่อทำสิ่งต่อไปนี้ได้ ขอการตั้งค่าแอปทั้งหมดสำหรับทุกแอปภายใต้ OU
ส่งคำขอ
  curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
        policyTargetKey: {
          targetResource: "orgunits/04fatzly4jbjho9"
        },
        policySchemaFilter: "chrome.users.apps.*"
    }' \
  "https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/C02l1chq7/policies:resolve"
คำตอบ
{
  "resolvedPolicies": [
    {
      "targetKey": {
        "targetResource": "orgunits/04fatzly4jbjho9",
        "additionalTargetKeys": {
          "app_id": "chrome:mkaakpdehdafacodkgkpghoibnmamcme"
        }
      },
      "value": {
        "policySchema": "chrome.users.apps.InstallType",
        "value": {
          "appInstallType": "FORCED"
        }
      },
      "sourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      },
      "addedSourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      }
    },
    {
      "targetKey": {
        "targetResource": "orgunits/04fatzly4jbjho9",
        "additionalTargetKeys": {
          "app_id": "chrome:mkaakpdehdafacodkgkpghoibnmamcme"
        }
      },
      "value": {
        "policySchema": "chrome.users.apps.IncludeInChromeWebStoreCollection",
        "value": {
          "includeInCollection": true
        }
      },
      "sourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      },
      "addedSourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      }
    },
    {
      "targetKey": {
        "targetResource": "orgunits/04fatzly4jbjho9",
        "additionalTargetKeys": {
          "app_id": "chrome:fhcfdhnmhdkemdfdncjmgnanbekfmbab"
        }
      },
      "value": {
        "policySchema": "chrome.users.apps.InstallType",
        "value": {
          "appInstallType": "ALLOWED"
        }
      },
      "sourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      },
      "addedSourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      }
    },
    {
      "targetKey": {
        "targetResource": "orgunits/04fatzly4jbjho9",
        "additionalTargetKeys": {
          "app_id": "chrome:fhcfdhnmhdkemdfdncjmgnanbekfmbab"
        }
      },
      "value": {
        "policySchema": "chrome.users.apps.CertificateManagement",
        "value": {
          "allowAccessToKeys": true
        }
      },
      "sourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      },
      "addedSourceKey": {
        "targetResource": "orgunits/04fatzly4jbjho9"
      }
    },
    ...
  ]
}
การล้าง Kiosk Appsconfig AutoLaunchApp
ในการล้าง AutoLaunchApp นั้น คุณสามารถตั้ง appId เป็น "None" ได้
โปรดทราบว่าเมื่อตั้งค่า appId เป็น "None" การตั้งค่า AutoLaunchApp อื่นๆ ทั้งหมด จะเป็นค่าเริ่มต้น การตั้งค่า AutoLaunchApp ใดๆ นอกเหนือจาก ระบบจะไม่สนใจ appId ที่ส่งในคำขอในกรณีนี้
ส่งคำขอ
curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
        requests: [{
                policyTargetKey: {
                        targetResource: "orgunits/04fatzly4jbjho9"
                        },
                policyValue: {
                        policySchema: "chrome.devices.kiosk.appsconfig.AutoLaunchApp",
                        value: {appId: "None"}
                        },
                updateMask: {paths: "appId"}
                }]
      }' \
  "https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchModify"
คำตอบ
การตอบกลับที่สำเร็จว่างเปล่า
{}
