fog-linode 0.0.1.rc1

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 (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rubocop.yml +12 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +17 -0
  7. data/CODE_OF_CONDUCT.md +74 -0
  8. data/CONTRIBUTORS.md +1 -0
  9. data/Gemfile +6 -0
  10. data/Gemfile.lock +79 -0
  11. data/LICENSE.md +20 -0
  12. data/README.md +74 -0
  13. data/Rakefile +13 -0
  14. data/bin/console +14 -0
  15. data/bin/setup +8 -0
  16. data/fog-linode.gemspec +34 -0
  17. data/lib/fog/linode.rb +17 -0
  18. data/lib/fog/linode/compute.rb +50 -0
  19. data/lib/fog/linode/compute/models/image.rb +23 -0
  20. data/lib/fog/linode/compute/models/images.rb +23 -0
  21. data/lib/fog/linode/compute/models/kernel.rb +19 -0
  22. data/lib/fog/linode/compute/models/kernels.rb +23 -0
  23. data/lib/fog/linode/compute/models/region.rb +14 -0
  24. data/lib/fog/linode/compute/models/regions.rb +23 -0
  25. data/lib/fog/linode/compute/models/server.rb +56 -0
  26. data/lib/fog/linode/compute/models/servers.rb +23 -0
  27. data/lib/fog/linode/compute/models/stack_script.rb +26 -0
  28. data/lib/fog/linode/compute/models/stack_scripts.rb +23 -0
  29. data/lib/fog/linode/compute/models/type.rb +32 -0
  30. data/lib/fog/linode/compute/models/types.rb +23 -0
  31. data/lib/fog/linode/compute/requests/create_server.rb +22 -0
  32. data/lib/fog/linode/compute/requests/delete_server.rb +17 -0
  33. data/lib/fog/linode/compute/requests/list_images.rb +16 -0
  34. data/lib/fog/linode/compute/requests/list_kernels.rb +16 -0
  35. data/lib/fog/linode/compute/requests/list_regions.rb +18 -0
  36. data/lib/fog/linode/compute/requests/list_servers.rb +16 -0
  37. data/lib/fog/linode/compute/requests/list_stack_scripts.rb +16 -0
  38. data/lib/fog/linode/compute/requests/list_types.rb +19 -0
  39. data/lib/fog/linode/compute/requests/update_server.rb +21 -0
  40. data/lib/fog/linode/compute/requests/view_image.rb +17 -0
  41. data/lib/fog/linode/compute/requests/view_kernel.rb +17 -0
  42. data/lib/fog/linode/compute/requests/view_region.rb +18 -0
  43. data/lib/fog/linode/compute/requests/view_server.rb +17 -0
  44. data/lib/fog/linode/compute/requests/view_stack_script.rb +17 -0
  45. data/lib/fog/linode/compute/requests/view_type.rb +18 -0
  46. data/lib/fog/linode/dns.rb +37 -0
  47. data/lib/fog/linode/dns/models/domain.rb +46 -0
  48. data/lib/fog/linode/dns/models/domain_record.rb +38 -0
  49. data/lib/fog/linode/dns/models/domain_records.rb +30 -0
  50. data/lib/fog/linode/dns/models/domains.rb +23 -0
  51. data/lib/fog/linode/dns/requests/create_domain.rb +22 -0
  52. data/lib/fog/linode/dns/requests/create_domain_record.rb +22 -0
  53. data/lib/fog/linode/dns/requests/delete_domain.rb +17 -0
  54. data/lib/fog/linode/dns/requests/delete_domain_record.rb +17 -0
  55. data/lib/fog/linode/dns/requests/list_domain_records.rb +19 -0
  56. data/lib/fog/linode/dns/requests/list_domains.rb +19 -0
  57. data/lib/fog/linode/dns/requests/update_domain.rb +21 -0
  58. data/lib/fog/linode/dns/requests/update_domain_record.rb +22 -0
  59. data/lib/fog/linode/dns/requests/view_domain.rb +18 -0
  60. data/lib/fog/linode/dns/requests/view_domain_record.rb +17 -0
  61. data/lib/fog/linode/paginated_collection.rb +44 -0
  62. data/lib/fog/linode/service.rb +37 -0
  63. data/lib/fog/linode/version.rb +5 -0
  64. metadata +247 -0
@@ -0,0 +1,23 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Linode
5
+ class Compute
6
+ # Read-only model for Linode images
7
+ class Image < Fog::Model
8
+ identity :id
9
+
10
+ attribute :label
11
+ attribute :created
12
+ attribute :created_by
13
+ attribute :deprecated
14
+ attribute :description
15
+ attribute :is_public
16
+ attribute :size
17
+ attribute :type
18
+ attribute :expiry
19
+ attribute :vendor
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/linode/compute/models/kernel'
3
+
4
+ module Fog
5
+ module Linode
6
+ class Compute
7
+ # Collection class for loading Image models from Linode image data
8
+ class Images < Fog::Collection
9
+ model Image
10
+
11
+ def all(options = {})
12
+ images = service.list_images(options)
13
+ load images
14
+ end
15
+
16
+ def get(id)
17
+ image = service.view_image(id)
18
+ new image
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Linode
5
+ class Compute
6
+ # Read-only model for Linode kernels
7
+ class Kernel < Fog::Model
8
+ identity :id
9
+
10
+ attribute :label
11
+ attribute :version
12
+ attribute :kvm
13
+ attribute :xen
14
+ attribute :architecture
15
+ attribute :pvops
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/linode/compute/models/kernel'
3
+
4
+ module Fog
5
+ module Linode
6
+ class Compute
7
+ # Collection class for loading Kernel models from Linode instance kernel data
8
+ class Kernels < Fog::Collection
9
+ model Kernel
10
+
11
+ def all(options = {})
12
+ kernels = service.list_kernels(options)
13
+ load kernels
14
+ end
15
+
16
+ def get(id)
17
+ kernel = service.view_kernel(id)
18
+ new kernel
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Linode
5
+ class Compute
6
+ # Read-only model for Linode regions
7
+ class Region < Fog::Model
8
+ identity :id
9
+
10
+ attribute :country
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,23 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/linode/compute/models/type'
3
+
4
+ module Fog
5
+ module Linode
6
+ class Compute
7
+ # Collection class for loading Region models from Linode region data
8
+ class Regions < Fog::Collection
9
+ model Region
10
+
11
+ def all
12
+ regions = service.list_regions
13
+ load regions
14
+ end
15
+
16
+ def get(id)
17
+ region = service.view_region(id)
18
+ new region
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,56 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Linode
5
+ class Compute
6
+ # Read-only model for Linode instances
7
+ class Server < Fog::Model
8
+ identity :id
9
+
10
+ attribute :label
11
+ attribute :region
12
+ attribute :image
13
+ attribute :type
14
+ attribute :group
15
+ attribute :tags
16
+ attribute :status
17
+ attribute :hypervisor
18
+ attribute :created
19
+ attribute :updated
20
+ attribute :ipv4
21
+ attribute :ipv6
22
+ attribute :specs
23
+ attribute :alerts
24
+ attribute :backups
25
+ attribute :watchdog_enabled
26
+
27
+ # Attributes for creation (not available when viewing, not supported for update)
28
+ attribute :backup_id
29
+ attribute :backups_enabled
30
+ attribute :swap_size
31
+ attribute :root_pass
32
+ attribute :authorized_keys
33
+ attribute :stackscript_id
34
+ attribute :stackscript_data
35
+ attribute :booted
36
+ attribute :private_ip
37
+ attribute :authorized_users
38
+
39
+ def save
40
+ if identity.nil?
41
+ merge_attributes(service.create_server(attributes))
42
+ else
43
+ merge_attributes(service.update_server(identity, attributes_for_update))
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def attributes_for_update
50
+ supported_attributes = %i[label group tags alerts backups watchdog_enabled]
51
+ attributes.dup.select { |key| supported_attributes.include? key }
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,23 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/linode/compute/models/kernel'
3
+
4
+ module Fog
5
+ module Linode
6
+ class Compute
7
+ # Collection class for loading Server models from Linode instance data
8
+ class Servers < Fog::Collection
9
+ model Server
10
+
11
+ def all(options = {})
12
+ servers = service.list_servers(options)
13
+ load servers
14
+ end
15
+
16
+ def get(id)
17
+ server = service.view_server(id)
18
+ new server
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,26 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Linode
5
+ class Compute
6
+ # Read-only model for Linode StackScripts
7
+ class StackScript < Fog::Model
8
+ identity :id
9
+
10
+ attribute :username
11
+ attribute :user_gravatar_id
12
+ attribute :label
13
+ attribute :description
14
+ attribute :images
15
+ attribute :deployments_total
16
+ attribute :deployments_active
17
+ attribute :is_public
18
+ attribute :created
19
+ attribute :updated
20
+ attribute :rev_note
21
+ attribute :script
22
+ attribute :user_defined_fields
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/linode/compute/models/type'
3
+
4
+ module Fog
5
+ module Linode
6
+ class Compute
7
+ # Collection class for loading StackScript models from Linode StackScript data
8
+ class StackScripts < Fog::Collection
9
+ model StackScript
10
+
11
+ def all(options = {})
12
+ stack_scripts = service.list_stack_scripts(options)
13
+ load stack_scripts
14
+ end
15
+
16
+ def get(id)
17
+ stack_script = service.view_stack_script(id)
18
+ new stack_script
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,32 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Linode
5
+ class Compute
6
+ # Read-only model for Linode instance types
7
+ class Type < Fog::Model
8
+ identity :id
9
+
10
+ attribute :label
11
+ attribute :disk
12
+ attribute :class_name
13
+ attribute :price
14
+ attribute :addons
15
+ attribute :network_out
16
+ attribute :memory
17
+ attribute :successor
18
+ attribute :transfer
19
+ attribute :vcpus
20
+
21
+ # Types have an attribute named `class`, which is a reserved word,
22
+ # so we rename the attribute to `class_name` before initalization
23
+ # to avoid runtime errors due to overwriting `class`
24
+ def initialize(attributes = {})
25
+ cleaned_attributes = attributes.dup
26
+ cleaned_attributes[:class_name] = cleaned_attributes.delete('class')
27
+ super(cleaned_attributes)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/linode/compute/models/type'
3
+
4
+ module Fog
5
+ module Linode
6
+ class Compute
7
+ # Collection class for loading Type models from Linode instance type data
8
+ class Types < Fog::Collection
9
+ model Type
10
+
11
+ def all(options = {})
12
+ types = service.list_types(options)
13
+ load types
14
+ end
15
+
16
+ def get(id)
17
+ type = service.view_type(id)
18
+ new type
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ module Fog
2
+ module Linode
3
+ class Compute
4
+ # This class provides the actual implementation for service calls
5
+ class Real
6
+ def create_server(options = {})
7
+ response = request(
8
+ expects: [200],
9
+ method: 'POST',
10
+ path: 'linode/instances',
11
+ body: Fog::JSON.encode(options),
12
+ headers: {
13
+ 'Content-Type' => 'application/json'
14
+ }
15
+ )
16
+
17
+ response.body
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ module Fog
2
+ module Linode
3
+ class Compute
4
+ # This class provides the actual implementation for service calls
5
+ class Real
6
+ def delete_server(id)
7
+ response = request(
8
+ expects: [200],
9
+ method: 'DELETE',
10
+ path: "linode/instances/#{id}"
11
+ )
12
+ response.body
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ require 'fog/linode/paginated_collection'
2
+
3
+ module Fog
4
+ module Linode
5
+ class Compute
6
+ # This class provides the actual implementation for service calls
7
+ class Real
8
+ include PaginatedCollection
9
+
10
+ def list_images(options = {})
11
+ make_paginated_request('images', options)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'fog/linode/paginated_collection'
2
+
3
+ module Fog
4
+ module Linode
5
+ class Compute
6
+ # This class provides the actual implementation for service calls
7
+ class Real
8
+ include PaginatedCollection
9
+
10
+ def list_kernels(options = {})
11
+ make_paginated_request('linode/kernels', options)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ module Fog
2
+ module Linode
3
+ class Compute
4
+ # This class provides the actual implementation for service calls
5
+ class Real
6
+ def list_regions
7
+ response = request(
8
+ expects: [200],
9
+ method: 'GET',
10
+ path: 'regions'
11
+ )
12
+
13
+ response.body['data']
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ require 'fog/linode/paginated_collection'
2
+
3
+ module Fog
4
+ module Linode
5
+ class Compute
6
+ # This class provides the actual implementation for service calls
7
+ class Real
8
+ include PaginatedCollection
9
+
10
+ def list_servers(options = {})
11
+ make_paginated_request('linode/instances', options)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end