20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/commands/common/thor/set_required_attributes.rb', line 20
def set_required_attributes_aux(id, type, subtype = nil, additional_message = nil)
id_field = "#{type}_id".to_sym
post_body = {
id_field => id,
:subtype => 'instance',
:filter => 'required_unset_attributes'
}
post_body.merge!(:subtype => subtype.to_s) if subtype
response = post rest_url("#{type}/get_attributes"), post_body
return response unless response.ok?
missing_params = response.data
if missing_params.empty?
response.set_data('Message' => "No parameters to set.")
response
else
param_bindings = Shell::InteractiveWizard.resolve_missing_params(missing_params, additional_message)
post_body = {
id_field => id,
:av_pairs_hash => param_bindings.inject(Hash.new){|h,r|h.merge(r[:id] => r[:value])}
}
response = post rest_url("#{type}/set_attributes"), post_body
return response unless response.ok?
response.data
end
end
|