diff --git a/google-beta/resource_logging_metric.go b/google-beta/resource_logging_metric.go index e69bff67fd..82ae2b5e24 100644 --- a/google-beta/resource_logging_metric.go +++ b/google-beta/resource_logging_metric.go @@ -97,6 +97,12 @@ or just for responses that failed.`, [The Unified Code for Units of Measure](http://unitsofmeasure.org/ucum.html) standard`, Default: "1", }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: `The metric type, including its DNS name prefix. The type is not URL-encoded. +All user-defined metric types have the DNS name 'custom.googleapis.com' or 'external.googleapis.com'.`, + }, }, }, }, @@ -543,6 +549,8 @@ func flattenLoggingMetricMetricDescriptor(v interface{}, d *schema.ResourceData) flattenLoggingMetricMetricDescriptorLabels(original["labels"], d) transformed["display_name"] = flattenLoggingMetricMetricDescriptorDisplayName(original["displayName"], d) + transformed["type"] = + flattenLoggingMetricMetricDescriptorType(original["type"], d) return []interface{}{transformed} } func flattenLoggingMetricMetricDescriptorUnit(v interface{}, d *schema.ResourceData) interface{} { @@ -597,6 +605,10 @@ func flattenLoggingMetricMetricDescriptorDisplayName(v interface{}, d *schema.Re return v } +func flattenLoggingMetricMetricDescriptorType(v interface{}, d *schema.ResourceData) interface{} { + return v +} + func flattenLoggingMetricLabelExtractors(v interface{}, d *schema.ResourceData) interface{} { return v } @@ -771,6 +783,13 @@ func expandLoggingMetricMetricDescriptor(v interface{}, d TerraformResourceData, transformed["displayName"] = transformedDisplayName } + transformedType, err := expandLoggingMetricMetricDescriptorType(original["type"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedType); val.IsValid() && !isEmptyValue(val) { + transformed["type"] = transformedType + } + return transformed, nil } @@ -839,6 +858,10 @@ func expandLoggingMetricMetricDescriptorDisplayName(v interface{}, d TerraformRe return v, nil } +func expandLoggingMetricMetricDescriptorType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + return v, nil +} + func expandLoggingMetricLabelExtractors(v interface{}, d TerraformResourceData, config *Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/google-beta/resource_sql_database_instance_test.go b/google-beta/resource_sql_database_instance_test.go index 5b99680669..b04988ac0a 100644 --- a/google-beta/resource_sql_database_instance_test.go +++ b/google-beta/resource_sql_database_instance_test.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" + sqladmin "google.golang.org/api/sqladmin/v1beta4" ) diff --git a/website/docs/r/logging_metric.html.markdown b/website/docs/r/logging_metric.html.markdown index 885172a142..d6e009b30d 100644 --- a/website/docs/r/logging_metric.html.markdown +++ b/website/docs/r/logging_metric.html.markdown @@ -177,6 +177,10 @@ The `metric_descriptor` block supports: without an ending period, for example "Request count". This field is optional but it is recommended to be set for any metrics associated with user-visible concepts, such as Quota. +* `type` - + The metric type, including its DNS name prefix. The type is not URL-encoded. + All user-defined metric types have the DNS name `custom.googleapis.com` or `external.googleapis.com`. + The `labels` block supports: