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 MarketPlaceCollection
18
3
  include Enumerable
@@ -1,19 +1,3 @@
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
-
17
1
  module Megam
18
2
  class Organizations < Megam::RestAdapter
19
3
  def initialize(o)
@@ -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 OrganizationsCollection
18
3
  include Enumerable
@@ -1,18 +1,3 @@
1
- ##
2
- ## Copyright 2013-2016 Megam Systems
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 Promos < Megam::RestAdapter
18
3
  def initialize(email=nil, api_key=nil, host=nil)
@@ -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 Request < Megam::RestAdapter
18
3
  def initialize(params)
@@ -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 RequestCollection
18
3
  include Enumerable
@@ -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 RestAdapter
18
3
  attr_reader :email
@@ -1,157 +1,141 @@
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
- class Sensors < Megam::RestAdapter
19
- def initialize(email = nil, api_key = nil, host = nil)
20
- @id = nil
21
- @sensor_type = nil
22
- @payload = {}
23
- @created_at = nil
24
- super(email, api_key, host)
25
- end
26
-
27
- def sensors
28
- self
29
- end
30
-
31
- def id(arg = nil)
32
- if !arg.nil?
33
- @id = arg
34
- else
35
- @id
36
- end
37
- end
38
-
39
- def sensor_type(arg = nil)
40
- if !arg.nil?
41
- @sensor_type = arg
42
- else
43
- @sensor_type
44
- end
45
- end
46
-
47
- def payload(arg = nil)
48
- if !arg.nil?
49
- @payload = arg
50
- else
51
- @payload
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 error?
64
- crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error'
65
- end
66
-
67
- # Transform the ruby obj -> to a Hash
68
- def to_hash
69
- index_hash = {}
70
- index_hash['json_claz'] = self.class.name
71
- index_hash['id'] = id
72
-
73
- index_hash['sensor_type'] = sensor_type
74
- index_hash['payload'] = payload
75
- index_hash['created_at'] = created_at
76
- index_hash
77
- end
78
-
79
- # Serialize this object as a hash: called from JsonCompat.
80
- # Verify if this called from JsonCompat during testing.
81
- def to_json(*a)
82
- for_json.to_json(*a)
83
- end
84
-
85
- def for_json
86
- result = {
87
- 'id' => id,
88
- 'sensor_type' => sensor_type,
89
- 'payload' => payload,
90
- 'created_at' => created_at
91
- }
92
- result
93
- end
94
-
95
- def self.json_create(o)
96
- asm = new
97
- asm.id(o['id']) if o.key?('id')
98
- asm.sensor_type(o['sensor_type']) if o.key?('sensor_type')
99
- asm.payload(o['payload']) if o.key?('payload')
100
- asm.created_at(o['created_at']) if o.key?('created_at')
101
- asm
102
- end
103
-
104
- def self.from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil)
105
- asm = new(tmp_email, tmp_api_key, tmp_host)
106
- asm.from_hash(o)
107
- asm
108
- end
109
-
110
- def from_hash(o)
111
- @id = o['id'] if o.key?('id')
112
- @sensor_type = o['sensor_type'] if o.key?('sensor_type')
113
- @payload = o['payload'] if o.key?('payload')
114
- @created_at = o['created_at'] if o.key?('created_at')
115
- self
116
- end
117
-
118
- def self.create(params)
119
- sensors = from_hash(params, params['email'], params['api_key'], params['host'])
120
- sensors.create
121
- end
122
-
123
- # Load a account by email_p
124
- def self.show(params)
125
- sensors = new(params['email'], params['api_key'], params['host'])
126
- sensors.megam_rest.get_sensor(params['id'])
127
- end
128
-
129
- def self.list(params)
130
- sensors = self.new(params["email"], params["api_key"], params["host"])
131
- sensors.megam_rest.get_sensors
132
- end
133
-
134
- def self.update(params)
135
- sensors = from_hash(params, params['email'] || params[:email], params['api_key'] || params[:api_key], params['host'] || params[:host])
136
- sensors.update
137
- end
138
-
139
- def self.list(o)
140
- app = self.new(o["email"], o["api_key"], o["host"])
141
- app.megam_rest.get_sensors
142
- end
143
-
144
- # Create the node via the REST API
145
- def update
146
- megam_rest.update_(to_hash)
147
- end
148
-
149
- def create
150
- megam_rest.post_sensors(to_hash)
151
- end
152
-
153
- def to_s
154
- Megam::Stuff.styled_hash(to_hash)
2
+ class Sensors < Megam::RestAdapter
3
+ def initialize(email = nil, api_key = nil, host = nil)
4
+ @id = nil
5
+ @sensor_type = nil
6
+ @payload = {}
7
+ @created_at = nil
8
+ super(email, api_key, host)
9
+ end
10
+
11
+ def sensors
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
+
23
+ def sensor_type(arg = nil)
24
+ if !arg.nil?
25
+ @sensor_type = arg
26
+ else
27
+ @sensor_type
28
+ end
29
+ end
30
+
31
+ def payload(arg = nil)
32
+ if !arg.nil?
33
+ @payload = arg
34
+ else
35
+ @payload
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 error?
48
+ crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error'
49
+ end
50
+
51
+ # Transform the ruby obj -> to a Hash
52
+ def to_hash
53
+ index_hash = {}
54
+ index_hash['json_claz'] = self.class.name
55
+ index_hash['id'] = id
56
+
57
+ index_hash['sensor_type'] = sensor_type
58
+ index_hash['payload'] = payload
59
+ index_hash['created_at'] = created_at
60
+ index_hash
61
+ end
62
+
63
+ # Serialize this object as a hash: called from JsonCompat.
64
+ # Verify if this called from JsonCompat during testing.
65
+ def to_json(*a)
66
+ for_json.to_json(*a)
67
+ end
68
+
69
+ def for_json
70
+ result = {
71
+ 'id' => id,
72
+ 'sensor_type' => sensor_type,
73
+ 'payload' => payload,
74
+ 'created_at' => created_at
75
+ }
76
+ result
77
+ end
78
+
79
+ def self.json_create(o)
80
+ asm = new
81
+ asm.id(o['id']) if o.key?('id')
82
+ asm.sensor_type(o['sensor_type']) if o.key?('sensor_type')
83
+ asm.payload(o['payload']) if o.key?('payload')
84
+ asm.created_at(o['created_at']) if o.key?('created_at')
85
+ asm
86
+ end
87
+
88
+ def self.from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil)
89
+ asm = new(tmp_email, tmp_api_key, tmp_host)
90
+ asm.from_hash(o)
91
+ asm
92
+ end
93
+
94
+ def from_hash(o)
95
+ @id = o['id'] if o.key?('id')
96
+ @sensor_type = o['sensor_type'] if o.key?('sensor_type')
97
+ @payload = o['payload'] if o.key?('payload')
98
+ @created_at = o['created_at'] if o.key?('created_at')
99
+ self
100
+ end
101
+
102
+ def self.create(params)
103
+ sensors = from_hash(params, params['email'], params['api_key'], params['host'])
104
+ sensors.create
105
+ end
106
+
107
+ # Load a account by email_p
108
+ def self.show(params)
109
+ sensors = new(params['email'], params['api_key'], params['host'])
110
+ sensors.megam_rest.get_sensor(params['id'])
111
+ end
112
+
113
+ def self.list(params)
114
+ sensors = self.new(params["email"], params["api_key"], params["host"])
115
+ sensors.megam_rest.get_sensors
116
+ end
117
+
118
+ def self.update(params)
119
+ sensors = from_hash(params, params['email'] || params[:email], params['api_key'] || params[:api_key], params['host'] || params[:host])
120
+ sensors.update
121
+ end
122
+
123
+ def self.list(o)
124
+ app = self.new(o["email"], o["api_key"], o["host"])
125
+ app.megam_rest.get_sensors
126
+ end
127
+
128
+ # Create the node via the REST API
129
+ def update
130
+ megam_rest.update_(to_hash)
131
+ end
132
+
133
+ def create
134
+ megam_rest.post_sensors(to_hash)
135
+ end
136
+
137
+ def to_s
138
+ Megam::Stuff.styled_hash(to_hash)
139
+ end
155
140
  end
156
- end
157
141
  end
@@ -1,18 +1,3 @@
1
- ##
2
- ## Copyright 2013-2016 Megam Systems
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 SensorsCollection
18
3
  include Enumerable