Sha256: a73ff8659437b30285f1de7c6ab848f802c180a293093f5f797e6ff4a034b5d1

Contents?: true

Size: 1.28 KB

Versions: 13

Compression:

Stored size: 1.28 KB

Contents

module Fog
  module Google
    class Pubsub
      class Real
        # Retrieves a subscription by name from the remote service.
        #
        # @param subscription_name [#to_s] name of subscription to retrieve
        # @see https://cloud.google.com/pubsub/reference/rest/v1/projects.topics/get
        def get_subscription(subscription_name)
          api_method = @pubsub.projects.subscriptions.get
          parameters = {
            "subscription" => subscription_name.to_s
          }

          request(api_method, parameters)
        end
      end

      class Mock
        def get_subscription(subscription_name)
          sub = data[:subscriptions][subscription_name]
          if sub.nil?
            subscription_resource = subscription_name.split("/")[-1]
            body = {
              "error" => {
                "code"    => 404,
                "message" => "Resource not found (resource=#{subscription_resource}).",
                "status"  => "NOT_FOUND"
              }
            }
            return build_excon_response(body, 404)
          end

          body = sub.select do |k, _|
            %w(name topic pushConfig ackDeadlineSeconds).include?(k)
          end
          status = 200

          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_subscription.rb
fog-google-0.5.5 lib/fog/google/requests/pubsub/get_subscription.rb
fog-google-0.5.4 lib/fog/google/requests/pubsub/get_subscription.rb
fog-google-0.5.3 lib/fog/google/requests/pubsub/get_subscription.rb
fog-google-0.5.2 lib/fog/google/requests/pubsub/get_subscription.rb
fog-google-0.5.1 lib/fog/google/requests/pubsub/get_subscription.rb
fog-google-0.5.0 lib/fog/google/requests/pubsub/get_subscription.rb
fog-google-0.4.2 lib/fog/google/requests/pubsub/get_subscription.rb
fog-google-0.4.1 lib/fog/google/requests/pubsub/get_subscription.rb
fog-google-0.4.0 lib/fog/google/requests/pubsub/get_subscription.rb
fog-google-0.3.2 lib/fog/google/requests/pubsub/get_subscription.rb
fog-google-0.3.1 lib/fog/google/requests/pubsub/get_subscription.rb
fog-google-0.3.0 lib/fog/google/requests/pubsub/get_subscription.rb