Skip to content

Commit

Permalink
fingerprint_name
Browse files Browse the repository at this point in the history
  • Loading branch information
rambleraptor committed Dec 5, 2019
1 parent a8521e3 commit 9c0e688
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion templates/ansible/resource.erb
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,30 @@ def update_fields(module, request, response):

<% update_props.each do |key, props| -%>
<% func_name = "#{props.first.name.underscore}_update" -%>
<% fingerprint_name = props.map { |x| x.fingerprint_name }.first -%>
<% unless object.hidden.include?(func_name) -%>
def <%= func_name -%>(module, request, response):
auth = GcpSession(module, <%= quote_string(prod_name) -%>)
<% if fingerprint_name -%>
new_resource = <%= method_call('fetch_resource', ['module', 'self_link(module)',
('kind' if object.kind?),
])
-%>
fingerprint = new_resource[:<%= fingerprint_name -%>]
<% end -%>
<%
request_props = if fingerprint_name
request_properties.merge({fingerprint_name => "new_resource[:#{fingerprint_name}]"})
else
request_properties(props)
end
-%>
auth.<%= key[:update_verb].downcase -%>(
''.join([
"<%= object.__product.base_url -%>",
"<%= key[:update_url].gsub('{{', '{').gsub('}}', '}') -%>"
]).format(**module.params),
<%= lines(python_literal(request_properties(props), use_hash_brackets: true)) -%>
<%= lines(python_literal(request_props, use_hash_brackets: true)) -%>
)

<% end # unless object.hidden.include? -%>
Expand Down

0 comments on commit 9c0e688

Please sign in to comment.