Skip to content

Commit

Permalink
Merge pull request #72 from cisco-en-programmability/develop
Browse files Browse the repository at this point in the history
## [5.0.21] - 2023-11-20
  • Loading branch information
fmunozmiranda authored Nov 22, 2023
2 parents d034c67 + fb2718d commit eaa9349
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 66 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [5.0.21] - 2023-11-20
- `ResponseConfigurationTemplatesGetProjectsDetails` is now an array.

## [5.0.20] - 2023-11-20
### Changed
- `ResponseNetworkSettingsGetReserveIPSubpoolResponse` changes response.
Expand Down Expand Up @@ -589,4 +592,5 @@ Services removed on Cisco DNA Center 2.3.3.0's API:
[5.0.18]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.17...v5.0.18
[5.0.19]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.18...v5.0.19
[5.0.20]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.19...v5.0.20
[Unreleased]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.20...main
[5.0.21]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.20...v5.0.21
[Unreleased]: https://github.com/cisco-en-programmability/dnacenter-go-sdk/compare/v5.0.21...main
145 changes: 80 additions & 65 deletions examples/configuration_templates/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"encoding/json"
"fmt"

dnac "github.com/cisco-en-programmability/dnacenter-go-sdk/v5/sdk"
Expand All @@ -9,80 +10,94 @@ import (
// client is DNA Center API client
var client *dnac.Client

func responseInterfaceToString(v interface{}) string {
b, err := json.Marshal(v)
if err != nil {
return fmt.Sprint(v)
}
return fmt.Sprint(string(b))
}

func main() {
var err error
projectID := ""
templateId := ""
// projectID := ""
// templateId := ""
fmt.Println("Authenticating...")
client, err = dnac.NewClientWithOptions("https://192.168.196.2/",
"altus", "Altus123",
client, err = dnac.NewClientWithOptions("https://100.119.103.190",
"cloverhound_user", "LABchsys!23$",
"true", "false", nil)
if err != nil {
fmt.Println(err)
return
}

fmt.Println("Printing GetsAListOfProjects")
getListOfProjectsQueryParams := &dnac.GetsAListOfProjectsQueryParams{}
respListOfProjects, _, err := client.ConfigurationTemplates.GetsAListOfProjects(getListOfProjectsQueryParams)
if err != nil {
fmt.Println(err)
return
}

if respListOfProjects != nil {
fmt.Println(respListOfProjects)
projectID = (*respListOfProjects)[0].ID
} else {
fmt.Println("There's no data on GetsAListOfProjects response")
return
}

fmt.Println("Printing DetailsOfAGivenProject")
respDetailsOfAGivenProject, _, err := client.ConfigurationTemplates.GetsTheDetailsOfAGivenProject(projectID)
if err != nil {
fmt.Println(err)
return
}

if respDetailsOfAGivenProject != nil {
fmt.Println(respDetailsOfAGivenProject)
} else {
fmt.Println("There's no data on DetailsOfAGivenProject response")
return
}

fmt.Println("Printing GetsTheTemplatesAvailable")
getTemplatesAvailableQueryParams := &dnac.GetsTheTemplatesAvailableQueryParams{}
respTemplatesAvailable, _, err := client.ConfigurationTemplates.GetsTheTemplatesAvailable(getTemplatesAvailableQueryParams)
if err != nil {
fmt.Println(err)
return
}

if respTemplatesAvailable != nil {
fmt.Println(respTemplatesAvailable)
templateId = (*respTemplatesAvailable)[0].TemplateID
} else {
fmt.Println("There's no data on GetsTheTemplatesAvailable response")
return
}

//Print StatusOfTemplateDeployment can't test

fmt.Println("Printng GetsAllTheVersionsOfAGivenTemplate")
respAllTheVersionsOfAGivenTemplate, _, err := client.ConfigurationTemplates.GetsAllTheVersionsOfAGivenTemplate(templateId)
if err != nil {
fmt.Println(err)
return
}

if respAllTheVersionsOfAGivenTemplate != nil {
fmt.Println(respAllTheVersionsOfAGivenTemplate)
} else {
fmt.Println("There's no data on GetsAllTheVersionsOfAGivenTemplate response")
return
}
// fmt.Println("Printing GetsAListOfProjects")
// getListOfProjectsQueryParams := &dnac.GetsAListOfProjectsQueryParams{}
// respListOfProjects, _, err := client.ConfigurationTemplates.GetsAListOfProjects(getListOfProjectsQueryParams)
// if err != nil {
// fmt.Println(err)
// return
// }

// if respListOfProjects != nil {
// fmt.Println(respListOfProjects)
// projectID = (*respListOfProjects)[0].ID
// } else {
// fmt.Println("There's no data on GetsAListOfProjects response")
// return
// }

// fmt.Println("Printing DetailsOfAGivenProject")
// respDetailsOfAGivenProject, _, err := client.ConfigurationTemplates.GetsTheDetailsOfAGivenProject(projectID)
// if err != nil {
// fmt.Println(err)
// return
// }

// if respDetailsOfAGivenProject != nil {
// fmt.Println(respDetailsOfAGivenProject)
// } else {
// fmt.Println("There's no data on DetailsOfAGivenProject response")
// return
// }

// fmt.Println("Printing GetsTheTemplatesAvailable")
// getTemplatesAvailableQueryParams := &dnac.GetsTheTemplatesAvailableQueryParams{}
// respTemplatesAvailable, _, err := client.ConfigurationTemplates.GetsTheTemplatesAvailable(getTemplatesAvailableQueryParams)
// if err != nil {
// fmt.Println(err)
// return
// }

// if respTemplatesAvailable != nil {
// fmt.Println(respTemplatesAvailable)
// templateId = (*respTemplatesAvailable)[0].TemplateID
// } else {
// fmt.Println("There's no data on GetsTheTemplatesAvailable response")
// return
// }

// //Print StatusOfTemplateDeployment can't test

// fmt.Println("Printng GetsAllTheVersionsOfAGivenTemplate")
// respAllTheVersionsOfAGivenTemplate, _, err := client.ConfigurationTemplates.GetsAllTheVersionsOfAGivenTemplate(templateId)
// if err != nil {
// fmt.Println(err)
// return
// }

// if respAllTheVersionsOfAGivenTemplate != nil {
// fmt.Println(respAllTheVersionsOfAGivenTemplate)
// } else {
// fmt.Println("There's no data on GetsAllTheVersionsOfAGivenTemplate response")
// return
// }

resp, _, err := client.ConfigurationTemplates.GetProjectsDetails(&dnac.GetProjectsDetailsQueryParams{
Name: "Onboarding Configuration",
})

println(responseInterfaceToString(resp))

// /v2 endpoints can't test

Expand Down
5 changes: 5 additions & 0 deletions sdk/configuration_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,12 @@ type ResponseConfigurationTemplatesGetsDetailsOfAGivenTemplateValidationErrors s
}
type ResponseConfigurationTemplatesGetsDetailsOfAGivenTemplateValidationErrorsRollbackTemplateErrors interface{}
type ResponseConfigurationTemplatesGetsDetailsOfAGivenTemplateValidationErrorsTemplateErrors interface{}

type ResponseConfigurationTemplatesGetProjectsDetails struct {
Response []ResponseConfigurationTemplatesGetProjectsDetailsResponse `json:"response,omitempty"` // Response
}

type ResponseConfigurationTemplatesGetProjectsDetailsResponse struct {
CreateTime *int `json:"createTime,omitempty"` // Create time of project
Description string `json:"description,omitempty"` // Description of project
ID string `json:"id,omitempty"` // UUID of project
Expand Down

0 comments on commit eaa9349

Please sign in to comment.