diff --git a/mmv1/products/vertexai/api.yaml b/mmv1/products/vertexai/api.yaml index a68d7b29b864..e62e71a89701 100644 --- a/mmv1/products/vertexai/api.yaml +++ b/mmv1/products/vertexai/api.yaml @@ -277,6 +277,81 @@ objects: Configuration of the snapshot analysis based monitoring pipeline running interval. The value is rolled up to full day. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s". + +# Vertex AI Featurestore Entity Type Feature + - !ruby/object:Api::Resource + name: FeaturestoreEntitytypeFeature + base_url: '{{entitytype}}/features' + create_url: '{{entitytype}}/features?featureId={{name}}' + self_link: '{{entitytype}}/features/{{name}}' + min_version: beta + update_verb: :PATCH + update_mask: true + references: !ruby/object:Api::Resource::ReferenceLinks + guides: + 'Official Documentation': + 'https://cloud.google.com/vertex-ai/docs' + api: 'https://cloud.google.com/vertex-ai/docs/reference/rest/v1beta1/projects.locations.featurestores.entityTypes.features' + async: !ruby/object:Api::OpAsync + operation: !ruby/object:Api::OpAsync::Operation + path: 'name' + base_url: '{{op_id}}' + wait_ms: 1000 + result: !ruby/object:Api::OpAsync::Result + path: 'response' + resource_inside_response: true + status: !ruby/object:Api::OpAsync::Status + path: 'done' + complete: True + allowed: + - True + - False + error: !ruby/object:Api::OpAsync::Error + path: 'error' + message: 'message' + include_project: true + description: |- + Feature Metadata information that describes an attribute of an entity type. For example, apple is an entity type, and color is a feature that describes apple. + parameters: + - !ruby/object:Api::Type::String + name: entitytype + description: The name of the Featurestore to use, in the format projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entitytype}. + url_param_only: true + input: true + required: true + properties: + - !ruby/object:Api::Type::String + name: 'name' + description: The name of the feature. The feature can be up to 64 characters long and can consist only of ASCII Latin letters A-Z and a-z, underscore(_), and ASCII digits 0-9 starting with a letter. The value will be unique given an entity type. + input: true + url_param_only: true + pattern: '{{entitytype}}/features/{{name}}' + - !ruby/object:Api::Type::String + name: 'etag' + description: Used to perform consistent read-modify-write updates. + output: true + - !ruby/object:Api::Type::String + name: 'createTime' + output: true + description: | + The timestamp of when the entity type was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. + - !ruby/object:Api::Type::String + name: 'updateTime' + output: 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. + - !ruby/object:Api::Type::KeyValuePairs + name: 'labels' + description: | + A set of key/value label pairs to assign to the feature. + - !ruby/object:Api::Type::String + name: 'description' + description: Description of the feature. + - !ruby/object:Api::Type::String + name: 'valueType' + description: | + Type of Feature value. Immutable. https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.featurestores.entityTypes.features#ValueType + required: true # Vertex ML Metadata - !ruby/object:Api::Resource name: MetadataStore diff --git a/mmv1/products/vertexai/terraform.yaml b/mmv1/products/vertexai/terraform.yaml index c0b08b0dd35e..a8edc29f1d2e 100644 --- a/mmv1/products/vertexai/terraform.yaml +++ b/mmv1/products/vertexai/terraform.yaml @@ -79,7 +79,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides billing_account: :BILLING_ACCT test_vars_overrides: kms_key_name: 'BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name' - properties: etag: !ruby/object:Overrides::Terraform::PropertyOverride ignore_read: true @@ -89,6 +88,30 @@ overrides: !ruby/object:Overrides::ResourceOverrides pre_create: templates/terraform/constants/vertex_ai_featurestore_entitytype.go.erb pre_update: templates/terraform/constants/vertex_ai_featurestore_entitytype.go.erb pre_delete: templates/terraform/constants/vertex_ai_featurestore_entitytype.go.erb + FeaturestoreEntitytypeFeature: !ruby/object:Overrides::Terraform::ResourceOverride + import_format: ["{{%entitytype}}/features/{{name}}"] + autogen_async: false + examples: + - !ruby/object:Provider::Terraform::Examples + name: "vertex_ai_featurestore_entitytype_feature" + primary_resource_id: "feature" + vars: + name: "terraform" + project: "vertex-ai" + kms_key_name: "kms-name" + test_env_vars: + org_id: :ORG_ID + billing_account: :BILLING_ACCT + test_vars_overrides: + properties: + etag: !ruby/object:Overrides::Terraform::PropertyOverride + ignore_read: true + name: !ruby/object:Overrides::Terraform::PropertyOverride + custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb + custom_code: !ruby/object:Provider::Terraform::CustomCode + pre_create: templates/terraform/constants/vertex_ai_featurestore_entitytype_feature.go.erb + pre_update: templates/terraform/constants/vertex_ai_featurestore_entitytype_feature.go.erb + pre_delete: templates/terraform/constants/vertex_ai_featurestore_entitytype_feature.go.erb MetadataStore: !ruby/object:Overrides::Terraform::ResourceOverride autogen_async: false id_format: '{{name}}' diff --git a/mmv1/templates/terraform/constants/vertex_ai_featurestore_entitytype_feature.go.erb b/mmv1/templates/terraform/constants/vertex_ai_featurestore_entitytype_feature.go.erb new file mode 100644 index 000000000000..857082b84f35 --- /dev/null +++ b/mmv1/templates/terraform/constants/vertex_ai_featurestore_entitytype_feature.go.erb @@ -0,0 +1,9 @@ +if v, ok := d.GetOk("entitytype"); 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/examples/vertex_ai_featurestore_entitytype_feature.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_featurestore_entitytype_feature.tf.erb new file mode 100644 index 000000000000..e3b6fad54842 --- /dev/null +++ b/mmv1/templates/terraform/examples/vertex_ai_featurestore_entitytype_feature.tf.erb @@ -0,0 +1,37 @@ +resource "google_vertex_ai_featurestore" "featurestore" { + provider = google-beta + name = "<%= ctx[:vars]['name'] %>" + labels = { + foo = "bar" + } + region = "us-central1" + online_serving_config { + fixed_node_count = 2 + } +} + +resource "google_vertex_ai_featurestore_entitytype" "entity" { + provider = google-beta + name = "<%= ctx[:vars]['name'] %>" + labels = { + foo = "bar" + } + featurestore = google_vertex_ai_featurestore.featurestore.id + monitoring_config { + snapshot_analysis { + disabled = false + monitoring_interval = "86400s" + } + } +} + +resource "google_vertex_ai_featurestore_entitytype_feature" "feature" { + provider = google-beta + name = "<%= ctx[:vars]['name'] %>" + labels = { + foo = "bar" + } + entitytype = google_vertex_ai_featurestore_entitytype.entity.id + + value_type = "INT64_ARRAY" +} diff --git a/mmv1/templates/terraform/resource.erb b/mmv1/templates/terraform/resource.erb index 13eefeb1f01e..6e607e10d5f8 100644 --- a/mmv1/templates/terraform/resource.erb +++ b/mmv1/templates/terraform/resource.erb @@ -63,12 +63,6 @@ import ( timeouts ||= Api::Timeouts.new -%> -<% if object.async&.is_a? Api::OpAsync -%> - <% if object.async.include_project -%> -var project string - <% end -%> -<% end -%> - func resource<%= resource_name -%>() *schema.Resource { return &schema.Resource{ Create: resource<%= resource_name -%>Create, @@ -166,6 +160,9 @@ func resource<%= resource_name -%><%= prop.name.camelize(:upper) -%>SetStyleDiff <% end -%> func resource<%= resource_name -%>Create(d *schema.ResourceData, meta interface{}) error { +<% if object.async&.is_a?(Api::OpAsync) && object.async.include_project -%> + var project string +<% end -%> config := meta.(*Config) <% if object.custom_code.custom_create -%> <%= lines(compile(pwd + '/' + object.custom_code.custom_create)) -%> @@ -576,6 +573,9 @@ func resource<%= resource_name -%>Read(d *schema.ResourceData, meta interface{}) <% if updatable?(object, object.root_properties) -%> func resource<%= resource_name -%>Update(d *schema.ResourceData, meta interface{}) error { +<% if object.async&.is_a?(Api::OpAsync) && object.async.include_project -%> + var project string +<% end -%> config := meta.(*Config) userAgent, err := generateUserAgentString(d, config.userAgent) if err != nil { @@ -835,6 +835,9 @@ if <%= props.map { |prop| "d.HasChange(\"#{prop.name.underscore}\")" }.join ' || <% end # if updatable? -%> func resource<%= resource_name -%>Delete(d *schema.ResourceData, meta interface{}) error { +<% if object.async&.is_a?(Api::OpAsync) && object.async.include_project -%> + var project string +<% end -%> <% if object.skip_delete -%> log.Printf("[WARNING] <%= object.__product.name + " " + object.name %> resources" + " cannot be deleted from Google Cloud. The resource %s will be removed from Terraform" +