Sha256: 9992a5c658b78750d115f3a1b0775fa44f4238467aa16c86319418be21d77920

Contents?: true

Size: 1.9 KB

Versions: 207

Compression:

Stored size: 1.9 KB

Contents

module Souls
  class Pubsub < Thor
    desc "create_subscription", "Create Google Cloud PubSub Subscription"
    method_option :topic_name,
                  default: "send-user-mailer",
                  aliases: "--topic_name",
                  desc: "Google Cloud Pubsub Topic Name"
    method_option :endpoint,
                  default: "https:://test.com",
                  aliases: "--endpoint",
                  desc: "Google Cloud Pubsub Push Subscription Endpoint"
    def create_subscription
      project_id = Souls.configuration.project_id
      service_account = "#{Souls.configuration.app}@#{project_id}.iam.gserviceaccount.com"
      system(
        "gcloud pubsub subscriptions create #{options[:topic_name]}-sub \
            --topic #{options[:topic_name]} \
            --topic-project #{project_id} \
            --push-auth-service-account #{service_account} \
            --push-endpoint #{options[:endpoint]} \
            --expiration-period never
            "
      )
    rescue Thor::Error => e
      raise(Thor::Error, e)
    end

    desc "subscription_list", "Show Google Cloud Pubsub Subscription List"
    def subscription_list
      system("gcloud pubsub subscriptions list")
    rescue Thor::Error => e
      raise(Thor::Error, e)
    end

    desc "update_subscription", "Update Google Cloud Pubsub Subscription Endpoint"
    method_option :topic_name,
                  default: "send-user-mailer",
                  aliases: "--topic_name",
                  desc: "Google Cloud Pubsub Topic Name"
    method_option :endpoint,
                  default: "https:://test.com",
                  aliases: "--endpoint",
                  desc: "Google Cloud Pubsub Push Subscription Endpoint"
    def update_subscription
      system("gcloud pubsub subscriptions update #{options[:topic_name]}-sub --push-endpoint #{options[:endpoint]} ")
    rescue Thor::Error => e
      raise(Thor::Error, e)
    end
  end
end

Version data entries

207 entries across 207 versions & 1 rubygems

Version Path
souls-0.68.7 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.68.6 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.68.5 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.68.4 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.68.3 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.68.2 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.68.1 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.68.0 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.67.3 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.67.2 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.67.1 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.67.0 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.66.3 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.66.2 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.66.1 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.66.0 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.65.5 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.65.4 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.65.3 lib/souls/cli/gcloud/pubsub/subscriptions.rb
souls-0.65.2 lib/souls/cli/gcloud/pubsub/subscriptions.rb