-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: support black list * feat: add changelog * fix: rename
- Loading branch information
Showing
7 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:new-resource | ||
tencentcloud_ses_black_list_delete | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ] | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters