-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vertexai): add vertex_ai_index_endpoint for Vertex AI Matching E…
…ngine (#6873) (#1049) * feat: create vertex_ai_index_endpoint * fix: remove a white line * feat: add a comment about deployedIndexes [ci skip] * feat: add an unit test to check update * fix: fix the handwritten test name to avoid a conflict * fix: fix unnecessary code from test * fix: use immutable instead of input * refactor: refactor test code with acctest and tpgresource * test: update network_name to use the unique names * test: fix an invalid label definition * feat: increase timeout from 20m to 1h regarding vertex ai index endpoint * test: increase the timeouts to 120m * Apply suggestions from code review * feat: update test and yaml to clarify the fields mutabilities Signed-off-by: Modular Magician <magic-modules@google.com>
- Loading branch information
1 parent
d9ca6e8
commit 1df2ec8
Showing
3 changed files
with
108 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
tfplan2cai/converters/google/resources/services/vertexai/vertexai_index_endpoint.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** Type: MMv1 *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// This file is automatically generated by Magic Modules and manual | ||
// changes will be clobbered when the file is regenerated. | ||
// | ||
// Please read more about how to change this file in | ||
// .github/CONTRIBUTING.md. | ||
// | ||
// ---------------------------------------------------------------------------- | ||
|
||
package vertexai | ||
|
||
import ( | ||
"reflect" | ||
|
||
"github.com/GoogleCloudPlatform/terraform-google-conversion/v2/tfplan2cai/converters/google/resources/tpgresource" | ||
transport_tpg "github.com/GoogleCloudPlatform/terraform-google-conversion/v2/tfplan2cai/converters/google/resources/transport" | ||
) | ||
|
||
const VertexAIIndexEndpointAssetType string = "{{region}}-aiplatform.googleapis.com/IndexEndpoint" | ||
|
||
func ResourceConverterVertexAIIndexEndpoint() tpgresource.ResourceConverter { | ||
return tpgresource.ResourceConverter{ | ||
AssetType: VertexAIIndexEndpointAssetType, | ||
Convert: GetVertexAIIndexEndpointCaiObject, | ||
} | ||
} | ||
|
||
func GetVertexAIIndexEndpointCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]tpgresource.Asset, error) { | ||
name, err := tpgresource.AssetName(d, config, "//{{region}}-aiplatform.googleapis.com/projects/{{project}}/locations/{{region}}/indexEndpoints/{{name}}") | ||
if err != nil { | ||
return []tpgresource.Asset{}, err | ||
} | ||
if obj, err := GetVertexAIIndexEndpointApiObject(d, config); err == nil { | ||
return []tpgresource.Asset{{ | ||
Name: name, | ||
Type: VertexAIIndexEndpointAssetType, | ||
Resource: &tpgresource.AssetResource{ | ||
Version: "v1", | ||
DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/{{region}}-aiplatform/v1/rest", | ||
DiscoveryName: "IndexEndpoint", | ||
Data: obj, | ||
}, | ||
}}, nil | ||
} else { | ||
return []tpgresource.Asset{}, err | ||
} | ||
} | ||
|
||
func GetVertexAIIndexEndpointApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { | ||
obj := make(map[string]interface{}) | ||
displayNameProp, err := expandVertexAIIndexEndpointDisplayName(d.Get("display_name"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { | ||
obj["displayName"] = displayNameProp | ||
} | ||
descriptionProp, err := expandVertexAIIndexEndpointDescription(d.Get("description"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { | ||
obj["description"] = descriptionProp | ||
} | ||
labelsProp, err := expandVertexAIIndexEndpointLabels(d.Get("labels"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { | ||
obj["labels"] = labelsProp | ||
} | ||
networkProp, err := expandVertexAIIndexEndpointNetwork(d.Get("network"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(networkProp)) && (ok || !reflect.DeepEqual(v, networkProp)) { | ||
obj["network"] = networkProp | ||
} | ||
|
||
return obj, nil | ||
} | ||
|
||
func expandVertexAIIndexEndpointDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandVertexAIIndexEndpointDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandVertexAIIndexEndpointLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { | ||
if v == nil { | ||
return map[string]string{}, nil | ||
} | ||
m := make(map[string]string) | ||
for k, val := range v.(map[string]interface{}) { | ||
m[k] = val.(string) | ||
} | ||
return m, nil | ||
} | ||
|
||
func expandVertexAIIndexEndpointNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { | ||
return v, nil | ||
} |