nexpose 0.0.98 → 0.1.0

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.
@@ -1,347 +1,348 @@
1
- module Nexpose
2
- module NexposeAPI
3
- include XMLUtils
4
-
5
- ###################
6
- # SILO MANAGEMENT #
7
- ###################
8
-
9
- #########################
10
- # MULTI-TENANT USER OPS #
11
- #########################
12
-
13
- #-------------------------------------------------------------------------
14
- # Creates a multi-tenant user
15
- #
16
- # user_config - A map of the user data.
17
- #
18
- # REQUIRED PARAMS
19
- # user-id, authsrcid, user-name, full-name, enabled, superuser
20
- #
21
- # OPTIONAL PARAMS
22
- # email, password
23
- #
24
- # silo_configs - An array of maps of silo specific data
25
- #
26
- # REQUIRED PARAMS
27
- # silo-id, role-name, all-groups, all-sites, default-silo
28
- #
29
- # allowed_groups/allowed_sites - An array of ids
30
- #-------------------------------------------------------------------------
31
- def create_multi_tenant_user(user_config, silo_configs)
32
- xml = make_xml('MultiTenantUserCreateRequest')
33
- mtu_config_xml = make_xml('MultiTenantUserConfig', user_config, '', false)
34
-
35
- # Add the silo access
36
- silo_xml = make_xml('SiloAccesses', {}, '', false)
37
- silo_config_xml = make_xml('SiloAccess', {}, '', false)
38
- silo_configs.keys.each do |k|
39
- if k.eql? 'allowed_sites'
40
- allowed_sites_xml = make_xml('AllowedSites', {}, '', false)
41
- silo_configs['allowed_sites'].each do |allowed_site|
42
- allowed_sites_xml.add_element make_xml('AllowedSite', {'id' => allowed_site}, '', false)
43
- end
44
- silo_config_xml.add_element allowed_sites_xml
45
- elsif k.eql? 'allowed_groups'
46
- allowed_groups_xml = make_xml('AllowedGroups', {}, '', false)
47
- silo_configs['allowed_groups'].each do |allowed_group|
48
- allowed_groups_xml.add_element make_xml('AllowedGroup', {'id' => allowed_group}, '', false)
49
- end
50
- silo_config_xml.add_element allowed_groups_xml
51
- else
52
- silo_config_xml.attributes[k] = silo_configs[k]
53
- end
54
- end
55
- silo_xml.add_element silo_config_xml
56
- mtu_config_xml.add_element silo_xml
57
- xml.add_element mtu_config_xml
58
- r = execute xml, '1.2'
59
- r.success
60
- end
61
-
62
-
63
- #-------------------------------------------------------------------------
64
- # Lists all the multi-tenant users and their attributes.
65
- #-------------------------------------------------------------------------
66
- def list_mtu
67
- xml = make_xml('MultiTenantUserListingRequest')
68
- r = execute xml, '1.2'
69
-
70
- if r.success
71
- res = []
72
- r.res.elements.each("//MultiTenantUserSummary") do |mtu|
73
- res << {
74
- :id => mtu.attributes['id'],
75
- :full_name => mtu.attributes['full-name'],
76
- :user_name => mtu.attributes['user-name'],
77
- :email => mtu.attributes['email'],
78
- :super_user => mtu.attributes['superuser'],
79
- :enabled => mtu.attributes['enabled'],
80
- :auth_module => mtu.attributes['auth-module'],
81
- :silo_count => mtu.attributes['silo-count'],
82
- :locked => mtu.attributes['locked']
83
- }
84
- end
85
- res
86
- else
87
- false
88
- end
89
- end
90
-
91
- #-------------------------------------------------------------------------
92
- # Delete a multi-tenant user
93
- #-------------------------------------------------------------------------
94
- def delete_mtu user_name, user_id
95
- using_user_name = (user_name and not user_name.empty?)
96
- xml = make_xml('MultiTenantUserDeleteRequest', (using_user_name ? {'user-name' => user_name} : {'user-id' => user_id}))
97
- r = execute xml, '1.2'
98
- r.success
99
- end
100
-
101
- ####################
102
- # SILO PROFILE OPS #
103
- ####################
104
-
105
- #-------------------------------------------------------------------------
106
- # Creates a silo profile
107
- #
108
- # silo_config - A map of the silo data.
109
- #
110
- # REQUIRED PARAMS
111
- # id, name, all‐licensed-modules, all‐global-engines, all-global-report-templates, all‐global-scan‐templates
112
- #
113
- # OPTIONAL PARAMS
114
- # description
115
- #
116
- # permissions - A map of an array of maps of silo specific data
117
- #
118
- # REQUIRED PARAMS
119
- # silo-id, role-name, all-groups, all-sites, default-silo
120
- #
121
- # allowed_groups/allowed_sites - An array of ids
122
- #-------------------------------------------------------------------------
123
- def create_silo_profile silo_profile_config, permissions
124
- xml = make_xml 'SiloProfileCreateRequest'
125
- spc_xml = make_xml('SiloProfileConfig', silo_profile_config, '', false)
126
-
127
- # Add the permissions
128
- if permissions['global_report_templates']
129
- grt_xml = make_xml('GlobalReportTemplates', {}, '', false)
130
- permissions['global_report_templates'].each do |name|
131
- grt_xml.add_element make_xml('GlobalReportTemplate', {'name' => name}, '', false)
132
- end
133
- spc_xml.add_element grt_xml
134
- end
135
-
136
- if permissions['global_scan_engines']
137
- gse_xml = make_xml('GlobalScanEngines', {}, '', false)
138
- permissions['global_scan_engines'].each do |name|
139
- gse_xml.add_element make_xml('GlobalScanEngine', {'name' => name}, '', false)
140
- end
141
- spc_xml.add_element gse_xml
142
- end
143
-
144
- if permissions['global_scan_templates']
145
- gst_xml = make_xml('GlobalScanTemplates', {}, '', false)
146
- permissions['global_scan_templates'].each do |name|
147
- gst_xml.add_element make_xml('GlobalScanTemplate', {'name' => name}, '', false)
148
- end
149
- spc_xml.add_element gst_xml
150
- end
151
-
152
- if permissions['licensed_modules']
153
- lm_xml = make_xml('LicensedModules', {}, '', false)
154
- permissions['licensed_modules'].each do |name|
155
- lm_xml.add_element make_xml('LicensedModule', {'name' => name}, '', false)
156
- end
157
- spc_xml.add_element lm_xml
158
- end
159
-
160
- if permissions['restricted_report_formats']
161
- rrf_xml = make_xml('RestrictedReportFormats', {}, '', false)
162
- permissions['restricted_report_formats'].each do |name|
163
- rrf_xml.add_element make_xml('RestrictedReportFormat', {'name' => name}, '', false)
164
- end
165
- spc_xml.add_element rrf_xml
166
- end
167
-
168
- if permissions['restricted_report_sections']
169
- rrs_xml = make_xml('RestrictedReportSections', {}, '', false)
170
- permissions['restricted_report_sections'].each do |name|
171
- rrs_xml.add_element make_xml('RestrictedReportSection', {'name' => name}, '', false)
172
- end
173
- spc_xml.add_element rrs_xml
174
- end
175
-
176
- xml.add_element spc_xml
177
- r = execute xml, '1.2'
178
- r.success
179
- end
180
-
181
- #-------------------------------------------------------------------------
182
- # Lists all the silo profiles and their attributes.
183
- #-------------------------------------------------------------------------
184
- def list_silo_profiles
185
- xml = make_xml('SiloProfileListingRequest')
186
- r = execute xml, '1.2'
187
-
188
- if r.success
189
- res = []
190
- r.res.elements.each("//SiloProfileSummary") do |silo_profile|
191
- res << {
192
- :id => silo_profile.attributes['id'],
193
- :name => silo_profile.attributes['name'],
194
- :description => silo_profile.attributes['description'],
195
- :global_report_template_count => silo_profile.attributes['global-report-template-count'],
196
- :global_scan_engine_count => silo_profile.attributes['global-scan-engine-count'],
197
- :global_scan_template_count => silo_profile.attributes['global-scan-template-count'],
198
- :licensed_module_count => silo_profile.attributes['licensed-module-count'],
199
- :restricted_report_section_count => silo_profile.attributes['restricted-report-section-count'],
200
- :all_licensed_modules => silo_profile.attributes['all-licensed-modules'],
201
- :all_global_engines => silo_profile.attributes['all-global-engines'],
202
- :all_global_report_templates => silo_profile.attributes['all-global-report-templates'],
203
- :all_global_scan_templates => silo_profile.attributes['all-global-scan-templates']
204
- }
205
- end
206
- res
207
- else
208
- false
209
- end
210
- end
211
-
212
- #-------------------------------------------------------------------------
213
- # Delete a silo profile
214
- #-------------------------------------------------------------------------
215
- def delete_silo_profile name, id
216
- using_name = (name and not name.empty?)
217
- xml = make_xml('SiloProfileDeleteRequest', (using_name ? {'name' => name} : {'silo-profile-id' => id}))
218
- r = execute xml, '1.2'
219
- r.success
220
- end
221
-
222
- ####################
223
- # SILO OPS #
224
- ####################
225
-
226
- #-------------------------------------------------------------------------
227
- # Creates a silo
228
- #
229
- # silo_config - A map of the silo creation data.
230
- #
231
- # REQUIRED PARAMS
232
- # id, name, silo-profile-id, max-assets, max-hosted-assets, max-users
233
- #
234
- # OPTIONAL PARAMS
235
- # description
236
- #-------------------------------------------------------------------------
237
- def create_silo silo_config
238
- xml = make_xml 'SiloCreateRequest'
239
- silo_config_xml = make_xml 'SiloConfig', {}, '', false
240
-
241
- # Add the attributes
242
- silo_config.keys.each do |key|
243
- if not 'merchant'.eql? key and not 'organization'.eql? key
244
- silo_config_xml.attributes[key] = silo_config[key]
245
- end
246
- end
247
-
248
- # Add Organization info
249
- if silo_config['organization']
250
- org_xml = make_xml 'Organization', {}, '', false
251
- silo_config['organization'].keys.each do |key|
252
- if not 'address'.eql? key
253
- org_xml.attributes[key] = silo_config['organization'][key]
254
- end
255
- end
256
-
257
- address_xml = make_xml 'Address', silo_config['organization']['address'], '', false
258
- org_xml.add_element address_xml
259
- silo_config_xml.add_element org_xml
260
- end
261
-
262
- # Add Merchant info
263
- if silo_config['merchant']
264
- merchant_xml = make_xml 'Merchant', {}, '', false
265
-
266
- silo_config['merchant'].keys.each do |key|
267
- if not 'dba'.eql? key and not 'other_industries'.eql? key and not 'qsa'.eql? key and not 'address'.eql? key
268
- merchant_xml.attributes[key] = silo_config['merchant'][key]
269
- end
270
- end
271
-
272
- # Add the merchant address
273
- merchant_address_xml = make_xml 'Address', silo_config['merchant']['address'], '', false
274
- merchant_xml.add_element merchant_address_xml
275
-
276
- #Now add the complex data types
277
- if silo_config['merchant']['dba']
278
- dba_xml = make_xml 'DBAs', {}, '', false
279
- silo_config['merchant']['dba'].each do |name|
280
- dba_xml.add_element make_xml('DBA', {'name' => name}, '', false)
281
- end
282
- merchant_xml.add_element dba_xml
283
- end
284
-
285
- if silo_config['merchant']['other_industries']
286
- ois_xml = make_xml 'OtherIndustries', {}, '', false
287
- silo_config['merchant']['other_industries'].each do |name|
288
- ois_xml.add_element make_xml('Industry', {'name' => name}, '', false)
289
- end
290
- merchant_xml.add_element ois_xml
291
- end
292
-
293
- if silo_config['merchant']['qsa']
294
- qsa_xml = make_xml 'QSA', {}, '', false
295
- silo_config['merchant']['qsa'].keys.each do |key|
296
- if not 'address'.eql? key
297
- qsa_xml.attributes[key] = silo_config['merchant']['qsa'][key]
298
- end
299
- end
300
-
301
- # Add the address for this QSA
302
- address_xml = make_xml 'Address', silo_config['merchant']['qsa']['address'], '', false
303
-
304
- qsa_xml.add_element address_xml
305
- merchant_xml.add_element qsa_xml
306
- end
307
- silo_config_xml.add_element merchant_xml
308
- end
309
-
310
- xml.add_element silo_config_xml
311
- r = execute xml, '1.2'
312
- r.success
313
- end
314
-
315
- #-------------------------------------------------------------------------
316
- # Lists all the silos and their attributes.
317
- #-------------------------------------------------------------------------
318
- def list_silos
319
- xml = make_xml('SiloListingRequest')
320
- r = execute xml, '1.2'
321
-
322
- if r.success
323
- res = []
324
- r.res.elements.each("//SiloSummary") do |silo_profile|
325
- res << {
326
- :id => silo_profile.attributes['id'],
327
- :name => silo_profile.attributes['name'],
328
- :description => silo_profile.attributes['description']
329
- }
330
- end
331
- res
332
- else
333
- false
334
- end
335
- end
336
-
337
- #-------------------------------------------------------------------------
338
- # Delete a silo
339
- #-------------------------------------------------------------------------
340
- def delete_silo name, id
341
- using_name = (name and not name.empty?)
342
- xml = make_xml('SiloDeleteRequest', (using_name ? {'silo-name' => name} : {'silo-id' => id}))
343
- r = execute xml, '1.2'
344
- r.success
345
- end
346
- end
347
- end
1
+ module Nexpose
2
+ module NexposeAPI
3
+ include XMLUtils
4
+
5
+ ###################
6
+ # SILO MANAGEMENT #
7
+ ###################
8
+
9
+ #########################
10
+ # MULTI-TENANT USER OPS #
11
+ #########################
12
+
13
+ #-------------------------------------------------------------------------
14
+ # Creates a multi-tenant user
15
+ #
16
+ # user_config - A map of the user data.
17
+ #
18
+ # REQUIRED PARAMS
19
+ # user-id, authsrcid, user-name, full-name, enabled, superuser
20
+ #
21
+ # OPTIONAL PARAMS
22
+ # email, password
23
+ #
24
+ # silo_configs - An array of maps of silo specific data
25
+ #
26
+ # REQUIRED PARAMS
27
+ # silo-id, role-name, all-groups, all-sites, default-silo
28
+ #
29
+ # allowed_groups/allowed_sites - An array of ids
30
+ #-------------------------------------------------------------------------
31
+ def create_multi_tenant_user(user_config, silo_configs)
32
+ xml = make_xml('MultiTenantUserCreateRequest')
33
+ mtu_config_xml = make_xml('MultiTenantUserConfig', user_config, '', false)
34
+
35
+ # Add the silo access
36
+ silo_xml = make_xml('SiloAccesses', {}, '', false)
37
+ silo_configs.each do |silo_config|
38
+ silo_config_xml = make_xml('SiloAccess', {}, '', false)
39
+ silo_config.keys.each do |k|
40
+ if k == 'allowed_sites'
41
+ allowed_sites_xml = make_xml('AllowedSites', {}, '', false)
42
+ silo_config['allowed_sites'].each do |allowed_site|
43
+ allowed_sites_xml.add_element(make_xml('AllowedSite', {'id' => allowed_site}, '', false))
44
+ end
45
+ silo_config_xml.add_element(allowed_sites_xml)
46
+ elsif k == 'allowed_groups'
47
+ allowed_groups_xml = make_xml('AllowedGroups', {}, '', false)
48
+ silo_config['allowed_groups'].each do |allowed_group|
49
+ allowed_groups_xml.add_element(make_xml('AllowedGroup', {'id' => allowed_group}, '', false))
50
+ end
51
+ silo_config_xml.add_element(allowed_groups_xml)
52
+ else
53
+ silo_config_xml.attributes[k] = silo_config[k]
54
+ end
55
+ end
56
+ silo_xml.add_element(silo_config_xml)
57
+ end
58
+ mtu_config_xml.add_element(silo_xml)
59
+ xml.add_element(mtu_config_xml)
60
+ r = execute(xml, '1.2')
61
+ r.success
62
+ end
63
+
64
+ #-------------------------------------------------------------------------
65
+ # Lists all the multi-tenant users and their attributes.
66
+ #-------------------------------------------------------------------------
67
+ def list_mtu
68
+ xml = make_xml('MultiTenantUserListingRequest')
69
+ r = execute xml, '1.2'
70
+
71
+ if r.success
72
+ res = []
73
+ r.res.elements.each("//MultiTenantUserSummary") do |mtu|
74
+ res << {
75
+ :id => mtu.attributes['id'],
76
+ :full_name => mtu.attributes['full-name'],
77
+ :user_name => mtu.attributes['user-name'],
78
+ :email => mtu.attributes['email'],
79
+ :super_user => mtu.attributes['superuser'],
80
+ :enabled => mtu.attributes['enabled'],
81
+ :auth_module => mtu.attributes['auth-module'],
82
+ :silo_count => mtu.attributes['silo-count'],
83
+ :locked => mtu.attributes['locked']
84
+ }
85
+ end
86
+ res
87
+ else
88
+ false
89
+ end
90
+ end
91
+
92
+ #-------------------------------------------------------------------------
93
+ # Delete a multi-tenant user
94
+ #-------------------------------------------------------------------------
95
+ def delete_mtu user_name, user_id
96
+ using_user_name = (user_name and not user_name.empty?)
97
+ xml = make_xml('MultiTenantUserDeleteRequest', (using_user_name ? {'user-name' => user_name} : {'user-id' => user_id}))
98
+ r = execute xml, '1.2'
99
+ r.success
100
+ end
101
+
102
+ ####################
103
+ # SILO PROFILE OPS #
104
+ ####################
105
+
106
+ #-------------------------------------------------------------------------
107
+ # Creates a silo profile
108
+ #
109
+ # silo_config - A map of the silo data.
110
+ #
111
+ # REQUIRED PARAMS
112
+ # id, name, all‐licensed-modules, all‐global-engines, all-global-report-templates, all‐global-scan‐templates
113
+ #
114
+ # OPTIONAL PARAMS
115
+ # description
116
+ #
117
+ # permissions - A map of an array of maps of silo specific data
118
+ #
119
+ # REQUIRED PARAMS
120
+ # silo-id, role-name, all-groups, all-sites, default-silo
121
+ #
122
+ # allowed_groups/allowed_sites - An array of ids
123
+ #-------------------------------------------------------------------------
124
+ def create_silo_profile silo_profile_config, permissions
125
+ xml = make_xml 'SiloProfileCreateRequest'
126
+ spc_xml = make_xml('SiloProfileConfig', silo_profile_config, '', false)
127
+
128
+ # Add the permissions
129
+ if permissions['global_report_templates']
130
+ grt_xml = make_xml('GlobalReportTemplates', {}, '', false)
131
+ permissions['global_report_templates'].each do |name|
132
+ grt_xml.add_element make_xml('GlobalReportTemplate', {'name' => name}, '', false)
133
+ end
134
+ spc_xml.add_element grt_xml
135
+ end
136
+
137
+ if permissions['global_scan_engines']
138
+ gse_xml = make_xml('GlobalScanEngines', {}, '', false)
139
+ permissions['global_scan_engines'].each do |name|
140
+ gse_xml.add_element make_xml('GlobalScanEngine', {'name' => name}, '', false)
141
+ end
142
+ spc_xml.add_element gse_xml
143
+ end
144
+
145
+ if permissions['global_scan_templates']
146
+ gst_xml = make_xml('GlobalScanTemplates', {}, '', false)
147
+ permissions['global_scan_templates'].each do |name|
148
+ gst_xml.add_element make_xml('GlobalScanTemplate', {'name' => name}, '', false)
149
+ end
150
+ spc_xml.add_element gst_xml
151
+ end
152
+
153
+ if permissions['licensed_modules']
154
+ lm_xml = make_xml('LicensedModules', {}, '', false)
155
+ permissions['licensed_modules'].each do |name|
156
+ lm_xml.add_element make_xml('LicensedModule', {'name' => name}, '', false)
157
+ end
158
+ spc_xml.add_element lm_xml
159
+ end
160
+
161
+ if permissions['restricted_report_formats']
162
+ rrf_xml = make_xml('RestrictedReportFormats', {}, '', false)
163
+ permissions['restricted_report_formats'].each do |name|
164
+ rrf_xml.add_element make_xml('RestrictedReportFormat', {'name' => name}, '', false)
165
+ end
166
+ spc_xml.add_element rrf_xml
167
+ end
168
+
169
+ if permissions['restricted_report_sections']
170
+ rrs_xml = make_xml('RestrictedReportSections', {}, '', false)
171
+ permissions['restricted_report_sections'].each do |name|
172
+ rrs_xml.add_element make_xml('RestrictedReportSection', {'name' => name}, '', false)
173
+ end
174
+ spc_xml.add_element rrs_xml
175
+ end
176
+
177
+ xml.add_element spc_xml
178
+ r = execute xml, '1.2'
179
+ r.success
180
+ end
181
+
182
+ #-------------------------------------------------------------------------
183
+ # Lists all the silo profiles and their attributes.
184
+ #-------------------------------------------------------------------------
185
+ def list_silo_profiles
186
+ xml = make_xml('SiloProfileListingRequest')
187
+ r = execute xml, '1.2'
188
+
189
+ if r.success
190
+ res = []
191
+ r.res.elements.each("//SiloProfileSummary") do |silo_profile|
192
+ res << {
193
+ :id => silo_profile.attributes['id'],
194
+ :name => silo_profile.attributes['name'],
195
+ :description => silo_profile.attributes['description'],
196
+ :global_report_template_count => silo_profile.attributes['global-report-template-count'],
197
+ :global_scan_engine_count => silo_profile.attributes['global-scan-engine-count'],
198
+ :global_scan_template_count => silo_profile.attributes['global-scan-template-count'],
199
+ :licensed_module_count => silo_profile.attributes['licensed-module-count'],
200
+ :restricted_report_section_count => silo_profile.attributes['restricted-report-section-count'],
201
+ :all_licensed_modules => silo_profile.attributes['all-licensed-modules'],
202
+ :all_global_engines => silo_profile.attributes['all-global-engines'],
203
+ :all_global_report_templates => silo_profile.attributes['all-global-report-templates'],
204
+ :all_global_scan_templates => silo_profile.attributes['all-global-scan-templates']
205
+ }
206
+ end
207
+ res
208
+ else
209
+ false
210
+ end
211
+ end
212
+
213
+ #-------------------------------------------------------------------------
214
+ # Delete a silo profile
215
+ #-------------------------------------------------------------------------
216
+ def delete_silo_profile name, id
217
+ using_name = (name and not name.empty?)
218
+ xml = make_xml('SiloProfileDeleteRequest', (using_name ? {'name' => name} : {'silo-profile-id' => id}))
219
+ r = execute xml, '1.2'
220
+ r.success
221
+ end
222
+
223
+ ####################
224
+ # SILO OPS #
225
+ ####################
226
+
227
+ #-------------------------------------------------------------------------
228
+ # Creates a silo
229
+ #
230
+ # silo_config - A map of the silo creation data.
231
+ #
232
+ # REQUIRED PARAMS
233
+ # id, name, silo-profile-id, max-assets, max-hosted-assets, max-users
234
+ #
235
+ # OPTIONAL PARAMS
236
+ # description
237
+ #-------------------------------------------------------------------------
238
+ def create_silo silo_config
239
+ xml = make_xml 'SiloCreateRequest'
240
+ silo_config_xml = make_xml 'SiloConfig', {}, '', false
241
+
242
+ # Add the attributes
243
+ silo_config.keys.each do |key|
244
+ if not 'merchant'.eql? key and not 'organization'.eql? key
245
+ silo_config_xml.attributes[key] = silo_config[key]
246
+ end
247
+ end
248
+
249
+ # Add Organization info
250
+ if silo_config['organization']
251
+ org_xml = make_xml 'Organization', {}, '', false
252
+ silo_config['organization'].keys.each do |key|
253
+ if not 'address'.eql? key
254
+ org_xml.attributes[key] = silo_config['organization'][key]
255
+ end
256
+ end
257
+
258
+ address_xml = make_xml 'Address', silo_config['organization']['address'], '', false
259
+ org_xml.add_element address_xml
260
+ silo_config_xml.add_element org_xml
261
+ end
262
+
263
+ # Add Merchant info
264
+ if silo_config['merchant']
265
+ merchant_xml = make_xml 'Merchant', {}, '', false
266
+
267
+ silo_config['merchant'].keys.each do |key|
268
+ if not 'dba'.eql? key and not 'other_industries'.eql? key and not 'qsa'.eql? key and not 'address'.eql? key
269
+ merchant_xml.attributes[key] = silo_config['merchant'][key]
270
+ end
271
+ end
272
+
273
+ # Add the merchant address
274
+ merchant_address_xml = make_xml 'Address', silo_config['merchant']['address'], '', false
275
+ merchant_xml.add_element merchant_address_xml
276
+
277
+ #Now add the complex data types
278
+ if silo_config['merchant']['dba']
279
+ dba_xml = make_xml 'DBAs', {}, '', false
280
+ silo_config['merchant']['dba'].each do |name|
281
+ dba_xml.add_element make_xml('DBA', {'name' => name}, '', false)
282
+ end
283
+ merchant_xml.add_element dba_xml
284
+ end
285
+
286
+ if silo_config['merchant']['other_industries']
287
+ ois_xml = make_xml 'OtherIndustries', {}, '', false
288
+ silo_config['merchant']['other_industries'].each do |name|
289
+ ois_xml.add_element make_xml('Industry', {'name' => name}, '', false)
290
+ end
291
+ merchant_xml.add_element ois_xml
292
+ end
293
+
294
+ if silo_config['merchant']['qsa']
295
+ qsa_xml = make_xml 'QSA', {}, '', false
296
+ silo_config['merchant']['qsa'].keys.each do |key|
297
+ if not 'address'.eql? key
298
+ qsa_xml.attributes[key] = silo_config['merchant']['qsa'][key]
299
+ end
300
+ end
301
+
302
+ # Add the address for this QSA
303
+ address_xml = make_xml 'Address', silo_config['merchant']['qsa']['address'], '', false
304
+
305
+ qsa_xml.add_element address_xml
306
+ merchant_xml.add_element qsa_xml
307
+ end
308
+ silo_config_xml.add_element merchant_xml
309
+ end
310
+
311
+ xml.add_element silo_config_xml
312
+ r = execute xml, '1.2'
313
+ r.success
314
+ end
315
+
316
+ #-------------------------------------------------------------------------
317
+ # Lists all the silos and their attributes.
318
+ #-------------------------------------------------------------------------
319
+ def list_silos
320
+ xml = make_xml('SiloListingRequest')
321
+ r = execute xml, '1.2'
322
+
323
+ if r.success
324
+ res = []
325
+ r.res.elements.each("//SiloSummary") do |silo_profile|
326
+ res << {
327
+ :id => silo_profile.attributes['id'],
328
+ :name => silo_profile.attributes['name'],
329
+ :description => silo_profile.attributes['description']
330
+ }
331
+ end
332
+ res
333
+ else
334
+ false
335
+ end
336
+ end
337
+
338
+ #-------------------------------------------------------------------------
339
+ # Delete a silo
340
+ #-------------------------------------------------------------------------
341
+ def delete_silo name, id
342
+ using_name = (name and not name.empty?)
343
+ xml = make_xml('SiloDeleteRequest', (using_name ? {'silo-name' => name} : {'silo-id' => id}))
344
+ r = execute xml, '1.2'
345
+ r.success
346
+ end
347
+ end
348
+ end