diff --git a/mmv1/products/vertexai/Models.yaml b/mmv1/products/vertexai/Models.yaml index 7924900ad03b..97fdd8deed3d 100644 --- a/mmv1/products/vertexai/Models.yaml +++ b/mmv1/products/vertexai/Models.yaml @@ -14,20 +14,27 @@ --- !ruby/object:Api::Resource name: Models base_url: projects/{{project}}/locations/{{region}}/models -self_link: 'projects/{{project}}/locations/{{region}}/models/{{name}}' -min_version: beta -immutable: true +create_url: 'projects/{{project}}/locations/{{region}}/modelsPRE_CREATE_REPLACE_ME' +delete_url: '{{name}}' +self_link: '{{name}}' + 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/v1/projects.locations.models' +description: |- + A trained machine learning Model. +id_format: '{{name}}' +autogen_async: false +exclude_import: true async: !ruby/object:Api::OpAsync + actions: + - create + - delete operation: !ruby/object:Api::OpAsync::Operation path: 'name' base_url: '{{op_id}}' wait_ms: 1000 - timeouts: !ruby/object:Api::Timeouts - insert_minutes: 40 result: !ruby/object:Api::OpAsync::Result path: 'response' resource_inside_response: true @@ -40,15 +47,13 @@ async: !ruby/object:Api::OpAsync error: !ruby/object:Api::OpAsync::Error path: 'error' message: 'message' -description: |- - A trained machine learning Model. -autogen_async: false -id_format: '{{name}}' -skip_sweeper: true +custom_code: !ruby/object:Provider::Terraform::CustomCode + decoder: templates/terraform/decoders/vertex_ai_models.go.erb + pre_create: templates/terraform/pre_create/vertex_ai_models.go.erb examples: - !ruby/object:Provider::Terraform::Examples - name: 'vertex_ai_model' - skip_test: true + name: 'vertex_ai_model_basic' + skip_import_test: true primary_resource_id: 'model' vars: name: 'test-model' @@ -65,9 +70,9 @@ properties: description: The name of the Model. This value may be up to 60 characters, and valid characters are [a-z0-9_]. The first character cannot be a number. - url_param_only: true - pattern: projects/{{project}}/locations/{{region}}/models/{{name}} - custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb + output: true + # url_param_only: true + custom_flatten: templates/terraform/custom_flatten/vertex_ai_name_from_model.go.erb - !ruby/object:Api::Type::String name: 'description' description: Description of the Model. @@ -99,27 +104,25 @@ properties: Points to a YAML file stored on Google Cloud Storage describing additional information about the Model, that is specific to it. - !ruby/object:Api::Type::NestedObject name: 'predictSchemata' - output: true description: | The schemata that describe formats of the Model's predictions and explanations as given and returned via PredictionService.Predict and PredictionService.Explain. - item_type: !ruby/object:Api::Type::NestedObject - properties: - - !ruby/object:Api::Type::String - name: instanceSchemaUri - immutable: true - description: | - Points to a YAML file stored on Google Cloud Storage describing the format of a single instance, which are used in PredictRequest.instances, ExplainRequest.instances and BatchPredictionJob.input_config. - - !ruby/object:Api::Type::String - name: parametersSchemaUri - immutable: true - description: | - Points to a YAML file stored on Google Cloud Storage describing the parameters of prediction and explanation via PredictRequest.parameters, ExplainRequest.parameters and BatchPredictionJob.model_parameters. - - !ruby/object:Api::Type::String - name: predictionSchemaUri - immutable: true - description: | - Points to a YAML file stored on Google Cloud Storage describing the format of a single prediction produced by this Model, which are returned via PredictResponse.predictions, ExplainResponse.explanations, and BatchPredictionJob.output_config. - - !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::String + name: instanceSchemaUri + immutable: true + description: | + Points to a YAML file stored on Google Cloud Storage describing the format of a single instance, which are used in PredictRequest.instances, ExplainRequest.instances and BatchPredictionJob.input_config. + - !ruby/object:Api::Type::String + name: parametersSchemaUri + immutable: true + description: | + Points to a YAML file stored on Google Cloud Storage describing the parameters of prediction and explanation via PredictRequest.parameters, ExplainRequest.parameters and BatchPredictionJob.model_parameters. + - !ruby/object:Api::Type::String + name: predictionSchemaUri + immutable: true + description: | + Points to a YAML file stored on Google Cloud Storage describing the format of a single prediction produced by this Model, which are returned via PredictResponse.predictions, ExplainResponse.explanations, and BatchPredictionJob.output_config. + - !ruby/object:Api::Type::Array name: 'supportedExportFormats' output: true description: | @@ -152,123 +155,121 @@ properties: name: 'containerSpec' description: | The specification of the container that is to be used when deploying this Model. - item_type: !ruby/object:Api::Type::NestedObject - properties: - - !ruby/object:Api::Type::String - name: 'imageUri' - required: true - immutable: true - description: URI of the Docker image to be used as the custom container for serving predictions. - - !ruby/object:Api::Type::Array - name: 'command' - immutable: true - description: Specifies the command that runs when the container starts. This overrides the container's ENTRYPOINT. - item_type: !ruby/object:Api::Type::String - - !ruby/object:Api::Type::Array - name: 'args' - immutable: true - description: Specifies arguments for the command that runs when the container starts. - item_type: !ruby/object:Api::Type::String - - !ruby/object:Api::Type::Array - name: 'env' - immutable: true - description: List of environment variables to set in the container. - item_type: !ruby/object:Api::Type::NestedObject - properties: - - !ruby/object:Api::Type::String - name: 'name' - required: true - description: name of the environment variable. Must be a valid C identifier. - - !ruby/object:Api::Type::String - name: 'value' - required: true - description: Variables that reference a $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. - - !ruby/object:Api::Type::Array - name: 'ports' - immutable: true - description: List of ports to expose from the container. - item_type: !ruby/object:Api::Type::NestedObject - properties: - - !ruby/object:Api::Type::Integer - name: 'containerPort' - required: true - description: The number of the port to expose on the pod's IP address. Must be a valid port number, between 1 and 65535 inclusive. - - !ruby/object:Api::Type::String - name: 'predictRoute' - immutable: true - description: HTTP path on the container to send prediction requests to. - - !ruby/object:Api::Type::String - name: 'healthRoute' - immutable: true - description: HTTP path on the container to send health checks to. - - !ruby/object:Api::Type::Array - name: 'grpcPorts' - immutable: true - description: List of ports to expose from the container. - item_type: !ruby/object:Api::Type::NestedObject - properties: - - !ruby/object:Api::Type::Integer - name: 'containerPort' - required: true - description: The number of the port to expose on the pod's IP address. Must be a valid port number, between 1 and 65535 inclusive. - - !ruby/object:Api::Type::String - name: 'deploymentTimeout' - immutable: true - description: Deployment timeout. Limit for deployment timeout is 2 hours. - - !ruby/object:Api::Type::String - name: 'sharedMemorySizeMb' - immutable: true - description: The amount of the VM memory to reserve as the shared memory for the model in megabytes. - - !ruby/object:Api::Type::NestedObject - name: 'startupProbe' - immutable: true - description: Specification for Kubernetes startup probe. + properties: + - !ruby/object:Api::Type::String + name: 'imageUri' + required: true + immutable: true + description: URI of the Docker image to be used as the custom container for serving predictions. + - !ruby/object:Api::Type::Array + name: 'command' + immutable: true + description: Specifies the command that runs when the container starts. This overrides the container's ENTRYPOINT. + item_type: Api::Type::String + - !ruby/object:Api::Type::Array + name: 'args' + immutable: true + description: Specifies arguments for the command that runs when the container starts. + item_type: Api::Type::String + - !ruby/object:Api::Type::Array + name: 'env' + immutable: true + description: List of environment variables to set in the container. + item_type: !ruby/object:Api::Type::NestedObject properties: - - !ruby/object:Api::Type::Integer - name: 'periodSeconds' - immutable: true - default_value: 10 - description: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1. Must be less than timeoutSeconds. - - !ruby/object:Api::Type::Integer - name: 'timeoutSeconds' - immutable: true - default_value: 1 - description: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. Must be greater or equal to periodSeconds. - - !ruby/object:Api::Type::NestedObject - name: 'exec' - description: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. Must be greater or equal to periodSeconds. - properties: - - !ruby/object:Api::Type::String - name: 'command' - description: Command is the command line to execute inside the container, the working directory for the command is root ('/') in the container's filesystem. - - !ruby/object:Api::Type::NestedObject - name: 'healthProbe' - immutable: true - description: Specification for Kubernetes readiness probe. + - !ruby/object:Api::Type::String + name: 'name' + required: true + description: name of the environment variable. Must be a valid C identifier. + - !ruby/object:Api::Type::String + name: 'value' + required: true + description: Variables that reference a $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. + - !ruby/object:Api::Type::Array + name: 'ports' + immutable: true + description: List of ports to expose from the container. + item_type: !ruby/object:Api::Type::NestedObject properties: - !ruby/object:Api::Type::Integer - name: 'periodSeconds' - immutable: true - default_value: 10 - description: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1. Must be less than timeoutSeconds. + name: 'containerPort' + required: true + description: The number of the port to expose on the pod's IP address. Must be a valid port number, between 1 and 65535 inclusive. + - !ruby/object:Api::Type::String + name: 'predictRoute' + immutable: true + description: HTTP path on the container to send prediction requests to. + - !ruby/object:Api::Type::String + name: 'healthRoute' + immutable: true + description: HTTP path on the container to send health checks to. + - !ruby/object:Api::Type::Array + name: 'grpcPorts' + immutable: true + description: List of ports to expose from the container. + item_type: !ruby/object:Api::Type::NestedObject + properties: - !ruby/object:Api::Type::Integer - name: 'timeoutSeconds' - immutable: true - default_value: 1 - description: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. Must be greater or equal to periodSeconds. - - !ruby/object:Api::Type::NestedObject - name: 'exec' - description: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. Must be greater or equal to periodSeconds. - properties: - - !ruby/object:Api::Type::String - name: 'command' - description: Command is the command line to execute inside the container, the working directory for the command is root ('/') in the container's filesystem. + name: 'containerPort' + required: true + description: The number of the port to expose on the pod's IP address. Must be a valid port number, between 1 and 65535 inclusive. + - !ruby/object:Api::Type::String + name: 'deploymentTimeout' + immutable: true + description: Deployment timeout. Limit for deployment timeout is 2 hours. + - !ruby/object:Api::Type::String + name: 'sharedMemorySizeMb' + immutable: true + description: The amount of the VM memory to reserve as the shared memory for the model in megabytes. + - !ruby/object:Api::Type::NestedObject + name: 'startupProbe' + immutable: true + description: Specification for Kubernetes startup probe. + properties: + - !ruby/object:Api::Type::Integer + name: 'periodSeconds' + immutable: true + default_value: 10 + description: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1. Must be less than timeoutSeconds. + - !ruby/object:Api::Type::Integer + name: 'timeoutSeconds' + immutable: true + default_value: 1 + description: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. Must be greater or equal to periodSeconds. + - !ruby/object:Api::Type::NestedObject + name: 'exec' + description: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. Must be greater or equal to periodSeconds. + properties: + - !ruby/object:Api::Type::String + name: 'command' + description: Command is the command line to execute inside the container, the working directory for the command is root ('/') in the container's filesystem. + - !ruby/object:Api::Type::NestedObject + name: 'healthProbe' + immutable: true + description: Specification for Kubernetes readiness probe. + properties: + - !ruby/object:Api::Type::Integer + name: 'periodSeconds' + immutable: true + default_value: 10 + description: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1. Must be less than timeoutSeconds. + - !ruby/object:Api::Type::Integer + name: 'timeoutSeconds' + immutable: true + default_value: 1 + description: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. Must be greater or equal to periodSeconds. + - !ruby/object:Api::Type::NestedObject + name: 'exec' + description: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. Must be greater or equal to periodSeconds. + properties: + - !ruby/object:Api::Type::String + name: 'command' + description: Command is the command line to execute inside the container, the working directory for the command is root ('/') in the container's filesystem. - !ruby/object:Api::Type::String name: 'artifactUri' immutable: true description: | The path to the directory containing the Model artifact and any of its supporting files. - - !ruby/object:Api::Type::String name: 'createTime' output: true @@ -284,12 +285,6 @@ properties: description: The display name of the Model. The name can be up to 128 characters long and can consist of any UTF-8 characters. - required: true - - !ruby/object:Api::Type::String - name: 'metadataSchemaUri' - description: |- - Points to a YAML file stored on Google Cloud Storage describing additional information about the Model, that is specific to it. Unset if the Model does not have any additional information. - output: true - !ruby/object:Api::Type::String name: 'etag' description: Used to perform consistent read-modify-write updates. @@ -299,7 +294,7 @@ properties: name: 'versionAliases' description: user provided version aliases so that a model version can be referenced via alias. - item_type: !ruby/object:Api::Type::String + item_type: Api::Type::String - !ruby/object:Api::Type::KeyValueLabels name: 'labels' description: The labels with user-defined metadata to organize your Models. @@ -417,4 +412,28 @@ properties: - bruteForceConfig description: |- Configuration options for using brute force search, which simply implements the - standard linear search in the database for each query. \ No newline at end of file + standard linear search in the database for each query. + - !ruby/object:Api::Type::String + name: 'sourceModel' + at_least_one_of: + - model + - sourceModel + description: | + The resource name of the Model to copy. That Model must be in the same Project + - !ruby/object:Api::Type::ResourceRef + name: 'model' + resource: 'Model' + imports: 'displayName' + at_least_one_of: + - sourceModel + - model + description: | + The Model to create. + - !ruby/object:Api::Type::String + name: 'modelID' + description: | + Copy sourceModel into a new Model with this ID. The ID will become the final component of the model resource name. + - !ruby/object:Api::Type::String + name: 'parentModel' + description: | + Specify this field to copy sourceModel into this existing Model as a new version. diff --git a/mmv1/templates/terraform/custom_flatten/vertex_ai_name_from_model.go.erb b/mmv1/templates/terraform/custom_flatten/vertex_ai_name_from_model.go.erb new file mode 100644 index 000000000000..d6dcef6856ec --- /dev/null +++ b/mmv1/templates/terraform/custom_flatten/vertex_ai_name_from_model.go.erb @@ -0,0 +1,7 @@ +func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if d.Get("name").(string) == "" { + return v.(string) + } + + return d.Get("name") +} \ No newline at end of file diff --git a/mmv1/templates/terraform/decoders/vertex_ai_models.go.erb b/mmv1/templates/terraform/decoders/vertex_ai_models.go.erb new file mode 100644 index 000000000000..66985ff32565 --- /dev/null +++ b/mmv1/templates/terraform/decoders/vertex_ai_models.go.erb @@ -0,0 +1,4 @@ +if res["model"] != "" { + res["name"] = res["model"] +} +return res, nil \ No newline at end of file diff --git a/mmv1/templates/terraform/examples/vertex_ai_model_basic.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_model_basic.tf.erb new file mode 100644 index 000000000000..4bbb7740aabc --- /dev/null +++ b/mmv1/templates/terraform/examples/vertex_ai_model_basic.tf.erb @@ -0,0 +1,13 @@ +resource "google_vertex_ai_models" "<%= ctx[:primary_resource_id] %>" { + display_name = "<%= ctx[:vars]['display_name'] %>" + description = "sample description" + labels = { + "key1" : "value1", + "key2" : "value2" + } + region = "us-central1" + encryption_spec { + kms_key_name = "<%= ctx[:vars]['kms_key_name'] %>" + } + depends_on = [google_kms_crypto_key_iam_member.crypto_key] +} \ No newline at end of file diff --git a/mmv1/templates/terraform/pre_create/vertex_ai_models.go.erb b/mmv1/templates/terraform/pre_create/vertex_ai_models.go.erb new file mode 100644 index 000000000000..d0dea95f6ce5 --- /dev/null +++ b/mmv1/templates/terraform/pre_create/vertex_ai_models.go.erb @@ -0,0 +1,9 @@ +var postRequestType string +if _, ok := d.GetOk("model"); ok { + postRequestType = ":upload" +} + +if _, ok := d.GetOk("source_model"); ok { + postRequestType = ":copy" +} +url = regexp.MustCompile("PRE_CREATE_REPLACE_ME").ReplaceAllLiteralString(url, postRequestType) \ No newline at end of file