Skip to content

Commit ef988ee

Browse files
Add Example resource for CES (#15590) (#11020)
[upstream:cfb40788578275c084cc57991a506f7ee5535ebf] Signed-off-by: Modular Magician <[email protected]>
1 parent 1c8f7ba commit ef988ee

File tree

7 files changed

+1368
-2
lines changed

7 files changed

+1368
-2
lines changed

.changelog/15590.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_ces_example`
3+
```

google-beta/provider/provider_mmv1_resources.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
625625
}
626626

627627
// Resources
628-
// Generated resources: 734
628+
// Generated resources: 735
629629
// Generated IAM resources: 348
630-
// Total generated resources: 1082
630+
// Total generated resources: 1083
631631
var generatedResources = map[string]*schema.Resource{
632632
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
633633
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
@@ -795,6 +795,7 @@ var generatedResources = map[string]*schema.Resource{
795795
"google_certificate_manager_trust_config": certificatemanager.ResourceCertificateManagerTrustConfig(),
796796
"google_ces_app": ces.ResourceCESApp(),
797797
"google_ces_deployment": ces.ResourceCESDeployment(),
798+
"google_ces_example": ces.ResourceCESExample(),
798799
"google_ces_toolset": ces.ResourceCESToolset(),
799800
"google_chronicle_data_access_label": chronicle.ResourceChronicleDataAccessLabel(),
800801
"google_chronicle_data_access_scope": chronicle.ResourceChronicleDataAccessScope(),
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
// ----------------------------------------------------------------------------
4+
//
5+
// *** AUTO GENERATED CODE *** Type: Handwritten ***
6+
//
7+
// ----------------------------------------------------------------------------
8+
//
9+
// This code is generated by Magic Modules using the following:
10+
//
11+
// Source file: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/services/ces/ces_example_test.go
12+
//
13+
// DO NOT EDIT this file directly. Any changes made to this file will be
14+
// overwritten during the next generation cycle.
15+
//
16+
// ----------------------------------------------------------------------------
17+
package ces_test
18+
19+
import (
20+
"testing"
21+
22+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
23+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
24+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest"
25+
)
26+
27+
func TestAccCESExample_update(t *testing.T) {
28+
t.Parallel()
29+
30+
context := map[string]interface{}{
31+
"random_suffix": acctest.RandString(t, 10),
32+
}
33+
34+
acctest.VcrTest(t, resource.TestCase{
35+
PreCheck: func() { acctest.AccTestPreCheck(t) },
36+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
37+
CheckDestroy: testAccCheckCESExampleDestroyProducer(t),
38+
Steps: []resource.TestStep{
39+
{
40+
Config: testAccCESExample_cesExampleBasicExample_full(context),
41+
},
42+
{
43+
ResourceName: "google_ces_example.my-example",
44+
ImportState: true,
45+
ImportStateVerify: true,
46+
ImportStateVerifyIgnore: []string{"app", "example_id", "location"},
47+
},
48+
{
49+
Config: testAccCESExample_cesExampleBasicExample_update(context),
50+
ConfigPlanChecks: resource.ConfigPlanChecks{
51+
PreApply: []plancheck.PlanCheck{
52+
plancheck.ExpectResourceAction("google_ces_example.my-example", plancheck.ResourceActionUpdate),
53+
},
54+
},
55+
},
56+
{
57+
ResourceName: "google_ces_example.my-example",
58+
ImportState: true,
59+
ImportStateVerify: true,
60+
ImportStateVerifyIgnore: []string{"app", "example_id", "location"},
61+
},
62+
},
63+
})
64+
}
65+
66+
func testAccCESExample_cesExampleBasicExample_full(context map[string]interface{}) string {
67+
return acctest.Nprintf(`
68+
resource "google_ces_app" "my-app" {
69+
location = "us"
70+
display_name = "tf-test-my-app%{random_suffix}"
71+
app_id = "tf-test-app-id%{random_suffix}"
72+
time_zone_settings {
73+
time_zone = "America/Los_Angeles"
74+
}
75+
}
76+
resource "google_ces_example" "my-example" {
77+
location = "us"
78+
display_name = "tf-test-my-example%{random_suffix}"
79+
app = google_ces_app.my-app.name
80+
example_id = "tf-test-example-id%{random_suffix}"
81+
description = "example description"
82+
messages {
83+
chunks {
84+
image {
85+
mime_type = "image/png"
86+
data = base64encode("This is some fake image binary data.")
87+
}
88+
}
89+
chunks {
90+
text = "text_data"
91+
}
92+
chunks {
93+
updated_variables = jsonencode({
94+
var1 = "val1"
95+
var2 = "val2"
96+
})
97+
}
98+
role = "agent"
99+
}
100+
}
101+
`, context)
102+
}
103+
104+
func testAccCESExample_cesExampleBasicExample_update(context map[string]interface{}) string {
105+
return acctest.Nprintf(`
106+
resource "google_ces_app" "my-app" {
107+
location = "us"
108+
display_name = "tf-test-my-app%{random_suffix}"
109+
app_id = "tf-test-app-id%{random_suffix}"
110+
time_zone_settings {
111+
time_zone = "America/Los_Angeles"
112+
}
113+
}
114+
resource "google_ces_example" "my-example" {
115+
location = "us"
116+
display_name = "tf-test-my-example%{random_suffix}"
117+
app = google_ces_app.my-app.name
118+
example_id = "tf-test-example-id%{random_suffix}"
119+
description = "updated description"
120+
messages {
121+
chunks {
122+
image {
123+
mime_type = "image/png"
124+
data = base64encode("This is some fake image binary data.")
125+
}
126+
}
127+
chunks {
128+
text = "text_data_updated"
129+
}
130+
chunks {
131+
updated_variables = jsonencode({
132+
var1 = "val1_updated"
133+
var2 = "val2_updated"
134+
})
135+
}
136+
role = "agent"
137+
}
138+
}
139+
`, context)
140+
}

0 commit comments

Comments
 (0)