Skip to content

Commit

Permalink
Add Firebase Data Connect Service (#12853) (#9304)
Browse files Browse the repository at this point in the history
[upstream:e0d4bfff1d715eda63a17259d55305e55a75a6eb]

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Feb 11, 2025
1 parent bc20b18 commit cb5fdc3
Show file tree
Hide file tree
Showing 13 changed files with 1,215 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/12853.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
`google_firebase_data_connect_service`
```
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 {
FirebaseCustomEndpoint types.String `tfsdk:"firebase_custom_endpoint"`
FirebaseAppCheckCustomEndpoint types.String `tfsdk:"firebase_app_check_custom_endpoint"`
FirebaseDatabaseCustomEndpoint types.String `tfsdk:"firebase_database_custom_endpoint"`
FirebaseDataConnectCustomEndpoint types.String `tfsdk:"firebase_data_connect_custom_endpoint"`
FirebaseExtensionsCustomEndpoint types.String `tfsdk:"firebase_extensions_custom_endpoint"`
FirebaseHostingCustomEndpoint types.String `tfsdk:"firebase_hosting_custom_endpoint"`
FirebaseStorageCustomEndpoint types.String `tfsdk:"firebase_storage_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 @@ -593,6 +593,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
transport_tpg.CustomEndpointValidator(),
},
},
"firebase_data_connect_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
transport_tpg.CustomEndpointValidator(),
},
},
"firebase_extensions_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,
},
"firebase_data_connect_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"firebase_extensions_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1157,6 +1162,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.FirebaseBasePath = d.Get("firebase_custom_endpoint").(string)
config.FirebaseAppCheckBasePath = d.Get("firebase_app_check_custom_endpoint").(string)
config.FirebaseDatabaseBasePath = d.Get("firebase_database_custom_endpoint").(string)
config.FirebaseDataConnectBasePath = d.Get("firebase_data_connect_custom_endpoint").(string)
config.FirebaseExtensionsBasePath = d.Get("firebase_extensions_custom_endpoint").(string)
config.FirebaseHostingBasePath = d.Get("firebase_hosting_custom_endpoint").(string)
config.FirebaseStorageBasePath = d.Get("firebase_storage_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/firebase"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/firebaseappcheck"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/firebasedatabase"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/firebasedataconnect"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/firebaseextensions"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/firebasehosting"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/firebasestorage"
Expand Down Expand Up @@ -532,9 +533,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
}

// Resources
// Generated resources: 606
// Generated resources: 607
// Generated IAM resources: 306
// Total generated resources: 912
// Total generated resources: 913
var generatedResources = map[string]*schema.Resource{
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
Expand Down Expand Up @@ -1023,6 +1024,7 @@ var generatedResources = map[string]*schema.Resource{
"google_firebase_app_check_recaptcha_v3_config": firebaseappcheck.ResourceFirebaseAppCheckRecaptchaV3Config(),
"google_firebase_app_check_service_config": firebaseappcheck.ResourceFirebaseAppCheckServiceConfig(),
"google_firebase_database_instance": firebasedatabase.ResourceFirebaseDatabaseInstance(),
"google_firebase_data_connect_service": firebasedataconnect.ResourceFirebaseDataConnectService(),
"google_firebase_extensions_instance": firebaseextensions.ResourceFirebaseExtensionsInstance(),
"google_firebase_hosting_channel": firebasehosting.ResourceFirebaseHostingChannel(),
"google_firebase_hosting_custom_domain": firebasehosting.ResourceFirebaseHostingCustomDomain(),
Expand Down
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 firebasedataconnect

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 FirebaseDataConnectOperationWaiter struct {
Config *transport_tpg.Config
UserAgent string
Project string
tpgresource.CommonOperationWaiter
}

func (w *FirebaseDataConnectOperationWaiter) 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.FirebaseDataConnectBasePath, 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 createFirebaseDataConnectWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*FirebaseDataConnectOperationWaiter, error) {
w := &FirebaseDataConnectOperationWaiter{
Config: config,
UserAgent: userAgent,
Project: project,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
}
return w, nil
}

// nolint: deadcode,unused
func FirebaseDataConnectOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
w, err := createFirebaseDataConnectWaiter(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 FirebaseDataConnectOperationWaitTime(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 := createFirebaseDataConnectWaiter(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 cb5fdc3

Please sign in to comment.