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

feat(vertexai): add parameter region to google_vertex_ai_featurestore_entitytype_feature #5739

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
3 changes: 3 additions & 0 deletions .changelog/6992.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
vertexai: made google_vertex_ai_featurestore_entitytype_feature always use regional corresponding to parent's region
```
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ func ResourceVertexAIFeaturestoreEntitytypeFeature() *schema.Resource {
Computed: true,
Description: `The timestamp when the entity type was most recently updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.`,
},
"region": {
Type: schema.TypeString,
Computed: true,
Description: "The region of the feature",
},
},
UseJSONNumber: true,
}
Expand Down Expand Up @@ -126,6 +131,11 @@ func resourceVertexAIFeaturestoreEntitytypeFeatureCreate(d *schema.ResourceData,
obj["valueType"] = valueTypeProp
}

obj, err = resourceVertexAIFeaturestoreEntitytypeFeatureEncoder(d, meta, obj)
if err != nil {
return err
}

url, err := tpgresource.ReplaceVars(d, config, "{{VertexAIBasePath}}{{entitytype}}/features?featureId={{name}}")
if err != nil {
return err
Expand Down Expand Up @@ -265,6 +275,11 @@ func resourceVertexAIFeaturestoreEntitytypeFeatureUpdate(d *schema.ResourceData,
obj["description"] = descriptionProp
}

obj, err = resourceVertexAIFeaturestoreEntitytypeFeatureEncoder(d, meta, obj)
if err != nil {
return err
}

url, err := tpgresource.ReplaceVars(d, config, "{{VertexAIBasePath}}{{entitytype}}/features/{{name}}")
if err != nil {
return err
Expand Down Expand Up @@ -383,6 +398,13 @@ func resourceVertexAIFeaturestoreEntitytypeFeatureImport(d *schema.ResourceData,
}
d.SetId(id)

entitytype := d.Get("entitytype").(string)

re := regexp.MustCompile("^projects/(.+)/locations/(.+)/featurestores/(.+)/entityTypes/(.+)$")
if parts := re.FindStringSubmatch(entitytype); parts != nil {
d.Set("region", parts[2])
}

return []*schema.ResourceData{d}, nil
}

Expand Down Expand Up @@ -424,3 +446,14 @@ func expandVertexAIFeaturestoreEntitytypeFeatureDescription(v interface{}, d tpg
func expandVertexAIFeaturestoreEntitytypeFeatureValueType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func resourceVertexAIFeaturestoreEntitytypeFeatureEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) {
if v, ok := d.GetOk("entitytype"); ok {
re := regexp.MustCompile("^projects/(.+)/locations/(.+)/featurestores/(.+)/entityTypes/(.+)$")
if parts := re.FindStringSubmatch(v.(string)); parts != nil {
d.Set("region", parts[2])
}
}

return obj, nil
}