Exemplo n.º 1
0
def TopicDict(topic):
  topic_dict = resource_projector.MakeSerializable(topic)
  topic_info = util.TopicIdentifier(topic.name)
  topic_dict['topic'] = topic.name
  topic_dict['topicId'] = topic_info.resource_name
  del topic_dict['name']
  return topic_dict
Exemplo n.º 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
Exemplo n.º 3
0
def SnapshotDict(snapshot):
  """Returns a snapshot dict with additional fields."""
  result = resource_projector.MakeSerializable(snapshot)
  snapshot_info = util.SnapshotIdentifier(snapshot.name)
  result['projectId'] = snapshot_info.project.project_name
  result['snapshotId'] = snapshot_info.resource_name
  topic_info = util.TopicIdentifier(snapshot.topic)
  result['topicId'] = topic_info.resource_name
  result['expireTime'] = snapshot.expireTime
  return result