Skip to content

Commit a637e0a

Browse files
PerlMonker303SirGitsalot
authored andcommitted
Add Gemini Code Tools Setting Binding resource (GoogleCloudPlatform#13337)
Co-authored-by: Chris Hawk <[email protected]>
1 parent 7d4a162 commit a637e0a

File tree

4 files changed

+249
-1
lines changed

4 files changed

+249
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Copyright 2024 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: CodeToolsSettingBinding
16+
api_resource_type_kind: SettingBinding
17+
description: The resource for managing CodeTools setting bindings for Admin Control.
18+
min_version: 'beta'
19+
references:
20+
guides:
21+
'Gemini Cloud Assist overview': 'https://cloud.google.com/gemini/docs/cloud-assist/overview'
22+
base_url: projects/{{project}}/locations/{{location}}/codeToolsSettings/{{code_tools_setting_id}}/settingBindings
23+
self_link: projects/{{project}}/locations/{{location}}/codeToolsSettings/{{code_tools_setting_id}}/settingBindings/{{setting_binding_id}}
24+
create_url: projects/{{project}}/locations/{{location}}/codeToolsSettings/{{code_tools_setting_id}}/settingBindings?settingBindingId={{setting_binding_id}}
25+
update_verb: PATCH
26+
update_mask: true
27+
id_format: projects/{{project}}/locations/{{location}}/codeToolsSettings/{{code_tools_setting_id}}/settingBindings/{{setting_binding_id}}
28+
import_format:
29+
- projects/{{project}}/locations/{{location}}/codeToolsSettings/{{code_tools_setting_id}}/settingBindings/{{setting_binding_id}}
30+
mutex: projects/{{project}}/locations/{{location}}/codeToolsSettings/{{code_tools_setting_id}}
31+
examples:
32+
- name: gemini_code_tools_setting_binding_basic
33+
min_version: 'beta'
34+
primary_resource_id: example
35+
exclude_test: true
36+
vars:
37+
code_tools_setting_id: ls-tf1
38+
setting_binding_id: ls-tf1b1
39+
target: projects/980109375338
40+
autogen_async: true
41+
async:
42+
operation:
43+
timeouts:
44+
insert_minutes: 90
45+
update_minutes: 90
46+
delete_minutes: 90
47+
base_url: '{{op_id}}'
48+
actions:
49+
- create
50+
- delete
51+
- update
52+
type: OpAsync
53+
result:
54+
resource_inside_response: true
55+
include_project: false
56+
autogen_status: U2V0dGluZ0JpbmRpbmc=
57+
parameters:
58+
- name: location
59+
type: String
60+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
61+
immutable: true
62+
url_param_only: true
63+
- name: codeToolsSettingId
64+
type: String
65+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
66+
immutable: true
67+
url_param_only: true
68+
required: true
69+
- name: settingBindingId
70+
type: String
71+
description: |-
72+
Id of the setting binding.
73+
immutable: true
74+
url_param_only: true
75+
required: true
76+
properties:
77+
- name: product
78+
type: Enum
79+
description: |-
80+
Product type of the setting binding.
81+
enum_values:
82+
- 'GEMINI_CODE_ASSIST'
83+
default_from_api: true
84+
- name: name
85+
type: String
86+
description: |-
87+
Identifier. Name of the resource.
88+
Format:projects/{project}/locations/{location}/codeToolsSettings/{setting}/settingBindings/{setting_binding}
89+
output: true
90+
- name: createTime
91+
type: String
92+
description: Create time stamp.
93+
output: true
94+
- name: updateTime
95+
type: String
96+
description: Update time stamp.
97+
output: true
98+
- name: labels
99+
type: KeyValueLabels
100+
description: Labels as key value pairs.
101+
- name: target
102+
type: String
103+
description: Target of the binding.
104+
required: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
resource "google_gemini_code_tools_setting" "{{$.PrimaryResourceId}}" {
2+
provider = google-beta
3+
code_tools_setting_id = "{{index $.Vars "code_tools_setting_id"}}"
4+
location = "global"
5+
labels = {"my_key": "my_value"}
6+
enabled_tool {
7+
handle = "my_handle"
8+
tool = "my_tool"
9+
account_connector = "my_con"
10+
config {
11+
key = "my_key"
12+
value = "my_value"
13+
}
14+
uri_override = "my_uri_override"
15+
}
16+
}
17+
18+
resource "google_gemini_code_tools_setting_binding" "{{$.PrimaryResourceId}}" {
19+
provider = google-beta
20+
code_tools_setting_id = google_gemini_code_tools_setting.basic.code_tools_setting_id
21+
setting_binding_id = "{{index $.Vars "setting_binding_id"}}"
22+
location = "global"
23+
target = "{{index $.Vars "target"}}"
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
package gemini_test
2+
{{- if ne $.TargetVersionName "ga" }}
3+
4+
import (
5+
"fmt"
6+
"testing"
7+
8+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
9+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
10+
11+
"github.com/hashicorp/terraform-provider-google/google/acctest"
12+
)
13+
14+
func TestAccGeminiCodeToolsSettingBinding_update(t *testing.T) {
15+
t.Parallel()
16+
17+
context := map[string]interface{}{
18+
"code_tools_setting_id": fmt.Sprintf("tf-test-ls-%s", acctest.RandString(t, 10)),
19+
"setting_binding_id": fmt.Sprintf("tf-test-lsb-%s", acctest.RandString(t, 10)),
20+
}
21+
22+
acctest.VcrTest(t, resource.TestCase{
23+
PreCheck: func() { acctest.AccTestPreCheck(t) },
24+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
25+
Steps: []resource.TestStep{
26+
{
27+
Config: testAccGeminiCodeToolsSettingBinding_basic(context),
28+
},
29+
{
30+
ResourceName: "google_gemini_code_tools_setting_binding.basic_binding",
31+
ImportState: true,
32+
ImportStateVerify: true,
33+
ImportStateVerifyIgnore: []string{"labels", "location", "code_tools_setting_id", "terraform_labels"},
34+
},
35+
{
36+
Config: testAccGeminiCodeToolsSettingBinding_update(context),
37+
ConfigPlanChecks: resource.ConfigPlanChecks{
38+
PreApply: []plancheck.PlanCheck{
39+
plancheck.ExpectResourceAction("google_gemini_code_tools_setting_binding.basic_binding", plancheck.ResourceActionUpdate),
40+
},
41+
},
42+
},
43+
{
44+
ResourceName: "google_gemini_code_tools_setting_binding.basic_binding",
45+
ImportState: true,
46+
ImportStateVerify: true,
47+
ImportStateVerifyIgnore: []string{"labels", "location", "code_tools_setting_id", "terraform_labels"},
48+
},
49+
},
50+
})
51+
}
52+
53+
func testAccGeminiCodeToolsSettingBinding_basic(context map[string]interface{}) string {
54+
return acctest.Nprintf(`
55+
data "google_project" "project" {
56+
provider = google-beta
57+
}
58+
59+
resource "google_gemini_code_tools_setting" "basic" {
60+
provider = google-beta
61+
code_tools_setting_id = "%{code_tools_setting_id}"
62+
location = "global"
63+
labels = {"my_key" = "my_value"}
64+
enabled_tool {
65+
handle = "my_handle"
66+
tool = "my_tool"
67+
account_connector = "my_con"
68+
config {
69+
key = "my_key"
70+
value = "my_value"
71+
}
72+
uri_override = "my_uri_override"
73+
}
74+
}
75+
76+
resource "google_gemini_code_tools_setting_binding" "basic_binding" {
77+
provider = google-beta
78+
code_tools_setting_id = google_gemini_code_tools_setting.basic.code_tools_setting_id
79+
setting_binding_id = "%{setting_binding_id}"
80+
location = "global"
81+
target = "projects/${data.google_project.project.number}"
82+
}
83+
`, context)
84+
}
85+
86+
func testAccGeminiCodeToolsSettingBinding_update(context map[string]interface{}) string {
87+
return acctest.Nprintf(`
88+
data "google_project" "project" {
89+
provider = google-beta
90+
}
91+
92+
resource "google_gemini_code_tools_setting" "basic" {
93+
provider = google-beta
94+
code_tools_setting_id = "%{code_tools_setting_id}"
95+
location = "global"
96+
labels = {"my_key" = "my_value"}
97+
enabled_tool {
98+
handle = "my_handle"
99+
tool = "my_tool"
100+
account_connector = "my_con"
101+
config {
102+
key = "my_key"
103+
value = "my_value"
104+
}
105+
uri_override = "my_uri_override"
106+
}
107+
}
108+
109+
resource "google_gemini_code_tools_setting_binding" "basic_binding" {
110+
provider = google-beta
111+
code_tools_setting_id = google_gemini_code_tools_setting.basic.code_tools_setting_id
112+
setting_binding_id = "%{setting_binding_id}"
113+
location = "global"
114+
target = "projects/${data.google_project.project.number}"
115+
labels = {"my_key" = "my_value"}
116+
product = "GEMINI_CODE_ASSIST"
117+
}
118+
`, context)
119+
}
120+
{{ end }}

mmv1/third_party/terraform/services/gemini/resource_gemini_code_tools_setting_test.go.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ resource "google_gemini_code_tools_setting" "example" {
8080
}
8181
}
8282
`, context)
83-
}
83+
}

0 commit comments

Comments
 (0)