fog-joyent 0.0.1

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.
Files changed (110) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rubocop.yml +20 -0
  4. data/.rubocop_todo.yml +436 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +26 -0
  8. data/CONTRIBUTING.md +18 -0
  9. data/CONTRIBUTORS.md +17 -0
  10. data/Gemfile +4 -0
  11. data/LICENSE.md +10 -0
  12. data/README.md +29 -0
  13. data/Rakefile +12 -0
  14. data/fog-joyent.gemspec +29 -0
  15. data/lib/fog/bin/joyent.rb +33 -0
  16. data/lib/fog/joyent.rb +16 -0
  17. data/lib/fog/joyent/analytics.rb +310 -0
  18. data/lib/fog/joyent/compute.rb +272 -0
  19. data/lib/fog/joyent/core.rb +10 -0
  20. data/lib/fog/joyent/errors.rb +91 -0
  21. data/lib/fog/joyent/models/analytics/field.rb +13 -0
  22. data/lib/fog/joyent/models/analytics/fields.rb +24 -0
  23. data/lib/fog/joyent/models/analytics/instrumentation.rb +82 -0
  24. data/lib/fog/joyent/models/analytics/instrumentations.rb +23 -0
  25. data/lib/fog/joyent/models/analytics/joyent_module.rb +13 -0
  26. data/lib/fog/joyent/models/analytics/joyent_modules.rb +24 -0
  27. data/lib/fog/joyent/models/analytics/metric.rb +17 -0
  28. data/lib/fog/joyent/models/analytics/metrics.rb +16 -0
  29. data/lib/fog/joyent/models/analytics/transformation.rb +13 -0
  30. data/lib/fog/joyent/models/analytics/transformations.rb +24 -0
  31. data/lib/fog/joyent/models/analytics/type.rb +16 -0
  32. data/lib/fog/joyent/models/analytics/types.rb +24 -0
  33. data/lib/fog/joyent/models/analytics/value.rb +20 -0
  34. data/lib/fog/joyent/models/compute/datacenter.rb +11 -0
  35. data/lib/fog/joyent/models/compute/datacenters.rb +21 -0
  36. data/lib/fog/joyent/models/compute/flavor.rb +19 -0
  37. data/lib/fog/joyent/models/compute/flavors.rb +21 -0
  38. data/lib/fog/joyent/models/compute/image.rb +26 -0
  39. data/lib/fog/joyent/models/compute/images.rb +30 -0
  40. data/lib/fog/joyent/models/compute/key.rb +19 -0
  41. data/lib/fog/joyent/models/compute/keys.rb +32 -0
  42. data/lib/fog/joyent/models/compute/network.rb +12 -0
  43. data/lib/fog/joyent/models/compute/networks.rb +14 -0
  44. data/lib/fog/joyent/models/compute/server.rb +124 -0
  45. data/lib/fog/joyent/models/compute/servers.rb +35 -0
  46. data/lib/fog/joyent/models/compute/snapshot.rb +44 -0
  47. data/lib/fog/joyent/models/compute/snapshots.rb +35 -0
  48. data/lib/fog/joyent/requests/analytics/create_instrumentation.rb +25 -0
  49. data/lib/fog/joyent/requests/analytics/delete_instrumentation.rb +23 -0
  50. data/lib/fog/joyent/requests/analytics/describe_analytics.rb +26 -0
  51. data/lib/fog/joyent/requests/analytics/get_instrumentation.rb +26 -0
  52. data/lib/fog/joyent/requests/analytics/get_instrumentation_value.rb +30 -0
  53. data/lib/fog/joyent/requests/analytics/list_instrumentations.rb +25 -0
  54. data/lib/fog/joyent/requests/compute/add_machine_tags.rb +19 -0
  55. data/lib/fog/joyent/requests/compute/create_key.rb +54 -0
  56. data/lib/fog/joyent/requests/compute/create_machine.rb +16 -0
  57. data/lib/fog/joyent/requests/compute/create_machine_snapshot.rb +16 -0
  58. data/lib/fog/joyent/requests/compute/delete_all_machine_metadata.rb +16 -0
  59. data/lib/fog/joyent/requests/compute/delete_all_machine_tags.rb +15 -0
  60. data/lib/fog/joyent/requests/compute/delete_key.rb +27 -0
  61. data/lib/fog/joyent/requests/compute/delete_machine.rb +15 -0
  62. data/lib/fog/joyent/requests/compute/delete_machine_metadata.rb +16 -0
  63. data/lib/fog/joyent/requests/compute/delete_machine_snapshot.rb +18 -0
  64. data/lib/fog/joyent/requests/compute/delete_machine_tag.rb +15 -0
  65. data/lib/fog/joyent/requests/compute/get_dataset.rb +27 -0
  66. data/lib/fog/joyent/requests/compute/get_image.rb +28 -0
  67. data/lib/fog/joyent/requests/compute/get_key.rb +29 -0
  68. data/lib/fog/joyent/requests/compute/get_machine.rb +29 -0
  69. data/lib/fog/joyent/requests/compute/get_machine_metadata.rb +24 -0
  70. data/lib/fog/joyent/requests/compute/get_machine_snapshot.rb +15 -0
  71. data/lib/fog/joyent/requests/compute/get_machine_tag.rb +18 -0
  72. data/lib/fog/joyent/requests/compute/get_package.rb +32 -0
  73. data/lib/fog/joyent/requests/compute/list_datacenters.rb +16 -0
  74. data/lib/fog/joyent/requests/compute/list_datasets.rb +24 -0
  75. data/lib/fog/joyent/requests/compute/list_images.rb +25 -0
  76. data/lib/fog/joyent/requests/compute/list_keys.rb +25 -0
  77. data/lib/fog/joyent/requests/compute/list_machine_snapshots.rb +15 -0
  78. data/lib/fog/joyent/requests/compute/list_machine_tags.rb +20 -0
  79. data/lib/fog/joyent/requests/compute/list_machines.rb +26 -0
  80. data/lib/fog/joyent/requests/compute/list_networks.rb +26 -0
  81. data/lib/fog/joyent/requests/compute/list_packages.rb +34 -0
  82. data/lib/fog/joyent/requests/compute/reboot_machine.rb +15 -0
  83. data/lib/fog/joyent/requests/compute/resize_machine.rb +16 -0
  84. data/lib/fog/joyent/requests/compute/start_machine.rb +16 -0
  85. data/lib/fog/joyent/requests/compute/start_machine_from_snapshot.rb +15 -0
  86. data/lib/fog/joyent/requests/compute/stop_machine.rb +16 -0
  87. data/lib/fog/joyent/requests/compute/update_machine_metadata.rb +15 -0
  88. data/lib/fog/joyent/version.rb +5 -0
  89. data/tests/helper.rb +18 -0
  90. data/tests/helpers/mock_helper.rb +16 -0
  91. data/tests/helpers/succeeds_helper.rb +9 -0
  92. data/tests/joyent/models/analytics/field_tests.rb +10 -0
  93. data/tests/joyent/models/analytics/fields_tests.rb +13 -0
  94. data/tests/joyent/models/analytics/instrumentation_tests.rb +13 -0
  95. data/tests/joyent/models/analytics/instrumentations_tests.rb +3 -0
  96. data/tests/joyent/models/analytics/joyent_module_tests.rb +10 -0
  97. data/tests/joyent/models/analytics/joyent_modules_tests.rb +13 -0
  98. data/tests/joyent/models/analytics/metric_tests.rb +10 -0
  99. data/tests/joyent/models/analytics/metrics_tests.rb +20 -0
  100. data/tests/joyent/models/analytics/transformation_tests.rb +10 -0
  101. data/tests/joyent/models/analytics/transformations_tests.rb +13 -0
  102. data/tests/joyent/models/analytics/type_tests.rb +10 -0
  103. data/tests/joyent/models/analytics/types_tests.rb +13 -0
  104. data/tests/joyent/requests/analytics/instrumentation_tests.rb +44 -0
  105. data/tests/joyent/requests/compute/datasets_tests.rb +58 -0
  106. data/tests/joyent/requests/compute/keys_tests.rb +47 -0
  107. data/tests/joyent/requests/compute/machines_tests.rb +66 -0
  108. data/tests/joyent/requests/compute/networks_tests.rb +39 -0
  109. data/tests/joyent/requests/compute/packages_tests.rb +68 -0
  110. metadata +235 -0
@@ -0,0 +1,15 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Real
5
+ def delete_machine(machine_id)
6
+ request(
7
+ :path => "/my/machines/#{machine_id}",
8
+ :method => "DELETE",
9
+ :expects => [200, 204, 410]
10
+ )
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Real
5
+ # https://us-west-1.api.joyentcloud.com/docs#DeleteAllMachineMetadata
6
+ def delete_machine_metadata(machine_id, key)
7
+ request(
8
+ :method => "DELETE",
9
+ :path => "/my/machines/#{machine_id}/metadata/#{key}",
10
+ :expects => [200, 204]
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Real
5
+ def delete_machine_snapshot(machine_id, snapshot)
6
+ request(
7
+ :method => "DELETE",
8
+ :path => "/my/machines/#{machine_id}/snapshots/#{snapshot}",
9
+ :expects => [200, 204]
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Real
5
+ def delete_machine_tag(machine_id, tagname)
6
+ request(
7
+ :path => "/my/machines/#{machine_id}/tags/#{tagname}",
8
+ :method => "DELETE",
9
+ :expects => 204
10
+ )
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Mock
5
+ def get_dataset(id)
6
+ if ds = self.data[:datasets][id]
7
+ res = Excon::Response.new
8
+ res.status = 200
9
+ res.body = ds
10
+ else
11
+ raise Excon::Errors::NotFound
12
+ end
13
+ end
14
+ end
15
+
16
+ class Real
17
+ def get_dataset
18
+ request(
19
+ :method => "GET",
20
+ :path => "/my/datasets",
21
+ :idempotent => true
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Mock
5
+ def get_image(id)
6
+ if ds = self.data[:datasets][id]
7
+ res = Excon::Response.new
8
+ res.status = 200
9
+ res.body = ds
10
+ else
11
+ raise Excon::Errors::NotFound
12
+ end
13
+ end
14
+ end
15
+
16
+ class Real
17
+ def get_image(id)
18
+ request(
19
+ :method => "GET",
20
+ :path => "/#{@joyent_username}/images/#{id}",
21
+ :expects => 200,
22
+ :idempotent => true
23
+ )
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Mock
5
+ def get_key(keyid)
6
+ if key = self.data[:keys][keyid]
7
+ response = Excon::Response.new
8
+ response.status = 200
9
+ response.body = key
10
+ response
11
+ else
12
+ raise Excon::Errors::NotFound
13
+ end
14
+ end
15
+ end
16
+
17
+ class Real
18
+ def get_key(keyid)
19
+ request(
20
+ :method => "GET",
21
+ :path => "/my/keys/#{keyid}",
22
+ :expects => 200,
23
+ :idempotent => true
24
+ )
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Mock
5
+ def get_machine(uuid)
6
+ if machine = self.data[:machines][uuid]
7
+ res = Excon::Response.new
8
+ res.status = 200
9
+ res.body = machine
10
+ res
11
+ else
12
+ raise Excon::Errors::NotFound, "Not Found"
13
+ end
14
+ end
15
+ end
16
+
17
+ class Real
18
+ def get_machine(uuid)
19
+ request(
20
+ :method => "GET",
21
+ :path => "/my/machines/#{uuid}",
22
+ :expects => [200, 410],
23
+ :idempotent => true
24
+ )
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Real
5
+ def get_machine_metadata(machine_id, options = {})
6
+ query = {}
7
+ if options[:credentials]
8
+ if options[:credentials].is_a?(Boolean)
9
+ query[:credentials] = options[:credentials]
10
+ else
11
+ raise ArgumentError, "options[:credentials] must be a Boolean or nil"
12
+ end
13
+ end
14
+
15
+ request(
16
+ :path => "/my/machines/#{machine_id}/metadata",
17
+ :query => query,
18
+ :idempotent => true
19
+ )
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Real
5
+ def get_machine_snapshot(machine_id, snapshot_name)
6
+ request(
7
+ :path => "/my/machines/#{machine_id}/snapshots/#{snapshot_name}",
8
+ :method => "GET",
9
+ :idempotent => true
10
+ )
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Real
5
+ # https://us-west-1.api.joyentcloud.com/docs#GetMachineTag
6
+ def get_machine_tag(machine_id, tagname)
7
+ request(
8
+ :path => "/my/machines/#{machine_id}/tags/#{tagname}",
9
+ :method => "GET",
10
+ :headers => {"Accept" => "text/plain"},
11
+ :expects => 200,
12
+ :idempotent => true
13
+ )
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,32 @@
1
+ require 'uri'
2
+
3
+ module Fog
4
+ module Compute
5
+ class Joyent
6
+ class Mock
7
+ def get_package(name)
8
+ if pkg = self.data[:packages][name]
9
+ response = Excon::Response.new
10
+ response.body = pkg
11
+ response.status = 200
12
+ response
13
+ else
14
+ raise Excon::Errors::NotFound
15
+ end
16
+ end
17
+ end
18
+
19
+ class Real
20
+ def get_package(name)
21
+ name = URI.escape(name)
22
+ request(
23
+ :method => "GET",
24
+ :path => "/my/packages/#{name}",
25
+ :expects => 200,
26
+ :idempotent => true
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,16 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Real
5
+ def list_datacenters
6
+ request(
7
+ :expects => 200,
8
+ :method => :'GET',
9
+ :path => '/my/datacenters',
10
+ :idempotent => true
11
+ )
12
+ end
13
+ end # Real
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Mock
5
+ def list_datasets
6
+ res = Excon::Response.new
7
+ res.status = 200
8
+ res.body = self.data[:datasets].values
9
+ res
10
+ end
11
+ end
12
+
13
+ class Real
14
+ def list_datasets
15
+ request(
16
+ :method => "GET",
17
+ :path => "/my/datasets",
18
+ :idempotent => true
19
+ )
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Mock
5
+ def list_images
6
+ res = Excon::Response.new
7
+ res.status = 200
8
+ res.body = self.data[:datasets].values
9
+ res
10
+ end
11
+ end
12
+
13
+ class Real
14
+ def list_images
15
+ request(
16
+ :method => "GET",
17
+ :path => "/#{@joyent_username}/images",
18
+ :expects => 200,
19
+ :idempotent => true
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Mock
5
+ def list_keys
6
+ response = Excon::Response.new
7
+ response.status = 200
8
+ response.body = self.data[:keys].values
9
+ response
10
+ end
11
+ end
12
+
13
+ class Real
14
+ def list_keys
15
+ request(
16
+ :expects => 200,
17
+ :method => :'GET',
18
+ :path => '/my/keys',
19
+ :idempotent => true
20
+ )
21
+ end
22
+ end # Real
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Real
5
+ def list_machine_snapshots(machine_id)
6
+ request(
7
+ :method => "GET",
8
+ :path => "/my/machines/#{machine_id}/snapshots",
9
+ :idempotent => true
10
+ )
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Real
5
+ # https://us-west-1.api.joyentcloud.com/docs#ListMachineTags
6
+ def list_machine_tags(machine_id)
7
+ request(
8
+ :path => "/my/machines/#{machine_id}/tags",
9
+ :method => "GET",
10
+ :expects => 200,
11
+ :idempotent => true
12
+ )
13
+ end
14
+ end
15
+
16
+ class Mock
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Compute
3
+ class Joyent
4
+ class Mock
5
+ def list_machines(options={})
6
+ res = Excon::Response.new
7
+ res.status = 200
8
+ res.body = self.data[:machines].values
9
+ res
10
+ end
11
+ end
12
+
13
+ class Real
14
+ def list_machines(options={})
15
+ request(
16
+ :path => "/my/machines",
17
+ :method => "GET",
18
+ :query => options,
19
+ :expects => 200,
20
+ :idempotent => true
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end