|
| 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/lustre/Instance.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 lustre |
| 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 LustreInstanceAssetType string = "lustre.googleapis.com/Instance" |
| 28 | + |
| 29 | +func ResourceConverterLustreInstance() cai.ResourceConverter { |
| 30 | + return cai.ResourceConverter{ |
| 31 | + AssetType: LustreInstanceAssetType, |
| 32 | + Convert: GetLustreInstanceCaiObject, |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +func GetLustreInstanceCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { |
| 37 | + name, err := cai.AssetName(d, config, "//lustre.googleapis.com/projects/{{project}}/locations/{{location}}/instances/{{instance_id}}") |
| 38 | + if err != nil { |
| 39 | + return []cai.Asset{}, err |
| 40 | + } |
| 41 | + if obj, err := GetLustreInstanceApiObject(d, config); err == nil { |
| 42 | + return []cai.Asset{{ |
| 43 | + Name: name, |
| 44 | + Type: LustreInstanceAssetType, |
| 45 | + Resource: &cai.AssetResource{ |
| 46 | + Version: "v1", |
| 47 | + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/lustre/v1/rest", |
| 48 | + DiscoveryName: "Instance", |
| 49 | + Data: obj, |
| 50 | + }, |
| 51 | + }}, nil |
| 52 | + } else { |
| 53 | + return []cai.Asset{}, err |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +func GetLustreInstanceApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { |
| 58 | + obj := make(map[string]interface{}) |
| 59 | + capacityGibProp, err := expandLustreInstanceCapacityGib(d.Get("capacity_gib"), d, config) |
| 60 | + if err != nil { |
| 61 | + return nil, err |
| 62 | + } else if v, ok := d.GetOkExists("capacity_gib"); !tpgresource.IsEmptyValue(reflect.ValueOf(capacityGibProp)) && (ok || !reflect.DeepEqual(v, capacityGibProp)) { |
| 63 | + obj["capacityGib"] = capacityGibProp |
| 64 | + } |
| 65 | + descriptionProp, err := expandLustreInstanceDescription(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 | + gkeSupportEnabledProp, err := expandLustreInstanceGkeSupportEnabled(d.Get("gke_support_enabled"), d, config) |
| 72 | + if err != nil { |
| 73 | + return nil, err |
| 74 | + } else if v, ok := d.GetOkExists("gke_support_enabled"); !tpgresource.IsEmptyValue(reflect.ValueOf(gkeSupportEnabledProp)) && (ok || !reflect.DeepEqual(v, gkeSupportEnabledProp)) { |
| 75 | + obj["gkeSupportEnabled"] = gkeSupportEnabledProp |
| 76 | + } |
| 77 | + filesystemProp, err := expandLustreInstanceFilesystem(d.Get("filesystem"), d, config) |
| 78 | + if err != nil { |
| 79 | + return nil, err |
| 80 | + } else if v, ok := d.GetOkExists("filesystem"); !tpgresource.IsEmptyValue(reflect.ValueOf(filesystemProp)) && (ok || !reflect.DeepEqual(v, filesystemProp)) { |
| 81 | + obj["filesystem"] = filesystemProp |
| 82 | + } |
| 83 | + networkProp, err := expandLustreInstanceNetwork(d.Get("network"), d, config) |
| 84 | + if err != nil { |
| 85 | + return nil, err |
| 86 | + } else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(networkProp)) && (ok || !reflect.DeepEqual(v, networkProp)) { |
| 87 | + obj["network"] = networkProp |
| 88 | + } |
| 89 | + labelsProp, err := expandLustreInstanceEffectiveLabels(d.Get("effective_labels"), d, config) |
| 90 | + if err != nil { |
| 91 | + return nil, err |
| 92 | + } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { |
| 93 | + obj["labels"] = labelsProp |
| 94 | + } |
| 95 | + |
| 96 | + return obj, nil |
| 97 | +} |
| 98 | + |
| 99 | +func expandLustreInstanceCapacityGib(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 100 | + return v, nil |
| 101 | +} |
| 102 | + |
| 103 | +func expandLustreInstanceDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 104 | + return v, nil |
| 105 | +} |
| 106 | + |
| 107 | +func expandLustreInstanceGkeSupportEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 108 | + return v, nil |
| 109 | +} |
| 110 | + |
| 111 | +func expandLustreInstanceFilesystem(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 112 | + return v, nil |
| 113 | +} |
| 114 | + |
| 115 | +func expandLustreInstanceNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 116 | + return v, nil |
| 117 | +} |
| 118 | + |
| 119 | +func expandLustreInstanceEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { |
| 120 | + if v == nil { |
| 121 | + return map[string]string{}, nil |
| 122 | + } |
| 123 | + m := make(map[string]string) |
| 124 | + for k, val := range v.(map[string]interface{}) { |
| 125 | + m[k] = val.(string) |
| 126 | + } |
| 127 | + return m, nil |
| 128 | +} |
0 commit comments