diff --git a/.changelog/3540.txt b/.changelog/3540.txt new file mode 100644 index 0000000000..091da629d5 --- /dev/null +++ b/.changelog/3540.txt @@ -0,0 +1,19 @@ +```release-note:new-resource +tencentcloud_wedata_task +``` + +```release-note:new-resource +tencentcloud_wedata_workflow_folder +``` + +```release-note:new-resource +tencentcloud_wedata_workflow +``` + +```release-note:new-resource +tencentcloud_wedata_resource_file +``` + +```release-note:new-resource +tencentcloud_wedata_resource_folder +``` diff --git a/tencentcloud/provider.go b/tencentcloud/provider.go index 8cbb968015..6b9233410e 100644 --- a/tencentcloud/provider.go +++ b/tencentcloud/provider.go @@ -2295,6 +2295,11 @@ func Provider() *schema.Provider { "tencentcloud_waf_bot_scene_ucb_rule": waf.ResourceTencentCloudWafBotSceneUCBRule(), "tencentcloud_waf_attack_white_rule": waf.ResourceTencentCloudWafAttackWhiteRule(), "tencentcloud_wedata_submit_task_operation": wedata.ResourceTencentCloudWedataSubmitTaskOperation(), + "tencentcloud_wedata_task": wedata.ResourceTencentCloudWedataTask(), + "tencentcloud_wedata_workflow_folder": wedata.ResourceTencentCloudWedataWorkflowFolder(), + "tencentcloud_wedata_workflow": wedata.ResourceTencentCloudWedataWorkflow(), + "tencentcloud_wedata_resource_file": wedata.ResourceTencentCloudWedataResourceFile(), + "tencentcloud_wedata_resource_folder": wedata.ResourceTencentCloudWedataResourceFolder(), "tencentcloud_wedata_rule_template": wedata.ResourceTencentCloudWedataRuleTemplate(), "tencentcloud_wedata_datasource": wedata.ResourceTencentCloudWedataDatasource(), "tencentcloud_wedata_function": wedata.ResourceTencentCloudWedataFunction(), diff --git a/tencentcloud/provider.md b/tencentcloud/provider.md index 3bc9ca7331..d3e7f52c32 100644 --- a/tencentcloud/provider.md +++ b/tencentcloud/provider.md @@ -2243,6 +2243,11 @@ tencentcloud_wedata_data_source_list Resource tencentcloud_wedata_submit_task_operation +tencentcloud_wedata_task +tencentcloud_wedata_workflow_folder +tencentcloud_wedata_workflow +tencentcloud_wedata_resource_file +tencentcloud_wedata_resource_folder tencentcloud_wedata_datasource tencentcloud_wedata_function tencentcloud_wedata_script diff --git a/tencentcloud/services/wedata/resource_tc_wedata_resource_file.go b/tencentcloud/services/wedata/resource_tc_wedata_resource_file.go new file mode 100644 index 0000000000..3424ad566b --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_resource_file.go @@ -0,0 +1,316 @@ +package wedata + +import ( + "context" + "fmt" + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + wedatav20250806 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata/v20250806" + + tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func ResourceTencentCloudWedataResourceFile() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudWedataResourceFileCreate, + Read: resourceTencentCloudWedataResourceFileRead, + Update: resourceTencentCloudWedataResourceFileUpdate, + Delete: resourceTencentCloudWedataResourceFileDelete, + Schema: map[string]*schema.Schema{ + "project_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "Project id.", + }, + + "resource_name": { + Type: schema.TypeString, + Required: true, + Description: "The resource file name should be consistent with the uploaded file name as much as possible.", + }, + + "bucket_name": { + Type: schema.TypeString, + Required: true, + Description: "cos bucket name, which can be obtained from the GetResourceCosPath interface.", + }, + + "cos_region": { + Type: schema.TypeString, + Required: true, + Description: "The cos bucket area corresponding to the BucketName bucket.", + }, + + "parent_folder_path": { + Type: schema.TypeString, + Required: true, + Description: "The path to upload resource files in the project, example value: /wedata/qxxxm/, root directory, please use/.", + }, + + "resource_file": { + Type: schema.TypeString, + Required: true, + Description: "- You can only choose one of the two methods of uploading a file and manually filling. If both are provided, the order of values is file> manual filling value\n-the manual filling value must be the existing cos path, /datastudio/resource/is a fixed prefix, projectId is the project ID, and a specific value needs to be passed in, parentFolderPath is the parent folder path, name is the file name, and examples of manual filling value values are: /datastudio/resource/projectId/parentFolderPath/name \n.", + }, + + "bundle_id": { + Type: schema.TypeString, + Optional: true, + Description: "bundle client ID.", + }, + + "bundle_info": { + Type: schema.TypeString, + Optional: true, + Description: "bundle client information.", + }, + }, + } +} + +func resourceTencentCloudWedataResourceFileCreate(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_resource_file.create")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + var ( + projectId string + resourceId string + ) + var ( + request = wedatav20250806.NewCreateResourceFileRequest() + response = wedatav20250806.NewCreateResourceFileResponse() + ) + + if v, ok := d.GetOk("project_id"); ok { + projectId = v.(string) + request.ProjectId = helper.String(projectId) + } + + if v, ok := d.GetOk("resource_name"); ok { + request.ResourceName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("bucket_name"); ok { + request.BucketName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("cos_region"); ok { + request.CosRegion = helper.String(v.(string)) + } + + if v, ok := d.GetOk("parent_folder_path"); ok { + request.ParentFolderPath = helper.String(v.(string)) + } + + if v, ok := d.GetOk("resource_file"); ok { + request.ResourceFile = helper.String(v.(string)) + } + + if v, ok := d.GetOk("bundle_id"); ok { + request.BundleId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("bundle_info"); ok { + request.BundleInfo = helper.String(v.(string)) + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().CreateResourceFileWithContext(ctx, request) + if e != nil { + return tccommon.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 wedata resource file failed, reason:%+v", logId, err) + return err + } + + if response.Response.Data != nil && response.Response.Data.ResourceId != nil { + resourceId = *response.Response.Data.ResourceId + d.SetId(strings.Join([]string{projectId, resourceId}, tccommon.FILED_SP)) + + } + + return resourceTencentCloudWedataResourceFileRead(d, meta) +} + +func resourceTencentCloudWedataResourceFileRead(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_resource_file.read")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + service := WedataService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} + + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + projectId := idSplit[0] + resourceId := idSplit[1] + + respData, err := service.DescribeWedataResourceFileById(ctx, projectId, resourceId) + if err != nil { + return err + } + + if respData == nil { + d.SetId("") + log.Printf("[WARN]%s resource `wedata_resource_file` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + _ = d.Set("project_id", projectId) + if respData.ResourceName != nil { + _ = d.Set("resource_name", respData.ResourceName) + } + + if respData.BucketName != nil { + _ = d.Set("bucket_name", respData.BucketName) + } + + if respData.CosRegion != nil { + _ = d.Set("cos_region", respData.CosRegion) + } + + if respData.BundleId != nil { + _ = d.Set("bundle_id", respData.BundleId) + } + + if respData.BundleInfo != nil { + _ = d.Set("bundle_info", respData.BundleInfo) + } + + _ = projectId + _ = resourceId + return nil +} + +func resourceTencentCloudWedataResourceFileUpdate(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_resource_file.update")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + immutableArgs := []string{"bucket_name", "cos_region", "parent_folder_path"} + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + projectId := idSplit[0] + resourceId := idSplit[1] + + needChange := false + mutableArgs := []string{"resource_file", "resource_name", "bundle_id", "bundle_info"} + for _, v := range mutableArgs { + if d.HasChange(v) { + needChange = true + break + } + } + + if needChange { + request := wedatav20250806.NewUpdateResourceFileRequest() + request.ProjectId = helper.String(projectId) + request.ResourceId = helper.String(resourceId) + + if v, ok := d.GetOk("resource_file"); ok { + request.ResourceFile = helper.String(v.(string)) + } + + if v, ok := d.GetOk("resource_name"); ok { + request.ResourceName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("bundle_id"); ok { + request.BundleId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("bundle_info"); ok { + request.BundleInfo = helper.String(v.(string)) + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().UpdateResourceFileWithContext(ctx, request) + if e != nil { + return tccommon.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 wedata resource file failed, reason:%+v", logId, err) + return err + } + } + + _ = projectId + _ = resourceId + return resourceTencentCloudWedataResourceFileRead(d, meta) +} + +func resourceTencentCloudWedataResourceFileDelete(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_resource_file.delete")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + projectId := idSplit[0] + resourceId := idSplit[1] + + var ( + request = wedatav20250806.NewDeleteResourceFileRequest() + response = wedatav20250806.NewDeleteResourceFileResponse() + ) + + request.ProjectId = helper.String(projectId) + request.ResourceId = helper.String(resourceId) + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().DeleteResourceFileWithContext(ctx, request) + if e != nil { + return tccommon.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 delete wedata resource file failed, reason:%+v", logId, err) + return err + } + + _ = response + _ = projectId + _ = resourceId + return nil +} diff --git a/tencentcloud/services/wedata/resource_tc_wedata_resource_file.md b/tencentcloud/services/wedata/resource_tc_wedata_resource_file.md new file mode 100644 index 0000000000..4a144fabb6 --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_resource_file.md @@ -0,0 +1,20 @@ +Provides a resource to create a wedata wedata_resource_file + +Example Usage + +```hcl +resource "tencentcloud_wedata_resource_folder" "wedata_resource_folder" { + project_id = 2905622749543821312 + parent_folder_path = "/" + folder_name = "folder" +} + +resource "tencentcloud_wedata_resource_file" "wedata_resource_file" { + project_id = 2905622749543821312 + resource_name = "tftest.txt" + bucket_name = "data-manage-fsi-1315051789" + cos_region = "ap-beijing-fsi" + parent_folder_path = "${tencentcloud_wedata_resource_folder.wedata_resource_folder.parent_folder_path}${tencentcloud_wedata_resource_folder.wedata_resource_folder.folder_name}" + resource_file = "/datastudio/resource/2905622749543821312/${tencentcloud_wedata_resource_folder.wedata_resource_folder.parent_folder_path}${tencentcloud_wedata_resource_folder.wedata_resource_folder.folder_name}/test" +} +``` diff --git a/tencentcloud/services/wedata/resource_tc_wedata_resource_file_test.go b/tencentcloud/services/wedata/resource_tc_wedata_resource_file_test.go new file mode 100644 index 0000000000..3a0bf3ebb2 --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_resource_file_test.go @@ -0,0 +1,53 @@ +package wedata_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest" +) + +func TestAccTencentCloudWedataResourceFileResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + tcacctest.AccPreCheck(t) + }, + Providers: tcacctest.AccProviders, + Steps: []resource.TestStep{ + { + Config: testAccWedataResourceFile, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_wedata_resource_file.wedata_resource_file", "id")), + }, + { + Config: testAccWedataResourceFileUpdate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("tencentcloud_wedata_resource_file.wedata_resource_file", "resource_name", "tftest1.txt"), + ), + }, + }, + }) +} + +const testAccWedataResourceFile = ` +resource "tencentcloud_wedata_resource_file" "wedata_resource_file" { + project_id = 2905622749543821312 + resource_name = "tftest.txt" + bucket_name = "data-manage-fsi-1315051789" + cos_region = "ap-beijing-fsi" + parent_folder_path = "/" + resource_file = "/datastudio/resource/2905622749543821312/test" +} +` + +const testAccWedataResourceFileUpdate = ` +resource "tencentcloud_wedata_resource_file" "wedata_resource_file" { + project_id = 2905622749543821312 + resource_name = "tftest1.txt" + bucket_name = "data-manage-fsi-1315051789" + cos_region = "ap-beijing-fsi" + parent_folder_path = "/" + resource_file = "/datastudio/resource/2905622749543821312/test" +} +` diff --git a/tencentcloud/services/wedata/resource_tc_wedata_resource_folder.go b/tencentcloud/services/wedata/resource_tc_wedata_resource_folder.go new file mode 100644 index 0000000000..165cd76e37 --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_resource_folder.go @@ -0,0 +1,238 @@ +package wedata + +import ( + "context" + "fmt" + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + wedatav20250806 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata/v20250806" + + tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func ResourceTencentCloudWedataResourceFolder() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudWedataResourceFolderCreate, + Read: resourceTencentCloudWedataResourceFolderRead, + Update: resourceTencentCloudWedataResourceFolderUpdate, + Delete: resourceTencentCloudWedataResourceFolderDelete, + Schema: map[string]*schema.Schema{ + "project_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "Project id.", + }, + + "parent_folder_path": { + Type: schema.TypeString, + Required: true, + Description: "Absolute path of parent folder, value example/wedata/test, root directory, please use/.", + }, + + "folder_name": { + Type: schema.TypeString, + Required: true, + Description: "Folder name.", + }, + }, + } +} + +func resourceTencentCloudWedataResourceFolderCreate(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_resource_folder.create")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + var ( + projectId string + folderId string + ) + var ( + request = wedatav20250806.NewCreateResourceFolderRequest() + response = wedatav20250806.NewCreateResourceFolderResponse() + ) + + if v, ok := d.GetOk("project_id"); ok { + projectId = v.(string) + request.ProjectId = helper.String(projectId) + } + + if v, ok := d.GetOk("parent_folder_path"); ok { + request.ParentFolderPath = helper.String(v.(string)) + } + + if v, ok := d.GetOk("folder_name"); ok { + request.FolderName = helper.String(v.(string)) + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().CreateResourceFolderWithContext(ctx, request) + if e != nil { + return tccommon.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 wedata resource folder failed, reason:%+v", logId, err) + return err + } + + if response.Response.Data != nil && response.Response.Data.FolderId != nil { + folderId = *response.Response.Data.FolderId + d.SetId(strings.Join([]string{projectId, folderId}, tccommon.FILED_SP)) + } + + return resourceTencentCloudWedataResourceFolderRead(d, meta) +} + +func resourceTencentCloudWedataResourceFolderRead(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_resource_folder.read")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + service := WedataService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} + + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + projectId := idSplit[0] + folderId := idSplit[1] + + parentFolderPath := d.Get("parent_folder_path").(string) + respData, err := service.DescribeWedataResourceFolderById(ctx, projectId, folderId, parentFolderPath) + if err != nil { + return err + } + + if len(respData) < 1 { + d.SetId("") + log.Printf("[WARN]%s resource `wedata_resource_folder` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + folder := respData[0] + if folder.FolderName != nil { + _ = d.Set("folder_name", folder.FolderName) + } + + _ = projectId + _ = folderId + return nil +} + +func resourceTencentCloudWedataResourceFolderUpdate(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_resource_folder.update")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + immutableArgs := []string{"parent_folder_path"} + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + projectId := idSplit[0] + folderId := idSplit[1] + + needChange := false + mutableArgs := []string{"project_id", "folder_id", "folder_name"} + for _, v := range mutableArgs { + if d.HasChange(v) { + needChange = true + break + } + } + + if needChange { + request := wedatav20250806.NewUpdateResourceFolderRequest() + request.ProjectId = helper.String(projectId) + request.FolderId = helper.String(folderId) + + if v, ok := d.GetOk("folder_name"); ok { + request.FolderName = helper.String(v.(string)) + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().UpdateResourceFolderWithContext(ctx, request) + if e != nil { + return tccommon.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 wedata resource folder failed, reason:%+v", logId, err) + return err + } + } + + _ = projectId + _ = folderId + return resourceTencentCloudWedataResourceFolderRead(d, meta) +} + +func resourceTencentCloudWedataResourceFolderDelete(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_resource_folder.delete")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + projectId := idSplit[0] + folderId := idSplit[1] + + var ( + request = wedatav20250806.NewDeleteResourceFolderRequest() + response = wedatav20250806.NewDeleteResourceFolderResponse() + ) + + request.ProjectId = helper.String(projectId) + request.FolderId = helper.String(folderId) + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().DeleteResourceFolderWithContext(ctx, request) + if e != nil { + return tccommon.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 delete wedata resource folder failed, reason:%+v", logId, err) + return err + } + + _ = response + _ = projectId + _ = folderId + return nil +} diff --git a/tencentcloud/services/wedata/resource_tc_wedata_resource_folder.md b/tencentcloud/services/wedata/resource_tc_wedata_resource_folder.md new file mode 100644 index 0000000000..4d7a22c1e9 --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_resource_folder.md @@ -0,0 +1,11 @@ +Provides a resource to create a wedata wedata_resource_folder + +Example Usage + +```hcl +resource "tencentcloud_wedata_resource_folder" "wedata_resource_folder" { + project_id = 2905622749543821312 + parent_folder_path = "/" + folder_name = "folder" +} +``` diff --git a/tencentcloud/services/wedata/resource_tc_wedata_resource_folder_test.go b/tencentcloud/services/wedata/resource_tc_wedata_resource_folder_test.go new file mode 100644 index 0000000000..a1b0420a6b --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_resource_folder_test.go @@ -0,0 +1,47 @@ +package wedata_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest" +) + +func TestAccTencentCloudWedataResourceFolderResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + tcacctest.AccPreCheck(t) + }, + Providers: tcacctest.AccProviders, + Steps: []resource.TestStep{ + { + Config: testAccWedataResourceFolder, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_wedata_resource_folder.wedata_resource_folder", "id")), + }, + { + Config: testAccWedataResourceFolderUpdate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("tencentcloud_wedata_resource_folder.wedata_resource_folder", "folder_name", "folder1"), + ), + }, + }, + }) +} + +const testAccWedataResourceFolder = ` +resource "tencentcloud_wedata_resource_folder" "wedata_resource_folder" { + project_id = 2905622749543821312 + parent_folder_path = "/" + folder_name = "folder" +} +` + +const testAccWedataResourceFolderUpdate = ` +resource "tencentcloud_wedata_resource_folder" "wedata_resource_folder" { + project_id = 2905622749543821312 + parent_folder_path = "/" + folder_name = "folder1" +} +` diff --git a/tencentcloud/services/wedata/resource_tc_wedata_task.go b/tencentcloud/services/wedata/resource_tc_wedata_task.go new file mode 100644 index 0000000000..f723587077 --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_task.go @@ -0,0 +1,1585 @@ +package wedata + +import ( + "context" + "fmt" + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + wedatav20250806 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata/v20250806" + + tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func ResourceTencentCloudWedataTask() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudWedataTaskCreate, + Read: resourceTencentCloudWedataTaskRead, + Update: resourceTencentCloudWedataTaskUpdate, + Delete: resourceTencentCloudWedataTaskDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "project_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "Project ID.", + }, + + "task_base_attribute": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Description: "Basic task attributes.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "task_name": { + Type: schema.TypeString, + Required: true, + Description: "Task name.", + }, + "task_type_id": { + Type: schema.TypeString, + Required: true, + Description: "Task type ID:\n\n* 21:JDBC SQL\n* 23:TDSQL-PostgreSQL\n* 26:OfflineSynchronization\n* 30:Python\n* 31:PySpark\n* 32:DLC SQL\n* 33:Impala\n* 34:Hive SQL\n* 35:Shell\n* 36:Spark SQL\n* 38:Shell Form Mode\n* 39:Spark\n* 40:TCHouse-P\n* 41:Kettle\n* 42:Tchouse-X\n* 43:TCHouse-X SQL\n* 46:DLC Spark\n* 47:TiOne\n* 48:Trino\n* 50:DLC PySpark\n* 92:MapReduce\n* 130:Branch Node\n* 131:Merged Node\n* 132:Notebook\n* 133:SSH\n* 134:StarRocks\n* 137:For-each\n* 138:Setats SQL.", + }, + "workflow_id": { + Type: schema.TypeString, + Required: true, + Description: "Workflow ID.", + }, + "owner_uin": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Task owner ID, defaults to current user.", + }, + "task_description": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Task description.", + }, + }, + }, + }, + + "task_configuration": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Description: "Task configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "resource_group": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Resource group ID: Need to obtain ExecutorGroupId via DescribeNormalSchedulerExecutorGroups.", + }, + "code_content": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Base64 encoded code content.", + }, + "task_ext_configuration_list": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + Description: "Task extended attribute configuration list.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "param_key": { + Type: schema.TypeString, + Required: true, + Description: "Parameter name.", + }, + "param_value": { + Type: schema.TypeString, + Required: true, + Description: "Parameter value.", + }, + }, + }, + }, + "data_cluster": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Cluster ID.", + }, + "broker_ip": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Specified running node.", + }, + "yarn_queue": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Resource pool queue name, need to obtain via DescribeProjectClusterQueues.", + }, + "source_service_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Source data source ID, separated by `;`, need to obtain via DescribeDataSourceWithoutInfo.", + }, + "target_service_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Target data source ID, separated by `;`, need to obtain via DescribeDataSourceWithoutInfo.", + }, + "task_scheduling_parameter_list": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + Description: "Scheduling parameters.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "param_key": { + Type: schema.TypeString, + Required: true, + Description: "Parameter name.", + }, + "param_value": { + Type: schema.TypeString, + Required: true, + Description: "Parameter value.", + }, + }, + }, + }, + "bundle_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "ID used by Bundle.", + }, + "bundle_info": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Bundle information.", + }, + }, + }, + }, + + "task_scheduler_configuration": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Description: "Task scheduling configuration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cycle_type": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Cycle type: Defaults to DAY_CYCLE.\n\nSupported types are\n\n* ONEOFF_CYCLE: One-time\n* YEAR_CYCLE: Yearly\n* MONTH_CYCLE: Monthly\n* WEEK_CYCLE: Weekly\n* DAY_CYCLE: Daily\n* HOUR_CYCLE: Hourly\n* MINUTE_CYCLE: Minutely\n* CRONTAB_CYCLE: Crontab expression type.", + }, + "schedule_time_zone": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Time zone, defaults to UTC+8.", + }, + "crontab_expression": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Cron expression, defaults to 0 0 0 * * `?` *.", + }, + "start_time": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Effective date, defaults to 00:00:00 of current date.", + }, + "end_time": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "End date, defaults to 2099-12-31 23:59:59.", + }, + "execution_start_time": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Execution time left-closed interval, default 00:00.", + }, + "execution_end_time": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Execution time right-closed interval, default 23:59.", + }, + "schedule_run_type": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Scheduling type: 0 Normal scheduling 1 Empty run scheduling, defaults to 0.", + }, + "calendar_open": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Calendar scheduling: Values are 0 and 1, 1 for enabled, 0 for disabled, defaults to 0.", + }, + "calendar_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Calendar scheduling calendar ID.", + }, + "self_depend": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Self-dependency, default value serial, values: parallel, serial, orderly.", + }, + "upstream_dependency_config_list": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Description: "Upstream dependency array.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "task_id": { + Type: schema.TypeString, + Required: true, + Description: "Task ID.", + }, + "main_cyclic_config": { + Type: schema.TypeString, + Required: true, + Description: "Main dependency configuration, values:\n\n* CRONTAB\n* DAY\n* HOUR\n* LIST_DAY\n* LIST_HOUR\n* LIST_MINUTE\n* MINUTE\n* MONTH\n* RANGE_DAY\n* RANGE_HOUR\n* RANGE_MINUTE\n* WEEK\n* YEAR.", + }, + "subordinate_cyclic_config": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Secondary dependency configuration, values:\n* ALL_DAY_OF_YEAR\n* ALL_MONTH_OF_YEAR\n* CURRENT\n* CURRENT_DAY\n* CURRENT_HOUR\n* CURRENT_MINUTE\n* CURRENT_MONTH\n* CURRENT_WEEK\n* CURRENT_YEAR\n* PREVIOUS_BEGIN_OF_MONTH\n* PREVIOUS_DAY\n* PREVIOUS_DAY_LATER_OFFSET_HOUR\n* PREVIOUS_DAY_LATER_OFFSET_MINUTE\n* PREVIOUS_END_OF_MONTH\n* PREVIOUS_FRIDAY\n* PREVIOUS_HOUR\n* PREVIOUS_HOUR_CYCLE\n* PREVIOUS_HOUR_LATER_OFFSET_MINUTE\n* PREVIOUS_MINUTE_CYCLE\n* PREVIOUS_MONTH\n* PREVIOUS_WEEK\n* PREVIOUS_WEEKEND\n* RECENT_DATE.", + }, + "offset": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Offset in interval and list modes.", + }, + "dependency_strategy": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 1, + Description: "Dependency execution strategy.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "polling_null_strategy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Strategy for waiting for upstream task instances: EXECUTING; WAITING.", + }, + "task_dependency_executing_strategies": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + Description: "This field is required only when PollingNullStrategy is EXECUTING, List type: NOT_EXIST (default, when minute depends on minute/hour depends on hour, parent instance is not within the downstream instance scheduling time range); PARENT_EXPIRED (parent instance failed); PARENT_TIMEOUT (parent instance timed out). If any of the above scenarios is met, the parent task instance dependency judgment can be passed; otherwise, it is necessary to wait for the parent instance.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "task_dependency_executing_timeout_value": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "This field is required only when TaskDependencyExecutingStrategies contains PARENT_TIMEOUT, the timeout time for downstream tasks depending on parent instance execution, unit: minutes.", + }, + }, + }, + }, + }, + }, + }, + "event_listener_list": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Description: "Event array.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "event_name": { + Type: schema.TypeString, + Required: true, + Description: "Event name.", + }, + "event_sub_type": { + Type: schema.TypeString, + Required: true, + Description: "Event cycle: SECOND, MIN, HOUR, DAY.", + }, + "event_broadcast_type": { + Type: schema.TypeString, + Required: true, + Description: "Event broadcast type: SINGLE, BROADCAST.", + }, + "properties_list": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Description: "Extended information.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "param_key": { + Type: schema.TypeString, + Required: true, + Description: "Parameter name.", + }, + "param_value": { + Type: schema.TypeString, + Required: true, + Description: "Parameter value.", + }, + }, + }, + }, + }, + }, + }, + "run_priority": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Task scheduling priority: 4 for high, 5 for medium, 6 for low, default: 6.", + }, + "retry_wait": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Retry strategy - retry waiting time, unit: minutes: default: 5.", + }, + "max_retry_attempts": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Retry strategy - maximum number of attempts, default: 4.", + }, + "execution_ttl": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Timeout handling strategy - running time timeout (unit: minutes) defaults to -1.", + }, + "wait_execution_total_ttl": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Timeout handling strategy - total waiting time timeout (unit: minutes) defaults to -1.", + }, + "allow_redo_type": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Rerun & backfill configuration, defaults to ALL; ALL: can rerun or backfill after success or failure; FAILURE: cannot rerun or backfill after success, can rerun or backfill after failure; NONE: cannot rerun or backfill after success or failure.", + }, + "param_task_out_list": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Description: "Output parameter array.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "param_key": { + Type: schema.TypeString, + Required: true, + Description: "Parameter name.", + }, + "param_value": { + Type: schema.TypeString, + Required: true, + Description: "Parameter definition.", + }, + }, + }, + }, + "param_task_in_list": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Description: "Input parameter array.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "param_key": { + Type: schema.TypeString, + Required: true, + Description: "Parameter name.", + }, + "param_desc": { + Type: schema.TypeString, + Required: true, + Description: "Parameter description: format is project_identifier.task_name.parameter_name; example: project_wedata_1.sh_250820_104107.pp_out.", + }, + "from_task_id": { + Type: schema.TypeString, + Required: true, + Description: "Parent task ID.", + }, + "from_param_key": { + Type: schema.TypeString, + Required: true, + Description: "Parent task parameter key.", + }, + }, + }, + }, + "task_output_registry_list": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Description: "Output registration.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "datasource_id": { + Type: schema.TypeString, + Required: true, + Description: "Data source ID.", + }, + "database_name": { + Type: schema.TypeString, + Required: true, + Description: "Database name.", + }, + "table_name": { + Type: schema.TypeString, + Required: true, + Description: "Table name.", + }, + "partition_name": { + Type: schema.TypeString, + Required: true, + Description: "Partition name.", + }, + "data_flow_type": { + Type: schema.TypeString, + Required: true, + Description: "Input/output table type\n Input stream\n UPSTREAM,\n Output stream\n DOWNSTREAM.", + }, + "table_physical_id": { + Type: schema.TypeString, + Required: true, + Description: "Table physical unique ID.", + }, + "db_guid": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Database unique identifier.", + }, + "table_guid": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Table unique identifier.", + }, + }, + }, + }, + "init_strategy": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "**Instance generation strategy**\n* T_PLUS_0: T+0 generation, default strategy\n* T_PLUS_1: T+1 generation.", + }, + }, + }, + }, + }, + } +} + +func resourceTencentCloudWedataTaskCreate(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_task.create")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + var ( + projectId string + taskId string + ) + var ( + request = wedatav20250806.NewCreateTaskRequest() + response = wedatav20250806.NewCreateTaskResponse() + ) + + if v, ok := d.GetOk("project_id"); ok { + projectId = v.(string) + request.ProjectId = helper.String(projectId) + } + + if taskBaseAttributeMap, ok := helper.InterfacesHeadMap(d, "task_base_attribute"); ok { + createTaskBaseAttribute := wedatav20250806.CreateTaskBaseAttribute{} + if v, ok := taskBaseAttributeMap["task_name"]; ok { + createTaskBaseAttribute.TaskName = helper.String(v.(string)) + } + if v, ok := taskBaseAttributeMap["task_type_id"]; ok { + createTaskBaseAttribute.TaskTypeId = helper.String(v.(string)) + } + if v, ok := taskBaseAttributeMap["workflow_id"]; ok { + createTaskBaseAttribute.WorkflowId = helper.String(v.(string)) + } + if v, ok := taskBaseAttributeMap["owner_uin"]; ok { + createTaskBaseAttribute.OwnerUin = helper.String(v.(string)) + } + if v, ok := taskBaseAttributeMap["task_description"]; ok { + createTaskBaseAttribute.TaskDescription = helper.String(v.(string)) + } + request.TaskBaseAttribute = &createTaskBaseAttribute + } + + if taskConfigurationMap, ok := helper.InterfacesHeadMap(d, "task_configuration"); ok { + createTaskConfiguration := wedatav20250806.CreateTaskConfiguration{} + if v, ok := taskConfigurationMap["resource_group"]; ok { + createTaskConfiguration.ResourceGroup = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["code_content"]; ok { + createTaskConfiguration.CodeContent = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["task_ext_configuration_list"]; ok { + for _, item := range v.(*schema.Set).List() { + taskExtConfigurationListMap := item.(map[string]interface{}) + taskExtParameter := wedatav20250806.TaskExtParameter{} + if v, ok := taskExtConfigurationListMap["param_key"]; ok { + taskExtParameter.ParamKey = helper.String(v.(string)) + } + if v, ok := taskExtConfigurationListMap["param_value"]; ok { + taskExtParameter.ParamValue = helper.String(v.(string)) + } + createTaskConfiguration.TaskExtConfigurationList = append(createTaskConfiguration.TaskExtConfigurationList, &taskExtParameter) + } + } + if v, ok := taskConfigurationMap["data_cluster"]; ok { + createTaskConfiguration.DataCluster = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["broker_ip"]; ok { + createTaskConfiguration.BrokerIp = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["yarn_queue"]; ok { + createTaskConfiguration.YarnQueue = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["source_service_id"]; ok { + createTaskConfiguration.SourceServiceId = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["target_service_id"]; ok { + createTaskConfiguration.TargetServiceId = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["task_scheduling_parameter_list"]; ok { + for _, item := range v.(*schema.Set).List() { + taskSchedulingParameterListMap := item.(map[string]interface{}) + taskSchedulingParameter := wedatav20250806.TaskSchedulingParameter{} + if v, ok := taskSchedulingParameterListMap["param_key"]; ok { + taskSchedulingParameter.ParamKey = helper.String(v.(string)) + } + if v, ok := taskSchedulingParameterListMap["param_value"]; ok { + taskSchedulingParameter.ParamValue = helper.String(v.(string)) + } + createTaskConfiguration.TaskSchedulingParameterList = append(createTaskConfiguration.TaskSchedulingParameterList, &taskSchedulingParameter) + } + } + if v, ok := taskConfigurationMap["bundle_id"]; ok { + createTaskConfiguration.BundleId = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["bundle_info"]; ok { + createTaskConfiguration.BundleInfo = helper.String(v.(string)) + } + request.TaskConfiguration = &createTaskConfiguration + } + + if taskSchedulerConfigurationMap, ok := helper.InterfacesHeadMap(d, "task_scheduler_configuration"); ok { + createTaskSchedulerConfiguration := wedatav20250806.CreateTaskSchedulerConfiguration{} + if v, ok := taskSchedulerConfigurationMap["cycle_type"]; ok { + createTaskSchedulerConfiguration.CycleType = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["schedule_time_zone"]; ok { + createTaskSchedulerConfiguration.ScheduleTimeZone = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["crontab_expression"]; ok { + createTaskSchedulerConfiguration.CrontabExpression = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["start_time"]; ok { + createTaskSchedulerConfiguration.StartTime = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["end_time"]; ok { + createTaskSchedulerConfiguration.EndTime = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["execution_start_time"]; ok { + createTaskSchedulerConfiguration.ExecutionStartTime = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["execution_end_time"]; ok { + createTaskSchedulerConfiguration.ExecutionEndTime = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["schedule_run_type"]; ok { + createTaskSchedulerConfiguration.ScheduleRunType = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["calendar_open"]; ok { + createTaskSchedulerConfiguration.CalendarOpen = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["calendar_id"]; ok { + createTaskSchedulerConfiguration.CalendarId = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["self_depend"]; ok { + createTaskSchedulerConfiguration.SelfDepend = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["upstream_dependency_config_list"]; ok { + for _, item := range v.([]interface{}) { + upstreamDependencyConfigListMap := item.(map[string]interface{}) + dependencyTaskBrief := wedatav20250806.DependencyTaskBrief{} + if v, ok := upstreamDependencyConfigListMap["task_id"]; ok { + dependencyTaskBrief.TaskId = helper.String(v.(string)) + } + if v, ok := upstreamDependencyConfigListMap["main_cyclic_config"]; ok { + dependencyTaskBrief.MainCyclicConfig = helper.String(v.(string)) + } + if v, ok := upstreamDependencyConfigListMap["subordinate_cyclic_config"]; ok { + dependencyTaskBrief.SubordinateCyclicConfig = helper.String(v.(string)) + } + if v, ok := upstreamDependencyConfigListMap["offset"]; ok { + dependencyTaskBrief.Offset = helper.String(v.(string)) + } + if dependencyStrategyMap, ok := helper.ConvertInterfacesHeadToMap(upstreamDependencyConfigListMap["dependency_strategy"]); ok { + dependencyStrategyTask := wedatav20250806.DependencyStrategyTask{} + if v, ok := dependencyStrategyMap["polling_null_strategy"]; ok { + dependencyStrategyTask.PollingNullStrategy = helper.String(v.(string)) + } + if v, ok := dependencyStrategyMap["task_dependency_executing_strategies"]; ok { + taskDependencyExecutingStrategiesSet := v.(*schema.Set).List() + for i := range taskDependencyExecutingStrategiesSet { + taskDependencyExecutingStrategies := taskDependencyExecutingStrategiesSet[i].(string) + dependencyStrategyTask.TaskDependencyExecutingStrategies = append(dependencyStrategyTask.TaskDependencyExecutingStrategies, helper.String(taskDependencyExecutingStrategies)) + } + } + if v, ok := dependencyStrategyMap["task_dependency_executing_timeout_value"]; ok { + dependencyStrategyTask.TaskDependencyExecutingTimeoutValue = helper.IntInt64(v.(int)) + } + dependencyTaskBrief.DependencyStrategy = &dependencyStrategyTask + } + createTaskSchedulerConfiguration.UpstreamDependencyConfigList = append(createTaskSchedulerConfiguration.UpstreamDependencyConfigList, &dependencyTaskBrief) + } + } + if v, ok := taskSchedulerConfigurationMap["event_listener_list"]; ok { + for _, item := range v.([]interface{}) { + eventListenerListMap := item.(map[string]interface{}) + eventListener := wedatav20250806.EventListener{} + if v, ok := eventListenerListMap["event_name"]; ok { + eventListener.EventName = helper.String(v.(string)) + } + if v, ok := eventListenerListMap["event_sub_type"]; ok { + eventListener.EventSubType = helper.String(v.(string)) + } + if v, ok := eventListenerListMap["event_broadcast_type"]; ok { + eventListener.EventBroadcastType = helper.String(v.(string)) + } + if v, ok := eventListenerListMap["properties_list"]; ok { + for _, item := range v.([]interface{}) { + propertiesListMap := item.(map[string]interface{}) + paramInfo := wedatav20250806.ParamInfo{} + if v, ok := propertiesListMap["param_key"]; ok { + paramInfo.ParamKey = helper.String(v.(string)) + } + if v, ok := propertiesListMap["param_value"]; ok { + paramInfo.ParamValue = helper.String(v.(string)) + } + eventListener.PropertiesList = append(eventListener.PropertiesList, ¶mInfo) + } + } + createTaskSchedulerConfiguration.EventListenerList = append(createTaskSchedulerConfiguration.EventListenerList, &eventListener) + } + } + if v, ok := taskSchedulerConfigurationMap["run_priority"]; ok { + createTaskSchedulerConfiguration.RunPriority = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["retry_wait"]; ok { + createTaskSchedulerConfiguration.RetryWait = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["max_retry_attempts"]; ok { + createTaskSchedulerConfiguration.MaxRetryAttempts = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["execution_ttl"]; ok { + createTaskSchedulerConfiguration.ExecutionTTL = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["wait_execution_total_ttl"]; ok { + createTaskSchedulerConfiguration.WaitExecutionTotalTTL = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["allow_redo_type"]; ok { + createTaskSchedulerConfiguration.AllowRedoType = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["param_task_out_list"]; ok { + for _, item := range v.([]interface{}) { + paramTaskOutListMap := item.(map[string]interface{}) + outTaskParameter := wedatav20250806.OutTaskParameter{} + if v, ok := paramTaskOutListMap["param_key"]; ok { + outTaskParameter.ParamKey = helper.String(v.(string)) + } + if v, ok := paramTaskOutListMap["param_value"]; ok { + outTaskParameter.ParamValue = helper.String(v.(string)) + } + createTaskSchedulerConfiguration.ParamTaskOutList = append(createTaskSchedulerConfiguration.ParamTaskOutList, &outTaskParameter) + } + } + if v, ok := taskSchedulerConfigurationMap["param_task_in_list"]; ok { + for _, item := range v.([]interface{}) { + paramTaskInListMap := item.(map[string]interface{}) + inTaskParameter := wedatav20250806.InTaskParameter{} + if v, ok := paramTaskInListMap["param_key"]; ok { + inTaskParameter.ParamKey = helper.String(v.(string)) + } + if v, ok := paramTaskInListMap["param_desc"]; ok { + inTaskParameter.ParamDesc = helper.String(v.(string)) + } + if v, ok := paramTaskInListMap["from_task_id"]; ok { + inTaskParameter.FromTaskId = helper.String(v.(string)) + } + if v, ok := paramTaskInListMap["from_param_key"]; ok { + inTaskParameter.FromParamKey = helper.String(v.(string)) + } + createTaskSchedulerConfiguration.ParamTaskInList = append(createTaskSchedulerConfiguration.ParamTaskInList, &inTaskParameter) + } + } + if v, ok := taskSchedulerConfigurationMap["task_output_registry_list"]; ok { + for _, item := range v.([]interface{}) { + taskOutputRegistryListMap := item.(map[string]interface{}) + taskDataRegistry := wedatav20250806.TaskDataRegistry{} + if v, ok := taskOutputRegistryListMap["datasource_id"]; ok { + taskDataRegistry.DatasourceId = helper.String(v.(string)) + } + if v, ok := taskOutputRegistryListMap["database_name"]; ok { + taskDataRegistry.DatabaseName = helper.String(v.(string)) + } + if v, ok := taskOutputRegistryListMap["table_name"]; ok { + taskDataRegistry.TableName = helper.String(v.(string)) + } + if v, ok := taskOutputRegistryListMap["partition_name"]; ok { + taskDataRegistry.PartitionName = helper.String(v.(string)) + } + if v, ok := taskOutputRegistryListMap["data_flow_type"]; ok { + taskDataRegistry.DataFlowType = helper.String(v.(string)) + } + if v, ok := taskOutputRegistryListMap["table_physical_id"]; ok { + taskDataRegistry.TablePhysicalId = helper.String(v.(string)) + } + if v, ok := taskOutputRegistryListMap["db_guid"]; ok { + taskDataRegistry.DbGuid = helper.String(v.(string)) + } + if v, ok := taskOutputRegistryListMap["table_guid"]; ok { + taskDataRegistry.TableGuid = helper.String(v.(string)) + } + createTaskSchedulerConfiguration.TaskOutputRegistryList = append(createTaskSchedulerConfiguration.TaskOutputRegistryList, &taskDataRegistry) + } + } + if v, ok := taskSchedulerConfigurationMap["init_strategy"]; ok { + createTaskSchedulerConfiguration.InitStrategy = helper.String(v.(string)) + } + request.TaskSchedulerConfiguration = &createTaskSchedulerConfiguration + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().CreateTaskWithContext(ctx, request) + if e != nil { + return tccommon.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 wedata task failed, reason:%+v", logId, err) + return err + } + + if response.Response != nil && response.Response.Data != nil && response.Response.Data.TaskId != nil { + taskId = *response.Response.Data.TaskId + } else { + return fmt.Errorf("taskId is nil") + } + _ = response + + d.SetId(strings.Join([]string{projectId, taskId}, tccommon.FILED_SP)) + + return resourceTencentCloudWedataTaskRead(d, meta) +} + +func resourceTencentCloudWedataTaskRead(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_task.read")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + service := WedataService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} + + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + projectId := idSplit[0] + taskId := idSplit[1] + + var response *wedatav20250806.GetTaskResponseParams + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := service.DescribeWedataTaskById(ctx, projectId, taskId) + if e != nil { + return tccommon.RetryError(e) + } + response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s delete wedata task failed, reason:%+v", logId, err) + return err + } + + if response == nil { + d.SetId("") + log.Printf("[WARN]%s resource `wedata_task` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + _ = d.Set("project_id", projectId) + + respData := response.Data + taskBaseAttributeMap := map[string]interface{}{} + if respData.TaskBaseAttribute != nil { + + if respData.TaskBaseAttribute.TaskName != nil { + taskBaseAttributeMap["task_name"] = respData.TaskBaseAttribute.TaskName + } + + if respData.TaskBaseAttribute.TaskTypeId != nil { + taskBaseAttributeMap["task_type_id"] = helper.UInt64ToStr(*respData.TaskBaseAttribute.TaskTypeId) + } + + if respData.TaskBaseAttribute.WorkflowId != nil { + taskBaseAttributeMap["workflow_id"] = respData.TaskBaseAttribute.WorkflowId + } + + if respData.TaskBaseAttribute.OwnerUin != nil { + taskBaseAttributeMap["owner_uin"] = respData.TaskBaseAttribute.OwnerUin + } + + if respData.TaskBaseAttribute.TaskDescription != nil { + taskBaseAttributeMap["task_description"] = respData.TaskBaseAttribute.TaskDescription + } + + _ = d.Set("task_base_attribute", []interface{}{taskBaseAttributeMap}) + } + + taskConfigurationMap := map[string]interface{}{} + + if respData.TaskConfiguration != nil { + if respData.TaskConfiguration.ResourceGroup != nil { + taskConfigurationMap["resource_group"] = respData.TaskConfiguration.ResourceGroup + } + + if respData.TaskConfiguration.CodeContent != nil { + taskConfigurationMap["code_content"] = respData.TaskConfiguration.CodeContent + } + + taskExtConfigurationListList := make([]map[string]interface{}, 0, len(respData.TaskConfiguration.TaskExtConfigurationList)) + if respData.TaskConfiguration.TaskExtConfigurationList != nil { + for _, taskExtConfigurationList := range respData.TaskConfiguration.TaskExtConfigurationList { + taskExtConfigurationListMap := map[string]interface{}{} + + if taskExtConfigurationList.ParamKey != nil { + taskExtConfigurationListMap["param_key"] = taskExtConfigurationList.ParamKey + } + + if taskExtConfigurationList.ParamValue != nil { + taskExtConfigurationListMap["param_value"] = taskExtConfigurationList.ParamValue + } + + taskExtConfigurationListList = append(taskExtConfigurationListList, taskExtConfigurationListMap) + } + + taskConfigurationMap["task_ext_configuration_list"] = taskExtConfigurationListList + } + if respData.TaskConfiguration.DataCluster != nil { + taskConfigurationMap["data_cluster"] = respData.TaskConfiguration.DataCluster + } + + if respData.TaskConfiguration.BrokerIp != nil { + taskConfigurationMap["broker_ip"] = respData.TaskConfiguration.BrokerIp + } + + if respData.TaskConfiguration.YarnQueue != nil { + taskConfigurationMap["yarn_queue"] = respData.TaskConfiguration.YarnQueue + } + + if respData.TaskConfiguration.SourceServiceId != nil { + taskConfigurationMap["source_service_id"] = respData.TaskConfiguration.SourceServiceId + } + + if respData.TaskConfiguration.TargetServiceId != nil { + taskConfigurationMap["target_service_id"] = respData.TaskConfiguration.TargetServiceId + } + + taskSchedulingParameterListList := make([]map[string]interface{}, 0, len(respData.TaskConfiguration.TaskSchedulingParameterList)) + if respData.TaskConfiguration.TaskSchedulingParameterList != nil { + for _, taskSchedulingParameterList := range respData.TaskConfiguration.TaskSchedulingParameterList { + taskSchedulingParameterListMap := map[string]interface{}{} + + if taskSchedulingParameterList.ParamKey != nil { + taskSchedulingParameterListMap["param_key"] = taskSchedulingParameterList.ParamKey + } + + if taskSchedulingParameterList.ParamValue != nil { + taskSchedulingParameterListMap["param_value"] = taskSchedulingParameterList.ParamValue + } + + taskSchedulingParameterListList = append(taskSchedulingParameterListList, taskSchedulingParameterListMap) + } + + taskConfigurationMap["task_scheduling_parameter_list"] = taskSchedulingParameterListList + } + if respData.TaskConfiguration.BundleId != nil { + taskConfigurationMap["bundle_id"] = respData.TaskConfiguration.BundleId + } + + if respData.TaskConfiguration.BundleInfo != nil { + taskConfigurationMap["bundle_info"] = respData.TaskConfiguration.BundleInfo + } + + _ = d.Set("task_configuration", []interface{}{taskConfigurationMap}) + } + + taskSchedulerConfigurationMap := map[string]interface{}{} + + if respData.TaskSchedulerConfiguration != nil { + if respData.TaskSchedulerConfiguration.CycleType != nil { + taskSchedulerConfigurationMap["cycle_type"] = respData.TaskSchedulerConfiguration.CycleType + } + + if respData.TaskSchedulerConfiguration.ScheduleTimeZone != nil { + taskSchedulerConfigurationMap["schedule_time_zone"] = respData.TaskSchedulerConfiguration.ScheduleTimeZone + } + + if respData.TaskSchedulerConfiguration.CrontabExpression != nil { + taskSchedulerConfigurationMap["crontab_expression"] = respData.TaskSchedulerConfiguration.CrontabExpression + } + + if respData.TaskSchedulerConfiguration.StartTime != nil { + taskSchedulerConfigurationMap["start_time"] = respData.TaskSchedulerConfiguration.StartTime + } + + if respData.TaskSchedulerConfiguration.EndTime != nil { + taskSchedulerConfigurationMap["end_time"] = respData.TaskSchedulerConfiguration.EndTime + } + + if respData.TaskSchedulerConfiguration.ExecutionStartTime != nil { + taskSchedulerConfigurationMap["execution_start_time"] = respData.TaskSchedulerConfiguration.ExecutionStartTime + } + + if respData.TaskSchedulerConfiguration.ExecutionEndTime != nil { + taskSchedulerConfigurationMap["execution_end_time"] = respData.TaskSchedulerConfiguration.ExecutionEndTime + } + + if respData.TaskSchedulerConfiguration.ScheduleRunType != nil { + taskSchedulerConfigurationMap["schedule_run_type"] = helper.Int64ToStr(*respData.TaskSchedulerConfiguration.ScheduleRunType) + } + + if respData.TaskSchedulerConfiguration.CalendarOpen != nil { + taskSchedulerConfigurationMap["calendar_open"] = respData.TaskSchedulerConfiguration.CalendarOpen + } + + if respData.TaskSchedulerConfiguration.CalendarId != nil { + taskSchedulerConfigurationMap["calendar_id"] = respData.TaskSchedulerConfiguration.CalendarId + } + + if respData.TaskSchedulerConfiguration.SelfDepend != nil { + taskSchedulerConfigurationMap["self_depend"] = respData.TaskSchedulerConfiguration.SelfDepend + } + + upstreamDependencyConfigListList := make([]map[string]interface{}, 0, len(respData.TaskSchedulerConfiguration.UpstreamDependencyConfigList)) + if respData.TaskSchedulerConfiguration.UpstreamDependencyConfigList != nil { + for _, upstreamDependencyConfigList := range respData.TaskSchedulerConfiguration.UpstreamDependencyConfigList { + upstreamDependencyConfigListMap := map[string]interface{}{} + + if upstreamDependencyConfigList.TaskId != nil { + upstreamDependencyConfigListMap["task_id"] = upstreamDependencyConfigList.TaskId + } + + if upstreamDependencyConfigList.MainCyclicConfig != nil { + upstreamDependencyConfigListMap["main_cyclic_config"] = upstreamDependencyConfigList.MainCyclicConfig + } + + if upstreamDependencyConfigList.SubordinateCyclicConfig != nil { + upstreamDependencyConfigListMap["subordinate_cyclic_config"] = upstreamDependencyConfigList.SubordinateCyclicConfig + } + + if upstreamDependencyConfigList.Offset != nil { + upstreamDependencyConfigListMap["offset"] = upstreamDependencyConfigList.Offset + } + + dependencyStrategyMap := map[string]interface{}{} + + if upstreamDependencyConfigList.DependencyStrategy != nil { + if upstreamDependencyConfigList.DependencyStrategy.PollingNullStrategy != nil { + dependencyStrategyMap["polling_null_strategy"] = upstreamDependencyConfigList.DependencyStrategy.PollingNullStrategy + } + + if upstreamDependencyConfigList.DependencyStrategy.TaskDependencyExecutingStrategies != nil { + dependencyStrategyMap["task_dependency_executing_strategies"] = upstreamDependencyConfigList.DependencyStrategy.TaskDependencyExecutingStrategies + } + + if upstreamDependencyConfigList.DependencyStrategy.TaskDependencyExecutingTimeoutValue != nil { + dependencyStrategyMap["task_dependency_executing_timeout_value"] = upstreamDependencyConfigList.DependencyStrategy.TaskDependencyExecutingTimeoutValue + } + + upstreamDependencyConfigListMap["dependency_strategy"] = []interface{}{dependencyStrategyMap} + } + + upstreamDependencyConfigListList = append(upstreamDependencyConfigListList, upstreamDependencyConfigListMap) + } + + taskSchedulerConfigurationMap["upstream_dependency_config_list"] = upstreamDependencyConfigListList + } + + eventListenerListList := make([]map[string]interface{}, 0, len(respData.TaskSchedulerConfiguration.EventListenerList)) + if respData.TaskSchedulerConfiguration.EventListenerList != nil { + for _, eventListenerList := range respData.TaskSchedulerConfiguration.EventListenerList { + eventListenerListMap := map[string]interface{}{} + + if eventListenerList.EventName != nil { + eventListenerListMap["event_name"] = eventListenerList.EventName + } + + if eventListenerList.EventSubType != nil { + eventListenerListMap["event_sub_type"] = eventListenerList.EventSubType + } + + if eventListenerList.EventBroadcastType != nil { + eventListenerListMap["event_broadcast_type"] = eventListenerList.EventBroadcastType + } + + propertiesListList := make([]map[string]interface{}, 0, len(eventListenerList.PropertiesList)) + if eventListenerList.PropertiesList != nil { + for _, propertiesList := range eventListenerList.PropertiesList { + propertiesListMap := map[string]interface{}{} + + if propertiesList.ParamKey != nil { + propertiesListMap["param_key"] = propertiesList.ParamKey + } + + if propertiesList.ParamValue != nil { + propertiesListMap["param_value"] = propertiesList.ParamValue + } + + propertiesListList = append(propertiesListList, propertiesListMap) + } + + eventListenerListMap["properties_list"] = propertiesListList + } + eventListenerListList = append(eventListenerListList, eventListenerListMap) + } + + taskSchedulerConfigurationMap["event_listener_list"] = eventListenerListList + } + if respData.TaskSchedulerConfiguration.RunPriority != nil { + taskSchedulerConfigurationMap["run_priority"] = helper.UInt64ToStr(*respData.TaskSchedulerConfiguration.RunPriority) + } + + if respData.TaskSchedulerConfiguration.RetryWait != nil { + taskSchedulerConfigurationMap["retry_wait"] = helper.Int64ToStr(*respData.TaskSchedulerConfiguration.RetryWait) + } + + if respData.TaskSchedulerConfiguration.MaxRetryAttempts != nil { + taskSchedulerConfigurationMap["max_retry_attempts"] = helper.Int64ToStr(*respData.TaskSchedulerConfiguration.MaxRetryAttempts) + } + + if respData.TaskSchedulerConfiguration.ExecutionTTL != nil { + taskSchedulerConfigurationMap["execution_ttl"] = helper.Int64ToStr(*respData.TaskSchedulerConfiguration.ExecutionTTL) + } + + if respData.TaskSchedulerConfiguration.WaitExecutionTotalTTL != nil { + taskSchedulerConfigurationMap["wait_execution_total_ttl"] = respData.TaskSchedulerConfiguration.WaitExecutionTotalTTL + } + + if respData.TaskSchedulerConfiguration.AllowRedoType != nil { + taskSchedulerConfigurationMap["allow_redo_type"] = respData.TaskSchedulerConfiguration.AllowRedoType + } + + paramTaskOutListList := make([]map[string]interface{}, 0, len(respData.TaskSchedulerConfiguration.ParamTaskOutList)) + if respData.TaskSchedulerConfiguration.ParamTaskOutList != nil { + for _, paramTaskOutList := range respData.TaskSchedulerConfiguration.ParamTaskOutList { + paramTaskOutListMap := map[string]interface{}{} + + if paramTaskOutList.ParamKey != nil { + paramTaskOutListMap["param_key"] = paramTaskOutList.ParamKey + } + + if paramTaskOutList.ParamValue != nil { + paramTaskOutListMap["param_value"] = paramTaskOutList.ParamValue + } + + paramTaskOutListList = append(paramTaskOutListList, paramTaskOutListMap) + } + + taskSchedulerConfigurationMap["param_task_out_list"] = paramTaskOutListList + } + paramTaskInListList := make([]map[string]interface{}, 0, len(respData.TaskSchedulerConfiguration.ParamTaskInList)) + if respData.TaskSchedulerConfiguration.ParamTaskInList != nil { + for _, paramTaskInList := range respData.TaskSchedulerConfiguration.ParamTaskInList { + paramTaskInListMap := map[string]interface{}{} + + if paramTaskInList.ParamKey != nil { + paramTaskInListMap["param_key"] = paramTaskInList.ParamKey + } + + if paramTaskInList.ParamDesc != nil { + paramTaskInListMap["param_desc"] = paramTaskInList.ParamDesc + } + + if paramTaskInList.FromTaskId != nil { + paramTaskInListMap["from_task_id"] = paramTaskInList.FromTaskId + } + + if paramTaskInList.FromParamKey != nil { + paramTaskInListMap["from_param_key"] = paramTaskInList.FromParamKey + } + + paramTaskInListList = append(paramTaskInListList, paramTaskInListMap) + } + + taskSchedulerConfigurationMap["param_task_in_list"] = paramTaskInListList + } + taskOutputRegistryListList := make([]map[string]interface{}, 0, len(respData.TaskSchedulerConfiguration.TaskOutputRegistryList)) + if respData.TaskSchedulerConfiguration.TaskOutputRegistryList != nil { + for _, taskOutputRegistryList := range respData.TaskSchedulerConfiguration.TaskOutputRegistryList { + taskOutputRegistryListMap := map[string]interface{}{} + + if taskOutputRegistryList.DatasourceId != nil { + taskOutputRegistryListMap["datasource_id"] = taskOutputRegistryList.DatasourceId + } + + if taskOutputRegistryList.DatabaseName != nil { + taskOutputRegistryListMap["database_name"] = taskOutputRegistryList.DatabaseName + } + + if taskOutputRegistryList.TableName != nil { + taskOutputRegistryListMap["table_name"] = taskOutputRegistryList.TableName + } + + if taskOutputRegistryList.PartitionName != nil { + taskOutputRegistryListMap["partition_name"] = taskOutputRegistryList.PartitionName + } + + if taskOutputRegistryList.DataFlowType != nil { + taskOutputRegistryListMap["data_flow_type"] = taskOutputRegistryList.DataFlowType + } + + if taskOutputRegistryList.TablePhysicalId != nil { + taskOutputRegistryListMap["table_physical_id"] = taskOutputRegistryList.TablePhysicalId + } + + if taskOutputRegistryList.DbGuid != nil { + taskOutputRegistryListMap["db_guid"] = taskOutputRegistryList.DbGuid + } + + if taskOutputRegistryList.TableGuid != nil { + taskOutputRegistryListMap["table_guid"] = taskOutputRegistryList.TableGuid + } + + taskOutputRegistryListList = append(taskOutputRegistryListList, taskOutputRegistryListMap) + } + + taskSchedulerConfigurationMap["task_output_registry_list"] = taskOutputRegistryListList + } + if respData.TaskSchedulerConfiguration.InitStrategy != nil { + taskSchedulerConfigurationMap["init_strategy"] = respData.TaskSchedulerConfiguration.InitStrategy + } + + _ = d.Set("task_scheduler_configuration", []interface{}{taskSchedulerConfigurationMap}) + } + _ = projectId + _ = taskId + return nil +} + +func resourceTencentCloudWedataTaskUpdate(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_task.update")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + immutableArgs := []string{} + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + projectId := idSplit[0] + taskId := idSplit[1] + + needChange := false + mutableArgs := []string{"task_base_attribute", "task_configuration", "task_scheduler_configuration"} + for _, v := range mutableArgs { + if d.HasChange(v) { + needChange = true + break + } + } + + if needChange { + request := wedatav20250806.NewUpdateTaskRequest() + request.ProjectId = helper.String(projectId) + request.TaskId = helper.String(taskId) + request.Task = &wedatav20250806.UpdateTaskBrief{} + if taskBaseAttributeMap, ok := helper.InterfacesHeadMap(d, "task_base_attribute"); ok { + updateTaskBaseAttribute := wedatav20250806.UpdateTaskBaseAttribute{} + if v, ok := taskBaseAttributeMap["task_name"]; ok { + updateTaskBaseAttribute.TaskName = helper.String(v.(string)) + } + if v, ok := taskBaseAttributeMap["owner_uin"]; ok { + updateTaskBaseAttribute.OwnerUin = helper.String(v.(string)) + } + if v, ok := taskBaseAttributeMap["task_description"]; ok { + updateTaskBaseAttribute.TaskDescription = helper.String(v.(string)) + } + request.Task.TaskBaseAttribute = &updateTaskBaseAttribute + } + + if taskConfigurationMap, ok := helper.InterfacesHeadMap(d, "task_configuration"); ok { + taskConfiguration := wedatav20250806.TaskConfiguration{} + if v, ok := taskConfigurationMap["resource_group"]; ok { + taskConfiguration.ResourceGroup = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["code_content"]; ok { + taskConfiguration.CodeContent = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["task_ext_configuration_list"]; ok { + for _, item := range v.(*schema.Set).List() { + taskExtConfigurationListMap := item.(map[string]interface{}) + taskExtParameter := wedatav20250806.TaskExtParameter{} + if v, ok := taskExtConfigurationListMap["param_key"]; ok { + taskExtParameter.ParamKey = helper.String(v.(string)) + } + if v, ok := taskExtConfigurationListMap["param_value"]; ok { + taskExtParameter.ParamValue = helper.String(v.(string)) + } + taskConfiguration.TaskExtConfigurationList = append(taskConfiguration.TaskExtConfigurationList, &taskExtParameter) + } + } + if v, ok := taskConfigurationMap["data_cluster"]; ok { + taskConfiguration.DataCluster = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["broker_ip"]; ok { + taskConfiguration.BrokerIp = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["yarn_queue"]; ok { + taskConfiguration.YarnQueue = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["source_service_id"]; ok { + taskConfiguration.SourceServiceId = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["target_service_id"]; ok { + taskConfiguration.TargetServiceId = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["task_scheduling_parameter_list"]; ok { + for _, item := range v.(*schema.Set).List() { + taskSchedulingParameterListMap := item.(map[string]interface{}) + taskSchedulingParameter := wedatav20250806.TaskSchedulingParameter{} + if v, ok := taskSchedulingParameterListMap["param_key"]; ok { + taskSchedulingParameter.ParamKey = helper.String(v.(string)) + } + if v, ok := taskSchedulingParameterListMap["param_value"]; ok { + taskSchedulingParameter.ParamValue = helper.String(v.(string)) + } + taskConfiguration.TaskSchedulingParameterList = append(taskConfiguration.TaskSchedulingParameterList, &taskSchedulingParameter) + } + } + if v, ok := taskConfigurationMap["bundle_id"]; ok { + taskConfiguration.BundleId = helper.String(v.(string)) + } + if v, ok := taskConfigurationMap["bundle_info"]; ok { + taskConfiguration.BundleInfo = helper.String(v.(string)) + } + request.Task.TaskConfiguration = &taskConfiguration + } + + if taskSchedulerConfigurationMap, ok := helper.InterfacesHeadMap(d, "task_scheduler_configuration"); ok { + taskSchedulerConfiguration := wedatav20250806.TaskSchedulerConfiguration{} + if v, ok := taskSchedulerConfigurationMap["cycle_type"]; ok { + taskSchedulerConfiguration.CycleType = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["schedule_time_zone"]; ok { + taskSchedulerConfiguration.ScheduleTimeZone = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["crontab_expression"]; ok { + taskSchedulerConfiguration.CrontabExpression = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["start_time"]; ok { + taskSchedulerConfiguration.StartTime = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["end_time"]; ok { + taskSchedulerConfiguration.EndTime = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["execution_start_time"]; ok { + taskSchedulerConfiguration.ExecutionStartTime = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["execution_end_time"]; ok { + taskSchedulerConfiguration.ExecutionEndTime = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["schedule_run_type"]; ok { + taskSchedulerConfiguration.ScheduleRunType = helper.StrToInt64Point(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["calendar_open"]; ok { + taskSchedulerConfiguration.CalendarOpen = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["calendar_id"]; ok { + taskSchedulerConfiguration.CalendarId = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["self_depend"]; ok { + taskSchedulerConfiguration.SelfDepend = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["upstream_dependency_config_list"]; ok { + for _, item := range v.([]interface{}) { + upstreamDependencyConfigListMap := item.(map[string]interface{}) + dependencyTaskBrief := wedatav20250806.DependencyTaskBrief{} + if v, ok := upstreamDependencyConfigListMap["task_id"]; ok { + dependencyTaskBrief.TaskId = helper.String(v.(string)) + } + if v, ok := upstreamDependencyConfigListMap["main_cyclic_config"]; ok { + dependencyTaskBrief.MainCyclicConfig = helper.String(v.(string)) + } + if v, ok := upstreamDependencyConfigListMap["subordinate_cyclic_config"]; ok { + dependencyTaskBrief.SubordinateCyclicConfig = helper.String(v.(string)) + } + if v, ok := upstreamDependencyConfigListMap["offset"]; ok { + dependencyTaskBrief.Offset = helper.String(v.(string)) + } + if dependencyStrategyMap, ok := helper.ConvertInterfacesHeadToMap(upstreamDependencyConfigListMap["dependency_strategy"]); ok { + dependencyStrategyTask := wedatav20250806.DependencyStrategyTask{} + if v, ok := dependencyStrategyMap["polling_null_strategy"]; ok { + dependencyStrategyTask.PollingNullStrategy = helper.String(v.(string)) + } + if v, ok := dependencyStrategyMap["task_dependency_executing_strategies"]; ok { + taskDependencyExecutingStrategiesSet := v.(*schema.Set).List() + for i := range taskDependencyExecutingStrategiesSet { + taskDependencyExecutingStrategies := taskDependencyExecutingStrategiesSet[i].(string) + dependencyStrategyTask.TaskDependencyExecutingStrategies = append(dependencyStrategyTask.TaskDependencyExecutingStrategies, helper.String(taskDependencyExecutingStrategies)) + } + } + if v, ok := dependencyStrategyMap["task_dependency_executing_timeout_value"]; ok { + dependencyStrategyTask.TaskDependencyExecutingTimeoutValue = helper.IntInt64(v.(int)) + } + dependencyTaskBrief.DependencyStrategy = &dependencyStrategyTask + } + taskSchedulerConfiguration.UpstreamDependencyConfigList = append(taskSchedulerConfiguration.UpstreamDependencyConfigList, &dependencyTaskBrief) + } + } + if v, ok := taskSchedulerConfigurationMap["event_listener_list"]; ok { + for _, item := range v.([]interface{}) { + eventListenerListMap := item.(map[string]interface{}) + eventListener := wedatav20250806.EventListener{} + if v, ok := eventListenerListMap["event_name"]; ok { + eventListener.EventName = helper.String(v.(string)) + } + if v, ok := eventListenerListMap["event_sub_type"]; ok { + eventListener.EventSubType = helper.String(v.(string)) + } + if v, ok := eventListenerListMap["event_broadcast_type"]; ok { + eventListener.EventBroadcastType = helper.String(v.(string)) + } + if v, ok := eventListenerListMap["properties_list"]; ok { + for _, item := range v.([]interface{}) { + propertiesListMap := item.(map[string]interface{}) + paramInfo := wedatav20250806.ParamInfo{} + if v, ok := propertiesListMap["param_key"]; ok { + paramInfo.ParamKey = helper.String(v.(string)) + } + if v, ok := propertiesListMap["param_value"]; ok { + paramInfo.ParamValue = helper.String(v.(string)) + } + eventListener.PropertiesList = append(eventListener.PropertiesList, ¶mInfo) + } + } + taskSchedulerConfiguration.EventListenerList = append(taskSchedulerConfiguration.EventListenerList, &eventListener) + } + } + if v, ok := taskSchedulerConfigurationMap["run_priority"]; ok { + taskSchedulerConfiguration.RunPriority = helper.StrToUint64Point(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["retry_wait"]; ok { + taskSchedulerConfiguration.RetryWait = helper.StrToInt64Point(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["max_retry_attempts"]; ok { + taskSchedulerConfiguration.MaxRetryAttempts = helper.StrToInt64Point(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["execution_ttl"]; ok { + taskSchedulerConfiguration.ExecutionTTL = helper.StrToInt64Point(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["wait_execution_total_ttl"]; ok { + taskSchedulerConfiguration.WaitExecutionTotalTTL = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["allow_redo_type"]; ok { + taskSchedulerConfiguration.AllowRedoType = helper.String(v.(string)) + } + if v, ok := taskSchedulerConfigurationMap["param_task_out_list"]; ok { + for _, item := range v.([]interface{}) { + paramTaskOutListMap := item.(map[string]interface{}) + outTaskParameter := wedatav20250806.OutTaskParameter{} + if v, ok := paramTaskOutListMap["param_key"]; ok { + outTaskParameter.ParamKey = helper.String(v.(string)) + } + if v, ok := paramTaskOutListMap["param_value"]; ok { + outTaskParameter.ParamValue = helper.String(v.(string)) + } + taskSchedulerConfiguration.ParamTaskOutList = append(taskSchedulerConfiguration.ParamTaskOutList, &outTaskParameter) + } + } + if v, ok := taskSchedulerConfigurationMap["param_task_in_list"]; ok { + for _, item := range v.([]interface{}) { + paramTaskInListMap := item.(map[string]interface{}) + inTaskParameter := wedatav20250806.InTaskParameter{} + if v, ok := paramTaskInListMap["param_key"]; ok { + inTaskParameter.ParamKey = helper.String(v.(string)) + } + if v, ok := paramTaskInListMap["param_desc"]; ok { + inTaskParameter.ParamDesc = helper.String(v.(string)) + } + if v, ok := paramTaskInListMap["from_task_id"]; ok { + inTaskParameter.FromTaskId = helper.String(v.(string)) + } + if v, ok := paramTaskInListMap["from_param_key"]; ok { + inTaskParameter.FromParamKey = helper.String(v.(string)) + } + taskSchedulerConfiguration.ParamTaskInList = append(taskSchedulerConfiguration.ParamTaskInList, &inTaskParameter) + } + } + if v, ok := taskSchedulerConfigurationMap["task_output_registry_list"]; ok { + for _, item := range v.([]interface{}) { + taskOutputRegistryListMap := item.(map[string]interface{}) + taskDataRegistry := wedatav20250806.TaskDataRegistry{} + if v, ok := taskOutputRegistryListMap["datasource_id"]; ok { + taskDataRegistry.DatasourceId = helper.String(v.(string)) + } + if v, ok := taskOutputRegistryListMap["database_name"]; ok { + taskDataRegistry.DatabaseName = helper.String(v.(string)) + } + if v, ok := taskOutputRegistryListMap["table_name"]; ok { + taskDataRegistry.TableName = helper.String(v.(string)) + } + if v, ok := taskOutputRegistryListMap["partition_name"]; ok { + taskDataRegistry.PartitionName = helper.String(v.(string)) + } + if v, ok := taskOutputRegistryListMap["data_flow_type"]; ok { + taskDataRegistry.DataFlowType = helper.String(v.(string)) + } + if v, ok := taskOutputRegistryListMap["table_physical_id"]; ok { + taskDataRegistry.TablePhysicalId = helper.String(v.(string)) + } + if v, ok := taskOutputRegistryListMap["db_guid"]; ok { + taskDataRegistry.DbGuid = helper.String(v.(string)) + } + if v, ok := taskOutputRegistryListMap["table_guid"]; ok { + taskDataRegistry.TableGuid = helper.String(v.(string)) + } + taskSchedulerConfiguration.TaskOutputRegistryList = append(taskSchedulerConfiguration.TaskOutputRegistryList, &taskDataRegistry) + } + } + if v, ok := taskSchedulerConfigurationMap["init_strategy"]; ok { + taskSchedulerConfiguration.InitStrategy = helper.String(v.(string)) + } + request.Task.TaskSchedulerConfiguration = &taskSchedulerConfiguration + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().UpdateTaskWithContext(ctx, request) + if e != nil { + return tccommon.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 wedata task failed, reason:%+v", logId, err) + return err + } + } + + _ = projectId + _ = taskId + return resourceTencentCloudWedataTaskRead(d, meta) +} + +func resourceTencentCloudWedataTaskDelete(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_task.delete")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + projectId := idSplit[0] + taskId := idSplit[1] + + var ( + request = wedatav20250806.NewDeleteTaskRequest() + response = wedatav20250806.NewDeleteTaskResponse() + ) + + request.ProjectId = helper.String(projectId) + request.TaskId = helper.String(taskId) + + if v, ok := d.GetOkExists("operate_inform"); ok { + request.OperateInform = helper.Bool(v.(bool)) + } + + if v, ok := d.GetOkExists("delete_mode"); ok { + request.DeleteMode = helper.Bool(v.(bool)) + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().DeleteTaskWithContext(ctx, request) + if e != nil { + return tccommon.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 delete wedata task failed, reason:%+v", logId, err) + return err + } + + _ = response + _ = projectId + _ = taskId + return nil +} diff --git a/tencentcloud/services/wedata/resource_tc_wedata_task.md b/tencentcloud/services/wedata/resource_tc_wedata_task.md new file mode 100644 index 0000000000..6a16f8da90 --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_task.md @@ -0,0 +1,77 @@ +Provides a resource to create a wedata wedata_task + +Example Usage + +```hcl +resource "tencentcloud_wedata_workflow_folder" "wedata_workflow_folder" { + project_id = "2905622749543821312" + parent_folder_path = "/" + folder_name = "tftest" +} + +resource "tencentcloud_wedata_workflow" "wedata_workflow" { + project_id = 2905622749543821312 + workflow_name = "test_workflow1" + parent_folder_path = "${tencentcloud_wedata_workflow_folder.wedata_workflow_folder.parent_folder_path}${tencentcloud_wedata_workflow_folder.wedata_workflow_folder.folder_name}" + workflow_type = "cycle" +} + +resource "tencentcloud_wedata_task" "wedata_task" { + project_id = 2905622749543821312 + task_base_attribute { + task_name = "tfTask" + task_type_id = 30 + workflow_id = tencentcloud_wedata_workflow.wedata_workflow.workflow_id + } + task_configuration { + code_content = base64encode("Hello World") + task_ext_configuration_list { + param_key = "bucket" + param_value = "wedata-fusion-bjjr-1257305158" + } + task_ext_configuration_list { + param_key = "ftp.file.name" + param_value = "/datastudio/project/2905622749543821312/tftest/test_workflow1/tfTask.py" + } + task_ext_configuration_list { + param_key = "tenantId" + param_value = "1257305158" + } + task_ext_configuration_list { + param_key = "region" + param_value = "ap-beijing-fsi" + } + task_ext_configuration_list { + param_key = "extraInfo" + param_value = "{\"fromMapping\":false}" + } + task_ext_configuration_list { + param_key = "ssmDynamicSkSwitch" + param_value = "ON" + } + task_ext_configuration_list { + param_key = "calendar_open" + param_value = "0" + } + task_ext_configuration_list { + param_key = "specLabelConfItems" + param_value = "eyJzcGVjTGFiZWxDb25mSXRlbXMiOltdfQ==" + } + task_ext_configuration_list { + param_key = "waitExecutionTotalTTL" + param_value = "-1" + } + } + task_scheduler_configuration { + cycle_type = "DAY_CYCLE" + } +} +``` + +Import + +wedata wedata_task can be imported using the id, e.g. + +``` +terraform import tencentcloud_wedata_task.wedata_task wedata_task_id +``` diff --git a/tencentcloud/services/wedata/resource_tc_wedata_task_test.go b/tencentcloud/services/wedata/resource_tc_wedata_task_test.go new file mode 100644 index 0000000000..13018d2046 --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_task_test.go @@ -0,0 +1,168 @@ +package wedata_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest" +) + +func TestAccTencentCloudWedataTaskResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + tcacctest.AccPreCheck(t) + }, + Providers: tcacctest.AccProviders, + Steps: []resource.TestStep{ + { + Config: testAccWedataTask, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_wedata_task.wedata_task", "id")), + }, + { + Config: testAccWedataTaskUpdate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("tencentcloud_wedata_task.wedata_task", "task_base_attribute.0.task_name", "tfTask1"), + ), + }, + { + ResourceName: "tencentcloud_wedata_task.wedata_task", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccWedataTask = ` +resource "tencentcloud_wedata_workflow_folder" "wedata_workflow_folder" { + project_id = "2905622749543821312" + parent_folder_path = "/" + folder_name = "tftest" +} + +resource "tencentcloud_wedata_workflow" "wedata_workflow" { + project_id = 2905622749543821312 + workflow_name = "test_workflow1" + parent_folder_path = "${tencentcloud_wedata_workflow_folder.wedata_workflow_folder.parent_folder_path}${tencentcloud_wedata_workflow_folder.wedata_workflow_folder.folder_name}" + workflow_type = "cycle" +} + +resource "tencentcloud_wedata_task" "wedata_task" { + project_id = 2905622749543821312 + task_base_attribute { + task_name = "tfTask" + task_type_id = 30 + workflow_id = tencentcloud_wedata_workflow.wedata_workflow.workflow_id + } + task_configuration { + code_content = base64encode("Hello World") + task_ext_configuration_list { + param_key = "bucket" + param_value = "wedata-fusion-bjjr-1257305158" + } + task_ext_configuration_list { + param_key = "ftp.file.name" + param_value = "/datastudio/project/2905622749543821312/tftest/test_workflow1/tfTask.py" + } + task_ext_configuration_list { + param_key = "tenantId" + param_value = "1257305158" + } + task_ext_configuration_list { + param_key = "region" + param_value = "ap-beijing-fsi" + } + task_ext_configuration_list { + param_key = "extraInfo" + param_value = "{\"fromMapping\":false}" + } + task_ext_configuration_list { + param_key = "ssmDynamicSkSwitch" + param_value = "ON" + } + task_ext_configuration_list { + param_key = "calendar_open" + param_value = "0" + } + task_ext_configuration_list { + param_key = "specLabelConfItems" + param_value = "eyJzcGVjTGFiZWxDb25mSXRlbXMiOltdfQ==" + } + task_ext_configuration_list { + param_key = "waitExecutionTotalTTL" + param_value = "-1" + } + } + task_scheduler_configuration { + cycle_type = "DAY_CYCLE" + } +} +` + +const testAccWedataTaskUpdate = ` +resource "tencentcloud_wedata_workflow_folder" "wedata_workflow_folder" { + project_id = "2905622749543821312" + parent_folder_path = "/" + folder_name = "tftest" +} + +resource "tencentcloud_wedata_workflow" "wedata_workflow" { + project_id = 2905622749543821312 + workflow_name = "test_workflow1" + parent_folder_path = "${tencentcloud_wedata_workflow_folder.wedata_workflow_folder.parent_folder_path}${tencentcloud_wedata_workflow_folder.wedata_workflow_folder.folder_name}" + workflow_type = "cycle" +} + +resource "tencentcloud_wedata_task" "wedata_task" { + project_id = 2905622749543821312 + task_base_attribute { + task_name = "tfTask1" + task_type_id = 30 + workflow_id = tencentcloud_wedata_workflow.wedata_workflow.workflow_id + } + task_configuration { + code_content = base64encode("Hello World") + task_ext_configuration_list { + param_key = "bucket" + param_value = "wedata-fusion-bjjr-1257305158" + } + task_ext_configuration_list { + param_key = "ftp.file.name" + param_value = "/datastudio/project/2905622749543821312/tftest/test_workflow1/tfTask.py" + } + task_ext_configuration_list { + param_key = "tenantId" + param_value = "1257305158" + } + task_ext_configuration_list { + param_key = "region" + param_value = "ap-beijing-fsi" + } + task_ext_configuration_list { + param_key = "extraInfo" + param_value = "{\"fromMapping\":false}" + } + task_ext_configuration_list { + param_key = "ssmDynamicSkSwitch" + param_value = "ON" + } + task_ext_configuration_list { + param_key = "calendar_open" + param_value = "0" + } + task_ext_configuration_list { + param_key = "specLabelConfItems" + param_value = "eyJzcGVjTGFiZWxDb25mSXRlbXMiOltdfQ==" + } + task_ext_configuration_list { + param_key = "waitExecutionTotalTTL" + param_value = "-1" + } + } + task_scheduler_configuration { + cycle_type = "DAY_CYCLE" + } +} +` diff --git a/tencentcloud/services/wedata/resource_tc_wedata_workflow.go b/tencentcloud/services/wedata/resource_tc_wedata_workflow.go new file mode 100644 index 0000000000..fac7432084 --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_workflow.go @@ -0,0 +1,654 @@ +package wedata + +import ( + "context" + "fmt" + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + wedatav20250806 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata/v20250806" + + tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func ResourceTencentCloudWedataWorkflow() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudWedataWorkflowCreate, + Read: resourceTencentCloudWedataWorkflowRead, + Update: resourceTencentCloudWedataWorkflowUpdate, + Delete: resourceTencentCloudWedataWorkflowDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "project_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "Project id.", + }, + + "workflow_name": { + Type: schema.TypeString, + Required: true, + Description: "Workflow name.", + }, + + "parent_folder_path": { + Type: schema.TypeString, + Required: true, + Description: "Parent folder path.", + }, + + "workflow_type": { + Type: schema.TypeString, + Optional: true, + Description: "Workflow type, value example: cycle cycle workflow;manual manual workflow, passed in cycle by default.", + }, + + "workflow_desc": { + Type: schema.TypeString, + Optional: true, + Description: "Workflow description.", + }, + + "owner_uin": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Workflow Owner ID.", + }, + + "workflow_params": { + Type: schema.TypeSet, + Optional: true, + Description: "workflow parameter.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "param_key": { + Type: schema.TypeString, + Required: true, + Description: "Parameter name.", + }, + "param_value": { + Type: schema.TypeString, + Required: true, + Description: "Parameter value.", + }, + }, + }, + }, + + "workflow_scheduler_configuration": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 1, + Description: "Unified dispatch information.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "schedule_time_zone": { + Type: schema.TypeString, + Required: true, + Description: "time zone.", + }, + "cycle_type": { + Type: schema.TypeString, + Required: true, + Description: "Cycle type: Supported types are\nONEOFF_CYCLE: One-time\nYEAR_CYCLE: Year\nMONTH_CYCLE: Month\nWEEK_CYCLE: Week\nDAY_CYCLE: Day\nHOUR_CYCLE: Hour\nMINUTE_CYCLE: Minute\nCRONTAB_CYCLE: crontab expression type.", + }, + "self_depend": { + Type: schema.TypeString, + Required: true, + Description: "Self-dependence, default value serial, values are: parallel, serial, orderly.", + }, + "start_time": { + Type: schema.TypeString, + Required: true, + Description: "Start time.", + }, + "end_time": { + Type: schema.TypeString, + Required: true, + Description: "End time.", + }, + "crontab_expression": { + Type: schema.TypeString, + Required: true, + Description: "Crontab expression.", + }, + "dependency_workflow": { + Type: schema.TypeString, + Optional: true, + Description: "Workflow dependence, yes or no.", + }, + "modify_cycle_value": { + Type: schema.TypeString, + Optional: true, + Description: "0: Do not modify 1: Change the upstream dependency configuration of the task to the default value.", + }, + "clear_link": { + Type: schema.TypeBool, + Optional: true, + Description: "Workflows have cross-workflow dependencies and are scheduled using cron expressions. If you save unified scheduling, unsupported dependencies will be broken.", + }, + "main_cyclic_config": { + Type: schema.TypeString, + Optional: true, + Description: "Effective when ModifyCycleValue is 1, indicating the default modified upstream dependence-time dimension. The value is: \n* CRONTAB\n* DAY\n* HOUR\n* LIST_DAY\n* LIST_HOUR\n * LIST_MINUTE\n * MONTH\n* RANGE_DAY\n * RANGE_HOUR\n * RANGE_MINUTE\n* WEEK\n* YEAR\n\nhttps://capi.woa.com/object/detail? product=wedata&env=api_dev&version=2025-08-06&name=WorkflowSchedulerConfigurationInfo.", + }, + "subordinate_cyclic_config": { + Type: schema.TypeString, + Optional: true, + Description: "Effective when ModifyCycleValue is 1, which means that the default modified upstream dependency-instance range\n value is: \n* ALL_DAY_OF_YEAR\n* ALL_MONTH_OF_YEAR\n* CURRENT\n* CURRENT_DAY\n* CURRENT_HOUR\n* CURRENT_MINUTE\n* CURRENT_MONTH\n* CURRENT_WEEK\n* CURRENT_YEAR\n* PREVIOUS_BEGIN_OF_MONTH\n* PREVIOUS_DAY\n* PREVIOUS_DAY_LATER_OFFSET_HOUR\n* PREVIOUS_DAY_LATER_OFFSET_MINUTE\n* PREVIOUS_END_OF_MONTH\n* PREVIOUS_FRIDAY\n* PREVIOUS_HOUR\n* PREVIOUS_HOUR_CYCLE\n* PREVIOUS_HOUR_LATER_OFFSET_MINUTE\n* PREVIOUS_MINUTE_CYCLE\n* PREVIOUS_MONTH\n* PREVIOUS_WEEK\n* PREVIOUS_WEEKEND\n* RECENT_DATE\n\nhttps://capi.woa.com/object/detail? product=wedata&env=api_dev&version=2025-08-06&name=WorkflowSchedulerConfigurationInfo.", + }, + "execution_start_time": { + Type: schema.TypeString, + Optional: true, + Description: "Execution time left-closed interval, example: 00:00, only if the cycle type is MINUTE_CYCLE needs to be filled in.", + }, + "execution_end_time": { + Type: schema.TypeString, + Optional: true, + Description: "Execution time right-closed interval, example: 23:59, only if the cycle type is MINUTE_CYCLE needs to be filled in.", + }, + "calendar_open": { + Type: schema.TypeString, + Optional: true, + Description: "Do you want to turn on calendar scheduling 1 on 0 off.", + }, + "calendar_id": { + Type: schema.TypeString, + Optional: true, + Description: "calendar id.", + }, + }, + }, + }, + + "bundle_id": { + Type: schema.TypeString, + Optional: true, + Description: "Bundle Id.", + }, + + "bundle_info": { + Type: schema.TypeString, + Optional: true, + Description: "Bundle Information.", + }, + + "workflow_id": { + Type: schema.TypeString, + Computed: true, + Description: "Workflow id.", + }, + }, + } +} + +func resourceTencentCloudWedataWorkflowCreate(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_workflow.create")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + var ( + projectId string + workflowId string + ) + var ( + request = wedatav20250806.NewCreateWorkflowRequest() + response = wedatav20250806.NewCreateWorkflowResponse() + ) + + if v, ok := d.GetOk("project_id"); ok { + projectId = v.(string) + request.ProjectId = helper.String(projectId) + } + + if v, ok := d.GetOk("workflow_name"); ok { + request.WorkflowName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("parent_folder_path"); ok { + request.ParentFolderPath = helper.String(v.(string)) + } + + if v, ok := d.GetOk("workflow_type"); ok { + request.WorkflowType = helper.String(v.(string)) + } + + if v, ok := d.GetOk("workflow_desc"); ok { + request.WorkflowDesc = helper.String(v.(string)) + } + + if v, ok := d.GetOk("owner_uin"); ok { + request.OwnerUin = helper.String(v.(string)) + } + + if v, ok := d.GetOk("workflow_params"); ok { + for _, item := range v.(*schema.Set).List() { + workflowParamsMap := item.(map[string]interface{}) + paramInfo := wedatav20250806.ParamInfo{} + if v, ok := workflowParamsMap["param_key"]; ok { + paramInfo.ParamKey = helper.String(v.(string)) + } + if v, ok := workflowParamsMap["param_value"]; ok { + paramInfo.ParamValue = helper.String(v.(string)) + } + request.WorkflowParams = append(request.WorkflowParams, ¶mInfo) + } + } + + if workflowSchedulerConfigurationMap, ok := helper.InterfacesHeadMap(d, "workflow_scheduler_configuration"); ok { + workflowSchedulerConfigurationInfo := wedatav20250806.WorkflowSchedulerConfigurationInfo{} + if v, ok := workflowSchedulerConfigurationMap["schedule_time_zone"]; ok { + workflowSchedulerConfigurationInfo.ScheduleTimeZone = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["cycle_type"]; ok { + workflowSchedulerConfigurationInfo.CycleType = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["self_depend"]; ok { + workflowSchedulerConfigurationInfo.SelfDepend = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["start_time"]; ok { + workflowSchedulerConfigurationInfo.StartTime = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["end_time"]; ok { + workflowSchedulerConfigurationInfo.EndTime = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["crontab_expression"]; ok { + workflowSchedulerConfigurationInfo.CrontabExpression = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["dependency_workflow"]; ok { + workflowSchedulerConfigurationInfo.DependencyWorkflow = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["modify_cycle_value"]; ok && v.(string) != "" { + workflowSchedulerConfigurationInfo.ModifyCycleValue = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["clear_link"]; ok { + workflowSchedulerConfigurationInfo.ClearLink = helper.Bool(v.(bool)) + } + if v, ok := workflowSchedulerConfigurationMap["main_cyclic_config"]; ok && v.(string) != "" { + workflowSchedulerConfigurationInfo.MainCyclicConfig = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["subordinate_cyclic_config"]; ok && v.(string) != "" { + workflowSchedulerConfigurationInfo.SubordinateCyclicConfig = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["execution_start_time"]; ok { + workflowSchedulerConfigurationInfo.ExecutionStartTime = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["execution_end_time"]; ok { + workflowSchedulerConfigurationInfo.ExecutionEndTime = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["calendar_open"]; ok && v.(string) != "" { + workflowSchedulerConfigurationInfo.CalendarOpen = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["calendar_id"]; ok { + workflowSchedulerConfigurationInfo.CalendarId = helper.String(v.(string)) + } + request.WorkflowSchedulerConfiguration = &workflowSchedulerConfigurationInfo + } + + if v, ok := d.GetOk("bundle_id"); ok { + request.BundleId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("bundle_info"); ok { + request.BundleInfo = helper.String(v.(string)) + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().CreateWorkflowWithContext(ctx, request) + if e != nil { + return tccommon.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 wedata workflow failed, reason:%+v", logId, err) + return err + } + + if response.Response.Data != nil && response.Response.Data.WorkflowId != nil { + workflowId = *response.Response.Data.WorkflowId + d.SetId(strings.Join([]string{projectId, workflowId}, tccommon.FILED_SP)) + } + + return resourceTencentCloudWedataWorkflowRead(d, meta) +} + +func resourceTencentCloudWedataWorkflowRead(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_workflow.read")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + service := WedataService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} + + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + projectId := idSplit[0] + workflowId := idSplit[1] + + var ( + respData *wedatav20250806.WorkflowDetail + innerErr error + ) + err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError { + respData, innerErr = service.DescribeWedataWorkflowById(ctx, projectId, workflowId) + if innerErr != nil { + return resource.RetryableError(innerErr) + } + return nil + }) + if err != nil { + return err + } + + if respData == nil { + d.SetId("") + log.Printf("[WARN]%s resource `wedata_workflow_folder` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + _ = d.Set("project_id", projectId) + + if respData.Path != nil && respData.WorkflowName != nil { + _ = d.Set("parent_folder_path", strings.TrimSuffix(*respData.Path, fmt.Sprintf("/%s", *respData.WorkflowName))) + } + if respData.WorkflowName != nil { + _ = d.Set("workflow_name", respData.WorkflowName) + } + + if respData.OwnerUin != nil { + _ = d.Set("owner_uin", respData.OwnerUin) + } + + if respData.WorkflowType != nil { + _ = d.Set("workflow_type", respData.WorkflowType) + } + + workflowParamsList := make([]map[string]interface{}, 0, len(respData.WorkflowParams)) + if respData.WorkflowParams != nil { + for _, workflowParams := range respData.WorkflowParams { + workflowParamsMap := map[string]interface{}{} + + if workflowParams.ParamKey != nil { + workflowParamsMap["param_key"] = workflowParams.ParamKey + } + + if workflowParams.ParamValue != nil { + workflowParamsMap["param_value"] = workflowParams.ParamValue + } + + workflowParamsList = append(workflowParamsList, workflowParamsMap) + } + + _ = d.Set("workflow_params", workflowParamsList) + } + + workflowSchedulerConfigurationMap := map[string]interface{}{} + + if respData.WorkflowSchedulerConfiguration != nil { + if respData.WorkflowSchedulerConfiguration.ScheduleTimeZone != nil { + workflowSchedulerConfigurationMap["schedule_time_zone"] = respData.WorkflowSchedulerConfiguration.ScheduleTimeZone + } + + if respData.WorkflowSchedulerConfiguration.CycleType != nil { + workflowSchedulerConfigurationMap["cycle_type"] = respData.WorkflowSchedulerConfiguration.CycleType + } + + if respData.WorkflowSchedulerConfiguration.SelfDepend != nil { + workflowSchedulerConfigurationMap["self_depend"] = respData.WorkflowSchedulerConfiguration.SelfDepend + } + + if respData.WorkflowSchedulerConfiguration.StartTime != nil { + workflowSchedulerConfigurationMap["start_time"] = respData.WorkflowSchedulerConfiguration.StartTime + } + + if respData.WorkflowSchedulerConfiguration.EndTime != nil { + workflowSchedulerConfigurationMap["end_time"] = respData.WorkflowSchedulerConfiguration.EndTime + } + + if respData.WorkflowSchedulerConfiguration.DependencyWorkflow != nil { + workflowSchedulerConfigurationMap["dependency_workflow"] = respData.WorkflowSchedulerConfiguration.DependencyWorkflow + } + + if respData.WorkflowSchedulerConfiguration.ExecutionStartTime != nil { + workflowSchedulerConfigurationMap["execution_start_time"] = respData.WorkflowSchedulerConfiguration.ExecutionStartTime + } + + if respData.WorkflowSchedulerConfiguration.ExecutionEndTime != nil { + workflowSchedulerConfigurationMap["execution_end_time"] = respData.WorkflowSchedulerConfiguration.ExecutionEndTime + } + + if respData.WorkflowSchedulerConfiguration.CrontabExpression != nil { + workflowSchedulerConfigurationMap["crontab_expression"] = respData.WorkflowSchedulerConfiguration.CrontabExpression + } + + if respData.WorkflowSchedulerConfiguration.CalendarOpen != nil { + workflowSchedulerConfigurationMap["calendar_open"] = respData.WorkflowSchedulerConfiguration.CalendarOpen + } + + if respData.WorkflowSchedulerConfiguration.CalendarName != nil { + workflowSchedulerConfigurationMap["calendar_name"] = respData.WorkflowSchedulerConfiguration.CalendarName + } + + if respData.WorkflowSchedulerConfiguration.CalendarId != nil { + workflowSchedulerConfigurationMap["calendar_id"] = respData.WorkflowSchedulerConfiguration.CalendarId + } + + _ = d.Set("workflow_scheduler_configuration", []interface{}{workflowSchedulerConfigurationMap}) + } + + if respData.WorkflowDesc != nil { + _ = d.Set("workflow_desc", respData.WorkflowDesc) + } + + if respData.BundleId != nil { + _ = d.Set("bundle_id", respData.BundleId) + } + + if respData.BundleInfo != nil { + _ = d.Set("bundle_info", respData.BundleInfo) + } + + _ = d.Set("workflow_id", workflowId) + _ = projectId + return nil +} + +func resourceTencentCloudWedataWorkflowUpdate(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_workflow.update")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + immutableArgs := []string{"parent_folder_path", "workflow_type"} + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + projectId := idSplit[0] + workflowId := idSplit[1] + + needChange := false + mutableArgs := []string{"project_id", "workflow_id", "workflow_name", "owner_uin", "workflow_desc", "workflow_params", "workflow_scheduler_configuration", "bundle_id", "bundle_info"} + for _, v := range mutableArgs { + if d.HasChange(v) { + needChange = true + break + } + } + + if needChange { + request := wedatav20250806.NewUpdateWorkflowRequest() + request.ProjectId = helper.String(projectId) + request.WorkflowId = helper.String(workflowId) + + if v, ok := d.GetOk("workflow_name"); ok { + request.WorkflowName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("owner_uin"); ok { + request.OwnerUin = helper.String(v.(string)) + } + + if v, ok := d.GetOk("workflow_desc"); ok { + request.WorkflowDesc = helper.String(v.(string)) + } + + if v, ok := d.GetOk("workflow_params"); ok { + for _, item := range v.(*schema.Set).List() { + workflowParamsMap := item.(map[string]interface{}) + paramInfo := wedatav20250806.ParamInfo{} + if v, ok := workflowParamsMap["param_key"]; ok { + paramInfo.ParamKey = helper.String(v.(string)) + } + if v, ok := workflowParamsMap["param_value"]; ok { + paramInfo.ParamValue = helper.String(v.(string)) + } + request.WorkflowParams = append(request.WorkflowParams, ¶mInfo) + } + } + + if workflowSchedulerConfigurationMap, ok := helper.InterfacesHeadMap(d, "workflow_scheduler_configuration"); ok { + workflowSchedulerConfigurationInfo := wedatav20250806.WorkflowSchedulerConfigurationInfo{} + if v, ok := workflowSchedulerConfigurationMap["schedule_time_zone"]; ok { + workflowSchedulerConfigurationInfo.ScheduleTimeZone = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["cycle_type"]; ok { + workflowSchedulerConfigurationInfo.CycleType = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["self_depend"]; ok { + workflowSchedulerConfigurationInfo.SelfDepend = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["start_time"]; ok { + workflowSchedulerConfigurationInfo.StartTime = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["end_time"]; ok { + workflowSchedulerConfigurationInfo.EndTime = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["crontab_expression"]; ok { + workflowSchedulerConfigurationInfo.CrontabExpression = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["dependency_workflow"]; ok { + workflowSchedulerConfigurationInfo.DependencyWorkflow = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["modify_cycle_value"]; ok && v.(string) != "" { + workflowSchedulerConfigurationInfo.ModifyCycleValue = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["clear_link"]; ok { + workflowSchedulerConfigurationInfo.ClearLink = helper.Bool(v.(bool)) + } + if v, ok := workflowSchedulerConfigurationMap["main_cyclic_config"]; ok && v.(string) != "" { + workflowSchedulerConfigurationInfo.MainCyclicConfig = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["subordinate_cyclic_config"]; ok && v.(string) != "" { + workflowSchedulerConfigurationInfo.SubordinateCyclicConfig = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["execution_start_time"]; ok { + workflowSchedulerConfigurationInfo.ExecutionStartTime = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["execution_end_time"]; ok { + workflowSchedulerConfigurationInfo.ExecutionEndTime = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["calendar_open"]; ok && v.(string) != "" { + workflowSchedulerConfigurationInfo.CalendarOpen = helper.String(v.(string)) + } + if v, ok := workflowSchedulerConfigurationMap["calendar_id"]; ok { + workflowSchedulerConfigurationInfo.CalendarId = helper.String(v.(string)) + } + request.WorkflowSchedulerConfiguration = &workflowSchedulerConfigurationInfo + } + + if v, ok := d.GetOk("bundle_id"); ok { + request.BundleId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("bundle_info"); ok { + request.BundleInfo = helper.String(v.(string)) + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().UpdateWorkflowWithContext(ctx, request) + if e != nil { + return tccommon.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 wedata workflow failed, reason:%+v", logId, err) + return err + } + } + + _ = projectId + _ = workflowId + return resourceTencentCloudWedataWorkflowRead(d, meta) +} + +func resourceTencentCloudWedataWorkflowDelete(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_workflow.delete")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + projectId := idSplit[0] + workflowId := idSplit[1] + + var ( + request = wedatav20250806.NewDeleteWorkflowRequest() + response = wedatav20250806.NewDeleteWorkflowResponse() + ) + + request.ProjectId = helper.String(projectId) + request.WorkflowId = helper.String(workflowId) + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().DeleteWorkflowWithContext(ctx, request) + if e != nil { + return tccommon.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 delete wedata workflow failed, reason:%+v", logId, err) + return err + } + + _ = response + _ = projectId + return nil +} diff --git a/tencentcloud/services/wedata/resource_tc_wedata_workflow.md b/tencentcloud/services/wedata/resource_tc_wedata_workflow.md new file mode 100644 index 0000000000..f5d7a8775c --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_workflow.md @@ -0,0 +1,20 @@ +Provides a resource to create a wedata wedata_workflow + +Example Usage + +```hcl +resource "tencentcloud_wedata_workflow" "wedata_workflow" { + project_id = 2905622749543821312 + workflow_name = "test" + parent_folder_path = "/tfmika" + workflow_type = "cycle" +} +``` + +Import + +wedata wedata_workflow can be imported using the id, e.g. + +``` +terraform import tencentcloud_wedata_workflow.wedata_workflow wedata_workflow_id +``` diff --git a/tencentcloud/services/wedata/resource_tc_wedata_workflow_folder.go b/tencentcloud/services/wedata/resource_tc_wedata_workflow_folder.go new file mode 100644 index 0000000000..12163023b6 --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_workflow_folder.go @@ -0,0 +1,244 @@ +package wedata + +import ( + "context" + "fmt" + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + wedatav20250806 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata/v20250806" + + tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" +) + +func ResourceTencentCloudWedataWorkflowFolder() *schema.Resource { + return &schema.Resource{ + Create: resourceTencentCloudWedataWorkflowFolderCreate, + Read: resourceTencentCloudWedataWorkflowFolderRead, + Update: resourceTencentCloudWedataWorkflowFolderUpdate, + Delete: resourceTencentCloudWedataWorkflowFolderDelete, + Schema: map[string]*schema.Schema{ + "project_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "Project id.", + }, + + "parent_folder_path": { + Type: schema.TypeString, + Required: true, + Description: "The absolute path of the parent folder, such as/abc/de, if it is the root directory, pass/.", + }, + + "folder_name": { + Type: schema.TypeString, + Required: true, + Description: "Name of the folder to create.", + }, + }, + } +} + +func resourceTencentCloudWedataWorkflowFolderCreate(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_workflow_folder.create")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + var ( + projectId string + folderId string + ) + var ( + request = wedatav20250806.NewCreateWorkflowFolderRequest() + response = wedatav20250806.NewCreateWorkflowFolderResponse() + ) + + if v, ok := d.GetOk("project_id"); ok { + projectId = v.(string) + request.ProjectId = helper.String(projectId) + } + + if v, ok := d.GetOk("parent_folder_path"); ok { + request.ParentFolderPath = helper.String(v.(string)) + } + + if v, ok := d.GetOk("folder_name"); ok { + request.FolderName = helper.String(v.(string)) + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().CreateWorkflowFolderWithContext(ctx, request) + if e != nil { + return tccommon.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 wedata workflow folder failed, reason:%+v", logId, err) + return err + } + + if response.Response.Data != nil && response.Response.Data.FolderId != nil { + folderId = *response.Response.Data.FolderId + d.SetId(projectId + tccommon.FILED_SP + folderId) + } + + return resourceTencentCloudWedataWorkflowFolderRead(d, meta) +} + +func resourceTencentCloudWedataWorkflowFolderRead(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_workflow_folder.read")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + service := WedataService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} + + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + + projectId := idSplit[0] + folderId := idSplit[1] + + var ( + respData []*wedatav20250806.WorkflowFolder + innerErr error + ) + + parentFolderPath := d.Get("parent_folder_path").(string) + err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError { + respData, innerErr = service.DescribeWedataWorkflowFolders(ctx, projectId, folderId, parentFolderPath) + if innerErr != nil { + return resource.RetryableError(innerErr) + } + return nil + }) + if err != nil { + return err + } + + if respData == nil { + d.SetId("") + log.Printf("[WARN]%s resource `wedata_workflow_folder` [%s] not found, please check if it has been deleted.\n", logId, d.Id()) + return nil + } + + _ = folderId + return nil +} + +func resourceTencentCloudWedataWorkflowFolderUpdate(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_workflow_folder.update")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + immutableArgs := []string{"project_id", "parent_folder_path"} + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } + } + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + + projectId := idSplit[0] + folderId := idSplit[1] + + needChange := false + mutableArgs := []string{"folder_name"} + for _, v := range mutableArgs { + if d.HasChange(v) { + needChange = true + break + } + } + + if needChange { + request := wedatav20250806.NewUpdateWorkflowFolderRequest() + request.ProjectId = helper.String(projectId) + request.FolderId = helper.String(folderId) + + if v, ok := d.GetOk("folder_name"); ok { + request.FolderName = helper.String(v.(string)) + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().UpdateWorkflowFolderWithContext(ctx, request) + if e != nil { + return tccommon.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 wedata workflow folder failed, reason:%+v", logId, err) + return err + } + } + + _ = folderId + return resourceTencentCloudWedataWorkflowFolderRead(d, meta) +} + +func resourceTencentCloudWedataWorkflowFolderDelete(d *schema.ResourceData, meta interface{}) error { + defer tccommon.LogElapsed("resource.tencentcloud_wedata_workflow_folder.delete")() + defer tccommon.InconsistentCheck(d, meta)() + + logId := tccommon.GetLogId(tccommon.ContextNil) + ctx := tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta) + + idSplit := strings.Split(d.Id(), tccommon.FILED_SP) + if len(idSplit) != 2 { + return fmt.Errorf("id is broken,%s", d.Id()) + } + + projectId := idSplit[0] + folderId := idSplit[1] + + var ( + request = wedatav20250806.NewDeleteWorkflowFolderRequest() + response = wedatav20250806.NewDeleteWorkflowFolderResponse() + ) + + request.ProjectId = helper.String(projectId) + request.FolderId = helper.String(folderId) + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWedataV20250806Client().DeleteWorkflowFolderWithContext(ctx, request) + if e != nil { + return tccommon.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 delete wedata workflow folder failed, reason:%+v", logId, err) + return err + } + + _ = response + _ = folderId + return nil +} diff --git a/tencentcloud/services/wedata/resource_tc_wedata_workflow_folder.md b/tencentcloud/services/wedata/resource_tc_wedata_workflow_folder.md new file mode 100644 index 0000000000..c8a648fa33 --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_workflow_folder.md @@ -0,0 +1,11 @@ +Provides a resource to create a wedata wedata_workflow_folder + +Example Usage + +```hcl +resource "tencentcloud_wedata_workflow_folder" "wedata_workflow_folder" { + project_id = 2905622749543821312 + parent_folder_path = "/" + folder_name = "test" +} +``` diff --git a/tencentcloud/services/wedata/resource_tc_wedata_workflow_folder_test.go b/tencentcloud/services/wedata/resource_tc_wedata_workflow_folder_test.go new file mode 100644 index 0000000000..44864ee1ce --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_workflow_folder_test.go @@ -0,0 +1,47 @@ +package wedata_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest" +) + +func TestAccTencentCloudWedataWorkflowFolderResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + tcacctest.AccPreCheck(t) + }, + Providers: tcacctest.AccProviders, + Steps: []resource.TestStep{ + { + Config: testAccWedataWorkflowFolder, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_wedata_workflow_folder.wedata_workflow_folder", "id")), + }, + { + Config: testAccWedataWorkflowFolderUpdate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("tencentcloud_wedata_workflow_folder.wedata_workflow_folder", "folder_name", "tftest1"), + ), + }, + }, + }) +} + +const testAccWedataWorkflowFolder = ` +resource "tencentcloud_wedata_workflow_folder" "wedata_workflow_folder" { + project_id = "2905622749543821312" + parent_folder_path = "/" + folder_name = "tftest" +} +` + +const testAccWedataWorkflowFolderUpdate = ` +resource "tencentcloud_wedata_workflow_folder" "wedata_workflow_folder" { + project_id = "2905622749543821312" + parent_folder_path = "/" + folder_name = "tftest1" +} +` diff --git a/tencentcloud/services/wedata/resource_tc_wedata_workflow_test.go b/tencentcloud/services/wedata/resource_tc_wedata_workflow_test.go new file mode 100644 index 0000000000..35a071b605 --- /dev/null +++ b/tencentcloud/services/wedata/resource_tc_wedata_workflow_test.go @@ -0,0 +1,66 @@ +package wedata_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest" +) + +func TestAccTencentCloudWedataWorkflowResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + tcacctest.AccPreCheck(t) + }, + Providers: tcacctest.AccProviders, + Steps: []resource.TestStep{ + { + Config: testAccWedataWorkflow, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_wedata_workflow.wedata_workflow", "id")), + }, + { + Config: testAccWedataWorkflowUpdate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("tencentcloud_wedata_workflow.wedata_workflow", "workflow_name", "test1"), + ), + }, + { + ResourceName: "tencentcloud_wedata_workflow.wedata_workflow", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"workflow_scheduler_configuration.0.start_time"}, + }}, + }) +} + +const testAccWedataWorkflow = ` +resource "tencentcloud_wedata_workflow_folder" "wedata_workflow_folder" { + project_id = "2905622749543821312" + parent_folder_path = "/" + folder_name = "tftest" +} + +resource "tencentcloud_wedata_workflow" "wedata_workflow" { + project_id = 2905622749543821312 + workflow_name = "test" + parent_folder_path = "${tencentcloud_wedata_workflow_folder.wedata_workflow_folder.parent_folder_path}${tencentcloud_wedata_workflow_folder.wedata_workflow_folder.folder_name}" + workflow_type = "cycle" +} +` + +const testAccWedataWorkflowUpdate = ` +resource "tencentcloud_wedata_workflow_folder" "wedata_workflow_folder" { + project_id = "2905622749543821312" + parent_folder_path = "/" + folder_name = "tftest" +} + +resource "tencentcloud_wedata_workflow" "wedata_workflow" { + project_id = 2905622749543821312 + workflow_name = "test1" + parent_folder_path = "${tencentcloud_wedata_workflow_folder.wedata_workflow_folder.parent_folder_path}${tencentcloud_wedata_workflow_folder.wedata_workflow_folder.folder_name}" + workflow_type = "cycle" +} +` diff --git a/tencentcloud/services/wedata/service_tencentcloud_wedata.go b/tencentcloud/services/wedata/service_tencentcloud_wedata.go index a4d132eb6e..2d881d5f3b 100644 --- a/tencentcloud/services/wedata/service_tencentcloud_wedata.go +++ b/tencentcloud/services/wedata/service_tencentcloud_wedata.go @@ -5,12 +5,11 @@ import ( "log" "strconv" - tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" - "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" wedata "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata/v20210820" wedatav20250806 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata/v20250806" + tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/connectivity" "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/ratelimit" @@ -1863,3 +1862,186 @@ func (me *WedataService) DescribeWedataTaskVersionByFilter(ctx context.Context, func NewWedataService(client *connectivity.TencentCloudClient) WedataService { return WedataService{client: client} } + +func (me *WedataService) DescribeWedataWorkflowFolders(ctx context.Context, projectId, folderId, parentFolderPath string) (folders []*wedatav20250806.WorkflowFolder, errRet error) { + logId := tccommon.GetLogId(ctx) + + request := wedatav20250806.NewListWorkflowFoldersRequest() + + 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()) + } + }() + + request.ProjectId = helper.String(projectId) + request.ParentFolderPath = helper.String(parentFolderPath) + ratelimit.Check(request.GetAction()) + + var ( + pageNum uint64 = 1 + pageSize uint64 = 200 + ) + for { + request.PageNumber = &pageNum + request.PageSize = &pageSize + response, err := me.client.UseWedataV20250806Client().ListWorkflowFolders(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 || response.Response == nil || response.Response.Data == nil || len(response.Response.Data.Items) < 1 { + break + } + + folders = append(folders, response.Response.Data.Items...) + for _, item := range response.Response.Data.Items { + if folderId != "" && item.FolderId != nil && *item.FolderId == folderId { + folders = append(folders, item) + } + } + if len(response.Response.Data.Items) < int(pageSize) { + break + } + + pageNum += pageSize + } + + return +} + +func (me *WedataService) DescribeWedataWorkflowById(ctx context.Context, projectId, workflowId string) (ret *wedatav20250806.WorkflowDetail, errRet error) { + logId := tccommon.GetLogId(ctx) + + request := wedatav20250806.NewGetWorkflowRequest() + request.ProjectId = helper.String(projectId) + request.WorkflowId = helper.String(workflowId) + 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.UseWedataV20250806Client().GetWorkflow(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.Response == nil { + return + } + + ret = response.Response.Data + return +} + +func (me *WedataService) DescribeWedataResourceFileById(ctx context.Context, projectId, resourceId string) (ret *wedatav20250806.ResourceFile, errRet error) { + logId := tccommon.GetLogId(ctx) + + request := wedatav20250806.NewGetResourceFileRequest() + request.ProjectId = helper.String(projectId) + request.ResourceId = helper.String(resourceId) + + 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.UseWedataV20250806Client().GetResourceFile(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.Response == nil { + return + } + + ret = response.Response.Data + return +} + +func (me *WedataService) DescribeWedataResourceFolderById(ctx context.Context, projectId, folderId, parentFolderPath string) (folders []*wedatav20250806.ResourceFolder, errRet error) { + logId := tccommon.GetLogId(ctx) + + request := wedatav20250806.NewListResourceFoldersRequest() + request.ProjectId = helper.String(projectId) + request.ParentFolderPath = helper.String(parentFolderPath) + + 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()) + } + }() + + var ( + pageNum uint64 = 1 + pageSize uint64 = 200 + ) + for { + request.PageNumber = &pageNum + request.PageSize = &pageSize + response, err := me.client.UseWedataV20250806Client().ListResourceFolders(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 || response.Response == nil || response.Response.Data == nil || len(response.Response.Data.Items) < 1 { + break + } + + folders = append(folders, response.Response.Data.Items...) + for _, item := range response.Response.Data.Items { + if folderId != "" && item.FolderId != nil && *item.FolderId == folderId { + folders = append(folders, item) + } + } + if len(response.Response.Data.Items) < int(pageSize) { + break + } + + pageNum += pageSize + } + return +} + +func (me *WedataService) DescribeWedataTaskById(ctx context.Context, projectId, taskId string) (ret *wedatav20250806.GetTaskResponseParams, errRet error) { + logId := tccommon.GetLogId(ctx) + + request := wedatav20250806.NewGetTaskRequest() + + 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()) + } + }() + + request.ProjectId = helper.String(projectId) + request.TaskId = helper.String(taskId) + + ratelimit.Check(request.GetAction()) + + response, err := me.client.UseWedataV20250806Client().GetTask(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()) + + ret = response.Response + return +} diff --git a/website/docs/r/wedata_resource_file.html.markdown b/website/docs/r/wedata_resource_file.html.markdown new file mode 100644 index 0000000000..02f7c52e74 --- /dev/null +++ b/website/docs/r/wedata_resource_file.html.markdown @@ -0,0 +1,55 @@ +--- +subcategory: "Wedata" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_wedata_resource_file" +sidebar_current: "docs-tencentcloud-resource-wedata_resource_file" +description: |- + Provides a resource to create a wedata wedata_resource_file +--- + +# tencentcloud_wedata_resource_file + +Provides a resource to create a wedata wedata_resource_file + +## Example Usage + +```hcl +resource "tencentcloud_wedata_resource_folder" "wedata_resource_folder" { + project_id = 2905622749543821312 + parent_folder_path = "/" + folder_name = "folder" +} + +resource "tencentcloud_wedata_resource_file" "wedata_resource_file" { + project_id = 2905622749543821312 + resource_name = "tftest.txt" + bucket_name = "data-manage-fsi-1315051789" + cos_region = "ap-beijing-fsi" + parent_folder_path = "${tencentcloud_wedata_resource_folder.wedata_resource_folder.parent_folder_path}${tencentcloud_wedata_resource_folder.wedata_resource_folder.folder_name}" + resource_file = "/datastudio/resource/2905622749543821312/${tencentcloud_wedata_resource_folder.wedata_resource_folder.parent_folder_path}${tencentcloud_wedata_resource_folder.wedata_resource_folder.folder_name}/test" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `bucket_name` - (Required, String) cos bucket name, which can be obtained from the GetResourceCosPath interface. +* `cos_region` - (Required, String) The cos bucket area corresponding to the BucketName bucket. +* `parent_folder_path` - (Required, String) The path to upload resource files in the project, example value: /wedata/qxxxm/, root directory, please use/. +* `project_id` - (Required, String, ForceNew) Project id. +* `resource_file` - (Required, String) - You can only choose one of the two methods of uploading a file and manually filling. If both are provided, the order of values is file> manual filling value +-the manual filling value must be the existing cos path, /datastudio/resource/is a fixed prefix, projectId is the project ID, and a specific value needs to be passed in, parentFolderPath is the parent folder path, name is the file name, and examples of manual filling value values are: /datastudio/resource/projectId/parentFolderPath/name +. +* `resource_name` - (Required, String) The resource file name should be consistent with the uploaded file name as much as possible. +* `bundle_id` - (Optional, String) bundle client ID. +* `bundle_info` - (Optional, String) bundle client information. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - ID of the resource. + + + diff --git a/website/docs/r/wedata_resource_folder.html.markdown b/website/docs/r/wedata_resource_folder.html.markdown new file mode 100644 index 0000000000..a955eacf05 --- /dev/null +++ b/website/docs/r/wedata_resource_folder.html.markdown @@ -0,0 +1,39 @@ +--- +subcategory: "Wedata" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_wedata_resource_folder" +sidebar_current: "docs-tencentcloud-resource-wedata_resource_folder" +description: |- + Provides a resource to create a wedata wedata_resource_folder +--- + +# tencentcloud_wedata_resource_folder + +Provides a resource to create a wedata wedata_resource_folder + +## Example Usage + +```hcl +resource "tencentcloud_wedata_resource_folder" "wedata_resource_folder" { + project_id = 2905622749543821312 + parent_folder_path = "/" + folder_name = "folder" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `folder_name` - (Required, String) Folder name. +* `parent_folder_path` - (Required, String) Absolute path of parent folder, value example/wedata/test, root directory, please use/. +* `project_id` - (Required, String, ForceNew) Project id. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - ID of the resource. + + + diff --git a/website/docs/r/wedata_task.html.markdown b/website/docs/r/wedata_task.html.markdown new file mode 100644 index 0000000000..856510895e --- /dev/null +++ b/website/docs/r/wedata_task.html.markdown @@ -0,0 +1,296 @@ +--- +subcategory: "Wedata" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_wedata_task" +sidebar_current: "docs-tencentcloud-resource-wedata_task" +description: |- + Provides a resource to create a wedata wedata_task +--- + +# tencentcloud_wedata_task + +Provides a resource to create a wedata wedata_task + +## Example Usage + +```hcl +resource "tencentcloud_wedata_workflow_folder" "wedata_workflow_folder" { + project_id = "2905622749543821312" + parent_folder_path = "/" + folder_name = "tftest" +} + +resource "tencentcloud_wedata_workflow" "wedata_workflow" { + project_id = 2905622749543821312 + workflow_name = "test_workflow1" + parent_folder_path = "${tencentcloud_wedata_workflow_folder.wedata_workflow_folder.parent_folder_path}${tencentcloud_wedata_workflow_folder.wedata_workflow_folder.folder_name}" + workflow_type = "cycle" +} + +resource "tencentcloud_wedata_task" "wedata_task" { + project_id = 2905622749543821312 + task_base_attribute { + task_name = "tfTask" + task_type_id = 30 + workflow_id = tencentcloud_wedata_workflow.wedata_workflow.workflow_id + } + task_configuration { + code_content = base64encode("Hello World") + task_ext_configuration_list { + param_key = "bucket" + param_value = "wedata-fusion-bjjr-1257305158" + } + task_ext_configuration_list { + param_key = "ftp.file.name" + param_value = "/datastudio/project/2905622749543821312/tftest/test_workflow1/tfTask.py" + } + task_ext_configuration_list { + param_key = "tenantId" + param_value = "1257305158" + } + task_ext_configuration_list { + param_key = "region" + param_value = "ap-beijing-fsi" + } + task_ext_configuration_list { + param_key = "extraInfo" + param_value = "{\"fromMapping\":false}" + } + task_ext_configuration_list { + param_key = "ssmDynamicSkSwitch" + param_value = "ON" + } + task_ext_configuration_list { + param_key = "calendar_open" + param_value = "0" + } + task_ext_configuration_list { + param_key = "specLabelConfItems" + param_value = "eyJzcGVjTGFiZWxDb25mSXRlbXMiOltdfQ==" + } + task_ext_configuration_list { + param_key = "waitExecutionTotalTTL" + param_value = "-1" + } + } + task_scheduler_configuration { + cycle_type = "DAY_CYCLE" + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `project_id` - (Required, String, ForceNew) Project ID. +* `task_base_attribute` - (Required, List) Basic task attributes. +* `task_configuration` - (Required, List) Task configuration. +* `task_scheduler_configuration` - (Required, List) Task scheduling configuration. + +The `dependency_strategy` object of `upstream_dependency_config_list` supports the following: + +* `polling_null_strategy` - (Optional, String) Strategy for waiting for upstream task instances: EXECUTING; WAITING. +* `task_dependency_executing_strategies` - (Optional, Set) This field is required only when PollingNullStrategy is EXECUTING, List type: NOT_EXIST (default, when minute depends on minute/hour depends on hour, parent instance is not within the downstream instance scheduling time range); PARENT_EXPIRED (parent instance failed); PARENT_TIMEOUT (parent instance timed out). If any of the above scenarios is met, the parent task instance dependency judgment can be passed; otherwise, it is necessary to wait for the parent instance. +* `task_dependency_executing_timeout_value` - (Optional, Int) This field is required only when TaskDependencyExecutingStrategies contains PARENT_TIMEOUT, the timeout time for downstream tasks depending on parent instance execution, unit: minutes. + +The `event_listener_list` object of `task_scheduler_configuration` supports the following: + +* `event_broadcast_type` - (Required, String) Event broadcast type: SINGLE, BROADCAST. +* `event_name` - (Required, String) Event name. +* `event_sub_type` - (Required, String) Event cycle: SECOND, MIN, HOUR, DAY. +* `properties_list` - (Optional, List) Extended information. + +The `param_task_in_list` object of `task_scheduler_configuration` supports the following: + +* `from_param_key` - (Required, String) Parent task parameter key. +* `from_task_id` - (Required, String) Parent task ID. +* `param_desc` - (Required, String) Parameter description: format is project_identifier.task_name.parameter_name; example: project_wedata_1.sh_250820_104107.pp_out. +* `param_key` - (Required, String) Parameter name. + +The `param_task_out_list` object of `task_scheduler_configuration` supports the following: + +* `param_key` - (Required, String) Parameter name. +* `param_value` - (Required, String) Parameter definition. + +The `properties_list` object of `event_listener_list` supports the following: + +* `param_key` - (Required, String) Parameter name. +* `param_value` - (Required, String) Parameter value. + +The `task_base_attribute` object supports the following: + +* `task_name` - (Required, String) Task name. +* `task_type_id` - (Required, String) Task type ID: + +* 21:JDBC SQL +* 23:TDSQL-PostgreSQL +* 26:OfflineSynchronization +* 30:Python +* 31:PySpark +* 32:DLC SQL +* 33:Impala +* 34:Hive SQL +* 35:Shell +* 36:Spark SQL +* 38:Shell Form Mode +* 39:Spark +* 40:TCHouse-P +* 41:Kettle +* 42:Tchouse-X +* 43:TCHouse-X SQL +* 46:DLC Spark +* 47:TiOne +* 48:Trino +* 50:DLC PySpark +* 92:MapReduce +* 130:Branch Node +* 131:Merged Node +* 132:Notebook +* 133:SSH +* 134:StarRocks +* 137:For-each +* 138:Setats SQL. +* `workflow_id` - (Required, String) Workflow ID. +* `owner_uin` - (Optional, String) Task owner ID, defaults to current user. +* `task_description` - (Optional, String) Task description. + +The `task_configuration` object supports the following: + +* `broker_ip` - (Optional, String) Specified running node. +* `bundle_id` - (Optional, String) ID used by Bundle. +* `bundle_info` - (Optional, String) Bundle information. +* `code_content` - (Optional, String) Base64 encoded code content. +* `data_cluster` - (Optional, String) Cluster ID. +* `resource_group` - (Optional, String) Resource group ID: Need to obtain ExecutorGroupId via DescribeNormalSchedulerExecutorGroups. +* `source_service_id` - (Optional, String) Source data source ID, separated by `;`, need to obtain via DescribeDataSourceWithoutInfo. +* `target_service_id` - (Optional, String) Target data source ID, separated by `;`, need to obtain via DescribeDataSourceWithoutInfo. +* `task_ext_configuration_list` - (Optional, Set) Task extended attribute configuration list. +* `task_scheduling_parameter_list` - (Optional, Set) Scheduling parameters. +* `yarn_queue` - (Optional, String) Resource pool queue name, need to obtain via DescribeProjectClusterQueues. + +The `task_ext_configuration_list` object of `task_configuration` supports the following: + +* `param_key` - (Required, String) Parameter name. +* `param_value` - (Required, String) Parameter value. + +The `task_output_registry_list` object of `task_scheduler_configuration` supports the following: + +* `data_flow_type` - (Required, String) Input/output table type + Input stream + UPSTREAM, + Output stream + DOWNSTREAM. +* `database_name` - (Required, String) Database name. +* `datasource_id` - (Required, String) Data source ID. +* `partition_name` - (Required, String) Partition name. +* `table_name` - (Required, String) Table name. +* `table_physical_id` - (Required, String) Table physical unique ID. +* `db_guid` - (Optional, String) Database unique identifier. +* `table_guid` - (Optional, String) Table unique identifier. + +The `task_scheduler_configuration` object supports the following: + +* `allow_redo_type` - (Optional, String) Rerun & backfill configuration, defaults to ALL; ALL: can rerun or backfill after success or failure; FAILURE: cannot rerun or backfill after success, can rerun or backfill after failure; NONE: cannot rerun or backfill after success or failure. +* `calendar_id` - (Optional, String) Calendar scheduling calendar ID. +* `calendar_open` - (Optional, String) Calendar scheduling: Values are 0 and 1, 1 for enabled, 0 for disabled, defaults to 0. +* `crontab_expression` - (Optional, String) Cron expression, defaults to 0 0 0 * * `?` *. +* `cycle_type` - (Optional, String) Cycle type: Defaults to DAY_CYCLE. + +Supported types are + +* ONEOFF_CYCLE: One-time +* YEAR_CYCLE: Yearly +* MONTH_CYCLE: Monthly +* WEEK_CYCLE: Weekly +* DAY_CYCLE: Daily +* HOUR_CYCLE: Hourly +* MINUTE_CYCLE: Minutely +* CRONTAB_CYCLE: Crontab expression type. +* `end_time` - (Optional, String) End date, defaults to 2099-12-31 23:59:59. +* `event_listener_list` - (Optional, List) Event array. +* `execution_end_time` - (Optional, String) Execution time right-closed interval, default 23:59. +* `execution_start_time` - (Optional, String) Execution time left-closed interval, default 00:00. +* `execution_ttl` - (Optional, String) Timeout handling strategy - running time timeout (unit: minutes) defaults to -1. +* `init_strategy` - (Optional, String) **Instance generation strategy** +* T_PLUS_0: T+0 generation, default strategy +* T_PLUS_1: T+1 generation. +* `max_retry_attempts` - (Optional, String) Retry strategy - maximum number of attempts, default: 4. +* `param_task_in_list` - (Optional, List) Input parameter array. +* `param_task_out_list` - (Optional, List) Output parameter array. +* `retry_wait` - (Optional, String) Retry strategy - retry waiting time, unit: minutes: default: 5. +* `run_priority` - (Optional, String) Task scheduling priority: 4 for high, 5 for medium, 6 for low, default: 6. +* `schedule_run_type` - (Optional, String) Scheduling type: 0 Normal scheduling 1 Empty run scheduling, defaults to 0. +* `schedule_time_zone` - (Optional, String) Time zone, defaults to UTC+8. +* `self_depend` - (Optional, String) Self-dependency, default value serial, values: parallel, serial, orderly. +* `start_time` - (Optional, String) Effective date, defaults to 00:00:00 of current date. +* `task_output_registry_list` - (Optional, List) Output registration. +* `upstream_dependency_config_list` - (Optional, List) Upstream dependency array. +* `wait_execution_total_ttl` - (Optional, String) Timeout handling strategy - total waiting time timeout (unit: minutes) defaults to -1. + +The `task_scheduling_parameter_list` object of `task_configuration` supports the following: + +* `param_key` - (Required, String) Parameter name. +* `param_value` - (Required, String) Parameter value. + +The `upstream_dependency_config_list` object of `task_scheduler_configuration` supports the following: + +* `main_cyclic_config` - (Required, String) Main dependency configuration, values: + +* CRONTAB +* DAY +* HOUR +* LIST_DAY +* LIST_HOUR +* LIST_MINUTE +* MINUTE +* MONTH +* RANGE_DAY +* RANGE_HOUR +* RANGE_MINUTE +* WEEK +* YEAR. +* `task_id` - (Required, String) Task ID. +* `dependency_strategy` - (Optional, List) Dependency execution strategy. +* `offset` - (Optional, String) Offset in interval and list modes. +* `subordinate_cyclic_config` - (Optional, String) Secondary dependency configuration, values: +* ALL_DAY_OF_YEAR +* ALL_MONTH_OF_YEAR +* CURRENT +* CURRENT_DAY +* CURRENT_HOUR +* CURRENT_MINUTE +* CURRENT_MONTH +* CURRENT_WEEK +* CURRENT_YEAR +* PREVIOUS_BEGIN_OF_MONTH +* PREVIOUS_DAY +* PREVIOUS_DAY_LATER_OFFSET_HOUR +* PREVIOUS_DAY_LATER_OFFSET_MINUTE +* PREVIOUS_END_OF_MONTH +* PREVIOUS_FRIDAY +* PREVIOUS_HOUR +* PREVIOUS_HOUR_CYCLE +* PREVIOUS_HOUR_LATER_OFFSET_MINUTE +* PREVIOUS_MINUTE_CYCLE +* PREVIOUS_MONTH +* PREVIOUS_WEEK +* PREVIOUS_WEEKEND +* RECENT_DATE. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - ID of the resource. + + + +## Import + +wedata wedata_task can be imported using the id, e.g. + +``` +terraform import tencentcloud_wedata_task.wedata_task wedata_task_id +``` + diff --git a/website/docs/r/wedata_workflow.html.markdown b/website/docs/r/wedata_workflow.html.markdown new file mode 100644 index 0000000000..90a82e1700 --- /dev/null +++ b/website/docs/r/wedata_workflow.html.markdown @@ -0,0 +1,126 @@ +--- +subcategory: "Wedata" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_wedata_workflow" +sidebar_current: "docs-tencentcloud-resource-wedata_workflow" +description: |- + Provides a resource to create a wedata wedata_workflow +--- + +# tencentcloud_wedata_workflow + +Provides a resource to create a wedata wedata_workflow + +## Example Usage + +```hcl +resource "tencentcloud_wedata_workflow" "wedata_workflow" { + project_id = 2905622749543821312 + workflow_name = "test" + parent_folder_path = "/tfmika" + workflow_type = "cycle" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `parent_folder_path` - (Required, String) Parent folder path. +* `project_id` - (Required, String, ForceNew) Project id. +* `workflow_name` - (Required, String) Workflow name. +* `bundle_id` - (Optional, String) Bundle Id. +* `bundle_info` - (Optional, String) Bundle Information. +* `owner_uin` - (Optional, String) Workflow Owner ID. +* `workflow_desc` - (Optional, String) Workflow description. +* `workflow_params` - (Optional, Set) workflow parameter. +* `workflow_scheduler_configuration` - (Optional, List) Unified dispatch information. +* `workflow_type` - (Optional, String) Workflow type, value example: cycle cycle workflow;manual manual workflow, passed in cycle by default. + +The `workflow_params` object supports the following: + +* `param_key` - (Required, String) Parameter name. +* `param_value` - (Required, String) Parameter value. + +The `workflow_scheduler_configuration` object supports the following: + +* `crontab_expression` - (Required, String) Crontab expression. +* `cycle_type` - (Required, String) Cycle type: Supported types are +ONEOFF_CYCLE: One-time +YEAR_CYCLE: Year +MONTH_CYCLE: Month +WEEK_CYCLE: Week +DAY_CYCLE: Day +HOUR_CYCLE: Hour +MINUTE_CYCLE: Minute +CRONTAB_CYCLE: crontab expression type. +* `end_time` - (Required, String) End time. +* `schedule_time_zone` - (Required, String) time zone. +* `self_depend` - (Required, String) Self-dependence, default value serial, values are: parallel, serial, orderly. +* `start_time` - (Required, String) Start time. +* `calendar_id` - (Optional, String) calendar id. +* `calendar_open` - (Optional, String) Do you want to turn on calendar scheduling 1 on 0 off. +* `clear_link` - (Optional, Bool) Workflows have cross-workflow dependencies and are scheduled using cron expressions. If you save unified scheduling, unsupported dependencies will be broken. +* `dependency_workflow` - (Optional, String) Workflow dependence, yes or no. +* `execution_end_time` - (Optional, String) Execution time right-closed interval, example: 23:59, only if the cycle type is MINUTE_CYCLE needs to be filled in. +* `execution_start_time` - (Optional, String) Execution time left-closed interval, example: 00:00, only if the cycle type is MINUTE_CYCLE needs to be filled in. +* `main_cyclic_config` - (Optional, String) Effective when ModifyCycleValue is 1, indicating the default modified upstream dependence-time dimension. The value is: +* CRONTAB +* DAY +* HOUR +* LIST_DAY +* LIST_HOUR + * LIST_MINUTE + * MONTH +* RANGE_DAY + * RANGE_HOUR + * RANGE_MINUTE +* WEEK +* YEAR + +https://capi.woa.com/object/detail? product=wedata&env=api_dev&version=2025-08-06&name=WorkflowSchedulerConfigurationInfo. +* `modify_cycle_value` - (Optional, String) 0: Do not modify 1: Change the upstream dependency configuration of the task to the default value. +* `subordinate_cyclic_config` - (Optional, String) Effective when ModifyCycleValue is 1, which means that the default modified upstream dependency-instance range + value is: +* ALL_DAY_OF_YEAR +* ALL_MONTH_OF_YEAR +* CURRENT +* CURRENT_DAY +* CURRENT_HOUR +* CURRENT_MINUTE +* CURRENT_MONTH +* CURRENT_WEEK +* CURRENT_YEAR +* PREVIOUS_BEGIN_OF_MONTH +* PREVIOUS_DAY +* PREVIOUS_DAY_LATER_OFFSET_HOUR +* PREVIOUS_DAY_LATER_OFFSET_MINUTE +* PREVIOUS_END_OF_MONTH +* PREVIOUS_FRIDAY +* PREVIOUS_HOUR +* PREVIOUS_HOUR_CYCLE +* PREVIOUS_HOUR_LATER_OFFSET_MINUTE +* PREVIOUS_MINUTE_CYCLE +* PREVIOUS_MONTH +* PREVIOUS_WEEK +* PREVIOUS_WEEKEND +* RECENT_DATE + +https://capi.woa.com/object/detail? product=wedata&env=api_dev&version=2025-08-06&name=WorkflowSchedulerConfigurationInfo. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - ID of the resource. +* `workflow_id` - Workflow id. + + +## Import + +wedata wedata_workflow can be imported using the id, e.g. + +``` +terraform import tencentcloud_wedata_workflow.wedata_workflow wedata_workflow_id +``` + diff --git a/website/docs/r/wedata_workflow_folder.html.markdown b/website/docs/r/wedata_workflow_folder.html.markdown new file mode 100644 index 0000000000..cb688779c4 --- /dev/null +++ b/website/docs/r/wedata_workflow_folder.html.markdown @@ -0,0 +1,39 @@ +--- +subcategory: "Wedata" +layout: "tencentcloud" +page_title: "TencentCloud: tencentcloud_wedata_workflow_folder" +sidebar_current: "docs-tencentcloud-resource-wedata_workflow_folder" +description: |- + Provides a resource to create a wedata wedata_workflow_folder +--- + +# tencentcloud_wedata_workflow_folder + +Provides a resource to create a wedata wedata_workflow_folder + +## Example Usage + +```hcl +resource "tencentcloud_wedata_workflow_folder" "wedata_workflow_folder" { + project_id = 2905622749543821312 + parent_folder_path = "/" + folder_name = "test" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `folder_name` - (Required, String) Name of the folder to create. +* `parent_folder_path` - (Required, String) The absolute path of the parent folder, such as/abc/de, if it is the root directory, pass/. +* `project_id` - (Required, String, ForceNew) Project id. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - ID of the resource. + + + diff --git a/website/tencentcloud.erb b/website/tencentcloud.erb index b889eb0cd9..00fdd7dd47 100644 --- a/website/tencentcloud.erb +++ b/website/tencentcloud.erb @@ -7101,6 +7101,12 @@
  • tencentcloud_wedata_ops_task_owner
  • +
  • + tencentcloud_wedata_resource_file +
  • +
  • + tencentcloud_wedata_resource_folder +
  • tencentcloud_wedata_rule_template
  • @@ -7110,6 +7116,9 @@
  • tencentcloud_wedata_submit_task_operation
  • +
  • + tencentcloud_wedata_task +
  • tencentcloud_wedata_task_kill_instance_async
  • @@ -7119,6 +7128,12 @@
  • tencentcloud_wedata_task_set_success_instance_async
  • +
  • + tencentcloud_wedata_workflow +
  • +
  • + tencentcloud_wedata_workflow_folder +