From 61f4f3cb861400a44b7b12ac3bf8bf3eda02dfa5 Mon Sep 17 00:00:00 2001 From: hellertang Date: Tue, 26 Sep 2023 21:23:27 +0800 Subject: [PATCH] add trocket rile (#2153) * add trocket rile * add changelog * fix lint --- .changelog/2153.txt | 3 + go.mod | 4 +- go.sum | 11 +- tencentcloud/provider.go | 2 + .../resource_tc_trocket_rocketmq_role.go | 293 +++++++++++++++ .../resource_tc_trocket_rocketmq_role_test.go | 92 +++++ tencentcloud/service_tencentcloud_trocket.go | 77 ++++ .../tencentcloud/common/http/request.go | 2 +- .../tencentcloud/trocket/v20230308/client.go | 210 +++++++++++ .../tencentcloud/trocket/v20230308/errors.go | 3 + .../tencentcloud/trocket/v20230308/models.go | 336 ++++++++++++++++++ vendor/modules.txt | 4 +- .../r/trocket_rocketmq_role.html.markdown | 65 ++++ website/tencentcloud.erb | 3 + 14 files changed, 1093 insertions(+), 12 deletions(-) create mode 100644 .changelog/2153.txt create mode 100644 tencentcloud/resource_tc_trocket_rocketmq_role.go create mode 100644 tencentcloud/resource_tc_trocket_rocketmq_role_test.go create mode 100644 website/docs/r/trocket_rocketmq_role.html.markdown diff --git a/.changelog/2153.txt b/.changelog/2153.txt new file mode 100644 index 0000000000..e75b73df23 --- /dev/null +++ b/.changelog/2153.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +tencentcloud_trocket_rocketmq_role +``` \ No newline at end of file diff --git a/go.mod b/go.mod index b95286e976..be94d05f99 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.693 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.711 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.755 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.756 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.589 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.692 @@ -88,7 +88,7 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tem v1.0.578 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.0.730 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.691 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.0.746 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.0.756 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.755 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.674 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.199 diff --git a/go.sum b/go.sum index e55eaef189..94619f6f2c 100644 --- a/go.sum +++ b/go.sum @@ -854,17 +854,16 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.725/go.mod github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.726/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.729/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.730/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= -github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.732/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.734/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.736/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.745/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= -github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.746/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.748/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.750/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.751/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.754/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= -github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.755 h1:mAhmX5bEBbLoLfeQu7y6ygeWFle4Kb4Z5e+sp8QyZcA= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.755/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.756 h1:TpeGo45T48N5OJ6LekUdMt3sjYJi4jis4x5jFo8Vz8A= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.756/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624 h1:nEZqsoqt1pEoaP9JjkHQy3/H00suCfzlHW1qOm2nYD8= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624/go.mod h1:+TXSVyeKwt1IhZRqKPbTREteBcP+K07Q846/ilNzLWA= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.589 h1:LZihgirMH0vsaGScYexxwY0fTss9vHaSZs/YOQUVESg= @@ -955,10 +954,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.0.730 h1:isKxaxm github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo v1.0.730/go.mod h1:vA9wf067VO5kkEjUgViUw/VA0ALUXE/wbSI1baeuHpI= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.691 h1:D+a7bZnjLoqPAAHSPCOmil4eigXnGPkR1R5G3ybT/+c= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.691/go.mod h1:hsc/CPzbCRXqblCYuE1HuvP3G06OWA9zhAGI6AtEe5U= -github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.0.746 h1:ZHfhs8xTWUtKHwDJQNd8mGzV2hFifwKOWYDJTbPrOSM= -github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.0.746/go.mod h1:NS1bkjH/+dhwCFvluZd+uq8h8hbnOHJaFDbkQe0YTm4= -github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.732 h1:hC6bRxIBwjAEnqDsJh8tpY/SqcSfP84exN+cVvHwtd4= -github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.732/go.mod h1:jF0O9bIPZ/oQ+m3qeEfWHLbtsJFKNaiqvdSNGP7AQCI= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.0.756 h1:89M6uA8Y/FC1b88TFxvRManGW+i62Isqg1lW8HjHDvU= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.0.756/go.mod h1:AJAItBOTaarpDpUF7pNp0tuz2Y6H2oFuMcyKouPs1IE= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.755 h1:DbYmGORd2zBnry69k6BR9hzEczrOmbNScE92POutYOY= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.755/go.mod h1:o+ABiUSkJQowYQjJsLBHBJsxy4BosjGVuRAsXas+VlY= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.674 h1:VsMV1/vsgVzespG7jUzraZS/AbAUllVQjmtVAlA9W/M= diff --git a/tencentcloud/provider.go b/tencentcloud/provider.go index 404134572f..21b3462795 100644 --- a/tencentcloud/provider.go +++ b/tencentcloud/provider.go @@ -1451,6 +1451,7 @@ TDMQ for RocketMQ(trocket) tencentcloud_trocket_rocketmq_instance tencentcloud_trocket_rocketmq_topic tencentcloud_trocket_rocketmq_consumer_group + tencentcloud_trocket_rocketmq_role TDMQ for RabbitMQ(trabbit) Resource @@ -2933,6 +2934,7 @@ func Provider() *schema.Provider { "tencentcloud_trocket_rocketmq_instance": resourceTencentCloudTrocketRocketmqInstance(), "tencentcloud_trocket_rocketmq_topic": resourceTencentCloudTrocketRocketmqTopic(), "tencentcloud_trocket_rocketmq_consumer_group": resourceTencentCloudTrocketRocketmqConsumerGroup(), + "tencentcloud_trocket_rocketmq_role": resourceTencentCloudTrocketRocketmqRole(), "tencentcloud_dts_sync_job": resourceTencentCloudDtsSyncJob(), "tencentcloud_dts_sync_config": resourceTencentCloudDtsSyncConfig(), "tencentcloud_dts_sync_check_job_operation": resourceTencentCloudDtsSyncCheckJobOperation(), diff --git a/tencentcloud/resource_tc_trocket_rocketmq_role.go b/tencentcloud/resource_tc_trocket_rocketmq_role.go new file mode 100644 index 0000000000..3422a4a7fd --- /dev/null +++ b/tencentcloud/resource_tc_trocket_rocketmq_role.go @@ -0,0 +1,293 @@ +/* +Provides a resource to create a trocket rocketmq_role + +Example Usage + +```hcl +resource "tencentcloud_trocket_rocketmq_instance" "rocketmq_instance" { + instance_type = "EXPERIMENT" + name = "test_role" + sku_code = "experiment_500" + remark = "test" + vpc_id = "vpc-xxxxx" + subnet_id = "subnet-xxxxx" + tags = { + tag_key = "rocketmq" + tag_value = "5.x" + } +} + +resource "tencentcloud_trocket_rocketmq_role" "rocketmq_role" { + instance_id = tencentcloud_trocket_rocketmq_instance.rocketmq_instance.id + role = "test_role" + remark = "test for terraform" + perm_write = false + perm_read = true +} +``` + +Import + +trocket rocketmq_role can be imported using the id, e.g. + +``` +terraform import tencentcloud_trocket_rocketmq_role.rocketmq_role instanceId#role +``` +*/ +package tencentcloud + +import ( + "context" + "fmt" + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + trocket "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket/v20230308" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func resourceTencentCloudTrocketRocketmqRole() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudTrocketRocketmqRoleCreate, + Read: resourceTencentCloudTrocketRocketmqRoleRead, + Update: resourceTencentCloudTrocketRocketmqRoleUpdate, + Delete: resourceTencentCloudTrocketRocketmqRoleDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "instance_id": { + Required: true, + Type: schema.TypeString, + ForceNew: true, + Description: "ID of instance.", + }, + + "role": { + Required: true, + Type: schema.TypeString, + ForceNew: true, + Description: "Name of role.", + }, + + "remark": { + Required: true, + Type: schema.TypeString, + Description: "remark.", + }, + + "perm_write": { + Required: true, + Type: schema.TypeBool, + Description: "Whether to enable production permission.", + }, + + "perm_read": { + Required: true, + Type: schema.TypeBool, + Description: "Whether to enable consumption permission.", + }, + + "created_time": { + Computed: true, + Type: schema.TypeInt, + Description: "Created time.", + }, + + "modified_time": { + Computed: true, + Type: schema.TypeInt, + Description: "Modified time.", + }, + }, + } +} + +func resourceTencentCloudTrocketRocketmqRoleCreate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_trocket_rocketmq_role.create")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + var ( + request = trocket.NewCreateRoleRequest() + response = trocket.NewCreateRoleResponse() + instanceId string + role string + ) + if v, ok := d.GetOk("instance_id"); ok { + instanceId = v.(string) + request.InstanceId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("role"); ok { + request.Role = helper.String(v.(string)) + } + + if v, ok := d.GetOk("remark"); ok { + request.Remark = helper.String(v.(string)) + } + + if v, ok := d.GetOkExists("perm_write"); ok { + request.PermWrite = helper.Bool(v.(bool)) + } + + if v, ok := d.GetOkExists("perm_read"); ok { + request.PermRead = helper.Bool(v.(bool)) + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTrocketClient().CreateRole(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()) + } + response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create trocket rocketmqRole failed, reason:%+v", logId, err) + return err + } + + role = *response.Response.Role + d.SetId(instanceId + FILED_SP + role) + + return resourceTencentCloudTrocketRocketmqRoleRead(d, meta) +} + +func resourceTencentCloudTrocketRocketmqRoleRead(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_trocket_rocketmq_role.read")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TrocketService{client: meta.(*TencentCloudClient).apiV3Conn} + + idSplit := strings.Split(d.Id(), FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + instanceId := idSplit[0] + role := idSplit[1] + + rocketmqRole, err := service.DescribeTrocketRocketmqRoleById(ctx, instanceId, role) + if err != nil { + return err + } + + if rocketmqRole == nil { + d.SetId("") + log.Printf("[WARN]%s resource `TrocketRocketmqRole` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + _ = d.Set("instance_id", instanceId) + _ = d.Set("role", role) + + if rocketmqRole.Remark != nil { + _ = d.Set("remark", rocketmqRole.Remark) + } + + if rocketmqRole.PermWrite != nil { + _ = d.Set("perm_write", rocketmqRole.PermWrite) + } + + if rocketmqRole.PermRead != nil { + _ = d.Set("perm_read", rocketmqRole.PermRead) + } + + if rocketmqRole.CreatedTime != nil { + _ = d.Set("created_time", rocketmqRole.CreatedTime) + } + + if rocketmqRole.ModifiedTime != nil { + _ = d.Set("modified_time", rocketmqRole.ModifiedTime) + } + + return nil +} + +func resourceTencentCloudTrocketRocketmqRoleUpdate(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_trocket_rocketmq_role.update")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + + request := trocket.NewModifyRoleRequest() + + idSplit := strings.Split(d.Id(), FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + instanceId := idSplit[0] + role := idSplit[1] + + request.InstanceId = &instanceId + request.Role = &role + + mutableArgs := []string{"remark", "perm_write", "perm_read"} + needChange := false + + for _, v := range mutableArgs { + if d.HasChange(v) { + needChange = true + } + } + + if needChange { + if v, ok := d.GetOk("remark"); ok { + request.Remark = helper.String(v.(string)) + } + + if v, ok := d.GetOkExists("perm_write"); ok { + request.PermWrite = helper.Bool(v.(bool)) + } + + if v, ok := d.GetOkExists("perm_read"); ok { + request.PermRead = helper.Bool(v.(bool)) + } + + err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { + result, e := meta.(*TencentCloudClient).apiV3Conn.UseTrocketClient().ModifyRole(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 update trocket rocketmqRole failed, reason:%+v", logId, err) + return err + } + } + return resourceTencentCloudTrocketRocketmqRoleRead(d, meta) +} + +func resourceTencentCloudTrocketRocketmqRoleDelete(d *schema.ResourceData, meta interface{}) error { + defer logElapsed("resource.tencentcloud_trocket_rocketmq_role.delete")() + defer inconsistentCheck(d, meta)() + + logId := getLogId(contextNil) + ctx := context.WithValue(context.TODO(), logIdKey, logId) + + service := TrocketService{client: meta.(*TencentCloudClient).apiV3Conn} + idSplit := strings.Split(d.Id(), FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + instanceId := idSplit[0] + role := idSplit[1] + + if err := service.DeleteTrocketRocketmqRoleById(ctx, instanceId, role); err != nil { + return err + } + + return nil +} diff --git a/tencentcloud/resource_tc_trocket_rocketmq_role_test.go b/tencentcloud/resource_tc_trocket_rocketmq_role_test.go new file mode 100644 index 0000000000..9c59775611 --- /dev/null +++ b/tencentcloud/resource_tc_trocket_rocketmq_role_test.go @@ -0,0 +1,92 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccTencentCloudTrocketRocketmqRoleResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTrocketRocketmqRole, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("tencentcloud_trocket_rocketmq_role.rocketmq_role", "id"), + resource.TestCheckResourceAttr("tencentcloud_trocket_rocketmq_role.rocketmq_role", "remark", "test for terraform"), + resource.TestCheckResourceAttr("tencentcloud_trocket_rocketmq_role.rocketmq_role", "perm_write", "false"), + resource.TestCheckResourceAttr("tencentcloud_trocket_rocketmq_role.rocketmq_role", "perm_read", "true"), + ), + }, + { + Config: testAccTrocketRocketmqRoleUpdate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("tencentcloud_trocket_rocketmq_role.rocketmq_role", "id"), + resource.TestCheckResourceAttr("tencentcloud_trocket_rocketmq_role.rocketmq_role", "remark", "test terraform"), + resource.TestCheckResourceAttr("tencentcloud_trocket_rocketmq_role.rocketmq_role", "perm_write", "true"), + resource.TestCheckResourceAttr("tencentcloud_trocket_rocketmq_role.rocketmq_role", "perm_read", "true"), + ), + }, + { + ResourceName: "tencentcloud_trocket_rocketmq_role.rocketmq_role", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccTrocketRocketmqRole = ` + +resource "tencentcloud_trocket_rocketmq_instance" "rocketmq_instance" { + instance_type = "EXPERIMENT" + name = "test_role" + sku_code = "experiment_500" + remark = "test" + vpc_id = "vpc-3a9fo1k9" + subnet_id = "subnet-8nby1yxg" + tags = { + tag_key = "rocketmq" + tag_value = "5.x" + } +} + +resource "tencentcloud_trocket_rocketmq_role" "rocketmq_role" { + instance_id = tencentcloud_trocket_rocketmq_instance.rocketmq_instance.id + role = "test_role" + remark = "test for terraform" + perm_write = false + perm_read = true +} + +` + +const testAccTrocketRocketmqRoleUpdate = ` + +resource "tencentcloud_trocket_rocketmq_instance" "rocketmq_instance" { + instance_type = "EXPERIMENT" + name = "test_role" + sku_code = "experiment_500" + remark = "test" + vpc_id = "vpc-3a9fo1k9" + subnet_id = "subnet-8nby1yxg" + tags = { + tag_key = "rocketmq" + tag_value = "5.x" + } +} + +resource "tencentcloud_trocket_rocketmq_role" "rocketmq_role" { + instance_id = tencentcloud_trocket_rocketmq_instance.rocketmq_instance.id + role = "test_role" + remark = "test terraform" + perm_write = true + perm_read = true +} + +` diff --git a/tencentcloud/service_tencentcloud_trocket.go b/tencentcloud/service_tencentcloud_trocket.go index 25bfd29d5a..03568f13c0 100644 --- a/tencentcloud/service_tencentcloud_trocket.go +++ b/tencentcloud/service_tencentcloud_trocket.go @@ -211,3 +211,80 @@ func (me *TrocketService) DeleteTrocketRocketmqConsumerGroupById(ctx context.Con return } + +func (me *TrocketService) DescribeTrocketRocketmqRoleById(ctx context.Context, instanceId string, role string) (rocketmqRole *trocket.RoleItem, errRet error) { + logId := getLogId(ctx) + + request := trocket.NewDescribeRoleListRequest() + request.InstanceId = &instanceId + filter := &trocket.Filter{ + Name: helper.String("RoleName"), + Values: []*string{&role}, + } + request.Filters = []*trocket.Filter{filter} + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + var ( + offset int64 = 0 + limit int64 = 100 + ) + instances := make([]*trocket.RoleItem, 0) + for { + request.Offset = &offset + request.Limit = &limit + response, err := me.client.UseTrocketClient().DescribeRoleList(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + if response == nil || len(response.Response.Data) < 1 { + break + } + instances = append(instances, response.Response.Data...) + if len(response.Response.Data) < int(limit) { + break + } + + offset += limit + } + + if len(instances) < 1 { + return + } + rocketmqRole = instances[0] + return +} + +func (me *TrocketService) DeleteTrocketRocketmqRoleById(ctx context.Context, instanceId string, role string) (errRet error) { + logId := getLogId(ctx) + + request := trocket.NewDeleteRoleRequest() + request.InstanceId = &instanceId + request.Role = &role + + defer func() { + if errRet != nil { + log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n", logId, request.GetAction(), request.ToJsonString(), errRet.Error()) + } + }() + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseTrocketClient().DeleteRole(request) + if err != nil { + errRet = err + return + } + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + + return +} diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go index 55f9d1240b..d2493e3b5b 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go @@ -265,7 +265,7 @@ func CompleteCommonParams(request Request, region string, requestClient string) params["Action"] = request.GetAction() params["Timestamp"] = strconv.FormatInt(time.Now().Unix(), 10) params["Nonce"] = strconv.Itoa(rand.Int()) - params["RequestClient"] = "SDK_GO_1.0.755" + params["RequestClient"] = "SDK_GO_1.0.756" if requestClient != "" { params["RequestClient"] += ": " + requestClient } diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket/v20230308/client.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket/v20230308/client.go index d9d3f5fb80..0e9f7d2465 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket/v20230308/client.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket/v20230308/client.go @@ -145,6 +145,62 @@ func (c *Client) CreateInstanceWithContext(ctx context.Context, request *CreateI return } +func NewCreateRoleRequest() (request *CreateRoleRequest) { + request = &CreateRoleRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("trocket", APIVersion, "CreateRole") + + + return +} + +func NewCreateRoleResponse() (response *CreateRoleResponse) { + response = &CreateRoleResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// CreateRole +// 添加角色 +// +// 可能返回的错误码: +// FAILEDOPERATION = "FailedOperation" +// FAILEDOPERATION_INSTANCENOTREADY = "FailedOperation.InstanceNotReady" +// OPERATIONDENIED = "OperationDenied" +// RESOURCEINUSE = "ResourceInUse" +// UNSUPPORTEDOPERATION_RESOURCEALREADYEXISTS = "UnsupportedOperation.ResourceAlreadyExists" +func (c *Client) CreateRole(request *CreateRoleRequest) (response *CreateRoleResponse, err error) { + return c.CreateRoleWithContext(context.Background(), request) +} + +// CreateRole +// 添加角色 +// +// 可能返回的错误码: +// FAILEDOPERATION = "FailedOperation" +// FAILEDOPERATION_INSTANCENOTREADY = "FailedOperation.InstanceNotReady" +// OPERATIONDENIED = "OperationDenied" +// RESOURCEINUSE = "ResourceInUse" +// UNSUPPORTEDOPERATION_RESOURCEALREADYEXISTS = "UnsupportedOperation.ResourceAlreadyExists" +func (c *Client) CreateRoleWithContext(ctx context.Context, request *CreateRoleRequest) (response *CreateRoleResponse, err error) { + if request == nil { + request = NewCreateRoleRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("CreateRole require credential") + } + + request.SetContext(ctx) + + response = NewCreateRoleResponse() + err = c.Send(request, response) + return +} + func NewCreateTopicRequest() (request *CreateTopicRequest) { request = &CreateTopicRequest{ BaseRequest: &tchttp.BaseRequest{}, @@ -305,6 +361,56 @@ func (c *Client) DeleteInstanceWithContext(ctx context.Context, request *DeleteI return } +func NewDeleteRoleRequest() (request *DeleteRoleRequest) { + request = &DeleteRoleRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("trocket", APIVersion, "DeleteRole") + + + return +} + +func NewDeleteRoleResponse() (response *DeleteRoleResponse) { + response = &DeleteRoleResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// DeleteRole +// 删除角色 +// +// 可能返回的错误码: +// FAILEDOPERATION = "FailedOperation" +// RESOURCENOTFOUND_ROLE = "ResourceNotFound.Role" +func (c *Client) DeleteRole(request *DeleteRoleRequest) (response *DeleteRoleResponse, err error) { + return c.DeleteRoleWithContext(context.Background(), request) +} + +// DeleteRole +// 删除角色 +// +// 可能返回的错误码: +// FAILEDOPERATION = "FailedOperation" +// RESOURCENOTFOUND_ROLE = "ResourceNotFound.Role" +func (c *Client) DeleteRoleWithContext(ctx context.Context, request *DeleteRoleRequest) (response *DeleteRoleResponse, err error) { + if request == nil { + request = NewDeleteRoleRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("DeleteRole require credential") + } + + request.SetContext(ctx) + + response = NewDeleteRoleResponse() + err = c.Send(request, response) + return +} + func NewDeleteTopicRequest() (request *DeleteTopicRequest) { request = &DeleteTopicRequest{ BaseRequest: &tchttp.BaseRequest{}, @@ -521,6 +627,62 @@ func (c *Client) DescribeInstanceListWithContext(ctx context.Context, request *D return } +func NewDescribeRoleListRequest() (request *DescribeRoleListRequest) { + request = &DescribeRoleListRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("trocket", APIVersion, "DescribeRoleList") + + + return +} + +func NewDescribeRoleListResponse() (response *DescribeRoleListResponse) { + response = &DescribeRoleListResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// DescribeRoleList +// 查询角色列表,Filter参数使用说明如下: +// +// +// +// 1. RoleName,角色名称模糊搜索 +// +// 可能返回的错误码: +// FAILEDOPERATION = "FailedOperation" +func (c *Client) DescribeRoleList(request *DescribeRoleListRequest) (response *DescribeRoleListResponse, err error) { + return c.DescribeRoleListWithContext(context.Background(), request) +} + +// DescribeRoleList +// 查询角色列表,Filter参数使用说明如下: +// +// +// +// 1. RoleName,角色名称模糊搜索 +// +// 可能返回的错误码: +// FAILEDOPERATION = "FailedOperation" +func (c *Client) DescribeRoleListWithContext(ctx context.Context, request *DescribeRoleListRequest) (response *DescribeRoleListResponse, err error) { + if request == nil { + request = NewDescribeRoleListRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("DescribeRoleList require credential") + } + + request.SetContext(ctx) + + response = NewDescribeRoleListResponse() + err = c.Send(request, response) + return +} + func NewDescribeTopicRequest() (request *DescribeTopicRequest) { request = &DescribeTopicRequest{ BaseRequest: &tchttp.BaseRequest{}, @@ -787,6 +949,54 @@ func (c *Client) ModifyInstanceWithContext(ctx context.Context, request *ModifyI return } +func NewModifyRoleRequest() (request *ModifyRoleRequest) { + request = &ModifyRoleRequest{ + BaseRequest: &tchttp.BaseRequest{}, + } + + request.Init().WithApiInfo("trocket", APIVersion, "ModifyRole") + + + return +} + +func NewModifyRoleResponse() (response *ModifyRoleResponse) { + response = &ModifyRoleResponse{ + BaseResponse: &tchttp.BaseResponse{}, + } + return +} + +// ModifyRole +// 修改角色 +// +// 可能返回的错误码: +// FAILEDOPERATION = "FailedOperation" +func (c *Client) ModifyRole(request *ModifyRoleRequest) (response *ModifyRoleResponse, err error) { + return c.ModifyRoleWithContext(context.Background(), request) +} + +// ModifyRole +// 修改角色 +// +// 可能返回的错误码: +// FAILEDOPERATION = "FailedOperation" +func (c *Client) ModifyRoleWithContext(ctx context.Context, request *ModifyRoleRequest) (response *ModifyRoleResponse, err error) { + if request == nil { + request = NewModifyRoleRequest() + } + + if c.GetCredential() == nil { + return nil, errors.New("ModifyRole require credential") + } + + request.SetContext(ctx) + + response = NewModifyRoleResponse() + err = c.Send(request, response) + return +} + func NewModifyTopicRequest() (request *ModifyTopicRequest) { request = &ModifyTopicRequest{ BaseRequest: &tchttp.BaseRequest{}, diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket/v20230308/errors.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket/v20230308/errors.go index 98d0ec4105..c7cbdccf01 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket/v20230308/errors.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket/v20230308/errors.go @@ -38,6 +38,9 @@ const ( // 实例不存在。 RESOURCENOTFOUND_INSTANCE = "ResourceNotFound.Instance" + // 角色不存在,请检查后重试。 + RESOURCENOTFOUND_ROLE = "ResourceNotFound.Role" + // 主题不存在,请检查后重试。 RESOURCENOTFOUND_TOPIC = "ResourceNotFound.Topic" diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket/v20230308/models.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket/v20230308/models.go index 26f36c2802..fd6d4d9e32 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket/v20230308/models.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket/v20230308/models.go @@ -255,6 +255,91 @@ func (r *CreateInstanceResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type CreateRoleRequestParams struct { + // 实例ID + InstanceId *string `json:"InstanceId,omitnil" name:"InstanceId"` + + // 角色名称 + Role *string `json:"Role,omitnil" name:"Role"` + + // 备注 + Remark *string `json:"Remark,omitnil" name:"Remark"` + + // 是否开启生产权限 + PermWrite *bool `json:"PermWrite,omitnil" name:"PermWrite"` + + // 是否开启消费权限 + PermRead *bool `json:"PermRead,omitnil" name:"PermRead"` +} + +type CreateRoleRequest struct { + *tchttp.BaseRequest + + // 实例ID + InstanceId *string `json:"InstanceId,omitnil" name:"InstanceId"` + + // 角色名称 + Role *string `json:"Role,omitnil" name:"Role"` + + // 备注 + Remark *string `json:"Remark,omitnil" name:"Remark"` + + // 是否开启生产权限 + PermWrite *bool `json:"PermWrite,omitnil" name:"PermWrite"` + + // 是否开启消费权限 + PermRead *bool `json:"PermRead,omitnil" name:"PermRead"` +} + +func (r *CreateRoleRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *CreateRoleRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "InstanceId") + delete(f, "Role") + delete(f, "Remark") + delete(f, "PermWrite") + delete(f, "PermRead") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "CreateRoleRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type CreateRoleResponseParams struct { + // 角色名 + Role *string `json:"Role,omitnil" name:"Role"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitnil" name:"RequestId"` +} + +type CreateRoleResponse struct { + *tchttp.BaseResponse + Response *CreateRoleResponseParams `json:"Response"` +} + +func (r *CreateRoleResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *CreateRoleResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type CreateTopicRequestParams struct { // 实例ID @@ -468,6 +553,67 @@ func (r *DeleteInstanceResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type DeleteRoleRequestParams struct { + // 实例ID + InstanceId *string `json:"InstanceId,omitnil" name:"InstanceId"` + + // 角色名称 + Role *string `json:"Role,omitnil" name:"Role"` +} + +type DeleteRoleRequest struct { + *tchttp.BaseRequest + + // 实例ID + InstanceId *string `json:"InstanceId,omitnil" name:"InstanceId"` + + // 角色名称 + Role *string `json:"Role,omitnil" name:"Role"` +} + +func (r *DeleteRoleRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *DeleteRoleRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "InstanceId") + delete(f, "Role") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DeleteRoleRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type DeleteRoleResponseParams struct { + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitnil" name:"RequestId"` +} + +type DeleteRoleResponse struct { + *tchttp.BaseResponse + Response *DeleteRoleResponseParams `json:"Response"` +} + +func (r *DeleteRoleResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *DeleteRoleResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type DeleteTopicRequestParams struct { // 实例ID @@ -830,6 +976,88 @@ func (r *DescribeInstanceResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type DescribeRoleListRequestParams struct { + // 实例ID + InstanceId *string `json:"InstanceId,omitnil" name:"InstanceId"` + + // 查询起始位置 + Offset *int64 `json:"Offset,omitnil" name:"Offset"` + + // 查询结果限制数量 + Limit *int64 `json:"Limit,omitnil" name:"Limit"` + + // 查询条件列表 + Filters []*Filter `json:"Filters,omitnil" name:"Filters"` +} + +type DescribeRoleListRequest struct { + *tchttp.BaseRequest + + // 实例ID + InstanceId *string `json:"InstanceId,omitnil" name:"InstanceId"` + + // 查询起始位置 + Offset *int64 `json:"Offset,omitnil" name:"Offset"` + + // 查询结果限制数量 + Limit *int64 `json:"Limit,omitnil" name:"Limit"` + + // 查询条件列表 + Filters []*Filter `json:"Filters,omitnil" name:"Filters"` +} + +func (r *DescribeRoleListRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *DescribeRoleListRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "InstanceId") + delete(f, "Offset") + delete(f, "Limit") + delete(f, "Filters") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DescribeRoleListRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type DescribeRoleListResponseParams struct { + // 查询总数 + // 注意:此字段可能返回 null,表示取不到有效值。 + TotalCount *int64 `json:"TotalCount,omitnil" name:"TotalCount"` + + // 角色信息列表 + Data []*RoleItem `json:"Data,omitnil" name:"Data"` + + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitnil" name:"RequestId"` +} + +type DescribeRoleListResponse struct { + *tchttp.BaseResponse + Response *DescribeRoleListResponseParams `json:"Response"` +} + +func (r *DescribeRoleListResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *DescribeRoleListResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type DescribeTopicListRequestParams struct { // 实例ID @@ -1402,6 +1630,88 @@ func (r *ModifyInstanceResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +// Predefined struct for user +type ModifyRoleRequestParams struct { + // 实例ID + InstanceId *string `json:"InstanceId,omitnil" name:"InstanceId"` + + // 角色名称 + Role *string `json:"Role,omitnil" name:"Role"` + + // 是否开启消费 + PermRead *bool `json:"PermRead,omitnil" name:"PermRead"` + + // 是否开启生产 + PermWrite *bool `json:"PermWrite,omitnil" name:"PermWrite"` + + // 备注 + Remark *string `json:"Remark,omitnil" name:"Remark"` +} + +type ModifyRoleRequest struct { + *tchttp.BaseRequest + + // 实例ID + InstanceId *string `json:"InstanceId,omitnil" name:"InstanceId"` + + // 角色名称 + Role *string `json:"Role,omitnil" name:"Role"` + + // 是否开启消费 + PermRead *bool `json:"PermRead,omitnil" name:"PermRead"` + + // 是否开启生产 + PermWrite *bool `json:"PermWrite,omitnil" name:"PermWrite"` + + // 备注 + Remark *string `json:"Remark,omitnil" name:"Remark"` +} + +func (r *ModifyRoleRequest) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *ModifyRoleRequest) FromJsonString(s string) error { + f := make(map[string]interface{}) + if err := json.Unmarshal([]byte(s), &f); err != nil { + return err + } + delete(f, "InstanceId") + delete(f, "Role") + delete(f, "PermRead") + delete(f, "PermWrite") + delete(f, "Remark") + if len(f) > 0 { + return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "ModifyRoleRequest has unknown keys!", "") + } + return json.Unmarshal([]byte(s), &r) +} + +// Predefined struct for user +type ModifyRoleResponseParams struct { + // 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 + RequestId *string `json:"RequestId,omitnil" name:"RequestId"` +} + +type ModifyRoleResponse struct { + *tchttp.BaseResponse + Response *ModifyRoleResponseParams `json:"Response"` +} + +func (r *ModifyRoleResponse) ToJsonString() string { + b, _ := json.Marshal(r) + return string(b) +} + +// FromJsonString It is highly **NOT** recommended to use this function +// because it has no param check, nor strict type check +func (r *ModifyRoleResponse) FromJsonString(s string) error { + return json.Unmarshal([]byte(s), &r) +} + // Predefined struct for user type ModifyTopicRequestParams struct { // 实例ID @@ -1477,6 +1787,32 @@ func (r *ModifyTopicResponse) FromJsonString(s string) error { return json.Unmarshal([]byte(s), &r) } +type RoleItem struct { + // 角色名称 + RoleName *string `json:"RoleName,omitnil" name:"RoleName"` + + // Access Key + AccessKey *string `json:"AccessKey,omitnil" name:"AccessKey"` + + // Secret Key + SecretKey *string `json:"SecretKey,omitnil" name:"SecretKey"` + + // 是否开启消费 + PermRead *bool `json:"PermRead,omitnil" name:"PermRead"` + + // 是否开启生产 + PermWrite *bool `json:"PermWrite,omitnil" name:"PermWrite"` + + // 备注信息 + Remark *string `json:"Remark,omitnil" name:"Remark"` + + // 创建时间,秒为单位 + CreatedTime *int64 `json:"CreatedTime,omitnil" name:"CreatedTime"` + + // 修改时间,秒为单位 + ModifiedTime *int64 `json:"ModifiedTime,omitnil" name:"ModifiedTime"` +} + type SubscriptionData struct { // 实例ID // 注意:此字段可能返回 null,表示取不到有效值。 diff --git a/vendor/modules.txt b/vendor/modules.txt index 3d27fb1364..c16a96305c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1094,7 +1094,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit/v20190319 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.711 ## explicit; go 1.14 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls/v20201016 -# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.755 +# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.756 ## explicit; go 1.14 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors @@ -1237,7 +1237,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke v1.0.691 ## explicit; go 1.14 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525 -# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.0.746 +# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket v1.0.756 ## explicit; go 1.14 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trocket/v20230308 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.755 diff --git a/website/docs/r/trocket_rocketmq_role.html.markdown b/website/docs/r/trocket_rocketmq_role.html.markdown new file mode 100644 index 0000000000..858cd7ef35 --- /dev/null +++ b/website/docs/r/trocket_rocketmq_role.html.markdown @@ -0,0 +1,65 @@ +--- +subcategory: "TDMQ for RocketMQ(trocket)" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_trocket_rocketmq_role" +sidebar_current: "docs-tencentcloud-resource-trocket_rocketmq_role" +description: |- + Provides a resource to create a trocket rocketmq_role +--- + +# tencentcloud_trocket_rocketmq_role + +Provides a resource to create a trocket rocketmq_role + +## Example Usage + +```hcl +resource "tencentcloud_trocket_rocketmq_instance" "rocketmq_instance" { + instance_type = "EXPERIMENT" + name = "test_role" + sku_code = "experiment_500" + remark = "test" + vpc_id = "vpc-xxxxx" + subnet_id = "subnet-xxxxx" + tags = { + tag_key = "rocketmq" + tag_value = "5.x" + } +} + +resource "tencentcloud_trocket_rocketmq_role" "rocketmq_role" { + instance_id = tencentcloud_trocket_rocketmq_instance.rocketmq_instance.id + role = "test_role" + remark = "test for terraform" + perm_write = false + perm_read = true +} +``` + +## Argument Reference + +The following arguments are supported: + +* `instance_id` - (Required, String, ForceNew) ID of instance. +* `perm_read` - (Required, Bool) Whether to enable consumption permission. +* `perm_write` - (Required, Bool) Whether to enable production permission. +* `remark` - (Required, String) remark. +* `role` - (Required, String, ForceNew) Name of role. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - ID of the resource. +* `created_time` - Created time. +* `modified_time` - Modified time. + + +## Import + +trocket rocketmq_role can be imported using the id, e.g. + +``` +terraform import tencentcloud_trocket_rocketmq_role.rocketmq_role instanceId#role +``` + diff --git a/website/tencentcloud.erb b/website/tencentcloud.erb index 04fc646b3c..c6b278dd18 100644 --- a/website/tencentcloud.erb +++ b/website/tencentcloud.erb @@ -2777,6 +2777,9 @@
  • tencentcloud_trocket_rocketmq_instance
  • +
  • + tencentcloud_trocket_rocketmq_role +
  • tencentcloud_trocket_rocketmq_topic