当前位置: 首页>>代码示例>>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;未经允许,请勿转载。