From 40f49285113fa8394144218730085473fc368719 Mon Sep 17 00:00:00 2001 From: wangzepeng <65212374+Zippo-Wang@users.noreply.github.com> Date: Wed, 1 Nov 2023 14:51:47 +0800 Subject: [PATCH] feat(GaussDB): add gaussdb_cassandra_flavors data source (#1040) --- .../data-sources/gaussdb_cassandra_flavors.md | 46 +++++++++++++++++++ ...leengine_gaussdb_cassandra_flavors_test.go | 45 ++++++++++++++++++ flexibleengine/provider.go | 1 + 3 files changed, 92 insertions(+) create mode 100644 docs/data-sources/gaussdb_cassandra_flavors.md create mode 100644 flexibleengine/acceptance/data_source_flexibleengine_gaussdb_cassandra_flavors_test.go diff --git a/docs/data-sources/gaussdb_cassandra_flavors.md b/docs/data-sources/gaussdb_cassandra_flavors.md new file mode 100644 index 00000000..ebb08b2d --- /dev/null +++ b/docs/data-sources/gaussdb_cassandra_flavors.md @@ -0,0 +1,46 @@ +--- +subcategory: "GaussDB NoSQL" +--- + +# flexibleengine_gaussdb_cassandra_flavors + +Use this data source to get available FlexibleEngine gaussdb cassandra flavors. + +## Example Usage + +```hcl +data "flexibleengine_gaussdb_cassandra_flavors" "flavors" { +} +``` + +## Argument Reference + +* `region` - (Optional, String) The region in which to obtain the flavors. If omitted, the provider-level region will be + used. + +* `vcpus` - (Optional, String) Specifies the count of vcpus of the flavors. + +* `memory` - (Optional, String) Specifies the memory size of the flavors. + +* `version` - (Optional, String) Specifies the engine version of the flavors. + +## Attribute Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - Specifies the data source ID. + +* `flavors` - Indicates the flavors information. The [flavors](#gaussdb_flavors) object structure is documented below. + + +The `flavors` block supports: + +* `name` - Indicates the spec code of the flavor. + +* `vcpus` - Indicates the CPU size. + +* `memory` - Indicates the memory size in GB. + +* `version` - Indicates the database version. + +* `az_status` - Indicates the flavor status in each availability zone. diff --git a/flexibleengine/acceptance/data_source_flexibleengine_gaussdb_cassandra_flavors_test.go b/flexibleengine/acceptance/data_source_flexibleengine_gaussdb_cassandra_flavors_test.go new file mode 100644 index 00000000..d8bf8646 --- /dev/null +++ b/flexibleengine/acceptance/data_source_flexibleengine_gaussdb_cassandra_flavors_test.go @@ -0,0 +1,45 @@ +package acceptance + +import ( + "testing" + + "github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/utils/fmtp" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccCassandraFlavorsDataSource_basic(t *testing.T) { + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: TestAccProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccCassandraFlavorsDataSource_basic, + Check: resource.ComposeTestCheckFunc( + testAccCheckCassandraFlavorsDataSourceID("data.flexibleengine_gaussdb_cassandra_flavors.test"), + ), + }, + }, + }) +} + +func testAccCheckCassandraFlavorsDataSourceID(n string) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmtp.Errorf("Can't find GaussDB cassandra flavors data source: %s ", n) + } + + if rs.Primary.ID == "" { + return fmtp.Errorf("GaussDB cassandra flavors data source ID not set ") + } + + return nil + } +} + +const testAccCassandraFlavorsDataSource_basic = ` +data "flexibleengine_gaussdb_cassandra_flavors" "test" { +} +` diff --git a/flexibleengine/provider.go b/flexibleengine/provider.go index 459b0220..e4b35b7b 100644 --- a/flexibleengine/provider.go +++ b/flexibleengine/provider.go @@ -305,6 +305,7 @@ func Provider() *schema.Provider { "flexibleengine_elb_certificate": elb.DataSourceELBCertificateV3(), "flexibleengine_fgs_dependencies": fgs.DataSourceFunctionGraphDependencies(), + "flexibleengine_gaussdb_cassandra_flavors": gaussdb.DataSourceCassandraFlavors(), "flexibleengine_gaussdb_cassandra_instances": gaussdb.DataSourceGeminiDBInstances(), "flexibleengine_gaussdb_nosql_flavors": gaussdb.DataSourceGaussDBNoSQLFlavors(),