عيّنات تعليمات برمجية

توضّح الطلبات أدناه إدارة السياسات باستخدام Policy API. قبل البدء، احرص على مراجعة نظرة عامة على Chrome Policy 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= في طلب قائمة "خدمة المخطط". على سبيل المثال، إذا كنت تريد البحث عن مخططات بها كلمة "طابعة" في الاسم وكلمة "أجهزة" في الوصف، يمكنك تطبيق القيمة التالية على عامل التصفية 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 أو كانت الاستجابة فارغة، هذا يعني أنّه لم يتم ضبط السياسة للعميل، وتم تحديد قيمة نظام تلقائية لها.

بالنسبة إلى "مجموعات Google"، سيكون مفتاح المصدر دائمًا مماثلاً للمجموعة المحدّدة في الطلب.

المثال التالي مخصص لوحدة تنظيمية. ويكون طلب المجموعة هو نفسه باستثناء طلب 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.*) تسمح لك بقراءة القيم لجميع السياسات ضمن مساحة الاسم هذه في وحدة تنظيمية أو مجموعة معيّنة. اطّلِع على مزيد من المعلومات عن مخطّطات السياسات.

المثال التالي مخصص لوحدة تنظيمية. ويكون طلب المجموعة هو نفسه باستثناء طلب 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 حقلاً واحدًا باسم 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، يتوفّر إصداران. لا يقبل الإصدار الأصلي سوى السلسلة كإدخال لـ 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 إرسال عدّة تعديلات على السياسة في الوقت نفسه. ومع ذلك، لا يمكن تجميع جميع السياسات معًا. لمعرفة مزيد من التفاصيل، يمكنك الاطّلاع على سياسات التعديلات المجمّعة.

في هذا المثال، سنعدّل، في الطلب نفسه، سياستين مختلفتين (chrome.printers.AllowForDevices وchrome.printers.AllowForUsers) للطابعة نفسها.

المثال التالي مخصص لوحدة تنظيمية. ويكون طلب المجموعة هو نفسه باستثناء طلب 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 بتعديل ترتيب الأولويات في "مجموعات Google" للتطبيق.

يشير ترتيب أرقام تعريف المجموعات في الطلب إلى الأولوية التي سيتم من خلالها تطبيق الإعدادات على التطبيق. وسيتم إلغاء سياسات المعرّفات اللاحقة من خلال السياسات التي تأتي أرقام تعريفها في موضع سابق من القائمة. ويجب أن يتضمن الطلب كل رقم تعريف مجموعة مطبّق حاليًا على التطبيق.

تجدر الإشارة إلى أنّ أولويات "المجموعة" أعلى من أولويات الوحدة التنظيمية.

في هذا الطلب، نقوم بتحديد ترتيب الأولويات لتطبيق مستخدم 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. عليك تحميل الملف الذي تريد ضبطه كقيمة لهذه السياسات إلى خادم واجهة برمجة التطبيقات، للحصول على عنوان 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"

الإجابة

يجب أن تكون الاستجابة الناجحة فارغة.

{}