Skip to content

Commit 73cd0ea

Browse files
authored
Fix communications group conditions and add test coverage (#166)
* Fix communications group conditions and add test coverage * Add additional tests * Add validation for communication channel to communications group * Test remove conditions from communications group * Update docs [skip ci]
1 parent 5c7b766 commit 73cd0ea

File tree

6 files changed

+468
-30
lines changed

6 files changed

+468
-30
lines changed

client/communications_groups.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// DO NOT MODIFY: This file is generated by tools/generate.js. Any changes will be overwritten during the next build.
2-
31
package client
42

53
import (

docs/resources/communications_group.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ Optional:
7171

7272
Optional:
7373

74-
- `email` (String) Email of the group member
7574
- `id` (String) ID of the group member
76-
- `name` (String) Name of the group member
7775
- `user_id` (Number) User ID
7876

7977
## Import

provider/resource_communications_group.go

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// DO NOT MODIFY: This file is generated by tools/generate.js. Any changes will be overwritten during the next build.
2-
31
package provider
42

53
import (
@@ -24,6 +22,20 @@ func resourceCommunicationsGroup() *schema.Resource {
2422
Importer: &schema.ResourceImporter{
2523
StateContext: schema.ImportStatePassthroughContext,
2624
},
25+
CustomizeDiff: func(ctx context.Context, d *schema.ResourceDiff, meta interface{}) error {
26+
emailChannel, emailSet := d.GetOk("email_channel")
27+
smsChannel, smsSet := d.GetOk("sms_channel")
28+
29+
// Check if at least one channel is explicitly set to true
30+
hasEmailChannel := emailSet && emailChannel.(bool)
31+
hasSmsChannel := smsSet && smsChannel.(bool)
32+
33+
if !hasEmailChannel && !hasSmsChannel {
34+
return fmt.Errorf("at least one of 'email_channel' or 'sms_channel' must be set to true")
35+
}
36+
37+
return nil
38+
},
2739
Schema: map[string]*schema.Schema{
2840

2941
"name": &schema.Schema{
@@ -237,28 +249,6 @@ func resourceCommunicationsGroup() *schema.Resource {
237249
WriteOnly: false,
238250
Description: "User ID",
239251
},
240-
241-
"name": &schema.Schema{
242-
Type: schema.TypeString,
243-
Computed: true,
244-
Required: false,
245-
Optional: true,
246-
Sensitive: false,
247-
ForceNew: false,
248-
WriteOnly: false,
249-
Description: "Name of the group member",
250-
},
251-
252-
"email": &schema.Schema{
253-
Type: schema.TypeString,
254-
Computed: true,
255-
Required: false,
256-
Optional: true,
257-
Sensitive: false,
258-
ForceNew: false,
259-
WriteOnly: false,
260-
Description: "Email of the group member",
261-
},
262252
},
263253
},
264254
},
@@ -434,8 +424,6 @@ func resourceCommunicationsGroupRead(ctx context.Context, d *schema.ResourceData
434424
processed_item_communication_group_members := map[string]interface{}{
435425
"id": rawItem["id"],
436426
"user_id": rawItem["user_id"],
437-
"name": rawItem["name"],
438-
"email": rawItem["email"],
439427
}
440428
processed_items_communication_group_members = append(processed_items_communication_group_members, processed_item_communication_group_members)
441429
}

0 commit comments

Comments
 (0)