module GClouder::Resources::Storage::Notifications::Notification
Public Class Methods
ensure(notification)
click to toggle source
# File lib/gclouder/resources/storage/notifications.rb, line 74 def self.ensure(notification) if notification_exists?(notification) good "notification topic: projects/#{notification["project"]}/topics/#{notification["name"]}; bucket: #{notification["bucket"]}", indent: 4 return end event_type_args = "" if notification.has_key?("events") event_type_args = "-e #{notification["events"].join(",")}" end prefix_arg = "" if notification.has_key?("prefix") prefix_arg = "-p #{notification["prefix"]}" end args = "-t projects/#{notification["project"]}/topics/#{notification["name"]} #{prefix_arg} #{event_type_args} -f json gs://#{notification["bucket"]}" add "notification topic: #{notification["name"]}; bucket: #{notification["bucket"]}", indent: 4 gsutil "notification create", args end
notification_exists?(notification)
click to toggle source
# File lib/gclouder/resources/storage/notifications.rb, line 63 def self.notification_exists?(notification) notifications_exist = gsutil_exec("notification list", " gs://#{notification["bucket"]} > /dev/null 2>&1 && echo 0 || echo 1").to_i == 0 if not notifications_exist return false end return gsutil("notification list", "gs://#{notification["bucket"]}", force: true) .include?("projects/#{notification["project"]}/topics/#{notification["name"]}") end