Skip to content

Commit

Permalink
Devtooling 625: fix export test (#1177)
Browse files Browse the repository at this point in the history
* Adding readonly answer_options.id field to survey resource/exporter

* Implementing the ID field for question_groups & questions in survey resource
  • Loading branch information
charliecon authored Jul 25, 2024
1 parent 5b429a9 commit 2aa318b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
12 changes: 12 additions & 0 deletions docs/resources/quality_forms_survey.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ Optional:
- `na_enabled` (Boolean) Specifies whether a not applicable answer is enabled. Defaults to `false`.
- `visibility_condition` (Block List, Max: 1) Defines conditions where question would be visible (see [below for nested schema](#nestedblock--question_groups--visibility_condition))

Read-Only:

- `id` (String) The ID of the survey question group.

<a id="nestedblock--question_groups--questions"></a>
### Nested Schema for `question_groups.questions`

Expand All @@ -146,6 +150,10 @@ Optional:
- `type` (String) Valid Values: multipleChoiceQuestion, freeTextQuestion, npsQuestion, readOnlyTextBlockQuestion Defaults to `multipleChoiceQuestion`.
- `visibility_condition` (Block List, Max: 1) Defines conditions where question would be visible (see [below for nested schema](#nestedblock--question_groups--questions--visibility_condition))

Read-Only:

- `id` (String) The ID of the survey question.

<a id="nestedblock--question_groups--questions--answer_options"></a>
### Nested Schema for `question_groups.questions.answer_options`

Expand All @@ -158,6 +166,10 @@ Optional:

- `assistance_conditions` (Block Set) Options from which to choose an answer for this question. (see [below for nested schema](#nestedblock--question_groups--questions--answer_options--assistance_conditions))

Read-Only:

- `id` (String) The ID of the survey answer option.

<a id="nestedblock--question_groups--questions--answer_options--assistance_conditions"></a>
### Nested Schema for `question_groups.questions.answer_options.assistance_conditions`

Expand Down
30 changes: 28 additions & 2 deletions genesyscloud/resource_genesyscloud_quality_forms_survey.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ type SurveyFormQuestionStruct struct {
var (
surveyQuestionGroup = &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Description: "The ID of the survey question group.",
Type: schema.TypeString,
Computed: true,
},
"name": {
Description: "Name of display question in question group.",
Type: schema.TypeString,
Expand Down Expand Up @@ -83,6 +88,11 @@ var (

surveyQuestion = &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Description: "The ID of the survey question.",
Type: schema.TypeString,
Computed: true,
},
"text": {
Description: "Individual question",
Type: schema.TypeString,
Expand Down Expand Up @@ -151,6 +161,11 @@ var (

surveyFormAnswerOptions = &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Description: "The ID of the survey answer option.",
Computed: true,
},
"text": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -214,6 +229,11 @@ func SurveyFormExporter() *resourceExporter.ResourceExporter {
GetResourcesFunc: provider.GetAllWithPooledClient(getAllSurveyForms),
RefAttrs: map[string]*resourceExporter.RefAttrSettings{}, // No references
AllowZeroValues: []string{"question_groups.questions.answer_options.value"},
ExcludedAttributes: []string{
"question_groups.id",
"question_groups.questions.id",
"question_groups.questions.answer_options.id",
},
}
}

Expand Down Expand Up @@ -542,10 +562,13 @@ func flattenSurveyQuestionGroups(questionGroups *[]platformclientv2.Surveyquesti
return nil
}

questionGroupList := []interface{}{}
var questionGroupList []interface{}

for _, questionGroup := range *questionGroups {
questionGroupMap := make(map[string]interface{})
if questionGroup.Id != nil {
questionGroupMap["id"] = *questionGroup.Id
}
if questionGroup.Name != nil {
questionGroupMap["name"] = *questionGroup.Name
}
Expand All @@ -569,10 +592,13 @@ func flattenSurveyQuestions(questions *[]platformclientv2.Surveyquestion) []inte
return nil
}

questionList := []interface{}{}
var questionList []interface{}

for _, question := range *questions {
questionMap := make(map[string]interface{})
if question.Id != nil {
questionMap["id"] = *question.Id
}
if question.Text != nil {
questionMap["text"] = *question.Text
}
Expand Down

0 comments on commit 2aa318b

Please sign in to comment.