Enterprise License Manager API: デベロッパー ガイド

このドキュメントでは、アカウント レベルの管理者および販売パートナー管理者が、Enterprise License Manager API を使用してユーザーのライセンス割り当てを管理する方法について説明します。アカウントのサービス SKU ライセンスを有効にしてユーザーを作成したら、Enterprise License Manager API を使用してアカウントのユーザーのライセンスの割り当て、更新、取得、削除を行います。

このバージョンでは、Enterprise License Manager API はアカウント管理者と販売パートナー管理者が使用します。License Management 権限を持つ代理管理者は、Enterprise License Manager API を使用することもできます。

注: Enterprise License Manager API は Google のユーザーが使用します。Google サードパーティ アプリケーション デベロッパーがライセンスを管理する方法については、Google Workspace Marketplace API をご覧ください。

Enterprise License Manager API は、ウェブサービスに対する Representational State Transfer(RESTful)設計アプローチに基づいています。

ライセンスの管理

ライセンスを割り当てる

この操作の前に、お客様または販売パートナー様が Google サービスのライセンスを注文し、ユーザーを作成しています。このようなサービス ライセンスのいずれかをこのユーザーに割り当てるには、次の POST HTTP リクエストを使用します。リクエストの承認の説明に従って、Authorization ヘッダーを含めます。プロダクト ID と SKU ID については、API の利用可能なプロダクトと SKU をご覧ください。

POST https://www.googleapis.com/apps/licensing/v1/product/productId/sku/skuId/user

注: 1 人のユーザーには、さまざまな Google サービスのライセンスを割り当てることができます。ただし、ユーザーに一度に割り当てられる SKU は 1 つのプロダクトにつき 1 つのみです。この API を使用すると、ユーザーの SKU ライセンスをサービス内の別の SKU ライセンスに再割り当てできます。

この例では、alex@example.com がメインのメールアドレスであるユーザーに Google-Drive-storage-20GB SKU を割り当てます。

POST https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-20GB/user

JSON リクエストの本文:

{
  "userId" : "alex@example.com",
}

成功すると、200 HTTP ステータス コードが返されます。発生する可能性のあるエラーコードについては、API のエラーコードをご覧ください。成功すると、ライセンス割り当てステータスを JSON データ形式で返します。

JSON レスポンス

{
  "kind": "licensing#licenseAssignment",
  "etags": "etag value",
  "selfLink": "https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-20GB/user/alex@example.com",
  "userId": "alex@example.com",
  "productId": "Google-Drive-storage",
  "skuId": "Google-Drive-storage-20GB",
  "skuName": "Google Drive storage 20 GB",
  "productName": "Google Drive storage"
}

詳しくは、licenseAssignments の insert メソッドのリファレンス ページをご覧ください。

ユーザーの商品 SKU を、同一商品内の別の SKU に再割り当てする

同じサービスの新しいライセンス SKU にユーザーのライセンスを再割り当てするには、次の PUT HTTP リクエストを使用します。API はパッチ構文もサポートしています。リクエストの承認の説明に従って、Authorization ヘッダーを含めます。プロダクト ID と SKU ID については、API の利用可能なプロダクトと SKU をご覧ください。

PUT https://www.googleapis.com/apps/licensing/v1/product/productId/sku/the current skuId/user/user's email

この例では、現在の Google-Drive-storage-20GB SKU を Google-Drive-storage-50GB に更新します。現在のライセンス SKU はリクエストの URI に含まれ、新しいライセンス SKU はリクエストの本文に含まれています。

PUT https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-20GB/user/alex@example.com

JSON リクエストの本文は次のようになります。

{
  "kind": "licensing#licenseAssignment",
  "etags": "etag value",
  "selfLink": "https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-50GB/user/alex@example.com",
  "userId": "alex@example.com",
  "productId": "Google-Drive-storage",
  "skuId": "Google-Drive-storage-50GB",
  "skuName": "Google Drive storage 50 GB",
  "productName": "Google Drive storage"
}

成功すると、200 HTTP ステータス コードが返されます。発生する可能性のあるエラーコードについては、API のエラーコードをご覧ください。成功すると、ライセンス割り当てステータスが JSON データ形式で返されます。

JSON レスポンス

{
  "kind": "licensing#licenseAssignment",
  "etags": "etag value",
  "selfLink": "https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-50GB/user/alex@example.com",
  "userId": "alex@example.com",
  "productId": "Google-Drive-storage",
  "skuId": "Google-Drive-storage-50GB",
  "skuName": "Google Drive storage 50 GB",
  "productName": "Google Drive storage"
}

詳しくは、licenseAssignments の update メソッドpatch メソッドのリファレンス ページをご覧ください。

特定のサービスのライセンスが割り当てられているすべてのユーザーを取得する

特定のサービスのすべてのユーザー ライセンスを取得するには、次の GET HTTP リクエストを使用します。リクエストの承認の説明に従って、Authorization ヘッダーを含めます。customerId クエリ文字列は顧客のプライマリ ドメイン名です。maxResults クエリ文字列は、API のレスポンスで返されるユーザー ライセンス エントリの数を決定します。

GET https://www.googleapis.com/apps/licensing/v1/product/productId/users?customerId=primary domain name&maxResults=max results per page

プロダクト ID と SKU ID については、API の利用可能なプロダクトと SKU をご覧ください。

この例では、example.com ドメイン内のすべてのユーザーについて、Google ドライブ ストレージ サービスのライセンスを割り当てられているすべてのユーザーの検索結果の最初のページを表示しています。

GET https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/users?customerId=example.com&maxResults=2

成功すると、200 HTTP ステータス コードが返されます。発生する可能性のあるエラーコードについては、API のエラーコードをご覧ください。成功すると、JSON 形式のライセンス リストが返されます。

JSON レスポンス

{
  "kind" : "licensing#licenseAssignmentList",
  "etag": "etag value",
  "nextPageToken" : "the next page token value",
  "items": [
  {
    "kind": "licensing#licenseAssignment",
    "etags": "etag value",
    "selfLink": "https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-50GB/user/alex@example.com",
    "userId": "alex@example.com",
    "productId": "Google-Drive-storage",
    "skuId": "Google-Drive-storage-50GB",
    "skuName": "Google Drive storage 50 GB",
    "productName": "Google Drive storage"
  },
  {
    "kind": "licensing#licenseAssignment",
    "etags": "etag value",
    "selfLink": "https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-200GB/user/keshav@example.com",
    "userId": "keshav@example.com",
    "productId": "Google-Drive-storage",
    "skuId": "Google-Drive-storage-200GB",
    "skuName": "Google Drive storage 200 GB",
    "productName": "Google Drive storage"
  },
  ...
}

詳細については、licenseAssignments の listForProduct メソッドのリファレンス ページをご覧ください。

特定のサービス SKU のライセンスが割り当てられているすべてのユーザーを取得する

特定のサービスの SKU のライセンスを持つ全ユーザーのリストを取得するには、次の GET HTTP リクエストを使用します。リクエストの承認の説明に従って、Authorization ヘッダーを含めます。customerId クエリ文字列は顧客のプライマリ ドメイン名です。maxResults クエリ文字列は、API のレスポンスで返されるユーザー エントリの数を決定します。

GET https://www.googleapis.com/apps/licensing/v1/product/productId/sku/skuId/users?customerId=primary domain name&maxResults=max results per response page

プロダクト ID と SKU ID については、API の利用可能なプロダクトと SKU をご覧ください。

この例では、Google-Drive-storage-200GB SKU のライセンスが割り当てられている example.com ドメイン内のすべてのユーザーの最初のページが返されます。レスポンスでは、1 ページに 2 つのユーザー エントリが一覧表示されます。

GET https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-200GB/users?customerId=example.com&maxResults=2

成功すると、200 HTTP ステータス コードが返されます。発生する可能性のあるエラーコードについては、API のエラーコードをご覧ください。成功すると、JSON 形式のライセンス リストがレスポンスとして返されます。

JSON レスポンス

{
  "kind" : "licensing#licenseAssignmentList",
   "etag": "etag value",
   "nextPageToken" : "next page token's value",
   "items": [
    {
     "kind": "licensing#licenseAssignment",
     "etags": "etag value",
     "selfLink": "https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-200GB/user/alex@example.com",
     "userId": "alex@example.com",
     "productId": "Google-Drive-storage",
     "skuId": "Google-Drive-storage-200GB",
     "skuName": "Google Drive storage 200 GB",
     "productName": "Google Drive storage"
    },
    {
     "kind": "licensing#licenseAssignment",
     "etags": "etag value",
     "selfLink": "https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-200GB/user/mary@example.com",
     "userId": "mary@example.com",
     "productId": "Google-Drive-storage",
     "skuId": "Google-Drive-storage-200GB",
     "skuName": "Google Drive storage 200 GB",
     "productName": "Google Drive storage"
    },
    ...
  }

詳細については、licenseAssignments の listForProductAndSku メソッドのリファレンス ページをご覧ください。

サービスの SKU ごとに特定のユーザー ライセンスを取得する

サービスの SKU ごとに特定のユーザー ライセンスを取得するには、次の GET HTTP リクエストを使用します。リクエストの承認の説明に従って、Authorization ヘッダーを含めます。プロダクト ID と SKU ID については、API の利用可能なプロダクトと SKU をご覧ください。

GET https://www.googleapis.com/apps/licensing/v1/product/productId/sku/skuId/user/userId

この例では、userId が alex@example.com であるユーザーの Google ドライブ ストレージ 50 GB のプロダクト SKU を取得します。

GET https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-50GB/user/alex@example.com

ユーザーがこのライセンスを持っている場合は、成功のレスポンスと 200 HTTP ステータス コードが返されます。発生する可能性のあるエラーコードについては、API のエラーコードをご覧ください。成功すると、レスポンスでユーザーのライセンスを JSON 形式で返します。

JSON レスポンス

{
  "kind": "licensing#licenseAssignment",
  "etag": "etag value",
  "selfLink": "https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-50GB/user/alex@example.com",
  "userId": "keshav@example.com",
  "productId": "Google-Drive-storage",
  "skuId": "Google-Drive-storage-50GB",
  "skuName": "Google Drive storage 50 GB",
  "productName": "Google Drive storage"
}

詳しくは、licenseAssignments の get メソッドのリファレンス ページをご覧ください。

ライセンスを削除する

ユーザーからのライセンスの割り当てを解除するには、次の DELETE HTTP リクエストを使用します。リクエストの承認の説明に従って、Authorization ヘッダーを含めます。プロダクト ID と SKU ID については、API の利用可能なプロダクトと SKU をご覧ください。

DELETE https://www.googleapis.com/apps/licensing/v1/product/productId/sku/skuId/user/userId

この例では、userId が alex@example.com であるユーザーに Google-Drive-storage-50 GB のライセンスが割り当てられていません。

DELETE https://www.googleapis.com/apps/licensing/v1/product/Google-Drive-storage/sku/Google-Drive-storage-50GB/user/alex@example.com

成功すると、200 HTTP ステータス コードが返されます。発生する可能性のあるエラーコードについては、API のエラーコードをご覧ください。

詳しくは、licenseAssignments の delete メソッドのリファレンス ページをご覧ください。

エラーコード

リクエストが失敗した場合、レスポンスにエラーの簡単な説明が表示されます。

エラーコード 説明
400 不正なリクエスト - ユーザーのメールアドレスが無効です。
400 不正なリクエスト - SKU/プロダクトが存在しない。
401 アクターには、この API を呼び出すための認証情報がありません。
404 ユーザーがこのライセンスを持っていない場合は、応答に「見つかりません」というエラー コードが表示されます。
412 前提条件が満たされていません。このエラーの詳細については、message フィールドを確認してください。例:
  • Auto License switching is not allowed.
  • Auto License un-assignment is not allowed.
  • For reassign operations, the new SKU should be different from the old SKU: sku
  • Reassign operation can't be performed on different products: product1, product2
  • Reassign operation can't be performed on different users: user1, user2
  • There aren't enough available licenses for the specified product-SKU pair
  • User already has a license for the specified product and SKU
  • User already has a license of the product, but with a different SKU. To reassign a new SKU for this product, use the 'update' operation.
503 ライセンス マネージャー サービスは使用できません。