From 2aa7d3a6f613edc5cf88ded64b2bac93e9df081f Mon Sep 17 00:00:00 2001 From: fmunoz Date: Wed, 27 Sep 2023 14:19:51 -0600 Subject: [PATCH] Provider does not detect changes in resource dnacenter_configuration_template made outside of terraform #211 UPDATING params --- dnacenter/resource_configuration_template.go | 26 ++++++++++++-------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/dnacenter/resource_configuration_template.go b/dnacenter/resource_configuration_template.go index af4a2599..9007fa5a 100644 --- a/dnacenter/resource_configuration_template.go +++ b/dnacenter/resource_configuration_template.go @@ -1962,13 +1962,6 @@ func resourceConfigurationTemplate() *schema.Resource { Optional: true, Computed: true, }, - "template_id": &schema.Schema{ - Description: `templateId path parameter. templateId(UUID) of template to be deleted -`, - Type: schema.TypeString, - Optional: true, - Default: "", - }, "template_params": &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -2267,16 +2260,18 @@ func resourceConfigurationTemplateCreate(ctx context.Context, d *schema.Resource } else { queryParamImport := dnacentersdkgo.GetsAListOfProjectsQueryParams{} queryParamImport.Name = vvProjectName - + log.Print("[DEBUG] 1") response2, err := searchConfigurationTemplatesGetsTheTemplatesAvailable(m, queryParamImport, vvName) - // log.Printf("[DEBUG] response2 sent => %v", responseInterfaceToString(*response2)) + log.Printf("[DEBUG] response2 sent => %v", responseInterfaceToString(*response2)) if response2 != nil && err == nil { + log.Print("[DEBUG] 2") resourceMap := make(map[string]string) resourceMap["template_name"] = response2.Name resourceMap["project_name"] = response2.ProjectName resourceMap["template_id"] = response2.ID resourceMap["project_id"] = response2.ProjectID d.SetId(joinResourceID(resourceMap)) + log.Print("[DEBUG] 3") return resourceConfigurationTemplateRead(ctx, d, m) } } @@ -2374,6 +2369,12 @@ func resourceConfigurationTemplateRead(ctx context.Context, d *schema.ResourceDa err)) return diags } + if err := d.Set("parameters", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetsTheTemplatesAvailable search response", + err)) + return diags + } } return diags @@ -4427,12 +4428,17 @@ func searchConfigurationTemplatesGetsTheTemplatesAvailable(m interface{}, queryP client := m.(*dnacentersdkgo.Client) var err error var foundItem *dnacentersdkgo.ResponseItemConfigurationTemplatesGetsAListOfProjectsTemplates + log.Print("[DEBUG] 4") nResponse, _, err := client.ConfigurationTemplates.GetsAListOfProjects(&queryParams) - + log.Print("[DEBUG] 5") if err != nil { log.Printf("[DEBUG] Error when search => %s", err.Error()) return foundItem, err } + if nResponse == nil { + log.Printf("[DEBUG] Error when search => %s", err.Error()) + return foundItem, err + } //maxPageSize := 10 log.Printf("[DEBUG] Start to find a concidence") for _, item := range *nResponse {