Skip to content

Commit

Permalink
Cloud Domains Registration (#9772) (#6833)
Browse files Browse the repository at this point in the history
[upstream:52434b30324b0b85d26383a7c433a027427da250]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Jan 9, 2024
1 parent cd5d893 commit 4228df6
Show file tree
Hide file tree
Showing 12 changed files with 2,639 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/9772.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
`google_clouddomains_registration`
```
5 changes: 5 additions & 0 deletions .teamcity/components/generated/services.kt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ var services = mapOf(
"displayName" to "Clouddeploy",
"path" to "./google-beta/services/clouddeploy"
),
"clouddomains" to mapOf(
"name" to "clouddomains",
"displayName" to "Clouddomains",
"path" to "./google-beta/services/clouddomains"
),
"cloudfunctions" to mapOf(
"name" to "cloudfunctions",
"displayName" to "Cloudfunctions",
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 @@ -51,6 +51,7 @@ type ProviderModel struct {
CloudBuildCustomEndpoint types.String `tfsdk:"cloud_build_custom_endpoint"`
Cloudbuildv2CustomEndpoint types.String `tfsdk:"cloudbuildv2_custom_endpoint"`
ClouddeployCustomEndpoint types.String `tfsdk:"clouddeploy_custom_endpoint"`
ClouddomainsCustomEndpoint types.String `tfsdk:"clouddomains_custom_endpoint"`
CloudFunctionsCustomEndpoint types.String `tfsdk:"cloud_functions_custom_endpoint"`
Cloudfunctions2CustomEndpoint types.String `tfsdk:"cloudfunctions2_custom_endpoint"`
CloudIdentityCustomEndpoint types.String `tfsdk:"cloud_identity_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 @@ -287,6 +287,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
transport_tpg.CustomEndpointValidator(),
},
},
"clouddomains_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
transport_tpg.CustomEndpointValidator(),
},
},
"cloud_functions_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
Expand Down
10 changes: 10 additions & 0 deletions google-beta/fwtransport/framework_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type FrameworkProviderConfig struct {
CloudBuildBasePath string
Cloudbuildv2BasePath string
ClouddeployBasePath string
ClouddomainsBasePath string
CloudFunctionsBasePath string
Cloudfunctions2BasePath string
CloudIdentityBasePath string
Expand Down Expand Up @@ -235,6 +236,7 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context,
p.CloudBuildBasePath = data.CloudBuildCustomEndpoint.ValueString()
p.Cloudbuildv2BasePath = data.Cloudbuildv2CustomEndpoint.ValueString()
p.ClouddeployBasePath = data.ClouddeployCustomEndpoint.ValueString()
p.ClouddomainsBasePath = data.ClouddomainsCustomEndpoint.ValueString()
p.CloudFunctionsBasePath = data.CloudFunctionsCustomEndpoint.ValueString()
p.Cloudfunctions2BasePath = data.Cloudfunctions2CustomEndpoint.ValueString()
p.CloudIdentityBasePath = data.CloudIdentityCustomEndpoint.ValueString()
Expand Down Expand Up @@ -657,6 +659,14 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo
data.ClouddeployCustomEndpoint = types.StringValue(customEndpoint.(string))
}
}
if data.ClouddomainsCustomEndpoint.IsNull() {
customEndpoint := transport_tpg.MultiEnvDefault([]string{
"GOOGLE_CLOUDDOMAINS_CUSTOM_ENDPOINT",
}, transport_tpg.DefaultBasePaths[transport_tpg.ClouddomainsBasePathKey])
if customEndpoint != nil {
data.ClouddomainsCustomEndpoint = types.StringValue(customEndpoint.(string))
}
}
if data.CloudFunctionsCustomEndpoint.IsNull() {
customEndpoint := transport_tpg.MultiEnvDefault([]string{
"GOOGLE_CLOUD_FUNCTIONS_CUSTOM_ENDPOINT",
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 @@ -260,6 +260,11 @@ func Provider() *schema.Provider {
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"clouddomains_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"cloud_functions_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -961,6 +966,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.CloudBuildBasePath = d.Get("cloud_build_custom_endpoint").(string)
config.Cloudbuildv2BasePath = d.Get("cloudbuildv2_custom_endpoint").(string)
config.ClouddeployBasePath = d.Get("clouddeploy_custom_endpoint").(string)
config.ClouddomainsBasePath = d.Get("clouddomains_custom_endpoint").(string)
config.CloudFunctionsBasePath = d.Get("cloud_functions_custom_endpoint").(string)
config.Cloudfunctions2BasePath = d.Get("cloudfunctions2_custom_endpoint").(string)
config.CloudIdentityBasePath = d.Get("cloud_identity_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 @@ -30,6 +30,7 @@ import (
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/cloudbuild"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/cloudbuildv2"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/clouddeploy"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/clouddomains"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/cloudfunctions"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/cloudfunctions2"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/cloudidentity"
Expand Down Expand Up @@ -421,9 +422,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
}

// Resources
// Generated resources: 417
// Generated resources: 418
// Generated IAM resources: 252
// Total generated resources: 669
// Total generated resources: 670
var generatedResources = map[string]*schema.Resource{
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
Expand Down Expand Up @@ -548,6 +549,7 @@ var generatedResources = map[string]*schema.Resource{
"google_cloudbuildv2_connection_iam_member": tpgiamresource.ResourceIamMember(cloudbuildv2.Cloudbuildv2ConnectionIamSchema, cloudbuildv2.Cloudbuildv2ConnectionIamUpdaterProducer, cloudbuildv2.Cloudbuildv2ConnectionIdParseFunc),
"google_cloudbuildv2_connection_iam_policy": tpgiamresource.ResourceIamPolicy(cloudbuildv2.Cloudbuildv2ConnectionIamSchema, cloudbuildv2.Cloudbuildv2ConnectionIamUpdaterProducer, cloudbuildv2.Cloudbuildv2ConnectionIdParseFunc),
"google_clouddeploy_automation": clouddeploy.ResourceClouddeployAutomation(),
"google_clouddomains_registration": clouddomains.ResourceClouddomainsRegistration(),
"google_cloudfunctions_function_iam_binding": tpgiamresource.ResourceIamBinding(cloudfunctions.CloudFunctionsCloudFunctionIamSchema, cloudfunctions.CloudFunctionsCloudFunctionIamUpdaterProducer, cloudfunctions.CloudFunctionsCloudFunctionIdParseFunc),
"google_cloudfunctions_function_iam_member": tpgiamresource.ResourceIamMember(cloudfunctions.CloudFunctionsCloudFunctionIamSchema, cloudfunctions.CloudFunctionsCloudFunctionIamUpdaterProducer, cloudfunctions.CloudFunctionsCloudFunctionIdParseFunc),
"google_cloudfunctions_function_iam_policy": tpgiamresource.ResourceIamPolicy(cloudfunctions.CloudFunctionsCloudFunctionIamSchema, cloudfunctions.CloudFunctionsCloudFunctionIamUpdaterProducer, cloudfunctions.CloudFunctionsCloudFunctionIdParseFunc),
Expand Down
92 changes: 92 additions & 0 deletions google-beta/services/clouddomains/clouddomains_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 clouddomains

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

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

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

Please sign in to comment.