Skip to content

Commit f8bd980

Browse files
committed
add
1 parent e2fd8e0 commit f8bd980

13 files changed

+6521
-5629
lines changed

tencentcloud/provider.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,7 @@ func Provider() *schema.Provider {
12441244
"tencentcloud_organization_org_share_unit_members": tco.DataSourceTencentCloudOrganizationOrgShareUnitMembers(),
12451245
"tencentcloud_role_configuration_provisionings": tco.DataSourceTencentCloudRoleConfigurationProvisionings(),
12461246
"tencentcloud_organization_resource_to_share_member": tco.DataSourceTencentCloudOrganizationResourceToShareMember(),
1247+
"tencentcloud_organization_org_share_area": tco.DataSourceTencentCloudOrganizationOrgShareArea(),
12471248
"tencentcloud_pts_scenario_with_jobs": pts.DataSourceTencentCloudPtsScenarioWithJobs(),
12481249
"tencentcloud_cam_list_attached_user_policy": cam.DataSourceTencentCloudCamListAttachedUserPolicy(),
12491250
"tencentcloud_cam_secret_last_used_time": cam.DataSourceTencentCloudCamSecretLastUsedTime(),
@@ -1280,7 +1281,6 @@ func Provider() *schema.Provider {
12801281
"tencentcloud_clickhouse_spec": cdwch.DataSourceTencentCloudClickhouseSpec(),
12811282
"tencentcloud_clickhouse_instance_shards": cdwch.DataSourceTencentCloudClickhouseInstanceShards(),
12821283
"tencentcloud_clickhouse_instance_nodes": cdwch.DataSourceTencentCloudClickhouseInstanceNodes(),
1283-
"tencentcloud_organization_org_share_area": tco.DataSourceTencentCloudOrganizationOrgShareArea(),
12841284
"tencentcloud_kubernetes_cluster_native_node_pools": tke.DataSourceTencentCloudKubernetesClusterNativeNodePools(),
12851285
"tencentcloud_cdc_dedicated_cluster_hosts": cdc.DataSourceTencentCloudCdcDedicatedClusterHosts(),
12861286
"tencentcloud_cdc_dedicated_cluster_instance_types": cdc.DataSourceTencentCloudCdcDedicatedClusterInstanceTypes(),
@@ -1621,7 +1621,6 @@ func Provider() *schema.Provider {
16211621
"tencentcloud_cam_user_permission_boundary_attachment": cam.ResourceTencentCloudCamUserPermissionBoundaryAttachment(),
16221622
"tencentcloud_cam_role_permission_boundary_attachment": cam.ResourceTencentCloudCamRolePermissionBoundaryAttachment(),
16231623
"tencentcloud_cam_message_receiver": cam.ResourceTencentCloudCamMessageReceiver(),
1624-
"tencentcloud_organization_quit_organization_operation": tco.ResourceTencentCloudOrganizationQuitOrganizationOperation(),
16251624
"tencentcloud_ciam_user_group": ciam.ResourceTencentCloudCiamUserGroup(),
16261625
"tencentcloud_ciam_user_store": ciam.ResourceTencentCloudCiamUserStore(),
16271626
"tencentcloud_scf_function": scf.ResourceTencentCloudScfFunction(),
@@ -2042,6 +2041,7 @@ func Provider() *schema.Provider {
20422041
"tencentcloud_tat_invoker_config": tat.ResourceTencentCloudTatInvokerConfig(),
20432042
"tencentcloud_tat_invocation_invoke_attachment": tat.ResourceTencentCloudTatInvocationInvokeAttachment(),
20442043
"tencentcloud_tat_invocation_command_attachment": tat.ResourceTencentCloudTatInvocationCommandAttachment(),
2044+
"tencentcloud_organization_quit_organization_operation": tco.ResourceTencentCloudOrganizationQuitOrganizationOperation(),
20452045
"tencentcloud_organization_org_node": tco.ResourceTencentCloudOrganizationOrgNode(),
20462046
"tencentcloud_organization_org_member": tco.ResourceTencentCloudOrganizationOrgMember(),
20472047
"tencentcloud_organization_org_identity": tco.ResourceTencentCloudOrganizationOrgIdentity(),
@@ -2071,6 +2071,13 @@ func Provider() *schema.Provider {
20712071
"tencentcloud_identity_center_scim_synchronization_status": tco.ResourceTencentCloudIdentityCenterScimSynchronizationStatus(),
20722072
"tencentcloud_provision_role_configuration_operation": tco.ResourceTencentCloudProvisionRoleConfigurationOperation(),
20732073
"tencentcloud_organization_member_auth_policy_attachment": tco.ResourceTencentCloudOrganizationMemberAuthPolicyAttachment(),
2074+
"tencentcloud_organization_org_share_unit_member": tco.ResourceTencentCloudOrganizationOrgShareUnitMember(),
2075+
"tencentcloud_organization_org_share_unit": tco.ResourceTencentCloudOrganizationOrgShareUnit(),
2076+
"tencentcloud_organization_org_share_unit_resource": tco.ResourceTencentCloudOrganizationOrgShareUnitResource(),
2077+
"tencentcloud_accept_join_share_unit_invitation_operation": tco.ResourceTencentCloudAcceptJoinShareUnitInvitationOperation(),
2078+
"tencentcloud_reject_join_share_unit_invitation_operation": tco.ResourceTencentCloudRejectJoinShareUnitInvitationOperation(),
2079+
"tencentcloud_organization_external_saml_idp_certificate": tco.ResourceTencentCloudOrganizationExternalSamlIdpCertificate(),
2080+
"tencentcloud_organization_external_saml_identity_provider": tco.ResourceTencentCloudOrganizationExternalSamlIdentityProvider(),
20742081
"tencentcloud_dbbrain_sql_filter": dbbrain.ResourceTencentCloudDbbrainSqlFilter(),
20752082
"tencentcloud_dbbrain_security_audit_log_export_task": dbbrain.ResourceTencentCloudDbbrainSecurityAuditLogExportTask(),
20762083
"tencentcloud_dbbrain_db_diag_report_task": dbbrain.ResourceTencentCloudDbbrainDbDiagReportTask(),

tencentcloud/provider.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,8 @@ tencentcloud_accept_join_share_unit_invitation_operation
18041804
tencentcloud_reject_join_share_unit_invitation_operation
18051805
tencentcloud_provision_role_configuration_operation
18061806
tencentcloud_organization_member_auth_policy_attachment
1807+
tencentcloud_organization_external_saml_idp_certificate
1808+
tencentcloud_organization_external_saml_identity_provider
18071809

18081810
TDSQL-C for PostgreSQL(TDCPG)
18091811
Data Source
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
package tco
2+
3+
import (
4+
"context"
5+
"log"
6+
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
8+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
9+
organizationv20210331 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/organization/v20210331"
10+
11+
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
12+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
13+
)
14+
15+
func ResourceTencentCloudOrganizationExternalSamlIdentityProvider() *schema.Resource {
16+
return &schema.Resource{
17+
Create: resourceTencentCloudOrganizationExternalSamlIdentityProviderCreate,
18+
Read: resourceTencentCloudOrganizationExternalSamlIdentityProviderRead,
19+
Delete: resourceTencentCloudOrganizationExternalSamlIdentityProviderDelete,
20+
Schema: map[string]*schema.Schema{
21+
"zone_id": {
22+
Type: schema.TypeString,
23+
Required: true,
24+
ForceNew: true,
25+
Description: "Space ID.",
26+
},
27+
28+
"encoded_metadata_document": {
29+
Type: schema.TypeString,
30+
Optional: true,
31+
ForceNew: true,
32+
Description: "IdP metadata document (Base64 encoded). Provided by an IdP that supports the SAML 2.0 protocol.",
33+
},
34+
35+
"sso_status": {
36+
Type: schema.TypeString,
37+
Optional: true,
38+
ForceNew: true,
39+
Description: "SSO enabling status. Valid values: Enabled, Disabled (default).",
40+
},
41+
42+
"entity_id": {
43+
Type: schema.TypeString,
44+
Optional: true,
45+
ForceNew: true,
46+
Description: "IdP identifier.",
47+
},
48+
49+
"login_url": {
50+
Type: schema.TypeString,
51+
Optional: true,
52+
ForceNew: true,
53+
Description: "IdP login URL.",
54+
},
55+
56+
"x509_certificate": {
57+
Type: schema.TypeString,
58+
Optional: true,
59+
ForceNew: true,
60+
Description: "X509 certificate in PEM format. If this parameter is specified, all existing certificates will be replaced.",
61+
},
62+
63+
// computed
64+
"create_time": {
65+
Type: schema.TypeString,
66+
Computed: true,
67+
Description: "Create time.",
68+
},
69+
70+
"update_time": {
71+
Type: schema.TypeString,
72+
Computed: true,
73+
Description: "Update time.",
74+
},
75+
},
76+
}
77+
}
78+
79+
func resourceTencentCloudOrganizationExternalSamlIdentityProviderCreate(d *schema.ResourceData, meta interface{}) error {
80+
defer tccommon.LogElapsed("resource.tencentcloud_organization_external_saml_identity_provider.create")()
81+
defer tccommon.InconsistentCheck(d, meta)()
82+
83+
var (
84+
logId = tccommon.GetLogId(tccommon.ContextNil)
85+
ctx = tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta)
86+
request = organizationv20210331.NewSetExternalSAMLIdentityProviderRequest()
87+
zoneId string
88+
)
89+
90+
if v, ok := d.GetOk("zone_id"); ok {
91+
request.ZoneId = helper.String(v.(string))
92+
zoneId = v.(string)
93+
}
94+
95+
if v, ok := d.GetOk("encoded_metadata_document"); ok {
96+
request.EncodedMetadataDocument = helper.String(v.(string))
97+
}
98+
99+
if v, ok := d.GetOk("sso_status"); ok {
100+
request.SSOStatus = helper.String(v.(string))
101+
}
102+
103+
if v, ok := d.GetOk("entity_id"); ok {
104+
request.EntityId = helper.String(v.(string))
105+
}
106+
107+
if v, ok := d.GetOk("login_url"); ok {
108+
request.LoginUrl = helper.String(v.(string))
109+
}
110+
111+
if v, ok := d.GetOk("x509_certificate"); ok {
112+
request.X509Certificate = helper.String(v.(string))
113+
}
114+
115+
reqErr := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
116+
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseOrganizationClient().SetExternalSAMLIdentityProviderWithContext(ctx, request)
117+
if e != nil {
118+
return tccommon.RetryError(e)
119+
} else {
120+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
121+
}
122+
123+
return nil
124+
})
125+
126+
if reqErr != nil {
127+
log.Printf("[CRITAL]%s create organization external saml identity provider failed, reason:%+v", logId, reqErr)
128+
return reqErr
129+
}
130+
131+
d.SetId(zoneId)
132+
return resourceTencentCloudOrganizationExternalSamlIdentityProviderRead(d, meta)
133+
}
134+
135+
func resourceTencentCloudOrganizationExternalSamlIdentityProviderRead(d *schema.ResourceData, meta interface{}) error {
136+
defer tccommon.LogElapsed("resource.tencentcloud_organization_external_saml_identity_provider.read")()
137+
defer tccommon.InconsistentCheck(d, meta)()
138+
139+
var (
140+
logId = tccommon.GetLogId(tccommon.ContextNil)
141+
ctx = tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta)
142+
service = OrganizationService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
143+
zoneId = d.Id()
144+
)
145+
146+
respData, err := service.DescribeOrganizationExternalSamlIdentityProviderById(ctx, zoneId)
147+
if err != nil {
148+
return err
149+
}
150+
151+
if respData == nil {
152+
log.Printf("[WARN]%s resource `tencentcloud_organization_external_saml_identity_provider` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
153+
d.SetId("")
154+
return nil
155+
}
156+
157+
_ = d.Set("zone_id", zoneId)
158+
159+
if respData.EncodedMetadataDocument != nil {
160+
_ = d.Set("encoded_metadata_document", respData.EncodedMetadataDocument)
161+
}
162+
163+
if respData.SSOStatus != nil {
164+
_ = d.Set("sso_status", respData.SSOStatus)
165+
}
166+
167+
if respData.EntityId != nil {
168+
_ = d.Set("entity_id", respData.EntityId)
169+
}
170+
171+
if respData.LoginUrl != nil {
172+
_ = d.Set("login_url", respData.LoginUrl)
173+
}
174+
175+
if respData.CertificateIds != nil {
176+
_ = d.Set("certificate_ids", respData.CertificateIds)
177+
}
178+
179+
if respData.CreateTime != nil {
180+
_ = d.Set("create_time", respData.CreateTime)
181+
}
182+
183+
if respData.UpdateTime != nil {
184+
_ = d.Set("update_time", respData.UpdateTime)
185+
}
186+
187+
return nil
188+
}
189+
190+
func resourceTencentCloudOrganizationExternalSamlIdentityProviderDelete(d *schema.ResourceData, meta interface{}) error {
191+
defer tccommon.LogElapsed("resource.tencentcloud_organization_external_saml_identity_provider.delete")()
192+
defer tccommon.InconsistentCheck(d, meta)()
193+
194+
var (
195+
logId = tccommon.GetLogId(tccommon.ContextNil)
196+
ctx = tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta)
197+
request = organizationv20210331.NewClearExternalSAMLIdentityProviderRequest()
198+
zoneId = d.Id()
199+
)
200+
201+
request.ZoneId = &zoneId
202+
reqErr := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
203+
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseOrganizationClient().ClearExternalSAMLIdentityProviderWithContext(ctx, request)
204+
if e != nil {
205+
return tccommon.RetryError(e)
206+
} else {
207+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
208+
}
209+
210+
return nil
211+
})
212+
213+
if reqErr != nil {
214+
log.Printf("[CRITAL]%s delete organization external saml identity provider failed, reason:%+v", logId, reqErr)
215+
return reqErr
216+
}
217+
218+
return nil
219+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Provides a resource to create a organization organization_external_saml_identity_provider
2+
3+
Example Usage
4+
5+
```hcl
6+
resource "tencentcloud_organization_external_saml_identity_provider" "organization_external_saml_identity_provider" {
7+
}
8+
```
9+
10+
Import
11+
12+
organization organization_external_saml_identity_provider can be imported using the id, e.g.
13+
14+
```
15+
terraform import tencentcloud_organization_external_saml_identity_provider.organization_external_saml_identity_provider organization_external_saml_identity_provider_id
16+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package tco_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
7+
8+
tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"
9+
)
10+
11+
func TestAccTencentCloudOrganizationExternalSamlIdentityProviderResource_basic(t *testing.T) {
12+
t.Parallel()
13+
resource.Test(t, resource.TestCase{
14+
PreCheck: func() {
15+
tcacctest.AccPreCheck(t)
16+
},
17+
Providers: tcacctest.AccProviders,
18+
Steps: []resource.TestStep{{
19+
Config: testAccOrganizationExternalSamlIdentityProvider,
20+
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_organization_external_saml_identity_provider.organization_external_saml_identity_provider", "id")),
21+
}, {
22+
ResourceName: "tencentcloud_organization_external_saml_identity_provider.organization_external_saml_identity_provider",
23+
ImportState: true,
24+
ImportStateVerify: true,
25+
}},
26+
})
27+
}
28+
29+
const testAccOrganizationExternalSamlIdentityProvider = `
30+
31+
resource "tencentcloud_organization_external_saml_identity_provider" "organization_external_saml_identity_provider" {
32+
}
33+
`

0 commit comments

Comments
 (0)