Directory API:管理客戶

您可以使用 Directory API 透過程式管理客戶。這個 API 中的各項方法可讓您更新 G Suite 網域的聯絡資訊,以及變更執行個體的主網域。

擷取客戶

如要擷取現有客戶,請使用下列 GET HTTP 要求,並附上「授權要求」一節中所述的授權權杖。customerKey 可以是專屬的 customerId,或是 my_customer 來表示目前的客戶。

GET https://admin.googleapis.com/admin/directory/v1/customers/customerKey

成功的回應會傳回 HTTP 200 狀態碼。除了狀態碼外,JSON 回應還會傳回客戶資訊:

{
  "etag": "\"spqlTgq5LGeoin0BH1d0f4rpI98/LnbnRK_ZWu_omowg36CZgTKECrY\"",
  "kind": "admin#directory#customer",
  "alternateEmail": "marty.mcfly@gmail.com",
  "id": "C03xgje4y",
  "customerDomain": "amatchmadeinspace.com",
  "postalAddress": {
    "organizationName": "A Match Made in Space, LLC",
    "countryCode": "US"
  },
  "customerCreationTime": "2015-10-21T20:42:35.224Z"
}

更新現有客戶

如要更新現有客戶,請使用下列 PUT HTTP 要求,並附上「授權要求」一節中所述的授權權杖。customerKey 可以是客戶的專屬 customerId,或是 my_customer 來表示目前的客戶。

PUT https://admin.googleapis.com/admin/directory/v1/customers/customerKey

成功的回應會傳回 HTTP 200 狀態碼。除了狀態碼外,JSON 回應還會傳回最新更新的客戶資訊:

{
  "alternateEmail": "marty.mcfly@gmail.com",
  "customerDomain": "amatchmadeinspace.com",
  "language": "EN",
  "postalAddress": {
    "organizationName": "A Match Made in Space, LLC",
    "phoneNumber": "+15558675309"
  }
}

成功的回應會傳回 HTTP 200 狀態碼。除了狀態碼外,JSON 回應還會傳回客戶資訊:

{
  "etag": "\"spqlTgq5LGeoin0BH1d0f4rpI98/LnbnRK_ZWu_omowg36CZgTKECrY\"",
  "kind": "admin#directory#customer",
  "alternateEmail": "marty.mcfly@gmail.com",
  "id": "C03xgje4y",
  "customerDomain": "amatchmadeinspace.com",
  "postalAddress": {
    "organizationName": "A Match Made in Space, LLC",
    "phoneNumber": "+15558675309"
  },
  "customerCreationTime": "2015-10-21T20:42:35.224Z"
}

變更客戶的主網域名稱

如要變更客戶的主網域,請使用下列 PUT HTTP 要求,並附上「授權要求」一節中所述的授權權杖。customerKey 必須是唯一的 customerId,或 my_customer

PUT https://admin.googleapis.com/admin/directory/v1/customers/customerKey

JSON 要求主體必須包含新的 customerDomain 值:

{
  "alternateEmail": "marty.mcfly@gmail.com",
  "customerDomain": "fluxcapacitor.com",
  "language": "EN",
  "postalAddress": {
    "organizationName": "A Match Made in Space, LLC",
    "phoneNumber": "+15558675309"
  }
}

成功的回應會傳回 HTTP 200 狀態碼。除了狀態碼外,JSON 回應還會包含客戶資訊:

{
  "etag": "\"spqlTgq5LGeoin0BH1d0f4rpI98/LnbnRK_ZWu_omowg36CZgTKECrY\"",
  "kind": "admin#directory#customer",
  "alternateEmail": "marty.mcfly@gmail.com",
  "id": "C03xgje4y",
  "customerDomain": "fluxcapacitor.com",
  "postalAddress": {
    "organizationName": "A Match Made in Space, LLC",
    "phoneNumber": "+15558675309"
  },
  "customerCreationTime": "2015-10-21T20:42:35.224Z"
}