diff --git a/alicloud/resource_alicloud_schedulerx_app_group.go b/alicloud/resource_alicloud_schedulerx_app_group.go index bf767365d463..2ffcbed67791 100644 --- a/alicloud/resource_alicloud_schedulerx_app_group.go +++ b/alicloud/resource_alicloud_schedulerx_app_group.go @@ -110,8 +110,12 @@ func resourceAliCloudSchedulerxAppGroupCreate(d *schema.ResourceData, meta inter return WrapError(err) } request = make(map[string]interface{}) - query["Namespace"] = d.Get("namespace") - query["GroupId"] = d.Get("group_id") + if v, ok := d.GetOk("namespace"); ok { + query["Namespace"] = v + } + if v, ok := d.GetOk("group_id"); ok { + query["GroupId"] = v + } query["RegionId"] = client.RegionId if v, ok := d.GetOk("description"); ok { @@ -209,12 +213,18 @@ func resourceAliCloudSchedulerxAppGroupRead(d *schema.ResourceData, meta interfa if objectRaw["MaxJobs"] != nil { d.Set("max_jobs", objectRaw["MaxJobs"]) } + if objectRaw["MonitorConfigJson"] != nil { + d.Set("monitor_config_json", objectRaw["MonitorConfigJson"]) + } + if objectRaw["MonitorContactsJson"] != nil { + d.Set("monitor_contacts_json", objectRaw["MonitorContactsJson"]) + } if objectRaw["GroupId"] != nil { d.Set("group_id", objectRaw["GroupId"]) } - - parts := strings.Split(d.Id(), ":") - d.Set("namespace", parts[0]) + if objectRaw["Namespace"] != nil { + d.Set("namespace", objectRaw["Namespace"]) + } return nil } @@ -242,11 +252,21 @@ func resourceAliCloudSchedulerxAppGroupUpdate(d *schema.ResourceData, meta inter request["Description"] = d.Get("description") } + if d.HasChange("monitor_config_json") { + update = true + request["MonitorConfigJson"] = d.Get("monitor_config_json") + } + if d.HasChange("app_version") { update = true request["AppVersion"] = d.Get("app_version") } + if d.HasChange("monitor_contacts_json") { + update = true + request["MonitorContactsJson"] = d.Get("monitor_contacts_json") + } + if v, ok := d.GetOkExists("max_concurrency"); ok { request["MaxConcurrency"] = v } diff --git a/alicloud/resource_alicloud_schedulerx_app_group_test.go b/alicloud/resource_alicloud_schedulerx_app_group_test.go index 04b84bd07812..59c6074fd921 100644 --- a/alicloud/resource_alicloud_schedulerx_app_group_test.go +++ b/alicloud/resource_alicloud_schedulerx_app_group_test.go @@ -10,11 +10,11 @@ import ( ) // Test Schedulerx AppGroup. >>> Resource test cases, automatically generated. -// Case 预发环境_20241220_杭州reigon 9654 -func TestAccAliCloudSchedulerxAppGroup_basic9654(t *testing.T) { +// Case 预发环境_20250110_乌兰察布(代码只部署到乌兰察布,用这个用例测试) 9957 +func TestAccAliCloudSchedulerxAppGroup_basic9957(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_schedulerx_app_group.default" - ra := resourceAttrInit(resourceId, AlicloudSchedulerxAppGroupMap9654) + ra := resourceAttrInit(resourceId, AlicloudSchedulerxAppGroupMap9957) rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} { return &SchedulerxServiceV2{testAccProvider.Meta().(*connectivity.AliyunClient)} }, "DescribeSchedulerxAppGroup") @@ -22,7 +22,7 @@ func TestAccAliCloudSchedulerxAppGroup_basic9654(t *testing.T) { testAccCheck := rac.resourceAttrMapUpdateSet() rand := acctest.RandIntRange(10000, 99999) name := fmt.Sprintf("tf-testacc%sschedulerxappgroup%d", defaultRegionToTest, rand) - testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudSchedulerxAppGroupBasicDependence9654) + testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudSchedulerxAppGroupBasicDependence9957) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) @@ -36,50 +36,50 @@ func TestAccAliCloudSchedulerxAppGroup_basic9654(t *testing.T) { "namespace": "${alicloud_schedulerx_namespace.CreateNameSpace.namespace_uid}", "group_id": "test-appgroup-pop-autotest", "description": "appgroup 资源用例自动生成", - "monitor_contacts_json": "[{\\\"userName\\\":\\\"张三\\\",\\\"userPhone\\\":\\\"89756******\\\"},{\\\"userName\\\":\\\"李四\\\",\\\"ding\\\":\\\"http://www.example.com\\\"}]", + "monitor_contacts_json": "[{\\\"name\\\":\\\"用户-手机\\\"},{\\\"name\\\":\\\"用户-钉钉\\\"}]", "enable_log": "false", "app_name": "test-appgroup-pop-autotest", "app_version": "1", "namespace_name": "default", - "monitor_config_json": "{\\\"sendChannel\\\":\\\"sms,ding\\\"}", + "monitor_config_json": "{\\\"sendChannel\\\":\\\"sms,ding\\\",\\\"alarmType\\\": \\\"Contacts\\\",\\\"webhookIsAtAll\\\": \\\"false\\\"}", "app_type": "1", "max_jobs": "100", "namespace_source": "schedulerx", "schedule_busy_workers": "false", - "delete_jobs": "false", }), Check: resource.ComposeTestCheckFunc( testAccCheck(map[string]string{ "namespace": CHECKSET, "group_id": "test-appgroup-pop-autotest", "description": "appgroup 资源用例自动生成", - "monitor_contacts_json": "[{\"userName\":\"张三\",\"userPhone\":\"89756******\"},{\"userName\":\"李四\",\"ding\":\"http://www.example.com\"}]", + "monitor_contacts_json": CHECKSET, "enable_log": "false", "app_name": "test-appgroup-pop-autotest", - "app_version": "1", + "app_version": CHECKSET, "namespace_name": "default", - "monitor_config_json": "{\"sendChannel\":\"sms,ding\"}", + "monitor_config_json": CHECKSET, "app_type": "1", "max_jobs": "100", "namespace_source": "schedulerx", "schedule_busy_workers": "false", - "delete_jobs": "false", }), ), }, { Config: testAccConfig(map[string]interface{}{ - "description": "appgroup 资源用例自动生成_update", - "app_version": "2", - "max_concurrency": "500", - "delete_jobs": "true", + "description": "appgroup 资源用例自动生成_update", + "monitor_contacts_json": "[{\\\"name\\\":\\\"用户-飞书\\\"},{\\\"name\\\":\\\"用户-钉钉\\\"}]", + "app_version": "2", + "monitor_config_json": "{\\\"sendChannel\\\":\\\"sms,ding\\\",\\\"alarmType\\\": \\\"Contacts\\\",\\\"webhookIsAtAll\\\": \\\"true\\\"}", + "max_concurrency": "500", }), Check: resource.ComposeTestCheckFunc( testAccCheck(map[string]string{ - "description": "appgroup 资源用例自动生成_update", - "app_version": "2", - "max_concurrency": "500", - "delete_jobs": "true", + "description": "appgroup 资源用例自动生成_update", + "monitor_contacts_json": CHECKSET, + "app_version": CHECKSET, + "monitor_config_json": CHECKSET, + "max_concurrency": "500", }), ), }, @@ -87,15 +87,15 @@ func TestAccAliCloudSchedulerxAppGroup_basic9654(t *testing.T) { ResourceName: resourceId, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"app_type", "enable_log", "max_concurrency", "monitor_config_json", "monitor_contacts_json", "namespace_name", "namespace_source", "schedule_busy_workers", "delete_jobs"}, + ImportStateVerifyIgnore: []string{"app_type", "enable_log", "max_concurrency", "namespace_name", "namespace_source", "schedule_busy_workers"}, }, }, }) } -var AlicloudSchedulerxAppGroupMap9654 = map[string]string{} +var AlicloudSchedulerxAppGroupMap9957 = map[string]string{} -func AlicloudSchedulerxAppGroupBasicDependence9654(name string) string { +func AlicloudSchedulerxAppGroupBasicDependence9957(name string) string { return fmt.Sprintf(` variable "name" { default = "%s" diff --git a/alicloud/service_alicloud_schedulerx_v2.go b/alicloud/service_alicloud_schedulerx_v2.go index f05ffdc2655b..372373882d8e 100644 --- a/alicloud/service_alicloud_schedulerx_v2.go +++ b/alicloud/service_alicloud_schedulerx_v2.go @@ -188,7 +188,6 @@ func (s *SchedulerxServiceV2) DescribeSchedulerxAppGroup(id string) (object map[ if len(parts) != 2 { err = WrapError(fmt.Errorf("invalid Resource Id %s. Expected parts' length %d, got %d", id, 2, len(parts))) } - action := "GetAppGroup" conn, err := client.NewSchedulerxClient() if err != nil { return object, WrapError(err) @@ -198,6 +197,7 @@ func (s *SchedulerxServiceV2) DescribeSchedulerxAppGroup(id string) (object map[ request["GroupId"] = parts[1] request["Namespace"] = parts[0] request["RegionId"] = client.RegionId + action := "GetAppGroup" runtime := util.RuntimeOptions{} runtime.SetAutoretry(true) diff --git a/website/docs/r/schedulerx_app_group.html.markdown b/website/docs/r/schedulerx_app_group.html.markdown index af8776cc9dea..87f1481d23bf 100644 --- a/website/docs/r/schedulerx_app_group.html.markdown +++ b/website/docs/r/schedulerx_app_group.html.markdown @@ -14,18 +14,12 @@ Provides a Schedulerx App Group resource. For information about Schedulerx App Group and how to use it, see [What is App Group](https://www.alibabacloud.com/help/en/). --> **NOTE:** Available since v1.240.0. +-> **NOTE:** Available since v1.242.0. ## Example Usage Basic Usage -