Skip to content

Commit 4a6a048

Browse files
authored
Merge pull request #325 from ns1-terraform/PENG-4485/remove_ddi_related_code
remove ddi related code and bump go sdk version
2 parents 497a3bc + 4b01981 commit 4a6a048

12 files changed

+46
-104
lines changed

examples/user_team_api_key.tf

+8-8
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ resource "ns1_user" "example_whitelist_user" {
8989
## API keys
9090
resource "ns1_apikey" "example" {
9191
name = "Example API Key from Terraform"
92-
dhcp_manage_dhcp = true
93-
dhcp_view_dhcp = true
94-
ipam_manage_ipam = true
95-
ipam_view_ipam = true
92+
monitoring_manage_lists = true
93+
monitoring_manage_jobs = true
94+
monitoring_view_jobs = true
95+
security_manage_global_2fa = true
9696
}
9797

9898

@@ -122,10 +122,10 @@ resource "ns1_apikey" "example" {
122122
#account_view_invoices - (Optional) Whether the user can view invoices.
123123
#account_manage_ip_whitelist - (Optional) Whether the user can manage ip whitelist.
124124
#monitoring_manage_lists - (Optional) Whether the user can modify notification lists.
125-
#monitoring_manage_jobs - (Optional) Whether the user can modify monitoring jobs.
125+
#monitoring_manage_jobs - (Optional) Whether the user can create, update, and delete monitoring jobs.
126+
#monitoring_create_jobs - (Optional) Whether the user can create monitoring jobs when manage_jobs is not set to true.
127+
#monitoring_update_jobs - (Optional) Whether the user can update monitoring jobs when manage_jobs is not set to true.
128+
#monitoring_delete_jobs - (Optional) Whether the user can delete monitoring jobs when manage_jobs is not set to true.
126129
#monitoring_view_jobs - (Optional) Whether the user can view monitoring jobs.
127130
#security_manage_global_2fa - (Optional) Whether the user can manage global two factor authentication.
128131
#security_manage_active_directory - (Optional) Whether the user can manage global active directory. Only relevant for the DDI product.
129-
#dhcp_manage_dhcp - (Optional) Whether the user can manage DHCP. Only relevant for the DDI product.
130-
#dhcp_view_dhcp - (Optional) Whether the user can view DHCP. Only relevant for the DDI product.
131-
#ipam_manage_ipam - (Optional) Whether the user can manage IPAM. Only relevant for the DDI product.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/hashicorp/go-retryablehttp v0.7.7
88
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
99
github.com/stretchr/testify v1.8.1
10-
gopkg.in/ns1/ns1-go.v2 v2.11.0
10+
gopkg.in/ns1/ns1-go.v2 v2.12.0
1111
)
1212

1313
require (

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8
251251
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
252252
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
253253
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
254-
gopkg.in/ns1/ns1-go.v2 v2.11.0 h1:T+rMHhQsQ58bSgGZwX8INxU0sjDO7cWieX9xPr/UEY4=
255-
gopkg.in/ns1/ns1-go.v2 v2.11.0/go.mod h1:pfaU0vECVP7DIOr453z03HXS6dFJpXdNRwOyRzwmPSc=
254+
gopkg.in/ns1/ns1-go.v2 v2.12.0 h1:cqdqQoTx17JmTusfxh5m3e2b36jfUzFAZedv89pFX18=
255+
gopkg.in/ns1/ns1-go.v2 v2.12.0/go.mod h1:pfaU0vECVP7DIOr453z03HXS6dFJpXdNRwOyRzwmPSc=
256256
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
257257
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
258258
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

ns1/config.go

-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ type Config struct {
2929
Key string
3030
Endpoint string
3131
IgnoreSSL bool
32-
EnableDDI bool
3332
RateLimitParallelism int
3433
RetryMax int
3534
UserAgent string
@@ -69,10 +68,6 @@ func (c *Config) Client() (*ns1.Client, error) {
6968
httpClient.Transport = tr
7069
}
7170

72-
if c.EnableDDI {
73-
decos = append(decos, ns1.SetDDIAPI())
74-
}
75-
7671
// If NS1_DEBUG is set, define custom Doer to log HTTP requests made by SDK
7772
if os.Getenv("NS1_DEBUG") != "" {
7873
doer := ns1.Decorate(httpClient, Logging())

ns1/permissions.go

+21-47
Original file line numberDiff line numberDiff line change
@@ -149,43 +149,37 @@ func addPermsSchema(s map[string]*schema.Schema) map[string]*schema.Schema {
149149
Default: false,
150150
DiffSuppressFunc: suppressPermissionDiff,
151151
}
152-
s["monitoring_view_jobs"] = &schema.Schema{
152+
s["monitoring_create_jobs"] = &schema.Schema{
153153
Type: schema.TypeBool,
154154
Optional: true,
155155
Default: false,
156156
DiffSuppressFunc: suppressPermissionDiff,
157157
}
158-
s["security_manage_global_2fa"] = &schema.Schema{
159-
Type: schema.TypeBool,
160-
Optional: true,
161-
Default: true,
162-
DiffSuppressFunc: suppressPermissionDiff,
163-
}
164-
s["security_manage_active_directory"] = &schema.Schema{
158+
s["monitoring_update_jobs"] = &schema.Schema{
165159
Type: schema.TypeBool,
166160
Optional: true,
167-
Default: true,
161+
Default: false,
168162
DiffSuppressFunc: suppressPermissionDiff,
169163
}
170-
s["dhcp_manage_dhcp"] = &schema.Schema{
164+
s["monitoring_delete_jobs"] = &schema.Schema{
171165
Type: schema.TypeBool,
172166
Optional: true,
173-
Default: true,
167+
Default: false,
174168
DiffSuppressFunc: suppressPermissionDiff,
175169
}
176-
s["dhcp_view_dhcp"] = &schema.Schema{
170+
s["monitoring_view_jobs"] = &schema.Schema{
177171
Type: schema.TypeBool,
178172
Optional: true,
179-
Default: true,
173+
Default: false,
180174
DiffSuppressFunc: suppressPermissionDiff,
181175
}
182-
s["ipam_manage_ipam"] = &schema.Schema{
176+
s["security_manage_global_2fa"] = &schema.Schema{
183177
Type: schema.TypeBool,
184178
Optional: true,
185179
Default: true,
186180
DiffSuppressFunc: suppressPermissionDiff,
187181
}
188-
s["ipam_view_ipam"] = &schema.Schema{
182+
s["security_manage_active_directory"] = &schema.Schema{
189183
Type: schema.TypeBool,
190184
Optional: true,
191185
Default: true,
@@ -248,19 +242,14 @@ func permissionsToResourceData(d *schema.ResourceData, permissions account.Permi
248242
d.Set("account_manage_ip_whitelist", permissions.Account.ManageIPWhitelist)
249243
d.Set("monitoring_manage_lists", permissions.Monitoring.ManageLists)
250244
d.Set("monitoring_manage_jobs", permissions.Monitoring.ManageJobs)
245+
d.Set("monitoring_create_jobs", permissions.Monitoring.CreateJobs)
246+
d.Set("monitoring_update_jobs", permissions.Monitoring.UpdateJobs)
247+
d.Set("monitoring_delete_jobs", permissions.Monitoring.DeleteJobs)
251248
d.Set("monitoring_view_jobs", permissions.Monitoring.ViewJobs)
252249
if permissions.Security != nil {
253250
d.Set("security_manage_global_2fa", permissions.Security.ManageGlobal2FA)
254251
d.Set("security_manage_active_directory", permissions.Security.ManageActiveDirectory)
255252
}
256-
if permissions.DHCP != nil {
257-
d.Set("dhcp_manage_dhcp", permissions.DHCP.ManageDHCP)
258-
d.Set("dhcp_view_dhcp", permissions.DHCP.ViewDHCP)
259-
}
260-
if permissions.IPAM != nil {
261-
d.Set("ipam_manage_ipam", permissions.IPAM.ManageIPAM)
262-
d.Set("ipam_view_ipam", permissions.IPAM.ViewIPAM)
263-
}
264253
if permissions.DNS.RecordsAllow != nil {
265254
d.Set("dns_records_allow", dnsRecordsACLtoSchema(permissions.DNS.RecordsAllow))
266255
}
@@ -351,6 +340,15 @@ func resourceDataToPermissions(d *schema.ResourceData) account.PermissionsMap {
351340
if v, ok := d.GetOk("monitoring_manage_jobs"); ok {
352341
p.Monitoring.ManageJobs = v.(bool)
353342
}
343+
if v, ok := d.GetOk("monitoring_create_jobs"); ok {
344+
p.Monitoring.CreateJobs = v.(bool)
345+
}
346+
if v, ok := d.GetOk("monitoring_update_jobs"); ok {
347+
p.Monitoring.UpdateJobs = v.(bool)
348+
}
349+
if v, ok := d.GetOk("monitoring_delete_jobs"); ok {
350+
p.Monitoring.DeleteJobs = v.(bool)
351+
}
354352
if v, ok := d.GetOk("monitoring_view_jobs"); ok {
355353
p.Monitoring.ViewJobs = v.(bool)
356354
}
@@ -363,30 +361,6 @@ func resourceDataToPermissions(d *schema.ResourceData) account.PermissionsMap {
363361
if v, ok := d.GetOk("security_manage_active_directory"); ok {
364362
p.Security.ManageActiveDirectory = v.(bool)
365363
}
366-
for _, thing := range []string{"dhcp_manage_dhcp", "dhcp_view_dhcp"} {
367-
_, ok := d.GetOkExists(thing)
368-
if d.HasChange(thing) || ok {
369-
p.DHCP = &account.PermissionsDHCP{}
370-
}
371-
}
372-
if v, ok := d.GetOk("dhcp_manage_dhcp"); ok {
373-
p.DHCP.ManageDHCP = v.(bool)
374-
}
375-
if v, ok := d.GetOk("dhcp_view_dhcp"); ok {
376-
p.DHCP.ViewDHCP = v.(bool)
377-
}
378-
for _, thing := range []string{"ipam_manage_ipam", "ipam_view_ipam"} {
379-
_, ok := d.GetOkExists(thing)
380-
if d.HasChange(thing) || ok {
381-
p.IPAM = &account.PermissionsIPAM{}
382-
}
383-
}
384-
if v, ok := d.GetOk("ipam_manage_ipam"); ok {
385-
p.IPAM.ManageIPAM = v.(bool)
386-
}
387-
if v, ok := d.GetOk("ipam_view_ipam"); ok {
388-
p.IPAM.ViewIPAM = v.(bool)
389-
}
390364
return p
391365
}
392366

ns1/permissions_migrations.go

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ import (
99
func permissionInstanceStateUpgradeV0(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
1010
rawState["security_manage_global_2fa"] = false
1111
rawState["security_manage_active_directory"] = false
12-
rawState["dhcp_manage_dhcp"] = false
13-
rawState["dhcp_view_dhcp"] = false
14-
rawState["ipam_manage_ipam"] = false
15-
rawState["ipam_view_ipam"] = false
1612

1713
return rawState, nil
1814
}

ns1/provider.go

-10
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ func Provider() *schema.Provider {
3030
DefaultFunc: schema.EnvDefaultFunc("NS1_IGNORE_SSL", nil),
3131
Description: descriptions["ignore_ssl"],
3232
},
33-
"enable_ddi": {
34-
Type: schema.TypeBool,
35-
Optional: true,
36-
DefaultFunc: schema.EnvDefaultFunc("NS1_ENABLE_DDI", nil),
37-
Description: descriptions["enable_ddi"],
38-
},
3933
"rate_limit_parallelism": {
4034
Type: schema.TypeInt,
4135
Optional: true,
@@ -108,9 +102,6 @@ func ns1Configure(d *schema.ResourceData) (interface{}, error) {
108102
if v, ok := d.GetOk("ignore_ssl"); ok {
109103
config.IgnoreSSL = v.(bool)
110104
}
111-
if v, ok := d.GetOk("enable_ddi"); ok {
112-
config.EnableDDI = v.(bool)
113-
}
114105
if v, ok := d.GetOk("rate_limit_parallelism"); ok {
115106
config.RateLimitParallelism = v.(int)
116107
}
@@ -134,7 +125,6 @@ func init() {
134125
"rate_limit_parallelism": "Tune response to rate limits, see docs",
135126
"retry_max": "Maximum retries for 50x errors (-1 to disable)",
136127
"user_agent": "User-Agent string to use in NS1 API requests",
137-
"enable_ddi": "Deprecated, no longer in use",
138128
}
139129

140130
structs.DefaultTagName = "json"

ns1/resource_team_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func TestAccTeam_ManualDelete(t *testing.T) {
116116
func TestAccTeam_import_test(t *testing.T) {
117117
var team account.Team
118118
n := fmt.Sprintf("terraform test team %s", acctest.RandStringFromCharSet(15, acctest.CharSetAlphaNum))
119-
ignored_fields := []string{"dhcp_manage_dhcp", "dhcp_view_dhcp", "ipam_manage_ipam", "ipam_view_ipam", "dns_records"}
119+
ignored_fields := []string{"dns_records"}
120120

121121
resource.Test(t, resource.TestCase{
122122
PreCheck: func() { testAccPreCheck(t) },

ns1/resource_user_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ func TestAccUser_import_test(t *testing.T) {
444444
rString := acctest.RandStringFromCharSet(15, acctest.CharSetAlphaNum)
445445
name := fmt.Sprintf("terraform acc test user %s", rString)
446446
username := fmt.Sprintf("tf_acc_test_user_%s", rString)
447-
ignored_fields := []string{"dhcp_manage_dhcp", "dhcp_view_dhcp", "ipam_manage_ipam", "ipam_view_ipam"}
447+
ignored_fields := []string{""}
448448

449449
resource.Test(t, resource.TestCase{
450450
PreCheck: func() { testAccPreCheck(t) },

website/docs/r/apikey.html.markdown

+4-9
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,14 @@ The following arguments are supported:
7070
* `account_view_invoices` - (Optional) Whether the apikey can view invoices.
7171
* `account_manage_ip_whitelist` - (Optional) Whether the apikey can manage ip whitelist.
7272
* `monitoring_manage_lists` - (Optional) Whether the apikey can modify notification lists.
73-
* `monitoring_manage_jobs` - (Optional) Whether the apikey can modify monitoring jobs.
73+
* `monitoring_manage_jobs` - (Optional) Whether the user can create, update, and delete monitoring jobs.
74+
* `monitoring_create_jobs` - (Optional) Whether the user can create monitoring jobs when manage_jobs is not set to true.
75+
* `monitoring_update_jobs` - (Optional) Whether the user can update monitoring jobs when manage_jobs is not set to true.
76+
* `monitoring_delete_jobs` - (Optional) Whether the user can delete monitoring jobs when manage_jobs is not set to true.
7477
* `monitoring_view_jobs` - (Optional) Whether the apikey can view monitoring jobs.
7578
* `security_manage_global_2fa` - (Optional) Whether the apikey can manage global two factor authentication.
7679
* `security_manage_active_directory` - (Optional) Whether the apikey can manage global active directory.
7780
Only relevant for the DDI product.
78-
* `dhcp_manage_dhcp` - (Optional) Whether the apikey can manage DHCP.
79-
Only relevant for the DDI product.
80-
* `dhcp_view_dhcp` - (Optional) Whether the apikey can view DHCP.
81-
Only relevant for the DDI product.
82-
* `ipam_manage_ipam` - (Optional) Whether the apikey can manage IPAM.
83-
Only relevant for the DDI product.
84-
* `ipam_view_ipam` - (Optional) Whether the apikey can view IPAM.
85-
Only relevant for the DDI product.
8681

8782
## Attributes Reference
8883

website/docs/r/team.html.markdown

+4-9
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,14 @@ The following arguments are supported:
8080
* `account_view_invoices` - (Optional) Whether the team can view invoices.
8181
* `account_manage_ip_whitelist` - (Optional) Whether the team can manage ip whitelist.
8282
* `monitoring_manage_lists` - (Optional) Whether the team can modify notification lists.
83-
* `monitoring_manage_jobs` - (Optional) Whether the team can modify monitoring jobs.
83+
* `monitoring_manage_jobs` - (Optional) Whether the user can create, update, and delete monitoring jobs.
84+
* `monitoring_create_jobs` - (Optional) Whether the user can create monitoring jobs when manage_jobs is not set to true.
85+
* `monitoring_update_jobs` - (Optional) Whether the user can update monitoring jobs when manage_jobs is not set to true.
86+
* `monitoring_delete_jobs` - (Optional) Whether the user can delete monitoring jobs when manage_jobs is not set to true.
8487
* `monitoring_view_jobs` - (Optional) Whether the team can view monitoring jobs.
8588
* `security_manage_global_2fa` - (Optional) Whether the team can manage global two factor authentication.
8689
* `security_manage_active_directory` - (Optional) Whether the team can manage global active directory.
8790
Only relevant for the DDI product.
88-
* `dhcp_manage_dhcp` - (Optional) Whether the team can manage DHCP.
89-
Only relevant for the DDI product.
90-
* `dhcp_view_dhcp` - (Optional) Whether the team can view DHCP.
91-
Only relevant for the DDI product.
92-
* `ipam_manage_ipam` - (Optional) Whether the team can manage IPAM.
93-
Only relevant for the DDI product.
94-
* `ipam_view_ipam` - (Optional) Whether the team can view IPAM.
95-
Only relevant for the DDI product.
9691

9792
## Import
9893

website/docs/r/user.html.markdown

+4-7
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,14 @@ The following arguments are supported:
7777
* `account_view_invoices` - (Optional) Whether the user can view invoices.
7878
* `account_manage_ip_whitelist` - (Optional) Whether the user can manage ip whitelist.
7979
* `monitoring_manage_lists` - (Optional) Whether the user can modify notification lists.
80-
* `monitoring_manage_jobs` - (Optional) Whether the user can modify monitoring jobs.
80+
* `monitoring_manage_jobs` - (Optional) Whether the user can create, update, and delete monitoring jobs.
81+
* `monitoring_create_jobs` - (Optional) Whether the user can create monitoring jobs when manage_jobs is not set to true.
82+
* `monitoring_update_jobs` - (Optional) Whether the user can update monitoring jobs when manage_jobs is not set to true.
83+
* `monitoring_delete_jobs` - (Optional) Whether the user can delete monitoring jobs when manage_jobs is not set to true.
8184
* `monitoring_view_jobs` - (Optional) Whether the user can view monitoring jobs.
8285
* `security_manage_global_2fa` - (Optional) Whether the user can manage global two factor authentication.
8386
* `security_manage_active_directory` - (Optional) Whether the user can manage global active directory.
8487
Only relevant for the DDI product.
85-
* `dhcp_manage_dhcp` - (Optional) Whether the user can manage DHCP.
86-
Only relevant for the DDI product.
87-
* `dhcp_view_dhcp` - (Optional) Whether the user can view DHCP.
88-
Only relevant for the DDI product.
89-
* `ipam_manage_ipam` - (Optional) Whether the user can manage IPAM.
90-
Only relevant for the DDI product.
9188

9289
## Import
9390

0 commit comments

Comments
 (0)