Class: RubyApiPackCloudways::Api::CwLists

Inherits:
Object
  • Object
show all
Extended by:
Handlers::ResponseValidator
Defined in:
lib/ruby_api_pack_cloudways/api/cw_lists.rb

Constant Summary collapse

ENDPOINTS =

List endpoints

{
  apps: '/apps',
  backup_frequencies: '/backup-frequencies',
  countries: '/countries',
  monitor_durations: '/monitor_durations',
  monitor_targets: '/monitor_targets',
  packages: '/packages',
  providers: '/providers',
  regions: '/regions',
  server_sizes: '/server_sizes',
  settings: '/settings'
}.freeze

Class Method Summary collapse

Methods included from Handlers::ResponseValidator

validate_response

Class Method Details

.app_listObject

Fetch list of applications available



25
26
27
# File 'lib/ruby_api_pack_cloudways/api/cw_lists.rb', line 25

def self.app_list
  validate_response(fetch_resource(ENDPOINTS[:apps]), 'apps')
end

.backup_frequency_listObject

Fetch list of available backup frequencies



30
31
32
# File 'lib/ruby_api_pack_cloudways/api/cw_lists.rb', line 30

def self.backup_frequency_list
  validate_response(fetch_resource(ENDPOINTS[:backup_frequencies]), 'frequencies')
end

.country_listObject

Fetch list of supported countries



35
36
37
38
39
# File 'lib/ruby_api_pack_cloudways/api/cw_lists.rb', line 35

def self.country_list
  response = fetch_resource(ENDPOINTS[:countries])
  wrapped_response = { 'countries' => response } if response.is_a?(Array)
  validate_response(wrapped_response || response, 'countries')
end

.monitor_duration_listObject

Fetch list of monitoring durations



42
43
44
# File 'lib/ruby_api_pack_cloudways/api/cw_lists.rb', line 42

def self.monitor_duration_list
  validate_response(fetch_resource(ENDPOINTS[:monitor_durations]), 'durations')
end

.monitor_target_listObject

Fetch list of monitoring targets



47
48
49
# File 'lib/ruby_api_pack_cloudways/api/cw_lists.rb', line 47

def self.monitor_target_list
  validate_response(fetch_resource(ENDPOINTS[:monitor_targets]), 'targets')
end

.package_listObject

Fetch list of available packages



52
53
54
# File 'lib/ruby_api_pack_cloudways/api/cw_lists.rb', line 52

def self.package_list
  validate_response(fetch_resource(ENDPOINTS[:packages]), 'packages')
end

.provider_listObject

Fetch list of providers



57
58
59
# File 'lib/ruby_api_pack_cloudways/api/cw_lists.rb', line 57

def self.provider_list
  validate_response(fetch_resource(ENDPOINTS[:providers]), 'providers')
end

.region_listObject

Fetch list of regions



62
63
64
# File 'lib/ruby_api_pack_cloudways/api/cw_lists.rb', line 62

def self.region_list
  validate_response(fetch_resource(ENDPOINTS[:regions]), 'regions')
end

.server_size_listObject

Fetch list of server sizes



67
68
69
# File 'lib/ruby_api_pack_cloudways/api/cw_lists.rb', line 67

def self.server_size_list
  validate_response(fetch_resource(ENDPOINTS[:server_sizes]), 'sizes')
end

.setting_listObject

Fetch list of available settings



72
73
74
# File 'lib/ruby_api_pack_cloudways/api/cw_lists.rb', line 72

def self.setting_list
  validate_response(fetch_resource(ENDPOINTS[:settings]), 'settings')
end