vultr 0.4.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +32 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +5 -10
- data/README.md +306 -136
- data/Rakefile +10 -6
- data/bin/console +21 -0
- data/bin/setup +8 -0
- data/bin/test +6 -0
- data/lib/vultr/client.rb +111 -0
- data/lib/vultr/collection.rb +22 -0
- data/lib/vultr/error.rb +4 -0
- data/lib/vultr/object.rb +19 -0
- data/lib/vultr/objects/account.rb +4 -0
- data/lib/vultr/objects/application.rb +4 -0
- data/lib/vultr/objects/backup.rb +4 -0
- data/lib/vultr/objects/bare_metal.rb +4 -0
- data/lib/vultr/objects/block_storage.rb +4 -0
- data/lib/vultr/objects/domain.rb +4 -0
- data/lib/vultr/objects/firewall_group.rb +4 -0
- data/lib/vultr/objects/instance.rb +4 -0
- data/lib/vultr/objects/iso.rb +4 -0
- data/lib/vultr/objects/kubernetes_cluster.rb +4 -0
- data/lib/vultr/objects/load_balancer.rb +4 -0
- data/lib/vultr/objects/object_storage.rb +4 -0
- data/lib/vultr/objects/operating_system.rb +4 -0
- data/lib/vultr/objects/plan.rb +4 -0
- data/lib/vultr/objects/private_network.rb +4 -0
- data/lib/vultr/objects/region.rb +4 -0
- data/lib/vultr/objects/reserved_ip.rb +4 -0
- data/lib/vultr/objects/snapshot.rb +4 -0
- data/lib/vultr/objects/ssh_key.rb +4 -0
- data/lib/vultr/objects/startup_script.rb +4 -0
- data/lib/vultr/objects/user.rb +4 -0
- data/lib/vultr/resource.rb +52 -0
- data/lib/vultr/resources/account.rb +7 -0
- data/lib/vultr/resources/applications.rb +8 -0
- data/lib/vultr/resources/backups.rb +12 -0
- data/lib/vultr/resources/bare_metal.rb +79 -0
- data/lib/vultr/resources/block_storage.rb +32 -0
- data/lib/vultr/resources/dns.rb +58 -0
- data/lib/vultr/resources/firewall.rb +42 -0
- data/lib/vultr/resources/instances.rb +145 -0
- data/lib/vultr/resources/iso.rb +25 -0
- data/lib/vultr/resources/kubernetes.rb +61 -0
- data/lib/vultr/resources/load_balancers.rb +50 -0
- data/lib/vultr/resources/object_storage.rb +33 -0
- data/lib/vultr/resources/operating_systems.rb +8 -0
- data/lib/vultr/resources/plans.rb +13 -0
- data/lib/vultr/resources/private_networks.rb +24 -0
- data/lib/vultr/resources/regions.rb +12 -0
- data/lib/vultr/resources/reserved_ips.rb +32 -0
- data/lib/vultr/resources/snapshots.rb +28 -0
- data/lib/vultr/resources/ssh_keys.rb +24 -0
- data/lib/vultr/resources/startup_scripts.rb +24 -0
- data/lib/vultr/resources/users.rb +24 -0
- data/lib/vultr/version.rb +1 -8
- data/lib/vultr.rb +56 -887
- data/test/fixtures/account/info.json +11 -0
- data/test/fixtures/applications/list.json +29 -0
- data/test/fixtures/backups/list.json +18 -0
- data/test/fixtures/backups/retrieve.json +9 -0
- data/test/fixtures/bare_metals/bandwidth.json +12 -0
- data/test/fixtures/bare_metals/create.json +26 -0
- data/test/fixtures/bare_metals/list.json +36 -0
- data/test/fixtures/bare_metals/list_ipv4.json +18 -0
- data/test/fixtures/bare_metals/list_ipv6.json +17 -0
- data/test/fixtures/bare_metals/reinstall.json +25 -0
- data/test/fixtures/bare_metals/retrieve.json +26 -0
- data/test/fixtures/bare_metals/update.json +26 -0
- data/test/fixtures/bare_metals/upgrades.json +47 -0
- data/test/fixtures/bare_metals/user_data.json +5 -0
- data/test/fixtures/bare_metals/vnc.json +5 -0
- data/test/fixtures/block_storage/attach.json +4 -0
- data/test/fixtures/block_storage/create.json +13 -0
- data/test/fixtures/block_storage/detach.json +4 -0
- data/test/fixtures/block_storage/list.json +22 -0
- data/test/fixtures/block_storage/retrieve.json +13 -0
- data/test/fixtures/domains/create.json +6 -0
- data/test/fixtures/domains/dnssec.json +7 -0
- data/test/fixtures/domains/list.json +15 -0
- data/test/fixtures/domains/record.json +10 -0
- data/test/fixtures/domains/records.json +19 -0
- data/test/fixtures/domains/retrieve.json +6 -0
- data/test/fixtures/domains/soa.json +6 -0
- data/test/fixtures/firewall/create.json +11 -0
- data/test/fixtures/firewall/create_rule.json +9 -0
- data/test/fixtures/firewall/delete.json +1 -0
- data/test/fixtures/firewall/delete_rule.json +1 -0
- data/test/fixtures/firewall/list.json +20 -0
- data/test/fixtures/firewall/list_rules.json +22 -0
- data/test/fixtures/firewall/retrieve.json +11 -0
- data/test/fixtures/firewall/retrieve_rule.json +13 -0
- data/test/fixtures/firewall/update.json +1 -0
- data/test/fixtures/instances/attach_iso.json +6 -0
- data/test/fixtures/instances/attach_private_network.json +1 -0
- data/test/fixtures/instances/backup_schedule.json +10 -0
- data/test/fixtures/instances/bandwidth.json +12 -0
- data/test/fixtures/instances/create.json +36 -0
- data/test/fixtures/instances/create_ipv4_reverse.json +1 -0
- data/test/fixtures/instances/create_ipv6_reverse.json +1 -0
- data/test/fixtures/instances/delete.json +1 -0
- data/test/fixtures/instances/delete_ipv4.json +1 -0
- data/test/fixtures/instances/delete_ipv6.json +1 -0
- data/test/fixtures/instances/detach_iso.json +5 -0
- data/test/fixtures/instances/detach_private_network.json +1 -0
- data/test/fixtures/instances/halt.json +1 -0
- data/test/fixtures/instances/halt_instances.json +1 -0
- data/test/fixtures/instances/ipv4.json +9 -0
- data/test/fixtures/instances/ipv6_reverse.json +15 -0
- data/test/fixtures/instances/iso.json +6 -0
- data/test/fixtures/instances/list.json +44 -0
- data/test/fixtures/instances/list_ipv4.json +32 -0
- data/test/fixtures/instances/list_ipv6.json +17 -0
- data/test/fixtures/instances/list_private_networks.json +16 -0
- data/test/fixtures/instances/neighbors.json +6 -0
- data/test/fixtures/instances/reboot.json +1 -0
- data/test/fixtures/instances/reboot_instances.json +1 -0
- data/test/fixtures/instances/reinstall.json +35 -0
- data/test/fixtures/instances/restore.json +7 -0
- data/test/fixtures/instances/retrieve.json +35 -0
- data/test/fixtures/instances/set_backup_schedule.json +1 -0
- data/test/fixtures/instances/set_default_reverse_dns_entry.json +1 -0
- data/test/fixtures/instances/start.json +1 -0
- data/test/fixtures/instances/start_instances.json +1 -0
- data/test/fixtures/instances/update.json +1 -0
- data/test/fixtures/instances/upgrades.json +55 -0
- data/test/fixtures/instances/user_data.json +5 -0
- data/test/fixtures/isos/create.json +8 -0
- data/test/fixtures/isos/list.json +20 -0
- data/test/fixtures/isos/list_public.json +17 -0
- data/test/fixtures/isos/retrieve.json +11 -0
- data/test/fixtures/kubernetes/config.json +3 -0
- data/test/fixtures/kubernetes/create.json +39 -0
- data/test/fixtures/kubernetes/create_node_pool.json +25 -0
- data/test/fixtures/kubernetes/list.json +85 -0
- data/test/fixtures/kubernetes/list_node_pools.json +56 -0
- data/test/fixtures/kubernetes/list_resources.json +26 -0
- data/test/fixtures/kubernetes/retrieve.json +39 -0
- data/test/fixtures/kubernetes/retrieve_node_pool.json +25 -0
- data/test/fixtures/kubernetes/update_node_pool.json +19 -0
- data/test/fixtures/load_balancers/create.json +48 -0
- data/test/fixtures/load_balancers/create_forwarding_rule.json +1 -0
- data/test/fixtures/load_balancers/delete.json +1 -0
- data/test/fixtures/load_balancers/delete_forwarding_rule.json +1 -0
- data/test/fixtures/load_balancers/list.json +57 -0
- data/test/fixtures/load_balancers/list_firewall_rules.json +17 -0
- data/test/fixtures/load_balancers/list_forwarding_rules.json +18 -0
- data/test/fixtures/load_balancers/retrieve.json +48 -0
- data/test/fixtures/load_balancers/retrieve_firewall_rule.json +8 -0
- data/test/fixtures/load_balancers/retrieve_forwarding_rule.json +9 -0
- data/test/fixtures/load_balancers/update.json +1 -0
- data/test/fixtures/object_storage/create.json +14 -0
- data/test/fixtures/object_storage/delete.json +1 -0
- data/test/fixtures/object_storage/list.json +22 -0
- data/test/fixtures/object_storage/list_clusters.json +17 -0
- data/test/fixtures/object_storage/regenerate_keys.json +7 -0
- data/test/fixtures/object_storage/retrieve.json +13 -0
- data/test/fixtures/object_storage/update.json +1 -0
- data/test/fixtures/operating_systems/list.json +17 -0
- data/test/fixtures/plans/list.json +22 -0
- data/test/fixtures/plans/list_metal.json +24 -0
- data/test/fixtures/private_networks/create.json +10 -0
- data/test/fixtures/private_networks/delete.json +1 -0
- data/test/fixtures/private_networks/list.json +19 -0
- data/test/fixtures/private_networks/retrieve.json +10 -0
- data/test/fixtures/private_networks/update.json +1 -0
- data/test/fixtures/regions/list.json +20 -0
- data/test/fixtures/regions/list_availability.json +24 -0
- data/test/fixtures/reserved_ips/attach.json +1 -0
- data/test/fixtures/reserved_ips/convert.json +11 -0
- data/test/fixtures/reserved_ips/create.json +11 -0
- data/test/fixtures/reserved_ips/delete.json +1 -0
- data/test/fixtures/reserved_ips/detach.json +1 -0
- data/test/fixtures/reserved_ips/list.json +29 -0
- data/test/fixtures/reserved_ips/retrieve.json +11 -0
- data/test/fixtures/snapshots/create.json +11 -0
- data/test/fixtures/snapshots/create_from_url.json +11 -0
- data/test/fixtures/snapshots/delete.json +1 -0
- data/test/fixtures/snapshots/list.json +20 -0
- data/test/fixtures/snapshots/retrieve.json +11 -0
- data/test/fixtures/snapshots/update.json +1 -0
- data/test/fixtures/ssh_keys/create.json +8 -0
- data/test/fixtures/ssh_keys/delete.json +1 -0
- data/test/fixtures/ssh_keys/list.json +17 -0
- data/test/fixtures/ssh_keys/retrieve.json +8 -0
- data/test/fixtures/ssh_keys/update.json +1 -0
- data/test/fixtures/startup_scripts/create.json +10 -0
- data/test/fixtures/startup_scripts/delete.json +1 -0
- data/test/fixtures/startup_scripts/list.json +18 -0
- data/test/fixtures/startup_scripts/retrieve.json +10 -0
- data/test/fixtures/startup_scripts/update.json +1 -0
- data/test/fixtures/users/create.json +9 -0
- data/test/fixtures/users/delete.json +1 -0
- data/test/fixtures/users/list.json +29 -0
- data/test/fixtures/users/retrieve.json +20 -0
- data/test/fixtures/users/update.json +1 -0
- data/test/test_helper.rb +18 -5
- data/test/vultr/client_test.rb +8 -0
- data/test/vultr/object_test.rb +21 -0
- data/test/vultr/resources/account_test.rb +12 -0
- data/test/vultr/resources/applications_test.rb +15 -0
- data/test/vultr/resources/backups_test.rb +24 -0
- data/test/vultr/resources/bare_metal_test.rb +267 -0
- data/test/vultr/resources/block_storage_test.rb +85 -0
- data/test/vultr/resources/dns_test.rb +134 -0
- data/test/vultr/resources/firewall_test.rb +88 -0
- data/test/vultr/resources/instances_test.rb +325 -0
- data/test/vultr/resources/iso_test.rb +58 -0
- data/test/vultr/resources/kubernetes_test.rb +185 -0
- data/test/vultr/resources/load_balancers_test.rb +110 -0
- data/test/vultr/resources/object_storage_test.rb +71 -0
- data/test/vultr/resources/operating_systems_test.rb +15 -0
- data/test/vultr/resources/plans_test.rb +25 -0
- data/test/vultr/resources/private_networks_test.rb +50 -0
- data/test/vultr/resources/regions_test.rb +26 -0
- data/test/vultr/resources/reserved_ips_test.rb +67 -0
- data/test/vultr/resources/snapshots_test.rb +60 -0
- data/test/vultr/resources/ssh_keys_test.rb +50 -0
- data/test/vultr/resources/startup_scripts_test.rb +50 -0
- data/test/vultr/resources/users_test.rb +50 -0
- data/vultr.gemspec +17 -17
- metadata +394 -48
- data/test/vultr/vultr_account_test.rb +0 -29
- data/test/vultr/vultr_app_test.rb +0 -26
- data/test/vultr/vultr_backup_test.rb +0 -22
- data/test/vultr/vultr_iso_test.rb +0 -27
- data/test/vultr/vultr_os_test.rb +0 -21
- data/test/vultr/vultr_plan_test.rb +0 -22
- data/test/vultr/vultr_region_test.rb +0 -33
- data/test/vultr/vultr_snapshot_test.rb +0 -30
- data/test/vultr/vultr_sshkey_test.rb +0 -50
- data/test/vultr/vultr_startupscript_test.rb +0 -53
@@ -0,0 +1,50 @@
|
|
1
|
+
module Vultr
|
2
|
+
class LoadBalancersResource < Resource
|
3
|
+
def list(**params)
|
4
|
+
response = get_request("load-balancers", params: params)
|
5
|
+
Collection.from_response(response, key: "load_balancers", type: LoadBalancer)
|
6
|
+
end
|
7
|
+
|
8
|
+
def create(**attributes)
|
9
|
+
LoadBalancer.new post_request("load-balancers", body: attributes).body.dig("load_balancer")
|
10
|
+
end
|
11
|
+
|
12
|
+
def retrieve(load_balancer_id:)
|
13
|
+
LoadBalancer.new get_request("load-balancers/#{load_balancer_id}").body.dig("load_balancer")
|
14
|
+
end
|
15
|
+
|
16
|
+
def update(load_balancer_id:, **attributes)
|
17
|
+
LoadBalancer.new patch_request("load-balancers/#{load_balancer_id}", body: attributes).body.dig("load_balancer")
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete(load_balancer_id:)
|
21
|
+
delete_request("load-balancers/#{load_balancer_id}")
|
22
|
+
end
|
23
|
+
|
24
|
+
def list_forwarding_rules(load_balancer_id:, **params)
|
25
|
+
response = get_request("load-balancers/#{load_balancer_id}/forwarding-rules", params: params)
|
26
|
+
Collection.from_response(response, key: "forwarding_rules", type: Object)
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_forwarding_rule(load_balancer_id:, **attributes)
|
30
|
+
Object.new post_request("load-balancers/#{load_balancer_id}/forwarding-rules", body: attributes).body.dig("forwarding_rule")
|
31
|
+
end
|
32
|
+
|
33
|
+
def retrieve_forwarding_rule(load_balancer_id:, forwarding_rule_id:)
|
34
|
+
Object.new get_request("load-balancers/#{load_balancer_id}/forwarding-rules/#{forwarding_rule_id}").body.dig("forwarding_rule")
|
35
|
+
end
|
36
|
+
|
37
|
+
def delete_forwarding_rule(load_balancer_id:, forwarding_rule_id:)
|
38
|
+
delete_request("load-balancers/#{load_balancer_id}/forwarding-rules/#{forwarding_rule_id}")
|
39
|
+
end
|
40
|
+
|
41
|
+
def list_firewall_rules(load_balancer_id:, **params)
|
42
|
+
response = get_request("load-balancers/#{load_balancer_id}/firewall-rules", params: params)
|
43
|
+
Collection.from_response(response, key: "firewall_rules", type: Object)
|
44
|
+
end
|
45
|
+
|
46
|
+
def retrieve_firewall_rule(load_balancer_id:, firewall_rule_id:)
|
47
|
+
Object.new get_request("load-balancers/#{load_balancer_id}/firewall-rules/#{firewall_rule_id}").body.dig("firewall_rule")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Vultr
|
2
|
+
class ObjectStorageResource < Resource
|
3
|
+
def list(**params)
|
4
|
+
response = get_request("object-storage", params: params)
|
5
|
+
Collection.from_response(response, key: "object_storages", type: ObjectStorage)
|
6
|
+
end
|
7
|
+
|
8
|
+
def create(**attributes)
|
9
|
+
ObjectStorage.new post_request("object-storage", body: attributes).body.dig("object_storage")
|
10
|
+
end
|
11
|
+
|
12
|
+
def retrieve(object_storage_id:)
|
13
|
+
ObjectStorage.new get_request("object-storage/#{object_storage_id}").body.dig("object_storage")
|
14
|
+
end
|
15
|
+
|
16
|
+
def update(object_storage_id:, **attributes)
|
17
|
+
put_request("object-storage/#{object_storage_id}", body: attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete(object_storage_id:)
|
21
|
+
delete_request("object-storage/#{object_storage_id}")
|
22
|
+
end
|
23
|
+
|
24
|
+
def regenerate_keys(object_storage_id:)
|
25
|
+
Object.new post_request("object-storage/#{object_storage_id}/regenerate-keys", body: {}).body
|
26
|
+
end
|
27
|
+
|
28
|
+
def list_clusters(**params)
|
29
|
+
response = get_request("object-storage/clusters", params: params)
|
30
|
+
Collection.from_response(response, key: "clusters", type: Object)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Vultr
|
2
|
+
class PlansResource < Resource
|
3
|
+
def list(**params)
|
4
|
+
response = get_request("plans", params: params)
|
5
|
+
Collection.from_response(response, key: "plans", type: Plan)
|
6
|
+
end
|
7
|
+
|
8
|
+
def list_metal(**params)
|
9
|
+
response = get_request("plans-metal", params: params)
|
10
|
+
Collection.from_response(response, key: "plans_metal", type: Plan)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Vultr
|
2
|
+
class PrivateNetworksResource < Resource
|
3
|
+
def list(**params)
|
4
|
+
response = get_request("private-networks", params: params)
|
5
|
+
Collection.from_response(response, key: "networks", type: PrivateNetwork)
|
6
|
+
end
|
7
|
+
|
8
|
+
def create(**attributes)
|
9
|
+
PrivateNetwork.new post_request("private-networks", body: attributes).body.dig("network")
|
10
|
+
end
|
11
|
+
|
12
|
+
def retrieve(network_id:)
|
13
|
+
PrivateNetwork.new get_request("private-networks/#{network_id}").body.dig("network")
|
14
|
+
end
|
15
|
+
|
16
|
+
def update(network_id:, **attributes)
|
17
|
+
put_request("private-networks/#{network_id}", body: attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete(network_id:)
|
21
|
+
delete_request("private-networks/#{network_id}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Vultr
|
2
|
+
class RegionsResource < Resource
|
3
|
+
def list(**params)
|
4
|
+
response = get_request("regions", params: params)
|
5
|
+
Collection.from_response(response, key: "regions", type: Region)
|
6
|
+
end
|
7
|
+
|
8
|
+
def list_availability(region_id:)
|
9
|
+
Object.new get_request("regions/#{region_id}/availability").body
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Vultr
|
2
|
+
class ReservedIpsResource < Resource
|
3
|
+
def list(**params)
|
4
|
+
response = get_request("reserved-ips", params: params)
|
5
|
+
Collection.from_response(response, key: "reserved_ips", type: ReservedIp)
|
6
|
+
end
|
7
|
+
|
8
|
+
def create(**attributes)
|
9
|
+
ReservedIp.new post_request("reserved-ips", body: attributes).body.dig("reserved_ip")
|
10
|
+
end
|
11
|
+
|
12
|
+
def retrieve(reserved_ip:)
|
13
|
+
ReservedIp.new get_request("reserved-ips/#{reserved_ip}").body.dig("reserved_ip")
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete(reserved_ip:)
|
17
|
+
delete_request("reserved-ips/#{reserved_ip}")
|
18
|
+
end
|
19
|
+
|
20
|
+
def attach(reserved_ip:, instance_id:)
|
21
|
+
post_request("reserved-ips/#{reserved_ip}/attach", body: {instance_id: instance_id})
|
22
|
+
end
|
23
|
+
|
24
|
+
def detach(reserved_ip:)
|
25
|
+
post_request("reserved-ips/#{reserved_ip}/detach", body: {})
|
26
|
+
end
|
27
|
+
|
28
|
+
def convert(**attributes)
|
29
|
+
ReservedIp.new post_request("reserved-ips/convert", body: attributes).body.dig("reserved_ip")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Vultr
|
2
|
+
class SnapshotsResource < Resource
|
3
|
+
def list(**params)
|
4
|
+
response = get_request("snapshots", params: params)
|
5
|
+
Collection.from_response(response, key: "snapshots", type: Snapshot)
|
6
|
+
end
|
7
|
+
|
8
|
+
def create(**attributes)
|
9
|
+
Snapshot.new post_request("snapshots", body: attributes).body.dig("snapshot")
|
10
|
+
end
|
11
|
+
|
12
|
+
def retrieve(snapshot_id:)
|
13
|
+
Snapshot.new get_request("snapshots/#{snapshot_id}").body.dig("snapshot")
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_from_url(url)
|
17
|
+
Snapshot.new post_request("snapshots/create-from-url", body: {url: url}).body.dig("snapshot")
|
18
|
+
end
|
19
|
+
|
20
|
+
def update(snapshot_id:, **attributes)
|
21
|
+
put_request("snapshots/#{snapshot_id}", body: attributes)
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete(snapshot_id:)
|
25
|
+
delete_request("snapshots/#{snapshot_id}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Vultr
|
2
|
+
class SshKeysResource < Resource
|
3
|
+
def list(**params)
|
4
|
+
response = get_request("ssh-keys", params: params)
|
5
|
+
Collection.from_response(response, key: "ssh_keys", type: SshKey)
|
6
|
+
end
|
7
|
+
|
8
|
+
def create(**attributes)
|
9
|
+
SshKey.new post_request("ssh-keys", body: attributes).body.dig("ssh_key")
|
10
|
+
end
|
11
|
+
|
12
|
+
def retrieve(ssh_key_id:)
|
13
|
+
SshKey.new get_request("ssh-keys/#{ssh_key_id}").body.dig("ssh_key")
|
14
|
+
end
|
15
|
+
|
16
|
+
def update(ssh_key_id:, **attributes)
|
17
|
+
patch_request("ssh-keys/#{ssh_key_id}", body: attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete(ssh_key_id:)
|
21
|
+
delete_request("ssh-keys/#{ssh_key_id}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Vultr
|
2
|
+
class StartupScriptsResource < Resource
|
3
|
+
def list(**params)
|
4
|
+
response = get_request("startup-scripts", params: params)
|
5
|
+
Collection.from_response(response, key: "startup_scripts", type: StartupScript)
|
6
|
+
end
|
7
|
+
|
8
|
+
def create(**attributes)
|
9
|
+
StartupScript.new post_request("startup-scripts", body: attributes).body.dig("startup_script")
|
10
|
+
end
|
11
|
+
|
12
|
+
def retrieve(startup_script_id:)
|
13
|
+
StartupScript.new get_request("startup-scripts/#{startup_script_id}").body.dig("startup_script")
|
14
|
+
end
|
15
|
+
|
16
|
+
def update(startup_script_id:, **attributes)
|
17
|
+
patch_request("startup-scripts/#{startup_script_id}", body: attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete(startup_script_id:)
|
21
|
+
delete_request("startup-scripts/#{startup_script_id}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Vultr
|
2
|
+
class UserResource < Resource
|
3
|
+
def list(**params)
|
4
|
+
response = get_request("users", params: params)
|
5
|
+
Collection.from_response(response, key: "users", type: User)
|
6
|
+
end
|
7
|
+
|
8
|
+
def create(**attributes)
|
9
|
+
User.new post_request("users", body: attributes).body.dig("user")
|
10
|
+
end
|
11
|
+
|
12
|
+
def retrieve(user_id:)
|
13
|
+
User.new get_request("users/#{user_id}").body.dig("user")
|
14
|
+
end
|
15
|
+
|
16
|
+
def update(user_id:, **attributes)
|
17
|
+
patch_request("users/#{user_id}", body: attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete(user_id:)
|
21
|
+
delete_request("users/#{user_id}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/vultr/version.rb
CHANGED
data/lib/vultr.rb
CHANGED
@@ -1,888 +1,57 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
|
5
|
-
module Vultr
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
:path => '/v1/baremetal/bandwidth',
|
58
|
-
:apikey_required => true
|
59
|
-
},
|
60
|
-
create: {
|
61
|
-
:method => :post,
|
62
|
-
:path => '/v1/baremetal/create',
|
63
|
-
:params => %w(DCID METALPLANID OSID SCRIPTID SNAPSHOTID enable_ipv6 label SSHKEYID APPID userdata notify_activate hostname tag),
|
64
|
-
:apikey_required => true
|
65
|
-
},
|
66
|
-
destroy: {
|
67
|
-
:method => :post,
|
68
|
-
:path => '/v1/baremetal/destroy',
|
69
|
-
:params => %w(SUBID),
|
70
|
-
:apikey_required => true
|
71
|
-
},
|
72
|
-
get_app_info: {
|
73
|
-
:method => :get,
|
74
|
-
:path => '/v1/baremetal/get_app_info',
|
75
|
-
:params => %w(SUBID),
|
76
|
-
:apikey_required => true
|
77
|
-
},
|
78
|
-
get_user_data: {
|
79
|
-
:method => :get,
|
80
|
-
:path => '/v1/baremetal/get_user_data',
|
81
|
-
:params => %w(SUBID),
|
82
|
-
:apikey_required => true
|
83
|
-
},
|
84
|
-
halt: {
|
85
|
-
:method => :post,
|
86
|
-
:path => '/v1/baremetal/halt',
|
87
|
-
:params => %w(SUBID),
|
88
|
-
:apikey_required => true
|
89
|
-
},
|
90
|
-
ipv6_enable: {
|
91
|
-
:method => :post,
|
92
|
-
:path => '/v1/baremetal/ipv6_enable',
|
93
|
-
:params => %w(SUBID),
|
94
|
-
:apikey_required => true
|
95
|
-
},
|
96
|
-
label_set: {
|
97
|
-
:method => :post,
|
98
|
-
:path => '/v1/baremetal/label_set',
|
99
|
-
:params => %w(SUBID label),
|
100
|
-
:apikey_required => true
|
101
|
-
},
|
102
|
-
list: {
|
103
|
-
:method => :get,
|
104
|
-
:path => '/v1/baremetal/list',
|
105
|
-
:params => %w(SUBID tag label main_ip),
|
106
|
-
:apikey_required => true
|
107
|
-
},
|
108
|
-
list_ipv4: {
|
109
|
-
:method => :get,
|
110
|
-
:path => '/v1/baremetal/list_ipv4',
|
111
|
-
:params => %w(SUBID),
|
112
|
-
:apikey_required => true
|
113
|
-
},
|
114
|
-
list_ipv6: {
|
115
|
-
:method => :get,
|
116
|
-
:path => '/v1/baremetal/list_ipv6',
|
117
|
-
:params => %w(SUBID),
|
118
|
-
:apikey_required => true
|
119
|
-
},
|
120
|
-
os_change: {
|
121
|
-
:method => :post,
|
122
|
-
:path => '/v1/baremetal/os_change',
|
123
|
-
:params => %w(SUBID OSID),
|
124
|
-
:apikey_required => true
|
125
|
-
},
|
126
|
-
os_change_list: {
|
127
|
-
:method => :get,
|
128
|
-
:path => '/v1/baremetal/os_change_list',
|
129
|
-
:params => %w(SUBID),
|
130
|
-
:apikey_required => true
|
131
|
-
},
|
132
|
-
reboot: {
|
133
|
-
:method => :post,
|
134
|
-
:path => '/v1/baremetal/reboot',
|
135
|
-
:params => %w(SUBID),
|
136
|
-
:apikey_required => true
|
137
|
-
},
|
138
|
-
reinstall: {
|
139
|
-
:method => :post,
|
140
|
-
:path => '/v1/baremetal/reinstall',
|
141
|
-
:params => %w(SUBID),
|
142
|
-
:apikey_required => true
|
143
|
-
},
|
144
|
-
set_user_data: {
|
145
|
-
:method => :post,
|
146
|
-
:path => '/v1/baremetal/set_user_data',
|
147
|
-
:params => %w(SUBID userdata),
|
148
|
-
:apikey_required => true
|
149
|
-
},
|
150
|
-
tag_set: {
|
151
|
-
:method => :post,
|
152
|
-
:path => '/v1/baremetal/tag_set',
|
153
|
-
:params => %w(SUBID tag),
|
154
|
-
:apikey_required => true
|
155
|
-
}
|
156
|
-
},
|
157
|
-
# Block Storage
|
158
|
-
Block: {
|
159
|
-
attach: {
|
160
|
-
:method => :post,
|
161
|
-
:path => '/v1/block/attach?api_key=[api_key]',
|
162
|
-
:params => %w(SUBID attach_to_SUBID),
|
163
|
-
:apikey_required => true
|
164
|
-
},
|
165
|
-
create: {
|
166
|
-
:method => :post,
|
167
|
-
:path => '/v1/block/create',
|
168
|
-
:params => %w(DCID size_gb label),
|
169
|
-
:apikey_required => true
|
170
|
-
},
|
171
|
-
delete: {
|
172
|
-
:method => :post,
|
173
|
-
:path => '/v1/block/delete',
|
174
|
-
:params => %w(SUBID),
|
175
|
-
:apikey_required => true
|
176
|
-
},
|
177
|
-
detach: {
|
178
|
-
:method => :post,
|
179
|
-
:path => '/v1/block/detach',
|
180
|
-
:params => %w(SUBID),
|
181
|
-
:apikey_required => true
|
182
|
-
},
|
183
|
-
label_set: {
|
184
|
-
:method => :post,
|
185
|
-
:path => '/v1/block/label_set',
|
186
|
-
:params => %w(SUBID label),
|
187
|
-
:apikey_required => true
|
188
|
-
},
|
189
|
-
list: {
|
190
|
-
:method => :get,
|
191
|
-
:path => '/v1/block/list',
|
192
|
-
:params => %w(SUBID),
|
193
|
-
:apikey_required => true
|
194
|
-
},
|
195
|
-
resize: {
|
196
|
-
:method => :post,
|
197
|
-
:path => '/v1/block/resize',
|
198
|
-
:params => %w(SUBID size_gb),
|
199
|
-
:apikey_required => true
|
200
|
-
}
|
201
|
-
},
|
202
|
-
# DNS
|
203
|
-
DNS: {
|
204
|
-
create_domain: {
|
205
|
-
:method => :post,
|
206
|
-
:path => '/v1/dns/create_domain',
|
207
|
-
:params => %w(domain serverip),
|
208
|
-
:apikey_required => true
|
209
|
-
},
|
210
|
-
create_record: {
|
211
|
-
:method => :post,
|
212
|
-
:path => '/v1/dns/create_record',
|
213
|
-
:params => %w(domain name type data ttl priority),
|
214
|
-
:apikey_required => true
|
215
|
-
},
|
216
|
-
delete_domain: {
|
217
|
-
:method => :post,
|
218
|
-
:path => '/v1/dns/delete_domain',
|
219
|
-
:params => %w(domain),
|
220
|
-
:apikey_required => true
|
221
|
-
},
|
222
|
-
delete_record: {
|
223
|
-
:method => :post,
|
224
|
-
:path => '/v1/dns/delete_record',
|
225
|
-
:params => %w(domain RECORDID),
|
226
|
-
:apikey_required => true
|
227
|
-
},
|
228
|
-
dnssec_enable: {
|
229
|
-
:method => :post,
|
230
|
-
:path => '/v1/dns/dnssec_enable',
|
231
|
-
:params => %w(domain enable),
|
232
|
-
:apikey_required => true
|
233
|
-
},
|
234
|
-
dnssec_info: {
|
235
|
-
:method => :post,
|
236
|
-
:path => '/v1/dns/dnssec_info',
|
237
|
-
:params => %w(domain),
|
238
|
-
:apikey_required => true
|
239
|
-
},
|
240
|
-
list: {
|
241
|
-
:method => :get,
|
242
|
-
:path => '/v1/dns/list',
|
243
|
-
:apikey_required => true
|
244
|
-
},
|
245
|
-
records: {
|
246
|
-
:method => :get,
|
247
|
-
:path => '/v1/dns/records',
|
248
|
-
:params => %w(domain),
|
249
|
-
:apikey_required => true
|
250
|
-
},
|
251
|
-
soa_info: {
|
252
|
-
:method => :get,
|
253
|
-
:path => '/v1/dns/records',
|
254
|
-
:params => %w(domain),
|
255
|
-
:apikey_required => true
|
256
|
-
},
|
257
|
-
soa_update: {
|
258
|
-
:method => :get,
|
259
|
-
:path => '/v1/dns/records',
|
260
|
-
:params => %w(domain),
|
261
|
-
:apikey_required => true
|
262
|
-
},
|
263
|
-
update_record: {
|
264
|
-
:method => :post,
|
265
|
-
:path => '/v1/dns/update_record',
|
266
|
-
:params => %w(domain RECORDID name type data ttl priority),
|
267
|
-
:apikey_required => true
|
268
|
-
}
|
269
|
-
},
|
270
|
-
# Firewall
|
271
|
-
Firewall: {
|
272
|
-
group_create: {
|
273
|
-
:method => :post,
|
274
|
-
:path => '/v1/firewall/group_create',
|
275
|
-
:params => %w(description),
|
276
|
-
:apikey_required => true
|
277
|
-
},
|
278
|
-
group_delete: {
|
279
|
-
:method => :post,
|
280
|
-
:path => '/v1/firewall/group_delete',
|
281
|
-
:params => %w(FIREWALLGROUPID),
|
282
|
-
:apikey_required => true
|
283
|
-
},
|
284
|
-
group_list: {
|
285
|
-
:method => :get,
|
286
|
-
:path => '/v1/firewall/group_list',
|
287
|
-
:params => %w(FIREWALLGROUPID),
|
288
|
-
:apikey_required => true
|
289
|
-
},
|
290
|
-
group_set_description: {
|
291
|
-
:method => :post,
|
292
|
-
:path => '/v1/firewall/group_set_description',
|
293
|
-
:params => %w(FIREWALLGROUPID description),
|
294
|
-
:apikey_required => true
|
295
|
-
},
|
296
|
-
rule_create: {
|
297
|
-
:method => :post,
|
298
|
-
:path => '/v1/firewall/rule_create',
|
299
|
-
:params => %w(FIREWALLGROUPID direction ip_type protocol subnet subnet_size port notes),
|
300
|
-
:apikey_required => true
|
301
|
-
},
|
302
|
-
rule_delete: {
|
303
|
-
:method => :post,
|
304
|
-
:path => '/v1/firewall/rule_delete',
|
305
|
-
:params => %w(FIREWALLGROUPID rulenumber),
|
306
|
-
:apikey_required => true
|
307
|
-
},
|
308
|
-
rule_list: {
|
309
|
-
:method => :get,
|
310
|
-
:path => '/v1/firewall/rule_list',
|
311
|
-
:params => %w(FIREWALLGROUPID direction ip_type),
|
312
|
-
:apikey_required => true
|
313
|
-
}
|
314
|
-
},
|
315
|
-
# ISO Image
|
316
|
-
ISO: {
|
317
|
-
create_from_url: {
|
318
|
-
:method => :post,
|
319
|
-
:path => '/v1/iso/create_from_url',
|
320
|
-
:params => %w(url),
|
321
|
-
:apikey_required => true
|
322
|
-
},
|
323
|
-
list: {
|
324
|
-
:method => :get,
|
325
|
-
:path => '/v1/iso/list',
|
326
|
-
:apikey_required => true
|
327
|
-
},
|
328
|
-
list_public: {
|
329
|
-
:method => :get,
|
330
|
-
:path => '/v1/iso/list_public',
|
331
|
-
:apikey_required => true
|
332
|
-
}
|
333
|
-
},
|
334
|
-
# Network
|
335
|
-
Network: {
|
336
|
-
create: {
|
337
|
-
:method => :post,
|
338
|
-
:path => '/v1/network/create',
|
339
|
-
:params => %w(DCID description v4_subnet v4_subnet_mask),
|
340
|
-
:apikey_required => true
|
341
|
-
},
|
342
|
-
destroy: {
|
343
|
-
:method => :post,
|
344
|
-
:path => '/v1/network/destroy',
|
345
|
-
:params => %w(NETWORKID),
|
346
|
-
:apikey_required => true
|
347
|
-
},
|
348
|
-
list: {
|
349
|
-
:method => :get,
|
350
|
-
:path => '/v1/network/list',
|
351
|
-
:apikey_required => true
|
352
|
-
}
|
353
|
-
},
|
354
|
-
# Operating System
|
355
|
-
OS: {
|
356
|
-
list: {
|
357
|
-
:method => :get,
|
358
|
-
:path => '/v1/os/list',
|
359
|
-
:apikey_required => false
|
360
|
-
}
|
361
|
-
},
|
362
|
-
# Plans
|
363
|
-
Plans: {
|
364
|
-
list: {
|
365
|
-
:method => :get,
|
366
|
-
:path => '/v1/plans/list',
|
367
|
-
:params => %w(type),
|
368
|
-
:apikey_required => true
|
369
|
-
},
|
370
|
-
list_baremetal: {
|
371
|
-
:method => :get,
|
372
|
-
:path => '/v1/plans/list_baremetal',
|
373
|
-
:apikey_required => true
|
374
|
-
},
|
375
|
-
list_vc2: {
|
376
|
-
:method => :get,
|
377
|
-
:path => '/v1/plans/list_vc2',
|
378
|
-
:apikey_required => false
|
379
|
-
},
|
380
|
-
list_vdc2: {
|
381
|
-
:method => :get,
|
382
|
-
:path => '/v1/plans/list_vdc2',
|
383
|
-
:apikey_required => false
|
384
|
-
}
|
385
|
-
},
|
386
|
-
# Regions
|
387
|
-
Regions: {
|
388
|
-
availability: {
|
389
|
-
:method => :get,
|
390
|
-
:path => '/v1/regions/availability',
|
391
|
-
:params => %w(DCID type),
|
392
|
-
:apikey_required => false
|
393
|
-
},
|
394
|
-
availability_baremetal: {
|
395
|
-
:method => :get,
|
396
|
-
:path => '/v1/regions/availability_baremetal',
|
397
|
-
:params => %w(DCID),
|
398
|
-
:apikey_required => true
|
399
|
-
},
|
400
|
-
availability_vc2: {
|
401
|
-
:method => :get,
|
402
|
-
:path => '/v1/regions/availability_vc2',
|
403
|
-
:params => %w(DCID),
|
404
|
-
:apikey_required => false
|
405
|
-
},
|
406
|
-
availability_vdc2: {
|
407
|
-
:method => :get,
|
408
|
-
:path => '/v1/regions/availability_vdc2',
|
409
|
-
:params => %w(DCID),
|
410
|
-
:apikey_required => false
|
411
|
-
},
|
412
|
-
list: {
|
413
|
-
:method => :get,
|
414
|
-
:path => '/v1/regions/list',
|
415
|
-
:params => %w(availability),
|
416
|
-
:apikey_required => false
|
417
|
-
}
|
418
|
-
},
|
419
|
-
# Reserved IP
|
420
|
-
ReservedIP: {
|
421
|
-
attach: {
|
422
|
-
:method => :post,
|
423
|
-
:path => '/v1/reservedip/attach',
|
424
|
-
:params => %w(ip_address attach_SUBID),
|
425
|
-
:apikey_required => true
|
426
|
-
},
|
427
|
-
convert: {
|
428
|
-
:method => :post,
|
429
|
-
:path => '/v1/reservedip/convert',
|
430
|
-
:params => %w(SUBID ip_address label),
|
431
|
-
:apikey_required => true
|
432
|
-
},
|
433
|
-
create: {
|
434
|
-
:method => :post,
|
435
|
-
:path => '/v1/reservedip/create',
|
436
|
-
:params => %w(DCID ip_type label),
|
437
|
-
:apikey_required => true
|
438
|
-
},
|
439
|
-
destroy: {
|
440
|
-
:method => :post,
|
441
|
-
:path => '/v1/reservedip/destroy',
|
442
|
-
:params => %w(ip_address),
|
443
|
-
:apikey_required => true
|
444
|
-
},
|
445
|
-
detach: {
|
446
|
-
:method => :post,
|
447
|
-
:path => '/v1/reservedip/detach',
|
448
|
-
:params => %w(ip_address detach_SUBID),
|
449
|
-
:apikey_required => true
|
450
|
-
},
|
451
|
-
list: {
|
452
|
-
:method => :get,
|
453
|
-
:path => '/v1/reservedip/list',
|
454
|
-
:apikey_required => true
|
455
|
-
}
|
456
|
-
},
|
457
|
-
# Server
|
458
|
-
Server: {
|
459
|
-
app_change: {
|
460
|
-
:method => :post,
|
461
|
-
:path => '/v1/server/app_change',
|
462
|
-
:params => %w(SUBID APPID),
|
463
|
-
:apikey_required => true
|
464
|
-
},
|
465
|
-
app_change_list: {
|
466
|
-
:method => :get,
|
467
|
-
:path => '/v1/server/app_change_list',
|
468
|
-
:params => ['SUBID'],
|
469
|
-
:apikey_required => true
|
470
|
-
},
|
471
|
-
backup_disable: {
|
472
|
-
:method => :post,
|
473
|
-
:path => '/v1/server/backup_disable',
|
474
|
-
:params => %w(SUBID),
|
475
|
-
:apikey_required => true
|
476
|
-
},
|
477
|
-
backup_enable: {
|
478
|
-
:method => :post,
|
479
|
-
:path => '/v1/server/backup_enable',
|
480
|
-
:params => %w(SUBID),
|
481
|
-
:apikey_required => true
|
482
|
-
},
|
483
|
-
backup_get_schedule: {
|
484
|
-
:method => :post,
|
485
|
-
:path => '/v1/server/backup_get_schedule',
|
486
|
-
:params => %w(SUBID),
|
487
|
-
:apikey_required => true
|
488
|
-
},
|
489
|
-
backup_set_schedule: {
|
490
|
-
:method => :post,
|
491
|
-
:path => '/v1/server/backup_set_schedule',
|
492
|
-
:params => %w(SUBID cron_type hour dow dom),
|
493
|
-
:apikey_required => true
|
494
|
-
},
|
495
|
-
bandwidth: {
|
496
|
-
:method => :get,
|
497
|
-
:path => '/v1/server/bandwidth',
|
498
|
-
:params => %w(SUBID),
|
499
|
-
:apikey_required => true
|
500
|
-
},
|
501
|
-
create: {
|
502
|
-
:method => :post,
|
503
|
-
:path => '/v1/server/create',
|
504
|
-
:params => %w(DCID VPSPLANID OSID ipxe_chain_url ISOID SCRIPTID SNAPSHOTID enable_ipv6 enable_private_network NETWORKID label SSHKEYID auto_backups APPID userdata notify_activate ddos_protection reserved_ip_v4 hostname tag FIREWALLGROUPID),
|
505
|
-
:apikey_required => true
|
506
|
-
},
|
507
|
-
create_ipv4: {
|
508
|
-
:method => :post,
|
509
|
-
:path => '/v1/server/create_ipv4',
|
510
|
-
:params => %w(SUBID reboot),
|
511
|
-
:apikey_required => true
|
512
|
-
},
|
513
|
-
destroy: {
|
514
|
-
:method => :post,
|
515
|
-
:path => '/v1/server/destroy',
|
516
|
-
:params => %w(SUBID),
|
517
|
-
:apikey_required => true
|
518
|
-
},
|
519
|
-
destroy_ipv4: {
|
520
|
-
:method => :post,
|
521
|
-
:path => '/v1/server/destroy_ipv4',
|
522
|
-
:params => %w(SUBID ip),
|
523
|
-
:apikey_required => true
|
524
|
-
},
|
525
|
-
firewall_group_set: {
|
526
|
-
:method => :post,
|
527
|
-
:path => '/v1/server/firewall_group_set',
|
528
|
-
:params => %w(SUBID FIREWALLGROUPID),
|
529
|
-
:apikey_required => true
|
530
|
-
},
|
531
|
-
get_app_info: {
|
532
|
-
:method => :get,
|
533
|
-
:path => '/v1/server/get_app_info',
|
534
|
-
:params => %w(SUBID),
|
535
|
-
:apikey_required => true
|
536
|
-
},
|
537
|
-
get_user_data: {
|
538
|
-
:method => :get,
|
539
|
-
:path => '/v1/server/set_user_data',
|
540
|
-
:params => %w(SUBID),
|
541
|
-
:apikey_required => true
|
542
|
-
},
|
543
|
-
halt: {
|
544
|
-
:method => :post,
|
545
|
-
:path => '/v1/server/halt',
|
546
|
-
:params => %w('SUBID'),
|
547
|
-
:apikey_required => true
|
548
|
-
},
|
549
|
-
ipv6_enable: {
|
550
|
-
:method => :post,
|
551
|
-
:path => '/v1/server/ipv6_enable',
|
552
|
-
:params => %w(SUBID),
|
553
|
-
:apikey_required => true
|
554
|
-
},
|
555
|
-
iso_attach: {
|
556
|
-
:method => :post,
|
557
|
-
:path => '/v1/server/iso_detach',
|
558
|
-
:params => %w(SUBID, ISOID),
|
559
|
-
:apikey_required => true
|
560
|
-
},
|
561
|
-
iso_detach: {
|
562
|
-
:method => :post,
|
563
|
-
:path => '/v1/server/iso_detach',
|
564
|
-
:params => %w(SUBID),
|
565
|
-
:apikey_required => true
|
566
|
-
},
|
567
|
-
iso_status: {
|
568
|
-
:method => :get,
|
569
|
-
:path => '/v1/server/iso_status',
|
570
|
-
:params => %w(SUBID),
|
571
|
-
:apikey_required => true
|
572
|
-
},
|
573
|
-
label_set: {
|
574
|
-
:method => :post,
|
575
|
-
:path => '/v1/server/label_set',
|
576
|
-
:params => %w(SUBID label),
|
577
|
-
:apikey_required => true
|
578
|
-
},
|
579
|
-
list: {
|
580
|
-
:method => :get,
|
581
|
-
:path => '/v1/server/list',
|
582
|
-
:params => %w(SUBID tag label main_ip),
|
583
|
-
:apikey_required => true
|
584
|
-
},
|
585
|
-
list_ipv4: {
|
586
|
-
:method => :get,
|
587
|
-
:path => '/v1/server/list_ipv4',
|
588
|
-
:params => %w(SUBID),
|
589
|
-
:apikey_required => true
|
590
|
-
},
|
591
|
-
list_ipv6: {
|
592
|
-
:method => :get,
|
593
|
-
:path => '/v1/server/list_ipv6',
|
594
|
-
:params => %w(SUBID),
|
595
|
-
:apikey_required => true
|
596
|
-
},
|
597
|
-
neighbors: {
|
598
|
-
:method => :get,
|
599
|
-
:path => '/v1/server/neighbors',
|
600
|
-
:params => %w(SUBID),
|
601
|
-
:apikey_required => true
|
602
|
-
},
|
603
|
-
os_change: {
|
604
|
-
:method => :post,
|
605
|
-
:path => '/v1/server/os_change',
|
606
|
-
:params => %w(SUBID OSID),
|
607
|
-
:apikey_required => true
|
608
|
-
},
|
609
|
-
os_change_list: {
|
610
|
-
:method => :get,
|
611
|
-
:path => '/v1/server/os_change_list',
|
612
|
-
:params => %w(SUBID),
|
613
|
-
:apikey_required => true
|
614
|
-
},
|
615
|
-
private_network_disable: {
|
616
|
-
:method => :post,
|
617
|
-
:path => '/v1/server/private_network_disable',
|
618
|
-
:params => %w(SUBID NETWORKID),
|
619
|
-
:apikey_required => true
|
620
|
-
},
|
621
|
-
private_network_enable: {
|
622
|
-
:method => :post,
|
623
|
-
:path => '/v1/server/private_network_enable',
|
624
|
-
:params => %w(SUBID NETWORKID),
|
625
|
-
:apikey_required => true
|
626
|
-
},
|
627
|
-
private_networks: {
|
628
|
-
:method => :get,
|
629
|
-
:path => '/v1/server/private_networks',
|
630
|
-
:params => %w(SUBID),
|
631
|
-
:apikey_required => true
|
632
|
-
},
|
633
|
-
reboot: {
|
634
|
-
:method => :post,
|
635
|
-
:path => '/v1/server/reboot' 'SUBID',
|
636
|
-
:params => %w(SUBID),
|
637
|
-
:apikey_required => true
|
638
|
-
},
|
639
|
-
reinstall: {
|
640
|
-
:method => :post,
|
641
|
-
:path => '/v1/server/reinstall',
|
642
|
-
:params => %w(SUBID hostname),
|
643
|
-
:apikey_required => true
|
644
|
-
},
|
645
|
-
restore_backup: {
|
646
|
-
:method => :post,
|
647
|
-
:path => '/v1/server/restore_backup',
|
648
|
-
:params => %w(SUBID BACKUPID),
|
649
|
-
:apikey_required => true
|
650
|
-
},
|
651
|
-
restore_snapshot: {
|
652
|
-
:method => :post,
|
653
|
-
:path => '/v1/server/restore_snapshot',
|
654
|
-
:params => %w(SUBID SNAPSHOTID),
|
655
|
-
:apikey_required => true
|
656
|
-
},
|
657
|
-
reverse_default_ipv4: {
|
658
|
-
:method => :post,
|
659
|
-
:path => '/v1/server/reverse_default_ipv4',
|
660
|
-
:params => %w(SUBID ip),
|
661
|
-
:apikey_required => true
|
662
|
-
},
|
663
|
-
reverse_delete_ipv6: {
|
664
|
-
:method => :post,
|
665
|
-
:path => '/v1/server/reverse_delete_ipv6',
|
666
|
-
:params => %w(SUBID ip),
|
667
|
-
:apikey_required => true
|
668
|
-
},
|
669
|
-
reverse_list_ipv6: {
|
670
|
-
:method => :get,
|
671
|
-
:path => '/v1/server/reverse_list_ipv6',
|
672
|
-
:params => %w(SUBID),
|
673
|
-
:apikey_required => true
|
674
|
-
},
|
675
|
-
reverse_set_ipv4: {
|
676
|
-
:method => :post,
|
677
|
-
:path => '/v1/server/reverse_set_ipv4',
|
678
|
-
:params => %w(SUBID ip entry),
|
679
|
-
:apikey_required => true
|
680
|
-
},
|
681
|
-
reverse_set_ipv6: {
|
682
|
-
:method => :post,
|
683
|
-
:path => '/v1/server/reverse_set_ipv6',
|
684
|
-
:params => %w(SUBID ip entry),
|
685
|
-
:apikey_required => true
|
686
|
-
},
|
687
|
-
set_user_data: {
|
688
|
-
:method => :post,
|
689
|
-
:path => '/v1/server/set_user_data',
|
690
|
-
:params => %w(SUBID userdata),
|
691
|
-
:apikey_required => true
|
692
|
-
},
|
693
|
-
start: {
|
694
|
-
:method => :post,
|
695
|
-
:path => '/v1/server/start',
|
696
|
-
:params => %w(SUBID),
|
697
|
-
:apikey_required => true
|
698
|
-
},
|
699
|
-
tag_set: {
|
700
|
-
:method => :post,
|
701
|
-
:path => '/v1/server/tag_set',
|
702
|
-
:params => %w(SUBID tag),
|
703
|
-
:apikey_required => true
|
704
|
-
},
|
705
|
-
upgrade_plan: {
|
706
|
-
:method => :post,
|
707
|
-
:path => '/v1/server/upgrade_plan',
|
708
|
-
:params => %w(SUBID VPSPLANID),
|
709
|
-
:apikey_required => true
|
710
|
-
},
|
711
|
-
upgrade_plan_list: {
|
712
|
-
:method => :get,
|
713
|
-
:path => '/v1/server/upgrade_plan_list',
|
714
|
-
:params => %w(SUBID),
|
715
|
-
:apikey_required => true
|
716
|
-
}
|
717
|
-
},
|
718
|
-
# Snapshot
|
719
|
-
Snapshot: {
|
720
|
-
create: {
|
721
|
-
:method => :post,
|
722
|
-
:path => '/v1/snapshot/create',
|
723
|
-
:params => %w(SUBID),
|
724
|
-
:apikey_required => true
|
725
|
-
},
|
726
|
-
destroy: {
|
727
|
-
:method => :post,
|
728
|
-
:path => '/v1/snapshot/destroy',
|
729
|
-
:params => %w(SNAPSHOTID),
|
730
|
-
:apikey_required => true
|
731
|
-
},
|
732
|
-
list: {
|
733
|
-
:method => :get,
|
734
|
-
:path => '/v1/snapshot/list',
|
735
|
-
:apikey_required => true
|
736
|
-
}
|
737
|
-
},
|
738
|
-
# SSH Key
|
739
|
-
SSHKey: {
|
740
|
-
create: {
|
741
|
-
:method => :post,
|
742
|
-
:path => '/v1/sshkey/create',
|
743
|
-
:params => %w(name ssh_key),
|
744
|
-
:apikey_required => true
|
745
|
-
},
|
746
|
-
destroy: {
|
747
|
-
:method => :post,
|
748
|
-
:path => '/v1/sshkey/destroy',
|
749
|
-
:params => %w(SSHKEYID),
|
750
|
-
:apikey_required => true
|
751
|
-
},
|
752
|
-
list: {
|
753
|
-
:method => :get,
|
754
|
-
:path => '/v1/sshkey/list',
|
755
|
-
:apikey_required => true
|
756
|
-
},
|
757
|
-
update: {
|
758
|
-
:method => :post,
|
759
|
-
:path => '/v1/sshkey/update',
|
760
|
-
:params => %w(SSHKEYID name ssh_key),
|
761
|
-
:apikey_required => true
|
762
|
-
}
|
763
|
-
},
|
764
|
-
# Startup Script
|
765
|
-
StartupScript: {
|
766
|
-
create: {
|
767
|
-
:method => :post,
|
768
|
-
:path => '/v1/startupscript/create',
|
769
|
-
:params => %w(name script type),
|
770
|
-
:apikey_required => true
|
771
|
-
},
|
772
|
-
destroy: {
|
773
|
-
:method => :post,
|
774
|
-
:path => '/v1/startupscript/destroy',
|
775
|
-
:params => %w(SCRIPTID),
|
776
|
-
:apikey_required => true
|
777
|
-
},
|
778
|
-
list: {
|
779
|
-
:method => :get,
|
780
|
-
:path => '/v1/startupscript/list',
|
781
|
-
:apikey_required => true
|
782
|
-
},
|
783
|
-
update: {
|
784
|
-
:method => :post,
|
785
|
-
:path => '/v1/startupscript/update',
|
786
|
-
:params => %w(SCRIPTID name script),
|
787
|
-
:apikey_required => true
|
788
|
-
}
|
789
|
-
},
|
790
|
-
# User Management
|
791
|
-
User: {
|
792
|
-
create: {
|
793
|
-
:method => :post,
|
794
|
-
:path => '/v1/user/create',
|
795
|
-
:params => %w(email name password api_enabled acls),
|
796
|
-
:apikey_required => true
|
797
|
-
},
|
798
|
-
delete: {
|
799
|
-
:method => :post,
|
800
|
-
:path => '/v1/user/delete',
|
801
|
-
:params => %w(USERID),
|
802
|
-
:apikey_required => true
|
803
|
-
},
|
804
|
-
list: {
|
805
|
-
:method => :get,
|
806
|
-
:path => '/v1/user/list',
|
807
|
-
:apikey_required => true
|
808
|
-
},
|
809
|
-
update: {
|
810
|
-
:method => :post,
|
811
|
-
:path => '/v1/user/update',
|
812
|
-
:params => %w(USERID email name password api_enabled acls),
|
813
|
-
:apikey_required => true
|
814
|
-
}
|
815
|
-
}
|
816
|
-
}
|
817
|
-
|
818
|
-
DEFINITIONS.each do |resource_name, actions|
|
819
|
-
resource_class = Class.new(Object) do
|
820
|
-
actions.each do |action, config|
|
821
|
-
method = config.fetch(:method)
|
822
|
-
path = config.fetch(:path)
|
823
|
-
params = config.fetch(:params, nil)
|
824
|
-
apikey_required = config.fetch(:apikey_required, false)
|
825
|
-
|
826
|
-
define_singleton_method action do |*args|
|
827
|
-
headers = apikey_required ? {'API-Key' => Vultr::APIKey} : {}
|
828
|
-
body = nil
|
829
|
-
if method == :get
|
830
|
-
extra_params = Hash.new
|
831
|
-
hash = args[-1]
|
832
|
-
if hash.is_a?(Hash)
|
833
|
-
hash.each do |key, value|
|
834
|
-
extra_params[key] = value if params.include? key.to_s
|
835
|
-
end
|
836
|
-
end
|
837
|
-
url = Vultr.request.build_url(path, extra_params)
|
838
|
-
elsif method == :post
|
839
|
-
body = Hash.new
|
840
|
-
hash = args[-1]
|
841
|
-
if hash.is_a?(Hash)
|
842
|
-
hash.each do |key, value|
|
843
|
-
body[key] = value if params.include? key.to_s
|
844
|
-
end
|
845
|
-
end
|
846
|
-
url = Vultr.request.build_url(path)
|
847
|
-
end
|
848
|
-
|
849
|
-
resp = Vultr.request.run_request(method, url, body, headers)
|
850
|
-
{status: resp.status, result: resp.body}
|
851
|
-
end
|
852
|
-
end
|
853
|
-
end
|
854
|
-
|
855
|
-
Vultr.const_set(resource_name, resource_class)
|
856
|
-
end
|
857
|
-
|
858
|
-
def request=(request)
|
859
|
-
@request = request
|
860
|
-
end
|
861
|
-
|
862
|
-
def request
|
863
|
-
@request
|
864
|
-
end
|
865
|
-
|
866
|
-
def api_key=(api_key)
|
867
|
-
Vultr.const_set('APIKey', api_key)
|
868
|
-
setup_request!
|
869
|
-
|
870
|
-
Vultr::APIKey
|
871
|
-
end
|
872
|
-
|
873
|
-
def api_key
|
874
|
-
return Vultr::APIKey if Vultr::APIKey
|
875
|
-
'API Key is required'
|
876
|
-
end
|
877
|
-
|
878
|
-
private
|
879
|
-
|
880
|
-
def setup_request!
|
881
|
-
Vultr.request = Faraday.new do |faraday|
|
882
|
-
faraday.url_prefix = 'https://api.vultr.com'
|
883
|
-
faraday.request :url_encoded
|
884
|
-
faraday.response :json, :content_type => 'application/json'
|
885
|
-
faraday.adapter :net_http
|
886
|
-
end
|
887
|
-
end
|
1
|
+
require "faraday"
|
2
|
+
require "faraday_middleware"
|
3
|
+
require "vultr/version"
|
4
|
+
|
5
|
+
module Vultr
|
6
|
+
autoload :Client, "vultr/client"
|
7
|
+
autoload :Collection, "vultr/collection"
|
8
|
+
autoload :Error, "vultr/error"
|
9
|
+
autoload :Resource, "vultr/resource"
|
10
|
+
autoload :Object, "vultr/object"
|
11
|
+
|
12
|
+
# High-level categories of Vultr API calls
|
13
|
+
autoload :AccountResource, "vultr/resources/account"
|
14
|
+
autoload :ApplicationsResource, "vultr/resources/applications"
|
15
|
+
autoload :InstancesResource, "vultr/resources/instances"
|
16
|
+
autoload :BackupsResource, "vultr/resources/backups"
|
17
|
+
autoload :BareMetalResource, "vultr/resources/bare_metal"
|
18
|
+
autoload :BlockStorageResource, "vultr/resources/block_storage"
|
19
|
+
autoload :DnsResource, "vultr/resources/dns"
|
20
|
+
autoload :FirewallResource, "vultr/resources/firewall"
|
21
|
+
autoload :IsoResource, "vultr/resources/iso"
|
22
|
+
autoload :KubernetesResource, "vultr/resources/kubernetes"
|
23
|
+
autoload :LoadBalancersResource, "vultr/resources/load_balancers"
|
24
|
+
autoload :ObjectStorageResource, "vultr/resources/object_storage"
|
25
|
+
autoload :OperatingSystemsResource, "vultr/resources/operating_systems"
|
26
|
+
autoload :PlansResource, "vultr/resources/plans"
|
27
|
+
autoload :PrivateNetworksResource, "vultr/resources/private_networks"
|
28
|
+
autoload :RegionsResource, "vultr/resources/regions"
|
29
|
+
autoload :ReservedIpsResource, "vultr/resources/reserved_ips"
|
30
|
+
autoload :SnapshotsResource, "vultr/resources/snapshots"
|
31
|
+
autoload :SshKeysResource, "vultr/resources/ssh_keys"
|
32
|
+
autoload :StartupScriptsResource, "vultr/resources/startup_scripts"
|
33
|
+
autoload :UserResource, "vultr/resources/users"
|
34
|
+
|
35
|
+
# Classes used to return a nicer object wrapping the response data
|
36
|
+
autoload :Account, "vultr/objects/account"
|
37
|
+
autoload :Application, "vultr/objects/application"
|
38
|
+
autoload :Backup, "vultr/objects/backup"
|
39
|
+
autoload :BareMetal, "vultr/objects/bare_metal"
|
40
|
+
autoload :BlockStorage, "vultr/objects/block_storage"
|
41
|
+
autoload :Domain, "vultr/objects/domain"
|
42
|
+
autoload :FirewallGroup, "vultr/objects/firewall_group"
|
43
|
+
autoload :Instance, "vultr/objects/instance"
|
44
|
+
autoload :Iso, "vultr/objects/iso"
|
45
|
+
autoload :KubernetesCluster, "vultr/objects/kubernetes_cluster"
|
46
|
+
autoload :LoadBalancer, "vultr/objects/load_balancer"
|
47
|
+
autoload :ObjectStorage, "vultr/objects/object_storage"
|
48
|
+
autoload :OperatingSystem, "vultr/objects/operating_system"
|
49
|
+
autoload :Plan, "vultr/objects/plan"
|
50
|
+
autoload :PrivateNetwork, "vultr/objects/private_network"
|
51
|
+
autoload :Region, "vultr/objects/region"
|
52
|
+
autoload :ReservedIp, "vultr/objects/reserved_ip"
|
53
|
+
autoload :Snapshot, "vultr/objects/snapshot"
|
54
|
+
autoload :SshKey, "vultr/objects/ssh_key"
|
55
|
+
autoload :StartupScript, "vultr/objects/startup_script"
|
56
|
+
autoload :User, "vultr/objects/user"
|
888
57
|
end
|