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

توضّح الطلبات أدناه إدارة السياسات من خلال 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. في ما يلي طلب سياسة تطبيق Kiosk المكافئ:

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 مساوية للوحدة التنظيمية في 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"

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

{}

ستستخدم طلبات حذف تطبيقات Kiosk وتطبيقات "جلسة الضيف المُدارة" المخططَين 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/$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 لجميع التطبيقات ضمن تلك الوحدة التنظيمية.

الطلب

  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/$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/$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"
      }
    },
    ...
  ]
}

إدراج جميع السياسات لجميع التطبيقات في وحدة تنظيمية

يمكن حذف رقم تعريف التطبيق واستخدام حرف بدل في السياسة لطلب جميع إعدادات التطبيقات لجميع التطبيقات ضمن وحدة تنظيمية.

الطلب

  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/$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"

الإجابة

الرد الناجح فارغ.

{}