def parse_name(name):
  """Parse the topic or subscription name."""
  components = name.split('/')
  if len(components) != 4:
    raise ValueError('Invalid pubsub name.')

  project = components[1]
  name = components[3]
  return project, name