From df3bea4b41403fd1d331c0c10438ba36595287c6 Mon Sep 17 00:00:00 2001 From: The Magician Date: Thu, 21 Dec 2023 06:40:51 -0800 Subject: [PATCH] add vertexai/featureonlinestore resource (#9632) (#1818) * rebase featureonlinestore based on merged changes * rebase based on merged featureonlinestore pr * fix pr suggestions featureonlinestore * fix documentation and pr comments featureonlinestore [upstream:f6b6532046e9886815386703ebdbfc9cfbcada93] Signed-off-by: Modular Magician --- go.mod | 2 +- go.sum | 4 +- .../vertexai/vertexai_feature_online_store.go | 141 ++++++++++++++++-- 3 files changed, 134 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index b2b87f6c8..901de7789 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/hashicorp/hcl/v2 v2.19.1 github.com/hashicorp/terraform-json v0.17.1 github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 - github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231220222615-4bacd328306a + github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231221143711-ed33a1cd9d55 github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index 8f396cdda..cc5d20d30 100644 --- a/go.sum +++ b/go.sum @@ -176,8 +176,8 @@ github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwU github.com/hashicorp/terraform-plugin-mux v0.8.0 h1:WCTP66mZ+iIaIrCNJnjPEYnVjawTshnDJu12BcXK1EI= github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 h1:wcOKYwPI9IorAJEBLzgclh3xVolO7ZorYd6U1vnok14= github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0/go.mod h1:qH/34G25Ugdj5FcM95cSoXzUgIbgfhVLXCcEcYaMwq8= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231220222615-4bacd328306a h1:bfZ4UBjAP7bUW1pE7l3CA2YmaaplIVbs6LfqPgYv0tY= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231220222615-4bacd328306a/go.mod h1:ynFcIK7qd2qWgPlZWwzOLrgeaQhVgHuWmMXxxMaifGw= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231221143711-ed33a1cd9d55 h1:J/u45h9HNUUx6+TNvs6t2gPP1uUC0svBOGU273rDpCU= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231221143711-ed33a1cd9d55/go.mod h1:ynFcIK7qd2qWgPlZWwzOLrgeaQhVgHuWmMXxxMaifGw= github.com/hashicorp/terraform-registry-address v0.2.2 h1:lPQBg403El8PPicg/qONZJDC6YlgCVbWDtNmmZKtBno= github.com/hashicorp/terraform-registry-address v0.2.2/go.mod h1:LtwNbCihUoUZ3RYriyS2wF/lGPB6gF9ICLRtuDk7hSo= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= diff --git a/tfplan2cai/converters/google/resources/services/vertexai/vertexai_feature_online_store.go b/tfplan2cai/converters/google/resources/services/vertexai/vertexai_feature_online_store.go index fddd49201..1ac4ff8c2 100644 --- a/tfplan2cai/converters/google/resources/services/vertexai/vertexai_feature_online_store.go +++ b/tfplan2cai/converters/google/resources/services/vertexai/vertexai_feature_online_store.go @@ -54,18 +54,30 @@ func GetVertexAIFeatureOnlineStoreCaiObject(d tpgresource.TerraformResourceData, func GetVertexAIFeatureOnlineStoreApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { obj := make(map[string]interface{}) - nameProp, err := expandVertexAIFeatureOnlineStoreName(d.Get("name"), d, config) - if err != nil { - return nil, err - } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { - obj["name"] = nameProp - } bigtableProp, err := expandVertexAIFeatureOnlineStoreBigtable(d.Get("bigtable"), d, config) if err != nil { return nil, err } 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 nil, err + } else if v, ok := d.GetOkExists("optimized"); ok || !reflect.DeepEqual(v, optimizedProp) { + obj["optimized"] = optimizedProp + } + dedicatedServingEndpointProp, err := expandVertexAIFeatureOnlineStoreDedicatedServingEndpoint(d.Get("dedicated_serving_endpoint"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("dedicated_serving_endpoint"); !tpgresource.IsEmptyValue(reflect.ValueOf(dedicatedServingEndpointProp)) && (ok || !reflect.DeepEqual(v, dedicatedServingEndpointProp)) { + obj["dedicatedServingEndpoint"] = dedicatedServingEndpointProp + } + embeddingManagementProp, err := expandVertexAIFeatureOnlineStoreEmbeddingManagement(d.Get("embedding_management"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("embedding_management"); !tpgresource.IsEmptyValue(reflect.ValueOf(embeddingManagementProp)) && (ok || !reflect.DeepEqual(v, embeddingManagementProp)) { + obj["embeddingManagement"] = embeddingManagementProp + } labelsProp, err := expandVertexAIFeatureOnlineStoreEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return nil, err @@ -76,10 +88,6 @@ func GetVertexAIFeatureOnlineStoreApiObject(d tpgresource.TerraformResourceData, return obj, nil } -func expandVertexAIFeatureOnlineStoreName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandVertexAIFeatureOnlineStoreBigtable(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { @@ -144,6 +152,119 @@ 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 expandVertexAIFeatureOnlineStoreDedicatedServingEndpoint(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedPublicEndpointDomainName, err := expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPublicEndpointDomainName(original["public_endpoint_domain_name"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPublicEndpointDomainName); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["publicEndpointDomainName"] = transformedPublicEndpointDomainName + } + + transformedServiceAttachment, err := expandVertexAIFeatureOnlineStoreDedicatedServingEndpointServiceAttachment(original["service_attachment"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedServiceAttachment); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["serviceAttachment"] = transformedServiceAttachment + } + + transformedPrivateServiceConnectConfig, err := expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfig(original["private_service_connect_config"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedPrivateServiceConnectConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["privateServiceConnectConfig"] = transformedPrivateServiceConnectConfig + } + + return transformed, nil +} + +func expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPublicEndpointDomainName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandVertexAIFeatureOnlineStoreDedicatedServingEndpointServiceAttachment(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedEnablePrivateServiceConnect, err := expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfigEnablePrivateServiceConnect(original["enable_private_service_connect"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedEnablePrivateServiceConnect); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["enablePrivateServiceConnect"] = transformedEnablePrivateServiceConnect + } + + transformedProjectAllowlist, err := expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfigProjectAllowlist(original["project_allowlist"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedProjectAllowlist); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["projectAllowlist"] = transformedProjectAllowlist + } + + return transformed, nil +} + +func expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfigEnablePrivateServiceConnect(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfigProjectAllowlist(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandVertexAIFeatureOnlineStoreEmbeddingManagement(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil + } + raw := l[0] + original := raw.(map[string]interface{}) + transformed := make(map[string]interface{}) + + transformedEnabled, err := expandVertexAIFeatureOnlineStoreEmbeddingManagementEnabled(original["enabled"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedEnabled); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["enabled"] = transformedEnabled + } + + return transformed, nil +} + +func expandVertexAIFeatureOnlineStoreEmbeddingManagementEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandVertexAIFeatureOnlineStoreEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil