Servers¶
-
OneAndOne::Server()
The
Server
class allows a user to perform actions against the 1and1 API.-
list
(page: nil, per_page: nil, sort: nil, q: nil, fields: nil)¶ Return a list of all images.
Parameters: - page (
int
) – Allows the use of pagination. Indicate which page to start on. - per_page (
int
) – Number of items per page. - sort (
str
) –sort: 'name'
retrieves a list of elements sorted alphabetically.sort: 'creation_date'
retrieves a list of elements sorted by their creation date in descending order. - q (
str
) –q
is for query. Use this parameter to return only the items that match your search query. - fields (
str
) – Returns only the parameters requested. (i.e. fields: ‘id, name, description, hardware.ram’)
Return type: JSON
- page (
-
create
(name: nil, description: nil, fixed_instance_id: nil, vcore: nil, cores_per_processor: nil, ram: nil, appliance_id: nil, hdds: nil, password: nil, power_on: nil, firewall_id: nil, ip_id: nil, load_balancer_id: nil, monitoring_policy_id: nil)¶ Create a server.
Note
Only the following parameters are required to create a server:
name
description
vcore
cores_per_processor
ram
appliance_id
Note
Your HDD’s size must be a multiple of
20
.Parameters: - name (
str
) – server name. - description (
str
) – server description. - fixed_instance_id (
str
) – the unique identifier for your desired fixed server flavor. - vcore (
int
) – Total amount of virtual cores. - cores_per_processor (
int
) – Number of cores per processor. - ram (
int
) – Memory size. - appliance_id (
str
) – image to be installed on the server. - hdds (
array
) – takes an array of HDD’s. - password (
str
) – server password. - power_on (
bool
) – choose whether or not you want the server to ‘POWER_ON’ after creation. (True by default) - firewall_id (
str
) – the unique identifier for the firewall policy to be assigned. - ip_id (
str
) – the unique identifier for the IP to be assigned. - load_balancer_id (
str
) – the unique identifier for the load balancer to be assigned. - monitoring_policy_id (
str
) – the unique identifier for the monitoring policy to be assigned.
Return type: JSON
-
list_fixed
()¶ Returns a list of available fixed server options.
Return type: JSON
-
get_fixed
(fixed_instance_id: nil)¶ Retrieve information about a fixed server option.
Parameters: - fixed_instance_id (
str
) – the unique identifier for the fixed server option.
Return type: JSON
- fixed_instance_id (
-
get
(server_id: @id)¶ Retrieve the current specs of a server.
Parameters: - server_id (
str
) – the unique identifier for the server.
Return type: JSON
- server_id (
-
modify
(server_id: @id, name: nil, description: nil)¶ Modify a server.
Parameters: - server_id (
str
) – the unique identifier for the server. - name (
str
) – server name. - description (
str
) – server description.
Return type: JSON
- server_id (
-
delete
(server_id: @id, keep_ips: nil)¶ Delete a server.
Parameters: - server_id (
str
) – the unique identifier for the server. - keep_ips (
bool
) – Setkeep_ips
toTrue
to keep server IPs after deleting a server. (False
by default).
Return type: JSON
- server_id (
-
hardware
(server_id: @id)¶ Retrieve a server’s hardware configurations.
Parameters: - server_id (
str
) – the unique identifier for the server.
Return type: JSON
- server_id (
-
modify_hardware
(server_id: @id, fixed_instance_id: nil, vcore: nil, cores_per_processor: nil, ram: nil)¶ Modify a server’s hardware.
Note
Cannot perform “hot” decreasing of server hardware values. “Cold” decreasing is allowed.
Parameters: - server_id (
str
) – the unique identifier for the server. - fixed_instance_id – ID of the instance size for the server. It is not possible to resize to a fixed instance with a HDD smaller than the current one.
- vcore (
int
) – Total amount of virtual cores. - cores_per_processor (
int
) – Number of cores per processor. - ram (
int
) – Memory size.
Return type: JSON
- server_id (
-
hdds
(server_id: @id)¶ Returns a list of the server’s HDD’s.
Parameters: - server_id (
str
) – the unique identifier for the server.
Return type: JSON
- server_id (
-
add_hdds
(server_id: @id, hdds: nil)¶ Add additional HDD’s to a server.
Parameters: - server_id (
str
) – the unique identifier for the server. - hdds (
array
) – takes an array of HDD’s.
Return type: JSON
- server_id (
-
get_hdd
(server_id: @id, hdd_id: nil)¶ Retrieve information about a server’s HDD.
Parameters: - server_id (
str
) – the unique identifier for the server. - hdd_id (
str
) – the unique identifier for the HDD.
Return type: JSON
- server_id (
-
modify_hdd
(server_id: @id, hdd_id: nil, size: nil)¶ Modify a server’s HDD.
Parameters: - server_id (
str
) – the unique identifier for the server. - hdd_id (
str
) – the unique identifier for the server’s HDD. - size (
int
) – the new size of the HDD. Must be a multiple of20
.
Return type: JSON
- server_id (
-
delete_hdd
(server_id: @id, hdd_id: nil)¶ Delete a server’s HDD.
Parameters: - server_id (
str
) – the unique identifier for the server. - hdd_id (
str
) – the unique identifier for the server’s HDD.
Return type: JSON
- server_id (
-
image
(server_id: @id)¶ Returns information about a server’s image.
Parameters: - server_id (
str
) – the unique identifier for the server.
Return type: JSON
- server_id (
-
install_image
(server_id: @id, image_id: nil, password: nil, firewall_id: nil)¶ Installs an image onto the server.
Parameters: - server_id (
str
) – the unique identifier for the server. - image_id (
str
) – the unique identifier for the server image. - password (
str
) – server password. - firewall_id (
str
) – the unique identifier for the firewall policy to be assigned.
Return type: JSON
- server_id (
-
ips
(server_id: @id)¶ Returns a list of the server’s IP’s.
Parameters: - server_id (
str
) – the unique identifier for the server.
Return type: JSON
- server_id (
-
add_ip
(server_id: @id, ip_type: nil)¶ Add an IP to the server.
Parameters: - server_id (
str
) – the unique identifier for the server. - ip_type (
str
) – at the moment, only`IPV4`
is currently supported.
Return type: JSON
- server_id (
-
ip
(server_id: @id, ip_id: nil)¶ Returns information about a server’s IP.
Parameters: - server_id (
str
) – the unique identifier for the server. - ip_id (
str
) – the unique identifier for the IP.
Return type: JSON
- server_id (
-
release_ip
(server_id: @id, ip_id: nil, keep_ip: nil)¶ Release an IP from the server.
Parameters: - server_id (
str
) – the unique identifier for the server. - ip_id (
str
) – the unique identifier for the server’s IP. - keep_ip (
bool
) – Setkeep_ip
toTrue
for releasing the IP without deleting it permanently. (False
by default)
Return type: JSON
- server_id (
-
add_firewall
(server_id: @id, ip_id: nil, firewall_id: nil)¶ Add a firewall policy to a server’s IP.
Parameters: - server_id (
str
) – the unique identifier for the server. - ip_id (
str
) – the unique identifier for the server’s IP. - firewall_id (
str
) – the unique identifier for the firewall policy.
Return type: JSON
- server_id (
-
firewall
(server_id: @id, ip_id: nil)¶ Returns information about a server IP’s firewall policy.
Parameters: - server_id (
str
) – the unique identifier for the server. - ip_id (
str
) – the unique identifier for the server’s IP.
Return type: JSON
- server_id (
-
load_balancers
(server_id: @id, ip_id: nil)¶ Returns a list of the load balancers assigned to a server IP.
Parameters: - server_id (
str
) – the unique identifier for the server. - ip_id (
str
) – the unique identifier for the server’s IP.
Return type: JSON
- server_id (
-
add_load_balancer
(server_id: @id, ip_id: nil, load_balancer_id: nil)¶ Add a load balancer to a server’s IP.
Parameters: - server_id (
str
) – the unique identifier for the server. - ip_id (
str
) – the unique identifier for the server’s IP. - load_balancer_id (
str
) – the unique identifier for the load balancer.
Return type: JSON
- server_id (
-
remove_load_balancer
(server_id: @id, ip_id: nil, load_balancer_id: nil)¶ Remove a load balancer from a server’s IP.
Parameters: - server_id (
str
) – the unique identifier for the server. - ip_id (
str
) – the unique identifier for the server’s IP. - load_balancer_id (
str
) – the unique identifier for the load balancer.
Return type: JSON
- server_id (
-
status
(server_id: @id)¶ Retrieve the server’s current state.
Parameters: - server_id (
str
) – the unique identifier for the server.
Return type: JSON
- server_id (
-
change_status
(server_id: @id, action: nil, method: nil)¶ Modify a server’s state.
Parameters: - server_id (
str
) – the unique identifier for the server. - action (
str
) – the action to perform on the server. Possible values are'POWER_OFF'
,'POWER_ON'
, and'REBOOT'
. - method (
str
) – the action’s method. Possible values are'SOFTWARE'
or'HARDWARE'
.
Return type: JSON
- server_id (
-
dvd
(server_id: @id)¶ Returns information about the DVD currently loaded into the server.
Parameters: - server_id (
str
) – the unique identifier for the server.
Return type: JSON
- server_id (
-
load_dvd
(server_id: @id, dvd_id: nil)¶ Loads a DVD into the server.
Parameters: - server_id (
str
) – the unique identifier for the server. - dvd_id (
str
) – the unique identifier for the DVD.
Return type: JSON
- server_id (
-
eject_dvd
(server_id: @id)¶ Eject the DVD from the server.
Parameters: - server_id (
str
) – the unique identifier for the server.
Return type: JSON
- server_id (
-
private_networks
(server_id: @id)¶ Returns a list of the server’s private networks.
Parameters: - server_id (
str
) – the unique identifier for the server.
Return type: JSON
- server_id (
-
private_network
(server_id: @id, private_network_id: nil)¶ Returns information about a server’s private network.
Parameters: - server_id (
str
) – the unique identifier for the server. - private_network_id (
str
) – the unique identifier for the private network.
Return type: JSON
- server_id (
-
remove_private_network
(server_id: @id, private_network_id: nil)¶ Removes a server from a private network.
Parameters: - server_id (
str
) – the unique identifier for the server. - private_network_id (
str
) – the unique identifier for the private network.
Return type: JSON
- server_id (
-
add_private_network
(server_id: @id, private_network_id: nil)¶ Add a server to a private network.
Parameters: - server_id (
str
) – the unique identifier for the server. - private_network_id (
str
) – the unique identifier for the private network.
Return type: JSON
- server_id (
-
create_snapshot
(server_id: @id)¶ Creates a server snapshot.
Parameters: - server_id (
str
) – the unique identifier for the server.
Return type: JSON
- server_id (
-
snapshot
(server_id: @id)¶ Returns information about a server’s snapshot.
Parameters: - server_id (
str
) – the unique identifier for the server.
Return type: JSON
- server_id (
-
restore_snapshot
(server_id: @id, snapshot_id: nil)¶ Restore a server’s snapshot.
Parameters: - server_id (
str
) – the unique identifier for the server. - snapshot_id (
str
) – the unique identifier for the server snapshot.
Return type: JSON
- server_id (
-
delete_snapshot
(server_id: @id, snapshot_id: nil)¶ Remove a server’s snapshot.
Parameters: - server_id (
str
) – the unique identifier for the server. - snapshot_id (
str
) – the unique identifier for the server snapshot.
Return type: JSON
- server_id (
-
clone
(server_id: @id, name: nil)¶ Clone a server.
Parameters: - server_id (
str
) – the unique identifier for the server to be cloned. - name (
str
) – the new server’s name.
Return type: JSON
- server_id (
-
wait_for
()¶ Polls the server until an “ACTIVE”, “POWERED_ON”, or “POWERED_OFF” state is returned. Use this when chaining actions.
Return type: nil
-