ruby_api_pack_cloudways 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64e6f4ca33ac70dcd6309f9b74d7f72c3f1b70598756eb35ef54642cc98f5836
4
- data.tar.gz: 1e83554286f6bc0d6c0803c18e33dd2e7e47706788ccadfa65949cdc81062e94
3
+ metadata.gz: 55bab48c0d619f7918865a2a4e3f73a8384253844892e29231fe00843e4168b2
4
+ data.tar.gz: 44054862918fd30db13413b2b8d344e59a44e7f522add84b13d31c93afa5d9e5
5
5
  SHA512:
6
- metadata.gz: 51f40268262aaed80030f2e9343c4b5f31c8784e8fc5da4cee18b086acc18649d52b5f4e0e3f20d5fcf3c66f07fe9966b38d953e62c7c2b787e521dbff1bb876
7
- data.tar.gz: e6fd7306e44faa0f0ea3c94799c66c2e40d645675a387bf92ffc88c173fd764eee16f36e95ffc90071cde0ef78764403c5f35d6b60194f54acb591be3775d7cd
6
+ metadata.gz: 97fbbb96b0ebc20a12ce6af6912e08f1a9962d95c319fe40a6f48c3a4de41c1d45b66ad2fa3b1b2a17402051e700df54f4eb2500664cee3182871b80705f40c9
7
+ data.tar.gz: 0b85aeeb9211ffab7c946fdf219a4015f8ab3c937274700f356f0e39d5e769e77588a0c172d608e7e05628b5ee6abbed4d98b2f2f82385c19b2713fea555732a
data/README.md CHANGED
@@ -61,7 +61,8 @@ $ gem install ruby_api_pack_cloudways
61
61
  # Documentation Wiki
62
62
 
63
63
  - [Home](https://github.com/phcdevworks/ruby_api_pack_cloudways/wiki)
64
- - [Server Endpoints](https://github.com/phcdevworks/ruby_api_pack_cloudways/wiki/Cloudways-API-Ruby-Server-Endpoint-Client)
64
+ - [List Endpoints](https://github.com/phcdevworks/ruby_api_pack_cloudways/wiki/Cloudways-Ruby-List-Endpoints)
65
+ - [Server Endpoints](https://github.com/phcdevworks/ruby_api_pack_cloudways/wiki/Cloudways-Ruby-Server-Endpoints)
65
66
 
66
67
  ## Contributing
67
68
 
@@ -3,27 +3,76 @@
3
3
  module RubyApiPackCloudways
4
4
  module Api
5
5
  class CwLists
6
- def self.fetch_resource(endpoint)
7
- Connection::CwConnect.new(
8
- RubyApiPackCloudways.configuration.api_url,
9
- endpoint
10
- ).cloudways_api_connection
6
+ # List endpoints
7
+ ENDPOINTS = {
8
+ apps: '/apps',
9
+ backup_frequencies: '/backup-frequencies',
10
+ countries: '/countries',
11
+ monitor_durations: '/monitoring/durations',
12
+ monitor_targets: '/monitoring/targets',
13
+ packages: '/packages',
14
+ providers: '/providers',
15
+ regions: '/regions',
16
+ server_sizes: '/server_sizes',
17
+ settings: '/settings'
18
+ }.freeze
19
+
20
+ # Fetch list of applications available
21
+ def self.app_list
22
+ fetch_resource(ENDPOINTS[:apps])['apps']
11
23
  end
12
24
 
25
+ # Fetch list of available backup frequencies
26
+ def self.backup_frequency_list
27
+ fetch_resource(ENDPOINTS[:backup_frequencies])['frequencies']
28
+ end
29
+
30
+ # Fetch list of supported countries
31
+ def self.country_list
32
+ fetch_resource(ENDPOINTS[:countries])['countries']
33
+ end
34
+
35
+ # Fetch list of monitoring durations
36
+ def self.monitor_duration_list
37
+ fetch_resource(ENDPOINTS[:monitor_durations])['durations']
38
+ end
39
+
40
+ # Fetch list of monitoring targets
41
+ def self.monitor_target_list
42
+ fetch_resource(ENDPOINTS[:monitor_targets])['targets']
43
+ end
44
+
45
+ # Fetch list of available packages
46
+ def self.package_list
47
+ fetch_resource(ENDPOINTS[:packages])['packages']
48
+ end
49
+
50
+ # Fetch list of providers
13
51
  def self.provider_list
14
- fetch_resource('/providers')['providers']
52
+ fetch_resource(ENDPOINTS[:providers])['providers']
53
+ end
54
+
55
+ # Fetch list of regions
56
+ def self.region_list
57
+ fetch_resource(ENDPOINTS[:regions])['regions']
15
58
  end
16
59
 
60
+ # Fetch list of server sizes
17
61
  def self.server_size_list
18
- fetch_resource('/server_sizes')['sizes']
62
+ fetch_resource(ENDPOINTS[:server_sizes])['sizes']
19
63
  end
20
64
 
21
- def self.app_list
22
- fetch_resource('/apps')['apps']
65
+ # Fetch list of available settings
66
+ def self.setting_list
67
+ fetch_resource(ENDPOINTS[:settings])['settings']
23
68
  end
24
69
 
25
- def self.package_list
26
- fetch_resource('/packages')['packages']
70
+ # Private method to fetch resources from a specified endpoint
71
+ private_class_method def self.fetch_resource(endpoint)
72
+ Connection::CwConnect.new(
73
+ RubyApiPackCloudways.configuration.api_url,
74
+ endpoint
75
+ ).cloudways_api_connection
27
76
  end
28
77
  end
29
78
  end
@@ -6,11 +6,11 @@ module RubyApiPackCloudways
6
6
  # Server endpoints
7
7
  ENDPOINTS = {
8
8
  list: '/server',
9
- details: '/server/details',
10
9
  attach_block_storage: '/server/attach_block_storage',
11
10
  clone: '/server/clone',
12
11
  create: '/server/create',
13
12
  delete: '/server/delete',
13
+ details: '/server/details',
14
14
  disk_usage: '/server/disk_usage',
15
15
  restart: '/server/restart',
16
16
  scale_block_storage: '/server/scale_block_storage',
@@ -26,11 +26,6 @@ module RubyApiPackCloudways
26
26
  fetch_list(ENDPOINTS[:list])['servers']
27
27
  end
28
28
 
29
- # Get server details
30
- def self.server_details(server_id)
31
- fetch_with_id(ENDPOINTS[:details], server_id)
32
- end
33
-
34
29
  # Attach block storage to a server
35
30
  def self.attach_block_storage(server_id, params)
36
31
  post_with_id(ENDPOINTS[:attach_block_storage], server_id, params)
@@ -61,6 +56,11 @@ module RubyApiPackCloudways
61
56
  fetch_with_id(ENDPOINTS[:restart], server_id)
62
57
  end
63
58
 
59
+ # Get server details
60
+ def self.server_details(server_id)
61
+ fetch_with_id(ENDPOINTS[:details], server_id)
62
+ end
63
+
64
64
  # Scale block storage of a server
65
65
  def self.scale_block_storage(server_id, params)
66
66
  post_with_id(ENDPOINTS[:scale_block_storage], server_id, params)
@@ -47,7 +47,7 @@ module RubyApiPackCloudways
47
47
 
48
48
  # Parse response from Cloudways API
49
49
  def parse_response(response)
50
- Oj.load(response.body)
50
+ Oj.load(response.body, mode: :strict)
51
51
  rescue Oj::ParseError => e
52
52
  raise "Error parsing response: #{e.message}"
53
53
  end
@@ -24,7 +24,7 @@ module RubyApiPackCloudways
24
24
  private
25
25
 
26
26
  def parse_response(response)
27
- Oj.load(response.body)
27
+ Oj.load(response.body, mode: :strict)
28
28
  rescue Oj::ParseError => e
29
29
  raise "Error parsing response: #{e.message}"
30
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyApiPackCloudways
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_api_pack_cloudways
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PHCDevworks
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-10-30 00:00:00.000000000 Z
12
+ date: 2024-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty