|
| 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/dialogflow/version.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 dialogflow |
| 18 | + |
| 19 | +import ( |
| 20 | + "bytes" |
| 21 | + "context" |
| 22 | + "encoding/base64" |
| 23 | + "encoding/json" |
| 24 | + "fmt" |
| 25 | + "log" |
| 26 | + "reflect" |
| 27 | + "regexp" |
| 28 | + "slices" |
| 29 | + "sort" |
| 30 | + "strconv" |
| 31 | + "strings" |
| 32 | + "time" |
| 33 | + |
| 34 | + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" |
| 35 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" |
| 36 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" |
| 37 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging" |
| 38 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" |
| 39 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" |
| 40 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/structure" |
| 41 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" |
| 42 | + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" |
| 43 | + |
| 44 | + "github.com/GoogleCloudPlatform/terraform-google-conversion/v7/tfplan2cai/converters/google/resources/cai" |
| 45 | + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" |
| 46 | + transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" |
| 47 | + "github.com/hashicorp/terraform-provider-google-beta/google-beta/verify" |
| 48 | + |
| 49 | + "google.golang.org/api/googleapi" |
| 50 | +) |
| 51 | + |
| 52 | +var ( |
| 53 | + _ = bytes.Clone |
| 54 | + _ = context.WithCancel |
| 55 | + _ = base64.StdEncoding |
| 56 | + _ = fmt.Sprintf |
| 57 | + _ = json.Marshal |
| 58 | + _ = log.Print |
| 59 | + _ = reflect.ValueOf |
| 60 | + _ = regexp.Match |
| 61 | + _ = slices.Min([]int{1}) |
| 62 | + _ = sort.IntSlice{} |
| 63 | + _ = strconv.Atoi |
| 64 | + _ = strings.Trim |
| 65 | + _ = time.Now |
| 66 | + _ = diag.Diagnostic{} |
| 67 | + _ = customdiff.All |
| 68 | + _ = id.UniqueId |
| 69 | + _ = logging.LogLevel |
| 70 | + _ = retry.Retry |
| 71 | + _ = schema.Noop |
| 72 | + _ = structure.ExpandJsonFromString |
| 73 | + _ = validation.All |
| 74 | + _ = terraform.State{} |
| 75 | + _ = tpgresource.SetLabels |
| 76 | + _ = transport_tpg.Config{} |
| 77 | + _ = verify.ProjectRegex |
| 78 | + _ = googleapi.Error{} |
| 79 | +) |
| 80 | + |
| 81 | +const DialogflowVersionAssetType string = "dialogflow.googleapis.com/Version" |
| 82 | + |
| 83 | +func ResourceConverterDialogflowVersion() cai.ResourceConverter { |
| 84 | + return cai.ResourceConverter{ |
| 85 | + AssetType: DialogflowVersionAssetType, |
| 86 | + Convert: GetDialogflowVersionCaiObject, |
| 87 | + } |
| 88 | +} |
| 89 | + |
| 90 | +func GetDialogflowVersionCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { |
| 91 | + name, err := cai.AssetName(d, config, "//dialogflow.googleapis.com/{{parent}}/versions/{{name}}") |
| 92 | + if err != nil { |
| 93 | + return []cai.Asset{}, err |
| 94 | + } |
| 95 | + if obj, err := GetDialogflowVersionApiObject(d, config); err == nil { |
| 96 | + return []cai.Asset{{ |
| 97 | + Name: name, |
| 98 | + Type: DialogflowVersionAssetType, |
| 99 | + Resource: &cai.AssetResource{ |
| 100 | + Version: "v2", |
| 101 | + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/dialogflow/v2/rest", |
| 102 | + DiscoveryName: "Version", |
| 103 | + Data: obj, |
| 104 | + }, |
| 105 | + }}, nil |
| 106 | + } else { |
| 107 | + return []cai.Asset{}, err |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +func GetDialogflowVersionApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { |
| 112 | + obj := make(map[string]interface{}) |
| 113 | + descriptionProp, err := expandDialogflowVersionDescription(d.Get("description"), d, config) |
| 114 | + if err != nil { |
| 115 | + return nil, err |
| 116 | + } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { |
| 117 | + obj["description"] = descriptionProp |
| 118 | + } |
| 119 | + |
| 120 | + return obj, nil |
| 121 | +} |
| 122 | + |
| 123 | +func expandDialogflowVersionDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { |
| 124 | + return v, nil |
| 125 | +} |
0 commit comments