Skip to content

Commit 04174a8

Browse files
authored
Add Code Repository Index resource (#12338)
1 parent 6173b7e commit 04174a8

File tree

7 files changed

+236
-1
lines changed

7 files changed

+236
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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: CodeRepositoryIndex
16+
description: The resource for managing Code Repository Index for Gemini Code Assist.
17+
min_version: 'beta'
18+
base_url: projects/{{project}}/locations/{{location}}/codeRepositoryIndexes
19+
self_link: projects/{{project}}/locations/{{location}}/codeRepositoryIndexes/{{code_repository_index_id}}
20+
create_url: projects/{{project}}/locations/{{location}}/codeRepositoryIndexes?codeRepositoryIndexId={{code_repository_index_id}}
21+
update_verb: 'PATCH'
22+
update_mask: true
23+
id_format: projects/{{project}}/locations/{{location}}/codeRepositoryIndexes/{{code_repository_index_id}}
24+
import_format:
25+
- projects/{{project}}/locations/{{location}}/codeRepositoryIndexes/{{code_repository_index_id}}
26+
mutex: 'projects/{{project}}/locations/{{location}}/codeRepositoryIndexes/{{code_repository_index_id}}'
27+
examples:
28+
- name: "gemini_code_repository_index_basic"
29+
min_version: 'beta'
30+
primary_resource_id: "example"
31+
test_vars_overrides:
32+
cri_id: '"cri-example"'
33+
exclude_test: true
34+
autogen_async: true
35+
timeouts:
36+
insert_minutes: 90
37+
update_minutes: 90
38+
delete_minutes: 90
39+
async:
40+
operation:
41+
timeouts:
42+
insert_minutes: 90
43+
update_minutes: 90
44+
delete_minutes: 90
45+
path: name
46+
base_url: "{{op_id}}"
47+
wait_ms: 1000
48+
actions:
49+
- create
50+
- delete
51+
- update
52+
type: OpAsync
53+
result:
54+
resource_inside_response: true
55+
path: response
56+
error:
57+
path: error
58+
message: message
59+
include_project: false
60+
parameters:
61+
- name: location
62+
type: String
63+
description: The location of the Code Repository Index, for example `us-central1`.
64+
min_version: 'beta'
65+
immutable: true
66+
url_param_only: true
67+
required: true
68+
- name: codeRepositoryIndexId
69+
type: String
70+
description: Required. Id of the Code Repository Index.
71+
min_version: 'beta'
72+
immutable: true
73+
url_param_only: true
74+
required: true
75+
properties:
76+
- name: updateTime
77+
type: String
78+
description: Output only. Update time stamp.
79+
min_version: 'beta'
80+
output: true
81+
- name: state
82+
type: String
83+
description: |-
84+
Output only. Code Repository Index instance State.
85+
Possible values:
86+
STATE_UNSPECIFIED
87+
CREATING
88+
ACTIVE
89+
DELETING
90+
SUSPENDED
91+
min_version: 'beta'
92+
output: true
93+
- name: labels
94+
type: KeyValueLabels
95+
description: Optional. Labels as key value pairs.
96+
min_version: 'beta'
97+
- name: kmsKey
98+
type: String
99+
description: |-
100+
Optional. Immutable. Customer-managed encryption key name, in the format
101+
projects/*/locations/*/keyRings/*/cryptoKeys/*.
102+
min_version: 'beta'
103+
immutable: true
104+
- name: name
105+
type: String
106+
description: Immutable. Identifier. Name of Code Repository Index.
107+
min_version: 'beta'
108+
output: true
109+
immutable: true
110+
- name: createTime
111+
type: String
112+
description: Output only. Create time stamp.
113+
min_version: 'beta'
114+
output: true

mmv1/products/gemini/product.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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: Gemini
16+
display_name: Gemini for Google Cloud
17+
scopes:
18+
- https://www.googleapis.com/auth/cloud-platform
19+
versions:
20+
- base_url: https://cloudaicompanion.googleapis.com/v1/
21+
name: 'beta'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resource "google_gemini_code_repository_index" "example" {
2+
provider = google-beta
3+
location = "us-central1"
4+
code_repository_index_id = "{{index $.Vars "cri_id"}}"
5+
kms_key = "projects/projectExample/locations/locationExample/keyRings/keyRingExample/cryptoKeys/cryptoKeyExample"
6+
}

mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt

+5
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ var ServicesListBeta = mapOf(
416416
"displayName" to "Firestore",
417417
"path" to "./google-beta/services/firestore"
418418
),
419+
"gemini" to mapOf(
420+
"name" to "gemini",
421+
"displayName" to "Gemini",
422+
"path" to "./google-beta/services/gemini"
423+
),
419424
"gkebackup" to mapOf(
420425
"name" to "gkebackup",
421426
"displayName" to "Gkebackup",

mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt

+5
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,11 @@ var ServicesListGa = mapOf(
411411
"displayName" to "Firestore",
412412
"path" to "./google/services/firestore"
413413
),
414+
"gemini" to mapOf(
415+
"name" to "gemini",
416+
"displayName" to "Gemini",
417+
"path" to "./google/services/gemini"
418+
),
414419
"gkebackup" to mapOf(
415420
"name" to "gkebackup",
416421
"displayName" to "Gkebackup",

mmv1/third_party/terraform/acctest/bootstrap_test_utils.go.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ func NewServiceNetworkSettings(options ...func(*ServiceNetworkSettings)) *Servic
501501
// must be deleted first. After the service instances are deleted, some service producers delay the deletion
502502
// utnil a waiting period has passed. For example, after four days that you delete a SQL instance,
503503
// the service networking connection can be deleted.
504-
// That is the reason to use the shared service networking connection for thest resources.
504+
// That is the reason to use the shared service networking connection for test resources.
505505
// https://cloud.google.com/vpc/docs/configure-private-services-access#removing-connection
506506
//
507507
// testId specifies the test for which a shared network and a gobal address are used/initialized.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package gemini_test
2+
{{- if ne $.TargetVersionName "ga" }}
3+
4+
import (
5+
"os"
6+
"testing"
7+
8+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
9+
10+
"github.com/hashicorp/terraform-provider-google/google/acctest"
11+
)
12+
13+
func TestAccGeminiCodeRepositoryIndex_update(t *testing.T) {
14+
bootstrappedKMS := acctest.BootstrapKMSKeyInLocation(t, "us-central1")
15+
context := map[string]interface{}{
16+
"random_suffix": acctest.RandString(t, 10),
17+
"project_id": os.Getenv("GOOGLE_PROJECT"),
18+
"kms_key": bootstrappedKMS.CryptoKey.Name,
19+
}
20+
21+
acctest.VcrTest(t, resource.TestCase{
22+
PreCheck: func() { acctest.AccTestPreCheck(t) },
23+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
24+
Steps: []resource.TestStep{
25+
{
26+
Config: testAccGeminiCodeRepositoryIndex_basic(context),
27+
},
28+
{
29+
ResourceName: "google_gemini_code_repository_index.example",
30+
ImportState: true,
31+
ImportStateVerify: true,
32+
ImportStateVerifyIgnore: []string{"code_repository_index_id", "labels", "location", "terraform_labels"},
33+
},
34+
{
35+
Config: testAccGeminiCodeRepositoryIndex_update(context),
36+
},
37+
{
38+
ResourceName: "google_gemini_code_repository_index.example",
39+
ImportState: true,
40+
ImportStateVerify: true,
41+
ImportStateVerifyIgnore: []string{"code_repository_index_id", "labels", "location", "terraform_labels"},
42+
},
43+
},
44+
})
45+
}
46+
47+
func testAccGeminiCodeRepositoryIndex_basic(context map[string]interface{}) string {
48+
return acctest.Nprintf(`
49+
resource "google_gemini_code_repository_index" "example" {
50+
provider = google-beta
51+
labels = {"ccfe_debug_note": "terraform_e2e_should_be_deleted"}
52+
location = "us-central1"
53+
code_repository_index_id = "tf-test-cri-index-example-%{random_suffix}"
54+
kms_key = "%{kms_key}"
55+
depends_on = [google_kms_crypto_key_iam_binding.crypto_key_binding]
56+
}
57+
58+
data "google_project" "project" {
59+
provider = google-beta
60+
}
61+
62+
resource "google_kms_crypto_key_iam_binding" "crypto_key_binding" {
63+
provider = google-beta
64+
crypto_key_id = "%{kms_key}"
65+
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
66+
members = [
67+
"serviceAccount:service-${data.google_project.project.number}@gcp-sa-cloudaicompanion.iam.gserviceaccount.com",
68+
]
69+
}
70+
`, context)
71+
}
72+
73+
func testAccGeminiCodeRepositoryIndex_update(context map[string]interface{}) string {
74+
return acctest.Nprintf(`
75+
resource "google_gemini_code_repository_index" "example" {
76+
provider = google-beta
77+
labels = {"ccfe_debug_note": "terraform_e2e_should_be_deleted", "new_label": "new_val"}
78+
location = "us-central1"
79+
code_repository_index_id = "tf-test-cri-index-example-%{random_suffix}"
80+
kms_key = "%{kms_key}"
81+
}
82+
`, context)
83+
}
84+
{{ end }}

0 commit comments

Comments
 (0)