Class: MrMurano::Business
Overview
The Business class represents an end user’s solutions.
Constant Summary
collapse
- ALLOWED_TYPES =
2017-06-30: In ADC-enabled Murano, there are now just 2 solution types. LATER: This’ll change in the future; Murano will support arbitrary
solution types.
ALLOWED_TYPES = [:domain, :onepApi, :dataApi, :application, :product,].freeze
i[application product].freeze
Constants included
from Verbose
Verbose::TABULARIZE_DATA_FORMAT_ERROR
Constants included
from AccountBase
AccountBase::LOGIN_ADVICE, AccountBase::LOGIN_NOTICE
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
-
#==(other) ⇒ Object
-
#add_member_to_child_business(bid, child_business_id, new_member_email) ⇒ Object
-
#add_network_child_business(bid, name) ⇒ Object
-
#applications(**options) ⇒ Object
-
#bizid ⇒ Object
-
#check_if_biz_network_capable(bid) ⇒ Object
-
#check_if_member_is_in_biz(business_id, email) ⇒ Object
-
#cid ⇒ Object
-
#configure_business_network(bid, name) ⇒ Object
-
#contact=(contact) ⇒ Object
-
#delete_application(sid) ⇒ Object
-
#delete_child_business(bid, child_business_id) ⇒ Object
-
#delete_product(sid) ⇒ Object
-
#delete_solution(sid) ⇒ Object
-
#email=(email) ⇒ Object
-
#fetch_member ⇒ Object
-
#fetch_network ⇒ Object
-
#fetch_network_info_parent ⇒ Object
-
#fetch_owner ⇒ Object
-
#fetch_tier ⇒ Object
-
#get_business_network(bid) ⇒ Object
-
#initialize(data = nil) ⇒ Business
constructor
A new instance of Business.
-
#invite_member(email) ⇒ Object
-
#maybe_add_network_info_child ⇒ Object
-
#must_business_id! ⇒ Object
-
#must_child_id! ⇒ Object
-
#name ⇒ Object
-
#name=(name) ⇒ Object
-
#new_application(name, type = :application) ⇒ Object
Create a new application in the current business.
-
#new_product(name, type = :product) ⇒ Object
Create a new product in the current business.
-
#new_solution!(name, type) ⇒ Object
Create a new solution in the current business.
-
#new_solution_prepare!(sol, resp) ⇒ Object
-
#overview(detailed: false, networks: false) ⇒ Object
-
#prepare_details_info ⇒ Object
-
#prepare_network_info ⇒ Object
-
#pretty_name_and_id ⇒ Object
-
#products(**options) ⇒ Object
-
#remove_member(email) ⇒ Object
-
#remove_member_from_child_business(bid, child_business_id, member_email) ⇒ Object
-
#solution_from_type!(type) ⇒ Object
Given a type (:application or :product), return a Solution instance.
-
#solutions(type: :all, api_id: nil, name: nil, fuzzy: nil, invalidate: false) ⇒ Object
-
#sort_solutions!(solz) ⇒ Object
-
#valid? ⇒ Boolean
-
#view_child_businesses(bid) ⇒ Object
-
#write(scope = :project) ⇒ Object
Methods included from Verbose
ask_yes_no, #ask_yes_no, #assert, assert, cmd_confirm_delete!, #cmd_confirm_delete!, debug, #debug, dump_file_json, dump_file_plain, dump_file_yaml, #dump_output_file, #error, error, #error_file_format!, fancy_ticks, #fancy_ticks, #load_file_json, #load_file_plain, #load_file_yaml, #load_input_file, outf, #outf, #outformat_engine, #pluralize?, pluralize?, #prepare_hash_csv, #read_hashf!, #tabularize, tabularize, verbose, #verbose, warning, #warning, #whirly_interject, whirly_interject, #whirly_linger, whirly_linger, #whirly_msg, whirly_msg, #whirly_pause, whirly_pause, #whirly_start, whirly_start, #whirly_stop, whirly_stop, #whirly_unpause, whirly_unpause
#add_headers, #ask_for_password!, #ask_for_user!, #cfg_clear_user_and_business, #credentials_reset, #get, #invalidate_token, #login_info, #logout, #must_prompt_if_logged_off!, #token, #token_reset, #verify_cfg_auth!, #verify_cfg_auth_persist, #verify_cfg_auth_scheme!, #verify_cfg_auth_ttl, #verify_set, warn_configfile_env_maybe
Methods included from Http
#add_headers, #curldebug, curldebug_after, curldebug_elapsed, curldebug_log, #delete, #endpoint, #get, #host, #http, #http_reset, #isJSON, #json_opts, #patch, #post, #postf, #put, #showHttpError, #user, #workit, #workit_response
Constructor Details
#initialize(data = nil) ⇒ Business
Returns a new instance of Business.
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/MrMurano/Business.rb', line 38
def initialize(data=nil)
super()
@bid = nil
@name = nil
self.meta = data unless data.nil?
@network_status = :unknown
@role = nil
@billing = nil
@network = nil
@members = nil
@owner = nil
@tier = nil
@valid = false
@user_bizes = {}
end
|
Instance Attribute Details
#bid ⇒ Object
61
62
63
64
|
# File 'lib/MrMurano/Business.rb', line 61
def bid
return @bid unless @bid.to_s.empty?
$cfg['business.id'].to_s
end
|
#billing ⇒ Object
32
33
34
|
# File 'lib/MrMurano/Business.rb', line 32
def billing
@billing
end
|
#members ⇒ Object
Returns the value of attribute members.
33
34
35
|
# File 'lib/MrMurano/Business.rb', line 33
def members
@members
end
|
Returns the value of attribute meta.
27
28
29
|
# File 'lib/MrMurano/Business.rb', line 27
def meta
@meta
end
|
#network ⇒ Object
Returns the value of attribute network.
34
35
36
|
# File 'lib/MrMurano/Business.rb', line 34
def network
@network
end
|
#network_status ⇒ Object
Returns the value of attribute network_status.
28
29
30
|
# File 'lib/MrMurano/Business.rb', line 28
def network_status
@network_status
end
|
#owner ⇒ Object
Returns the value of attribute owner.
35
36
37
|
# File 'lib/MrMurano/Business.rb', line 35
def owner
@owner
end
|
#role ⇒ Object
Returns the value of attribute role.
29
30
31
|
# File 'lib/MrMurano/Business.rb', line 29
def role
@role
end
|
#tier ⇒ Object
Returns the value of attribute tier.
36
37
38
|
# File 'lib/MrMurano/Business.rb', line 36
def tier
@tier
end
|
Class Method Details
.missing_business_id_msg ⇒ Object
128
129
130
131
132
133
134
|
# File 'lib/MrMurano/Business.rb', line 128
def self.missing_business_id_msg
%(
The business ID is not specified. For help, run:
#{MrMurano::EXE_NAME} business --help
).strip
end
|
.missing_child_msg ⇒ Object
136
137
138
139
140
141
142
|
# File 'lib/MrMurano/Business.rb', line 136
def self.missing_child_msg
%(
The network child business ID is not specified. For help, run:
#{MrMurano::EXE_NAME} business --help
).strip
end
|
.must_not_be_managed! ⇒ Object
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
|
# File 'lib/MrMurano/Business.rb', line 726
def self.must_not_be_managed!
MrMurano::Verbose.whirly_msg 'Verifying solutions can be managed...'
biz = MrMurano::Business.new
solz = biz.solutions
solz.each do |sol|
if [$cfg['application.id'], $cfg['product.id']].include? sol.sid
sol.must_not_be_managed!
end
end
MrMurano::Verbose.whirly_stop
end
|
Instance Method Details
#==(other) ⇒ Object
80
81
82
|
# File 'lib/MrMurano/Business.rb', line 80
def ==(other)
other.class == self.class && other.state == state
end
|
#add_member_to_child_business(bid, child_business_id, new_member_email) ⇒ Object
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
|
# File 'lib/MrMurano/Business.rb', line 620
def add_member_to_child_business(bid, child_business_id, new_member_email)
return nil unless check_if_biz_network_capable(bid)
member_in_parent_biz = check_if_member_is_in_biz(bid, new_member_email)
unless (member_in_parent_biz)
MrMurano::Verbose.error(
'User is not a member of the parent business.'
)
return nil
end
member_in_child_biz = check_if_member_is_in_biz(child_business_id, new_member_email)
if (member_in_child_biz)
MrMurano::Verbose.error(
'User is already a member of the child business.'
)
return nil
end
put(
'business/' +
bid +
'/network/business/' +
child_business_id +
'/member/' +
new_member_email
) do |request, http|
response = http.request(request)
case response
when Net::HTTPSuccess
workit_response(response)
else
showHttpError(request, response)
nil
end
end
end
|
#add_network_child_business(bid, name) ⇒ Object
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
|
# File 'lib/MrMurano/Business.rb', line 578
def add_network_child_business(bid, name)
return nil unless check_if_biz_network_capable(bid) == true
post('business/' + bid + '/network/business/', name: name) do |request, http|
response = http.request(request)
case response
when Net::HTTPSuccess
workit_response(response)
when Net::HTTPConflict
MrMurano::Verbose.error(
'You have reached your limit of child businesses in your network.'
)
nil
else
showHttpError(request, response)
nil
end
end
end
|
#applications(**options) ⇒ Object
515
516
517
|
# File 'lib/MrMurano/Business.rb', line 515
def applications(**options)
solutions(type: :application, **options)
end
|
#bizid ⇒ Object
76
77
78
|
# File 'lib/MrMurano/Business.rb', line 76
def bizid
bid
end
|
#check_if_biz_network_capable(bid) ⇒ Object
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
|
# File 'lib/MrMurano/Business.rb', line 685
def check_if_biz_network_capable(bid)
get('business/' + bid + '/tier') do |request, http|
tier_response = http.request(request)
case tier_response
when Net::HTTPSuccess
parsed_response = workit_response(tier_response)
if parsed_response[:features][:network] != true
MrMurano::Verbose.error(
'Your business does not have access to business network features. Please upgrade your business.'
)
nil
else
true
end
else
showHttpError(request, tier_response)
nil
end
end
end
|
#check_if_member_is_in_biz(business_id, email) ⇒ Object
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
|
# File 'lib/MrMurano/Business.rb', line 708
def check_if_member_is_in_biz(business_id, email)
get('business/' + business_id + '/member/') do |request, http|
response = http.request(request)
case response
when Net::HTTPSuccess
parsed_response = workit_response(response)
if (parsed_response.none? { |m| m[:email] == email })
false
else
true
end
else
showHttpError(request, response)
nil
end
end
end
|
#cid ⇒ Object
66
67
68
69
|
# File 'lib/MrMurano/Business.rb', line 66
def cid
return @cid unless @cid.to_s.empty?
$cfg['business.child'].to_s
end
|
546
547
548
549
550
551
552
553
554
555
556
557
558
|
# File 'lib/MrMurano/Business.rb', line 546
def configure_business_network(bid, name)
return nil unless check_if_biz_network_capable(bid) == true
patch('business/' + bid + '/network', name: name) do |request, http|
response = http.request(request)
case response
when Net::HTTPSuccess
workit_response(response)
else
showHttpError(request, response)
nil
end
end
end
|
92
93
94
|
# File 'lib/MrMurano/Business.rb', line 92
def contact=(contact)
patch("business/#{bid}/billing", contact: contact)
end
|
#delete_application(sid) ⇒ Object
524
525
526
|
# File 'lib/MrMurano/Business.rb', line 524
def delete_application(sid)
delete_solution(sid)
end
|
#delete_child_business(bid, child_business_id) ⇒ Object
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
|
# File 'lib/MrMurano/Business.rb', line 599
def delete_child_business(bid, child_business_id)
return nil unless check_if_biz_network_capable(bid) == true
delete(
'business/' +
bid +
'/network/business/' +
child_business_id
) do |request, http|
response = http.request(request)
case response
when Net::HTTPSuccess
workit_response(response)
else
showHttpError(request, response)
nil
end
end
end
|
#delete_product(sid) ⇒ Object
509
510
511
|
# File 'lib/MrMurano/Business.rb', line 509
def delete_product(sid)
delete_solution(sid)
end
|
#delete_solution(sid) ⇒ Object
493
494
495
496
|
# File 'lib/MrMurano/Business.rb', line 493
def delete_solution(sid)
must_business_id!
delete('business/' + bid + '/solution/' + sid)
end
|
#email=(email) ⇒ Object
88
89
90
|
# File 'lib/MrMurano/Business.rb', line 88
def email=(email)
patch("business/#{bid}/billing", email: email)
end
|
#fetch_member ⇒ Object
154
155
156
157
|
# File 'lib/MrMurano/Business.rb', line 154
def fetch_member
whirly_msg("Fetching Business details (#{pretty_name_and_id}) / members...")
get("business/#{bid}/member/")
end
|
#fetch_network ⇒ Object
169
170
171
172
|
# File 'lib/MrMurano/Business.rb', line 169
def fetch_network
whirly_msg("Fetching Business details (#{pretty_name_and_id}) / network...")
get("business/#{bid}/network")
end
|
#fetch_network_info_parent ⇒ Object
277
278
279
280
281
282
283
284
285
286
287
288
|
# File 'lib/MrMurano/Business.rb', line 277
def fetch_network_info_parent
@meta[:network_relationship] = 'parent'
@network = fetch_network if @network.nil?
network_name = @network[:name]
if network_name
@meta[:network_name] = network_name
@network_status = :parent_configured
else
@meta[:network_name] = '<Not configured>'
@network_status = :parent_unconfigured
end
end
|
#fetch_owner ⇒ Object
174
175
176
177
|
# File 'lib/MrMurano/Business.rb', line 174
def fetch_owner
whirly_msg("Fetching Business details (#{pretty_name_and_id}) / owner...")
get("business/#{bid}/owner")
end
|
#fetch_tier ⇒ Object
179
180
181
182
|
# File 'lib/MrMurano/Business.rb', line 179
def fetch_tier
whirly_msg("Fetching Business details (#{pretty_name_and_id}) / tier...")
get("business/#{bid}/tier")
end
|
#get_business_network(bid) ⇒ Object
530
531
532
533
534
535
536
537
538
539
540
541
542
|
# File 'lib/MrMurano/Business.rb', line 530
def get_business_network(bid)
return nil unless check_if_biz_network_capable(bid) == true
get('business/' + bid + '/network') do |request, http|
response = http.request(request)
case response
when Net::HTTPSuccess
workit_response(response)
else
showHttpError(request, response)
nil
end
end
end
|
#invite_member(email) ⇒ Object
159
160
161
|
# File 'lib/MrMurano/Business.rb', line 159
def invite_member(email)
put("business/#{bid}/member/#{email}")
end
|
#maybe_add_network_info_child ⇒ Object
290
291
292
293
294
295
296
297
298
299
300
301
|
# File 'lib/MrMurano/Business.rb', line 290
def maybe_add_network_info_child
@owner = fetch_owner if @owner.nil?
if !@owner.empty?
@meta[:network_relationship] = 'child'
@meta[:network_name] = @owner[:network][:name]
@network_status = :child_configured
else
@meta[:network_relationship] = ''
@meta[:network_name] = 'N/A'
@network_status = :child_unconfigured
end
end
|
#must_business_id! ⇒ Object
120
121
122
|
# File 'lib/MrMurano/Business.rb', line 120
def must_business_id!
raise MrMurano::ConfigError.new(Business.missing_business_id_msg) if bid.to_s.empty?
end
|
#must_child_id! ⇒ Object
124
125
126
|
# File 'lib/MrMurano/Business.rb', line 124
def must_child_id!
raise MrMurano::ConfigError.new(Business.missing_child_msg) if cid.to_s.empty?
end
|
#name ⇒ Object
71
72
73
74
|
# File 'lib/MrMurano/Business.rb', line 71
def name
return @name unless @name.to_s.empty?
$cfg['business.name'].to_s
end
|
#name=(name) ⇒ Object
84
85
86
|
# File 'lib/MrMurano/Business.rb', line 84
def name=(name)
patch("business/#{bid}", name: name)
end
|
#new_application(name, type = :application) ⇒ Object
Create a new application in the current business
520
521
522
|
# File 'lib/MrMurano/Business.rb', line 520
def new_application(name, type=:application)
new_solution!(name, type)
end
|
#new_product(name, type = :product) ⇒ Object
Create a new product in the current business
505
506
507
|
# File 'lib/MrMurano/Business.rb', line 505
def new_product(name, type=:product)
new_solution!(name, type)
end
|
#new_solution!(name, type) ⇒ Object
Create a new solution in the current business
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
|
# File 'lib/MrMurano/Business.rb', line 406
def new_solution!(name, type)
must_business_id!
sol = solution_from_type!(type)
sol.set_name!(name)
if $cfg['tool.dry']
say "--dry: Not creating solution #{name}"
return nil
end
whirly_start 'Creating solution...'
resp = post(
'business/' + bid + '/solution/',
label: sol.name,
type: sol.type,
) do |request, http|
response = http.request(request)
MrMurano::Verbose.whirly_stop
if response.is_a?(Net::HTTPSuccess)
workit_response(response)
else
MrMurano::Verbose.error(
"Unable to create #{sol.type_name}: #{fancy_ticks(sol.name)}"
)
ok = false
if response.is_a?(Net::HTTPConflict)
_isj, jsn = isJSON(response.body)
if jsn[:message] == 'limit'
ok = true
MrMurano::Verbose.error(
"You've reached your limit of #{Inflecto.pluralize(sol.type.to_s)}."
)
else
ok = false
end
end
showHttpError(request, response) unless ok
exit 1
nil
end
end
whirly_stop
new_solution_prepare!(sol, resp)
end
|
#new_solution_prepare!(sol, resp) ⇒ Object
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
# File 'lib/MrMurano/Business.rb', line 450
def new_solution_prepare!(sol, resp)
if resp.nil?
error("Create #{sol.type_name} failed: Request failed")
exit 1
end
unless resp.is_a?(Hash)
error("Create #{sol.type_name} failed: Unexpected response: #{resp}")
exit 1
end
if resp[:id].to_s.empty?
error("Unexpected: Solution ID not returned: #{resp}")
exit 1
end
sol.api_id = resp[:id]
sol.affirm_valid
sol
end
|
#overview(detailed: false, networks: false) ⇒ Object
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
# File 'lib/MrMurano/Business.rb', line 186
def overview(detailed: false, networks: false)
@meta ||= {}
whirly_msg("Fetching Business details (#{pretty_name_and_id}) / name...")
bid_data = get("business/#{bid}")
@name = bid_data[:name]
@meta[:name] = bid_data[:name]
@valid = true
prepare_details_info if detailed
prepare_network_info if networks
end
|
#prepare_details_info ⇒ Object
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
# File 'lib/MrMurano/Business.rb', line 206
def prepare_details_info
whirly_msg("Fetching Business details (#{pretty_name_and_id}) / billing...")
@billing = get("business/#{bid}/billing") if @billing.nil?
unless @billing.nil?
@meta[:email] = @billing[:email]
@meta[:contact] = @billing[:contact]
end
@tier = fetch_tier if @tier.nil?
@meta[:tier] = @tier[:name] unless @tier.nil?
@members = fetch_member if @members.nil?
@meta[:role] = 'N/A'
@members.each do |member|
next unless member[:email] == $cfg['user.name']
@meta[:role] = member[:role]
break
end
end
|
#prepare_network_info ⇒ Object
264
265
266
267
268
269
270
271
272
273
274
275
|
# File 'lib/MrMurano/Business.rb', line 264
def prepare_network_info
@tier = fetch_tier if @tier.nil?
network_enabled = @tier[:features][:network]
if network_enabled
fetch_network_info_parent
else
maybe_add_network_info_child
end
end
|
#pretty_name_and_id ⇒ Object
144
145
146
147
148
149
150
|
# File 'lib/MrMurano/Business.rb', line 144
def pretty_name_and_id
if !name.to_s.empty?
"#{fancy_ticks(Rainbow(name).underline)} <#{bid}>"
else
"<#{bid}>"
end
end
|
#products(**options) ⇒ Object
500
501
502
|
# File 'lib/MrMurano/Business.rb', line 500
def products(**options)
solutions(type: :product, **options)
end
|
#remove_member(email) ⇒ Object
163
164
165
|
# File 'lib/MrMurano/Business.rb', line 163
def remove_member(email)
delete("business/#{bid}/member/#{email}")
end
|
#remove_member_from_child_business(bid, child_business_id, member_email) ⇒ Object
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
|
# File 'lib/MrMurano/Business.rb', line 657
def remove_member_from_child_business(bid, child_business_id, member_email)
return nil unless check_if_biz_network_capable(bid)
member_in_child_biz = check_if_member_is_in_biz(child_business_id, member_email)
unless (member_in_child_biz)
MrMurano::Verbose.error(
'User is not a member of the child business.'
)
return nil
end
delete(
'business/' +
child_business_id +
'/member/' +
member_email
) do |request, http|
response = http.request(request)
case response
when Net::HTTPSuccess
workit_response(response)
else
showHttpError(request, response)
nil
end
end
end
|
#solution_from_type!(type) ⇒ Object
Given a type (:application or :product), return a Solution instance.
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
# File 'lib/MrMurano/Business.rb', line 387
def solution_from_type!(type)
type = type.to_s.to_sym
unless type.to_s.empty? || ALLOWED_TYPES.include?(type)
raise "Unknown type(#{type})"
end
api_id = MrMurano::Solution::INVALID_API_ID
if type == :application
sol = MrMurano::Application.new(api_id)
elsif type == :product
sol = MrMurano::Product.new(api_id)
else
sol = MrMurano::Solution.new(api_id)
end
sol.biz = self
sol
end
|
#solutions(type: :all, api_id: nil, name: nil, fuzzy: nil, invalidate: false) ⇒ Object
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
# File 'lib/MrMurano/Business.rb', line 311
def solutions(type: :all, api_id: nil, name: nil, fuzzy: nil, invalidate: false)
debug "Getting all solutions of type #{type}"
must_business_id!
type = type.to_sym
raise "Unknown type(#{type})" unless type == :all || ALLOWED_TYPES.include?(type)
if invalidate || @user_bizes[type].nil?
if invalidate || @user_bizes[:all].nil?
got = get('business/' + bid + '/solution/') do |request, http|
response = http.request(request)
case response
when Net::HTTPSuccess
workit_response(response)
when Net::HTTPForbidden
nil
else
showHttpError(request, response)
nil
end
end
@user_bizes[:all] = got || []
end
if invalidate || @user_bizes[type].nil?
@user_bizes[type] = @user_bizes[:all].select { |i| i[:type] == type.to_s }
end
end
solz = @user_bizes[type].dup
match_api_id = ensure_array(api_id)
match_name = ensure_array(name)
match_fuzzy = ensure_array(fuzzy)
if match_api_id.any? || match_name.any? || match_fuzzy.any?
solz.select! do |sol|
(
match_api_id.include?(sol[:apiId]) ||
match_name.include?(sol[:name]) ||
match_fuzzy.any? do |term|
sol[:name] =~ /#{Regexp.escape(term)}/i || \
sol[:apiId] =~ /#{Regexp.escape(term)}/i
end
)
end
end
solz.map! do |meta|
case meta[:type].to_sym
when :application
MrMurano::Application.new(meta)
when :product
MrMurano::Product.new(meta)
else
warning("Unexpected solution type: #{meta[:type]}")
if meta[:type].to_sym == :dataApi
warning('* Please enable Murano for this business')
end
MrMurano::Solution.new(meta)
end
end
sort_solutions!(solz)
end
|
#sort_solutions!(solz) ⇒ Object
381
382
383
384
|
# File 'lib/MrMurano/Business.rb', line 381
def sort_solutions!(solz)
solz.sort_by!(&:name)
solz.sort_by! { |sol| ALLOWED_TYPES.index(sol.type) }
end
|
#valid? ⇒ Boolean
57
58
59
|
# File 'lib/MrMurano/Business.rb', line 57
def valid?
@valid
end
|
#view_child_businesses(bid) ⇒ Object
562
563
564
565
566
567
568
569
570
571
572
573
574
|
# File 'lib/MrMurano/Business.rb', line 562
def view_child_businesses(bid)
return nil unless check_if_biz_network_capable(bid) == true
get('business/' + bid + '/network/business/') do |request, http|
response = http.request(request)
case response
when Net::HTTPSuccess
workit_response(response)
else
showHttpError(request, response)
nil
end
end
end
|
#write(scope = :project) ⇒ Object
114
115
116
117
118
|
# File 'lib/MrMurano/Business.rb', line 114
def write(scope=:project)
$cfg.set('business.id', bid, scope)
$cfg.set('business.name', name, scope)
self
end
|