Class: PagerDuty::CacheGlobalDowntime

Inherits:
Object
  • Object
show all
Includes:
SentryLogging, Sidekiq::Job
Defined in:
app/sidekiq/pager_duty/cache_global_downtime.rb

Instance Method Summary collapse

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Instance Method Details

#performObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/sidekiq/pager_duty/cache_global_downtime.rb', line 12

def perform
  client = PagerDuty::MaintenanceClient.new
  options = { 'service_ids' => [global_service_id] }
  maintenance_windows = client.get_all(options)
  file_path = 'tmp/maintenance_windows.json'

  File.open(file_path, 'w') do |f|
    f << maintenance_windows.to_json
  end

  PagerDuty::MaintenanceWindowsUploader.upload_file(file_path)
rescue Common::Exceptions::BackendServiceException, Common::Client::Errors::ClientError => e
  log_exception_to_sentry(e)
end