Beispiel #1
0
def TopicSubscriptionDict(topic_subscription):
    """Returns a topic_subscription dict with additional fields."""
    result = resource_projector.MakeSerializable(
        {'subscription': topic_subscription})

    subscription_info = util.SubscriptionIdentifier(topic_subscription)
    result['projectId'] = subscription_info.project.project_name
    result['subscriptionId'] = subscription_info.resource_name
    return result
Beispiel #2
0
def SubscriptionDict(subscription):
  """Returns a subscription dict with additional fields."""
  result = resource_projector.MakeSerializable(subscription)
  result['type'] = 'PUSH' if subscription.pushConfig.pushEndpoint else 'PULL'
  subscription_info = util.SubscriptionIdentifier(subscription.name)
  result['projectId'] = subscription_info.project.project_name
  result['subscriptionId'] = subscription_info.resource_name
  topic_info = util.TopicIdentifier(subscription.topic)
  result['topicId'] = topic_info.resource_name
  return result