|
| 1 | +// ---------------------------------------------------------------------------- |
| 2 | +// |
| 3 | +// *** AUTO GENERATED CODE *** Type: MMv1 *** |
| 4 | +// |
| 5 | +// ---------------------------------------------------------------------------- |
| 6 | +// |
| 7 | +// This code is generated by Magic Modules using the following: |
| 8 | +// |
| 9 | +// Configuration: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/products/dataplex/GlossaryCategory.yaml |
| 10 | +// Template: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/templates/tgc/resource_converter.go.tmpl |
| 11 | +// |
| 12 | +// DO NOT EDIT this file directly. Any changes made to this file will be |
| 13 | +// overwritten during the next generation cycle. |
| 14 | +// |
| 15 | +// ---------------------------------------------------------------------------- |
| 16 | + |
| 17 | +package dataplex |
| 18 | + |
| 19 | +import ( |
| 20 | + "reflect" |
| 21 | + |
| 22 | + "github.com/GoogleCloudPlatform/terraform-google-conversion/v6/tfplan2cai/converters/google/resources/cai" |
| 23 | + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" |
| 24 | + transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" |
| 25 | +) |
| 26 | + |
| 27 | +const DataplexGlossaryCategoryAssetType string = "dataplex.googleapis.com/GlossaryCategory" |
| 28 | + |
| 29 | +func ResourceConverterDataplexGlossaryCategory() cai.ResourceConverter { |
| 30 | + return cai.ResourceConverter{ |
| 31 | + AssetType: DataplexGlossaryCategoryAssetType, |
| 32 | + Convert: GetDataplexGlossaryCategoryCaiObject, |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +func GetDataplexGlossaryCategoryCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { |
| 37 | + name, err := cai.AssetName(d, config, "//dataplex.googleapis.com/projects/{{project}}/locations/{{location}}/glossaries/{{glossary_id}}/categories/{{category_id}}") |
| 38 | + if err != nil { |
| 39 | + return []cai.Asset{}, err |
| 40 | + } |
| 41 | + if obj, err := GetDataplexGlossaryCategoryApiObject(d, config); err == nil { |
| 42 | + return []cai.Asset{{ |
| 43 | + Name: name, |
| 44 | + Type: DataplexGlossaryCategoryAssetType, |
| 45 | + Resource: &cai.AssetResource{ |
| 46 | + Version: "v1", |
| 47 | + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/dataplex/v1/rest", |
| 48 | + DiscoveryName: "GlossaryCategory", |
| 49 | + Data: obj, |
| 50 | + }, |
| 51 | + }}, nil |
| 52 | + } else { |
| 53 | + return []cai.Asset{}, err |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +func GetDataplexGlossaryCategoryApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { |
| 58 | + obj := make(map[string]interface{}) |
| 59 | + displayNameProp, err := expandDataplexGlossaryCategoryDisplayName(d.Get("display_name"), d, config) |
| 60 | + if err != nil { |
| 61 | + return nil, err |
| 62 | + } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { |
| 63 | + obj["displayName"] = displayNameProp |
| 64 | + } |
| 65 | + descriptionProp, err := expandDataplexGlossaryCategoryDescription(d.Get("description"), d, config) |
| 66 | + if err != nil { |
| 67 | + return nil, err |
| 68 | + } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { |
| 69 | + obj["description"] = descriptionProp |
| 70 | + } |
| 71 | + parentProp, err := expandDataplexGlossaryCategoryParent(d.Get("parent"), d, config) |
| 72 | + if err != nil { |
| 73 | + return nil, err |
| 74 | + } else if v, ok := d.GetOkExists("parent"); !tpgresource.IsEmptyValue(reflect.ValueOf(parentProp)) && (ok || !reflect.DeepEqual(v, parentProp)) { |
| 75 | + obj["parent"] = parentProp |
| 76 | + } |
| 77 | + labelsProp, err := expandDataplexGlossaryCategoryEffectiveLabels(d.Get("effective_labels"), d, config) |
| 78 | + if err != nil { |
| 79 | + return nil, err |
| 80 | + } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { |
| 81 | + obj["labels"] = labelsProp |
| 82 | + } |
| 83 | + |
| 84 | + return obj, nil |
| 85 | +} |
| 86 | + |
| 87 | +func expandDataplexGlossaryCategoryDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 88 | + return v, nil |
| 89 | +} |
| 90 | + |
| 91 | +func expandDataplexGlossaryCategoryDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 92 | + return v, nil |
| 93 | +} |
| 94 | + |
| 95 | +func expandDataplexGlossaryCategoryParent(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 96 | + return v, nil |
| 97 | +} |
| 98 | + |
| 99 | +func expandDataplexGlossaryCategoryEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { |
| 100 | + if v == nil { |
| 101 | + return map[string]string{}, nil |
| 102 | + } |
| 103 | + m := make(map[string]string) |
| 104 | + for k, val := range v.(map[string]interface{}) { |
| 105 | + m[k] = val.(string) |
| 106 | + } |
| 107 | + return m, nil |
| 108 | +} |
0 commit comments