Sha256: 20674eeb1b7fae8cf7e87a3821e19d160b72071eebc50cd35464b81077df2bb6

Contents?: true

Size: 1.3 KB

Versions: 13

Compression:

Stored size: 1.3 KB

Contents

module Fog
  module Google
    class Pubsub
      class Real
        # Acknowledges a message received from a subscription.
        #
        # @see https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/acknowledge
        def acknowledge_subscription(subscription, ack_ids)
          api_method = @pubsub.projects.subscriptions.acknowledge

          parameters = {
            "subscription" => subscription.to_s
          }

          body = {
            "ackIds" => ack_ids
          }

          request(api_method, parameters, body)
        end
      end

      class Mock
        def acknowledge_subscription(subscription, ack_ids)
          unless data[:subscriptions].key?(subscription)
            subscription_resource = subscription.to_s.split("/")[-1]
            body = {
              "error" => {
                "code"    => 404,
                "message" => "Resource not found (resource=#{subscription_resource}).",
                "status"  => "NOT_FOUND"
              }
            }
            status = 404
            return build_excon_response(body, status)
          end

          sub = data[:subscriptions][subscription]
          sub[:messages].delete_if { |msg| ack_ids.member?(msg["messageId"]) }

          build_excon_response(nil, 200)
        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/acknowledge_subscription.rb
fog-google-0.5.5 lib/fog/google/requests/pubsub/acknowledge_subscription.rb
fog-google-0.5.4 lib/fog/google/requests/pubsub/acknowledge_subscription.rb
fog-google-0.5.3 lib/fog/google/requests/pubsub/acknowledge_subscription.rb
fog-google-0.5.2 lib/fog/google/requests/pubsub/acknowledge_subscription.rb
fog-google-0.5.1 lib/fog/google/requests/pubsub/acknowledge_subscription.rb
fog-google-0.5.0 lib/fog/google/requests/pubsub/acknowledge_subscription.rb
fog-google-0.4.2 lib/fog/google/requests/pubsub/acknowledge_subscription.rb
fog-google-0.4.1 lib/fog/google/requests/pubsub/acknowledge_subscription.rb
fog-google-0.4.0 lib/fog/google/requests/pubsub/acknowledge_subscription.rb
fog-google-0.3.2 lib/fog/google/requests/pubsub/acknowledge_subscription.rb
fog-google-0.3.1 lib/fog/google/requests/pubsub/acknowledge_subscription.rb
fog-google-0.3.0 lib/fog/google/requests/pubsub/acknowledge_subscription.rb