Sha256: 3db4ed17eda228353e07fec8b43749127f177e12303168ff3924ca1eaf8af696

Contents?: true

Size: 1.07 KB

Versions: 13

Compression:

Stored size: 1.07 KB

Contents

module Fog
  module Google
    class Pubsub
      class Real
        # Retrieves a resource describing a topic.
        #
        # @param topic_name [#to_s] name of topic to retrieve
        # @see https://cloud.google.com/pubsub/reference/rest/v1/projects.topics/get
        def get_topic(topic_name)
          api_method = @pubsub.projects.topics.get
          parameters = {
            "topic" => topic_name.to_s
          }

          request(api_method, parameters)
        end
      end

      class Mock
        def get_topic(topic_name)
          if !data[:topics].key?(topic_name)
            topic_resource = topic_name.split("/")[-1]
            body = {
              "error" => {
                "code"    => 404,
                "message" => "Resource not found (resource=#{topic_resource}).",
                "status"  => "NOT_FOUND"
              }
            }
            status = 404
          else
            body = data[:topics][topic_name].clone
            status = 200
          end

          build_excon_response(body, status)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fog-google-0.6.0 lib/fog/google/requests/pubsub/get_topic.rb
fog-google-0.5.5 lib/fog/google/requests/pubsub/get_topic.rb
fog-google-0.5.4 lib/fog/google/requests/pubsub/get_topic.rb
fog-google-0.5.3 lib/fog/google/requests/pubsub/get_topic.rb
fog-google-0.5.2 lib/fog/google/requests/pubsub/get_topic.rb
fog-google-0.5.1 lib/fog/google/requests/pubsub/get_topic.rb
fog-google-0.5.0 lib/fog/google/requests/pubsub/get_topic.rb
fog-google-0.4.2 lib/fog/google/requests/pubsub/get_topic.rb
fog-google-0.4.1 lib/fog/google/requests/pubsub/get_topic.rb
fog-google-0.4.0 lib/fog/google/requests/pubsub/get_topic.rb
fog-google-0.3.2 lib/fog/google/requests/pubsub/get_topic.rb
fog-google-0.3.1 lib/fog/google/requests/pubsub/get_topic.rb
fog-google-0.3.0 lib/fog/google/requests/pubsub/get_topic.rb