Sha256: 3cd154a74c20e937855f9c2c1fd523e4eaa6d310ef356b059ddee360279379e4

Contents?: true

Size: 998 Bytes

Versions: 41

Compression:

Stored size: 998 Bytes

Contents

require "fog/core/collection"
require "fog/google/models/pubsub/subscription"

module Fog
  module Google
    class Pubsub
      class Subscriptions < Fog::Collection
        model Fog::Google::Pubsub::Subscription

        # Lists all subscriptions that exist on the project.
        #
        # @return [Array<Fog::Google::Pubsub::Subscription>] list of
        #   subscriptions
        def all
          data = service.list_subscriptions.to_h[:subscriptions] || []
          load(data)
        end

        # Retrieves a subscription by name
        #
        # @param subscription_name [String] name of subscription to retrieve
        # @return [Fog::Google::Pubsub::Topic] topic found, or nil if not found
        def get(subscription_name)
          subscription = service.get_subscription(subscription_name).to_h
          new(subscription)
        rescue ::Google::Apis::ClientError => e
          raise e unless e.status_code == 404
          nil
        end
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
fog-google-1.24.1 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.24.0 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.23.0 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.22.0 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.21.1 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.21.0 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.20.0 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.19.0 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.18.0 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.17.0 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.16.1 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.16.0 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.15.0 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.14.0 lib/fog/google/models/pubsub/subscriptions.rb
gitlab-fog-google-1.14.0 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.13.0 lib/fog/google/models/pubsub/subscriptions.rb
gitlab-fog-google-1.13.0 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.12.1 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.12.0 lib/fog/google/models/pubsub/subscriptions.rb
fog-google-1.11.0 lib/fog/google/models/pubsub/subscriptions.rb