diff --git a/.changelog/9438.txt b/.changelog/9438.txt new file mode 100644 index 0000000000..83607e311e --- /dev/null +++ b/.changelog/9438.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +provider: backfilled `terraform_labels` for some immutable resources, so resource recreation won't happen during provider upgrade from 4.X to 5.7 +``` diff --git a/google-beta/services/beyondcorp/resource_beyondcorp_app_gateway.go b/google-beta/services/beyondcorp/resource_beyondcorp_app_gateway.go index d8e99513a6..b74c0b246e 100644 --- a/google-beta/services/beyondcorp/resource_beyondcorp_app_gateway.go +++ b/google-beta/services/beyondcorp/resource_beyondcorp_app_gateway.go @@ -18,6 +18,7 @@ package beyondcorp import ( + "context" "fmt" "log" "reflect" @@ -46,6 +47,15 @@ func ResourceBeyondcorpAppGateway() *schema.Resource { Delete: schema.DefaultTimeout(20 * time.Minute), }, + SchemaVersion: 1, + + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceBeyondcorpAppGatewayResourceV0().CoreConfigSchema().ImpliedType(), + Upgrade: ResourceBeyondcorpAppGatewayUpgradeV0, + Version: 0, + }, + }, CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, @@ -506,3 +516,110 @@ func expandBeyondcorpAppGatewayEffectiveLabels(v interface{}, d tpgresource.Terr } return m, nil } + +func resourceBeyondcorpAppGatewayResourceV0() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `ID of the AppGateway.`, + }, + "display_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `An arbitrary user-provided name for the AppGateway.`, + }, + "host_type": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"HOST_TYPE_UNSPECIFIED", "GCP_REGIONAL_MIG", ""}), + Description: `The type of hosting used by the AppGateway. Default value: "HOST_TYPE_UNSPECIFIED" Possible values: ["HOST_TYPE_UNSPECIFIED", "GCP_REGIONAL_MIG"]`, + Default: "HOST_TYPE_UNSPECIFIED", + }, + "labels": { + Type: schema.TypeMap, + Optional: true, + ForceNew: true, + Description: `Resource labels to represent user provided metadata. + + +**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. +Please refer to the field 'effective_labels' for all of the labels present on the resource.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "region": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `The region of the AppGateway.`, + }, + "type": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"TYPE_UNSPECIFIED", "TCP_PROXY", ""}), + Description: `The type of network connectivity used by the AppGateway. Default value: "TYPE_UNSPECIFIED" Possible values: ["TYPE_UNSPECIFIED", "TCP_PROXY"]`, + Default: "TYPE_UNSPECIFIED", + }, + "allocated_connections": { + Type: schema.TypeList, + Computed: true, + Description: `A list of connections allocated for the Gateway.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ingress_port": { + Type: schema.TypeInt, + Optional: true, + Description: `The ingress port of an allocated connection.`, + }, + "psc_uri": { + Type: schema.TypeString, + Optional: true, + Description: `The PSC uri of an allocated connection.`, + }, + }, + }, + }, + "effective_labels": { + Type: schema.TypeMap, + Computed: true, + ForceNew: true, + Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "state": { + Type: schema.TypeString, + Computed: true, + Description: `Represents the different states of a AppGateway.`, + }, + "terraform_labels": { + Type: schema.TypeMap, + Computed: true, + ForceNew: true, + Description: `The combination of labels configured directly on the resource + and default labels configured on the provider.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "uri": { + Type: schema.TypeString, + Computed: true, + Description: `Server-defined URI for this resource.`, + }, + "project": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + }, + UseJSONNumber: true, + } +} + +func ResourceBeyondcorpAppGatewayUpgradeV0(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + return tpgresource.TerraformLabelsStateUpgrade(rawState) +} diff --git a/google-beta/services/bigquery/resource_bigquery_job.go b/google-beta/services/bigquery/resource_bigquery_job.go index 3e201fa323..6f4eb50bd7 100644 --- a/google-beta/services/bigquery/resource_bigquery_job.go +++ b/google-beta/services/bigquery/resource_bigquery_job.go @@ -18,6 +18,7 @@ package bigquery import ( + "context" "fmt" "log" "reflect" @@ -55,6 +56,15 @@ func ResourceBigQueryJob() *schema.Resource { Delete: schema.DefaultTimeout(20 * time.Minute), }, + SchemaVersion: 1, + + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceBigQueryJobResourceV0().CoreConfigSchema().ImpliedType(), + Upgrade: ResourceBigQueryJobUpgradeV0, + Version: 0, + }, + }, CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, @@ -3248,3 +3258,952 @@ func resourceBigQueryJobEncoder(d *schema.ResourceData, meta interface{}, obj ma obj["jobReference"].(map[string]interface{})["project"] = project return obj, nil } + +func resourceBigQueryJobResourceV0() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "copy": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Copies a table.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "source_tables": { + Type: schema.TypeList, + Required: true, + ForceNew: true, + Description: `Source tables to copy.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "table_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: tpgresource.CompareSelfLinkRelativePaths, + Description: `The table. Can be specified '{{table_id}}' if 'project_id' and 'dataset_id' are also set, +or of the form 'projects/{{project}}/datasets/{{dataset_id}}/tables/{{table_id}}' if not.`, + }, + "dataset_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `The ID of the dataset containing this table.`, + }, + "project_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `The ID of the project containing this table.`, + }, + }, + }, + }, + "create_disposition": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"CREATE_IF_NEEDED", "CREATE_NEVER", ""}), + Description: `Specifies whether the job is allowed to create new tables. The following values are supported: +CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. +CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in the job result. +Creation, truncation and append actions occur as one atomic update upon job completion Default value: "CREATE_IF_NEEDED" Possible values: ["CREATE_IF_NEEDED", "CREATE_NEVER"]`, + Default: "CREATE_IF_NEEDED", + }, + "destination_encryption_configuration": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Custom encryption configuration (e.g., Cloud KMS keys)`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "kms_key_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `Describes the Cloud KMS encryption key that will be used to protect destination BigQuery table. +The BigQuery Service Account associated with your project requires access to this encryption key.`, + }, + "kms_key_version": { + Type: schema.TypeString, + Computed: true, + Description: `Describes the Cloud KMS encryption key version used to protect destination BigQuery table.`, + }, + }, + }, + }, + "destination_table": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `The destination table.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "table_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: tpgresource.CompareSelfLinkRelativePaths, + Description: `The table. Can be specified '{{table_id}}' if 'project_id' and 'dataset_id' are also set, +or of the form 'projects/{{project}}/datasets/{{dataset_id}}/tables/{{table_id}}' if not.`, + }, + "dataset_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `The ID of the dataset containing this table.`, + }, + "project_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `The ID of the project containing this table.`, + }, + }, + }, + }, + "write_disposition": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"WRITE_TRUNCATE", "WRITE_APPEND", "WRITE_EMPTY", ""}), + Description: `Specifies the action that occurs if the destination table already exists. The following values are supported: +WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the table data and uses the schema from the query result. +WRITE_APPEND: If the table already exists, BigQuery appends the data to the table. +WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. +Each action is atomic and only occurs if BigQuery is able to complete the job successfully. +Creation, truncation and append actions occur as one atomic update upon job completion. Default value: "WRITE_EMPTY" Possible values: ["WRITE_TRUNCATE", "WRITE_APPEND", "WRITE_EMPTY"]`, + Default: "WRITE_EMPTY", + }, + }, + }, + ExactlyOneOf: []string{"query", "load", "copy", "extract"}, + }, + "extract": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Configures an extract job.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "destination_uris": { + Type: schema.TypeList, + Required: true, + ForceNew: true, + Description: `A list of fully-qualified Google Cloud Storage URIs where the extracted table should be written.`, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "compression": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `The compression type to use for exported files. Possible values include GZIP, DEFLATE, SNAPPY, and NONE. +The default value is NONE. DEFLATE and SNAPPY are only supported for Avro.`, + Default: "NONE", + }, + "destination_format": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `The exported file format. Possible values include CSV, NEWLINE_DELIMITED_JSON and AVRO for tables and SAVED_MODEL for models. +The default value for tables is CSV. Tables with nested or repeated fields cannot be exported as CSV. +The default value for models is SAVED_MODEL.`, + }, + "field_delimiter": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `When extracting data in CSV format, this defines the delimiter to use between fields in the exported data. +Default is ','`, + }, + "print_header": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `Whether to print out a header row in the results. Default is true.`, + Default: true, + }, + "source_model": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `A reference to the model being exported.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "dataset_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The ID of the dataset containing this model.`, + }, + "model_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The ID of the model.`, + }, + "project_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The ID of the project containing this model.`, + }, + }, + }, + ExactlyOneOf: []string{"extract.0.source_table", "extract.0.source_model"}, + }, + "source_table": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `A reference to the table being exported.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "table_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: tpgresource.CompareSelfLinkRelativePaths, + Description: `The table. Can be specified '{{table_id}}' if 'project_id' and 'dataset_id' are also set, +or of the form 'projects/{{project}}/datasets/{{dataset_id}}/tables/{{table_id}}' if not.`, + }, + "dataset_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `The ID of the dataset containing this table.`, + }, + "project_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `The ID of the project containing this table.`, + }, + }, + }, + ExactlyOneOf: []string{"extract.0.source_table", "extract.0.source_model"}, + }, + "use_avro_logical_types": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `Whether to use logical types when extracting to AVRO format.`, + }, + }, + }, + ExactlyOneOf: []string{"query", "load", "copy", "extract"}, + }, + "job_timeout_ms": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `Job timeout in milliseconds. If this time limit is exceeded, BigQuery may attempt to terminate the job.`, + }, + "labels": { + Type: schema.TypeMap, + Optional: true, + ForceNew: true, + Description: `The labels associated with this job. You can use these to organize and group your jobs. + + +**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. +Please refer to the field 'effective_labels' for all of the labels present on the resource.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "load": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Configures a load job.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "destination_table": { + Type: schema.TypeList, + Required: true, + ForceNew: true, + Description: `The destination table to load the data into.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "table_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: tpgresource.CompareSelfLinkRelativePaths, + Description: `The table. Can be specified '{{table_id}}' if 'project_id' and 'dataset_id' are also set, +or of the form 'projects/{{project}}/datasets/{{dataset_id}}/tables/{{table_id}}' if not.`, + }, + "dataset_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `The ID of the dataset containing this table.`, + }, + "project_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `The ID of the project containing this table.`, + }, + }, + }, + }, + "source_uris": { + Type: schema.TypeList, + Required: true, + ForceNew: true, + Description: `The fully-qualified URIs that point to your data in Google Cloud. +For Google Cloud Storage URIs: Each URI can contain one '\*' wildcard character +and it must come after the 'bucket' name. Size limits related to load jobs apply +to external data sources. For Google Cloud Bigtable URIs: Exactly one URI can be +specified and it has be a fully specified and valid HTTPS URL for a Google Cloud Bigtable table. +For Google Cloud Datastore backups: Exactly one URI can be specified. Also, the '\*' wildcard character is not allowed.`, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "allow_jagged_rows": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `Accept rows that are missing trailing optional columns. The missing values are treated as nulls. +If false, records with missing trailing columns are treated as bad records, and if there are too many bad records, +an invalid error is returned in the job result. The default value is false. Only applicable to CSV, ignored for other formats.`, + Default: false, + }, + "allow_quoted_newlines": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `Indicates if BigQuery should allow quoted data sections that contain newline characters in a CSV file. +The default value is false.`, + Default: false, + }, + "autodetect": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `Indicates if we should automatically infer the options and schema for CSV and JSON sources.`, + }, + "create_disposition": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"CREATE_IF_NEEDED", "CREATE_NEVER", ""}), + Description: `Specifies whether the job is allowed to create new tables. The following values are supported: +CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. +CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in the job result. +Creation, truncation and append actions occur as one atomic update upon job completion Default value: "CREATE_IF_NEEDED" Possible values: ["CREATE_IF_NEEDED", "CREATE_NEVER"]`, + Default: "CREATE_IF_NEEDED", + }, + "destination_encryption_configuration": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Custom encryption configuration (e.g., Cloud KMS keys)`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "kms_key_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `Describes the Cloud KMS encryption key that will be used to protect destination BigQuery table. +The BigQuery Service Account associated with your project requires access to this encryption key.`, + }, + "kms_key_version": { + Type: schema.TypeString, + Computed: true, + Description: `Describes the Cloud KMS encryption key version used to protect destination BigQuery table.`, + }, + }, + }, + }, + "encoding": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `The character encoding of the data. The supported values are UTF-8 or ISO-8859-1. +The default value is UTF-8. BigQuery decodes the data after the raw, binary data +has been split using the values of the quote and fieldDelimiter properties.`, + Default: "UTF-8", + }, + "field_delimiter": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `The separator for fields in a CSV file. The separator can be any ISO-8859-1 single-byte character. +To use a character in the range 128-255, you must encode the character as UTF8. BigQuery converts +the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the +data in its raw, binary state. BigQuery also supports the escape sequence "\t" to specify a tab separator. +The default value is a comma (',').`, + }, + "ignore_unknown_values": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `Indicates if BigQuery should allow extra values that are not represented in the table schema. +If true, the extra values are ignored. If false, records with extra columns are treated as bad records, +and if there are too many bad records, an invalid error is returned in the job result. +The default value is false. The sourceFormat property determines what BigQuery treats as an extra value: +CSV: Trailing columns +JSON: Named values that don't match any column names`, + Default: false, + }, + "json_extension": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `If sourceFormat is set to newline-delimited JSON, indicates whether it should be processed as a JSON variant such as GeoJSON. +For a sourceFormat other than JSON, omit this field. If the sourceFormat is newline-delimited JSON: - for newline-delimited +GeoJSON: set to GEOJSON.`, + }, + "max_bad_records": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + Description: `The maximum number of bad records that BigQuery can ignore when running the job. If the number of bad records exceeds this value, +an invalid error is returned in the job result. The default value is 0, which requires that all records are valid.`, + Default: 0, + }, + "null_marker": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `Specifies a string that represents a null value in a CSV file. For example, if you specify "\N", BigQuery interprets "\N" as a null value +when loading a CSV file. The default value is the empty string. If you set this property to a custom value, BigQuery throws an error if an +empty string is present for all data types except for STRING and BYTE. For STRING and BYTE columns, BigQuery interprets the empty string as +an empty value.`, + Default: "", + }, + "parquet_options": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Parquet Options for load and make external tables.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "enable_list_inference": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `If sourceFormat is set to PARQUET, indicates whether to use schema inference specifically for Parquet LIST logical type.`, + AtLeastOneOf: []string{"load.0.parquet_options.0.enum_as_string", "load.0.parquet_options.0.enable_list_inference"}, + }, + "enum_as_string": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `If sourceFormat is set to PARQUET, indicates whether to infer Parquet ENUM logical type as STRING instead of BYTES by default.`, + }, + }, + }, + }, + "projection_fields": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `If sourceFormat is set to "DATASTORE_BACKUP", indicates which entity properties to load into BigQuery from a Cloud Datastore backup. +Property names are case sensitive and must be top-level properties. If no properties are specified, BigQuery loads all properties. +If any named property isn't found in the Cloud Datastore backup, an invalid error is returned in the job result.`, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "quote": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `The value that is used to quote data sections in a CSV file. BigQuery converts the string to ISO-8859-1 encoding, +and then uses the first byte of the encoded string to split the data in its raw, binary state. +The default value is a double-quote ('"'). If your data does not contain quoted sections, set the property value to an empty string. +If your data contains quoted newline characters, you must also set the allowQuotedNewlines property to true.`, + }, + "schema_update_options": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Allows the schema of the destination table to be updated as a side effect of the load job if a schema is autodetected or +supplied in the job configuration. Schema update options are supported in two cases: when writeDisposition is WRITE_APPEND; +when writeDisposition is WRITE_TRUNCATE and the destination table is a partition of a table, specified by partition decorators. +For normal tables, WRITE_TRUNCATE will always overwrite the schema. One or more of the following values are specified: +ALLOW_FIELD_ADDITION: allow adding a nullable field to the schema. +ALLOW_FIELD_RELAXATION: allow relaxing a required field in the original schema to nullable.`, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "skip_leading_rows": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + ValidateFunc: validation.IntAtLeast(0), + Description: `The number of rows at the top of a CSV file that BigQuery will skip when loading the data. +The default value is 0. This property is useful if you have header rows in the file that should be skipped. +When autodetect is on, the behavior is the following: +skipLeadingRows unspecified - Autodetect tries to detect headers in the first row. If they are not detected, +the row is read as data. Otherwise data is read starting from the second row. +skipLeadingRows is 0 - Instructs autodetect that there are no headers and data should be read starting from the first row. +skipLeadingRows = N > 0 - Autodetect skips N-1 rows and tries to detect headers in row N. If headers are not detected, +row N is just skipped. Otherwise row N is used to extract column names for the detected schema.`, + Default: 0, + }, + "source_format": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `The format of the data files. For CSV files, specify "CSV". For datastore backups, specify "DATASTORE_BACKUP". +For newline-delimited JSON, specify "NEWLINE_DELIMITED_JSON". For Avro, specify "AVRO". For parquet, specify "PARQUET". +For orc, specify "ORC". [Beta] For Bigtable, specify "BIGTABLE". +The default value is CSV.`, + Default: "CSV", + }, + "time_partitioning": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Time-based partitioning specification for the destination table.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "type": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The only type supported is DAY, which will generate one partition per day. Providing an empty string used to cause an error, +but in OnePlatform the field will be treated as unset.`, + }, + "expiration_ms": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `Number of milliseconds for which to keep the storage for a partition. A wrapper is used here because 0 is an invalid value.`, + }, + "field": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `If not set, the table is partitioned by pseudo column '_PARTITIONTIME'; if set, the table is partitioned by this field. +The field must be a top-level TIMESTAMP or DATE field. Its mode must be NULLABLE or REQUIRED. +A wrapper is used here because an empty string is an invalid value.`, + }, + }, + }, + }, + "write_disposition": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"WRITE_TRUNCATE", "WRITE_APPEND", "WRITE_EMPTY", ""}), + Description: `Specifies the action that occurs if the destination table already exists. The following values are supported: +WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the table data and uses the schema from the query result. +WRITE_APPEND: If the table already exists, BigQuery appends the data to the table. +WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. +Each action is atomic and only occurs if BigQuery is able to complete the job successfully. +Creation, truncation and append actions occur as one atomic update upon job completion. Default value: "WRITE_EMPTY" Possible values: ["WRITE_TRUNCATE", "WRITE_APPEND", "WRITE_EMPTY"]`, + Default: "WRITE_EMPTY", + }, + }, + }, + ExactlyOneOf: []string{"query", "load", "copy", "extract"}, + }, + "query": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Configures a query job.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "query": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `SQL query text to execute. The useLegacySql field can be used to indicate whether the query uses legacy SQL or standard SQL. +*NOTE*: queries containing [DML language](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-manipulation-language) +('DELETE', 'UPDATE', 'MERGE', 'INSERT') must specify 'create_disposition = ""' and 'write_disposition = ""'.`, + }, + "allow_large_results": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `If true and query uses legacy SQL dialect, allows the query to produce arbitrarily large result tables at a slight cost in performance. +Requires destinationTable to be set. For standard SQL queries, this flag is ignored and large results are always allowed. +However, you must still set destinationTable when result size exceeds the allowed maximum response size.`, + }, + "create_disposition": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"CREATE_IF_NEEDED", "CREATE_NEVER", ""}), + Description: `Specifies whether the job is allowed to create new tables. The following values are supported: +CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. +CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in the job result. +Creation, truncation and append actions occur as one atomic update upon job completion Default value: "CREATE_IF_NEEDED" Possible values: ["CREATE_IF_NEEDED", "CREATE_NEVER"]`, + Default: "CREATE_IF_NEEDED", + }, + "default_dataset": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Specifies the default dataset to use for unqualified table names in the query. Note that this does not alter behavior of unqualified dataset names.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "dataset_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: tpgresource.CompareSelfLinkRelativePaths, + Description: `The dataset. Can be specified '{{dataset_id}}' if 'project_id' is also set, +or of the form 'projects/{{project}}/datasets/{{dataset_id}}' if not.`, + }, + "project_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `The ID of the project containing this table.`, + }, + }, + }, + }, + "destination_encryption_configuration": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Custom encryption configuration (e.g., Cloud KMS keys)`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "kms_key_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `Describes the Cloud KMS encryption key that will be used to protect destination BigQuery table. +The BigQuery Service Account associated with your project requires access to this encryption key.`, + }, + "kms_key_version": { + Type: schema.TypeString, + Computed: true, + Description: `Describes the Cloud KMS encryption key version used to protect destination BigQuery table.`, + }, + }, + }, + }, + "destination_table": { + Type: schema.TypeList, + Computed: true, + Optional: true, + ForceNew: true, + Description: `Describes the table where the query results should be stored. +This property must be set for large results that exceed the maximum response size. +For queries that produce anonymous (cached) results, this field will be populated by BigQuery.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "table_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: tpgresource.CompareSelfLinkRelativePaths, + Description: `The table. Can be specified '{{table_id}}' if 'project_id' and 'dataset_id' are also set, +or of the form 'projects/{{project}}/datasets/{{dataset_id}}/tables/{{table_id}}' if not.`, + }, + "dataset_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `The ID of the dataset containing this table.`, + }, + "project_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + Description: `The ID of the project containing this table.`, + }, + }, + }, + }, + "flatten_results": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `If true and query uses legacy SQL dialect, flattens all nested and repeated fields in the query results. +allowLargeResults must be true if this is set to false. For standard SQL queries, this flag is ignored and results are never flattened.`, + }, + "maximum_billing_tier": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + Description: `Limits the billing tier for this job. Queries that have resource usage beyond this tier will fail (without incurring a charge). +If unspecified, this will be set to your project default.`, + }, + "maximum_bytes_billed": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `Limits the bytes billed for this job. Queries that will have bytes billed beyond this limit will fail (without incurring a charge). +If unspecified, this will be set to your project default.`, + }, + "parameter_mode": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `Standard SQL only. Set to POSITIONAL to use positional (?) query parameters or to NAMED to use named (@myparam) query parameters in this query.`, + }, + "priority": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"INTERACTIVE", "BATCH", ""}), + Description: `Specifies a priority for the query. Default value: "INTERACTIVE" Possible values: ["INTERACTIVE", "BATCH"]`, + Default: "INTERACTIVE", + }, + "schema_update_options": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Allows the schema of the destination table to be updated as a side effect of the query job. +Schema update options are supported in two cases: when writeDisposition is WRITE_APPEND; +when writeDisposition is WRITE_TRUNCATE and the destination table is a partition of a table, +specified by partition decorators. For normal tables, WRITE_TRUNCATE will always overwrite the schema. +One or more of the following values are specified: +ALLOW_FIELD_ADDITION: allow adding a nullable field to the schema. +ALLOW_FIELD_RELAXATION: allow relaxing a required field in the original schema to nullable.`, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "script_options": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Options controlling the execution of scripts.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key_result_statement": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"LAST", "FIRST_SELECT", ""}), + Description: `Determines which statement in the script represents the "key result", +used to populate the schema and query results of the script job. Possible values: ["LAST", "FIRST_SELECT"]`, + AtLeastOneOf: []string{"query.0.script_options.0.statement_timeout_ms", "query.0.script_options.0.statement_byte_budget", "query.0.script_options.0.key_result_statement"}, + }, + "statement_byte_budget": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `Limit on the number of bytes billed per statement. Exceeding this budget results in an error.`, + AtLeastOneOf: []string{"query.0.script_options.0.statement_timeout_ms", "query.0.script_options.0.statement_byte_budget", "query.0.script_options.0.key_result_statement"}, + }, + "statement_timeout_ms": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `Timeout period for each statement in a script.`, + AtLeastOneOf: []string{"query.0.script_options.0.statement_timeout_ms", "query.0.script_options.0.statement_byte_budget", "query.0.script_options.0.key_result_statement"}, + }, + }, + }, + }, + "use_legacy_sql": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `Specifies whether to use BigQuery's legacy SQL dialect for this query. The default value is true. +If set to false, the query will use BigQuery's standard SQL.`, + }, + "use_query_cache": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `Whether to look for the result in the query cache. The query cache is a best-effort cache that will be flushed whenever +tables in the query are modified. Moreover, the query cache is only available when a query does not have a destination table specified. +The default value is true.`, + Default: true, + }, + "user_defined_function_resources": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Describes user-defined function resources used in the query.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "inline_code": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `An inline resource that contains code for a user-defined function (UDF). +Providing a inline code resource is equivalent to providing a URI for a file containing the same code.`, + }, + "resource_uri": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `A code resource to load from a Google Cloud Storage URI (gs://bucket/path).`, + }, + }, + }, + }, + "write_disposition": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"WRITE_TRUNCATE", "WRITE_APPEND", "WRITE_EMPTY", ""}), + Description: `Specifies the action that occurs if the destination table already exists. The following values are supported: +WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the table data and uses the schema from the query result. +WRITE_APPEND: If the table already exists, BigQuery appends the data to the table. +WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. +Each action is atomic and only occurs if BigQuery is able to complete the job successfully. +Creation, truncation and append actions occur as one atomic update upon job completion. Default value: "WRITE_EMPTY" Possible values: ["WRITE_TRUNCATE", "WRITE_APPEND", "WRITE_EMPTY"]`, + Default: "WRITE_EMPTY", + }, + }, + }, + ExactlyOneOf: []string{"query", "load", "copy", "extract"}, + }, + "effective_labels": { + Type: schema.TypeMap, + Computed: true, + ForceNew: true, + Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "job_type": { + Type: schema.TypeString, + Computed: true, + Description: `The type of the job.`, + }, + "terraform_labels": { + Type: schema.TypeMap, + Computed: true, + ForceNew: true, + Description: `The combination of labels configured directly on the resource + and default labels configured on the provider.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + + "job_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The ID of the job. The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores (_), or dashes (-). The maximum length is 1,024 characters.`, + }, + "location": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `The geographic location of the job. The default value is US.`, + Default: "US", + }, + + "status": { + Type: schema.TypeList, + Computed: true, + Description: `The status of this job. Examine this value when polling an asynchronous job to see if the job is complete.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "error_result": { + Type: schema.TypeList, + Computed: true, + Description: `Final error result of the job. If present, indicates that the job has completed and was unsuccessful.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "location": { + Type: schema.TypeString, + Optional: true, + Description: `Specifies where the error occurred, if present.`, + }, + "message": { + Type: schema.TypeString, + Optional: true, + Description: `A human-readable description of the error.`, + }, + "reason": { + Type: schema.TypeString, + Optional: true, + Description: `A short error code that summarizes the error.`, + }, + }, + }, + }, + "errors": { + Type: schema.TypeList, + Computed: true, + Description: `The first errors encountered during the running of the job. The final message +includes the number of errors that caused the process to stop. Errors here do +not necessarily mean that the job has not completed or was unsuccessful.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "location": { + Type: schema.TypeString, + Optional: true, + Description: `Specifies where the error occurred, if present.`, + }, + "message": { + Type: schema.TypeString, + Optional: true, + Description: `A human-readable description of the error.`, + }, + "reason": { + Type: schema.TypeString, + Optional: true, + Description: `A short error code that summarizes the error.`, + }, + }, + }, + }, + "state": { + Type: schema.TypeString, + Computed: true, + Description: `Running state of the job. Valid states include 'PENDING', 'RUNNING', and 'DONE'.`, + }, + }, + }, + }, + "user_email": { + Type: schema.TypeString, + Computed: true, + Description: `Email address of the user who ran the job.`, + }, + "project": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + }, + UseJSONNumber: true, + } +} + +func ResourceBigQueryJobUpgradeV0(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + return tpgresource.TerraformLabelsStateUpgrade(rawState) +} diff --git a/google-beta/services/certificatemanager/resource_certificate_manager_certificate_issuance_config.go b/google-beta/services/certificatemanager/resource_certificate_manager_certificate_issuance_config.go index a09a5410ef..2572a5eae0 100644 --- a/google-beta/services/certificatemanager/resource_certificate_manager_certificate_issuance_config.go +++ b/google-beta/services/certificatemanager/resource_certificate_manager_certificate_issuance_config.go @@ -18,6 +18,7 @@ package certificatemanager import ( + "context" "fmt" "log" "reflect" @@ -46,6 +47,15 @@ func ResourceCertificateManagerCertificateIssuanceConfig() *schema.Resource { Delete: schema.DefaultTimeout(20 * time.Minute), }, + SchemaVersion: 1, + + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceCertificateManagerCertificateIssuanceConfigResourceV0().CoreConfigSchema().ImpliedType(), + Upgrade: ResourceCertificateManagerCertificateIssuanceConfigUpgradeV0, + Version: 0, + }, + }, CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, @@ -593,3 +603,136 @@ func expandCertificateManagerCertificateIssuanceConfigEffectiveLabels(v interfac } return m, nil } + +func resourceCertificateManagerCertificateIssuanceConfigResourceV0() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "certificate_authority_config": { + Type: schema.TypeList, + Required: true, + ForceNew: true, + Description: `The CA that issues the workload certificate. It includes the CA address, type, authentication to CA service, etc.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "certificate_authority_service_config": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `Defines a CertificateAuthorityServiceConfig.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ca_pool": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: tpgresource.CompareResourceNames, + Description: `A CA pool resource used to issue a certificate. +The CA pool string has a relative resource path following the form +"projects/{project}/locations/{location}/caPools/{caPool}".`, + }, + }, + }, + }, + }, + }, + }, + "key_algorithm": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"RSA_2048", "ECDSA_P256"}), + Description: `Key algorithm to use when generating the private key. Possible values: ["RSA_2048", "ECDSA_P256"]`, + }, + "lifetime": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `Lifetime of issued certificates. A duration in seconds with up to nine fractional digits, ending with 's'. +Example: "1814400s". Valid values are from 21 days (1814400s) to 30 days (2592000s)`, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `A user-defined name of the certificate issuance config. +CertificateIssuanceConfig names must be unique globally.`, + }, + "rotation_window_percentage": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + Description: `It specifies the percentage of elapsed time of the certificate lifetime to wait before renewing the certificate. +Must be a number between 1-99, inclusive. +You must set the rotation window percentage in relation to the certificate lifetime so that certificate renewal occurs at least 7 days after +the certificate has been issued and at least 7 days before it expires.`, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `One or more paragraphs of text description of a CertificateIssuanceConfig.`, + }, + "labels": { + Type: schema.TypeMap, + Optional: true, + ForceNew: true, + Description: `'Set of label tags associated with the CertificateIssuanceConfig resource. + An object containing a list of "key": value pairs. Example: { "name": "wrench", "count": "3" }. + + +**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. +Please refer to the field 'effective_labels' for all of the labels present on the resource.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "location": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `The Certificate Manager location. If not specified, "global" is used.`, + Default: "global", + }, + "create_time": { + Type: schema.TypeString, + Computed: true, + Description: `The creation timestamp of a CertificateIssuanceConfig. Timestamp is in RFC3339 UTC "Zulu" format, +accurate to nanoseconds with up to nine fractional digits. +Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, + }, + "effective_labels": { + Type: schema.TypeMap, + Computed: true, + ForceNew: true, + Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "terraform_labels": { + Type: schema.TypeMap, + Computed: true, + ForceNew: true, + Description: `The combination of labels configured directly on the resource + and default labels configured on the provider.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "update_time": { + Type: schema.TypeString, + Computed: true, + Description: `The last update timestamp of a CertificateIssuanceConfig. Timestamp is in RFC3339 UTC "Zulu" format, +accurate to nanoseconds with up to nine fractional digits. +Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, + }, + "project": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + }, + UseJSONNumber: true, + } +} + +func ResourceCertificateManagerCertificateIssuanceConfigUpgradeV0(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + return tpgresource.TerraformLabelsStateUpgrade(rawState) +} diff --git a/google-beta/services/cloudrun/resource_cloud_run_domain_mapping.go b/google-beta/services/cloudrun/resource_cloud_run_domain_mapping.go index 039441eab7..77e19aa5f0 100644 --- a/google-beta/services/cloudrun/resource_cloud_run_domain_mapping.go +++ b/google-beta/services/cloudrun/resource_cloud_run_domain_mapping.go @@ -1249,6 +1249,7 @@ func ResourceCloudRunDomainMappingUpgradeV0(_ context.Context, rawState map[stri rawMetadata := rawMetadatas[0].(map[string]interface{}) rawLabels := rawMetadata["labels"] + rawTerraformLabels := rawMetadata["terraform_labels"] if rawLabels != nil { labels := make(map[string]interface{}) effectiveLabels := make(map[string]interface{}) @@ -1263,6 +1264,10 @@ func ResourceCloudRunDomainMappingUpgradeV0(_ context.Context, rawState map[stri rawMetadata["labels"] = labels rawMetadata["effective_labels"] = effectiveLabels + + if rawTerraformLabels == nil { + rawMetadata["terraform_labels"] = labels + } } upgradeAnnotations(rawMetadata) diff --git a/google-beta/services/datastream/resource_datastream_private_connection.go b/google-beta/services/datastream/resource_datastream_private_connection.go index 6c4e833821..aed1dc4a44 100644 --- a/google-beta/services/datastream/resource_datastream_private_connection.go +++ b/google-beta/services/datastream/resource_datastream_private_connection.go @@ -18,6 +18,7 @@ package datastream import ( + "context" "encoding/json" "fmt" "log" @@ -79,6 +80,15 @@ func ResourceDatastreamPrivateConnection() *schema.Resource { Delete: schema.DefaultTimeout(20 * time.Minute), }, + SchemaVersion: 1, + + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceDatastreamPrivateConnectionResourceV0().CoreConfigSchema().ImpliedType(), + Upgrade: ResourceDatastreamPrivateConnectionUpgradeV0, + Version: 0, + }, + }, CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, @@ -578,3 +588,119 @@ func expandDatastreamPrivateConnectionEffectiveLabels(v interface{}, d tpgresour } return m, nil } + +func resourceDatastreamPrivateConnectionResourceV0() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "display_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `Display name.`, + }, + "location": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The name of the location this private connection is located in.`, + }, + "private_connection_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The private connectivity identifier.`, + }, + "vpc_peering_config": { + Type: schema.TypeList, + Required: true, + ForceNew: true, + Description: `The VPC Peering configuration is used to create VPC peering +between Datastream and the consumer's VPC.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "subnet": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `A free subnet for peering. (CIDR of /29)`, + }, + "vpc": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `Fully qualified name of the VPC that Datastream will peer to. +Format: projects/{project}/global/{networks}/{name}`, + }, + }, + }, + }, + "labels": { + Type: schema.TypeMap, + Optional: true, + ForceNew: true, + Description: `Labels. + +**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. +Please refer to the field 'effective_labels' for all of the labels present on the resource.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "effective_labels": { + Type: schema.TypeMap, + Computed: true, + ForceNew: true, + Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "error": { + Type: schema.TypeList, + Computed: true, + Description: `The PrivateConnection error in case of failure.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "details": { + Type: schema.TypeMap, + Optional: true, + Description: `A list of messages that carry the error details.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "message": { + Type: schema.TypeString, + Optional: true, + Description: `A message containing more information about the error that occurred.`, + }, + }, + }, + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: `The resource's name.`, + }, + "state": { + Type: schema.TypeString, + Computed: true, + Description: `State of the PrivateConnection.`, + }, + "terraform_labels": { + Type: schema.TypeMap, + Computed: true, + ForceNew: true, + Description: `The combination of labels configured directly on the resource + and default labels configured on the provider.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "project": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + }, + UseJSONNumber: true, + } +} + +func ResourceDatastreamPrivateConnectionUpgradeV0(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + return tpgresource.TerraformLabelsStateUpgrade(rawState) +} diff --git a/google-beta/services/mlengine/resource_ml_engine_model.go b/google-beta/services/mlengine/resource_ml_engine_model.go index c430949a87..299316538e 100644 --- a/google-beta/services/mlengine/resource_ml_engine_model.go +++ b/google-beta/services/mlengine/resource_ml_engine_model.go @@ -18,6 +18,7 @@ package mlengine import ( + "context" "fmt" "log" "reflect" @@ -45,6 +46,15 @@ func ResourceMLEngineModel() *schema.Resource { Delete: schema.DefaultTimeout(20 * time.Minute), }, + SchemaVersion: 1, + + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceMLEngineModelResourceV0().CoreConfigSchema().ImpliedType(), + Upgrade: ResourceMLEngineModelUpgradeV0, + Version: 0, + }, + }, CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, @@ -506,3 +516,99 @@ func expandMLEngineModelEffectiveLabels(v interface{}, d tpgresource.TerraformRe } return m, nil } + +func resourceMLEngineModelResourceV0() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The name specified for the model.`, + }, + "default_version": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `The default version of the model. This version will be used to handle +prediction requests that do not specify a version.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The name specified for the version when it was created.`, + }, + }, + }, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `The description specified for the model when it was created.`, + }, + "labels": { + Type: schema.TypeMap, + Optional: true, + ForceNew: true, + Description: `One or more labels that you can add, to organize your models. + +**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. +Please refer to the field 'effective_labels' for all of the labels present on the resource.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "online_prediction_console_logging": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `If true, online prediction nodes send stderr and stdout streams to Stackdriver Logging`, + }, + "online_prediction_logging": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Description: `If true, online prediction access logs are sent to StackDriver Logging.`, + }, + "regions": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Description: `The list of regions where the model is going to be deployed. +Currently only one region per model is supported`, + MaxItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "effective_labels": { + Type: schema.TypeMap, + Computed: true, + ForceNew: true, + Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "terraform_labels": { + Type: schema.TypeMap, + Computed: true, + ForceNew: true, + Description: `The combination of labels configured directly on the resource + and default labels configured on the provider.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "project": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + }, + UseJSONNumber: true, + } +} + +func ResourceMLEngineModelUpgradeV0(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + return tpgresource.TerraformLabelsStateUpgrade(rawState) +} diff --git a/google-beta/services/networkservices/resource_network_services_service_binding.go b/google-beta/services/networkservices/resource_network_services_service_binding.go index b2c20514cc..2361d58627 100644 --- a/google-beta/services/networkservices/resource_network_services_service_binding.go +++ b/google-beta/services/networkservices/resource_network_services_service_binding.go @@ -18,6 +18,7 @@ package networkservices import ( + "context" "fmt" "log" "reflect" @@ -45,6 +46,15 @@ func ResourceNetworkServicesServiceBinding() *schema.Resource { Delete: schema.DefaultTimeout(10 * time.Minute), }, + SchemaVersion: 1, + + StateUpgraders: []schema.StateUpgrader{ + { + Type: resourceNetworkServicesServiceBindingResourceV0().CoreConfigSchema().ImpliedType(), + Upgrade: ResourceNetworkServicesServiceBindingUpgradeV0, + Version: 0, + }, + }, CustomizeDiff: customdiff.All( tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, @@ -403,3 +413,75 @@ func expandNetworkServicesServiceBindingEffectiveLabels(v interface{}, d tpgreso } return m, nil } + +func resourceNetworkServicesServiceBindingResourceV0() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `Name of the ServiceBinding resource.`, + }, + "service": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The full Service Directory Service name of the format +projects/*/locations/*/namespaces/*/services/*`, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `A free-text description of the resource. Max length 1024 characters.`, + }, + "labels": { + Type: schema.TypeMap, + Optional: true, + ForceNew: true, + Description: `Set of label tags associated with the ServiceBinding resource. + +**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. +Please refer to the field 'effective_labels' for all of the labels present on the resource.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "create_time": { + Type: schema.TypeString, + Computed: true, + Description: `Time the ServiceBinding was created in UTC.`, + }, + "effective_labels": { + Type: schema.TypeMap, + Computed: true, + ForceNew: true, + Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "terraform_labels": { + Type: schema.TypeMap, + Computed: true, + ForceNew: true, + Description: `The combination of labels configured directly on the resource + and default labels configured on the provider.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "update_time": { + Type: schema.TypeString, + Computed: true, + Description: `Time the ServiceBinding was updated in UTC.`, + }, + "project": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + }, + UseJSONNumber: true, + } +} + +func ResourceNetworkServicesServiceBindingUpgradeV0(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + return tpgresource.TerraformLabelsStateUpgrade(rawState) +}