Skip to content

Commit

Permalink
Merge pull request #170 from cisco-en-programmability/develop
Browse files Browse the repository at this point in the history
Develop v1.1.3-beta
  • Loading branch information
fmunozmiranda authored May 8, 2023
2 parents 9b20c4c + a56914a commit b20b171
Show file tree
Hide file tree
Showing 188 changed files with 284 additions and 220 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.1.3-beta (May 08, 2023)
BUGFIXES:
* Failure when refreshing state of dnacenter_global_credential_cli and dnacenter_global_credential_netconf resources #161
* Failure when creating resource dnacenter_configuration_template #163
* Failure when executing AddVnInFabric #167
* dnacenter_site resource does not save site_id in state any more, however site_id is required for creating other resources #168

## 1.1.2-beta (May 03, 2023)
BUGFIXES:
* dnacenter_reserve_ip_subpool requires id parameter #159.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ HOSTNAME=hashicorp.com
NAMESPACE=edu
NAME=dnacenter
BINARY=terraform-provider-${NAME}
VERSION=1.1.2-beta
VERSION=1.1.3-beta
OS_ARCH=darwin_amd64
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
WEBSITE_REPO=github.com/hashicorp/terraform-website
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The following table shows the supported versions.
| 2.2.3.3 | 0.3.0-beta |
| 2.2.3.3 | 0.3.0 |
| 2.3.3.0 | 1.0.19-beta |
| 2.3.5.3 | 1.1.2-beta |
| 2.3.5.3 | 1.1.3-beta |

If your SDK, Terraform provider is older please consider updating it first.

Expand Down
4 changes: 2 additions & 2 deletions dnacenter/data_source_sda_virtual_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ func flattenSdaGetVnFromSdaFabricItem(item *dnacentersdkgo.ResponseSdaGetVnFromS
respItem["site_name_hierarchy"] = item.SiteNameHierarchy
respItem["virtual_network_name"] = item.VirtualNetworkName
respItem["fabric_name"] = item.FabricName
respItem["is_infra_vn"] = item.IsInfraVn
respItem["is_default_vn"] = item.IsDefaultVn
respItem["is_infra_vn"] = boolPtrToString(item.IsInfraVn)
respItem["is_default_vn"] = boolPtrToString(item.IsDefaultVn)
respItem["status"] = item.Status
respItem["description"] = item.Description
return []map[string]interface{}{
Expand Down
75 changes: 49 additions & 26 deletions dnacenter/resource_configuration_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -1694,15 +1694,14 @@ func resourceConfigurationTemplate() *schema.Resource {
Description: `Project UUID
`,
Type: schema.TypeString,
Optional: true,
Default: "",
Required: true,
},
"project_name": &schema.Schema{
Description: `Project name
`,
Type: schema.TypeString,
Optional: true,
Computed: true,
Default: "",
},
"rollback_template_content": &schema.Schema{
Description: `Rollback template content
Expand Down Expand Up @@ -2233,29 +2232,49 @@ func resourceConfigurationTemplateCreate(ctx context.Context, d *schema.Resource

vTemplateID := resourceItem["template_id"]
vvTemplateID := interfaceToString(vTemplateID)
vProjectName := resourceItem["project_name"]
vvProjectName := interfaceToString(vProjectName)
vProjectID := resourceItem["project_id"]
vvProjectID := interfaceToString(vProjectID)
vName := resourceItem["name"]
vvName := interfaceToString(vName)
if vvProjectName == "" {
project, restyResp1, err := client.ConfigurationTemplates.GetsTheDetailsOfAGivenProject(vvProjectID)
if err != nil {
if restyResp1 != nil {
diags = append(diags, diagErrorWithResponse(
"Failure when executing CreateTemplate", err, restyResp1.String()))
return diags
}
diags = append(diags, diagError(
"Failure when executing CreateTemplate", err))
return diags
}
vvProjectName = project.Name
}
if vvTemplateID != "" {
getResponse2, _, err := client.ConfigurationTemplates.GetsDetailsOfAGivenTemplate(vvTemplateID, nil)
// log.Printf("[DEBUG] getResponse2 sent => %v", responseInterfaceToString(*getResponse2))
if err == nil && getResponse2 != nil {
resourceMap := make(map[string]string)
resourceMap["template_id"] = vvTemplateID
resourceMap["project_id"] = vvProjectID
resourceMap["project_name"] = getResponse2.ProjectName
resourceMap["project_id"] = getResponse2.ProjectID
resourceMap["template_name"] = getResponse2.Name
d.SetId(joinResourceID(resourceMap))
return resourceConfigurationTemplateRead(ctx, d, m)
}
} else {
queryParamImport := dnacentersdkgo.GetsTheTemplatesAvailableQueryParams{}
queryParamImport.ProjectID = vvProjectID
queryParamImport := dnacentersdkgo.GetsAListOfProjectsQueryParams{}
queryParamImport.Name = vvProjectName

response2, err := searchConfigurationTemplatesGetsTheTemplatesAvailable(m, queryParamImport, vvName)
// log.Printf("[DEBUG] response2 sent => %v", responseInterfaceToString(*response2))
if response2 != nil && err == nil {
resourceMap := make(map[string]string)
resourceMap["template_id"] = response2.TemplateID
resourceMap["template_name"] = response2.Name
resourceMap["project_name"] = response2.ProjectName
resourceMap["template_id"] = response2.ID
resourceMap["project_id"] = response2.ProjectID
d.SetId(joinResourceID(resourceMap))
return resourceConfigurationTemplateRead(ctx, d, m)
Expand Down Expand Up @@ -2300,8 +2319,8 @@ func resourceConfigurationTemplateCreate(ctx context.Context, d *schema.Resource
return diags
}
}
queryParamValidate := dnacentersdkgo.GetsTheTemplatesAvailableQueryParams{}
queryParamValidate.ProjectID = vvProjectID
queryParamValidate := dnacentersdkgo.GetsAListOfProjectsQueryParams{}
queryParamValidate.Name = vvProjectName
item3, err := searchConfigurationTemplatesGetsTheTemplatesAvailable(m, queryParamValidate, vvName)
if err != nil || item3 == nil {
diags = append(diags, diagErrorWithAlt(
Expand All @@ -2311,41 +2330,44 @@ func resourceConfigurationTemplateCreate(ctx context.Context, d *schema.Resource
}

resourceMap := make(map[string]string)
resourceMap["template_id"] = item3.TemplateID
resourceMap["template_name"] = item3.Name
resourceMap["project_name"] = item3.ProjectName
resourceMap["template_id"] = item3.ID
resourceMap["project_id"] = item3.ProjectID
d.SetId(joinResourceID(resourceMap))
return resourceConfigurationTemplateRead(ctx, d, m)
}

func resourceConfigurationTemplateRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
client := m.(*dnacentersdkgo.Client)
// client := m.(*dnacentersdkgo.Client)

var diags diag.Diagnostics

resourceID := d.Id()
resourceMap := separateResourceID(resourceID)
vTemplateID := resourceMap["template_id"]
vProjectName := resourceMap["project_name"]
vTemplateName := resourceMap["template_name"]

selectedMethod := 1
if selectedMethod == 1 {
log.Printf("[DEBUG] Selected method: GetsDetailsOfAGivenTemplate")
vvTemplateID := vTemplateID
queryParams1 := dnacentersdkgo.GetsDetailsOfAGivenTemplateQueryParams{}
queryParams1 := dnacentersdkgo.GetsAListOfProjectsQueryParams{}
queryParams1.Name = vProjectName

response1, restyResp1, err := client.ConfigurationTemplates.GetsDetailsOfAGivenTemplate(vvTemplateID, &queryParams1)
response1, err := searchConfigurationTemplatesGetsTheTemplatesAvailable(m, queryParams1, vTemplateName)

if err != nil || response1 == nil {
if restyResp1 != nil {
log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String())
}
d.SetId("")
return diags
}

log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1))

// Review flatten function used
vItem1 := flattenConfigurationTemplatesGetsDetailsOfAGivenTemplateItem(response1)
items := []dnacentersdkgo.ResponseItemConfigurationTemplatesGetsAListOfProjectsTemplates{
*response1,
}
vItem1 := flattenConfigurationTemplatesGetsAListOfProjectsItemsTemplates(&items)
if err := d.Set("item", vItem1); err != nil {
diags = append(diags, diagError(
"Failure when setting GetsTheTemplatesAvailable search response",
Expand Down Expand Up @@ -4401,11 +4423,11 @@ func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsTemplateErr
return &request
}

func searchConfigurationTemplatesGetsTheTemplatesAvailable(m interface{}, queryParams dnacentersdkgo.GetsTheTemplatesAvailableQueryParams, vName string) (*dnacentersdkgo.ResponseItemConfigurationTemplatesGetsTheTemplatesAvailable, error) {
func searchConfigurationTemplatesGetsTheTemplatesAvailable(m interface{}, queryParams dnacentersdkgo.GetsAListOfProjectsQueryParams, vName string) (*dnacentersdkgo.ResponseItemConfigurationTemplatesGetsAListOfProjectsTemplates, error) {
client := m.(*dnacentersdkgo.Client)
var err error
var foundItem *dnacentersdkgo.ResponseItemConfigurationTemplatesGetsTheTemplatesAvailable
nResponse, _, err := client.ConfigurationTemplates.GetsTheTemplatesAvailable(nil)
var foundItem *dnacentersdkgo.ResponseItemConfigurationTemplatesGetsAListOfProjectsTemplates
nResponse, _, err := client.ConfigurationTemplates.GetsAListOfProjects(&queryParams)

if err != nil {
log.Printf("[DEBUG] Error when search => %s", err.Error())
Expand All @@ -4414,11 +4436,12 @@ func searchConfigurationTemplatesGetsTheTemplatesAvailable(m interface{}, queryP
//maxPageSize := 10
log.Printf("[DEBUG] Start to find a concidence")
for _, item := range *nResponse {
if vName == item.Name {
foundItem = &item
return foundItem, err
for _, item2 := range *item.Templates {
if vName == item2.Name {
foundItem = &item2
return foundItem, err
}
}

}
return foundItem, err
}
20 changes: 20 additions & 0 deletions dnacenter/resource_global_credential_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,30 @@ func resourceGlobalCredentialCli() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"username": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"secure": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"port": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"read_community": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"password": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"netconf_port": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions dnacenter/resource_global_credential_netconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func resourceGlobalCredentialNetconf() *schema.Resource {
Computed: true,
},

"write_community": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"credential_type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Expand Down
20 changes: 15 additions & 5 deletions dnacenter/resource_site.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,21 @@ func resourceSite() *schema.Resource {
Schema: map[string]*schema.Schema{

"additional_info": &schema.Schema{
Description: `Additional Info`,
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{

"attributes": &schema.Schema{
Type: schema.TypeMap,
Computed: true,
},

"name_space": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
},
},
},
"id": &schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion examples/samples/data-sources/dnacenter_app_policy/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.2-beta"
version = "1.1.3-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.2-beta"
version = "1.1.3-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.2-beta"
version = "1.1.3-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.2-beta"
version = "1.1.3-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.2-beta"
version = "1.1.3-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.2-beta"
version = "1.1.3-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.2-beta"
version = "1.1.3-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.2-beta"
version = "1.1.3-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.2-beta"
version = "1.1.3-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.2-beta"
version = "1.1.3-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.2-beta"
version = "1.1.3-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.2-beta"
version = "1.1.3-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
dnacenter = {
version = "1.1.2-beta"
version = "1.1.3-beta"
source = "hashicorp.com/edu/dnacenter"
# "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry
}
Expand Down
Loading

0 comments on commit b20b171

Please sign in to comment.