앱 정책의 코드 샘플

아래 요청은 앱 정책을 예로 사용한 Policy API를 통한 정책 관리를 보여줍니다. 시작하기 전에 Chrome Policy API 개요정책 스키마 가이드를 검토하세요.

아래에 표시된 모든 요청은 다음 변수를 사용합니다.

  • $TOKEN - OAuth 2 토큰
  • $CUSTOMER - 고객 ID 또는 리터럴 my_customer

앱 강제 설치

다음은 조직 단위에 적용되는 예입니다. 그룹 요청은 id 앞에 'orgunits/' 대신 'groups/'가 있는 targetResource를 제외하고 동일합니다.

여기서는 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 필드에는 관리를 위해 추가된 조직 단위가 포함됩니다. 즉, deleteaddedSourceKey의 조직 단위가 policyTargetKey의 조직 단위와 동일한 앱에 대해서만 호출해야 합니다.

앱을 삭제 (관리에서 명시적으로 삭제)하려면 policySchema가 특정 앱 유형의 스키마이고 특정 정책 대신 별표 (*)를 사용하는 batchInherit 요청을 전송해야 합니다. 이 예에서는 '04fatzly4jbjho9' 조직 단위에 설치된 Google 드로잉 앱을 삭제합니다.

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.\* 스키마가 사용됩니다.

조직 단위의 앱에 대한 앱 설치 정책 가져오기

특정 앱의 정책을 가져오려면 요청에 정책과 앱 ID를 모두 지정해야 합니다. 이 예에서는 Google 드로잉 앱의 InstallType 정책 값을 읽습니다.

요청

  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"
      }
    }
  ]
}

조직 단위의 모든 앱에 대한 앱 설치 정책 가져오기

이전 예의 요청에서 앱 ID가 생략되면 해당 OU에 속한 모든 앱의 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"
      }
    },
    ...
  ]
}

조직 단위의 앱에 관한 모든 정책 나열

모든 앱의 정책 검색 요청에서 앱 ID를 생략할 수 있는 것처럼 정책에 와일드 카드를 사용하여 단일 앱의 모든 정책을 가져올 수도 있습니다. 이 예에서는 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"
      }
    },
    ...
  ]
}

조직 단위의 모든 앱에 대한 모든 정책 나열

OU에 속한 모든 앱의 모든 앱 설정을 요청하려면 정책에서 앱 ID를 생략하고 와일드 카드를 사용할 수 있습니다.

요청

  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 설정이 기본값으로 설정됩니다. 이 경우 요청에서 전송된 appId를 제외한 모든 AutoLaunchApp 설정이 무시됩니다.

요청

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"

응답

성공 응답은 비어 있습니다.

{}