Skip to content

Commit

Permalink
fix vod sub application status
Browse files Browse the repository at this point in the history
  • Loading branch information
mikatong committed Feb 27, 2024
1 parent 827fd74 commit 0170a6a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tencentcloud/services/vod/resource_tc_vod_sub_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
vod "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod/v20180717"

sdkErrors "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/ratelimit"
)
Expand Down Expand Up @@ -96,8 +97,13 @@ func resourceTencentCloudVodSubApplicationCreate(d *schema.ResourceData, meta in
ratelimit.Check(statusResquest.GetAction())
_, err := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVodClient().ModifySubAppIdStatus(statusResquest)
if err != nil {
if sdkError, ok := err.(*sdkErrors.TencentCloudSDKError); ok {
if sdkError.Code == "FailedOperation" && sdkError.Message == "invalid vod user" {
return resource.RetryableError(err)
}
}
log.Printf("[CRITAL]%s api[%s] fail, reason:%s", logId, request.GetAction(), err.Error())
return tccommon.RetryError(err)
return resource.NonRetryableError(err)
}
return nil
}); err != nil {
Expand Down Expand Up @@ -209,8 +215,13 @@ func resourceTencentCloudVodSubApplicationUpdate(d *schema.ResourceData, meta in
ratelimit.Check(statusRequest.GetAction())
_, err = meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVodClient().ModifySubAppIdStatus(statusRequest)
if err != nil {
if sdkError, ok := err.(*sdkErrors.TencentCloudSDKError); ok {
if sdkError.Code == "FailedOperation" && sdkError.Message == "invalid vod user" {
return resource.RetryableError(err)
}
}
log.Printf("[CRITAL]%s api[%s] fail, reason:%s", logId, statusRequest.GetAction(), err.Error())
return tccommon.RetryError(err)
return resource.NonRetryableError(err)
}
return nil
})
Expand Down
43 changes: 43 additions & 0 deletions tencentcloud/services/vod/resource_tc_vod_sub_application_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package vod_test

import (
"testing"

tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccTencentCloudVodSubApplicationResource(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { tcacctest.AccPreCheck(t) },
Providers: tcacctest.AccProviders,
Steps: []resource.TestStep{
{
Config: testAccVodSubApplication,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("tencentcloud_vod_sub_application.foo", "id"),
resource.TestCheckResourceAttr("tencentcloud_vod_sub_application.foo", "name", "foo"),
resource.TestCheckResourceAttr("tencentcloud_vod_sub_application.foo", "status", "On"),
resource.TestCheckResourceAttr("tencentcloud_vod_sub_application.foo", "description", "this is sub application"),
resource.TestCheckResourceAttrSet("tencentcloud_vod_sub_application.foo", "create_time"),
),
},
{
ResourceName: "tencentcloud_vod_sub_application.foo",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"status"},
},
},
})
}

const testAccVodSubApplication = `
resource "tencentcloud_vod_sub_application" "foo" {
name = "foo"
status = "On"
description = "this is sub application"
}
`

0 comments on commit 0170a6a

Please sign in to comment.