작동 방식

고객 API는 프로그래매틱 방식으로 기기 및 Android 제로터치 등록 구성 이 문서에서는 엔터프라이즈 모바일 관리 (EMM) 제공업체 및 엔터프라이즈 IT에 대한 API 있습니다. 이 문서를 읽은 후에는 상호작용하는 방식을 보여줍니다. 제로터치를 처음 사용하는 경우 자세한 내용은 간단한 android.com 소개를 참조하세요.

 개요

Customer API는 Android 제로터치 등록을 구매하는 조직을 지원합니다. 기기에서 사용할 수 있습니다. IT 관리자는 앱이나 도구를 사용하여 다음 작업을 할 수 있습니다.

  • 프로비저닝 구성을 생성, 수정, 삭제합니다.
  • 기기에 구성을 적용하거나 삭제합니다.
  • 제로터치 등록에 추가된 기기의 기본 구성을 선택합니다. .

IT 관리자는 API를 통해 제로터치에서 기기를 등록 취소할 수도 있습니다. 있습니다. 조직의 사용자를 관리하거나 서비스 약관에 동의하려면 IT 관리자는 제로터치 등록 포털을 사용합니다.

이 API의 일반적인 사용자는 다음과 같습니다.

  • EMM 제공업체가 콘솔에 제로터치 등록 지원을 추가합니다.
  • 제로터치 등록을 자동화하는 도구를 만드는 엔터프라이즈 IT 개발자 할 수 있습니다

핵심 리소스

구성 및 기기는 API에서 사용하는 핵심 리소스입니다. 조직에서 제로터치를 사용하여 구성 및 기기를 등록할 수 있습니다.

기기 및 고객 리소스 관계

구성
IT 관리자는 구성을 사용하여 기기의 프로비저닝 옵션을 설정합니다. 구성에는 다음에 표시되는 EMM 모바일 정책과 연락처 정보가 포함됩니다. 도움이 됩니다. 구성은 API의 핵심이므로 많은 작업에 사용합니다. 메서드를 참조하세요. 자세한 내용은 아래 구성을 참고하세요.
기기
조직에서 구매한 제로터치 등록 지원 Android 기기 확인할 수 있습니다 제로터치에 기기를 포함하도록 구성 적용 있습니다. 기기에는 하드웨어 ID와 연결된 메타데이터가 있습니다. 자세한 내용은 기기는 아래를 참고하세요.
DPC 옵션
EMM의 DPC (기기 정책)에 대한 읽기 전용 참조입니다. 컨트롤러)입니다. DPC 추가 기기의 EMM 솔루션을 선택하는 구성으로 이동 나열된 모든 DPC 제로터치 등록을 지원하며 Google Play에서 다운로드할 수 있습니다. 받는사람 자세한 내용은 Dpc를 참고하세요.

앱에서 사용할 수 있는 모든 API 메서드와 리소스를 나열하려면 다음을 참조하세요. API 참조

구성

Configuration API 리소스는 있습니다.

  • 기기에 설치된 EMM의 DPC
  • 기기에 적용된 EMM 정책
  • 설정 중 사용자를 지원하기 위해 기기에 표시되는 연락처 정보입니다.

API를 사용하여 앱에서 IT 관리자를 위해 구성을 관리할 수 있습니다. API를 호출하여 구성을 가져오고, 만들고, 업데이트하고, 삭제할 수 있습니다. 아래 예는 새 구성을 만듭니다.

자바

// Add metadata to help the device user during provisioning.
Configuration configuration = new Configuration();
configuration.setConfigurationName("Sales team");
configuration.setCompanyName("XYZ Corp.");
configuration.setContactEmail("it-support@example.com");
configuration.setContactPhone("+1 (800) 555-0112");
configuration.setCustomMessage("We're setting up your phone. Call or email for help.");

// Set the DPC that zero-touch enrollment downloads and installs from Google Play.
configuration.setDpcResourcePath(dpc.getName());

// Set the JSON-formatted EMM provisioning extras that are passed to the DPC.
configuration.setDpcExtras("{"
      + "\"android.app.extra.PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED\":true,"
      + "\"android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE\":{"
      + "\"default_min_password_length\":6,"
      + "\"company_name\":\"XYZ Corp\","
      + "\"management_server\":\"emm.example.com\","
      + "\"terms_url\":\"https://www.example.com/policies/terms/\","
      + "\"allowed_user_domains\":\"[\\\"example.com\\\", \\\"example.org\\\"]\""
      + "}"
      + "}");

// Create the new configuration on the server.
AndroidProvisioningPartner.Customers.Configurations.Create request =
      service.customers().configurations().create(customerAccount, configuration);
Configuration response = request.execute();

.NET

// Add metadata to help the device user during provisioning.
Configuration configuration = new Configuration
{
    ConfigurationName = "Sales team",
    CompanyName = "XYZ Corp.",
    ContactEmail = "it-support@example.com",
    ContactPhone = "+1 (800) 555-0112",
    CustomMessage = "We're setting up your phone. Call or email for help."
};

// Set the DPC that zero-touch enrollment downloads and installs from Google Play.
configuration.DpcResourcePath = dpc.Name;

// Set the JSON-formatted EMM provisioning extras that are passed to the DPC.
configuration.DpcExtras = @"{
    ""android.app.extra.PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED"":true,
    ""android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE"":{
    ""default_min_password_length"":6,
    ""company_name"":""XYZ Corp"",
    ""management_server"":""emm.example.com"",
    ""terms_url"":""https://www.example.com/policies/terms/"",
    ""allowed_user_domains"":""[\""example.com\"", \""example.org\""]""
  }
}";

// Create the new configuration on the server.
var request = service.Customers.Configurations.Create(configuration, customerAccount);
var response = request.Execute();

Python

# Add metadata to help the device user during provisioning.
configuration = {
    'configurationName': 'Sales team',
    'companyName': 'XYZ Corp.',
    'contactEmail': 'it-support@example.com',
    'contactPhone': '+1 (800) 555-0112',
    'customMessage': 'We\'re setting up your phone. Call or email for help.'}

# Set the DPC that zero-touch enrollment installs from Google Play.
configuration['dpcResourcePath'] = dpc['name']

# Set the JSON-formatted EMM provisioning extras that are passed to the DPC.
configuration['dpcExtras'] = '''{
    "android.app.extra.PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED":true,
    "android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE":{
      "default_min_password_length":6,
      "company_name":"XYZ Corp",
      "management_server":"emm.example.com",
      "terms_url":"https://www.example.com/policies/terms/",
      "allowed_user_domains":"[\\"example.com\\", \\"example.org\\"]"}
}'''

# Create the new configuration on the server.
response = service.customers().configurations().create(
    parent=customer_account, body=configuration).execute()

패치 API를 사용하여 구성을 업데이트할 때는 필드 마스크 또는 값을 null로 설정하고 싶지는 않은 모든 필드의 값을 지정해야 합니다. 기본값을 참조하세요. 구성 (아래)을 참조하세요. 구성을 효율적으로 업데이트할 수 있습니다

설정 삭제

기기에 아직 적용 중인 구성은 삭제할 수 없습니다. 당신이 사용 중인 구성을 삭제하면 API 메서드가 HTTP 400 Bad Request를 반환합니다. 상태 코드와 구성을 사용하는 기기 수를 설명하는 메시지가 포함됩니다. 전화걸기 customers.devices.removeConfiguration 드림 다시 시도하기 전에 기기에서 구성을 삭제하세요.

기본 구성

제로터치 등록은 조직에서 기본값을 설정할 때 가장 잘 작동합니다. 조직에서 구매하는 모든 새 기기에 적용됩니다. 기본 구성이 설정되지 않은 경우 IT 관리자에게 기본 구성을 설정하라는 메시지를 표시해 보세요. 아래 예는 isDefaulttrue로 설정합니다.

자바

// Send minimal data with the request. Just the 2 required fields.
// targetConfiguration is an existing configuration that we want to make the default.
Configuration configuration = new Configuration();
configuration.setIsDefault(true);
configuration.setConfigurationId(targetConfiguration.getConfigurationId());

// Call the API, including the FieldMask to avoid setting other fields to null.
AndroidProvisioningPartner.Customers.Configurations.Patch request = service
      .customers()
      .configurations()
      .patch(targetConfiguration.getName(), configuration);
request.setUpdateMask("isDefault");
Configuration results = request.execute();

.NET

// Send minimal data with the request. Just the 2 required fields.
// targetConfiguration is an existing configuration that we want to make the default.
Configuration configuration = new Configuration
{
    IsDefault = true,
    ConfigurationId = targetConfiguration.ConfigurationId,
};

// Call the API, including the FieldMask to avoid setting other fields to null.
var request = service.Customers.Configurations.Patch(configuration,
                                                     targetConfiguration.Name);
request.UpdateMask = "IsDefault";
Configuration results = request.Execute();

Python

# Send minimal data with the request. Just the 2 required fields.
# target_configuration is an existing configuration we'll make the default.
configuration = {
    'isDefault': True,
    'configurationId': target_configuration['configurationId']}

# Call the API, including the FieldMask to avoid setting other fields to null.
response = service.customers().configurations().patch(
    name=target_configuration['name'],
    body=configuration, updateMask='isDefault').execute()

기본 구성은 하나만 있을 수 있습니다. 새 기본 구성을 만들면 이전 구성의 isDefault 필드를 false로 설정합니다. 다음과 같은 작업이 필요할 수 있습니다. 캐시된 Configuration 인스턴스를 새로고침하여 isDefault 필드

기기 사용자 안내

제로터치 구성은 기기 설정에 맞춤설정된 사용자 가이드를 표시합니다. 사용자를 지원하는 마법사 연락처 전화번호와 이메일을 포함해야 합니다. 주소 및 구성할 수 있습니다 또한 customMessage 필드는 사용자의 현재 상태에 대한 세부정보를 제공하는 데 사용됩니다. 있습니다.

사용자가 설정 중인 기기에서 전화를 걸거나 이메일을 보낼 수 없기 때문입니다. 전화번호와 이메일 주소의 형식을 지정하면 이메일 주소를 한눈에 확인할 수 있습니다

기기

고객이 제로터치용으로 기기를 구매하면 리셀러가 기기 생성 등록: IT 관리자는 기기를 만들 수 없습니다. 기기로 작업하려면 Device API 리소스 검색해야 하는 경우 모든 기기를 나열하고 앱에서 로컬로 각 배치를 필터링합니다. 대상 아래의 페이징된 결과를 참고하세요.

기기 구성

기기에 구성을 적용하면 제로터치용 기기가 등록됨 있습니다. 구성을 적용하려면 다음을 호출합니다. customers.devices.applyConfiguration 구성을 적용하면 기기가 자동으로 또는 다음 초기화가 있습니다. 아래 예는 다음과 같이 기기 모음에 구성을 적용할 수 있습니다.

자바

List<Device> devices = getDevicesToConfigure(service);
Configuration configurationToApply = getConfigurationToApply(service);

// Loop through the collection and apply the configuration to each device. This might
// take some time if the collection contains many devices.
for (Device device : devices) {
    System.out.println(device.getDeviceIdentifier().getImei());

    // Wrap the device ID in a DeviceReference.
    DeviceReference deviceRef = new DeviceReference();
    deviceRef.setDeviceId(device.getDeviceId());

    // Build and send the request to the API.
    CustomerApplyConfigurationRequest body = new CustomerApplyConfigurationRequest();
    body.setConfiguration(configurationToApply.getName());
    body.setDevice(deviceRef);

    AndroidProvisioningPartner.Customers.Devices.ApplyConfiguration request = service
          .customers()
          .devices()
          .applyConfiguration(customerAccount, body);
    request.execute();
}

.NET

IList<Device> devices = GetDevicesToConfigure(service);
Configuration configurationToApply = GetConfigurationToApply(service);

// Loop through the collection and apply the configuration to each device. This might
// take some time if the collection contains many devices.
foreach (Device device in devices)
{
    Console.WriteLine(device.DeviceIdentifier.Imei);

    // Wrap the device ID in a DeviceReference.
    var deviceRef = new DeviceReference
    {
        DeviceId = device.DeviceId
    };

    // Build and send the request to the API.
    CustomerApplyConfigurationRequest body = new CustomerApplyConfigurationRequest
    {
        Configuration = configurationToApply.Name,
        Device = deviceRef
    };
    var request = service.Customers.Devices.ApplyConfiguration(body,
                                                               customerAccount);
    request.Execute();
}

Python

devices = get_devices_to_configure(service)
configuration = get_configuration_to_apply(service)

# Loop through the collection and apply the configuration to each device.
# This might take some time if the collection contains many devices.
for device in devices:
  print(device['deviceIdentifier']['imei'])

  # Wrap the device ID in a DeviceReference.
  device_ref = {'deviceId': device['deviceId']}

  # Build and send the request to the API.
  body = {'configuration': configuration['name'], 'device': device_ref}
  service.customers().devices().applyConfiguration(
      parent=customer_account, body=body).execute()

기기에서 구성을 삭제하려면 다음을 호출합니다. customers.devices.removeConfiguration 변경사항은 기기를 초기화한 후에 적용됩니다.

기기 소유권 주장 취소

IT 관리자는 기기의 소유권 주장을 취소하여 제로터치 등록에서 기기를 삭제할 수 있습니다. IT 관리자가 다른 계정으로 이전하려는 기기의 소유권을 주장하지 않고 리셀러에게 반품될 수 있습니다. 메서드 호출 기기 소유권 주장을 취소하려면 customers.devices.unclaim 액세스 권한을 부여하는 데 사용됩니다

아래 예는 IMEI 번호에서 기기의 보증을 취소하는 방법을 보여줍니다. 제조업체명:

자바

// Wrap the hardware ID and manufacturer values in a DeviceIdentifier.
// Then wrap the DeviceIdentifier in a DeviceReference.
DeviceIdentifier identifier = new DeviceIdentifier();
identifier.setImei("123456789012347");
identifier.setManufacturer("Google");
DeviceReference reference = new DeviceReference();
reference.setDeviceIdentifier(identifier);

// Create the body of the request.
CustomerUnclaimDeviceRequest body = new CustomerUnclaimDeviceRequest();
body.setDevice(reference);

// Call the API method to unclaim the device from the organization.
service.customers().devices().unclaim(customerAccount, body).execute();

.NET

// Wrap the hardware ID and manufacturer values in a DeviceIdentifier.
// Then wrap the DeviceIdentifier in a DeviceReference.
DeviceIdentifier identifier = new DeviceIdentifier
{
    Imei = "123456789012347",
    Manufacturer = "Google"
};
DeviceReference reference = new DeviceReference();
reference.DeviceIdentifier = identifier;

// Create the body of the request.
CustomerUnclaimDeviceRequest body = new CustomerUnclaimDeviceRequest();
body.Device = reference;

// Call the API method to unclaim the device from the organization.
service.Customers.Devices.Unclaim(body, customerAccount).Execute();

Python

# Wrap the hardware ID and manufacturer values in a DeviceIdentifier.
# Then wrap the DeviceIdentifier in a DeviceReference.
identifier = {'imei': '123456789012347', 'manufacturer': 'Google'}
reference = {'deviceIdentifier': identifier}

# Create the body of the request.
body = {'device': reference}

# Call the API method to unclaim the device from the organization.
service.customers().devices().unclaim(
    parent=customer_account, body=body).execute()

기기 메타데이터

IT 관리자는 리셀러가 기기에 연결한 메타데이터를 볼 수 있습니다. 디스플레이 IT 관리자가 기기를 인식하는 데 도움이 되도록 앱에 기기 메타데이터를 제공합니다.

표시될 수 있는 메타데이터에 대해 자세히 알아보려면 기기 메타데이터 가이드를 참조하세요.

페이징된 결과

customers.devices.list API 메서드가 많은 기기들이 있습니다. 응답 크기를 줄이기 위해 이 API와 다른 API는 메서드 (예: customers.list)는 페이징된 결과를 지원합니다. 다음으로 바꿉니다. 페이징된 결과를 기반으로 애플리케이션이 대규모 목록을 반복적으로 요청하고 처리할 수 있기 때문에 확인할 수 있습니다

API 메서드를 호출한 후 응답에 nextPageToken nextPageToken 상태가 null가 포함되어 있으면 앱에서 이 메서드를 사용하여 메서드를 다시 사용하세요. 사용 중인 장치의 수에 대한 상한을 pageSize 매개변수 nextPageTokennull이면 앱에서 다음을 요청한 것입니다. 마지막 페이지입니다.

아래의 예시 메서드는 앱이 기기 목록을 출력하는 방법을 보여줍니다. 한 번에 하나씩 표시할 수 있습니다.

자바

private void printDevices(AndroidProvisioningPartner service, String customerAccount,
      String pageToken) throws IOException {

    // Call the API to get a page of Devices. Send a page token from the method argument.
    // If the page token is null, the API returns the first page.
    AndroidProvisioningPartner.Customers.Devices.List request =
          service.customers().devices().list(customerAccount);
    request.setPageSize(50L);
    request.setPageToken(pageToken);
    CustomerListDevicesResponse response = request.execute();

    // Print the devices included in this page of results.
    for (Device device : response.getDevices()) {
        System.out.format("Device: %s\n", device.getName());
    }
    System.out.println("---");

    // Check to see if another page of devices is available. If yes, fetch & print the devices.
    if (response.getNextPageToken() != null) {
        this.printDevices(service, customerAccount, response.getNextPageToken());
    }
}

.NET

private void PrintDevices(AndroidProvisioningPartnerService service, String customerAccount,
                          String pageToken)
{
    // Call the API to get a page of Devices. Send a page token from the method argument.
    // If the page token is null, the API returns the first page.
    var request = service.Customers.Devices.List(customerAccount);
    request.PageSize = 50;
    request.PageToken = pageToken;
    var response = request.Execute();

    // Print the devices included in this page of results.
    foreach (Device device in response.Devices)
    {
        Console.WriteLine("Device: {0}", device.Name);
    }
    Console.WriteLine("---");

    // Check to see if another page of devices is available. If yes, fetch and print the devices.
    if (response.NextPageToken != null)
    {
        this.PrintDevices(service, customerAccount, response.NextPageToken);
    }
}

Python

def print_devices(service, customer_account, page_token):
  """Demonstrates how to loop through paginated lists of devices."""

  # Call the API to get a page of Devices. Send a page token from the method
  # argument. If the page token is None, the API returns the first page.
  response = service.customers().devices().list(
      parent=customer_account, pageSize=50, pageToken=page_token).execute()

  # Print the devices included in this page of results.
  for device in response['devices']:
    print('Device: {0}'.format(device['name']))
  print('---')

  # Check to see if another page of devices is available. If yes,
  # fetch and print the devices.
  if 'nextPageToken' in response:
    print_devices(service, customer_account, response['nextPageToken'])

시작하기

다음으로 승인에서 API 호출을 승인하는 방법을 읽어보세요. 원하는 경우 API를 살펴보고 API에 대한 빠른 시작 가이드를 자바 .NETPython. 사용자는 colab에서 보기 API 호출 예시를 살펴보고 API를 직접 호출해 보세요.