คำขอด้านล่างแสดงการจัดการนโยบายด้วย Policy API ก่อนที่จะเริ่มต้น โปรดอ่านภาพรวมของ API นโยบาย Chrome เพื่อดูข้อมูลสรุประดับสูงเกี่ยวกับคุณลักษณะของ API นี้
คำขอทั้งหมดที่แสดงอยู่ด้านล่างใช้ตัวแปรต่อไปนี้
$TOKEN
- โทเค็น OAuth 2$CUSTOMER
- รหัสลูกค้าหรือลิเทอรัลmy_customer
แสดงรายการสคีมาสำหรับนโยบายเครื่องพิมพ์
หากต้องการแสดงสคีมาที่เกี่ยวข้องกับนโยบายสำหรับเครื่องพิมพ์เท่านั้น เราจะใช้พารามิเตอร์ filter
กับคำขอรายการบริการสคีมา คุณสามารถควบคุมการใส่เลขหน้าผลลัพธ์โดยใช้พารามิเตอร์ pageSize
และ pageToken
ส่งคำขอ
curl -X GET \
-H "Authorization: Bearer $TOKEN" \
"https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policySchemas?filter=chrome.printers&pageSize=2"
คำตอบ
{
"policySchemas": [
{
"name": "customers/C0202nabg/policySchemas/chrome.printers.AllowForUsers",
"policyDescription": "Allows a printer for users in a given organization.",
"additionalTargetKeyNames": [
{
"key": "printer_id",
"keyDescription": "Id of printer as visible in Admin SDK printers API."
}
],
"definition": {
"messageType": [
{
"name": "AllowForUsers",
"field": [
{
"name": "allowForUsers",
"number": 1,
"label": "LABEL_OPTIONAL",
"type": "TYPE_BOOL"
}
]
}
]
},
"fieldDescriptions": [
{
"field": "allowForUsers",
"description": "Controls whether a printer is allowed for users in a given organization."
}
],
"schemaName": "chrome.printers.AllowForUsers"
},
{
"name": "customers/C0202nabg/policySchemas/chrome.printers.AllowForDevices",
"policyDescription": "Allows a printer for devices in a given organization.",
"additionalTargetKeyNames": [
{
"key": "printer_id",
"keyDescription": "Id of printer as visible in Admin SDK printers API."
}
],
"definition": {
"messageType": [
{
"name": "AllowForDevices",
"field": [
{
"name": "allowForDevices",
"number": 1,
"label": "LABEL_OPTIONAL",
"type": "TYPE_BOOL"
}
]
}
]
},
"fieldDescriptions": [
{
"field": "allowForDevices",
"description": "Controls whether a printer is allowed for devices in a given organization."
}
],
"schemaName": "chrome.printers.AllowForDevices"
}
],
"nextPageToken": "AEbDN_obE8A98T8YhIeU9VCIZhEBylLBwZRQpGu_DUug-mU4bnzcDx30UnO2xMuuImvfVpmeuXRF6VhJ4OmZpZ4H6EaRvu2qMOPxVN_u"
}
ค้นหาสคีมา
คุณอาจสร้างคำค้นหาที่ซับซ้อนได้โดยใช้พารามิเตอร์ filter=
ในคำขอรายการบริการสคีมา เช่น หากต้องการค้นหาสคีมาที่มีคำว่า "printer" ในชื่อและคำว่า "devices" ในคำอธิบาย คุณอาจใช้ค่าต่อไปนี้กับตัวกรอง name=printers AND description=devices
ได้
ดูวิธีระบุสคีมานโยบาย
ส่งคำขอ
curl -X GET \
-H "Authorization: Bearer $TOKEN" \
"https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policySchemas?filter=name=printers%20AND%20description=devices"
คำตอบ
{
"policySchemas": [
{
"name": "customers/C0202nabg/policySchemas/chrome.printers.AllowForDevices",
"policyDescription": "Allows a printer for devices in a given organization.",
"additionalTargetKeyNames": [
{
"key": "printer_id",
"keyDescription": "Id of printer as visible in Admin SDK printers API."
}
],
"definition": {
"messageType": [
{
"name": "AllowForDevices",
"field": [
{
"name": "allowForDevices",
"number": 1,
"label": "LABEL_OPTIONAL",
"type": "TYPE_BOOL"
}
]
}
]
},
"fieldDescriptions": [
{
"field": "allowForDevices",
"description": "Controls whether a printer is allowed for devices in a given organization."
}
],
"schemaName": "chrome.printers.AllowForDevices"
}
]
}
รับสคีมาเฉพาะ
ในผลลัพธ์ข้างต้น คุณจะเห็นรายการสคีมานโยบายที่รองรับ แต่ละสคีมาจะมีช่อง name
ที่ระบุสคีมา ในอนาคต เมื่อทราบชื่อสคีมาแล้ว คุณอาจอ่านสคีมานั้นๆ ได้โดยตรงด้วยการอ้างถึงชื่อสคีมาใน URL ของคำขอ
ดูตัวอย่างสคีมา chrome.printers.AllowForUsers
กัน
ส่งคำขอ
curl -X GET \
-H "Authorization: Bearer $TOKEN" \
"https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policySchemas/chrome.printers.AllowForUsers"
คำตอบ
{
"name": "customers/C0202nabg/policySchemas/chrome.printers.AllowForUsers",
"policyDescription": "Allows a printer for users in a given organization.",
"additionalTargetKeyNames": [
{
"key": "printer_id",
"keyDescription": "Id of printer as visible in Admin SDK printers API."
}
],
"definition": {
"messageType": [
{
"name": "AllowForUsers",
"field": [
{
"name": "allowForUsers",
"number": 1,
"label": "LABEL_OPTIONAL",
"type": "TYPE_BOOL"
}
]
}
]
},
"fieldDescriptions": [
{
"field": "allowForUsers",
"description": "Controls whether a printer is allowed for users in a given organization."
}
],
"schemaName": "chrome.printers.AllowForUsers"
}
ข้อมูลตอบกลับของสคีมานโยบายด้านบนจะอธิบายสคีมาของนโยบาย chrome.printers.AllowForUsers
ช่องประกาศ additionalTargetKeyNames
ช่องนี้อธิบายว่านโยบายนี้จำเป็นต้องระบุคีย์/ค่าเพิ่มเติมเมื่อต้องจัดการกับนโยบายนี้ โดยเฉพาะอย่างยิ่ง สำหรับนโยบายนี้ เราต้องระบุ
ตัวระบุของเครื่องพิมพ์เสมอ
อ่านค่านโยบาย
มาอ่านนโยบาย chrome.printers.AllowForUsers
สำหรับเครื่องพิมพ์บางรุ่นกัน
แจ้งให้ทราบโดยใช้ช่อง additionalTargetKeys
เพื่อระบุรหัสเครื่องพิมพ์ในคำขอ
คุณอ่านนโยบายจากหน่วยขององค์กรหรือกลุ่มได้
ในการตอบสนอง ให้สังเกตช่อง sourceKey
ซึ่งระบุหน่วยขององค์กรหรือกลุ่มที่ค่าของนโยบายนั้นมาจาก ความเป็นไปได้สำหรับหน่วยขององค์กรมีดังนี้
- หากหน่วยขององค์กรต้นทางเหมือนกับหน่วยขององค์กรที่ระบุไว้ในคำขอ หมายความว่านโยบายจะใช้ภายในหน่วยขององค์กรนี้
- หากหน่วยขององค์กรต้นทางแตกต่างจากหน่วยขององค์กรที่ให้ไว้ในคำขอ หมายความว่านโยบายจะรับค่ามาจากหน่วยขององค์กรต้นทาง
- หากไม่มี
sourceKey
หรือการตอบกลับว่างเปล่า แสดงว่าไม่มีการตั้งค่านโยบายให้กับลูกค้า และค่าเริ่มต้นของระบบ
สำหรับ Groups แล้ว sourceKey จะเหมือนกับกลุ่มที่ระบุในคำขอเสมอ
ตัวอย่างต่อไปนี้มีไว้สำหรับหน่วยขององค์กร คำขอ Group จะเหมือนกัน ยกเว้น targetResource ซึ่งจะมี "groups/" แทนที่จะเป็น "orgunits/" ก่อนรหัส
ส่งคำขอ
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
policyTargetKey: {
targetResource: "orgunits/04fatzly4jbjho9",
additionalTargetKeys: {"printer_id":"0gjdgxs208tpef"}
},
policySchemaFilter: "chrome.printers.AllowForDevices"
}' \
"https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies:resolve"
คำตอบ
{
"resolvedPolicies": [
{
"targetKey": {
"targetResource": "orgunits/03ph8a2z1xdnme9"
"additionalTargetKeys": {"printer_id":"0gjdgxs208tpef"}
},
"value": {
"policySchema": "chrome.users.AllowForDevices",
"value": {
"allowForDevices": true
}
},
"sourceKey": {
"targetResource": "orgunits/03ph8a2z3qhz81k"
}
}
]
}
โปรดทราบว่าคุณสามารถดึงข้อมูลเอนทิตีทั้งหมดในทรัพยากรเป้าหมายได้โดยการละเว้น additionalTargetKeys
ในคำขอ ตัวอย่างเช่น หากละเว้น additionalTargetKeys
จากคำขอข้างต้น ระบบจะแสดงเครื่องพิมพ์ทั้งหมดในทรัพยากรเป้าหมายที่ระบุ
อ่านนโยบายหลายรายการ
การระบุเนมสเปซของสคีมาที่มีเครื่องหมายดอกจัน (เช่น chrome.printers.*
) ช่วยให้คุณอ่านค่าของนโยบายทั้งหมดภายใต้เนมสเปซนี้ในหน่วยขององค์กรหรือกลุ่มที่เฉพาะเจาะจงได้ ดูข้อมูลเพิ่มเติมเกี่ยวกับสคีมานโยบาย
ตัวอย่างต่อไปนี้มีไว้สำหรับหน่วยขององค์กร คำขอ Group จะเหมือนกัน ยกเว้น targetResource ซึ่งจะมี "groups/" แทนที่จะเป็น "orgunits/" ก่อนรหัส
ส่งคำขอ
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
policyTargetKey: {
targetResource: "orgunits/04fatzly4jbjho9",
},
policySchemaFilter: "chrome.printers.*"
}' \
"https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies:resolve"
คำตอบ
{
"resolvedPolicies": [
{
"targetKey": {
"targetResource": "orgunits/04fatzly4jbjho9",
"additionalTargetKeys": {
"printer_id": "0gjdgxs0xd59y1"
}
},
"value": {
"policySchema": "chrome.printers.AllowForUsers",
"value": {
"allowForUsers": false
}
}
},
{
"targetKey": {
"targetResource": "orgunits/04fatzly4jbjho9",
"additionalTargetKeys": {
"printer_id": "0gjdgxs0xd59y1"
}
},
"value": {
"policySchema": "chrome.printers.AllowForDevices",
"value": {
"allowForDevices": false
}
}
},
//...
],
"nextPageToken": "AEbDN_pFvDeGSbQDkvMxr4UA0Ew7UEUw8aJyw95VPs2en6YxMmFcWQ9OQQEIeSkjnWFCQNyz5GGoOKQGEd50e2z6WqvM2w7sQz6TMxVOBD_4NmEHRWtIJCYymeYXWHIrNH29Ezl1wkeyYBAOKnE="
}
แก้ไขค่านโยบาย
ตามที่เห็นในการตอบกลับสคีมานโยบาย นโยบาย chrome.printers.AllowForUsers
มี 1 ช่องที่ชื่อว่า allowForUsers
ช่องนี้เป็นประเภทบูลีน ค่าของตัวอย่างนโยบายอาจเป็น {allowForUsers: false}
หรือ {allowForUsers: true}
ในกรณีนี้ เรามีเพียงช่องเดียว
แต่นโยบายอื่นๆ อาจมีหลายช่อง
ในคำขอแก้ไข เราต้องระบุ updateMask
อัปเดตมาสก์จะแสดง
ช่องทั้งหมดที่เราต้องการแก้ไข หากมีการใช้นโยบายภายในหน่วยองค์กรอยู่แล้ว ช่องที่ไม่ได้แสดงอยู่ในมาสก์การอัปเดตจะยังคงเหมือนเดิม หากไม่มีการใช้นโยบายภายในหน่วยขององค์กร และช่องทั้งหมดที่ไม่ได้ระบุไว้ในมาสก์การอัปเดตจะคัดลอกค่าจากหน่วยขององค์กรระดับบนสุดตามความเหมาะสม และนโยบายทั้งหมดจะถูกนำไปใช้ในเครื่อง
ตัวอย่างต่อไปนี้มีไว้สำหรับหน่วยขององค์กร คำขอของกลุ่มจะเหมือนกัน ยกเว้น targetResource ซึ่งจะมี "groups/" แทน "orgunits/" นำหน้ารหัส ในที่นี้เราจะไม่อนุญาตเครื่องพิมพ์ 0gjdgxs208tpef
สำหรับผู้ใช้ในรหัสหน่วยขององค์กร 04fatzly4jbjho9
:
ส่งคำขอ
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
requests: [{
policyTargetKey: {
targetResource: "orgunits/04fatzly4jbjho9",
additionalTargetKeys: {"printer_id":"0gjdgxs208tpef"}
},
policyValue: {
policySchema: "chrome.printers.AllowForUsers",
value: {allowForUsers: false}
},
updateMask: {paths: "allowForUsers"}
}]
}' \
"https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchModify"
คำตอบ
การตอบกลับที่สำเร็จว่างเปล่า
{}
ช่องที่มีค่าหลายค่า เช่น รายการหรืออาร์เรย์จะมีป้ายกำกับ "LABEL_REPEATED" หากต้องการป้อนข้อมูลในช่องหลายค่า ให้ใช้รูปแบบอาร์เรย์ JSON ต่อไปนี้
[value1, value2, value3, ...]
ตัวอย่างเช่น หากต้องการตั้งค่า URL แหล่งที่มาสำหรับแพ็กเกจแอปและส่วนขยายเป็น "test1.com", "test2.com" และ "test3.com" เราจะต้องส่งคำขอต่อไปนี้
ส่งคำขอ
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d "{
requests: [
{
policy_target_key: {
target_resource: 'orgunits/03ph8a2z28rz85a'
},
updateMask: {
paths: ['extensionInstallSources']
},
policy_value: {
policy_schema: 'chrome.users.appsconfig.AppExtensionInstallSources',
value: {
extensionInstallSources: ['test1.com', 'test2.com', 'test3.com']
}
}
}
]
}" \
"https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchModify"
คำตอบ
การตอบกลับที่สำเร็จว่างเปล่า
{}
นโยบายทั้งหมดที่มีช่อง NullableDuration จะมี 2 เวอร์ชัน เวอร์ชันเดิมยอมรับสตริงเป็นอินพุตสำหรับ NullableDuration เท่านั้นและเลิกใช้งานแล้ว โปรดใช้เวอร์ชัน V2 ซึ่งแทนที่ประเภทระยะเวลาด้วยอินพุตตัวเลข ตัวอย่างเช่น หากต้องการกำหนดระยะเวลาเซสชันสูงสุดของผู้ใช้เป็น 10 นาที เราต้องส่งคำขอต่อไปนี้
ส่งคำขอ
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d "{
requests: [
{
policy_target_key: {
target_resource: 'orgunits/03ph8a2z28rz85a'
},
updateMask: {
paths: ['sessionDurationLimit']
},
policy_value: {
policy_schema: 'chrome.users.SessionLengthV2',
value: {
sessionDurationLimit: {
duration: 10
}
}
}
}
]
}" \
"https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchModify"
คำตอบ
การตอบกลับที่สำเร็จว่างเปล่า
{}
แก้ไขหลายนโยบายพร้อมกัน
เมธอด batchModify
ช่วยให้คุณส่งการแก้ไขนโยบายหลายรายการพร้อมกันได้
อย่างไรก็ตาม นโยบายทั้งหมดไม่สามารถรวมไว้ด้วยกันได้ ดูรายละเอียดเพิ่มเติมได้ที่นโยบายการอัปเดตแบบกลุ่ม
ในตัวอย่างนี้ เราจะแก้ไขนโยบายที่ต่างกัน 2 นโยบาย (chrome.printers.AllowForDevices
และ chrome.printers.AllowForUsers
) สำหรับเครื่องพิมพ์เดียวกันในคำขอเดียวกัน
ตัวอย่างต่อไปนี้มีไว้สำหรับหน่วยขององค์กร คำขอ Group จะเหมือนกัน ยกเว้น targetResource ซึ่งจะมี "groups/" แทนที่จะเป็น "orgunits/" ก่อนรหัส
ส่งคำขอ
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
requests: [{
policyTargetKey: {
targetResource: "orgunits/04fatzly4jbjho9",
additionalTargetKeys: {"printer_id":"0gjdgxs208tpef"}
},
policyValue: {
policySchema: "chrome.printers.AllowForDevices",
value: {allowForDevices: true}
},
updateMask: {paths: "allowForDevices"}
},
{
policyTargetKey: {
targetResource: "orgunits/04fatzly4jbjho9",
additionalTargetKeys: {"printer_id":"0gjdgxs208tpef"}
},
policyValue: {
policySchema: "chrome.printers.AllowForUsers",
value: {allowForUsers: true}
},
updateMask: {paths: "allowForUsers"}
}]
}' \
"https://chromepolicy.googleapis.com/v1/customers/C0202nabg/policies/orgunits:batchModify"
คำตอบ
การตอบกลับที่สำเร็จว่างเปล่า
{}
รับค่านโยบายในหน่วยขององค์กร
เมธอด batchInherit
ช่วยให้คุณแก้ไขสถานะของนโยบายในหน่วยขององค์กรจาก "ใช้เฉพาะในพื้นที่" เป็น "รับค่าเดิม" ได้ ระบบจะล้างค่าในเครื่อง และนโยบายจะรับค่าจากหน่วยขององค์กรระดับบนสุด (หากมี)
เมธอด batchInherit
ยังช่วยให้คุณส่งคำขอที่รับช่วงค่านโยบายหลายรายการพร้อมกันได้ด้วย อย่างไรก็ตาม นโยบายทั้งหมดไม่สามารถรวมไว้ด้วยกันได้
ดูรายละเอียดเพิ่มเติมได้ที่นโยบายการอัปเดตแบบกลุ่ม
ส่งคำขอ
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
requests: [{
policyTargetKey: {
targetResource: "orgunits/04fatzly12wd3ox",
additionalTargetKeys: {"printer_id":"0gjdgxs208tpef"}
},
policySchema: "chrome.printers.AllowForUsers"
}]
}' \
"https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchInherit"
คำตอบ
การตอบกลับที่สำเร็จว่างเปล่า
{}
ลบค่านโยบายในกลุ่ม
เมธอด batchDelete
ช่วยให้คุณลบนโยบายออกจากกลุ่มได้ ค่าในเครื่องจะถูกล้าง
เมธอด batchDelete
ยังช่วยให้คุณส่งคำขอลบนโยบายหลายรายการพร้อมกันได้ อย่างไรก็ตาม นโยบายทั้งหมดไม่สามารถรวมไว้ด้วยกันได้
ดูรายละเอียดเพิ่มเติมได้ที่นโยบายการอัปเดตเป็นกลุ่ม
ส่งคำขอ
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
requests: [{
policyTargetKey: {
targetResource: "groups/04fatzly12wd3ox",
additionalTargetKeys: {"printer_id":"0gjdgxs208tpef"}
},
policySchema: "chrome.printers.AllowForUsers"
}]
}' \
"https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/groups:batchDelete"
คำตอบ
การตอบกลับที่สำเร็จว่างเปล่า
{}
แสดงลำดับความสำคัญของกลุ่ม
เมธอด listGroupPriorityOrdering
ให้คุณระบุลำดับความสำคัญของกลุ่มสำหรับแอปหนึ่งๆ ได้
ลำดับของรหัสกลุ่มที่แสดงผลแสดงถึงลำดับความสำคัญที่จะนำการตั้งค่าไปใช้กับแอป ส่วนนโยบายรหัสภายหลังจะถูกลบล้างโดยนโยบายที่มีรหัสอยู่ในช่วงต้นของรายการ
โปรดทราบว่าลำดับความสำคัญของกลุ่มจะสูงกว่าลำดับความสำคัญของหน่วยขององค์กร
ในคำขอนี้ เรากำลังส่งคืนการเรียงลำดับความสำคัญของแอปผู้ใช้ Chrome "exampleapp"
ส่งคำขอ
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
policyTargetKey: {
additionalTargetKeys: {"app_id":"chrome:exampleapp"}
},
policyNamespace: 'chrome.users.apps'
}' \
"https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/groups:listGroupPriorityOrdering"
คำตอบ
{
"policyTargetKey": {
"additionalTargetKeys": {
"app_id": "chrome:exampleapp"
}
},
"policyNamespace": "chrome.users.apps",
"groupIds": [
"03ep43zb2k1nodu",
"01t3h5sf2k52kol",
"03q5sasy2ihwnlz"
]
}
อัปเดตลำดับความสำคัญของกลุ่ม
เมธอด updateGroupPriorityOrdering
ช่วยให้คุณอัปเดตลำดับความสำคัญของกลุ่มสำหรับแอปได้
ลำดับของรหัสกลุ่มในคำขอบ่งบอกถึงลำดับความสำคัญที่จะนำการตั้งค่าไปใช้กับแอป นโยบายที่มีรหัสภายหลังจะถูกลบล้างโดยนโยบายที่มีรหัสอยู่ในช่วงต้นของรายการ โดยคำขอจะต้องมีรหัสกลุ่มทั้งหมดที่ใช้ในแอปในปัจจุบัน
โปรดทราบว่าลำดับความสำคัญของกลุ่มจะสูงกว่าลำดับความสำคัญของหน่วยขององค์กร
ในคำขอนี้ เราจะตั้งค่าลำดับความสำคัญของแอปผู้ใช้ Chrome "exampleapp"
ส่งคำขอ
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
policyTargetKey: {
additionalTargetKeys: {"app_id":"chrome:exampleapp"}
},
policyNamespace: 'chrome.users.apps',
groupIds: ['03ep43zb2k1nodu', '01t3h5sf2k52kol', '03q5sasy2ihwnlz']
}' \
"https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/groups:updateGroupPriorityOrdering"
คำตอบ
การตอบกลับที่สำเร็จว่างเปล่า
{}
การจัดการนโยบายที่ต้องรับทราบ
สคีมานโยบายบางแบบระบุ "การแจ้งเตือน" สำหรับค่าบางช่องที่ต้องมีการรับทราบ
ตัวอย่างสำหรับนโยบาย chrome.users.PluginVmAllowd
{
"name": "customers/C0202nabg/policySchemas/chrome.users.PluginVmAllowed",
"policyDescription": "Parallels Desktop.",
# ...
"fieldDescriptions": [
{
"field": "pluginVmAllowed",
"description": "N/A",
"knownValueDescriptions": [
{
"value": "true",
"description": "Allow users to use Parallels Desktop."
},
{
"value": "false",
"description": "Do not allow users to use Parallels Desktop."
}
]
},
{
"field": "ackNoticeForPluginVmAllowedSetToTrue",
"description": "This field must be set to true to acknowledge the notice message associated with the field 'plugin_vm_allowed' set to value 'true'. Please see the notices listed with this policy for more information."
}
],
"notices": [
{
"field": "pluginVmAllowed",
"noticeValue": "true",
"noticeMessage": "By enabling Parallels Desktop, you agree to the Parallels End-User License Agreement specified at https://www.parallels.com/about/legal/eula/. Warning: Device identifiers may be shared with Parallels. Please see privacy policy for more details at https://www.parallels.com/about/legal/privacy/. The minimum recommended configuration includes an i5 processor, 16 GB RAM, and 128 GB storage: https://support.google.com/chrome/a/answer/10044480.",
"acknowledgementRequired": true
}
],
"supportUri": "...",
"schemaName": "chrome.users.PluginVmAllowed"
}
ในตัวอย่างข้างต้น การตั้งค่าของช่อง pluginVmAllowed
เป็น true
จะเชื่อมโยงกับประกาศที่มี acknowledgementRequired
หากต้องการตั้งค่าช่องนี้เป็น true
ให้ถูกต้อง คุณจะต้องส่งคำขอที่ระบุช่องรับทราบ ackNoticeForPluginVmAllowedSetToTrue
ไปยัง true
มิเช่นนั้นระบบจะแสดงข้อผิดพลาดในคำขอ
ในตัวอย่างนี้ คุณจะต้องส่งคำขอแก้ไขเป็นกลุ่มต่อไปนี้
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d "{
'requests': [
{
'policyTargetKey': {
'targetResource': 'orgunits/03ph8a2z10ybbh2'
},
'policyValue': {
'policySchema': 'chrome.users.PluginVmAllowed',
'value': {
'pluginVmAllowed': true,
'ackNoticeForPluginVmAllowedSetToTrue': true
}
},
'updateMask': {
'paths': [
'pluginVmAllowed',
'ackNoticeForPluginVmAllowedSetToTrue'
]
}
}
]
}" \
"https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchModify"
การตั้งค่านโยบายไฟล์
นโยบายบางอย่างมีช่องพิมพ์เป็น UploadedFile
คุณจะต้องอัปโหลดไฟล์ที่ต้องการตั้งเป็นค่าของนโยบายเหล่านั้นไปยังเซิร์ฟเวอร์ API เพื่อรับ URL ที่จะใช้ในคำขอ BatchModify
ในตัวอย่างนี้ เราจะตั้งค่า chrome.users.Wallpaper
โดยการอัปโหลดไฟล์ JPEG
อัปโหลดไฟล์
ส่งคำขอ
curl -X POST \
-H "Content-Type: image/jpeg" \
-H "Authorization: Bearer $TOKEN" \
-T "/path/to/the/file" \
"https://chromepolicy.googleapis.com/upload/v1/customers/$CUSTOMER/policies/files:uploadPolicyFile?policy_field=chrome.users.Wallpaper.wallpaperImage"
คำตอบ
การตอบกลับที่ประสบความสำเร็จควรมี URL สำหรับเข้าถึงไฟล์:
{
"downloadUri": "https://storage.googleapis.com/chromeos-mgmt/0gjdgxs370bkl6/ChromeOsWallpaper/32ac50ab-b5ae-4bba-afa8-b6b443912897"
}
ตั้งค่านโยบายไฟล์
ส่งคำขอ
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
requests: [{
policyTargetKey: {
targetResource: "orgunits/04fatzly4jbjho9",
},
policyValue: {
policySchema: "chrome.users.Wallpaper",
value: {
wallpaperImage: {downloadUri: "https://storage.googleapis.com/chromeos-mgmt/0gjdgxs370bkl6/ChromeOsWallpaper/32ac50ab-b5ae-4bba-afa8-b6b443912897"}
}
},
updateMask: {paths: "wallpaperImage"}
}]
}' \
"https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchModify"
คำตอบ
การตอบกลับที่สำเร็จควรเว้นว่างไว้
{}