Python apiclient.errors.InvalidNotificationError() Examples

The following are 8 code examples of apiclient.errors.InvalidNotificationError(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module apiclient.errors , or try the search function .
Example #1
Source File: channel.py    From splunk-ref-pas-code with Apache License 2.0 5 votes vote down vote up
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) 
Example #2
Source File: channel.py    From sndlatr with Apache License 2.0 5 votes vote down vote up
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) 
Example #3
Source File: channel.py    From googleapps-message-recall with Apache License 2.0 5 votes vote down vote up
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) 
Example #4
Source File: channel.py    From twitter-for-bigquery with Apache License 2.0 5 votes vote down vote up
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) 
Example #5
Source File: channel.py    From data with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #6
Source File: channel.py    From data with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #7
Source File: channel.py    From data with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #8
Source File: channel.py    From data with GNU General Public License v3.0 5 votes vote down vote up
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)