Skip to content

Cloudways Ruby Server Endpoints

Bradley J Potts edited this page Nov 1, 2024 · 1 revision

This gem provides a Ruby client for interacting with Cloudways server endpoints, enabling management of servers using Cloudways' API. Below are the available server endpoints and their usage.

Installation

Add this line to your application's Gemfile:

gem 'ruby_api_pack_cloudways'

And then execute:

bundle install

Usage

Configuration

Set up configuration for Cloudways API access in your application:

RubyApiPackCloudways.configure do |config|
  config.api_url = 'https://api.cloudways.com/api/v1'
  config.api_email = 'your_email'
  config.api_key = 'your_api_key'
end

Available Server Endpoints

Below is a list of all available server endpoints provided by the CwServer class in the ruby_api_pack_cloudways gem.

1. List Servers

Fetches a list of all servers.

RubyApiPackCloudways::Api::CwServer.server_list

2. Server Details

Retrieves details for a specific server by server_id.

RubyApiPackCloudways::Api::CwServer.server_details(server_id)

3. Attach Block Storage

Attaches block storage to a server.

RubyApiPackCloudways::Api::CwServer.attach_block_storage(server_id, { storage_size: 100 })

4. Clone Server

Creates a clone of an existing server.

RubyApiPackCloudways::Api::CwServer.clone_server(server_id, { name: 'new_server' })

5. Create Server

Creates a new server with specified parameters.

RubyApiPackCloudways::Api::CwServer.create_server({ server_name: 'my_server', ... })

6. Delete Server

Deletes a server identified by server_id.

RubyApiPackCloudways::Api::CwServer.delete_server(server_id)

7. Disk Usage

Retrieves the disk usage information for a server.

RubyApiPackCloudways::Api::CwServer.disk_usage(server_id)

8. Restart Server

Restarts a specific server by server_id.

RubyApiPackCloudways::Api::CwServer.restart_server(server_id)

9. Scale Block Storage

Scales the block storage of a server.

RubyApiPackCloudways::Api::CwServer.scale_block_storage(server_id, { new_size: 200 })

10. Scale Volume Size

Scales the volume size of a server.

RubyApiPackCloudways::Api::CwServer.scale_volume_size(server_id, { new_size: 500 })

11. Start Server

Starts a specific server.

RubyApiPackCloudways::Api::CwServer.start_server(server_id)

12. Stop Server

Stops a specific server.

RubyApiPackCloudways::Api::CwServer.stop_server(server_id)

13. Update Server Label

Updates the label of a server.

RubyApiPackCloudways::Api::CwServer.update_server_label(server_id, { label: 'New Server Label' })

14. Upgrade Server

Upgrades the server to a new plan or configuration.

RubyApiPackCloudways::Api::CwServer.upgrade_server(server_id, { plan: 'premium' })