megam_api 1.5.rc5 → 1.5.rc7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -2
  3. data/LICENSE +21 -202
  4. data/README.md +3 -20
  5. data/lib/megam/api.rb +154 -169
  6. data/lib/megam/api/accounts.rb +0 -15
  7. data/lib/megam/api/assemblies.rb +0 -15
  8. data/lib/megam/api/assembly.rb +0 -15
  9. data/lib/megam/api/balances.rb +0 -15
  10. data/lib/megam/api/billedhistories.rb +0 -15
  11. data/lib/megam/api/billingtransactions.rb +0 -15
  12. data/lib/megam/api/components.rb +0 -15
  13. data/lib/megam/api/domains.rb +0 -15
  14. data/lib/megam/api/errors.rb +0 -15
  15. data/lib/megam/api/eventsbilling.rb +0 -15
  16. data/lib/megam/api/eventscontainer.rb +0 -15
  17. data/lib/megam/api/eventsstorage.rb +0 -15
  18. data/lib/megam/api/eventsvm.rb +0 -15
  19. data/lib/megam/api/marketplaces.rb +0 -15
  20. data/lib/megam/api/organizations.rb +0 -15
  21. data/lib/megam/api/promos.rb +0 -15
  22. data/lib/megam/api/requests.rb +0 -15
  23. data/lib/megam/api/sensors.rb +0 -15
  24. data/lib/megam/api/snapshots.rb +0 -15
  25. data/lib/megam/api/sshkeys.rb +0 -15
  26. data/lib/megam/api/version.rb +1 -16
  27. data/lib/megam/core/account.rb +241 -60
  28. data/lib/megam/core/assemblies.rb +0 -16
  29. data/lib/megam/core/assemblies_collection.rb +101 -116
  30. data/lib/megam/core/assembly.rb +201 -218
  31. data/lib/megam/core/assembly_collection.rb +101 -116
  32. data/lib/megam/core/balances.rb +182 -197
  33. data/lib/megam/core/balances_collection.rb +101 -116
  34. data/lib/megam/core/billedhistories.rb +186 -201
  35. data/lib/megam/core/billedhistories_collection.rb +101 -116
  36. data/lib/megam/core/billingtransactions.rb +0 -15
  37. data/lib/megam/core/billingtransactions_collection.rb +0 -15
  38. data/lib/megam/core/components.rb +300 -316
  39. data/lib/megam/core/components_collection.rb +0 -15
  40. data/lib/megam/core/domain_collection.rb +1 -16
  41. data/lib/megam/core/domains.rb +115 -131
  42. data/lib/megam/core/error.rb +55 -70
  43. data/lib/megam/core/eventsbilling.rb +0 -16
  44. data/lib/megam/core/eventsbilling_collection.rb +101 -116
  45. data/lib/megam/core/eventscontainer.rb +0 -16
  46. data/lib/megam/core/eventscontainer_collection.rb +101 -116
  47. data/lib/megam/core/eventsstorage.rb +0 -16
  48. data/lib/megam/core/eventsstorage_collection.rb +0 -15
  49. data/lib/megam/core/eventsvm.rb +0 -16
  50. data/lib/megam/core/eventsvm_collection.rb +101 -116
  51. data/lib/megam/core/json_compat.rb +0 -12
  52. data/lib/megam/core/konipai.rb +0 -15
  53. data/lib/megam/core/log.rb +0 -15
  54. data/lib/megam/core/marketplace.rb +224 -241
  55. data/lib/megam/core/marketplace_collection.rb +0 -15
  56. data/lib/megam/core/organizations.rb +0 -16
  57. data/lib/megam/core/organizations_collection.rb +0 -15
  58. data/lib/megam/core/promos.rb +0 -15
  59. data/lib/megam/core/request.rb +0 -15
  60. data/lib/megam/core/request_collection.rb +0 -15
  61. data/lib/megam/core/rest_adapter.rb +0 -15
  62. data/lib/megam/core/sensors.rb +138 -154
  63. data/lib/megam/core/sensors_collection.rb +0 -15
  64. data/lib/megam/core/snapshots.rb +0 -16
  65. data/lib/megam/core/snapshots_collection.rb +0 -15
  66. data/lib/megam/core/sshkey.rb +169 -184
  67. data/lib/megam/core/sshkey_collection.rb +0 -15
  68. data/lib/megam/core/stuff.rb +17 -32
  69. data/lib/megam/core/text.rb +82 -97
  70. data/lib/megam/mixins/assemblies.rb +10 -25
  71. data/lib/megam/mixins/assembly.rb +33 -49
  72. data/lib/megam/mixins/common_deployable.rb +64 -79
  73. data/lib/megam/mixins/components.rb +160 -175
  74. data/lib/megam/mixins/megam_attributes.rb +22 -37
  75. data/lib/megam/mixins/outputs.rb +14 -29
  76. data/lib/megam/mixins/policies.rb +21 -36
  77. data/lib/megam_api.rb +0 -15
  78. data/test/mixins/test_assemblies.rb +1 -2
  79. data/test/test_accounts.rb +84 -29
  80. data/test/test_billingtranscations.rb +17 -21
  81. data/test/test_eventscontainer.rb +19 -23
  82. data/test/test_eventsstorage.rb +8 -10
  83. data/test/test_eventsvm.rb +19 -23
  84. data/test/test_helper.rb +30 -30
  85. data/test/test_snapshots.rb +16 -22
  86. metadata +2 -2
@@ -1,42 +1,27 @@
1
- # Copyright:: Copyright (c) 2013-2016 Megam Systems
2
- # License:: Apache License, Version 2.0
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
1
  module Megam
17
- class Mixins
18
- class Policies
19
- attr_reader :bind_type, :policymembers
2
+ class Mixins
3
+ class Policies
4
+ attr_reader :bind_type, :policymembers
20
5
 
21
- def initialize(params)
22
- @bind_type = params[:bind_type] if params.key?(:bind_type)
23
- @policymembers = params[:policymembers] if params.key?(:policymembers)
24
- end
6
+ def initialize(params)
7
+ @bind_type = params[:bind_type] if params.key?(:bind_type)
8
+ @policymembers = params[:policymembers] if params.key?(:policymembers)
9
+ end
25
10
 
26
- def to_array
27
- com = []
28
- if @bind_type && @bind_type != 'Unbound service'
29
- value = {
30
- name: 'bind policy',
31
- ptype: 'colocated',
32
- members: [
33
- @policymembers
34
- ]
35
- }
36
- com << value
11
+ def to_array
12
+ com = []
13
+ if @bind_type && @bind_type != 'Unbound service'
14
+ value = {
15
+ name: 'bind policy',
16
+ ptype: 'colocated',
17
+ members: [
18
+ @policymembers
19
+ ]
20
+ }
21
+ com << value
22
+ end
23
+ com
24
+ end
37
25
  end
38
- com
39
- end
40
26
  end
41
- end
42
27
  end
data/lib/megam_api.rb CHANGED
@@ -1,16 +1 @@
1
- # Copyright:: Copyright (c) 2013-2016 Megam Systems
2
- # License:: Apache License, Version 2.0
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
1
  require(File.join(File.dirname(__FILE__), "megam", "api"))
@@ -7,7 +7,6 @@ require File.expand_path("#{File.dirname(__FILE__)}/../../lib/megam/mixins/assem
7
7
  require File.expand_path("#{File.dirname(__FILE__)}/../../lib/megam/mixins/components")
8
8
  class TestMixinsAssemblies < MiniTest::Unit::TestCase
9
9
 
10
- #=begin
11
10
  def test_torpedo
12
11
  ## input the torpedo hash
13
12
  tmp_hash = {"utf8"=>"✓", "mkp_name" => "ubuntu", "cattype":"TORPEDO", "version":"14.04", "assemblyname"=>"biblical", "domain"=>"megambox.com", "ram"=>"896", "cpu"=>"0.5", "SSH_USEOLD_name"=>"tom", "SSH_NEW_name"=>"", "sshoption"=>"SSH_USEOLD", "provider"=>"one", "componentname"=>"ovid", "commit"=>" Create ", "controller"=>"marketplaces", "action"=>"create", "email"=>"8@8.com", "api_key"=>"-NQi-aSKHcmKntCsXb03jw==", "host"=>"192.168.1.105", "org_id"=>"ORG1270367691894554624", "ssh_keypair_name"=>"tom", "name"=>"tom", "path"=>"8@8.com_tom"}
@@ -25,7 +24,7 @@ puts assembly_array.inspect
25
24
  #response = megams.post_billings(tmp_hash)
26
25
  #assert_equal(201, response.status)
27
26
  end
28
- #=end
27
+
29
28
  =begin
30
29
  def test_app_starterpack
31
30
  ## input the torpedo hash
@@ -14,32 +14,57 @@ def test_signin_auth
14
14
  end
15
15
 
16
16
  =end
17
- =begin
18
-
19
-
20
-
17
+ #=begin
21
18
  def test_get_accounts_good
22
- response =megams.get_accounts(sandbox_email)
19
+ response =megams.get_accounts("coolvader123@iamswag.com")
23
20
  response.body.to_s
24
21
  assert_equal(200, response.status)
25
22
  end
26
-
27
- =begin
28
-
29
-
23
+ #=end
24
+ #=begin
30
25
  def test_post_accounts_good
31
26
  tmp_hash = {
32
27
  "id" => "000099090909000",
33
- "first_name" => "Darth",
34
- "last_name" => "Vader",
35
- "email" => "coolvader@iamswag.com",
36
- "phone" => "19090909090",
28
+ "email" => "coolvader123@iamswag.com",
37
29
  "api_key" => "faketest",
38
- "authority" => "admin",
39
- "password" => "",
40
- "password_reset_key" => "",
41
- "password_reset_sent_at" => "",
42
- "created_at" => "2014-10-29 13:24:06 +0000"
30
+ "name" => {
31
+ "first_name" => "Darth",
32
+ "last_name" => "Vader"
33
+ },
34
+ "phone" => {
35
+ "phone" => "1908877643",
36
+ "phone_verified" => "verified"
37
+ },
38
+ "password" => {
39
+ "password" => "user",
40
+ "password_reset_key" => "",
41
+ "password_reset_sent_at" => ""
42
+ },
43
+ "states" => {
44
+ "authority" => "admin",
45
+ "active" => "active",
46
+ "blocked" => "blocked",
47
+ "staged" => ""
48
+ },
49
+ "approval" => {
50
+ "approved" => "approved",
51
+ "approved_by_id" => "",
52
+ "approved_at" => ""
53
+ },
54
+ "suspend" => {
55
+ "suspended" => "suspended",
56
+ "suspended_at" => "",
57
+ "suspended_till" => ""
58
+ },
59
+ "registration_ip_address" => "",
60
+ "dates" => {
61
+ "last_posted_at" => "",
62
+ "last_emailed_at" => "",
63
+ "previous_visit_at" => "",
64
+ "first_seen_at" => "",
65
+ "created_at" => "2014-10-29 13:24:06 +0000"
66
+ }
67
+
43
68
  }
44
69
  response =megams.post_accounts(tmp_hash)
45
70
  response.body.to_s
@@ -49,19 +74,49 @@ end
49
74
 
50
75
  =begin
51
76
  def test_update_accounts_good
52
- tmp_hash = {
53
- "id" => "w3423",
77
+ tmp_hash = {
78
+ "id" => "000099090909000",
79
+ "email" => "coolvader@iamswag.com",
80
+ "api_key" => "faketest",
81
+ "name" => {
54
82
  "first_name" => "Darth",
55
- "last_name" => "Vader",
56
- "email" => "super@test.com",
57
- "phone" => "19090909090011111111",
58
- "api_key" => "IamAtlas{74}NobdyCanSedfefdeME#07",
59
- "authority" => "admin",
60
- "password" => "tset",
83
+ "last_name" => "Vader"
84
+ },
85
+ "phone" => {
86
+ "phone" => "345566",
87
+ "phone_verified" => "verified"
88
+ },
89
+ "password" => {
90
+ "password" => "admin",
61
91
  "password_reset_key" => "",
62
- "password_reset_sent_at" => "",
63
- "created_at" => "2014-10-29 13:24:06 +0000"
64
- }
92
+ "password_reset_sent_at" => ""
93
+ },
94
+ "states" => {
95
+ "authority" => "admin",
96
+ "active" => "not",
97
+ "blocked" => "blocked",
98
+ "staged" => ""
99
+ },
100
+ "approval" => {
101
+ "approved" => "approved",
102
+ "approved_by_id" => "",
103
+ "approved_at" => ""
104
+ },
105
+ "suspend" => {
106
+ "suspended" => "suspended",
107
+ "suspended_at" => "",
108
+ "suspended_till" => ""
109
+ },
110
+ "registration_ip_address" => "",
111
+ "dates" => {
112
+ "last_posted_at" => "",
113
+ "last_emailed_at" => "",
114
+ "previous_visit_at" => "",
115
+ "first_seen_at" => "",
116
+ "created_at" => "2014-10-29 13:24:06 +0000"
117
+ }
118
+
119
+ }
65
120
  response = megams.update_accounts(tmp_hash)
66
121
  response.body.to_s
67
122
  assert_equal(201, response.status)
@@ -1,27 +1,23 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
- #=begin
5
- def test_post_billingtransactions
6
- tmp_hash = { :accounts_id => "5555555",
7
- :gateway => "paypal",
8
- :amountin => "5",
9
- :amountout => "5.99",
10
- :fees => "0.99",
11
- :tranid => "HGH111",
12
- :trandate => "31/21/2012",
13
- :currency_type => "USD"
14
- }
4
+ def test_post_billingtransactions
5
+ tmp_hash = { :accounts_id => "5555555",
6
+ :gateway => "paypal",
7
+ :amountin => "5",
8
+ :amountout => "5.99",
9
+ :fees => "0.99",
10
+ :tranid => "HGH111",
11
+ :trandate => "31/21/2012",
12
+ :currency_type => "USD"
13
+ }
15
14
 
16
- response = megams.post_billingtransactions(tmp_hash)
17
- assert_equal(201, response.status)
18
- end
19
- #=end
15
+ response = megams.post_billingtransactions(tmp_hash)
16
+ assert_equal(201, response.status)
17
+ end
20
18
 
21
- #=begin
22
- def test_get_billingtransactions
23
- response = megams.get_billingtransactions
24
- assert_equal(200, response.status)
25
- end
26
- #=end
19
+ def test_get_billingtransactions
20
+ response = megams.get_billingtransactions
21
+ assert_equal(200, response.status)
22
+ end
27
23
  end
@@ -2,29 +2,25 @@ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
4
 
5
- #=begin
6
- def test_get_eventscontainer
7
- tmp_hash = {
8
- "account_id" => "",
9
- "created_at" => "2016-05-05 10:57:30 +0000",
10
- "assembly_id" => "ASM9038606864211614815",
11
- "event_type" => "",
12
- "data" => []
13
- }
14
- response = megams.get_eventscontainer("0", tmp_hash)
5
+ def test_get_eventscontainer
6
+ tmp_hash = {
7
+ "account_id" => "",
8
+ "created_at" => "2016-05-05 10:57:30 +0000",
9
+ "assembly_id" => "ASM9038606864211614815",
10
+ "event_type" => "",
11
+ "data" => []
12
+ }
13
+ response = megams.get_eventscontainer("0", tmp_hash)
15
14
 
16
- assert_equal(200, response.status)
17
- end
15
+ assert_equal(200, response.status)
16
+ end
18
17
 
19
- #=end
20
- #=begin
21
- def test_list_eventscontainer
22
- response = megams.list_eventscontainer("0")
23
- assert_equal(200, response.status)
24
- end
25
- def test_index_eventscontainer
26
- response = megams.index_eventscontainer
27
- assert_equal(200, response.status)
28
- end
29
- #=end
18
+ def test_list_eventscontainer
19
+ response = megams.list_eventscontainer("0")
20
+ assert_equal(200, response.status)
21
+ end
22
+ def test_index_eventscontainer
23
+ response = megams.index_eventscontainer
24
+ assert_equal(200, response.status)
25
+ end
30
26
  end
@@ -1,14 +1,12 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
- #=begin
5
- def test_list_eventsstorage
6
- response = megams.list_eventsstorage("0")
7
- assert_equal(200, response.status)
8
- end
9
- def test_index_eventsstorage
10
- response = megams.index_eventsstorage
11
- assert_equal(200, response.status)
12
- end
13
- #=end
4
+ def test_list_eventsstorage
5
+ response = megams.list_eventsstorage("0")
6
+ assert_equal(200, response.status)
7
+ end
8
+ def test_index_eventsstorage
9
+ response = megams.index_eventsstorage
10
+ assert_equal(200, response.status)
11
+ end
14
12
  end
@@ -2,29 +2,25 @@ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
2
2
 
3
3
  class TestApps < MiniTest::Unit::TestCase
4
4
 
5
- #=begin
6
- def test_get_eventsvm
7
- tmp_hash = {
8
- "account_id" => "",
9
- "created_at" => "2016-05-05 10:57:30 +0000",
10
- "assembly_id" => "ASM9038606864211614815",
11
- "event_type" => "",
12
- "data" => []
13
- }
14
- response = megams.get_eventsvm("0", tmp_hash)
5
+ def test_get_eventsvm
6
+ tmp_hash = {
7
+ "account_id" => "",
8
+ "created_at" => "2016-05-05 10:57:30 +0000",
9
+ "assembly_id" => "ASM9038606864211614815",
10
+ "event_type" => "",
11
+ "data" => []
12
+ }
13
+ response = megams.get_eventsvm("0", tmp_hash)
15
14
 
16
- assert_equal(200, response.status)
17
- end
15
+ assert_equal(200, response.status)
16
+ end
18
17
 
19
- #=end
20
- #=begin
21
- def test_list_eventsvm
22
- response = megams.list_eventsvm("0")
23
- assert_equal(200, response.status)
24
- end
25
- def test_index_eventsvm
26
- response = megams.index_eventsvm
27
- assert_equal(200, response.status)
28
- end
29
- #=end
18
+ def test_list_eventsvm
19
+ response = megams.list_eventsvm("0")
20
+ assert_equal(200, response.status)
21
+ end
22
+ def test_index_eventsvm
23
+ response = megams.index_eventsvm
24
+ assert_equal(200, response.status)
25
+ end
30
26
  end
data/test/test_helper.rb CHANGED
@@ -6,73 +6,73 @@ require 'minitest/autorun'
6
6
  require 'time'
7
7
 
8
8
  SANDBOX_HOST_OPTIONS = {
9
- :scheme => 'http',
10
- :host => 'localhost',
11
- :nonblock => false,
12
- :port => 9000
9
+ :scheme => 'http',
10
+ :host => 'localhost',
11
+ :nonblock => false,
12
+ :port => 9000
13
13
  }
14
14
 
15
15
 
16
16
  def megam(options)
17
- options = SANDBOX_HOST_OPTIONS.merge(options)
18
- mg=Megam::API.new(options)
17
+ options = SANDBOX_HOST_OPTIONS.merge(options)
18
+ mg=Megam::API.new(options)
19
19
  end
20
20
 
21
21
  def megams_new(options={})
22
- s_options = SANDBOX_HOST_OPTIONS.merge({
23
- :email => "test@megam.io",
24
- :api_key => "faketest"
25
- })
26
- options = s_options.merge(options)
27
- mg=Megam::API.new(options)
22
+ s_options = SANDBOX_HOST_OPTIONS.merge({
23
+ :email => "test@megam.io",
24
+ :api_key => "faketest"
25
+ })
26
+ options = s_options.merge(options)
27
+ mg=Megam::API.new(options)
28
28
  end
29
29
 
30
30
  def megams(options={})
31
- s_options = SANDBOX_HOST_OPTIONS.merge({
32
- :email => "test@megam.io",
33
- :api_key => "IamAtlas{74}NobdyCanSedfefdeME#07",
34
- :org_id => "ORG123",
35
- #:password => "bWVnYW0="
36
- })
31
+ s_options = SANDBOX_HOST_OPTIONS.merge({
32
+ :email => "test@megam.io",
33
+ :api_key => "IamAtlas{74}NobdyCanSedfefdeME#07",
34
+ :org_id => "ORG123",
35
+ #:password => "bWVnYW0="
36
+ })
37
37
 
38
38
 
39
- Megam::Log.level(:debug)
40
- options = s_options.merge(options)
41
- mg=Megam::API.new(options)
39
+ Megam::Log.level(:debug)
40
+ options = s_options.merge(options)
41
+ mg=Megam::API.new(options)
42
42
  end
43
43
 
44
44
  def random_domain
45
- "megam.co"
45
+ "megam.co"
46
46
  end
47
47
 
48
48
  def random_id
49
- SecureRandom.random_number(1000)
49
+ SecureRandom.random_number(1000)
50
50
  end
51
51
 
52
52
  def random_name
53
- SecureRandom.hex(15)
53
+ SecureRandom.hex(15)
54
54
  end
55
55
 
56
56
  def random_apikey
57
- SecureRandom.hex(10)
57
+ SecureRandom.hex(10)
58
58
  end
59
59
 
60
60
  def random_email
61
- "email@#{random_apikey}.com"
61
+ "email@#{random_apikey}.com"
62
62
  end
63
63
 
64
64
  def domain_name
65
- "megambox.com"
65
+ "megambox.com"
66
66
  end
67
67
 
68
68
  def sandbox_name
69
- "org.megam"
69
+ "org.megam"
70
70
  end
71
71
 
72
72
  def sandbox_apikey
73
- "IamAtlas{74}NobdyCanSedfefdeME#07"
73
+ "IamAtlas{74}NobdyCanSedfefdeME#07"
74
74
  end
75
75
 
76
76
  def sandbox_email
77
- "tour@megam.io"
77
+ "tour@megam.io"
78
78
  end