Skip to content

Commit 4c84515

Browse files
modular-magicianrileykarson
authored andcommitted
Use block syntax in cloudiot docs (hashicorp#1127)
Signed-off-by: Modular Magician <[email protected]>
1 parent 85be372 commit 4c84515

4 files changed

+36
-8
lines changed

google-beta/resource_logging_metric.go

+22
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ func resourceLoggingMetric() *schema.Resource {
8585
},
8686
},
8787
},
88+
"unit": {
89+
Type: schema.TypeString,
90+
Optional: true,
91+
Default: "1",
92+
},
8893
},
8994
},
9095
},
@@ -456,6 +461,8 @@ func flattenLoggingMetricMetricDescriptor(v interface{}, d *schema.ResourceData)
456461
return nil
457462
}
458463
transformed := make(map[string]interface{})
464+
transformed["unit"] =
465+
flattenLoggingMetricMetricDescriptorUnit(original["unit"], d)
459466
transformed["value_type"] =
460467
flattenLoggingMetricMetricDescriptorValueType(original["valueType"], d)
461468
transformed["metric_kind"] =
@@ -464,6 +471,10 @@ func flattenLoggingMetricMetricDescriptor(v interface{}, d *schema.ResourceData)
464471
flattenLoggingMetricMetricDescriptorLabels(original["labels"], d)
465472
return []interface{}{transformed}
466473
}
474+
func flattenLoggingMetricMetricDescriptorUnit(v interface{}, d *schema.ResourceData) interface{} {
475+
return v
476+
}
477+
467478
func flattenLoggingMetricMetricDescriptorValueType(v interface{}, d *schema.ResourceData) interface{} {
468479
return v
469480
}
@@ -652,6 +663,13 @@ func expandLoggingMetricMetricDescriptor(v interface{}, d TerraformResourceData,
652663
original := raw.(map[string]interface{})
653664
transformed := make(map[string]interface{})
654665

666+
transformedUnit, err := expandLoggingMetricMetricDescriptorUnit(original["unit"], d, config)
667+
if err != nil {
668+
return nil, err
669+
} else if val := reflect.ValueOf(transformedUnit); val.IsValid() && !isEmptyValue(val) {
670+
transformed["unit"] = transformedUnit
671+
}
672+
655673
transformedValueType, err := expandLoggingMetricMetricDescriptorValueType(original["value_type"], d, config)
656674
if err != nil {
657675
return nil, err
@@ -676,6 +694,10 @@ func expandLoggingMetricMetricDescriptor(v interface{}, d TerraformResourceData,
676694
return transformed, nil
677695
}
678696

697+
func expandLoggingMetricMetricDescriptorUnit(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
698+
return v, nil
699+
}
700+
679701
func expandLoggingMetricMetricDescriptorValueType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
680702
return v, nil
681703
}

google-beta/resource_logging_metric_generated_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ resource "google_logging_metric" "logging_metric" {
5656
metric_descriptor {
5757
metric_kind = "DELTA"
5858
value_type = "DISTRIBUTION"
59+
unit = "1"
5960
labels {
6061
key = "mass"
6162
value_type = "STRING"

website/docs/r/cloudiot_registry.html.markdown

+6-8
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,12 @@ resource "google_cloudiot_registry" "default-registry" {
4343
mqtt_enabled_state = "MQTT_ENABLED"
4444
}
4545
46-
credentials = [
47-
{
48-
public_key_certificate = {
49-
format = "X509_CERTIFICATE_PEM"
50-
certificate = "${file("rsa_cert.pem")}"
51-
}
52-
},
53-
]
46+
credentials {
47+
public_key_certificate = {
48+
format = "X509_CERTIFICATE_PEM"
49+
certificate = "${file("rsa_cert.pem")}"
50+
}
51+
}
5452
}
5553
```
5654

website/docs/r/logging_metric.html.markdown

+7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ resource "google_logging_metric" "logging_metric" {
4848
metric_descriptor {
4949
metric_kind = "DELTA"
5050
value_type = "DISTRIBUTION"
51+
unit = "1"
5152
labels {
5253
key = "mass"
5354
value_type = "STRING"
@@ -133,6 +134,12 @@ The following arguments are supported:
133134

134135
The `metric_descriptor` block supports:
135136

137+
* `unit` -
138+
(Optional)
139+
The unit in which the metric value is reported. It is only applicable if the valueType is
140+
`INT64`, `DOUBLE`, or `DISTRIBUTION`. The supported units are a subset of
141+
[The Unified Code for Units of Measure](http://unitsofmeasure.org/ucum.html) standard
142+
136143
* `value_type` -
137144
(Required)
138145
Whether the measurement is an integer, a floating-point number, etc.

0 commit comments

Comments
 (0)