機能の概要

はじめに

ゼロタッチ登録 API を使用すると、デバイス販売パートナーは統合を自動化できます。 組織のセールスツールにはゼロタッチ登録が組み込まれており、 ユーザー、顧客、生産性が向上しますAPI を使用して、ユーザーが次のことを行えるようにしてください。

  • 購入したデバイスをお客様のゼロタッチ登録アカウントに割り当てます。
  • お客様のゼロタッチ登録アカウントを作成する。
  • 組織の電話番号と注文のメタデータをデバイスに添付します。
  • お客様に割り当てられたデバイスに関するレポートを作成する。

このドキュメントでは、API の概要とパターンについて説明します。API を自分で確認する場合は、Java.NETPython のクイックスタートをお試しください。

API のコンセプト

顧客とデバイスは、API で使用するコアリソースです。作成 create を呼び出します。デバイスは、Claim API メソッドを使用して作成できます(下記を参照)。組織は ゼロタッチ登録ポータルを使用してお客様とデバイスを作成する

デバイスとお客様のリソースの関係

顧客
組織がデバイスを販売している企業。お客様にはnameがあります ID があります。デバイスの復元や検索を行う場合は、customer を使用します。宛先 詳しくは、Customer をご覧ください。
デバイス
組織でゼロタッチ登録対応の Android または ChromeOS デバイス 考えることができますデバイスにはハードウェア ID、メタデータ、お客様の申し立てがあります。デバイスは API の中心となるため、ほぼすべての あります。詳しくは、Device をご覧ください。
DeviceIdentifier
製造されたものを識別するために IMEI や MEID などのハードウェア ID をカプセル化します ダウンロードしますDeviceIdentifier を使用してデバイスをターゲットにする 検索、更新、申し立てを行う場所を選択します。詳しくは、 識別子
DeviceMetadata
デバイスのメタデータの Key-Value ペアを格納します。使用 DeviceMetadata: 組織のメタデータを保存します。詳しくは、デバイスのメタデータをご覧ください。

アプリで使用できるすべての API メソッドとリソースを一覧表示するには、API リファレンスをご覧ください。

顧客を作成する

Android デバイスの場合、販売パートナーはお客様に代わってお客様アカウントを作成する必要があります。お客様はこのアカウントを使用してゼロタッチ ポータルにアクセスし、デバイスのプロビジョニング設定を構成します。この手順は、すでに Google Workspace アカウントが プロビジョニング設定の構成に使用する Workspace アカウント。

create API メソッドを呼び出して、ゼロタッチ登録用のお客様アカウントを作成できます。顧客には 追加する場合、アプリのユーザーは 正しいことを確認します。顧客を作成した後に顧客の名前を編集することはできません。

少なくとも 1 つの会社のメールアドレスを含める必要があります。 所有者となる Google アカウント。個人の Gmail アカウントは、 APIアカウントの関連付けについてお客様からお問い合わせを受けた場合は、 手順: Google アカウントを関連付ける

API を呼び出して顧客を作成すると、その顧客がその顧客の 顧客情報を編集することはできません。API を使用するユーザーですスニペット 顧客の作成方法は次のとおりです。

Java

// Provide the customer data as a Company type.
// The API requires a name and owners.
Company customer = new Company();
customer.setCompanyName("XYZ Corp");
customer.setOwnerEmails(Arrays.asList("liz@example.com", "darcy@example.com"));
customer.setAdminEmails(Collections.singletonList("jane@example.com"));

// Use our reseller ID for the parent resource name.
String parentResource = String.format("partners/%d", PARTNER_ID);

// Call the API to create the customer using the values in the company object.
CreateCustomerRequest body = new CreateCustomerRequest();
body.setCustomer(customer);
Company response = service.partners().customers().create(parentResource, body).execute();

.NET

// Provide the customer data as a Company type.
// The API requires a name and owners.
var customer = new Company
{
    CompanyName = "XYZ Corp",
    OwnerEmails = new String[] { "liz@example.com", "darcy@example.com" },
    AdminEmails = new String[] { "jane@example.com" }
};

// Use our reseller ID for the parent resource name.
var parentResource = String.Format("partners/{0}", PartnerId);

// Call the API to create the customer using the values in the company object.
var body = new CreateCustomerRequest
{
    Customer = customer
};
var request = service.Partners.Customers.Create(body, parentResource);
var response = request.Execute();

Python

# Provide the customer data as a Company type. The API requires
# a name and at least one owner.
company = {'companyName':'XYZ Corp', \
  'ownerEmails':['liz@example.com', 'darcy@example.com'], \
  'adminEmails':['jane@example.com']}

# Use our reseller ID for the parent resource name.
parent_resource = 'partners/{0}'.format(PARTNER_ID)

# Call the API to create the customer using the values in the company object.
response = service.partners().customers().create(parent=parent_resource,
    body={'customer':company}).execute()

お客様の従業員のオーナーロールと管理者ロールについて詳しくは、 ポータル ユーザーをご覧ください。

お客様に代わってデバイスを申請する

お客様はデバイスを購入した後、アカウントでデバイスのプロビジョニング設定を構成する必要があります。デバイスを登録すると、デバイスがゼロタッチ登録に追加され、お客様はプロビジョニング設定を構成できるようになります。

デバイスのプロビジョニング レコードには、ゼロタッチ登録のセクションがあります。デバイスを割り当てるには、お客様のレコードのゼロタッチ登録セクションを申請します。顧客を引数として partners.devices.claim メソッドまたは partners.devices.claimAsync メソッドを呼び出します。sectionType の値には常に SECTION_TYPE_ZERO_TOUCH を指定してください。

お客様のデバイスに対する申し立てを解除(後述)する必要があります。 別のお客様に対して同じデバイスの申請を行う。新しいデバイスを作成するときに、申し立て方法は DeviceIdentifier フィールド(IMEI または MEID、シリアル番号、メーカー名、モデル、ChromeOS デバイスの認証済みデバイス ID など)を検証します。

次のスニペットは、デバイスを申し込む方法を示しています。

Java

// Identify the device to claim.
DeviceIdentifier identifier = new DeviceIdentifier();
// The manufacturer value is optional but recommended for cellular devices
identifier.setManufacturer("Google");
identifier.setImei("098765432109875");

// Create the body to connect the customer with the device.
ClaimDeviceRequest body = new ClaimDeviceRequest();
body.setDeviceIdentifier(identifier);
body.setCustomerId(customerId);
body.setSectionType("SECTION_TYPE_ZERO_TOUCH");

// Claim the device.
ClaimDeviceResponse response = service.partners().devices().claim(PARTNER_ID, body).execute();

.NET

// Identify the device to claim.
var deviceIdentifier = new DeviceIdentifier
{
    // The manufacturer value is optional but recommended for cellular devices
    Manufacturer = "Google",
    Imei = "098765432109875"
};

// Create the body to connect the customer with the device.
ClaimDeviceRequest body = new ClaimDeviceRequest
{
    DeviceIdentifier = deviceIdentifier,
    CustomerId = CustomerId,
    SectionType = "SECTION_TYPE_ZERO_TOUCH"
};

// Claim the device.
var response = service.Partners.Devices.Claim(body, PartnerId).Execute();

Python

# Identify the device to claim.
# The manufacturer value is optional but recommended for cellular devices
device_identifier = {'manufacturer':'Google', 'imei':'098765432109875'}

# Create the body to connect the customer with the device.
request_body = {'deviceIdentifier':device_identifier, \
    'customerId':customer_id, \
    'sectionType':'SECTION_TYPE_ZERO_TOUCH'}

# Claim the device.
response = service.partners().devices().claim(partnerId=PARTNER_ID,
    body=request_body).execute()

デバイスの申請を解除しています

組織はお客様からのデバイスの申請を解除できます。デバイスの申し立てを解除すると、そのデバイスはゼロタッチ登録から削除されます。販売パートナーは、別のアカウントに移行するデバイス、返品するデバイス、誤って申し立てたデバイスの申し立てを取り消すことができます。メソッド partners.devices.unclaim または partners.devices.unclaimAsync を呼び出して、お客様のデバイスの申し立てを取り消します。

ベンダー

ベンダーを使用して、ディーラー ネットワーク内の販売パートナー、グローバル販売パートナー ネットワーク内のローカル事業者、またはお客様に代わってデバイスを販売する組織を代表できます。ベンダーは、ユーザー、顧客、デバイスを分離するのに役立ちます。

  • 作成したベンダーは、ゼロタッチ登録のアカウントや各ベンダーの 共有します。
  • ベンダーのお客様とデバイスを表示し、ベンダーのデバイスの登録を解除できます。ただし、ベンダーのお客様にデバイスを割り当てることはできません。

ポータルを使用して組織のベンダーを作成します。API は使用できません。アカウントの役割は、 Owner: 新しいベンダーを作成します。組織にベンダーがある場合は、partners.vendors.list を呼び出してベンダーを一覧表示し、partners.vendors.customers.list を呼び出してベンダーの顧客を取得できます。次の例では、これらのメソッドの両方を使用して、ベンダーの顧客の利用規約のステータスを含むレポートを印刷します。

Java

// First, get the organization's vendors.
String parentResource = String.format("partners/%d", PARTNER_ID);
ListVendorsResponse results = service.partners().vendors().list(parentResource).execute();
if (results.getVendors() == null) {
  return;
}

// For each vendor, report the company name and a maximum 5 customers.
for (Company vendor: results.getVendors()) {
  System.out.format("\n%s customers\n", vendor.getCompanyName());
  System.out.println("---");
  // Use the vendor's API resource name as the parent resource.
  AndroidProvisioningPartner.Partners.Vendors.Customers.List customerRequest =
      service.partners().vendors().customers().list(vendor.getName());
  customerRequest.setPageSize(5);
  ListVendorCustomersResponse customerResponse = customerRequest.execute();

  List<Company> customers = customerResponse.getCustomers();
  if (customers == null) {
    System.out.println("No customers");
    break;
  } else {
    for (Company customer: customers) {
      System.out.format("%s: %s\n",
          customer.getCompanyName(),
          customer.getTermsStatus());
    }
  }
}

.NET

// First, get the organization's vendors.
var parentResource = String.Format("partners/{0}", PartnerId);
var results = service.Partners.Vendors.List(parentResource).Execute();
if (results.Vendors == null)
{
    return;
}

// For each vendor, report the company name and a maximum 5 customers.
foreach (Company vendor in results.Vendors)
{
    Console.WriteLine("\n{0} customers", vendor);
    Console.WriteLine("---");
    // Use the vendor's API resource name as the parent resource.
    PartnersResource.VendorsResource.CustomersResource.ListRequest customerRequest =
        service.Partners.Vendors.Customers.List(vendor.Name);
    customerRequest.PageSize = 5;
    var customerResponse = customerRequest.Execute();

    IList<Company> customers = customerResponse.Customers;
    if (customers == null)
    {
        Console.WriteLine("No customers");
        break;
    }
    else
    {
        foreach (Company customer in customers)
        {
            Console.WriteLine("{0}: {1}", customer.Name, customer.TermsStatus);
        }
    }
}

Python

# First, get the organization's vendors.
parent_resource = 'partners/{0}'.format(PARTNER_ID)
vendor_response = service.partners().vendors().list(
    parent=parent_resource).execute()
if 'vendors' not in vendor_response:
  return

# For each vendor, report the company name and a maximum 5 customers.
for vendor in vendor_response['vendors']:
  print '\n{0} customers'.format(vendor['companyName'])
  print '---'
  # Use the vendor's API resource name as the parent resource.
  customer_response = service.partners().vendors().customers().list(
      parent=vendor['name'], pageSize=5).execute()
  if 'customers' not in customer_response:
    print 'No customers'
    break
  for customer in customer_response['customers']:
    print '  {0}: {1}'.format(customer['name'], customer['termsStatus'])

デバイスのコレクションがある場合は、 ベンダーがデバイスを申請しました。数値の販売パートナー ID を取得するには、 デバイスのクレーム レコードの resellerId フィールド。

組織は、ベンダーが申し立てたデバイスの申し立てを取り消すことができます。デバイスを変更する他の API 呼び出しでは、API メソッドを呼び出す前に、組織がデバイスを申し立てていることを確認する必要があります。次の例は、その方法を示しています。

Java

// Get the devices claimed for two customers: one of our organization's
// customers and one of our vendor's customers.
FindDevicesByOwnerRequest body = new FindDevicesByOwnerRequest();
body.setSectionType("SECTION_TYPE_ZERO_TOUCH");
body.setCustomerId(Arrays.asList(resellerCustomerId, vendorCustomerId));
body.setLimit(MAX_PAGE_SIZE);
FindDevicesByOwnerResponse response =
    service.partners().devices().findByOwner(PARTNER_ID, body).execute();
if (response.getDevices() == null) {
  return;
}

for (Device device: response.getDevices()) {
  // Confirm the device was claimed by our reseller and not a vendor before
  // updating metadata in another method.
  for (DeviceClaim claim: device.getClaims()) {
    if (claim.getResellerId() == PARTNER_ID) {
      updateDeviceMetadata(device.getDeviceId());
      break;
    }
  }
}

.NET

// Get the devices claimed for two customers: one of our organization's
// customers and one of our vendor's customers.
FindDevicesByOwnerRequest body = new FindDevicesByOwnerRequest
{
    Limit = MaxPageSize,
    SectionType = "SECTION_TYPE_ZERO_TOUCH",
    CustomerId = new List<long?>
    {
        resellerCustomerId,
        vendorCustomerId
    }
};
var response = service.Partners.Devices.FindByOwner(body, PartnerId).Execute();
if (response.Devices == null)
{
    return;
}

foreach (Device device in response.Devices)
{
    // Confirm the device was claimed by our reseller and not a vendor before
    // updating metadata in another method.
    foreach (DeviceClaim claim in device.Claims)
    {
        if (claim.ResellerId == PartnerId)
        {
            UpdateDeviceMetadata(device.DeviceId);
            break;
        }
    }
}

Python

# Get the devices claimed for two customers: one of our organization's
# customers and one of our vendor's customers.
request_body = {'limit':MAX_PAGE_SIZE, \
  'pageToken':None, \
  'customerId':[reseller_customer_id, vendor_customer_id], \
  'sectionType':'SECTION_TYPE_ZERO_TOUCH'}
response = service.partners().devices().findByOwner(partnerId=PARTNER_ID,
    body=request_body).execute()

for device in response['devices']:
  # Confirm the device was claimed by our reseller and not a vendor before
  # updating metadata in another method.
  for claim in device['claims']:
    if claim['resellerId'] == PARTNER_ID:
      update_device_metadata(device['deviceId'])
      break

長時間実行バッチ オペレーション

この API には、デバイス メソッドの非同期バージョンが含まれています。 これらの方法を使用すると、多くのデバイスをバッチ処理できます。また、同期処理が メソッドは、API リクエストごとに 1 台のデバイスを処理します。非同期メソッド名 Async という接尾辞が付いています(例: claimAsync)。

非同期 API メソッドは、処理が完了する前に結果を返します。非同期メソッドを使用すると、リクエストに対してアプリ(またはツール)の応答性を維持することもできます。 長時間実行オペレーションの完了を待っている間 ユーザーは待機するようになりますアプリは オペレーションのステータスを定期的にチェックします。

運用

Operation を使用して、長時間実行バッチ オペレーションを追跡します。 非同期メソッドの呼び出しが成功すると、オペレーションへの参照が返されます。 返されます。以下の JSON スニペットは、呼び出し後の一般的なレスポンスを示しています。 updateMetadataAsync:

{
  "name": "operations/apibatchoperation/1234567890123476789"
}

各オペレーションには、個々のタスクのリストが含まれます。発信 operations.get: ステータスに関する情報を確認し、 結果を返すことができます。次のスニペットは、その方法を示しています。実際のアプリでは、エラーを処理する必要があります。

Java

// Build out the request body to apply the same order number to a customer's
// purchase of 2 devices.
UpdateMetadataArguments firstUpdate = new UpdateMetadataArguments();
firstUpdate.setDeviceMetadata(metadata);
firstUpdate.setDeviceId(firstTargetDeviceId);

UpdateMetadataArguments secondUpdate = new UpdateMetadataArguments();
secondUpdate.setDeviceMetadata(metadata);
secondUpdate.setDeviceId(firstTargetDeviceId);

// Start the device metadata update.
UpdateDeviceMetadataInBatchRequest body = new UpdateDeviceMetadataInBatchRequest();
body.setUpdates(Arrays.asList(firstUpdate, secondUpdate));
Operation response = service
    .partners()
    .devices()
    .updateMetadataAsync(PARTNER_ID, body)
    .execute();

// Assume the metadata update started, so get the Operation for the update.
Operation operation = service.operations().get(response.getName()).execute();

.NET

// Build out the request body to apply the same order number to a customer's
// purchase of 2 devices.
var updates = new List<UpdateMetadataArguments>
{
    new UpdateMetadataArguments
    {
        DeviceMetadata = metadata,
        DeviceId = firstTargetDeviceId
    },
    new UpdateMetadataArguments
    {
        DeviceMetadata = metadata,
        DeviceId = secondTargetDeviceId
    }
};

// Start the device metadata update.
UpdateDeviceMetadataInBatchRequest body = new UpdateDeviceMetadataInBatchRequest
{
    Updates = updates
};
var response = service.Partners.Devices.UpdateMetadataAsync(body, PartnerId).Execute();

// Assume the metadata update started, so get the Operation for the update.
Operation operation = service.Operations.Get(response.Name).Execute();

Python

# Build out the request body to apply the same order number to a customer's
# purchase of 2 devices.
updates = [{'deviceMetadata':metadata,'deviceId':first_target_device_id},
    {'deviceMetadata':metadata,'deviceId':second_target_device_id}]

# Start the device metadata update.
response = service.partners().devices().updateMetadataAsync(
    partnerId=PARTNER_ID, body={'updates':updates}).execute()

# Assume the metadata update started, so get the Operation for the update.
operation = service.operations().get(name=response['name']).execute()

オペレーションが完了したかどうかを確認するには、値が truedone フィールドがオペレーションにあるかどうかを確認します。done がないか false の場合、オペレーションはまだ実行中です。

レスポンス

オペレーションが終了すると、API は結果を使用してオペレーションを更新します。 タスクが成功するか 1 つも成功しない場合のレスポンスが向上します。response フィールドは、 DevicesLongRunningOperationResponse オペレーションにおける各デバイスの処理を詳述するオブジェクトです。

successCount フィールドを検査して、タスクが失敗したかどうかを効率的に確認し、大きな結果リストを反復処理しないようにします。DevicesLongRunningOperationResponseperDeviceStatus フィールドは、オペレーション内の各デバイスの詳細を示す OperationPerDevice インスタンスのリストです。リストの順序は、元のリクエストのタスクと一致します。

OperationPerDevice タスクには、result フィールドとリマインダー サマリーが含まれます サーバーが受信したリクエストのレスポンスです。result フィールドを使用して、タスクが成功したかどうかを確認します。

次の JSON スニペットは、updateMetadataAsync の呼び出し後のオペレーションからの一般的なレスポンスを示しています。

"response": {
  "perDeviceStatus": [
    {
      "result": {
        "deviceId": "12345678901234567",
        "status": "SINGLE_DEVICE_STATUS_SUCCESS"
      },
      "updateMetadata": {
        "deviceId": "12345678901234567",
        "deviceMetadata": {
          "entries": {
            "phonenumber": "+1 (800) 555-0100"
          }
        }
      }
    }
  ],
  "successCount": 1
}

進捗状況を管理する

アプリで進捗状況を追跡する必要がある場合は、 あります。metadata フィールドには、 DevicesLongRunningOperationMetadata 実行中のオペレーションの最新の進行状況をアプリがチェックできるようにします。使用 次の DevicesLongRunningOperationMetadata のフィールド テーブルを使用してオペレーションの進行状況を追跡できます。

フィールド 一般的な使用
processingStatus BATCH_PROCESS_PENDING から BATCH_PROCESS_IN_PROGRESS、次に BATCH_PROCESS_PROCESSED
progress 処理された更新の割合。アプリはこれを基に終了時間を推定できます。オペレーションの完了中に progress の値が 100 になる可能性があるため、オペレーションの done フィールドをチェックして、オペレーションが完了し、結果が得られたかを確認します。
devicesCount オペレーション内の更新数を示します。API が一部の更新を解析できない場合、これはリクエスト内の更新数と異なる場合があります。

以下のシンプルな例は、アプリが進行状況のメタデータを使用して以下の操作を行う方法を示しています。 ポーリング間隔を設定できます。アプリで、より高度なタスクが必要になる場合がある ランナーを使用します。また、エラー処理を追加する必要があります。

Java

// Milliseconds between polling the API.
private static long MIN_INTERVAL = 2000;
private static long MAX_INTERVAL = 10000;

// ...
// Start the device metadata update.
Operation response = service
    .partners()
    .devices()
    .updateMetadataAsync(PARTNER_ID, body)
    .execute();
String operationName = response.getName();

// Start polling for completion.
long startTime = new Date().getTime();
while (true) {

  // Get the latest update on the operation's progress using the API.
  Operation operation = service.operations().get(operationName).execute();

  if (operation.get("done") != null && operation.getDone()) {
    // The operation is finished. Print the status.
    System.out.format("Operation complete: %s of %s successful device updates\n",
        operation.getResponse().get("successCount"),
        operation.getMetadata().get("devicesCount"));
    break;

  } else {
    // Estimate how long the operation *should* take - within min and max value.
    BigDecimal opProgress = (BigDecimal) operation.getMetadata().get("progress");
    double progress = opProgress.longValue();
    long interval = MAX_INTERVAL;
    if (progress > 0) {
      interval = (long) ((new Date().getTime() - startTime) *
          ((100.0 - progress) / progress));
    }
    interval = Math.max(MIN_INTERVAL, Math.min(interval, MAX_INTERVAL));

    // Sleep until the operation should be complete.
    Thread.sleep(interval);
  }
}

.NET

// Milliseconds between polling the API.
private static double MinInterval = 2000;
private static double MaxInterval = 10000;

// ...
// Start the device metadata update.
var response = service.Partners.Devices.UpdateMetadataAsync(body, PartnerId).Execute();
var operationName = response.Name;

// Start polling for completion.
var startTime = DateTime.Now;
while (true)
{

    // Get the latest update on the operation's progress using the API.
    Operation operation = service.Operations.Get(operationName).Execute();

    if (operation.Done == true)
    {
        // The operation is finished. Print the status.
        Console.WriteLine("Operation complete: {0} of {1} successful device updates",
                          operation.Response["successCount"],
                          operation.Metadata["devicesCount"]);
        break;
    }
    else
    {
        // Estimate how long the operation *should* take - within min and max value.
        double progress = (double)(long)operation.Metadata["progress"];
        double interval = MaxInterval;
        if (progress > 0)
        {
            interval = DateTime.Now.Subtract(startTime).TotalMilliseconds *
                                     ((100.0 - progress) / progress);
        }
        interval = Math.Max(MinInterval, Math.Min(interval, MaxInterval));

        // Sleep until the operation should be complete.
        System.Threading.Thread.Sleep((int)interval);
    }
}

Python

# Seconds between polling the API.
MIN_INTERVAL = 2;
MAX_INTERVAL = 10;

# ...
# Start the device metadata update
response = service.partners().devices().updateMetadataAsync(
  partnerId=PARTNER_ID, body={'updates':updates}).execute()

op_name = response['name']
start_time = time.time()

# Start polling for completion
while True:
  # Get the latest update on the operation's progress using the API
  op = service.operations().get(name=op_name).execute()

  if 'done' in op and op['done']:
    # The operation is finished. Print the status.
    print('Operation complete: {0} of {1} successful device updates'.format(
      op['response']['successCount'], op['metadata']['devicesCount']
    ))
    break
  else:
    # Estimate how long the operation *should* take - within min and max.
    progress = op['metadata']['progress']
    interval = MIN_INTERVAL
    if progress > 0:
      interval = (time.time() - start_time) * ((100.0 - progress) / progress)
    interval = max(MIN_INTERVAL, min(interval, MAX_INTERVAL))

    # Sleep until the operation should be complete.
    time.sleep(interval)

アプリのユーザーにとって適切なポーリング方法を選択します。プロセスの完了を待っているアプリユーザーには、定期的な進行状況の更新が役立つ場合があります。

ページングされた結果

partners.devices.findByOwner API メソッド 非常に大きなデバイスリストが返される場合があります。レスポンス サイズを小さくするために、この API メソッドと他の API メソッド(partners.devices.findByIdentifier など)はページ分割された結果をサポートしています。ページ分けされた結果を使用すると、アプリケーションは大量のリストを 1 ページずつ反復的にリクエストして処理できます。

API メソッドを呼び出した後、レスポンスに nextPageTokennextPageToken の場合 null でない場合は、次の呼び出しによってデバイスの別のページを取得できます。 メソッドを再度実行します。limit パラメータでデバイス数の上限を設定する必要があります。nextPageTokennull の場合、アプリは最後のページをリクエストしています。

次のメソッドの例は、アプリでデバイスのリストを 1 ページずつ出力する方法を示しています。

Java

private static long MAX_PAGE_SIZE = 10;

// ...
/**
 * Demonstrates how to loop through paginated lists of devices.
 * @param pageToken       The token specifying which result page to return.
 * @throws IOException    If the zero-touch API call fails.
 */
private void printDevices(String pageToken) throws IOException {

  // Create the request body to find the customer's devices.
  FindDevicesByOwnerRequest body = new FindDevicesByOwnerRequest();
  body.setLimit(MAX_PAGE_SIZE);
  body.setSectionType("SECTION_TYPE_ZERO_TOUCH");
  body.setCustomerId(Collections.singletonList(targetCustomerId));

  // Call the API to get a page of Devices. Send a page token from the method
  // argument (might be None). If the page token is None, the API returns the first page.
  FindDevicesByOwnerResponse response =
      service.partners().devices().findByOwner(PARTNER_ID, body).execute();
  if (response.getDevices() == null) {
    return;
  }

  // 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 and print the devices.
  if (response.getNextPageToken() != null) {
    this.printDevices(response.getNextPageToken());
  }
}

// ...
// Pass null to start printing the first page of devices.
printDevices(null);

.NET

private static int MaxPageSize = 10;

// ...
/// <summary>Demonstrates how to loop through paginated lists of devices.</summary>
/// <param name="pageToken">The token specifying which result page to return.</param>
private void PrintDevices(string pageToken)
{
    // Create the request body to find the customer's devices.
    FindDevicesByOwnerRequest body = new FindDevicesByOwnerRequest
    {
        PageToken = pageToken,
        Limit = MaxPageSize,
        SectionType = "SECTION_TYPE_ZERO_TOUCH",
        CustomerId = new List<long?>
        {
            targetCustomerId
        }
    };

    // Call the API to get a page of Devices. Send a page token from the method
    // argument (might be None). If the page token is None, the API returns the first page.
    var response = service.Partners.Devices.FindByOwner(body, PartnerId).Execute();
    if (response.Devices == null)
    {
        return;
    }

    // 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(response.NextPageToken);
    }
}

// ...
// Pass null to start printing the first page of devices.
PrintDevices(null);

Python

MAX_PAGE_SIZE = 10;

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

  Args:
    page_token: The token specifying which result page to return.
  """

   # Create the body to find the customer's devices.
  request_body = {'limit':MAX_PAGE_SIZE, \
    'pageToken':page_token, \
    'customerId':[target_customer_id], \
    'sectionType':'SECTION_TYPE_ZERO_TOUCH'}

  # Call the API to get a page of Devices. Send a page token from the method
  # argument (might be None). If the page token is None,
  # the API returns the first page.
  response = service.partners().devices().findByOwner(partnerId=PARTNER_ID,
    body=request_body).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(response['nextPageToken'])

# ...
# Pass None to start printing the first page of devices.
print_devices(None);

次のステップ

API の仕組みを理解できたら、Java.NETPython のクイックスタートでサンプルを試してみてください。こちらの colab API 呼び出しの例を確認し、ご自身で API の呼び出しを試してください。