Skip to content

Commit e94d9e9

Browse files
PerlMonker303melinathLucaPreteLuca Preteakshat-jindal-nit
committed
Add Gemini Logging Setting Binding resource (GoogleCloudPlatform#12893)
Signed-off-by: Martijn Stevenson <[email protected]> Signed-off-by: alkobi-google <[email protected]> Co-authored-by: Stephen Lewis (Burrows) <[email protected]> Co-authored-by: Luca Prete <[email protected]> Co-authored-by: Luca Prete <[email protected]> Co-authored-by: Akshat Jindal <[email protected]> Co-authored-by: Sam Levenick <[email protected]> Co-authored-by: abheda-crest <[email protected]> Co-authored-by: karolgorc <[email protected]> Co-authored-by: aniket gupta <[email protected]> Co-authored-by: Chris Stephens <[email protected]> Co-authored-by: hao-nan-li <[email protected]> Co-authored-by: Ankit Goyal <[email protected]> Co-authored-by: bcreddy-gcp <[email protected]> Co-authored-by: bestefreund <[email protected]> Co-authored-by: NA2047 <[email protected]> Co-authored-by: Dhruv Agarwal <[email protected]> Co-authored-by: Will Yardley <[email protected]> Co-authored-by: Chenhao Ma <[email protected]> Co-authored-by: himanikh <[email protected]> Co-authored-by: Nick Elliot <[email protected]> Co-authored-by: Andras Kerekes <[email protected]> Co-authored-by: Ryan Oaks <[email protected]> Co-authored-by: Riley Karson <[email protected]> Co-authored-by: Nikhil Bhoyar <[email protected]> Co-authored-by: Wiktor Niesiobędzki <[email protected]> Co-authored-by: Lagu22 <[email protected]> Co-authored-by: Chris Hawk <[email protected]> Co-authored-by: Jared <[email protected]> Co-authored-by: Daniel Dubnikov <[email protected]> Co-authored-by: Dawid212 <[email protected]> Co-authored-by: Andrea Lee <[email protected]> Co-authored-by: Damon <[email protected]> Co-authored-by: askubis <[email protected]> Co-authored-by: Shuya Ma <[email protected]> Co-authored-by: Stephen Lewis (Burrows) <[email protected]> Co-authored-by: coder-221 <[email protected]> Co-authored-by: Betto Cerrillos <[email protected]> Co-authored-by: wj-chen <[email protected]> Co-authored-by: Scott Suarez <[email protected]> Co-authored-by: Amit <[email protected]> Co-authored-by: martijneken <[email protected]> Co-authored-by: Zeleena Kearney <[email protected]> Co-authored-by: Cameron Moberg <[email protected]> Co-authored-by: cesteve <[email protected]> Co-authored-by: vijaykanthm <[email protected]> Co-authored-by: alkobi-google <[email protected]> Co-authored-by: nityaravi <[email protected]> Co-authored-by: Obada Alabbadi <[email protected]> Co-authored-by: cslink <[email protected]> Co-authored-by: Bob "Wombat" Hogg <[email protected]> Co-authored-by: Terje Larsen <[email protected]> Co-authored-by: Maksym Fuhol <[email protected]> Co-authored-by: Benyamin Bashari <[email protected]> Co-authored-by: gurankitt <[email protected]> Co-authored-by: rahul2393 <[email protected]> Co-authored-by: dsafdsa1 <[email protected]> Co-authored-by: wafrelka <[email protected]> Co-authored-by: Kevin-Looong <[email protected]> Co-authored-by: Kevin Long <[email protected]> Co-authored-by: Cameron Thornton <[email protected]> Co-authored-by: gvijbha <[email protected]> Co-authored-by: Thomas Rodgers <[email protected]> Co-authored-by: Arun Satyarth <[email protected]> Co-authored-by: asatyarth <[email protected]> Co-authored-by: Sander van Donkelaar <[email protected]> Co-authored-by: 7mako <[email protected]> Co-authored-by: Xylosma <[email protected]> Co-authored-by: Angelina Shibu <[email protected]> Co-authored-by: Nahur Fonseca <[email protected]> Co-authored-by: mihhalj <[email protected]>
1 parent 292caa6 commit e94d9e9

File tree

5 files changed

+228
-1
lines changed

5 files changed

+228
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Copyright 2025 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: LoggingSettingBinding
16+
description: The resource for managing Logging 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}}/loggingSettings/{{logging_setting_id}}/settingBindings
22+
self_link: projects/{{project}}/locations/{{location}}/loggingSettings/{{logging_setting_id}}/settingBindings/{{setting_binding_id}}
23+
create_url: projects/{{project}}/locations/{{location}}/loggingSettings/{{logging_setting_id}}/settingBindings?settingBindingId={{setting_binding_id}}
24+
id_format: projects/{{project}}/locations/{{location}}/loggingSettings/{{logging_setting_id}}/settingBindings/{{setting_binding_id}}
25+
update_verb: PATCH
26+
update_mask: true
27+
import_format:
28+
- projects/{{project}}/locations/{{location}}/loggingSettings/{{logging_setting_id}}/settingBindings/{{setting_binding_id}}
29+
mutex: projects/{{project}}/locations/{{location}}/loggingSettings/{{logging_setting_id}}
30+
examples:
31+
- name: gemini_logging_setting_binding_basic
32+
min_version: 'beta'
33+
primary_resource_id: example
34+
exclude_test: true
35+
vars:
36+
logging_setting_id: ls-tf1
37+
setting_binding_id: ls-tf1b1
38+
target: projects/980109375338
39+
autogen_async: true
40+
timeouts:
41+
insert_minutes: 90
42+
update_minutes: 90
43+
delete_minutes: 90
44+
async:
45+
operation:
46+
timeouts:
47+
insert_minutes: 90
48+
update_minutes: 90
49+
delete_minutes: 90
50+
base_url: '{{op_id}}'
51+
actions:
52+
- create
53+
- delete
54+
- update
55+
type: OpAsync
56+
result:
57+
resource_inside_response: true
58+
include_project: false
59+
autogen_status: U2V0dGluZ0JpbmRpbmdCeVByb2plY3RBbmRMb2NhdGlvbkFuZExvZ2dpbmdzZXR0aW5n
60+
parameters:
61+
- name: location
62+
type: String
63+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
64+
immutable: true
65+
url_param_only: true
66+
- name: loggingSettingId
67+
type: String
68+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
69+
immutable: true
70+
url_param_only: true
71+
required: true
72+
- name: settingBindingId
73+
type: String
74+
description: |-
75+
Id of the setting binding.
76+
immutable: true
77+
url_param_only: true
78+
required: true
79+
properties:
80+
- name: labels
81+
type: KeyValueLabels
82+
description: Labels as key value pairs.
83+
- name: target
84+
type: String
85+
description: Target of the binding.
86+
required: true
87+
- name: product
88+
type: Enum
89+
description: |-
90+
Product type of the setting binding.
91+
enum_values:
92+
- 'GEMINI_CLOUD_ASSIST'
93+
- 'GEMINI_CODE_ASSIST'
94+
- name: name
95+
type: String
96+
description: |-
97+
Identifier. Name of the resource.
98+
Format:projects/{project}/locations/{location}/loggingSettings/{setting}/settingBindings/{setting_binding}
99+
output: true
100+
- name: createTime
101+
type: String
102+
description: Create time stamp.
103+
output: true
104+
- name: updateTime
105+
type: String
106+
description: Update time stamp.
107+
output: true

mmv1/templates/terraform/examples/gemini_logging_setting_basic.tf.tmpl

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ resource "google_gemini_logging_setting" "{{$.PrimaryResourceId}}" {
22
provider = google-beta
33
logging_setting_id = "{{index $.Vars "logging_setting_id"}}"
44
location = "global"
5+
labels = {"my_key": "my_value"}
56
log_prompts_and_responses = true
67
log_metadata = true
78
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "google_gemini_logging_setting" "basic" {
2+
provider = google-beta
3+
logging_setting_id = "{{index $.Vars "logging_setting_id"}}"
4+
location = "global"
5+
labels = {"my_key": "my_value"}
6+
log_prompts_and_responses = true
7+
}
8+
9+
resource "google_gemini_logging_setting_binding" "{{$.PrimaryResourceId}}" {
10+
provider = google-beta
11+
logging_setting_id = google_gemini_logging_setting.basic.logging_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 TestAccGeminiLoggingSettingBinding_update(t *testing.T) {
15+
t.Parallel()
16+
17+
context := map[string]interface{}{
18+
"logging_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: testAccGeminiLoggingSettingBinding_basic(context),
28+
},
29+
{
30+
ResourceName: "google_gemini_logging_setting_binding.basic_binding",
31+
ImportState: true,
32+
ImportStateVerify: true,
33+
ImportStateVerifyIgnore: []string{"labels", "location", "logging_setting_id", "terraform_labels"},
34+
},
35+
{
36+
Config: testAccGeminiLoggingSettingBinding_update(context),
37+
ConfigPlanChecks: resource.ConfigPlanChecks{
38+
PreApply: []plancheck.PlanCheck{
39+
plancheck.ExpectResourceAction("google_gemini_logging_setting_binding.basic_binding", plancheck.ResourceActionUpdate),
40+
},
41+
},
42+
},
43+
{
44+
ResourceName: "google_gemini_logging_setting_binding.basic_binding",
45+
ImportState: true,
46+
ImportStateVerify: true,
47+
ImportStateVerifyIgnore: []string{"labels", "location", "logging_setting_id", "terraform_labels"},
48+
},
49+
},
50+
})
51+
}
52+
53+
func testAccGeminiLoggingSettingBinding_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_logging_setting" "basic" {
60+
provider = google-beta
61+
logging_setting_id = "%{logging_setting_id}"
62+
location = "global"
63+
labels = {"my_key" = "my_value"}
64+
log_prompts_and_responses = true
65+
}
66+
67+
resource "google_gemini_logging_setting_binding" "basic_binding" {
68+
provider = google-beta
69+
logging_setting_id = google_gemini_logging_setting.basic.logging_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 testAccGeminiLoggingSettingBinding_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_logging_setting" "basic" {
84+
provider = google-beta
85+
logging_setting_id = "%{logging_setting_id}"
86+
location = "global"
87+
labels = {"my_key" = "my_value"}
88+
log_prompts_and_responses = true
89+
}
90+
91+
resource "google_gemini_logging_setting_binding" "basic_binding" {
92+
provider = google-beta
93+
logging_setting_id = google_gemini_logging_setting.basic.logging_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_logging_setting_test.go.tmpl

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package gemini_test
22
{{- if ne $.TargetVersionName "ga" }}
33

44
import (
5+
"fmt"
56
"testing"
67

78
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -12,7 +13,7 @@ import (
1213
func TestAccGeminiLoggingSetting_geminiLoggingSettingBasicExample_update(t *testing.T) {
1314
t.Parallel()
1415
context := map[string]interface{}{
15-
"setting_id": "ls-tf1",
16+
"setting_id": fmt.Sprintf("tf-test-ls-%s", acctest.RandString(t, 10)),
1617
}
1718
acctest.VcrTest(t, resource.TestCase{
1819
PreCheck: func() { acctest.AccTestPreCheck(t) },
@@ -61,6 +62,7 @@ resource "google_gemini_logging_setting" "example" {
6162
provider = google-beta
6263
logging_setting_id = "%{setting_id}"
6364
location = "global"
65+
labels = {"my_key" = "my_value"}
6466
log_prompts_and_responses = false
6567
log_metadata = false
6668
}

0 commit comments

Comments
 (0)