@@ -2,13 +2,10 @@ package tco
2
2
3
3
import (
4
4
"context"
5
- "fmt"
6
- "log"
7
- "strings"
8
-
9
5
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
10
6
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
11
7
organization "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/organization/v20210331"
8
+ "log"
12
9
13
10
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
14
11
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
@@ -59,9 +56,8 @@ func resourceTencentCloudOrganizationOrgManagePolicyCreate(d *schema.ResourceDat
59
56
logId := tccommon .GetLogId (tccommon .ContextNil )
60
57
61
58
var (
62
- policyType string
63
- request = organization .NewCreatePolicyRequest ()
64
- response = organization .NewCreatePolicyResponse ()
59
+ request = organization .NewCreatePolicyRequest ()
60
+ response = organization .NewCreatePolicyResponse ()
65
61
)
66
62
if v , ok := d .GetOk ("name" ); ok {
67
63
request .Name = helper .String (v .(string ))
@@ -72,7 +68,6 @@ func resourceTencentCloudOrganizationOrgManagePolicyCreate(d *schema.ResourceDat
72
68
}
73
69
74
70
if v , ok := d .GetOk ("type" ); ok {
75
- policyType = v .(string )
76
71
request .Type = helper .String (v .(string ))
77
72
}
78
73
@@ -95,7 +90,7 @@ func resourceTencentCloudOrganizationOrgManagePolicyCreate(d *schema.ResourceDat
95
90
return err
96
91
}
97
92
98
- d .SetId (strings . Join ([] string { helper .UInt64ToStr (* response .Response .PolicyId ), policyType }, tccommon . FILED_SP ))
93
+ d .SetId (helper .UInt64ToStr (* response .Response .PolicyId ))
99
94
100
95
return resourceTencentCloudOrganizationOrgManagePolicyRead (d , meta )
101
96
}
@@ -110,12 +105,11 @@ func resourceTencentCloudOrganizationOrgManagePolicyRead(d *schema.ResourceData,
110
105
111
106
service := OrganizationService {client : meta .(tccommon.ProviderMeta ).GetAPIV3Conn ()}
112
107
113
- idSplit := strings .Split (d .Id (), tccommon .FILED_SP )
114
- if len (idSplit ) != 2 {
115
- return fmt .Errorf ("id is broken,%s" , d .Id ())
108
+ policyId := d .Id ()
109
+ var policyType string
110
+ if v , ok := d .GetOk ("type" ); ok {
111
+ policyType = v .(string )
116
112
}
117
- policyId := idSplit [0 ]
118
- policyType := idSplit [1 ]
119
113
120
114
OrgManagePolicy , err := service .DescribeOrganizationOrgManagePolicyById (ctx , policyId , policyType )
121
115
if err != nil {
@@ -154,11 +148,7 @@ func resourceTencentCloudOrganizationOrgManagePolicyUpdate(d *schema.ResourceDat
154
148
155
149
request := organization .NewUpdatePolicyRequest ()
156
150
157
- idSplit := strings .Split (d .Id (), tccommon .FILED_SP )
158
- if len (idSplit ) != 2 {
159
- return fmt .Errorf ("id is broken,%s" , d .Id ())
160
- }
161
- policyId := idSplit [0 ]
151
+ policyId := d .Id ()
162
152
163
153
request .PolicyId = helper .StrToInt64Point (policyId )
164
154
@@ -211,12 +201,11 @@ func resourceTencentCloudOrganizationOrgManagePolicyDelete(d *schema.ResourceDat
211
201
ctx := context .WithValue (context .TODO (), tccommon .LogIdKey , logId )
212
202
213
203
service := OrganizationService {client : meta .(tccommon.ProviderMeta ).GetAPIV3Conn ()}
214
- idSplit := strings .Split (d .Id (), tccommon .FILED_SP )
215
- if len (idSplit ) != 2 {
216
- return fmt .Errorf ("id is broken,%s" , d .Id ())
204
+ policyId := d .Id ()
205
+ var policyType string
206
+ if v , ok := d .GetOk ("type" ); ok {
207
+ policyType = v .(string )
217
208
}
218
- policyId := idSplit [0 ]
219
- policyType := idSplit [1 ]
220
209
221
210
if err := service .DeleteOrganizationOrgManagePolicyById (ctx , policyId , policyType ); err != nil {
222
211
return err
0 commit comments