Skip to content

Commit 3d603d6

Browse files
authored
Deprecate usage on billing permission (#356)
1 parent f9a6cd1 commit 3d603d6

3 files changed

Lines changed: 7 additions & 23 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/terraform-providers/terraform-provider-ns1
22

3-
go 1.23.0
3+
go 1.24
44

55
require (
66
github.com/fatih/structs v1.1.0

ns1/resource_user.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ func userResource() *schema.Resource {
3030
Required: true,
3131
},
3232
"notify": {
33-
Type: schema.TypeMap,
34-
Optional: true,
35-
Elem: schema.TypeBool,
33+
Deprecated: "This field is deprecated and will be removed in a future release; create account usage alerts instead.",
34+
Type: schema.TypeMap,
35+
Optional: true,
36+
Computed: true,
37+
Elem: schema.TypeBool,
3638
},
3739
"teams": {
3840
Type: schema.TypeList,
@@ -76,9 +78,6 @@ func userToResourceData(d *schema.ResourceData, u *account.User) error {
7678
d.Set("name", u.Name)
7779
d.Set("email", u.Email)
7880
d.Set("teams", u.TeamIDs)
79-
notify := make(map[string]bool)
80-
notify["billing"] = u.Notify.Billing
81-
d.Set("notify", notify)
8281
d.Set("ip_whitelist", u.IPWhitelist)
8382
d.Set("ip_whitelist_strict", u.IPWhitelistStrict)
8483
permissionsToResourceData(d, u.Permissions)
@@ -98,10 +97,6 @@ func resourceDataToUser(u *account.User, d *schema.ResourceData) error {
9897
} else {
9998
u.TeamIDs = make([]string, 0)
10099
}
101-
if v, ok := d.GetOk("notify"); ok {
102-
notifyRaw := v.(map[string]interface{})
103-
u.Notify.Billing = notifyRaw["billing"].(bool)
104-
}
105100

106101
if v, ok := d.GetOk("ip_whitelist"); ok {
107102
ipWhitelistRaw := v.(*schema.Set)

ns1/resource_user_test.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"log"
66
"reflect"
7-
"regexp"
87
"sort"
98
"testing"
109

@@ -36,7 +35,6 @@ func TestAccUser_basic(t *testing.T) {
3635
resource.TestCheckResourceAttr("ns1_user.u", "name", name),
3736
resource.TestCheckResourceAttr("ns1_user.u", "teams.#", "1"),
3837
resource.TestCheckResourceAttr("ns1_user.u", "notify.%", "1"),
39-
resource.TestCheckResourceAttr("ns1_user.u", "notify.billing", "true"),
4038
resource.TestCheckResourceAttr("ns1_user.u", "username", username),
4139
testAccCheckUserIPWhitelists(&user, []string{"1.1.1.1", "2.2.2.2"}),
4240
resource.TestCheckResourceAttr("ns1_user.u", "ip_whitelist_strict", "true"),
@@ -50,7 +48,6 @@ func TestAccUser_basic(t *testing.T) {
5048
resource.TestCheckResourceAttr("ns1_user.u", "name", name),
5149
resource.TestCheckResourceAttr("ns1_user.u", "teams.#", "1"),
5250
resource.TestCheckResourceAttr("ns1_user.u", "notify.%", "1"),
53-
resource.TestCheckResourceAttr("ns1_user.u", "notify.billing", "true"),
5451
resource.TestCheckResourceAttr("ns1_user.u", "username", username),
5552
testAccCheckUserIPWhitelists(&user, []string{}),
5653
resource.TestCheckResourceAttr("ns1_user.u", "ip_whitelist_strict", "false"),
@@ -81,13 +78,6 @@ func TestAccUser_ManualDelete(t *testing.T) {
8178
PlanOnly: true,
8279
ExpectNonEmptyPlan: true,
8380
},
84-
// Attempt to re-create it, this should fail because user names must be historically unique.
85-
// Error: PUT https://api.nsone.net/v1/account/users: 409 login name tf_acc_test_user_k8qsnpxghuhgmip already exists
86-
87-
{
88-
Config: testAccUserBasic(rString),
89-
ExpectError: regexp.MustCompile(`PUT .*/account/users.*already exists`),
90-
},
9181
},
9282
})
9383
}
@@ -459,7 +449,6 @@ func TestAccUser_import_test(t *testing.T) {
459449
resource.TestCheckResourceAttr("ns1_user.u", "name", name),
460450
resource.TestCheckResourceAttr("ns1_user.u", "teams.#", "1"),
461451
resource.TestCheckResourceAttr("ns1_user.u", "notify.%", "1"),
462-
resource.TestCheckResourceAttr("ns1_user.u", "notify.billing", "true"),
463452
resource.TestCheckResourceAttr("ns1_user.u", "username", username),
464453
testAccCheckUserIPWhitelists(&user, []string{"1.1.1.1", "2.2.2.2"}),
465454
resource.TestCheckResourceAttr("ns1_user.u", "ip_whitelist_strict", "true"),
@@ -656,7 +645,7 @@ resource "ns1_user" "u" {
656645
email = "tf_acc_test_ns1@hashicorp.com"
657646
teams = ["${ns1_team.t.id}"]
658647
notify = {
659-
billing = true
648+
billing = false
660649
}
661650
ip_whitelist = ["1.1.1.1", "2.2.2.2"]
662651
ip_whitelist_strict = true

0 commit comments

Comments
 (0)