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,18 +1,3 @@
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
2
  class ComponentsCollection
18
3
  include Enumerable
@@ -1,18 +1,3 @@
1
- # Copyright:: Copyright (c) 2012, 2014 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
2
  class DomainsCollection
18
3
  include Enumerable
@@ -103,7 +88,7 @@ module Megam
103
88
 
104
89
 
105
90
  def to_s
106
- @domains.join(", ")
91
+ @domains.join(", ")
107
92
  end
108
93
 
109
94
  def for_json
@@ -1,134 +1,118 @@
1
- # Copyright:: Copyright (c) 2013-2016 Megam Systems, Inc.
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 Domains < Megam::RestAdapter
18
- def initialize(o)
19
- @id = nil
20
- @org_id = nil
21
- @name = nil
22
- @created_at = nil
23
- super(o)
2
+ class Domains < Megam::RestAdapter
3
+ def initialize(o)
4
+ @id = nil
5
+ @org_id = nil
6
+ @name = nil
7
+ @created_at = nil
8
+ super(o)
9
+ end
10
+
11
+ def domain
12
+ self
13
+ end
14
+
15
+ def id(arg=nil)
16
+ if arg != nil
17
+ @id = arg
18
+ else
19
+ @id
20
+ end
21
+ end
22
+ def org_id(arg=nil)
23
+ if arg != nil
24
+ @org_id = arg
25
+ else
26
+ @org_id
27
+ end
28
+ end
29
+
30
+
31
+ def name(arg=nil)
32
+ if arg != nil
33
+ @name = arg
34
+ else
35
+ @name
36
+ end
37
+ end
38
+
39
+ def created_at(arg=nil)
40
+ if arg != nil
41
+ @created_at = arg
42
+ else
43
+ @created_at
44
+ end
45
+ end
46
+
47
+ def to_hash
48
+ index_hash = Hash.new
49
+ index_hash["json_claz"] = self.class.name
50
+ index_hash["id"] = id
51
+ index_hash["org_id"] = org_id
52
+ index_hash["name"] = name
53
+ index_hash["created_at"] = created_at
54
+ index_hash
55
+ end
56
+
57
+ def to_json(*a)
58
+ for_json.to_json(*a)
59
+ end
60
+
61
+ def for_json
62
+ result = {
63
+ "id" => id,
64
+ "org_id" => org_id,
65
+ "name" => name,
66
+ "created_at" => created_at
67
+ }
68
+ result
69
+ end
70
+
71
+ # Create a Megam::Domains from JSON (used by the backgroud job workers)
72
+ def self.json_create(o)
73
+ dmn = new({})
74
+ dmn.id(o["id"]) if o.has_key?("id")
75
+ dmn.org_id(o["org_id"]) if o.has_key?("org_id")
76
+ dmn.name(o["name"]) if o.has_key?("name")
77
+ dmn.created_at(o["created_at"]) if o.has_key?("created_at")
78
+ dmn
79
+ end
80
+
81
+ def self.from_hash(o)
82
+ org = self.new(o)
83
+ org.from_hash(o)
84
+ org
85
+ end
86
+
87
+
88
+ def from_hash(o)
89
+ @id = o[:id] if o.has_key?(:id)
90
+ @org_id = o[:org_id] if o.has_key?(:org_id)
91
+ @name = o[:name] if o.has_key?(:name)
92
+ @created_at = o[:created_at] if o.has_key?(:created_at)
93
+ self
94
+ end
95
+
96
+ def self.create(o)
97
+ dom = from_hash(o)
98
+ dom.create
99
+ end
100
+
101
+ def self.list(o)
102
+ dom = from_hash(o)
103
+ dom.megam_rest.get_domains
104
+ end
105
+
106
+ def create
107
+ megam_rest.post_domains(to_hash)
108
+ end
109
+
110
+ def show
111
+ megam_rest.get_domains(to_hash)
112
+ end
113
+
114
+ def to_s
115
+ Megam::Stuff.styled_hash(to_hash)
116
+ end
24
117
  end
25
-
26
- def domain
27
- self
28
- end
29
-
30
- def id(arg=nil)
31
- if arg != nil
32
- @id = arg
33
- else
34
- @id
35
- end
36
- end
37
-
38
- def org_id(arg=nil)
39
- if arg != nil
40
- @org_id = arg
41
- else
42
- @org_id
43
- end
44
- end
45
-
46
-
47
- def name(arg=nil)
48
- if arg != nil
49
- @name = arg
50
- else
51
- @name
52
- end
53
- end
54
-
55
- def created_at(arg=nil)
56
- if arg != nil
57
- @created_at = arg
58
- else
59
- @created_at
60
- end
61
- end
62
-
63
- def to_hash
64
- index_hash = Hash.new
65
- index_hash["json_claz"] = self.class.name
66
- index_hash["id"] = id
67
- index_hash["org_id"] = org_id
68
- index_hash["name"] = name
69
- index_hash["created_at"] = created_at
70
- index_hash
71
- end
72
-
73
- def to_json(*a)
74
- for_json.to_json(*a)
75
- end
76
-
77
- def for_json
78
- result = {
79
- "id" => id,
80
- "org_id" => org_id,
81
- "name" => name,
82
- "created_at" => created_at
83
- }
84
- result
85
- end
86
-
87
- # Create a Megam::Domains from JSON (used by the backgroud job workers)
88
- def self.json_create(o)
89
- dmn = new({})
90
- dmn.id(o["id"]) if o.has_key?("id")
91
- dmn.org_id(o["org_id"]) if o.has_key?("org_id")
92
- dmn.name(o["name"]) if o.has_key?("name")
93
- dmn.created_at(o["created_at"]) if o.has_key?("created_at")
94
- dmn
95
- end
96
-
97
- def self.from_hash(o)
98
- org = self.new(o)
99
- org.from_hash(o)
100
- org
101
- end
102
-
103
-
104
- def from_hash(o)
105
- @id = o[:id] if o.has_key?(:id)
106
- @org_id = o[:org_id] if o.has_key?(:org_id)
107
- @name = o[:name] if o.has_key?(:name)
108
- @created_at = o[:created_at] if o.has_key?(:created_at)
109
- self
110
- end
111
-
112
- def self.create(o)
113
- dom = from_hash(o)
114
- dom.create
115
- end
116
-
117
- def self.list(o)
118
- dom = from_hash(o)
119
- dom.megam_rest.get_domains
120
- end
121
-
122
- def create
123
- megam_rest.post_domains(to_hash)
124
- end
125
-
126
- def show
127
- megam_rest.get_domains(to_hash)
128
- end
129
-
130
- def to_s
131
- Megam::Stuff.styled_hash(to_hash)
132
- end
133
- end
134
118
  end
@@ -1,85 +1,70 @@
1
- # Copyright:: Copyright (c) 2013-2016 Megam Systems, Inc.
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 Error
2
+ class Error
18
3
 
19
- def initialize
20
- @some_msg = {}
21
- end
4
+ def initialize
5
+ @some_msg = {}
6
+ end
22
7
 
23
8
 
24
- def some_msg(arg=nil)
25
- if arg != nil
26
- @some_msg = arg
27
- else
28
- @some_msg
29
- end
30
- end
9
+ def some_msg(arg=nil)
10
+ if arg != nil
11
+ @some_msg = arg
12
+ else
13
+ @some_msg
14
+ end
15
+ end
31
16
 
32
- def error?
33
- crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
34
- end
17
+ def error?
18
+ crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
19
+ end
35
20
 
36
- # Transform the ruby obj -> to a Hash
37
- def to_hash
38
- index_hash = Hash.new
39
- index_hash["json_claz"] = self.class.name
40
- index_hash["some_msg"] = some_msg
41
- index_hash
42
- end
21
+ # Transform the ruby obj -> to a Hash
22
+ def to_hash
23
+ index_hash = Hash.new
24
+ index_hash["json_claz"] = self.class.name
25
+ index_hash["some_msg"] = some_msg
26
+ index_hash
27
+ end
43
28
 
44
- # Serialize this object as a hash: called from JsonCompat.
45
- # Verify if this called from JsonCompat during testing.
46
- def to_json(*a)
47
- for_json.to_json(*a)
48
- end
29
+ # Serialize this object as a hash: called from JsonCompat.
30
+ # Verify if this called from JsonCompat during testing.
31
+ def to_json(*a)
32
+ for_json.to_json(*a)
33
+ end
49
34
 
50
- def for_json
51
- result = { }
52
- result
53
- end
35
+ def for_json
36
+ result = { }
37
+ result
38
+ end
54
39
 
55
- # Create a Megam::Account from JSON (used by the backgroud job workers)
56
- def self.json_create(o)
57
- acct = new
58
- acct.some_msg[:code] = o["code"] if o.has_key?("code")
59
- acct.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
60
- acct.some_msg[:msg]= o["msg"] if o.has_key?("msg")
61
- acct.some_msg[:links] = o["links"] if o.has_key?("links")
62
- acct
63
- end
40
+ # Create a Megam::Account from JSON (used by the backgroud job workers)
41
+ def self.json_create(o)
42
+ acct = new
43
+ acct.some_msg[:code] = o["code"] if o.has_key?("code")
44
+ acct.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
45
+ acct.some_msg[:msg]= o["msg"] if o.has_key?("msg")
46
+ acct.some_msg[:links] = o["links"] if o.has_key?("links")
47
+ acct
48
+ end
64
49
 
65
- def self.from_hash(o)
66
- acct = self.new()
67
- acct.from_hash(o)
68
- acct
69
- end
50
+ def self.from_hash(o)
51
+ acct = self.new()
52
+ acct.from_hash(o)
53
+ acct
54
+ end
70
55
 
71
- def from_hash(o)
72
- @some_msg[:code] = o["code"] if o.has_key?("code")
73
- @some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
74
- @some_msg[:msg]= o["msg"] if o.has_key?("msg")
75
- @some_msg[:links] = o["links"] if o.has_key?("links")
76
- self
77
- end
56
+ def from_hash(o)
57
+ @some_msg[:code] = o["code"] if o.has_key?("code")
58
+ @some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
59
+ @some_msg[:msg]= o["msg"] if o.has_key?("msg")
60
+ @some_msg[:links] = o["links"] if o.has_key?("links")
61
+ self
62
+ end
78
63
 
79
64
 
80
- def to_s
81
- Megam::Stuff.styled_hash(to_hash)
82
- #"---> Megam::Account:[error=#{error?}]\n"+
65
+ def to_s
66
+ Megam::Stuff.styled_hash(to_hash)
67
+ #"---> Megam::Account:[error=#{error?}]\n"+
68
+ end
83
69
  end
84
- end
85
70
  end
@@ -1,19 +1,3 @@
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
-
17
1
  module Megam
18
2
  class EventsBilling < Megam::RestAdapter
19
3
  def initialize(o)