當前位置: 首頁>>代碼示例>>Python>>正文


Python errors.InvalidNotificationError方法代碼示例

本文整理匯總了Python中apiclient.errors.InvalidNotificationError方法的典型用法代碼示例。如果您正苦於以下問題:Python errors.InvalidNotificationError方法的具體用法?Python errors.InvalidNotificationError怎麽用?Python errors.InvalidNotificationError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在apiclient.errors的用法示例。


在下文中一共展示了errors.InvalidNotificationError方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: notification_from_headers

# 需要導入模塊: from apiclient import errors [as 別名]
# 或者: from apiclient.errors import InvalidNotificationError [as 別名]
def notification_from_headers(channel, headers):
  """Parse a notification from the webhook request headers, validate
    the notification, and return a Notification object.

  Args:
    channel: Channel, The channel that the notification is associated with.
    headers: dict, A dictionary like object that contains the request headers
      from the webhook HTTP request.

  Returns:
    A Notification object.

  Raises:
    errors.InvalidNotificationError if the notification is invalid.
    ValueError if the X-GOOG-MESSAGE-NUMBER can't be converted to an int.
  """
  headers = _upper_header_keys(headers)
  channel_id = headers[X_GOOG_CHANNEL_ID]
  if channel.id != channel_id:
    raise errors.InvalidNotificationError(
        'Channel id mismatch: %s != %s' % (channel.id, channel_id))
  else:
    message_number = int(headers[X_GOOG_MESSAGE_NUMBER])
    state = headers[X_GOOG_RESOURCE_STATE]
    resource_uri = headers[X_GOOG_RESOURCE_URI]
    resource_id = headers[X_GOOG_RESOURCE_ID]
    return Notification(message_number, state, resource_uri, resource_id) 
開發者ID:splunk,項目名稱:splunk-ref-pas-code,代碼行數:29,代碼來源:channel.py


注:本文中的apiclient.errors.InvalidNotificationError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。