enstratus 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 (115) hide show
  1. data/.gitignore +6 -0
  2. data/Gemfile +4 -0
  3. data/NOTES.md +80 -0
  4. data/README.md +51 -0
  5. data/Rakefile +1 -0
  6. data/TODO.md +21 -0
  7. data/config-sample.yaml +5 -0
  8. data/enstratus.gemspec +24 -0
  9. data/examples/list-servers.rb +17 -0
  10. data/lib/enstratus.rb +49 -0
  11. data/lib/enstratus/admin.rb +13 -0
  12. data/lib/enstratus/admin/account.rb +30 -0
  13. data/lib/enstratus/admin/acl.rb +8 -0
  14. data/lib/enstratus/admin/api_key.rb +24 -0
  15. data/lib/enstratus/admin/billing_code.rb +21 -0
  16. data/lib/enstratus/admin/customer.rb +25 -0
  17. data/lib/enstratus/admin/group.rb +12 -0
  18. data/lib/enstratus/admin/job.rb +16 -0
  19. data/lib/enstratus/admin/role.rb +13 -0
  20. data/lib/enstratus/admin/user.rb +30 -0
  21. data/lib/enstratus/analytics.rb +6 -0
  22. data/lib/enstratus/analytics/server_analytics.rb +12 -0
  23. data/lib/enstratus/analytics/tier_analytics.rb +12 -0
  24. data/lib/enstratus/automation.rb +19 -0
  25. data/lib/enstratus/automation/configuration_management_account.rb +0 -0
  26. data/lib/enstratus/automation/configuration_management_server.rb +0 -0
  27. data/lib/enstratus/automation/configuration_management_service.rb +0 -0
  28. data/lib/enstratus/automation/configuration_management_system.rb +0 -0
  29. data/lib/enstratus/automation/data_source.rb +0 -0
  30. data/lib/enstratus/automation/data_source_backup.rb +0 -0
  31. data/lib/enstratus/automation/deployment.rb +30 -0
  32. data/lib/enstratus/automation/deployment_load_balancer.rb +14 -0
  33. data/lib/enstratus/automation/launch_configuration.rb +0 -0
  34. data/lib/enstratus/automation/personality.rb +0 -0
  35. data/lib/enstratus/automation/script.rb +0 -0
  36. data/lib/enstratus/automation/service.rb +0 -0
  37. data/lib/enstratus/automation/service_backup.rb +0 -0
  38. data/lib/enstratus/automation/ssl_certificate.rb +0 -0
  39. data/lib/enstratus/automation/tier.rb +28 -0
  40. data/lib/enstratus/automation/tier_backup.rb +0 -0
  41. data/lib/enstratus/configuration.rb +13 -0
  42. data/lib/enstratus/finance.rb +5 -0
  43. data/lib/enstratus/finance/server_prepayment.rb +29 -0
  44. data/lib/enstratus/geography.rb +8 -0
  45. data/lib/enstratus/geography/cloud.rb +16 -0
  46. data/lib/enstratus/geography/data_center.rb +14 -0
  47. data/lib/enstratus/geography/region.rb +14 -0
  48. data/lib/enstratus/geography/subscription.rb +51 -0
  49. data/lib/enstratus/infrastructure.rb +11 -0
  50. data/lib/enstratus/infrastructure/machine_image.rb +31 -0
  51. data/lib/enstratus/infrastructure/server.rb +50 -0
  52. data/lib/enstratus/infrastructure/server_product.rb +21 -0
  53. data/lib/enstratus/infrastructure/snapshot.rb +32 -0
  54. data/lib/enstratus/infrastructure/volume.rb +31 -0
  55. data/lib/enstratus/infrastructure/volume_product.rb +4 -0
  56. data/lib/enstratus/network.rb +10 -0
  57. data/lib/enstratus/network/dns_zone.rb +0 -0
  58. data/lib/enstratus/network/firewall.rb +0 -0
  59. data/lib/enstratus/network/firewall_rule.rb +0 -0
  60. data/lib/enstratus/network/load_balancer.rb +0 -0
  61. data/lib/enstratus/network/network.rb +0 -0
  62. data/lib/enstratus/network/subnet.rb +0 -0
  63. data/lib/enstratus/platform.rb +47 -0
  64. data/lib/enstratus/platform/account_status.rb +0 -0
  65. data/lib/enstratus/platform/action.rb +0 -0
  66. data/lib/enstratus/platform/alert_configuration.rb +0 -0
  67. data/lib/enstratus/platform/algorithm.rb +0 -0
  68. data/lib/enstratus/platform/architecture.rb +0 -0
  69. data/lib/enstratus/platform/backup_status.rb +0 -0
  70. data/lib/enstratus/platform/breach_state.rb +0 -0
  71. data/lib/enstratus/platform/budget_state.rb +0 -0
  72. data/lib/enstratus/platform/cloud_subscription.rb +0 -0
  73. data/lib/enstratus/platform/color.rb +0 -0
  74. data/lib/enstratus/platform/credit_card.rb +0 -0
  75. data/lib/enstratus/platform/database_engine.rb +0 -0
  76. data/lib/enstratus/platform/deployment_state.rb +0 -0
  77. data/lib/enstratus/platform/deployment_type.rb +0 -0
  78. data/lib/enstratus/platform/distribution.rb +0 -0
  79. data/lib/enstratus/platform/dns_automation.rb +0 -0
  80. data/lib/enstratus/platform/dns_record.rb +0 -0
  81. data/lib/enstratus/platform/dns_record_type.rb +0 -0
  82. data/lib/enstratus/platform/event_type.rb +0 -0
  83. data/lib/enstratus/platform/job_status.rb +0 -0
  84. data/lib/enstratus/platform/jrusdiction.rb +0 -0
  85. data/lib/enstratus/platform/jurisdiction.rb +0 -0
  86. data/lib/enstratus/platform/key_value_database.rb +0 -0
  87. data/lib/enstratus/platform/lb_protocol.rb +0 -0
  88. data/lib/enstratus/platform/listener.rb +0 -0
  89. data/lib/enstratus/platform/load_balancer_scope.rb +0 -0
  90. data/lib/enstratus/platform/load_balancer_type.rb +0 -0
  91. data/lib/enstratus/platform/management_state.rb +0 -0
  92. data/lib/enstratus/platform/managment_state.rb +0 -0
  93. data/lib/enstratus/platform/message_queue.rb +0 -0
  94. data/lib/enstratus/platform/money.rb +0 -0
  95. data/lib/enstratus/platform/notification_setting.rb +0 -0
  96. data/lib/enstratus/platform/notification_targets.rb +0 -0
  97. data/lib/enstratus/platform/physical_address.rb +0 -0
  98. data/lib/enstratus/platform/platform.rb +0 -0
  99. data/lib/enstratus/platform/properties.rb +0 -0
  100. data/lib/enstratus/platform/protocol.rb +0 -0
  101. data/lib/enstratus/platform/push_notification_topic.rb +0 -0
  102. data/lib/enstratus/platform/qualifier.rb +0 -0
  103. data/lib/enstratus/platform/relational_database.rb +0 -0
  104. data/lib/enstratus/platform/relational_database_product.rb +0 -0
  105. data/lib/enstratus/platform/resource_type.rb +0 -0
  106. data/lib/enstratus/platform/scaling_rules.rb +0 -0
  107. data/lib/enstratus/platform/server_state.rb +0 -0
  108. data/lib/enstratus/platform/storage_object.rb +0 -0
  109. data/lib/enstratus/presenter.rb +0 -0
  110. data/lib/enstratus/request.rb +36 -0
  111. data/lib/enstratus/request_signer.rb +26 -0
  112. data/lib/enstratus/resource.rb +92 -0
  113. data/lib/enstratus/util.rb +5 -0
  114. data/lib/enstratus/version.rb +3 -0
  115. metadata +175 -0
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ config.yaml
6
+ examples/load.rb
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in enstratus.rb.gemspec
4
+ gemspec
@@ -0,0 +1,80 @@
1
+ _This is currently just the contents of the previous README_
2
+
3
+ # Setup
4
+
5
+ - Copy config-sample.yaml to config.yaml
6
+ - Edit config.yaml with your API keys
7
+ - Try running `examples/list-servers.rb`
8
+
9
+ # Notes
10
+ The only part of the library that's fleshed out right now is the request signer.
11
+ The examples are mainly the way I'm testing each aspect of the API right now.
12
+
13
+ ## Specific example notes
14
+ Other than `list-regions`,`list-servers` and `list-clouds`, all the examples require some additional configuration. Take `list-datacenters` for instance:
15
+
16
+ - The list datacenters call REQUIRES a regionID as a query param
17
+ - If you run `list-regions.rb`, you can get a list of regionIds that API key has access to
18
+ - replace `@region_id = "11111111"` in `list-datacenters` with the appropriate region
19
+ - run `list-datacenters` and you should get the details back for that.
20
+
21
+
22
+ # Creating/Deleting a server
23
+ Now to be able to create a server, you'll need three bits of information:
24
+
25
+ - datacenterId
26
+ - machineImageId
27
+ - productId
28
+
29
+ We have a way of getting the datacenterID as described above. Now we need to get the machineImageId.
30
+
31
+ To get a list of machineImageIds, we HAVE to provide a regionId. We have that from above. So we update `list-images` with the regionId and we get back a list of machine images for that region.
32
+
33
+ _Note there are bugs in the current release of the API that are fixed in the next release. If you get an auth failure, please retry your request_
34
+
35
+ To get the list of available product ids, you'll need to run `list-products` with the appropriate regionID (or alternately a machineImageId). Since there's currently a bug with listing by region (you must provide an architecture), we're going to pass in a machineImageId instead.
36
+
37
+ This will give us a list of valid products for the image we want to use.
38
+
39
+ Now that you have all that information (datacenterID,machineImageId and productID), you can update create-server and run it. Server creation is an async process. Your response will look something like this:
40
+
41
+ ```ruby
42
+ {"jobs"=>[{"jobId"=>56681, "status"=>"RUNNING"}]}
43
+ ```
44
+
45
+ To see the status of all jobs, there's a `list-jobs` script that returns:
46
+
47
+ ```ruby
48
+ {"jobs"=>
49
+ [
50
+ {"startDate"=>"2012-04-18T17:11:34.613+0000",
51
+ "jobId"=>56681,
52
+ "status"=>"RUNNING",
53
+ "description"=>"Launch Server enstratus.rb"}]}
54
+ ```
55
+
56
+ When it's finally done, you'll see this:
57
+
58
+ ```ruby
59
+ {"jobs"=>
60
+ [{"message"=>"241542",
61
+ "startDate"=>"2012-04-18T17:11:34.613+0000",
62
+ "jobId"=>56681,
63
+ "status"=>"COMPLETE",
64
+ "description"=>"Launch Server enstratus.rb",
65
+ "endDate"=>"2012-04-18T17:13:16.658+0000"}]}
66
+ ```
67
+
68
+ Obviously, we don't want to leave this running so we edit `delete-server` and put in the machine ID. Again, you can call list-servers to get that. Delete calls do not return any content so you'll have to list jobs to see what's up:
69
+
70
+ ```ruby
71
+ {"jobs"=>
72
+ [
73
+ {"startDate"=>"2012-04-18T17:23:54.075+0000",
74
+ "jobId"=>56682,
75
+ "status"=>"RUNNING",
76
+ "description"=>"Terminate 241542"}]}
77
+ ```
78
+
79
+ If you call list-servers after the job is finished, the server should be gone
80
+
@@ -0,0 +1,51 @@
1
+ # enstratus-ruby
2
+ This will soon be the gem to use for interacting with the enStratus API.
3
+
4
+ ## Currently Implemented GET operations (by resource group)
5
+
6
+ _testing against enStratus SaaS api version 2012-02-29_
7
+
8
+ - Admin (all)
9
+ - Anayltics (all)
10
+ - Finance (all)
11
+ - Geography (all)
12
+ - Infrastructure (all)
13
+ - Automation (deployment, tier)
14
+
15
+ ## status - 2012/05/06
16
+ I'm currently adding read-only support for all resources. The actual structure of a resource class may change.
17
+
18
+ **HOWEVER**
19
+
20
+ If you'd like to test against, your account:
21
+
22
+
23
+ (in an irb/pry session)
24
+ ```ruby
25
+ require 'enstratus'
26
+ require 'pp'
27
+
28
+ Enstratus.configure("/path/to/config.yaml")
29
+
30
+ Enstratus::Infrastructure::Server.all
31
+
32
+ # array of Enstratus::Infrastructure::Server objects returned
33
+ ```
34
+
35
+ See `lib/enstratus/infrastructure/` or `lib/enstratus/geography` for other resources currently done.
36
+
37
+ There is currently no error handling in place for calls that require query params. If you get some wonky errors, try
38
+
39
+ ```ruby
40
+ Enstratus::Geography::Region.all
41
+
42
+ # list of known regions returned
43
+
44
+ Enstratus::Infrastructure::MachineImage.all :regionId => some_region_id_from_above
45
+
46
+ # list of Machine Images returned
47
+ ```
48
+
49
+ Again, currently read-only operations (so any `GET` call documented is implemented but not against all resources.
50
+
51
+ There's a small sample program in `examples` that shows what the current API I'm using to validate reads is. Likely to change.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/TODO.md ADDED
@@ -0,0 +1,21 @@
1
+ # Fix `to_underscore` helper
2
+ Currently borking on all caps strings i.e. `subscribedCDN` becomes `subscribed_cd_n` instead of `subscribed_cdn`
3
+
4
+ # move attributes to elements where appropriate
5
+ Need to create a dsl for `elements` similar to attributes with appropriate distinction
6
+
7
+ # finish wiring up attributes (and elements)
8
+ Placeholders exist for handling extended information (mutability, type) but this needs to be fleshed out fully.
9
+ Same goes for elements when they come in to play.
10
+
11
+ # flesh out collections
12
+ Shitty array of objects is shitty. Do it right.
13
+
14
+ # error/exception handling
15
+ yeah...could use some
16
+
17
+ # remainder of CRUD
18
+ need to wire up ALL The operations
19
+
20
+ # tests
21
+ I don't always test but when I do....
@@ -0,0 +1,5 @@
1
+ debug: false
2
+ endpoint: "https://api.enstratus.com"
3
+ version: "2012-02-29"
4
+ access_key: XXXXXXXXXXXXXXXXXXXXXXXXXXX
5
+ secret_key: YYYYYYYYYYYYYYYYYYYYYYYYYYY
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "enstratus/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "enstratus"
7
+ s.version = Enstratus::VERSION
8
+ s.authors = ["John E. Vincent"]
9
+ s.email = ["lusis.org+github.com@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{enStratus API gem}
12
+ s.description = %q{gem for interacting with the enStratus API}
13
+
14
+ s.rubyforge_project = "enstratus"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ s.add_runtime_dependency "excon"
24
+ end
@@ -0,0 +1,17 @@
1
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
2
+ require 'enstratus'
3
+ require 'pp'
4
+
5
+ Enstratus.configure("#{File.expand_path(File.join(File.dirname(__FILE__), ".."))}/config.yaml")
6
+ # uncomment and set to true for raw repsonses
7
+ # or set debug: true in config.yaml
8
+
9
+ #Enstratus.configuration.debug = false
10
+
11
+ all_servers = Enstratus::Infrastructure::Server.all
12
+
13
+ # Pick the first server from all servers
14
+ single_server = Enstratus::Infrastructure::Server[all_servers.first.server_id]
15
+
16
+ pp all_servers
17
+ pp single_server
@@ -0,0 +1,49 @@
1
+ require "enstratus/version"
2
+ require 'base64'
3
+ require 'openssl'
4
+ require 'excon'
5
+ require 'yaml'
6
+ require 'json'
7
+
8
+ module Enstratus
9
+ UA = "enstratus.rb"
10
+
11
+ class << self
12
+ attr_accessor :configuration
13
+ end
14
+
15
+ def self.configure(config_file=nil)
16
+ self.configuration ||= Configuration.new
17
+ if config_file.nil?
18
+ yield(configuration)
19
+ else
20
+ begin
21
+ c = YAML.load(File.open(config_file, 'r'){|f| f.read})
22
+ c.each do |k,v|
23
+ self.configuration.instance_variable_set("@#{k}", v)
24
+ end
25
+ rescue Exception => e
26
+ puts e.message
27
+ end
28
+ end
29
+ end
30
+
31
+ def self.debug?
32
+ Enstratus.configuration.debug || false
33
+ end
34
+
35
+ end
36
+
37
+ require 'enstratus/util'
38
+ require 'enstratus/configuration'
39
+ require 'enstratus/request_signer'
40
+ require 'enstratus/request'
41
+ require 'enstratus/resource'
42
+ require 'enstratus/platform'
43
+ require 'enstratus/infrastructure'
44
+ require 'enstratus/geography'
45
+ require 'enstratus/admin'
46
+ require 'enstratus/analytics'
47
+ require 'enstratus/automation'
48
+ require 'enstratus/finance'
49
+ require 'enstratus/network'
@@ -0,0 +1,13 @@
1
+ module Enstratus
2
+ module Admin; end
3
+ end
4
+
5
+ require 'enstratus/admin/account'
6
+ require 'enstratus/admin/acl'
7
+ require 'enstratus/admin/api_key'
8
+ require 'enstratus/admin/billing_code'
9
+ require 'enstratus/admin/customer'
10
+ require 'enstratus/admin/group'
11
+ require 'enstratus/admin/job'
12
+ require 'enstratus/admin/role'
13
+ require 'enstratus/admin/user'
@@ -0,0 +1,30 @@
1
+ module Enstratus::Admin
2
+ class Account < Enstratus::Resource
3
+ attribute :account_id
4
+ attribute :default_budget
5
+ attribute :status
6
+
7
+ # Convert to element
8
+ attribute :alert_configuration
9
+ attribute :billing_address
10
+ attribute :billing_credit_card
11
+ attribute :billing_email
12
+ attribute :billing_phone
13
+ attribute :billing_system_id
14
+ attribute :cloud_subscription
15
+ attribute :configured
16
+ attribute :customer
17
+ attribute :dns_automation
18
+ attribute :name
19
+ attribute :owner_id
20
+ attribute :plan_id
21
+ attribute :provisioned
22
+ attribute :storage
23
+ attribute :subscribed
24
+
25
+ # docerror :not_documented
26
+ attribute :cloud_subscription_id
27
+ attribute :owner
28
+
29
+ end
30
+ end
@@ -0,0 +1,8 @@
1
+ module Enstratus::Admin
2
+ class Acl < Enstratus::Resource
3
+
4
+ attribute :action
5
+ attribute :qualifier
6
+ attribute :resource_type
7
+ end
8
+ end
@@ -0,0 +1,24 @@
1
+ module Enstratus::Admin
2
+ class ApiKey < Enstratus::Resource
3
+ collects_as :apiKeys
4
+
5
+ attribute :api_key_id
6
+ attribute :status
7
+
8
+ # elements
9
+ attribute :access_key
10
+ attribute :account
11
+ attribute :activation_timestamp
12
+ attribute :cidr_list
13
+ attribute :description
14
+ attribute :expiration_timestamp
15
+ attribute :configured
16
+ attribute :name
17
+ attribute :secret_key
18
+ attribute :user
19
+
20
+ # (docerror :undocumented)
21
+ attribute :state
22
+ attribute :activation
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ module Enstratus::Admin
2
+ class BillingCode < Enstratus::Resource
3
+ collects_as :billingCodes
4
+
5
+ attribute :billing_code_id
6
+ attribute :status
7
+
8
+ # elements
9
+ attribute :budget_state
10
+ attribute :customer
11
+ attribute :current_usage
12
+ attribute :description
13
+ attribute :finance_code
14
+ attribute :hard_quota
15
+ attribute :name
16
+ attribute :projected_usage
17
+ attribute :soft_quota
18
+
19
+
20
+ end
21
+ end
@@ -0,0 +1,25 @@
1
+ module Enstratus::Admin
2
+ class Customer < Enstratus::Resource
3
+
4
+ attribute :customer_id
5
+ attribute :status
6
+
7
+ # elements
8
+ attribute :admin_email
9
+ attribute :admin_first_name
10
+ attribute :admin_last_name
11
+ attribute :admin_password
12
+ attribute :admin_time_zone
13
+ attribute :accounting_currency
14
+ attribute :accounts
15
+ attribute :automated_exchange_rates
16
+ attribute :created
17
+ attribute :name
18
+ attribute :time_zone
19
+
20
+ # (docerror :undocumented)
21
+ attribute :business_name
22
+ attribute :created_timestamp
23
+ attribute :web_site
24
+ end
25
+ end
@@ -0,0 +1,12 @@
1
+ module Enstratus::Admin
2
+ class Group < Enstratus::Resource
3
+
4
+ attribute :group_id
5
+ attribute :status
6
+
7
+ # elements
8
+ attribute :customer
9
+ attribute :description
10
+ attribute :name
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ module Enstratus::Admin
2
+ class Job < Enstratus::Resource
3
+
4
+ attribute :job_id
5
+ attribute :status
6
+
7
+ # elements
8
+ attribute :description
9
+ attribute :end_date
10
+ attribute :message
11
+
12
+ # (docerror :undocumented)
13
+ attribute :start_date
14
+
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ module Enstratus::Admin
2
+ class Role < Enstratus::Resource
3
+
4
+ attribute :role_id
5
+ attribute :status
6
+
7
+ # elements
8
+ attribute :acl
9
+ attribute :customer
10
+ attribute :description
11
+ attribute :name
12
+ end
13
+ end