vultr 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/lib/vultr/collection.rb +2 -1
- data/lib/vultr/version.rb +1 -1
- metadata +17 -183
- data/.github/workflows/ci.yml +0 -38
- data/.gitignore +0 -23
- data/.standard.yml +0 -1
- data/Appraisals +0 -8
- data/Gemfile +0 -8
- data/Rakefile +0 -14
- data/bin/console +0 -21
- data/bin/setup +0 -8
- data/bin/test +0 -6
- data/gemfiles/faraday_1.gemfile +0 -12
- data/gemfiles/faraday_1.gemfile.lock +0 -104
- data/gemfiles/faraday_2.gemfile +0 -11
- data/gemfiles/faraday_2.gemfile.lock +0 -87
- data/test/fixtures/account/info.json +0 -11
- data/test/fixtures/applications/list.json +0 -29
- data/test/fixtures/backups/list.json +0 -18
- data/test/fixtures/backups/retrieve.json +0 -9
- data/test/fixtures/bare_metals/bandwidth.json +0 -12
- data/test/fixtures/bare_metals/create.json +0 -26
- data/test/fixtures/bare_metals/list.json +0 -36
- data/test/fixtures/bare_metals/list_ipv4.json +0 -18
- data/test/fixtures/bare_metals/list_ipv6.json +0 -17
- data/test/fixtures/bare_metals/reinstall.json +0 -25
- data/test/fixtures/bare_metals/retrieve.json +0 -26
- data/test/fixtures/bare_metals/update.json +0 -26
- data/test/fixtures/bare_metals/upgrades.json +0 -47
- data/test/fixtures/bare_metals/user_data.json +0 -5
- data/test/fixtures/bare_metals/vnc.json +0 -5
- data/test/fixtures/block_storage/attach.json +0 -4
- data/test/fixtures/block_storage/create.json +0 -13
- data/test/fixtures/block_storage/detach.json +0 -4
- data/test/fixtures/block_storage/list.json +0 -22
- data/test/fixtures/block_storage/retrieve.json +0 -13
- data/test/fixtures/domains/create.json +0 -6
- data/test/fixtures/domains/dnssec.json +0 -7
- data/test/fixtures/domains/list.json +0 -15
- data/test/fixtures/domains/record.json +0 -10
- data/test/fixtures/domains/records.json +0 -19
- data/test/fixtures/domains/retrieve.json +0 -6
- data/test/fixtures/domains/soa.json +0 -6
- data/test/fixtures/firewall/create.json +0 -11
- data/test/fixtures/firewall/create_rule.json +0 -9
- data/test/fixtures/firewall/delete.json +0 -1
- data/test/fixtures/firewall/delete_rule.json +0 -1
- data/test/fixtures/firewall/list.json +0 -20
- data/test/fixtures/firewall/list_rules.json +0 -22
- data/test/fixtures/firewall/retrieve.json +0 -11
- data/test/fixtures/firewall/retrieve_rule.json +0 -13
- data/test/fixtures/firewall/update.json +0 -1
- data/test/fixtures/instances/attach_iso.json +0 -6
- data/test/fixtures/instances/attach_private_network.json +0 -1
- data/test/fixtures/instances/backup_schedule.json +0 -10
- data/test/fixtures/instances/bandwidth.json +0 -12
- data/test/fixtures/instances/create.json +0 -36
- data/test/fixtures/instances/create_ipv4_reverse.json +0 -1
- data/test/fixtures/instances/create_ipv6_reverse.json +0 -1
- data/test/fixtures/instances/delete.json +0 -1
- data/test/fixtures/instances/delete_ipv4.json +0 -1
- data/test/fixtures/instances/delete_ipv6.json +0 -1
- data/test/fixtures/instances/detach_iso.json +0 -5
- data/test/fixtures/instances/detach_private_network.json +0 -1
- data/test/fixtures/instances/halt.json +0 -1
- data/test/fixtures/instances/halt_instances.json +0 -1
- data/test/fixtures/instances/ipv4.json +0 -9
- data/test/fixtures/instances/ipv6_reverse.json +0 -15
- data/test/fixtures/instances/iso.json +0 -6
- data/test/fixtures/instances/list.json +0 -44
- data/test/fixtures/instances/list_ipv4.json +0 -32
- data/test/fixtures/instances/list_ipv6.json +0 -17
- data/test/fixtures/instances/list_private_networks.json +0 -16
- data/test/fixtures/instances/neighbors.json +0 -6
- data/test/fixtures/instances/reboot.json +0 -1
- data/test/fixtures/instances/reboot_instances.json +0 -1
- data/test/fixtures/instances/reinstall.json +0 -35
- data/test/fixtures/instances/restore.json +0 -7
- data/test/fixtures/instances/retrieve.json +0 -35
- data/test/fixtures/instances/set_backup_schedule.json +0 -1
- data/test/fixtures/instances/set_default_reverse_dns_entry.json +0 -1
- data/test/fixtures/instances/start.json +0 -1
- data/test/fixtures/instances/start_instances.json +0 -1
- data/test/fixtures/instances/update.json +0 -1
- data/test/fixtures/instances/upgrades.json +0 -55
- data/test/fixtures/instances/user_data.json +0 -5
- data/test/fixtures/isos/create.json +0 -8
- data/test/fixtures/isos/list.json +0 -20
- data/test/fixtures/isos/list_public.json +0 -17
- data/test/fixtures/isos/retrieve.json +0 -11
- data/test/fixtures/kubernetes/config.json +0 -3
- data/test/fixtures/kubernetes/create.json +0 -39
- data/test/fixtures/kubernetes/create_node_pool.json +0 -25
- data/test/fixtures/kubernetes/list.json +0 -85
- data/test/fixtures/kubernetes/list_node_pools.json +0 -56
- data/test/fixtures/kubernetes/list_resources.json +0 -26
- data/test/fixtures/kubernetes/retrieve.json +0 -39
- data/test/fixtures/kubernetes/retrieve_node_pool.json +0 -25
- data/test/fixtures/kubernetes/update_node_pool.json +0 -19
- data/test/fixtures/load_balancers/create.json +0 -48
- data/test/fixtures/load_balancers/create_forwarding_rule.json +0 -1
- data/test/fixtures/load_balancers/delete.json +0 -1
- data/test/fixtures/load_balancers/delete_forwarding_rule.json +0 -1
- data/test/fixtures/load_balancers/list.json +0 -57
- data/test/fixtures/load_balancers/list_firewall_rules.json +0 -17
- data/test/fixtures/load_balancers/list_forwarding_rules.json +0 -18
- data/test/fixtures/load_balancers/retrieve.json +0 -48
- data/test/fixtures/load_balancers/retrieve_firewall_rule.json +0 -8
- data/test/fixtures/load_balancers/retrieve_forwarding_rule.json +0 -9
- data/test/fixtures/load_balancers/update.json +0 -1
- data/test/fixtures/object_storage/create.json +0 -14
- data/test/fixtures/object_storage/delete.json +0 -1
- data/test/fixtures/object_storage/list.json +0 -22
- data/test/fixtures/object_storage/list_clusters.json +0 -17
- data/test/fixtures/object_storage/regenerate_keys.json +0 -7
- data/test/fixtures/object_storage/retrieve.json +0 -13
- data/test/fixtures/object_storage/update.json +0 -1
- data/test/fixtures/operating_systems/list.json +0 -17
- data/test/fixtures/plans/list.json +0 -22
- data/test/fixtures/plans/list_metal.json +0 -24
- data/test/fixtures/private_networks/create.json +0 -10
- data/test/fixtures/private_networks/delete.json +0 -1
- data/test/fixtures/private_networks/list.json +0 -19
- data/test/fixtures/private_networks/retrieve.json +0 -10
- data/test/fixtures/private_networks/update.json +0 -1
- data/test/fixtures/regions/list.json +0 -20
- data/test/fixtures/regions/list_availability.json +0 -24
- data/test/fixtures/reserved_ips/attach.json +0 -1
- data/test/fixtures/reserved_ips/convert.json +0 -11
- data/test/fixtures/reserved_ips/create.json +0 -11
- data/test/fixtures/reserved_ips/delete.json +0 -1
- data/test/fixtures/reserved_ips/detach.json +0 -1
- data/test/fixtures/reserved_ips/list.json +0 -29
- data/test/fixtures/reserved_ips/retrieve.json +0 -11
- data/test/fixtures/snapshots/create.json +0 -11
- data/test/fixtures/snapshots/create_from_url.json +0 -11
- data/test/fixtures/snapshots/delete.json +0 -1
- data/test/fixtures/snapshots/list.json +0 -20
- data/test/fixtures/snapshots/retrieve.json +0 -11
- data/test/fixtures/snapshots/update.json +0 -1
- data/test/fixtures/ssh_keys/create.json +0 -8
- data/test/fixtures/ssh_keys/delete.json +0 -1
- data/test/fixtures/ssh_keys/list.json +0 -17
- data/test/fixtures/ssh_keys/retrieve.json +0 -8
- data/test/fixtures/ssh_keys/update.json +0 -1
- data/test/fixtures/startup_scripts/create.json +0 -10
- data/test/fixtures/startup_scripts/delete.json +0 -1
- data/test/fixtures/startup_scripts/list.json +0 -18
- data/test/fixtures/startup_scripts/retrieve.json +0 -10
- data/test/fixtures/startup_scripts/update.json +0 -1
- data/test/fixtures/users/create.json +0 -9
- data/test/fixtures/users/delete.json +0 -1
- data/test/fixtures/users/list.json +0 -29
- data/test/fixtures/users/retrieve.json +0 -20
- data/test/fixtures/users/update.json +0 -1
- data/test/test_helper.rb +0 -19
- data/test/vultr/client_test.rb +0 -8
- data/test/vultr/object_test.rb +0 -21
- data/test/vultr/resources/account_test.rb +0 -12
- data/test/vultr/resources/applications_test.rb +0 -15
- data/test/vultr/resources/backups_test.rb +0 -24
- data/test/vultr/resources/bare_metal_test.rb +0 -267
- data/test/vultr/resources/block_storage_test.rb +0 -85
- data/test/vultr/resources/dns_test.rb +0 -134
- data/test/vultr/resources/firewall_test.rb +0 -88
- data/test/vultr/resources/instances_test.rb +0 -325
- data/test/vultr/resources/iso_test.rb +0 -58
- data/test/vultr/resources/kubernetes_test.rb +0 -185
- data/test/vultr/resources/load_balancers_test.rb +0 -110
- data/test/vultr/resources/object_storage_test.rb +0 -71
- data/test/vultr/resources/operating_systems_test.rb +0 -15
- data/test/vultr/resources/plans_test.rb +0 -25
- data/test/vultr/resources/private_networks_test.rb +0 -50
- data/test/vultr/resources/regions_test.rb +0 -26
- data/test/vultr/resources/reserved_ips_test.rb +0 -67
- data/test/vultr/resources/snapshots_test.rb +0 -60
- data/test/vultr/resources/ssh_keys_test.rb +0 -50
- data/test/vultr/resources/startup_scripts_test.rb +0 -50
- data/test/vultr/resources/users_test.rb +0 -50
- data/vultr.gemspec +0 -24
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "test_helper"
|
|
4
|
-
|
|
5
|
-
class BlockStorageResourceTest < Minitest::Test
|
|
6
|
-
def test_list
|
|
7
|
-
stub = stub_request("blocks", response: stub_response(fixture: "block_storage/list"))
|
|
8
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
9
|
-
blocks = client.block_storage.list
|
|
10
|
-
|
|
11
|
-
assert_equal Vultr::Collection, blocks.class
|
|
12
|
-
assert_equal Vultr::BlockStorage, blocks.data.first.class
|
|
13
|
-
assert_equal 1, blocks.total
|
|
14
|
-
assert_equal "next", blocks.next_cursor
|
|
15
|
-
assert_equal "prev", blocks.prev_cursor
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def test_create
|
|
19
|
-
body = {region: "ewr", size_gb: 50, label: "Example Block Storage"}
|
|
20
|
-
stub = stub_request("blocks", method: :post, body: body, response: stub_response(fixture: "block_storage/create", status: 202))
|
|
21
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
22
|
-
blocks = client.block_storage.create(**body)
|
|
23
|
-
|
|
24
|
-
assert_equal blocks.id, "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
25
|
-
assert_equal blocks.date_created, Time.parse("2020-10-10T01:56:20+00:00")
|
|
26
|
-
assert_equal blocks.cost, 5
|
|
27
|
-
assert_equal blocks.status, "active"
|
|
28
|
-
assert_equal blocks.size_gb, 50
|
|
29
|
-
assert_equal blocks.region, "ewr"
|
|
30
|
-
assert_equal blocks.attached_to_instance, "742c9913-d088-4d67-bc61-5a10e922fbd1"
|
|
31
|
-
assert_equal blocks.label, "Example Block Storage"
|
|
32
|
-
assert_equal blocks.mount_id, "ewr-example112233"
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def test_retrieve
|
|
36
|
-
block_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
37
|
-
body = {region: "ewr", size_gb: 50, label: "Example Block Storage"}
|
|
38
|
-
stub = stub_request("blocks/#{block_id}", body: body, response: stub_response(fixture: "block_storage/retrieve"))
|
|
39
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
40
|
-
blocks = client.block_storage.retrieve(block_id: block_id)
|
|
41
|
-
|
|
42
|
-
assert_equal blocks.id, "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
43
|
-
assert_equal blocks.date_created, Time.parse("2020-10-10T01:56:20+00:00")
|
|
44
|
-
assert_equal blocks.cost, 5
|
|
45
|
-
assert_equal blocks.status, "active"
|
|
46
|
-
assert_equal blocks.size_gb, 50
|
|
47
|
-
assert_equal blocks.region, "ewr"
|
|
48
|
-
assert_equal blocks.attached_to_instance, "742c9913-d088-4d67-bc61-5a10e922fbd1"
|
|
49
|
-
assert_equal blocks.label, "Example Block Storage"
|
|
50
|
-
assert_equal blocks.mount_id, "ewr-example112233"
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def test_update
|
|
54
|
-
block_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
55
|
-
body = {size_gb: 50, label: "Example Block Storage"}
|
|
56
|
-
stub = stub_request("blocks/#{block_id}", method: :patch, body: body, response: {})
|
|
57
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
58
|
-
|
|
59
|
-
assert client.block_storage.update(block_id: block_id, **body)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def test_delete
|
|
63
|
-
block_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
64
|
-
stub = stub_request("blocks/#{block_id}", method: :delete, response: {})
|
|
65
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
66
|
-
|
|
67
|
-
assert client.block_storage.delete(block_id: block_id)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def test_attach
|
|
71
|
-
block_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
72
|
-
stub = stub_request("blocks/#{block_id}/attach", method: :post, response: stub_response(fixture: "block_storage/attach"))
|
|
73
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
74
|
-
|
|
75
|
-
assert client.block_storage.attach(block_id: block_id)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def test_detach
|
|
79
|
-
block_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
80
|
-
stub = stub_request("blocks/#{block_id}/detach", method: :post, response: stub_response(fixture: "block_storage/detach"))
|
|
81
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
82
|
-
|
|
83
|
-
assert client.block_storage.detach(block_id: block_id)
|
|
84
|
-
end
|
|
85
|
-
end
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "test_helper"
|
|
4
|
-
|
|
5
|
-
class DnsResourceTest < Minitest::Test
|
|
6
|
-
def test_list
|
|
7
|
-
stub = stub_request("domains", response: stub_response(fixture: "domains/list"))
|
|
8
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
9
|
-
dns = client.dns.list
|
|
10
|
-
|
|
11
|
-
assert_equal Vultr::Collection, dns.class
|
|
12
|
-
assert_equal Vultr::Domain, dns.data.first.class
|
|
13
|
-
assert_equal 1, dns.total
|
|
14
|
-
assert_equal "next", dns.next_cursor
|
|
15
|
-
assert_equal "prev", dns.prev_cursor
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def test_create
|
|
19
|
-
body = {domain: "example.com", ip: "192.0.2.123", dns_sec: :enabled}
|
|
20
|
-
stub = stub_request("domains", method: :post, body: body, response: stub_response(fixture: "domains/create", status: 201))
|
|
21
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
22
|
-
dns = client.dns.create(**body)
|
|
23
|
-
|
|
24
|
-
assert_equal "example.com", dns.domain
|
|
25
|
-
assert_equal Time.parse("2020-10-10T01:56:20+00:00"), dns.date_created
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def test_retrieve
|
|
29
|
-
dns_domain = "example.com"
|
|
30
|
-
stub = stub_request("domains/#{dns_domain}", response: stub_response(fixture: "domains/retrieve"))
|
|
31
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
32
|
-
dns = client.dns.retrieve(dns_domain: dns_domain)
|
|
33
|
-
|
|
34
|
-
assert_equal "example.com", dns.domain
|
|
35
|
-
assert_equal Time.parse("2020-10-10T01:56:20+00:00"), dns.date_created
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def test_update
|
|
39
|
-
dns_domain = "example.com"
|
|
40
|
-
body = {dns_sec: "enabled"}
|
|
41
|
-
stub = stub_request("domains/#{dns_domain}", method: :put, body: body, response: {})
|
|
42
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
43
|
-
|
|
44
|
-
assert client.dns.update(dns_domain: dns_domain, **body)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def test_delete
|
|
48
|
-
dns_domain = "example.com"
|
|
49
|
-
stub = stub_request("domains/#{dns_domain}", method: :delete, response: {})
|
|
50
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
51
|
-
|
|
52
|
-
assert client.dns.delete(dns_domain: dns_domain)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def test_soa
|
|
56
|
-
dns_domain = "example.com"
|
|
57
|
-
stub = stub_request("domains/#{dns_domain}/soa", response: stub_response(fixture: "domains/soa"))
|
|
58
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
59
|
-
soa = client.dns.soa(dns_domain: dns_domain)
|
|
60
|
-
|
|
61
|
-
assert_equal "ns1.vultr.com", soa.nsprimary
|
|
62
|
-
assert_equal "admin@example.com", soa.email
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def test_update_soa
|
|
66
|
-
dns_domain = "example.com"
|
|
67
|
-
body = {nsprimary: "ns1.vultr.com", email: "admin@example.com"}
|
|
68
|
-
stub = stub_request("domains/#{dns_domain}/soa", method: :patch, body: body, response: {})
|
|
69
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
70
|
-
|
|
71
|
-
assert client.dns.update_soa(dns_domain: dns_domain, **body)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def test_dnssec
|
|
75
|
-
dns_domain = "example.com"
|
|
76
|
-
stub = stub_request("domains/#{dns_domain}/dnssec", response: stub_response(fixture: "domains/dnssec"))
|
|
77
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
78
|
-
assert client.dns.dnssec(dns_domain: dns_domain)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def test_list_records
|
|
82
|
-
dns_domain = "example.com"
|
|
83
|
-
stub = stub_request("domains/#{dns_domain}/records", response: stub_response(fixture: "domains/records"))
|
|
84
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
85
|
-
dns = client.dns.list_records(dns_domain: dns_domain)
|
|
86
|
-
|
|
87
|
-
assert_equal Vultr::Collection, dns.class
|
|
88
|
-
assert_equal Vultr::Object, dns.data.first.class
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def test_create_record
|
|
92
|
-
dns_domain = "example.com"
|
|
93
|
-
body = {name: "www", type: "A", data: "192.0.2.123", ttl: 300, priority: 0}
|
|
94
|
-
stub = stub_request("domains/#{dns_domain}/records", method: :post, body: body, response: stub_response(fixture: "domains/record", status: 201))
|
|
95
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
96
|
-
dns = client.dns.create_record(dns_domain: dns_domain, **body)
|
|
97
|
-
|
|
98
|
-
assert dns.id
|
|
99
|
-
assert "www", dns.name
|
|
100
|
-
assert "A", dns.type
|
|
101
|
-
assert "192.0.2.123", dns.data
|
|
102
|
-
assert 300, dns.ttl
|
|
103
|
-
assert 0, dns.priority
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def test_retrieve_record
|
|
107
|
-
dns_domain = "example.com"
|
|
108
|
-
record_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
109
|
-
stub = stub_request("domains/#{dns_domain}/records/#{record_id}", response: stub_response(fixture: "domains/record"))
|
|
110
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
111
|
-
dns = client.dns.retrieve_record(dns_domain: dns_domain, record_id: record_id)
|
|
112
|
-
|
|
113
|
-
assert_equal record_id, dns.id
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def test_update_record
|
|
117
|
-
dns_domain = "example.com"
|
|
118
|
-
record_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
119
|
-
body = {name: "CNAME", data: "foo.example.com", ttl: 300, priority: 0}
|
|
120
|
-
stub = stub_request("domains/#{dns_domain}/records/#{record_id}", method: :patch, body: body, response: {})
|
|
121
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
122
|
-
|
|
123
|
-
assert client.dns.update_record(dns_domain: dns_domain, record_id: record_id, **body)
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def test_delete_record
|
|
127
|
-
dns_domain = "example.com"
|
|
128
|
-
record_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
129
|
-
stub = stub_request("domains/#{dns_domain}/records/#{record_id}", method: :delete, response: {})
|
|
130
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
131
|
-
|
|
132
|
-
assert client.dns.delete_record(dns_domain: dns_domain, record_id: record_id)
|
|
133
|
-
end
|
|
134
|
-
end
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "test_helper"
|
|
4
|
-
|
|
5
|
-
class FirewallResourceTest < Minitest::Test
|
|
6
|
-
def test_list
|
|
7
|
-
stub = stub_request("firewalls", response: stub_response(fixture: "firewall/list"))
|
|
8
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
9
|
-
firewall_group = client.firewall.list
|
|
10
|
-
|
|
11
|
-
assert_equal Vultr::Collection, firewall_group.class
|
|
12
|
-
assert_equal Vultr::FirewallGroup, firewall_group.data.first.class
|
|
13
|
-
assert_equal 1, firewall_group.total
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def test_create
|
|
17
|
-
body = {description: "Example Firewall Group"}
|
|
18
|
-
stub = stub_request("firewalls", method: :post, body: body, response: stub_response(fixture: "firewall/create"))
|
|
19
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
20
|
-
firewall_group = client.firewall.create(**body)
|
|
21
|
-
|
|
22
|
-
assert_equal Vultr::FirewallGroup, firewall_group.class
|
|
23
|
-
assert_equal "Example Firewall Group", firewall_group.description
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def test_retrieve
|
|
27
|
-
id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
28
|
-
stub = stub_request("firewalls/#{id}", response: stub_response(fixture: "firewall/retrieve"))
|
|
29
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
30
|
-
firewall_group = client.firewall.retrieve(firewall_group_id: id)
|
|
31
|
-
|
|
32
|
-
assert_equal Vultr::FirewallGroup, firewall_group.class
|
|
33
|
-
assert_equal "Example Firewall Group", firewall_group.description
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def test_update
|
|
37
|
-
id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
38
|
-
body = {description: "Example Firewall Group"}
|
|
39
|
-
stub = stub_request("firewalls/#{id}", method: :put, body: body, response: stub_response(fixture: "firewall/update"))
|
|
40
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
41
|
-
assert client.firewall.update(firewall_group_id: id, **body)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def test_delete
|
|
45
|
-
id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
46
|
-
stub = stub_request("firewalls/#{id}", method: :delete, response: stub_response(fixture: "firewall/delete"))
|
|
47
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
48
|
-
assert client.firewall.delete(firewall_group_id: id)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def test_list_rules
|
|
52
|
-
id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
53
|
-
stub = stub_request("firewalls/#{id}/rules", response: stub_response(fixture: "firewall/list_rules"))
|
|
54
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
55
|
-
rules = client.firewall.list_rules(firewall_group_id: id)
|
|
56
|
-
|
|
57
|
-
assert Vultr::Collection, rules.class
|
|
58
|
-
assert Vultr::Object, rules.data.first.class
|
|
59
|
-
assert 1, rules.total
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def test_create_rule
|
|
63
|
-
id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
64
|
-
body = {ip_type: "v4", protocol: "tcp", subnet: "192.0.2.0", subnet_size: 24}
|
|
65
|
-
stub = stub_request("firewalls/#{id}/rules", method: :post, body: body, response: stub_response(fixture: "firewall/create_rule"))
|
|
66
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
67
|
-
assert client.firewall.create_rule(firewall_group_id: id, **body)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def test_retrieve_rule
|
|
71
|
-
firewall_id = "id"
|
|
72
|
-
rule_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
73
|
-
stub = stub_request("firewalls/#{firewall_id}/rules/#{rule_id}", response: stub_response(fixture: "firewall/retrieve_rule"))
|
|
74
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
75
|
-
rule = client.firewall.retrieve_rule(firewall_group_id: firewall_id, firewall_rule_id: rule_id)
|
|
76
|
-
|
|
77
|
-
assert Vultr::Object, rule.class
|
|
78
|
-
assert "tcp", rule.protocol
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def test_delete_forwarding_rule
|
|
82
|
-
firewall_id = "id"
|
|
83
|
-
rule_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
84
|
-
stub = stub_request("firewalls/#{firewall_id}/rules/#{rule_id}", method: :delete, response: stub_response(fixture: "firewall/delete_rule"))
|
|
85
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
86
|
-
assert client.firewall.delete_rule(firewall_group_id: firewall_id, firewall_rule_id: rule_id)
|
|
87
|
-
end
|
|
88
|
-
end
|
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "test_helper"
|
|
4
|
-
|
|
5
|
-
class InstancesResourceTest < Minitest::Test
|
|
6
|
-
def test_list
|
|
7
|
-
stub = stub_request("instances", response: stub_response(fixture: "instances/list", status: 200))
|
|
8
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
9
|
-
instances = client.instances.list
|
|
10
|
-
|
|
11
|
-
assert_equal Vultr::Collection, instances.class
|
|
12
|
-
assert_equal Vultr::Instance, instances.data.first.class
|
|
13
|
-
assert_equal 3, instances.total
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def test_create
|
|
17
|
-
body = {region: "ewr", plan: "vc2-6c-16gb", label: "Example Instance", os_id: 215, user_data: "QmFzZTY0IEV4YW1wbGUgRGF0YQ==", backups: "enabled"}
|
|
18
|
-
stub = stub_request("instances", method: :post, body: body, response: stub_response(fixture: "instances/create", status: 202))
|
|
19
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
20
|
-
instance = client.instances.create(**body)
|
|
21
|
-
|
|
22
|
-
assert_equal Vultr::Instance, instance.class
|
|
23
|
-
assert_equal "Example Instance", instance.label
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def test_retrieve
|
|
27
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
28
|
-
stub = stub_request("instances/#{instance_id}", response: stub_response(fixture: "instances/retrieve"))
|
|
29
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
30
|
-
instance = client.instances.retrieve(instance_id: instance_id)
|
|
31
|
-
|
|
32
|
-
assert_equal Vultr::Instance, instance.class
|
|
33
|
-
assert_equal "Example Instance", instance.label
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def test_update
|
|
37
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
38
|
-
body = {label: "Example Instance", tag: "Example Tag", plan: "vc2-24c-97gb"}
|
|
39
|
-
stub = stub_request("instances/#{instance_id}", method: :patch, body: body, response: stub_response(fixture: "instances/update", status: 202))
|
|
40
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
41
|
-
assert client.instances.update(instance_id: instance_id, **body)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def test_delete
|
|
45
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
46
|
-
stub = stub_request("instances/#{instance_id}", method: :delete, response: stub_response(fixture: "instances/delete", status: 204))
|
|
47
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
48
|
-
assert client.instances.delete(instance_id: instance_id)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def test_start
|
|
52
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
53
|
-
stub = stub_request("instances/#{instance_id}/start", method: :post, response: stub_response(fixture: "instances/start", status: 204))
|
|
54
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
55
|
-
assert client.instances.start(instance_id: instance_id)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def test_reboot
|
|
59
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
60
|
-
stub = stub_request("instances/#{instance_id}/reboot", method: :post, response: stub_response(fixture: "instances/reboot", status: 204))
|
|
61
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
62
|
-
assert client.instances.reboot(instance_id: instance_id)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def test_reinstall
|
|
66
|
-
body = {hostname: "Example Instance"}
|
|
67
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
68
|
-
stub = stub_request("instances/#{instance_id}/reinstall", method: :post, body: body, response: stub_response(fixture: "instances/reinstall", status: 204))
|
|
69
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
70
|
-
instance = client.instances.reinstall(instance_id: instance_id, **body)
|
|
71
|
-
|
|
72
|
-
assert_equal Vultr::Instance, instance.class
|
|
73
|
-
assert_equal "Example Instance", instance.label
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def test_restore
|
|
77
|
-
body = {backup_id: "cb676a46-66fd-4dfb-b839-443f2e6c0b60"}
|
|
78
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
79
|
-
stub = stub_request("instances/#{instance_id}/restore", method: :post, body: body, response: stub_response(fixture: "instances/restore", status: 202))
|
|
80
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
81
|
-
instance = client.instances.restore(instance_id: instance_id, **body)
|
|
82
|
-
|
|
83
|
-
assert_equal Vultr::Object, instance.class
|
|
84
|
-
assert_equal "backup_id", instance.restore_type
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def test_halt
|
|
88
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
89
|
-
stub = stub_request("instances/#{instance_id}/halt", method: :post, response: stub_response(fixture: "instances/halt", status: 204))
|
|
90
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
91
|
-
assert client.instances.halt(instance_id: instance_id)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def test_bandwidth
|
|
95
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
96
|
-
stub = stub_request("instances/#{instance_id}/bandwidth", response: stub_response(fixture: "instances/bandwidth"))
|
|
97
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
98
|
-
instance = client.instances.bandwidth(instance_id: instance_id)
|
|
99
|
-
|
|
100
|
-
assert_equal Vultr::Object, instance.class
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def test_neighbors
|
|
104
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
105
|
-
stub = stub_request("instances/#{instance_id}/neighbors", response: stub_response(fixture: "instances/neighbors"))
|
|
106
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
107
|
-
instance = client.instances.neighbors(instance_id: instance_id)
|
|
108
|
-
|
|
109
|
-
assert_equal Array, instance.class
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def test_user_data
|
|
113
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
114
|
-
stub = stub_request("instances/#{instance_id}/user-data", response: stub_response(fixture: "instances/user_data"))
|
|
115
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
116
|
-
instance = client.instances.user_data(instance_id: instance_id)
|
|
117
|
-
|
|
118
|
-
assert_equal Vultr::Object, instance.class
|
|
119
|
-
assert_equal "QmFzZTY0IEV4YW1wbGUgRGF0YQ==", instance.data
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def test_upgrades
|
|
123
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
124
|
-
stub = stub_request("instances/#{instance_id}/upgrades", response: stub_response(fixture: "instances/upgrades"))
|
|
125
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
126
|
-
instance = client.instances.upgrades(instance_id: instance_id)
|
|
127
|
-
|
|
128
|
-
assert_equal Vultr::Object, instance.class
|
|
129
|
-
assert_equal "Example CentOS 6 x64", instance.os.first["name"]
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
def test_list_ipv4
|
|
133
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
134
|
-
stub = stub_request("instances/#{instance_id}/ipv4", response: stub_response(fixture: "instances/list_ipv4"))
|
|
135
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
136
|
-
instance = client.instances.list_ipv4(instance_id: instance_id)
|
|
137
|
-
|
|
138
|
-
assert_equal Vultr::Collection, instance.class
|
|
139
|
-
assert_equal 3, instance.total
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def test_create_ipv4
|
|
143
|
-
body = {reboot: true}
|
|
144
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
145
|
-
stub = stub_request("instances/#{instance_id}/ipv4", method: :post, body: body, response: stub_response(fixture: "instances/ipv4", status: 202))
|
|
146
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
147
|
-
instance = client.instances.create_ipv4(instance_id: instance_id, **body)
|
|
148
|
-
|
|
149
|
-
assert_equal Vultr::Object, instance.class
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def test_delete_ipv4
|
|
153
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
154
|
-
ipv4_id = "192.0.2.123"
|
|
155
|
-
stub = stub_request("instances/#{instance_id}/ipv4/#{ipv4_id}", method: :delete, response: stub_response(fixture: "instances/delete_ipv4", status: 204))
|
|
156
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
157
|
-
assert client.instances.delete_ipv4(instance_id: instance_id, ipv4: ipv4_id)
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
def test_create_ipv4_reverse
|
|
161
|
-
body = {ip: "192.0.2.123", reverse: "foo.example.com"}
|
|
162
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
163
|
-
stub = stub_request("instances/#{instance_id}/ipv4/reverse", method: :post, body: body, response: stub_response(fixture: "instances/create_ipv4_reverse", status: 202))
|
|
164
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
165
|
-
assert client.instances.create_ipv4_reverse(instance_id: instance_id, **body)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
def test_set_default_reverse_dns_entry
|
|
169
|
-
body = {ip: "192.0.2.123"}
|
|
170
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
171
|
-
stub = stub_request("instances/#{instance_id}/ipv4/reverse/default", method: :post, body: body, response: stub_response(fixture: "instances/set_default_reverse_dns_entry"))
|
|
172
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
173
|
-
assert client.instances.set_default_reverse_dns_entry(instance_id: instance_id, **body)
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
def test_list_ipv6
|
|
177
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
178
|
-
stub = stub_request("instances/#{instance_id}/ipv6", response: stub_response(fixture: "instances/list_ipv6"))
|
|
179
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
180
|
-
instance = client.instances.list_ipv6(instance_id: instance_id)
|
|
181
|
-
|
|
182
|
-
assert_equal Vultr::Collection, instance.class
|
|
183
|
-
assert_equal 1, instance.total
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
def test_ipv6_reverse
|
|
187
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
188
|
-
stub = stub_request("instances/#{instance_id}/ipv6/reverse", response: stub_response(fixture: "instances/ipv6_reverse"))
|
|
189
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
190
|
-
instance = client.instances.ipv6_reverse(instance_id: instance_id)
|
|
191
|
-
|
|
192
|
-
assert_equal Vultr::Collection, instance.class
|
|
193
|
-
assert_equal 1, instance.total
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
def test_create_ipv6_reverse
|
|
197
|
-
body = {ip: "2001:0db8:0005:6bb0:5400:2ff0:fee5:0002", reverse: "foo.example.com"}
|
|
198
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
199
|
-
stub = stub_request("instances/#{instance_id}/ipv6/reverse", method: :post, body: body, response: stub_response(fixture: "instances/create_ipv6_reverse", status: 202))
|
|
200
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
201
|
-
assert client.instances.create_ipv6_reverse(instance_id: instance_id, **body)
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
def test_delete_ipv6_reverse
|
|
205
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
206
|
-
ipv6_id = "2001:0db8:0005:6bb0:5400:2ff0:fee5:0002"
|
|
207
|
-
stub = stub_request("instances/#{instance_id}/ipv6/reverse/#{ipv6_id}", method: :delete, response: stub_response(fixture: "instances/delete_ipv6", status: 204))
|
|
208
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
209
|
-
assert client.instances.delete_ipv6_reverse(instance_id: instance_id, ipv6: ipv6_id)
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
def test_list_private_networks
|
|
213
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
214
|
-
stub = stub_request("instances/#{instance_id}/private-networks", response: stub_response(fixture: "instances/list_private_networks"))
|
|
215
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
216
|
-
instance = client.instances.list_private_networks(instance_id: instance_id)
|
|
217
|
-
|
|
218
|
-
assert_equal Vultr::Collection, instance.class
|
|
219
|
-
assert_equal 1, instance.total
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
def test_attach_private_network
|
|
223
|
-
body = {network_id: "cb676a46-66fd-4dfb-b839-443f2e6c0b60"}
|
|
224
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
225
|
-
stub = stub_request("instances/#{instance_id}/private-networks/attach", method: :post, body: body, response: stub_response(fixture: "instances/attach_private_network"))
|
|
226
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
227
|
-
assert client.instances.attach_private_network(instance_id: instance_id, **body)
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
def test_detach_private_network
|
|
231
|
-
body = {network_id: "cb676a46-66fd-4dfb-b839-443f2e6c0b60"}
|
|
232
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
233
|
-
stub = stub_request("instances/#{instance_id}/private-networks/detach", method: :post, body: body, response: stub_response(fixture: "instances/detach_private_network"))
|
|
234
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
235
|
-
assert client.instances.detach_private_network(instance_id: instance_id, **body)
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
def test_iso
|
|
239
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
240
|
-
stub = stub_request("instances/#{instance_id}/iso", response: stub_response(fixture: "instances/iso"))
|
|
241
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
242
|
-
instance = client.instances.iso(instance_id: instance_id)
|
|
243
|
-
|
|
244
|
-
assert_equal Vultr::Object, instance.class
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
def test_attach_iso
|
|
248
|
-
body = {iso_id: "cb676a46-66fd-4dfb-b839-443f2e6c0b60"}
|
|
249
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
250
|
-
stub = stub_request("instances/#{instance_id}/iso/attach", method: :post, body: body, response: stub_response(fixture: "instances/attach_iso", status: 204))
|
|
251
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
252
|
-
instance = client.instances.attach_iso(instance_id: instance_id, iso_id: body[:iso_id])
|
|
253
|
-
|
|
254
|
-
assert_equal Vultr::Object, instance.class
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
def test_detach_iso
|
|
258
|
-
body = {iso_id: "cb676a46-66fd-4dfb-b839-443f2e6c0b60"}
|
|
259
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
260
|
-
stub = stub_request("instances/#{instance_id}/iso/detach", method: :post, body: body, response: stub_response(fixture: "instances/detach_iso"))
|
|
261
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
262
|
-
instance = client.instances.detach_iso(instance_id: instance_id, iso_id: body[:iso_id])
|
|
263
|
-
|
|
264
|
-
assert_equal Vultr::Object, instance.class
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
def test_backup_schedule
|
|
268
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
269
|
-
stub = stub_request("instances/#{instance_id}/backup-schedule", response: stub_response(fixture: "instances/backup_schedule"))
|
|
270
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
271
|
-
instance = client.instances.backup_schedule(instance_id: instance_id)
|
|
272
|
-
|
|
273
|
-
assert_equal Vultr::Object, instance.class
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
def test_set_backup_schedule
|
|
277
|
-
body = {type: "daily", hour: 10, dow: 1, dom: 1}
|
|
278
|
-
instance_id = "cb676a46-66fd-4dfb-b839-443f2e6c0b60"
|
|
279
|
-
stub = stub_request("instances/#{instance_id}/backup-schedule", method: :post, body: body, response: stub_response(fixture: "instances/set_backup_schedule"))
|
|
280
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
281
|
-
assert client.instances.set_backup_schedule(instance_id: instance_id, **body)
|
|
282
|
-
end
|
|
283
|
-
|
|
284
|
-
def test_halt_instances
|
|
285
|
-
body = {
|
|
286
|
-
instance_ids: [
|
|
287
|
-
"cb676a46-66fd-4dfb-b839-443f2e6c0b60",
|
|
288
|
-
"1d651bd2-b93c-4bb6-8b91-0546fd765f15",
|
|
289
|
-
"c2790719-278d-474c-8dff-cb35d6e5503f"
|
|
290
|
-
]
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
stub = stub_request("instances/halt", method: :post, body: body, response: stub_response(fixture: "instances/halt_instances"))
|
|
294
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
295
|
-
assert client.instances.halt_instances(instance_ids: body[:instance_ids], **body)
|
|
296
|
-
end
|
|
297
|
-
|
|
298
|
-
def test_reboot_instances
|
|
299
|
-
body = {
|
|
300
|
-
instance_ids: [
|
|
301
|
-
"cb676a46-66fd-4dfb-b839-443f2e6c0b60",
|
|
302
|
-
"1d651bd2-b93c-4bb6-8b91-0546fd765f15",
|
|
303
|
-
"c2790719-278d-474c-8dff-cb35d6e5503f"
|
|
304
|
-
]
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
stub = stub_request("instances/reboot", method: :post, body: body, response: stub_response(fixture: "instances/reboot_instances"))
|
|
308
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
309
|
-
assert client.instances.reboot_instances(instance_ids: body[:instance_ids], **body)
|
|
310
|
-
end
|
|
311
|
-
|
|
312
|
-
def test_start_instances
|
|
313
|
-
body = {
|
|
314
|
-
instance_ids: [
|
|
315
|
-
"cb676a46-66fd-4dfb-b839-443f2e6c0b60",
|
|
316
|
-
"1d651bd2-b93c-4bb6-8b91-0546fd765f15",
|
|
317
|
-
"c2790719-278d-474c-8dff-cb35d6e5503f"
|
|
318
|
-
]
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
stub = stub_request("instances/start", method: :post, body: body, response: stub_response(fixture: "instances/start_instances"))
|
|
322
|
-
client = Vultr::Client.new(api_key: "fake", adapter: :test, stubs: stub)
|
|
323
|
-
assert client.instances.start_instances(instance_ids: body[:instance_ids], **body)
|
|
324
|
-
end
|
|
325
|
-
end
|