|
| 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/apihub/HostProjectRegistration.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 apihub |
| 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 ApihubHostProjectRegistrationAssetType string = "apihub.googleapis.com/HostProjectRegistration" |
| 28 | + |
| 29 | +func ResourceConverterApihubHostProjectRegistration() cai.ResourceConverter { |
| 30 | + return cai.ResourceConverter{ |
| 31 | + AssetType: ApihubHostProjectRegistrationAssetType, |
| 32 | + Convert: GetApihubHostProjectRegistrationCaiObject, |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +func GetApihubHostProjectRegistrationCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { |
| 37 | + name, err := cai.AssetName(d, config, "//apihub.googleapis.com/projects/{{project}}/locations/{{location}}/hostProjectRegistrations/{{host_project_registration_id}}") |
| 38 | + if err != nil { |
| 39 | + return []cai.Asset{}, err |
| 40 | + } |
| 41 | + if obj, err := GetApihubHostProjectRegistrationApiObject(d, config); err == nil { |
| 42 | + return []cai.Asset{{ |
| 43 | + Name: name, |
| 44 | + Type: ApihubHostProjectRegistrationAssetType, |
| 45 | + Resource: &cai.AssetResource{ |
| 46 | + Version: "v1", |
| 47 | + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/apihub/v1/rest", |
| 48 | + DiscoveryName: "HostProjectRegistration", |
| 49 | + Data: obj, |
| 50 | + }, |
| 51 | + }}, nil |
| 52 | + } else { |
| 53 | + return []cai.Asset{}, err |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +func GetApihubHostProjectRegistrationApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { |
| 58 | + obj := make(map[string]interface{}) |
| 59 | + gcpProjectProp, err := expandApihubHostProjectRegistrationGcpProject(d.Get("gcp_project"), d, config) |
| 60 | + if err != nil { |
| 61 | + return nil, err |
| 62 | + } else if v, ok := d.GetOkExists("gcp_project"); !tpgresource.IsEmptyValue(reflect.ValueOf(gcpProjectProp)) && (ok || !reflect.DeepEqual(v, gcpProjectProp)) { |
| 63 | + obj["gcpProject"] = gcpProjectProp |
| 64 | + } |
| 65 | + |
| 66 | + return obj, nil |
| 67 | +} |
| 68 | + |
| 69 | +func expandApihubHostProjectRegistrationGcpProject(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 70 | + return v, nil |
| 71 | +} |
0 commit comments