Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

promote optimized field to GA #18348

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func ResourceVertexAIFeatureOnlineStore() *schema.Resource {
},
},
},
ExactlyOneOf: []string{"bigtable"},
ExactlyOneOf: []string{"bigtable", "optimized"},
},
"labels": {
Type: schema.TypeMap,
Expand All @@ -107,6 +107,17 @@ func ResourceVertexAIFeatureOnlineStore() *schema.Resource {
Please refer to the field 'effective_labels' for all of the labels present on the resource.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"optimized": {
Type: schema.TypeList,
Optional: true,
Description: `Settings for the Optimized store that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{},
},
ConflictsWith: []string{},
ExactlyOneOf: []string{"bigtable", "optimized"},
},
"region": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -178,6 +189,12 @@ func resourceVertexAIFeatureOnlineStoreCreate(d *schema.ResourceData, meta inter
} else if v, ok := d.GetOkExists("bigtable"); !tpgresource.IsEmptyValue(reflect.ValueOf(bigtableProp)) && (ok || !reflect.DeepEqual(v, bigtableProp)) {
obj["bigtable"] = bigtableProp
}
optimizedProp, err := expandVertexAIFeatureOnlineStoreOptimized(d.Get("optimized"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("optimized"); ok || !reflect.DeepEqual(v, optimizedProp) {
obj["optimized"] = optimizedProp
}
labelsProp, err := expandVertexAIFeatureOnlineStoreEffectiveLabels(d.Get("effective_labels"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -314,6 +331,9 @@ func resourceVertexAIFeatureOnlineStoreRead(d *schema.ResourceData, meta interfa
if err := d.Set("bigtable", flattenVertexAIFeatureOnlineStoreBigtable(res["bigtable"], d, config)); err != nil {
return fmt.Errorf("Error reading FeatureOnlineStore: %s", err)
}
if err := d.Set("optimized", flattenVertexAIFeatureOnlineStoreOptimized(res["optimized"], d, config)); err != nil {
return fmt.Errorf("Error reading FeatureOnlineStore: %s", err)
}
if err := d.Set("terraform_labels", flattenVertexAIFeatureOnlineStoreTerraformLabels(res["labels"], d, config)); err != nil {
return fmt.Errorf("Error reading FeatureOnlineStore: %s", err)
}
Expand Down Expand Up @@ -346,6 +366,12 @@ func resourceVertexAIFeatureOnlineStoreUpdate(d *schema.ResourceData, meta inter
} else if v, ok := d.GetOkExists("bigtable"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, bigtableProp)) {
obj["bigtable"] = bigtableProp
}
optimizedProp, err := expandVertexAIFeatureOnlineStoreOptimized(d.Get("optimized"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("optimized"); ok || !reflect.DeepEqual(v, optimizedProp) {
obj["optimized"] = optimizedProp
}
labelsProp, err := expandVertexAIFeatureOnlineStoreEffectiveLabels(d.Get("effective_labels"), d, config)
if err != nil {
return err
Expand All @@ -366,6 +392,10 @@ func resourceVertexAIFeatureOnlineStoreUpdate(d *schema.ResourceData, meta inter
updateMask = append(updateMask, "bigtable")
}

if d.HasChange("optimized") {
updateMask = append(updateMask, "optimized")
}

if d.HasChange("effective_labels") {
updateMask = append(updateMask, "labels")
}
Expand Down Expand Up @@ -609,6 +639,14 @@ func flattenVertexAIFeatureOnlineStoreBigtableAutoScalingCpuUtilizationTarget(v
return v // let terraform core handle it otherwise
}

func flattenVertexAIFeatureOnlineStoreOptimized(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return nil
}
transformed := make(map[string]interface{})
return []interface{}{transformed}
}

func flattenVertexAIFeatureOnlineStoreTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return v
Expand Down Expand Up @@ -692,6 +730,21 @@ func expandVertexAIFeatureOnlineStoreBigtableAutoScalingCpuUtilizationTarget(v i
return v, nil
}

func expandVertexAIFeatureOnlineStoreOptimized(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 {
return nil, nil
}

if l[0] == nil {
transformed := make(map[string]interface{})
return transformed, nil
}
transformed := make(map[string]interface{})

return transformed, nil
}

func expandVertexAIFeatureOnlineStoreEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
if v == nil {
return map[string]string{}, nil
Expand Down
8 changes: 5 additions & 3 deletions website/docs/r/vertex_ai_feature_online_store.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ The following arguments are supported:
Structure is [documented below](#nested_bigtable).

* `optimized` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
(Optional)
Settings for the Optimized store that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore

* `dedicated_serving_endpoint` -
Expand All @@ -149,10 +149,12 @@ The following arguments are supported:
Structure is [documented below](#nested_dedicated_serving_endpoint).

* `embedding_management` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
The settings for embedding management in FeatureOnlineStore. Embedding management can only be used with BigTable.
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html), Deprecated)
The settings for embedding management in FeatureOnlineStore. Embedding management can only be set for BigTable. It is enabled by default for optimized storagetype.
Structure is [documented below](#nested_embedding_management).

~> **Warning:** `embedding_management` is deprecated. This field is no longer needed anymore and embedding management is automatically enabled when specifying Optimized storage type

* `region` -
(Optional)
The region of feature online store. eg us-central1
Expand Down