From 76d2d3b4a6f0944eddd9f8b16db870c0725bacb5 Mon Sep 17 00:00:00 2001 From: Kodanda Rama Date: Thu, 21 Dec 2023 14:17:06 +0530 Subject: [PATCH] add FeatureView resource with standard base_url --- .../FeatureOnlineStoreFeatureview.yaml | 66 +++++-------------- ...x_ai_featureonlinestore_featureview.go.erb | 9 --- ...x_ai_featureonlinestore_featureview.go.erb | 22 ------- ...x_ai_featureonlinestore_featureview.go.erb | 8 --- ...x_ai_featureonlinestore_featureview.tf.erb | 9 +-- ...x_ai_featureonlinestore_featureview.go.erb | 5 -- ...ai_feature_onlinestore_featureview_test.go | 19 ++++-- 7 files changed, 34 insertions(+), 104 deletions(-) delete mode 100644 mmv1/templates/terraform/constants/vertex_ai_featureonlinestore_featureview.go.erb delete mode 100644 mmv1/templates/terraform/custom_import/vertex_ai_featureonlinestore_featureview.go.erb delete mode 100644 mmv1/templates/terraform/encoders/vertex_ai_featureonlinestore_featureview.go.erb delete mode 100644 mmv1/templates/terraform/extra_schema_entry/vertex_ai_featureonlinestore_featureview.go.erb diff --git a/mmv1/products/vertexai/FeatureOnlineStoreFeatureview.yaml b/mmv1/products/vertexai/FeatureOnlineStoreFeatureview.yaml index 48c1237560e8..4a2f3b928ba4 100644 --- a/mmv1/products/vertexai/FeatureOnlineStoreFeatureview.yaml +++ b/mmv1/products/vertexai/FeatureOnlineStoreFeatureview.yaml @@ -13,9 +13,9 @@ --- !ruby/object:Api::Resource name: FeatureOnlinestoreFeatureview -base_url: '{{feature_online_store}}/featureViews' -create_url: '{{feature_online_store}}/featureViews?featureViewId={{name}}' -self_link: '{{feature_online_store}}/featureViews/{{name}}' +base_url: projects/{{project}}/locations/{{region}}/featureOnlineStores/{{feature_online_store}}/featureViews +create_url: projects/{{project}}/locations/{{region}}/featureOnlineStores/{{feature_online_store}}/featureViews?featureViewId={{name}} +self_link: projects/{{project}}/locations/{{region}}/featureOnlineStores/{{feature_online_store}}/featureViews/{{name}} update_verb: :PATCH update_mask: true references: !ruby/object:Api::Resource::ReferenceLinks @@ -42,34 +42,33 @@ async: !ruby/object:Api::OpAsync error: !ruby/object:Api::OpAsync::Error path: 'error' message: 'message' - include_project: true description: |- FeatureView is representation of values that the FeatureOnlineStore will serve based on its syncConfig. -import_format: ['{{feature_online_store}}/featureViews/{{name}}'] +import_format: + [ + 'projects/{{project}}/locations/{{region}}/featureOnlineStores/{{feature_online_store}}/featureViews/{{name}}', + ] autogen_async: false -# Skipping the sweeper due to the non-standard base_url -skip_sweeper: true examples: - !ruby/object:Provider::Terraform::Examples name: 'vertex_ai_featureonlinestore_featureview' primary_resource_id: 'featureview' vars: - name: 'tf_test_fv1' -custom_code: !ruby/object:Provider::Terraform::CustomCode - pre_create: templates/terraform/constants/vertex_ai_featureonlinestore_featureview.go.erb - pre_delete: templates/terraform/constants/vertex_ai_featureonlinestore_featureview.go.erb - custom_import: templates/terraform/custom_import/vertex_ai_featureonlinestore_featureview.go.erb - extra_schema_entry: templates/terraform/extra_schema_entry/vertex_ai_featureonlinestore_featureview.go.erb - encoder: templates/terraform/encoders/vertex_ai_featureonlinestore_featureview.go.erb + name: 'example_feature_view' parameters: - !ruby/object:Api::Type::String name: featureOnlineStore description: - The name of the FeatureOnlineStore to use, in the format - projects/{project}/locations/{region}/featureOnlineStores/{featureOnlineStore}. + The name of the FeatureOnlineStore to use for the featureview. url_param_only: true immutable: true required: true + - !ruby/object:Api::Type::String + name: 'region' + description: The region for the resource. It should be the same as the featureonlinestore region. + required: true + immutable: true + url_param_only: true properties: - !ruby/object:Api::Type::String name: 'name' @@ -78,13 +77,10 @@ properties: valid characters are [a-z0-9_]. The first character cannot be a number. immutable: true url_param_only: true - pattern: 'projects/{{project}}/locations/{{region}}/featureOnlineStores/{{featureOnlineStore}}/featureViews/{{name}}' - custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb - !ruby/object:Api::Type::String name: 'etag' description: Used to perform consistent read-modify-write updates. output: true - ignore_read: true - !ruby/object:Api::Type::String name: 'createTime' output: true @@ -114,11 +110,6 @@ properties: name: 'bigQuerySource' description: | Configures how data is supposed to be extracted from a BigQuery source to be loaded onto the FeatureOnlineStore. - conflicts: - - feature_registry_source - exactly_one_of: - - big_query_source - - feature_registry_source properties: - !ruby/object:Api::Type::String name: 'uri' @@ -131,30 +122,3 @@ properties: description: | Columns to construct entityId / row keys. Start by supporting 1 only. item_type: Api::Type::String - - !ruby/object:Api::Type::NestedObject - name: 'featureRegistrySource' - conflicts: - - big_query_source - exactly_one_of: - - big_query_source - - feature_registry_source - description: | - Configures the features from a Feature Registry source that need to be loaded onto the FeatureOnlineStore. - properties: - - !ruby/object:Api::Type::NestedObject - name: 'featureGroups' - required: true - description: | - List of features that need to be synced to Online Store. - properties: - - !ruby/object:Api::Type::String - name: 'featureGroupId' - required: true - description: | - Identifier of the feature group. - - !ruby/object:Api::Type::Array - name: featureIds - required: true - description: | - Identifiers of features under the feature group. - item_type: Api::Type::String diff --git a/mmv1/templates/terraform/constants/vertex_ai_featureonlinestore_featureview.go.erb b/mmv1/templates/terraform/constants/vertex_ai_featureonlinestore_featureview.go.erb deleted file mode 100644 index 50eb55b7c715..000000000000 --- a/mmv1/templates/terraform/constants/vertex_ai_featureonlinestore_featureview.go.erb +++ /dev/null @@ -1,9 +0,0 @@ -if v, ok := d.GetOk("feature_online_store"); ok { - re := regexp.MustCompile("projects/([a-zA-Z0-9-]*)/(?:locations|regions)/([a-zA-Z0-9-]*)") - switch { - case re.MatchString(v.(string)): - if res := re.FindStringSubmatch(v.(string)); len(res) == 3 && res[1] != "" { - project = res[1] - } - } -} diff --git a/mmv1/templates/terraform/custom_import/vertex_ai_featureonlinestore_featureview.go.erb b/mmv1/templates/terraform/custom_import/vertex_ai_featureonlinestore_featureview.go.erb deleted file mode 100644 index 108c00ef12b3..000000000000 --- a/mmv1/templates/terraform/custom_import/vertex_ai_featureonlinestore_featureview.go.erb +++ /dev/null @@ -1,22 +0,0 @@ -config := meta.(*transport_tpg.Config) -if err := tpgresource.ParseImportId([]string{ - "(?P.+)/featureViews/(?P[^/]+)", -}, d, config); err != nil { - return nil, err -} - -// Replace import id for the resource id -id, err := tpgresource.ReplaceVars(d, config, "{{feature_online_store}}/featureViews/{{name}}") -if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) -} -d.SetId(id) - -featureOnlineStore := d.Get("feature_online_store").(string) - -re := regexp.MustCompile("^projects/(.+)/locations/(.+)/featureOnlineStores/(.+)$") -if parts := re.FindStringSubmatch(featureOnlineStore); parts != nil { - d.Set("region", parts[2]) -} - -return []*schema.ResourceData{d}, nil \ No newline at end of file diff --git a/mmv1/templates/terraform/encoders/vertex_ai_featureonlinestore_featureview.go.erb b/mmv1/templates/terraform/encoders/vertex_ai_featureonlinestore_featureview.go.erb deleted file mode 100644 index a88fa04333d4..000000000000 --- a/mmv1/templates/terraform/encoders/vertex_ai_featureonlinestore_featureview.go.erb +++ /dev/null @@ -1,8 +0,0 @@ -if v, ok := d.GetOk("feature_online_store"); ok { - re := regexp.MustCompile("projects/(.+)/locations/(.+)/featureOnlineStores/(.+)$") - if parts := re.FindStringSubmatch(v.(string)); parts != nil { - d.Set("region", parts[2]) - } -} - -return obj, nil \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_featureview.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_featureview.tf.erb index 04b7001eb4cc..256dc5451038 100644 --- a/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_featureview.tf.erb +++ b/mmv1/templates/terraform/examples/vertex_ai_featureonlinestore_featureview.tf.erb @@ -1,5 +1,5 @@ resource "google_vertex_ai_feature_online_store" "featureonlinestore" { - name = "tf_test_featureonlinestore12" + name = "<%= ctx[:vars]['name'] %>" labels = { foo = "bar" } @@ -15,7 +15,7 @@ resource "google_vertex_ai_feature_online_store" "featureonlinestore" { resource "google_bigquery_dataset" "tf-test-dataset" { - dataset_id = "tf_test_dataset1_featureview1" + dataset_id = "<%= ctx[:vars]['name'] %>" friendly_name = "test" description = "This is a test description" location = "US" @@ -25,7 +25,7 @@ resource "google_bigquery_table" "tf-test-table" { deletion_protection = false dataset_id = google_bigquery_dataset.tf-test-dataset.dataset_id - table_id = "tf_test_bq_table" + table_id = "<%= ctx[:vars]['name'] %>" schema = <" { name = "<%= ctx[:vars]['name'] %>" - feature_online_store = google_vertex_ai_feature_online_store.featureonlinestore.id + region = "us-central1" + feature_online_store = google_vertex_ai_feature_online_store.featureonlinestore.name sync_config { cron = "0 0 * * *" } diff --git a/mmv1/templates/terraform/extra_schema_entry/vertex_ai_featureonlinestore_featureview.go.erb b/mmv1/templates/terraform/extra_schema_entry/vertex_ai_featureonlinestore_featureview.go.erb deleted file mode 100644 index 95268f37fd94..000000000000 --- a/mmv1/templates/terraform/extra_schema_entry/vertex_ai_featureonlinestore_featureview.go.erb +++ /dev/null @@ -1,5 +0,0 @@ -"region": { - Type: schema.TypeString, - Computed: true, - Description: "The region of the featureView.", -}, diff --git a/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_onlinestore_featureview_test.go b/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_onlinestore_featureview_test.go index a4455a1089c7..4a14a1cd8f5f 100644 --- a/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_onlinestore_featureview_test.go +++ b/mmv1/third_party/terraform/services/vertexai/resource_vertex_ai_feature_onlinestore_featureview_test.go @@ -21,6 +21,7 @@ func TestAccVertexAIFeatureOnlinestoreFeatureview_vertexAiFeatureonlinestoreFeat acctest.VcrTest(t, resource.TestCase{ PreCheck: func() { acctest.AccTestPreCheck(t) }, ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckVertexAIFeatureOnlinestoreFeatureviewDestroyProducer(t), Steps: []resource.TestStep{ { Config: testAccVertexAIFeatureOnlinestoreFeatureview_vertexAiFeatureonlinestoreFeatureview_basic(context), @@ -63,7 +64,7 @@ resource "google_vertex_ai_feature_online_store" "featureonlinestore" { resource "google_bigquery_dataset" "tf-test-dataset" { - dataset_id = "tf_test_dataset1_featureview1" + dataset_id = "tf_test_dataset1_featureview12" friendly_name = "test" description = "This is a test description" location = "US" @@ -100,7 +101,11 @@ EOF resource "google_vertex_ai_feature_onlinestore_featureview" "featureview" { name = "tf_test_tf_test_fv1%{random_suffix}" - feature_online_store = google_vertex_ai_feature_online_store.featureonlinestore.id + region = "us-central1" + labels = { + foo = "bar" + } + feature_online_store = google_vertex_ai_feature_online_store.featureonlinestore.name sync_config { cron = "0 0 * * *" } @@ -122,7 +127,7 @@ func testAccVertexAIFeatureOnlinestoreFeatureview_vertexAiFeatureonlinestoreFeat resource "google_vertex_ai_feature_online_store" "featureonlinestore" { name = "tf_test_featureonlinestore12" labels = { -foo = "bar" +foo1 = "bar1" } region = "us-central1" bigtable { @@ -136,7 +141,7 @@ cpu_utilization_target = 80 resource "google_bigquery_dataset" "tf-test-dataset" { -dataset_id = "tf_test_dataset1_featureview1" +dataset_id = "tf_test_dataset1_featureview12" friendly_name = "test" description = "This is a test description" location = "US" @@ -173,7 +178,11 @@ EOF resource "google_vertex_ai_feature_onlinestore_featureview" "featureview" { name = "tf_test_tf_test_fv1%{random_suffix}" -feature_online_store = google_vertex_ai_feature_online_store.featureonlinestore.id +region = "us-central1" +labels = { + foo1 = "bar1" + } +feature_online_store = google_vertex_ai_feature_online_store.featureonlinestore.name sync_config { cron = "0 4 * * *" }