Skip to content

Commit

Permalink
Add Code Repository Index resource (#12338) (#8781)
Browse files Browse the repository at this point in the history
[upstream:04174a883cf719344a49b5d8ddce33074f29dcf2]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Nov 25, 2024
1 parent 13cdd50 commit 301aca6
Show file tree
Hide file tree
Showing 14 changed files with 1,036 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/12338.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
`google_gemini_code_repository_index`
```
2 changes: 1 addition & 1 deletion google-beta/acctest/bootstrap_test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ func NewServiceNetworkSettings(options ...func(*ServiceNetworkSettings)) *Servic
// must be deleted first. After the service instances are deleted, some service producers delay the deletion
// utnil a waiting period has passed. For example, after four days that you delete a SQL instance,
// the service networking connection can be deleted.
// That is the reason to use the shared service networking connection for thest resources.
// That is the reason to use the shared service networking connection for test resources.
// https://cloud.google.com/vpc/docs/configure-private-services-access#removing-connection
//
// testId specifies the test for which a shared network and a gobal address are used/initialized.
Expand Down
1 change: 1 addition & 0 deletions google-beta/fwmodels/provider_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ type ProviderModel struct {
FirebaseHostingCustomEndpoint types.String `tfsdk:"firebase_hosting_custom_endpoint"`
FirebaseStorageCustomEndpoint types.String `tfsdk:"firebase_storage_custom_endpoint"`
FirestoreCustomEndpoint types.String `tfsdk:"firestore_custom_endpoint"`
GeminiCustomEndpoint types.String `tfsdk:"gemini_custom_endpoint"`
GKEBackupCustomEndpoint types.String `tfsdk:"gke_backup_custom_endpoint"`
GKEHubCustomEndpoint types.String `tfsdk:"gke_hub_custom_endpoint"`
GKEHub2CustomEndpoint types.String `tfsdk:"gke_hub2_custom_endpoint"`
Expand Down
6 changes: 6 additions & 0 deletions google-beta/fwprovider/framework_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
transport_tpg.CustomEndpointValidator(),
},
},
"gemini_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
transport_tpg.CustomEndpointValidator(),
},
},
"gke_backup_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
Expand Down
6 changes: 6 additions & 0 deletions google-beta/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,11 @@ func Provider() *schema.Provider {
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"gemini_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"gke_backup_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1122,6 +1127,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.FirebaseHostingBasePath = d.Get("firebase_hosting_custom_endpoint").(string)
config.FirebaseStorageBasePath = d.Get("firebase_storage_custom_endpoint").(string)
config.FirestoreBasePath = d.Get("firestore_custom_endpoint").(string)
config.GeminiBasePath = d.Get("gemini_custom_endpoint").(string)
config.GKEBackupBasePath = d.Get("gke_backup_custom_endpoint").(string)
config.GKEHubBasePath = d.Get("gke_hub_custom_endpoint").(string)
config.GKEHub2BasePath = d.Get("gke_hub2_custom_endpoint").(string)
Expand Down
6 changes: 4 additions & 2 deletions google-beta/provider/provider_mmv1_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import (
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/firebasehosting"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/firebasestorage"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/firestore"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/gemini"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/gkebackup"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/gkehub"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/gkehub2"
Expand Down Expand Up @@ -507,9 +508,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
}

// Resources
// Generated resources: 558
// Generated resources: 559
// Generated IAM resources: 291
// Total generated resources: 849
// Total generated resources: 850
var generatedResources = map[string]*schema.Resource{
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
Expand Down Expand Up @@ -976,6 +977,7 @@ var generatedResources = map[string]*schema.Resource{
"google_firestore_document": firestore.ResourceFirestoreDocument(),
"google_firestore_field": firestore.ResourceFirestoreField(),
"google_firestore_index": firestore.ResourceFirestoreIndex(),
"google_gemini_code_repository_index": gemini.ResourceGeminiCodeRepositoryIndex(),
"google_gke_backup_backup_plan": gkebackup.ResourceGKEBackupBackupPlan(),
"google_gke_backup_backup_plan_iam_binding": tpgiamresource.ResourceIamBinding(gkebackup.GKEBackupBackupPlanIamSchema, gkebackup.GKEBackupBackupPlanIamUpdaterProducer, gkebackup.GKEBackupBackupPlanIdParseFunc),
"google_gke_backup_backup_plan_iam_member": tpgiamresource.ResourceIamMember(gkebackup.GKEBackupBackupPlanIamSchema, gkebackup.GKEBackupBackupPlanIamUpdaterProducer, gkebackup.GKEBackupBackupPlanIdParseFunc),
Expand Down
92 changes: 92 additions & 0 deletions google-beta/services/gemini/gemini_operation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package gemini

import (
"encoding/json"
"errors"
"fmt"
"time"

"github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
)

type GeminiOperationWaiter struct {
Config *transport_tpg.Config
UserAgent string
Project string
tpgresource.CommonOperationWaiter
}

func (w *GeminiOperationWaiter) QueryOp() (interface{}, error) {
if w == nil {
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
}
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.GeminiBasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createGeminiWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*GeminiOperationWaiter, error) {
w := &GeminiOperationWaiter{
Config: config,
UserAgent: userAgent,
Project: project,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
}
return w, nil
}

// nolint: deadcode,unused
func GeminiOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
w, err := createGeminiWaiter(config, op, project, activity, userAgent)
if err != nil {
return err
}
if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil {
return err
}
rawResponse := []byte(w.CommonOperationWaiter.Op.Response)
if len(rawResponse) == 0 {
return errors.New("`resource` not set in operation response")
}
return json.Unmarshal(rawResponse, response)
}

func GeminiOperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
if val, ok := op["name"]; !ok || val == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
}
w, err := createGeminiWaiter(config, op, project, activity, userAgent)
if err != nil {
// If w is nil, the op was synchronous.
return err
}
return tpgresource.OperationWait(w, activity, timeout, config.PollInterval)
}
Loading

0 comments on commit 301aca6

Please sign in to comment.