Skip to content

Commit

Permalink
Promote gemini_* resources to ga (#12747)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Suarez <[email protected]>
  • Loading branch information
JumiDeluxe and ScottSuarez authored Jan 16, 2025
1 parent 2351a26 commit b5bdbf8
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 111 deletions.
15 changes: 6 additions & 9 deletions mmv1/products/gemini/CodeRepositoryIndex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
---
name: CodeRepositoryIndex
description: The resource for managing Code Repository Index for Gemini Code Assist.
min_version: 'beta'
references:
guides:
'Gemini Code Assist overview': 'https://cloud.google.com/gemini/docs/codeassist/overview'
api: 'https://cloud.google.com/gemini/docs/api/reference/rest/v1/projects.locations.codeRepositoryIndexes'
base_url: projects/{{project}}/locations/{{location}}/codeRepositoryIndexes
self_link: projects/{{project}}/locations/{{location}}/codeRepositoryIndexes/{{code_repository_index_id}}
create_url: projects/{{project}}/locations/{{location}}/codeRepositoryIndexes?codeRepositoryIndexId={{code_repository_index_id}}
Expand All @@ -26,7 +29,6 @@ import_format:
mutex: 'projects/{{project}}/locations/{{location}}/codeRepositoryIndexes/{{code_repository_index_id}}'
examples:
- name: "gemini_code_repository_index_basic"
min_version: 'beta'
primary_resource_id: "example"
test_vars_overrides:
cri_id: '"cri-example"'
Expand Down Expand Up @@ -85,12 +87,7 @@ properties:
type: String
description: |-
Output only. Code Repository Index instance State.
Possible values:
STATE_UNSPECIFIED
CREATING
ACTIVE
DELETING
SUSPENDED
Possible values are: `STATE_UNSPECIFIED`, `CREATING`, `ACTIVE`, `DELETING`, `SUSPENDED`.
output: true
- name: labels
type: KeyValueLabels
Expand All @@ -99,7 +96,7 @@ properties:
type: String
description: |-
Optional. Immutable. Customer-managed encryption key name, in the format
projects/*/locations/*/keyRings/*/cryptoKeys/*.
`projects/*/locations/*/keyRings/*/cryptoKeys/*`.
immutable: true
- name: name
type: String
Expand Down
17 changes: 8 additions & 9 deletions mmv1/products/gemini/RepositoryGroup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
---
name: RepositoryGroup
description: The resource for managing Repository Group for Gemini Code Assist.
min_version: 'beta'
references:
api: 'https://cloud.google.com/gemini/docs/api/reference/rest/v1/projects.locations.codeRepositoryIndexes.repositoryGroups'
base_url: projects/{{project}}/locations/{{location}}/codeRepositoryIndexes/{{code_repository_index}}/repositoryGroups
self_link: projects/{{project}}/locations/{{location}}/codeRepositoryIndexes/{{code_repository_index}}/repositoryGroups/{{repository_group_id}}
create_url: projects/{{project}}/locations/{{location}}/codeRepositoryIndexes/{{code_repository_index}}/repositoryGroups?repositoryGroupId={{repository_group_id}}
Expand All @@ -26,11 +27,10 @@ import_format:
mutex: 'projects/{{project}}/locations/{{location}}/codeRepositoryIndexes/{{code_repository_index}}'
examples:
- name: "gemini_repository_group_basic"
min_version: 'beta'
primary_resource_id: "example"
primary_resource_name: 'acctest.BootstrapSharedCodeRepositoryIndex(t, "basic-rg-gen-example", "us-central1", "", map[string]string{}), fmt.Sprintf("tf-test-gen-repository-group-%s", context["random_suffix"])'
vars:
repository_group_id: "gen-repository-group-"
repository_group_id: "example-repository-group"
git_repository_link_id: 'example-git-repository-link-id'
cri_id: "cri-example"
repository_resource: "projects/example-project/locations/us-central1/connections/example-connection/gitRepositoryLinks/example-repo"
Expand Down Expand Up @@ -62,7 +62,6 @@ async:
resource_inside_response: true
include_project: false
iam_policy:
min_version: 'beta'
parent_resource_attribute: 'repository_group_id'
method_name_separator: ':'
fetch_iam_policy_verb: 'GET'
Expand Down Expand Up @@ -96,7 +95,7 @@ parameters:
properties:
- name: repositories
type: Array
description: Required. List of repositories to group
description: Required. List of repositories to group.
required: true
item_type:
type: NestedObject
Expand All @@ -115,17 +114,17 @@ properties:
required: true
- name: name
type: String
description: Immutable. Identifier. name of resource
description: Immutable. Identifier. Name of Repository Group.
output: true
immutable: true
- name: createTime
type: String
description: Output only. Create time stamp
description: Output only. Create time stamp.
output: true
- name: updateTime
type: String
description: Output only. Update time stamp
description: Output only. Update time stamp.
output: true
- name: labels
type: KeyValueLabels
description: Optional. Labels as key value pairs
description: Optional. Labels as key value pairs.
2 changes: 2 additions & 0 deletions mmv1/products/gemini/product.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ display_name: Gemini for Google Cloud
scopes:
- https://www.googleapis.com/auth/cloud-platform
versions:
- base_url: https://cloudaicompanion.googleapis.com/v1/
name: 'ga'
- base_url: https://cloudaicompanion.googleapis.com/v1/
name: 'beta'
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
resource "google_gemini_code_repository_index" "example" {
provider = google-beta
location = "us-central1"
code_repository_index_id = "{{index $.Vars "cri_id"}}"
code_repository_index_id = "code-repository-index-example"
kms_key = "projects/projectExample/locations/locationExample/keyRings/keyRingExample/cryptoKeys/cryptoKeyExample"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
resource "google_gemini_repository_group" "example" {
provider = google-beta
location = "us-central1"
code_repository_index = "%{cri_id}"
code_repository_index = "example-cri"
repository_group_id = "{{index $.Vars "repository_group_id"}}"
repositories {
resource = "{{index $.Vars "repository_resource"}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"strings"
"testing"
"time"
"net/http"

{{ if ne $.TargetVersionName `ga` -}}
// For beta tests only
"net/http"
resourceManagerV3 "google.golang.org/api/cloudresourcemanager/v3"
tpgservicusage "github.com/hashicorp/terraform-provider-google/google/services/serviceusage"
"github.com/hashicorp/terraform-provider-google/google/services/kms"

{{- end }}

"github.com/hashicorp/terraform-provider-google/google/envvar"
Expand Down Expand Up @@ -1747,7 +1747,6 @@ func SetupProjectsAndGetAccessToken(org, billing, pid, service string, config *t
return accessToken, nil
}

{{ if ne $.TargetVersionName `ga` -}}
// For bootstrapping Developer Connect git repository link
const SharedGitRepositoryLinkIdPrefix = "tf-bootstrap-git-repository-"

Expand Down Expand Up @@ -2058,8 +2057,6 @@ func BootstrapSharedCodeRepositoryIndex(t *testing.T, codeRepositoryIndexId, loc
return codeRepositoryIndexId
}

{{- end }}

const sharedTagKeyPrefix = "tf-bootstrap-tagkey"

func BootstrapSharedTestTagKey(t *testing.T, testId string) string {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package gemini_test
{{- if ne $.TargetVersionName "ga" }}

import (
"fmt"
Expand All @@ -22,18 +21,18 @@ func TestAccGeminiRepositoryGroupIamBinding(t *testing.T) {
repositoryGroupId := "tf-test-iam-repository-group-id-" + acctest.RandString(t, 10)

context := map[string]interface{}{
"role": "roles/cloudaicompanion.repositoryGroupsUser",
"code_repository_index": codeRepositoryIndexId,
"location": location,
"project": envvar.GetTestProjectFromEnv(),
"connection_id": developerConnectionId,
"git_link_id": gitRepositoryLinkId,
"repository_group_id": repositoryGroupId,
"role": "roles/cloudaicompanion.repositoryGroupsUser",
"code_repository_index": codeRepositoryIndexId,
"location": location,
"project": envvar.GetTestProjectFromEnv(),
"connection_id": developerConnectionId,
"git_link_id": gitRepositoryLinkId,
"repository_group_id": repositoryGroupId,
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccGeminiRepositoryGroupIamBinding_basic(context),
Expand Down Expand Up @@ -66,18 +65,18 @@ func TestAccGeminiRepositoryGroupIamMember(t *testing.T) {
repositoryGroupId := "tf-test-iam-repository-group-id-" + acctest.RandString(t, 10)

context := map[string]interface{}{
"role": "roles/cloudaicompanion.repositoryGroupsUser",
"code_repository_index": codeRepositoryIndexId,
"location": location,
"project": envvar.GetTestProjectFromEnv(),
"connection_id": developerConnectionId,
"git_link_id": gitRepositoryLinkId,
"repository_group_id": repositoryGroupId,
"role": "roles/cloudaicompanion.repositoryGroupsUser",
"code_repository_index": codeRepositoryIndexId,
"location": location,
"project": envvar.GetTestProjectFromEnv(),
"connection_id": developerConnectionId,
"git_link_id": gitRepositoryLinkId,
"repository_group_id": repositoryGroupId,
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
// Test Iam Member creation (no update for member, no need to test)
Expand All @@ -101,18 +100,18 @@ func TestAccGeminiRepositoryGroupIamPolicy(t *testing.T) {
repositoryGroupId := "tf-test-iam-repository-group-id-" + acctest.RandString(t, 10)

context := map[string]interface{}{
"role": "roles/cloudaicompanion.repositoryGroupsUser",
"code_repository_index": codeRepositoryIndexId,
"location": location,
"project": envvar.GetTestProjectFromEnv(),
"connection_id": developerConnectionId,
"git_link_id": gitRepositoryLinkId,
"repository_group_id": repositoryGroupId,
"role": "roles/cloudaicompanion.repositoryGroupsUser",
"code_repository_index": codeRepositoryIndexId,
"location": location,
"project": envvar.GetTestProjectFromEnv(),
"connection_id": developerConnectionId,
"git_link_id": gitRepositoryLinkId,
"repository_group_id": repositoryGroupId,
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccGeminiRepositoryGroupIamPolicy_basic(context),
Expand Down Expand Up @@ -140,7 +139,6 @@ func TestAccGeminiRepositoryGroupIamPolicy(t *testing.T) {
func testAccGeminiRepositoryGroupIamMember_basic(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_gemini_repository_group_iam_member" "foo" {
provider = google-beta
project = "%{project}"
location = "%{location}"
code_repository_index = "%{code_repository_index}"
Expand All @@ -150,7 +148,6 @@ resource "google_gemini_repository_group_iam_member" "foo" {
}

resource "google_gemini_repository_group" "example" {
provider = google-beta
location = "us-central1"
code_repository_index = "%{code_repository_index}"
repository_group_id = "%{repository_group_id}"
Expand All @@ -166,15 +163,13 @@ resource "google_gemini_repository_group" "example" {
func testAccGeminiRepositoryGroupIamPolicy_basic(context map[string]interface{}) string {
return acctest.Nprintf(`
data "google_iam_policy" "foo" {
provider = google-beta
binding {
role = "%{role}"
members = ["user:[email protected]"]
}
}

resource "google_gemini_repository_group_iam_policy" "foo" {
provider = google-beta
project = "%{project}"
location = "%{location}"
code_repository_index = "%{code_repository_index}"
Expand All @@ -183,7 +178,6 @@ resource "google_gemini_repository_group_iam_policy" "foo" {
}

data "google_gemini_repository_group_iam_policy" "foo" {
provider = google-beta
project = "%{project}"
location = "%{location}"
code_repository_index = "%{code_repository_index}"
Expand All @@ -194,7 +188,6 @@ data "google_gemini_repository_group_iam_policy" "foo" {
}

resource "google_gemini_repository_group" "example" {
provider = google-beta
location = "us-central1"
code_repository_index = "%{code_repository_index}"
repository_group_id = "%{repository_group_id}"
Expand All @@ -210,11 +203,9 @@ resource "google_gemini_repository_group" "example" {
func testAccGeminiRepositoryGroupIamPolicy_emptyBinding(context map[string]interface{}) string {
return acctest.Nprintf(`
data "google_iam_policy" "foo" {
provider = google-beta
}

resource "google_gemini_repository_group_iam_policy" "foo" {
provider = google-beta
project = "%{project}"
location = "%{location}"
code_repository_index = "%{code_repository_index}"
Expand All @@ -223,7 +214,6 @@ resource "google_gemini_repository_group_iam_policy" "foo" {
}

resource "google_gemini_repository_group" "example" {
provider = google-beta
location = "us-central1"
code_repository_index = "%{code_repository_index}"
repository_group_id = "%{repository_group_id}"
Expand All @@ -239,7 +229,6 @@ resource "google_gemini_repository_group" "example" {
func testAccGeminiRepositoryGroupIamBinding_basic(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_gemini_repository_group_iam_binding" "foo" {
provider = google-beta
project = "%{project}"
location = "%{location}"
code_repository_index = "%{code_repository_index}"
Expand All @@ -249,7 +238,6 @@ resource "google_gemini_repository_group_iam_binding" "foo" {
}

resource "google_gemini_repository_group" "example" {
provider = google-beta
location = "us-central1"
code_repository_index = "%{code_repository_index}"
repository_group_id = "%{repository_group_id}"
Expand All @@ -265,7 +253,6 @@ resource "google_gemini_repository_group" "example" {
func testAccGeminiRepositoryGroupIamBinding_update(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_gemini_repository_group_iam_binding" "foo" {
provider = google-beta
project = "%{project}"
location = "%{location}"
code_repository_index = "%{code_repository_index}"
Expand All @@ -275,7 +262,6 @@ resource "google_gemini_repository_group_iam_binding" "foo" {
}

resource "google_gemini_repository_group" "example" {
provider = google-beta
location = "us-central1"
code_repository_index = "%{code_repository_index}"
repository_group_id = "%{repository_group_id}"
Expand All @@ -287,4 +273,3 @@ resource "google_gemini_repository_group" "example" {
}
`, context)
}
{{ end }}
Loading

0 comments on commit b5bdbf8

Please sign in to comment.