Skip to content

Commit 4bd02e1

Browse files
Add Gemini Data Sharing With Google Setting Binding resource (#12906)
1 parent d813aec commit 4bd02e1

5 files changed

+223
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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: DataSharingWithGoogleSettingBinding
16+
description: The resource for managing DataSharingWithGoogle setting bindings for Admin Control.
17+
references:
18+
guides:
19+
'Gemini Cloud Assist overview': 'https://cloud.google.com/gemini/docs/cloud-assist/overview'
20+
min_version: 'beta'
21+
base_url: projects/{{project}}/locations/{{location}}/dataSharingWithGoogleSettings/{{data_sharing_with_google_setting_id}}/settingBindings
22+
self_link: projects/{{project}}/locations/{{location}}/dataSharingWithGoogleSettings/{{data_sharing_with_google_setting_id}}/settingBindings/{{setting_binding_id}}
23+
create_url: projects/{{project}}/locations/{{location}}/dataSharingWithGoogleSettings/{{data_sharing_with_google_setting_id}}/settingBindings?settingBindingId={{setting_binding_id}}
24+
update_verb: PATCH
25+
update_mask: true
26+
id_format: projects/{{project}}/locations/{{location}}/dataSharingWithGoogleSettings/{{data_sharing_with_google_setting_id}}/settingBindings/{{setting_binding_id}}
27+
import_format:
28+
- projects/{{project}}/locations/{{location}}/dataSharingWithGoogleSettings/{{data_sharing_with_google_setting_id}}/settingBindings/{{setting_binding_id}}
29+
mutex: projects/{{project}}/locations/{{location}}/dataSharingWithGoogleSettings/{{data_sharing_with_google_setting_id}}
30+
examples:
31+
- name: gemini_data_sharing_with_google_setting_binding_basic
32+
min_version: 'beta'
33+
primary_resource_id: example
34+
exclude_test: true
35+
vars:
36+
data_sharing_with_google_setting_id: ls-tf1
37+
setting_binding_id: ls-tf1b1
38+
target: projects/980109375338
39+
autogen_async: true
40+
async:
41+
operation:
42+
timeouts:
43+
insert_minutes: 90
44+
update_minutes: 90
45+
delete_minutes: 90
46+
base_url: '{{op_id}}'
47+
actions:
48+
- create
49+
- delete
50+
- update
51+
type: OpAsync
52+
result:
53+
resource_inside_response: true
54+
include_project: false
55+
autogen_status: U2V0dGluZ0JpbmRpbmc=
56+
parameters:
57+
- name: location
58+
type: String
59+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
60+
immutable: true
61+
url_param_only: true
62+
- name: dataSharingWithGoogleSettingId
63+
type: String
64+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
65+
immutable: true
66+
url_param_only: true
67+
required: true
68+
- name: settingBindingId
69+
type: String
70+
description: |-
71+
Required. Id of the setting binding.
72+
immutable: true
73+
url_param_only: true
74+
required: true
75+
properties:
76+
- name: product
77+
type: Enum
78+
description: |-
79+
Product type of the setting binding.
80+
enum_values:
81+
- 'GEMINI_CLOUD_ASSIST'
82+
- 'GEMINI_CODE_ASSIST'
83+
- name: name
84+
type: String
85+
description: |-
86+
Identifier. Name of the resource.
87+
Format:projects/{project}/locations/{location}/dataSharingWithGoogleSettings/{setting}/settingBindings/{setting_binding}
88+
output: true
89+
- name: createTime
90+
type: String
91+
description: Create time stamp.
92+
output: true
93+
- name: updateTime
94+
type: String
95+
description: Update time stamp.
96+
output: true
97+
- name: labels
98+
type: KeyValueLabels
99+
description: Labels as key value pairs.
100+
- name: target
101+
type: String
102+
description: Target of the binding.
103+
required: true
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
resource "google_gemini_data_sharing_with_google_setting" "{{$.PrimaryResourceId}}" {
22
data_sharing_with_google_setting_id = "{{index $.Vars "data_sharing_with_google_setting_id"}}"
33
location = "global"
4+
labels = {"my_key": "my_value"}
45
enable_preview_data_sharing = true
5-
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "google_gemini_data_sharing_with_google_setting" "basic" {
2+
provider = google-beta
3+
data_sharing_with_google_setting_id = "{{index $.Vars "data_sharing_with_google_setting_id"}}"
4+
location = "global"
5+
labels = {"my_key": "my_value"}
6+
enable_preview_data_sharing = true
7+
}
8+
9+
resource "google_gemini_data_sharing_with_google_setting_binding" "{{$.PrimaryResourceId}}" {
10+
provider = google-beta
11+
data_sharing_with_google_setting_id = google_gemini_data_sharing_with_google_setting.basic.data_sharing_with_google_setting_id
12+
setting_binding_id = "{{index $.Vars "setting_binding_id"}}"
13+
location = "global"
14+
target = "{{index $.Vars "target"}}"
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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 TestAccGeminiDataSharingWithGoogleSettingBinding_update(t *testing.T) {
15+
t.Parallel()
16+
17+
context := map[string]interface{}{
18+
"data_sharing_with_google_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: testAccGeminiDataSharingWithGoogleSettingBinding_basic(context),
28+
},
29+
{
30+
ResourceName: "google_gemini_data_sharing_with_google_setting_binding.basic_binding",
31+
ImportState: true,
32+
ImportStateVerify: true,
33+
ImportStateVerifyIgnore: []string{"labels", "location", "data_sharing_with_google_setting_id", "terraform_labels"},
34+
},
35+
{
36+
Config: testAccGeminiDataSharingWithGoogleSettingBinding_update(context),
37+
ConfigPlanChecks: resource.ConfigPlanChecks{
38+
PreApply: []plancheck.PlanCheck{
39+
plancheck.ExpectResourceAction("google_gemini_data_sharing_with_google_setting_binding.basic_binding", plancheck.ResourceActionUpdate),
40+
},
41+
},
42+
},
43+
{
44+
ResourceName: "google_gemini_data_sharing_with_google_setting_binding.basic_binding",
45+
ImportState: true,
46+
ImportStateVerify: true,
47+
ImportStateVerifyIgnore: []string{"labels", "location", "data_sharing_with_google_setting_id", "terraform_labels"},
48+
},
49+
},
50+
})
51+
}
52+
53+
func testAccGeminiDataSharingWithGoogleSettingBinding_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_data_sharing_with_google_setting" "basic" {
60+
provider = google-beta
61+
data_sharing_with_google_setting_id = "%{data_sharing_with_google_setting_id}"
62+
location = "global"
63+
labels = {"my_key" = "my_value"}
64+
enable_preview_data_sharing = true
65+
}
66+
67+
resource "google_gemini_data_sharing_with_google_setting_binding" "basic_binding" {
68+
provider = google-beta
69+
data_sharing_with_google_setting_id = google_gemini_data_sharing_with_google_setting.basic.data_sharing_with_google_setting_id
70+
setting_binding_id = "%{setting_binding_id}"
71+
location = "global"
72+
target = "projects/${data.google_project.project.number}"
73+
}
74+
`, context)
75+
}
76+
77+
func testAccGeminiDataSharingWithGoogleSettingBinding_update(context map[string]interface{}) string {
78+
return acctest.Nprintf(`
79+
data "google_project" "project" {
80+
provider = google-beta
81+
}
82+
83+
resource "google_gemini_data_sharing_with_google_setting" "basic" {
84+
provider = google-beta
85+
data_sharing_with_google_setting_id = "%{data_sharing_with_google_setting_id}"
86+
location = "global"
87+
labels = {"my_key" = "my_value"}
88+
enable_preview_data_sharing = true
89+
}
90+
91+
resource "google_gemini_data_sharing_with_google_setting_binding" "basic_binding" {
92+
provider = google-beta
93+
data_sharing_with_google_setting_id = google_gemini_data_sharing_with_google_setting.basic.data_sharing_with_google_setting_id
94+
setting_binding_id = "%{setting_binding_id}"
95+
location = "global"
96+
target = "projects/${data.google_project.project.number}"
97+
labels = {"my_key" = "my_value"}
98+
product = "GEMINI_CODE_ASSIST"
99+
}
100+
`, context)
101+
}
102+
{{ end }}

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

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func testAccGeminiDataSharingWithGoogleSetting_geminiDataSharingWithGoogleSettin
5858
resource "google_gemini_data_sharing_with_google_setting" "example" {
5959
data_sharing_with_google_setting_id = "%{setting_id}"
6060
location = "global"
61+
labels = {"my_key" = "my_value"}
6162
enable_preview_data_sharing = false
6263
}
6364
`, context)

0 commit comments

Comments
 (0)