Module: PagerDuty::MaintenanceWindowsUploader

Defined in:
lib/pagerduty/maintenance_windows_uploader.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new_s3_resourceObject



11
12
13
14
15
16
17
# File 'lib/pagerduty/maintenance_windows_uploader.rb', line 11

def new_s3_resource
  Aws::S3::Resource.new(
    region: Settings.maintenance.aws.region,
    access_key_id: Settings.maintenance.aws.access_key_id,
    secret_access_key: Settings.maintenance.aws.secret_access_key
  )
end

.s3_bucketObject



7
8
9
# File 'lib/pagerduty/maintenance_windows_uploader.rb', line 7

def s3_bucket
  Settings.maintenance.aws.bucket
end

.upload_file(file) ⇒ Object



19
20
21
22
23
# File 'lib/pagerduty/maintenance_windows_uploader.rb', line 19

def upload_file(file)
  s3_resource = new_s3_resource
  obj = s3_resource.bucket(s3_bucket).object('maintenance_windows.json')
  obj.upload_file(file, acl: 'public-read', content_type: 'application/json')
end

Instance Method Details

#new_s3_resourceObject (private)



11
12
13
14
15
16
17
# File 'lib/pagerduty/maintenance_windows_uploader.rb', line 11

def new_s3_resource
  Aws::S3::Resource.new(
    region: Settings.maintenance.aws.region,
    access_key_id: Settings.maintenance.aws.access_key_id,
    secret_access_key: Settings.maintenance.aws.secret_access_key
  )
end

#s3_bucketObject (private)



7
8
9
# File 'lib/pagerduty/maintenance_windows_uploader.rb', line 7

def s3_bucket
  Settings.maintenance.aws.bucket
end

#upload_file(file) ⇒ Object (private)



19
20
21
22
23
# File 'lib/pagerduty/maintenance_windows_uploader.rb', line 19

def upload_file(file)
  s3_resource = new_s3_resource
  obj = s3_resource.bucket(s3_bucket).object('maintenance_windows.json')
  obj.upload_file(file, acl: 'public-read', content_type: 'application/json')
end