Skip to content

Commit 71c2a37

Browse files
Add Version Resource (#15114) (#4793)
[upstream:41511011458e008aec92bd008acb5e3e01a00070] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent e8615cc commit 71c2a37

File tree

3 files changed

+128
-3
lines changed

3 files changed

+128
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/hashicorp/hcl/v2 v2.23.0
1313
github.com/hashicorp/terraform-json v0.25.0
1414
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0
15-
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20251117170317-549988e8f23c
15+
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20251117202205-5884d35b833f
1616
github.com/mitchellh/go-homedir v1.1.0
1717
github.com/pkg/errors v0.9.1
1818
github.com/stretchr/testify v1.10.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0 h1:NFPMacTrY/IdcIcnUB+7hsor
181181
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0/go.mod h1:QYmYnLfsosrxjCnGY1p9c7Zj6n9thnEE+7RObeYs3fA=
182182
github.com/hashicorp/terraform-plugin-testing v1.5.1 h1:T4aQh9JAhmWo4+t1A7x+rnxAJHCDIYW9kXyo4sVO92c=
183183
github.com/hashicorp/terraform-plugin-testing v1.5.1/go.mod h1:dg8clO6K59rZ8w9EshBmDp1CxTIPu3yA4iaDpX1h5u0=
184-
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20251117170317-549988e8f23c h1:wNkGAi9tgMS+QvX9xB066FY6TpihJ4eHVFIHj3c4pBU=
185-
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20251117170317-549988e8f23c/go.mod h1:9nRKCi/wR5lugO3OV9JM7yvoiA1nylKSnPMwTLgT+/s=
184+
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20251117202205-5884d35b833f h1:bWPussFOwT+fw1P1dXR6WkvhjMl+qDjKR2VpaTk3Tww=
185+
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20251117202205-5884d35b833f/go.mod h1:9nRKCi/wR5lugO3OV9JM7yvoiA1nylKSnPMwTLgT+/s=
186186
github.com/hashicorp/terraform-registry-address v0.2.5 h1:2GTftHqmUhVOeuu9CW3kwDkRe4pcBDq0uuK5VJngU1M=
187187
github.com/hashicorp/terraform-registry-address v0.2.5/go.mod h1:PpzXWINwB5kuVS5CA7m1+eO2f1jKb5ZDIxrOPfpnGkg=
188188
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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

Comments
 (0)