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,182 +1,167 @@
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.expand_path("#{File.dirname(__FILE__)}/megam_attributes")
17
2
  require File.expand_path("#{File.dirname(__FILE__)}/common_deployable")
18
3
  require File.expand_path("#{File.dirname(__FILE__)}/outputs")
19
4
 
20
5
  module Megam
21
- class Mixins
22
- class Components
23
- attr_reader :mixins, :name, :repo, :related_components, :operations, :artifacts, :envs, :outputs, :id
24
- def initialize(params)
25
- @mixins = CommonDeployable.new(params)
26
- @id = params[:id] if params[:id]
27
- @name = params[:componentname] || params[:name] || ''
28
- @outputs = Outputs.new(params)
29
- @operations = add_operations(params)
30
- @related_components = add_related_components(params)
31
- @artifacts = add_artifacts(params)
32
- @repo = add_repo(params)
33
- @envs = params[:envs]
34
- end
35
-
36
- def to_hash
37
- result = @mixins.to_hash
38
- result[:id] = @id if @id
39
- result[:name] = @name if @name
40
- result[:artifacts] = @artifacts if @artifacts
41
- result[:repo] = @repo if @repo
42
- result[:operations] = @operations if @operations
43
- result[:outputs] = @outputs.to_array if @outputs
44
- result[:related_components] = @related_components if @related_components
45
- result[:envs] = @envs if @envs
46
- result.to_hash
47
- end
48
-
49
- def to_a
50
- [to_hash]
51
- end
52
-
53
- private
54
-
55
- def add_repo(params)
56
- Repo.new(params).tohash
57
- end
58
-
59
- def add_related_components(params)
60
- @related_components = []
61
- @related_components << "#{params[:bind_type]}" if params.key?(:bind_type)
62
- end
63
-
64
- def add_operations(params)
65
- operations = []
66
- operations.push(create_operation(Operations::CI, Operations::CI_DESCRIPTON, params)) if params.key?(:scm_name) && params.key?(:scmtoken)
67
- operations.push(create_operation(Operations::BIND, Operations::BIND_DESCRIPTON, params)) if params.key?(:bind_type)
68
- operations
69
- end
70
-
71
- def create_operation(type, desc, params)
72
- Operations.new(params, type, desc).tohash
73
- end
74
-
75
- def add_artifacts(params)
76
- Artifacts.new(params).tohash
77
- end
6
+ class Mixins
7
+ class Components
8
+ attr_reader :mixins, :name, :repo, :related_components, :operations, :artifacts, :envs, :outputs, :id
9
+ def initialize(params)
10
+ @mixins = CommonDeployable.new(params)
11
+ @id = params[:id] if params[:id]
12
+ @name = params[:componentname] || params[:name] || ''
13
+ @outputs = Outputs.new(params)
14
+ @operations = add_operations(params)
15
+ @related_components = add_related_components(params)
16
+ @artifacts = add_artifacts(params)
17
+ @repo = add_repo(params)
18
+ @envs = params[:envs]
19
+ end
20
+
21
+ def to_hash
22
+ result = @mixins.to_hash
23
+ result[:id] = @id if @id
24
+ result[:name] = @name if @name
25
+ result[:artifacts] = @artifacts if @artifacts
26
+ result[:repo] = @repo if @repo
27
+ result[:operations] = @operations if @operations
28
+ result[:outputs] = @outputs.to_array if @outputs
29
+ result[:related_components] = @related_components if @related_components
30
+ result[:envs] = @envs if @envs
31
+ result.to_hash
32
+ end
33
+
34
+ def to_a
35
+ [to_hash]
36
+ end
37
+
38
+ private
39
+
40
+ def add_repo(params)
41
+ Repo.new(params).tohash
42
+ end
43
+
44
+ def add_related_components(params)
45
+ @related_components = []
46
+ @related_components << "#{params[:bind_type]}" if params.key?(:bind_type)
47
+ end
48
+
49
+ def add_operations(params)
50
+ operations = []
51
+ operations.push(create_operation(Operations::CI, Operations::CI_DESCRIPTON, params)) if params.key?(:scm_name) && params.key?(:scmtoken)
52
+ operations.push(create_operation(Operations::BIND, Operations::BIND_DESCRIPTON, params)) if params.key?(:bind_type)
53
+ operations
54
+ end
55
+
56
+ def create_operation(type, desc, params)
57
+ Operations.new(params, type, desc).tohash
58
+ end
59
+
60
+ def add_artifacts(params)
61
+ Artifacts.new(params).tohash
62
+ end
63
+ end
64
+
65
+ class Repo
66
+ include Nilavu::MegamAttributes
67
+ attr_reader :type, :source, :url, :oneclick
68
+ ATTRIBUTES = [
69
+ :type,
70
+ :source,
71
+ :oneclick,
72
+ :url]
73
+
74
+ def attributes
75
+ ATTRIBUTES
76
+ end
77
+
78
+ def initialize(params)
79
+ set_attributes(params)
80
+ @type = params[:type] || ""
81
+ @source = params[:scm_name] || ""
82
+ @url = params[:source] || ""
83
+ @oneclick = params[:oneclick] || ""
84
+ end
85
+
86
+ def tohash
87
+ { rtype: @type,
88
+ source: @source,
89
+ oneclick: @oneclick,
90
+ url: @url
91
+ }
92
+ end
93
+ end
94
+
95
+ class Operations
96
+ include Nilavu::MegamAttributes
97
+ attr_reader :type, :desc, :prop, :status
98
+
99
+ ATTRIBUTES = [
100
+ :type,
101
+ :desc,
102
+ :prop,
103
+ :status]
104
+
105
+ def attributes
106
+ ATTRIBUTES
107
+ end
108
+
109
+ CI = 'CI'.freeze
110
+ CI_DESCRIPTON = 'always up to date code. sweet.'
111
+ NOTBOUND = "notbound".freeze
112
+ BIND = 'bind'.freeze
113
+ BIND_DESCRIPTON = 'bind. sweet.'
114
+
115
+ def initialize(params, type, desc)
116
+ @type = type
117
+ @desc = desc
118
+ @prop = prop(params)
119
+ end
120
+
121
+ def attributes
122
+ ATTRIBUTES
123
+ end
124
+
125
+ def tohash
126
+ { operation_type: @type,
127
+ description: @desc,
128
+ properties: @prop,
129
+ status: NOTBOUND
130
+ }
131
+ end
132
+
133
+ # Key_name mismatch. Key_name is to be changed.
134
+ def prop(params)
135
+ op = []
136
+ op << { 'key' => 'type', 'value' => params[:scm_name] } if params.key?(:scm_name)
137
+ op << { 'key' => 'token', 'value' => params[:scmtoken] } if params.key?(:scmtoken)
138
+ op << { 'key' => 'username', 'value' => params[:scmowner] } if params.key?(:scmowner)
139
+ op << { 'key' => 'related_component', 'value' => params[:bind_type] } if params.key?(:bind_type)
140
+ op
141
+ end
142
+ end
143
+
144
+ class Artifacts
145
+ include Nilavu::MegamAttributes
146
+ ATTRIBUTES = [
147
+ :type,
148
+ :content,
149
+ :requirements]
150
+
151
+ def attributes
152
+ ATTRIBUTES
153
+ end
154
+
155
+ def initialize(params)
156
+ set_attributes(params)
157
+ end
158
+
159
+ def tohash
160
+ { artifact_type: '',
161
+ content: '',
162
+ requirements: []
163
+ }
164
+ end
165
+ end
78
166
  end
79
-
80
- class Repo
81
- include Nilavu::MegamAttributes
82
- attr_reader :type, :source, :url, :oneclick
83
- ATTRIBUTES = [
84
- :type,
85
- :source,
86
- :oneclick,
87
- :url]
88
-
89
- def attributes
90
- ATTRIBUTES
91
- end
92
-
93
- def initialize(params)
94
- set_attributes(params)
95
- @type = params[:type] || ""
96
- @source = params[:scm_name] || ""
97
- @url = params[:source] || ""
98
- @oneclick = params[:oneclick] || ""
99
- end
100
-
101
- def tohash
102
- { rtype: @type,
103
- source: @source,
104
- oneclick: @oneclick,
105
- url: @url
106
- }
107
- end
108
- end
109
-
110
- class Operations
111
- include Nilavu::MegamAttributes
112
- attr_reader :type, :desc, :prop, :status
113
-
114
- ATTRIBUTES = [
115
- :type,
116
- :desc,
117
- :prop,
118
- :status]
119
-
120
- def attributes
121
- ATTRIBUTES
122
- end
123
-
124
- CI = 'CI'.freeze
125
- CI_DESCRIPTON = 'always up to date code. sweet.'
126
- NOTBOUND = "notbound".freeze
127
- BIND = 'bind'.freeze
128
- BIND_DESCRIPTON = 'bind. sweet.'
129
-
130
- def initialize(params, type, desc)
131
- @type = type
132
- @desc = desc
133
- @prop = prop(params)
134
- end
135
-
136
- def attributes
137
- ATTRIBUTES
138
- end
139
-
140
- def tohash
141
- { operation_type: @type,
142
- description: @desc,
143
- properties: @prop,
144
- status: NOTBOUND
145
- }
146
- end
147
-
148
- # Key_name mismatch. Key_name is to be changed.
149
- def prop(params)
150
- op = []
151
- op << { 'key' => 'type', 'value' => params[:scm_name] } if params.key?(:scm_name)
152
- op << { 'key' => 'token', 'value' => params[:scmtoken] } if params.key?(:scmtoken)
153
- op << { 'key' => 'username', 'value' => params[:scmowner] } if params.key?(:scmowner)
154
- op << { 'key' => 'related_component', 'value' => params[:bind_type] } if params.key?(:bind_type)
155
- op
156
- end
157
- end
158
-
159
- class Artifacts
160
- include Nilavu::MegamAttributes
161
- ATTRIBUTES = [
162
- :type,
163
- :content,
164
- :requirements]
165
-
166
- def attributes
167
- ATTRIBUTES
168
- end
169
-
170
- def initialize(params)
171
- set_attributes(params)
172
- end
173
-
174
- def tohash
175
- { artifact_type: '',
176
- content: '',
177
- requirements: []
178
- }
179
- end
180
- end
181
- end
182
167
  end
@@ -1,45 +1,30 @@
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 Nilavu
17
- module MegamAttributes
18
- ATTRIBUTES = []
19
- KEY = 'key'.freeze
20
- VALUE = 'value'.freeze
2
+ module MegamAttributes
3
+ ATTRIBUTES = []
4
+ KEY = 'key'.freeze
5
+ VALUE = 'value'.freeze
21
6
 
22
- attr_accessor *ATTRIBUTES
7
+ attr_accessor *ATTRIBUTES
23
8
 
24
- def attributes
25
- NotImplementedError
26
- end
9
+ def attributes
10
+ NotImplementedError
11
+ end
27
12
 
28
- def initialize(control_data = {})
29
- set_attributes(control_data)
30
- end
13
+ def initialize(control_data = {})
14
+ set_attributes(control_data)
15
+ end
31
16
 
32
- def set_attributes(control_data)
33
- attributes.each { |a| instance_variable_set("@#{a}", control_data[a]) unless control_data[a].nil? }
34
- end
17
+ def set_attributes(control_data)
18
+ attributes.each { |a| instance_variable_set("@#{a}", control_data[a]) unless control_data[a].nil? }
19
+ end
35
20
 
36
- def to_hash
37
- h = attributes.reduce([]) do |res, key|
38
- val = instance_variable_get("@#{key}".to_sym)
39
- res << { KEY => key.to_s, VALUE => val } unless val.nil?
40
- res
41
- end
42
- h
21
+ def to_hash
22
+ h = attributes.reduce([]) do |res, key|
23
+ val = instance_variable_get("@#{key}".to_sym)
24
+ res << { KEY => key.to_s, VALUE => val } unless val.nil?
25
+ res
26
+ end
27
+ h
28
+ end
43
29
  end
44
- end
45
30
  end
@@ -1,38 +1,23 @@
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.expand_path("#{File.dirname(__FILE__)}/megam_attributes")
17
2
 
18
3
  module Megam
19
- class Outputs
20
- include Nilavu::MegamAttributes
4
+ class Outputs
5
+ include Nilavu::MegamAttributes
21
6
 
22
- attr_reader :nodeip, :publicip, :privateip, :lastsuccessfulupdate, :laststatus
7
+ attr_reader :nodeip, :publicip, :privateip, :lastsuccessfulupdate, :laststatus
23
8
 
24
- ATTRIBUTES = [
25
- ]
26
- def attributes
27
- ATTRIBUTES
28
- end
9
+ ATTRIBUTES = []
10
+
11
+ def attributes
12
+ ATTRIBUTES
13
+ end
29
14
 
30
- def initialize(params)
31
- set_attributes(params)
32
- end
15
+ def initialize(params)
16
+ set_attributes(params)
17
+ end
33
18
 
34
- def to_array
35
- array = []
19
+ def to_array
20
+ array = []
21
+ end
36
22
  end
37
- end
38
23
  end