File: pubsub.rb

package info (click to toggle)
ruby-fog-google 1.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,568 kB
  • sloc: ruby: 16,775; makefile: 3
file content (69 lines) | stat: -rw-r--r-- 1,840 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
module Fog
  module Google
    class Pubsub < Fog::Service
      autoload :Mock, File.expand_path("../pubsub/mock", __FILE__)
      autoload :Real, File.expand_path("../pubsub/real", __FILE__)

      requires :google_project
      recognizes(
        :app_name,
        :app_version,
        :google_application_default,
        :google_auth,
        :google_client,
        :google_client_options,
        :google_json_key_location,
        :google_json_key_string,
        :google_key_location,
        :google_key_string
      )

      GOOGLE_PUBSUB_API_VERSION    = "v1".freeze
      GOOGLE_PUBSUB_BASE_URL       = "https://www.googleapis.com/pubsub".freeze
      GOOGLE_PUBSUB_API_SCOPE_URLS = %w(https://www.googleapis.com/auth/pubsub).freeze

      ##
      # MODELS
      model_path "fog/google/models/pubsub"

      # Topic
      model :topic
      collection :topics

      # Subscription
      model :subscription
      collection :subscriptions

      # ReceivedMessage
      model :received_message

      ##
      # REQUESTS
      request_path "fog/google/requests/pubsub"

      # Topic
      request :list_topics
      request :get_topic
      request :create_topic
      request :delete_topic
      request :publish_topic

      # Subscription
      request :list_subscriptions
      request :get_subscription
      request :create_subscription
      request :delete_subscription
      request :pull_subscription
      request :acknowledge_subscription

      # Helper class for getting a subscription name
      #
      # @param subscription [Subscription, #to_s] subscription instance or name
      #   of subscription
      # @return [String] name of subscription
      def self.subscription_name(subscription)
        subscription.is_a?(Subscription) ? subscription.name : subscription.to_s
      end
    end
  end
end