Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support black list #2131

Merged
merged 3 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/2131.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
tencentcloud_ses_black_list_delete
```
2 changes: 2 additions & 0 deletions tencentcloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,7 @@ Simple Email Service(SES)
tencentcloud_ses_send_email
tencentcloud_ses_batch_send_email
tencentcloud_ses_verify_domain
tencentcloud_ses_black_list_delete

Security Token Service(STS)
Data Source
Expand Down Expand Up @@ -2815,6 +2816,7 @@ func Provider() *schema.Provider {
"tencentcloud_ses_send_email": resourceTencentCloudSesSendEmail(),
"tencentcloud_ses_batch_send_email": resourceTencentCloudSesBatchSendEmail(),
"tencentcloud_ses_verify_domain": resourceTencentCloudSesVerifyDomain(),
"tencentcloud_ses_black_list_delete": resourceTencentCloudSesBlackListDelete(),
"tencentcloud_sms_sign": resourceTencentCloudSmsSign(),
"tencentcloud_sms_template": resourceTencentCloudSmsTemplate(),
"tencentcloud_dcdb_account": resourceTencentCloudDcdbAccount(),
Expand Down
90 changes: 90 additions & 0 deletions tencentcloud/resource_tc_ses_black_list_delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
Provides a resource to create a ses black_list

~> **NOTE:** Used to remove email addresses from blacklists.

Example Usage

```hcl
resource "tencentcloud_ses_black_list_delete" "black_list" {
email_address = "[email protected]"
}
```
*/
package tencentcloud

import (
"log"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ses "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ses/v20201002"
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
)

func resourceTencentCloudSesBlackListDelete() *schema.Resource {
return &schema.Resource{
Create: resourceTencentCloudSesBlackListDeleteCreate,
Read: resourceTencentCloudSesBlackListDeleteRead,
Delete: resourceTencentCloudSesBlackListDeleteDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"email_address": {
Required: true,
ForceNew: true,
Type: schema.TypeString,
Description: "Email addresses to be unblocklisted.",
},
},
}
}

func resourceTencentCloudSesBlackListDeleteCreate(d *schema.ResourceData, meta interface{}) error {
defer logElapsed("resource.tencentcloud_ses_black_list_delete.create")()
defer inconsistentCheck(d, meta)()

logId := getLogId(contextNil)

var (
request = ses.NewDeleteBlackListRequest()
emailAddress string
)
if v, ok := d.GetOk("email_address"); ok {
emailAddress = v.(string)
request.EmailAddressList = append(request.EmailAddressList, helper.String(v.(string)))
}

err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
result, e := meta.(*TencentCloudClient).apiV3Conn.UseSesClient().DeleteBlackList(request)
if e != nil {
return retryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
}
return nil
})
if err != nil {
log.Printf("[CRITAL]%s operate ses BlackList failed, reason:%+v", logId, err)
return err
}

d.SetId(emailAddress)

return resourceTencentCloudSesBlackListDeleteRead(d, meta)
}

func resourceTencentCloudSesBlackListDeleteRead(d *schema.ResourceData, meta interface{}) error {
defer logElapsed("resource.tencentcloud_ses_black_list_delete.read")()
defer inconsistentCheck(d, meta)()

return nil
}

func resourceTencentCloudSesBlackListDeleteDelete(d *schema.ResourceData, meta interface{}) error {
defer logElapsed("resource.tencentcloud_ses_black_list_delete.delete")()
defer inconsistentCheck(d, meta)()

return nil
}
50 changes: 50 additions & 0 deletions tencentcloud/resource_tc_ses_black_list_delete_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package tencentcloud

import (
"testing"

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

func TestAccTencentNeedFixCloudSesBlackListResource_basic(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccStepSetRegion(t, "ap-hongkong")
testAccPreCheckBusiness(t, ACCOUNT_TYPE_SES)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccSesBlackList,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("tencentcloud_ses_black_list_delete.black_list", "id"),
),
},
},
})
}

const testAccSesBlackList = `

resource "tencentcloud_ses_send_email" "send_email" {
from_email_address = "[email protected]"
destination = ["[email protected]"]
subject = "test subject"
reply_to_addresses = "[email protected]"

template {
template_id = 99629
template_data = "{\"name\":\"xxx\",\"age\":\"xx\"}"
}

unsubscribe = "1"
trigger_type = 1
}

resource "tencentcloud_ses_black_list_delete" "black_list" {
email_address = "[email protected]"
depends_on = [ tencentcloud_ses_send_email.send_email ]
}

`
37 changes: 37 additions & 0 deletions website/docs/r/ses_black_list.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
subcategory: "Simple Email Service(SES)"
layout: "tencentcloud"
page_title: "TencentCloud: tencentcloud_ses_black_list"
sidebar_current: "docs-tencentcloud-resource-ses_black_list"
description: |-
Provides a resource to create a ses black_list
---

# tencentcloud_ses_black_list

Provides a resource to create a ses black_list

~> **NOTE:** Used to remove email addresses from blacklists.

## Example Usage

```hcl
resource "tencentcloud_ses_black_list" "black_list" {
email_address = "[email protected]"
}
```

## Argument Reference

The following arguments are supported:

* `email_address` - (Required, String, ForceNew) Email addresses to be unblocklisted.

## Attributes Reference

In addition to all arguments above, the following attributes are exported:

* `id` - ID of the resource.



37 changes: 37 additions & 0 deletions website/docs/r/ses_black_list_delete.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
subcategory: "Simple Email Service(SES)"
layout: "tencentcloud"
page_title: "TencentCloud: tencentcloud_ses_black_list_delete"
sidebar_current: "docs-tencentcloud-resource-ses_black_list_delete"
description: |-
Provides a resource to create a ses black_list
---

# tencentcloud_ses_black_list_delete

Provides a resource to create a ses black_list

~> **NOTE:** Used to remove email addresses from blacklists.

## Example Usage

```hcl
resource "tencentcloud_ses_black_list_delete" "black_list" {
email_address = "[email protected]"
}
```

## Argument Reference

The following arguments are supported:

* `email_address` - (Required, String, ForceNew) Email addresses to be unblocklisted.

## Attributes Reference

In addition to all arguments above, the following attributes are exported:

* `id` - ID of the resource.



3 changes: 3 additions & 0 deletions website/tencentcloud.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2581,6 +2581,9 @@
<li>
<a href="/docs/providers/tencentcloud/r/ses_batch_send_email.html">tencentcloud_ses_batch_send_email</a>
</li>
<li>
<a href="/docs/providers/tencentcloud/r/ses_black_list_delete.html">tencentcloud_ses_black_list_delete</a>
</li>
<li>
<a href="/docs/providers/tencentcloud/r/ses_domain.html">tencentcloud_ses_domain</a>
</li>
Expand Down