本頁說明您會收到的 Google Workspace 訂閱項目生命週期事件,以及如何使用這些事件來維持有效訂閱狀態。
Google Workspace Events API 會傳送下列類型的生命週期事件:
應用程式應明確處理這些生命週期事件類型,並忽略日後可能出現的新事件類型。
Google Workspace Events API 的生命週期事件是根據 CloudEvents 規格建構。詳情請參閱「Google Workspace 事件結構」。
停權事件
如果 Google Workspace 訂閱項目發生錯誤,Google Workspace Events API 會暫停訂閱項目,並防止其接收事件。請先解決訂閱方案的任何錯誤,再重新啟用。
為通知您帳戶遭到停權,Google Workspace Events API 會傳送事件類型為 google.workspace.events.subscription.v1.suspended 的生命週期事件。
收到暫停通知後,您可以瞭解暫停原因、解決任何錯誤,並重新啟用訂閱方案。詳情請參閱「解決錯誤並重新啟用 Google Workspace 訂閱方案」。
以下顯示 Google Workspace 訂閱方案的生命週期事件 CloudEvent,該方案因錯誤 ENDPOINT_PERMISSION_DENIED 而遭到停權:
{
"id": "EVENT_UUID",
"source": "//workspaceevents.googleapis.com/subscriptions/SUBSCRIPTION_ID",
"subject": "//workspaceevents.googleapis.com/subscriptions/SUBSCRIPTION_ID",
"type": "google.workspace.events.subscription.v1.suspended",
"time": "2023-06-08T06:50:43.641299Z",
"spec_version": '1.0',
"datacontenttype": "application/json",
"data": {
"subscription":{
"name": "subscriptions/SUBSCRIPTION_ID",
"suspension_reason": "ENDPOINT_PERMISSION_DENIED",
...
}
}
}
到期提醒事件
訂閱項目到期後,Google Workspace Events API 會永久刪除該項目,且無法續訂或重新啟用。
為通知您訂閱即將到期,Google Workspace Events API 會在到期時間前 12 小時和 1 小時傳送生命週期事件。生命週期事件的事件類型為 google.workspace.events.subscription.v1.expirationReminder。
收到到期提醒事件時,請使用 subscriptions.update() 方法更新到期時間。詳情請參閱「更新或續訂 Google Workspace 訂閱方案」。
以下顯示有關 Google Workspace 訂閱方案即將到期的生命週期事件 CloudEvent:
{
"id": "EVENT_UUID",
"source": "//workspaceevents.googleapis.com/subscriptions/SUBSCRIPTION_ID",
"subject": "//workspaceevents.googleapis.com/subscriptions/SUBSCRIPTION_ID",
"type": "google.workspace.events.subscription.v1.expirationReminder",
"time": "2023-06-08T06:50:43.641299Z",
"spec_version": '1.0',
"datacontenttype": "application/json",
"data": {
"subscription":{
"name": "subscriptions/SUBSCRIPTION_ID",
"expire_time": "2023-06-08T18:50:43.641299Z",
...
}
}
}
訂閱項目到期事件
訂閱項目到期時,Google Workspace Events API 會傳送生命週期事件給您。這項生命週期事件的事件類型為 google.workspace.events.subscription.v1.expired。
Google Workspace Events API 會永久刪除過期的訂閱項目。
如果訂閱方案到期,請使用 subscriptions.create() 方法建立其他訂閱方案。詳情請參閱「建立 Google Workspace 訂閱方案」。
以下顯示有關 Google Workspace 訂閱方案過期的生命週期事件 CloudEvent:
{
"id": "EVENT_UUID",
"source": "//workspaceevents.googleapis.com/subscriptions/SUBSCRIPTION_ID",
"subject": "//workspaceevents.googleapis.com/subscriptions/SUBSCRIPTION_ID",
"type": "google.workspace.events.subscription.v1.expired",
"time": "2023-06-08T07:00:00.000000Z",
"spec_version": '1.0',
"datacontenttype": "application/json",
"data": {
"subscription":{
"name": "subscriptions/SUBSCRIPTION_ID",
"expire_time": "2023-06-08T07:00:00.000000Z",
...
}
}
}