Class: Fog::Google::Pubsub::Topics

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/google/models/pubsub/topics.rb

Instance Method Summary collapse

Instance Method Details

#allArray<Fog::Google::Pubsub::Topic>

Lists all topics that exist on the project.

Returns:


13
14
15
16
# File 'lib/fog/google/models/pubsub/topics.rb', line 13

def all
  data = service.list_topics.to_h[:topics] || []
  load(data)
end

#get(topic_name) ⇒ Fog::Google::Pubsub::Topic

Retrieves a topic by name

Parameters:

  • topic_name (String)

    name of topic to retrieve

Returns:


22
23
24
25
26
27
28
# File 'lib/fog/google/models/pubsub/topics.rb', line 22

def get(topic_name)
  topic = service.get_topic(topic_name).to_h
  new(topic)
rescue ::Google::Apis::ClientError => e
  raise e unless e.status_code == 404
  nil
end