From 3dfe44d7bc8befbe068da94de69fd1d14be89fe1 Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Fri, 19 Oct 2018 13:34:26 -0700 Subject: [PATCH 1/2] Add singular initialize method --- templates/inspec/singular_resource.erb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/templates/inspec/singular_resource.erb b/templates/inspec/singular_resource.erb index 0858313284a5..f2f52fa94dbf 100644 --- a/templates/inspec/singular_resource.erb +++ b/templates/inspec/singular_resource.erb @@ -35,6 +35,22 @@ class <%= object.name -%> < Inspec.resource(1) '<%= url(object) %>' end +<% if object.self_link_query.nil? -%> + def initialize(params) + @fetched = fetch_resource(params) + parse unless @fetched.nil? + end +<% else # object.self_link_query.nil? -%> + # TODO(slevenick) for other products + def initialize(params) + raise 'Not implemented' + end +<% end # object.self_link_query.nil? -%> + + def fetch_resource(params) + get_request = inspec.backend.fetch(base, url, params) + end + # TODO def parse end From ff5d8ef4c05fdb3df2c037dccf92654b3c5aa97d Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Fri, 19 Oct 2018 13:35:17 -0700 Subject: [PATCH 2/2] Spacing --- templates/inspec/singular_resource.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/inspec/singular_resource.erb b/templates/inspec/singular_resource.erb index f2f52fa94dbf..ce1a3365c5e0 100644 --- a/templates/inspec/singular_resource.erb +++ b/templates/inspec/singular_resource.erb @@ -41,10 +41,10 @@ class <%= object.name -%> < Inspec.resource(1) parse unless @fetched.nil? end <% else # object.self_link_query.nil? -%> - # TODO(slevenick) for other products - def initialize(params) - raise 'Not implemented' - end + # TODO(slevenick) for other products + def initialize(params) + raise 'Not implemented' + end <% end # object.self_link_query.nil? -%> def fetch_resource(params)