Skip to content

Commit f08102e

Browse files
Add a new 'data_classification' field on 'dataplex_aspect_type' resource. (#15317) (#10929)
[upstream:c61d59ea591d95f20d6de8e2ae25ba033faaa2a4] Signed-off-by: Modular Magician <[email protected]>
1 parent b35ad81 commit f08102e

File tree

6 files changed

+52
-2
lines changed

6 files changed

+52
-2
lines changed

.changelog/15317.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
compute: added `data_classification` field to `google_dataplex_aspect_type` resource
3+
```

google-beta/services/dataplex/iam_dataplex_aspect_type_generated_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ resource "google_dataplex_aspect_type" "test_aspect_type_basic" {
104104
project = "%{project_name}"
105105
location = "us-central1"
106106
107+
data_classification = "DATA_CLASSIFICATION_UNSPECIFIED"
107108
metadata_template = <<EOF
108109
{
109110
"name": "tf-test-template",
@@ -149,6 +150,7 @@ resource "google_dataplex_aspect_type" "test_aspect_type_basic" {
149150
project = "%{project_name}"
150151
location = "us-central1"
151152
153+
data_classification = "DATA_CLASSIFICATION_UNSPECIFIED"
152154
metadata_template = <<EOF
153155
{
154156
"name": "tf-test-template",
@@ -209,6 +211,7 @@ resource "google_dataplex_aspect_type" "test_aspect_type_basic" {
209211
project = "%{project_name}"
210212
location = "us-central1"
211213
214+
data_classification = "DATA_CLASSIFICATION_UNSPECIFIED"
212215
metadata_template = <<EOF
213216
{
214217
"name": "tf-test-template",
@@ -256,6 +259,7 @@ resource "google_dataplex_aspect_type" "test_aspect_type_basic" {
256259
project = "%{project_name}"
257260
location = "us-central1"
258261
262+
data_classification = "DATA_CLASSIFICATION_UNSPECIFIED"
259263
metadata_template = <<EOF
260264
{
261265
"name": "tf-test-template",
@@ -301,6 +305,7 @@ resource "google_dataplex_aspect_type" "test_aspect_type_basic" {
301305
project = "%{project_name}"
302306
location = "us-central1"
303307
308+
data_classification = "DATA_CLASSIFICATION_UNSPECIFIED"
304309
metadata_template = <<EOF
305310
{
306311
"name": "tf-test-template",

google-beta/services/dataplex/resource_dataplex_aspect_type.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535

3636
"github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
3737
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
38+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/verify"
3839
)
3940

4041
func ResourceDataplexAspectType() *schema.Resource {
@@ -66,6 +67,17 @@ func ResourceDataplexAspectType() *schema.Resource {
6667
ForceNew: true,
6768
Description: `The aspect type id of the aspect type.`,
6869
},
70+
"data_classification": {
71+
Type: schema.TypeString,
72+
Optional: true,
73+
ForceNew: true,
74+
ValidateFunc: verify.ValidateEnum([]string{"DATA_CLASSIFICATION_UNSPECIFIED", "METADATA_AND_DATA", ""}),
75+
DiffSuppressFunc: tpgresource.EmptyOrDefaultStringSuppress("DATA_CLASSIFICATION_UNSPECIFIED"),
76+
Description: `Classifies the data stored by the aspect.
77+
'DATA_CLASSIFICATION_UNSPECIFIED' denotes that the aspect contains only metadata
78+
while 'METADATA_AND_DATA' indicates data derived content.
79+
<br><br> Possible values: ["DATA_CLASSIFICATION_UNSPECIFIED", "METADATA_AND_DATA"]`,
80+
},
6981
"description": {
7082
Type: schema.TypeString,
7183
Optional: true,
@@ -175,6 +187,12 @@ func resourceDataplexAspectTypeCreate(d *schema.ResourceData, meta interface{})
175187
} else if v, ok := d.GetOkExists("metadata_template"); !tpgresource.IsEmptyValue(reflect.ValueOf(metadataTemplateProp)) && (ok || !reflect.DeepEqual(v, metadataTemplateProp)) {
176188
obj["metadataTemplate"] = metadataTemplateProp
177189
}
190+
dataClassificationProp, err := expandDataplexAspectTypeDataClassification(d.Get("data_classification"), d, config)
191+
if err != nil {
192+
return err
193+
} else if v, ok := d.GetOkExists("data_classification"); !tpgresource.IsEmptyValue(reflect.ValueOf(dataClassificationProp)) && (ok || !reflect.DeepEqual(v, dataClassificationProp)) {
194+
obj["dataClassification"] = dataClassificationProp
195+
}
178196
effectiveLabelsProp, err := expandDataplexAspectTypeEffectiveLabels(d.Get("effective_labels"), d, config)
179197
if err != nil {
180198
return err
@@ -307,6 +325,9 @@ func resourceDataplexAspectTypeRead(d *schema.ResourceData, meta interface{}) er
307325
if err := d.Set("transfer_status", flattenDataplexAspectTypeTransferStatus(res["transferStatus"], d, config)); err != nil {
308326
return fmt.Errorf("Error reading AspectType: %s", err)
309327
}
328+
if err := d.Set("data_classification", flattenDataplexAspectTypeDataClassification(res["dataClassification"], d, config)); err != nil {
329+
return fmt.Errorf("Error reading AspectType: %s", err)
330+
}
310331
if err := d.Set("terraform_labels", flattenDataplexAspectTypeTerraformLabels(res["labels"], d, config)); err != nil {
311332
return fmt.Errorf("Error reading AspectType: %s", err)
312333
}
@@ -556,6 +577,10 @@ func flattenDataplexAspectTypeTransferStatus(v interface{}, d *schema.ResourceDa
556577
return v
557578
}
558579

580+
func flattenDataplexAspectTypeDataClassification(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
581+
return v
582+
}
583+
559584
func flattenDataplexAspectTypeTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
560585
if v == nil {
561586
return v
@@ -595,6 +620,10 @@ func expandDataplexAspectTypeMetadataTemplate(v interface{}, d tpgresource.Terra
595620
return m, nil
596621
}
597622

623+
func expandDataplexAspectTypeDataClassification(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
624+
return v, nil
625+
}
626+
598627
func expandDataplexAspectTypeEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
599628
if v == nil {
600629
return map[string]string{}, nil

google-beta/services/dataplex/resource_dataplex_aspect_type_generated_meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ fields:
88
- field: 'aspect_type_id'
99
provider_only: true
1010
- api_field: 'createTime'
11+
- api_field: 'dataClassification'
1112
- api_field: 'description'
1213
- api_field: 'displayName'
1314
- field: 'effective_labels'

google-beta/services/dataplex/resource_dataplex_aspect_type_generated_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ resource "google_dataplex_aspect_type" "test_aspect_type_basic" {
6464
project = "%{project_name}"
6565
location = "us-central1"
6666
67+
data_classification = "DATA_CLASSIFICATION_UNSPECIFIED"
6768
metadata_template = <<EOF
6869
{
6970
"name": "tf-test-template",
@@ -129,7 +130,8 @@ resource "google_dataplex_aspect_type" "test_aspect_type_full" {
129130
130131
labels = { "tag": "test-tf" }
131132
display_name = "terraform aspect type"
132-
description = "aspect type created by Terraform"
133+
description = "data aspect type created by Terraform"
134+
data_classification = "METADATA_AND_DATA"
133135
metadata_template = <<EOF
134136
{
135137
"type": "record",

website/docs/r/dataplex_aspect_type.html.markdown

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ resource "google_dataplex_aspect_type" "test_aspect_type_basic" {
3434
project = "my-project-name"
3535
location = "us-central1"
3636
37+
data_classification = "DATA_CLASSIFICATION_UNSPECIFIED"
3738
metadata_template = <<EOF
3839
{
3940
"name": "tf-test-template",
@@ -73,7 +74,8 @@ resource "google_dataplex_aspect_type" "test_aspect_type_full" {
7374
7475
labels = { "tag": "test-tf" }
7576
display_name = "terraform aspect type"
76-
description = "aspect type created by Terraform"
77+
description = "data aspect type created by Terraform"
78+
data_classification = "METADATA_AND_DATA"
7779
metadata_template = <<EOF
7880
{
7981
"type": "record",
@@ -232,6 +234,14 @@ The following arguments are supported:
232234
(Optional)
233235
MetadataTemplate of the Aspect.
234236

237+
* `data_classification` -
238+
(Optional)
239+
Classifies the data stored by the aspect.
240+
`DATA_CLASSIFICATION_UNSPECIFIED` denotes that the aspect contains only metadata
241+
while `METADATA_AND_DATA` indicates data derived content.
242+
<br><br>
243+
Possible values are: `DATA_CLASSIFICATION_UNSPECIFIED`, `METADATA_AND_DATA`.
244+
235245
* `location` -
236246
(Optional)
237247
The location where aspect type will be created in.

0 commit comments

Comments
 (0)