Skip to content

Commit 29e22ba

Browse files
Terraform Integration for Capability (#13282) (#9917)
[upstream:4c8da9d42bf631d5534578bbe2fc8255bf71381a] Signed-off-by: Modular Magician <[email protected]>
1 parent e575f29 commit 29e22ba

13 files changed

+673
-2
lines changed

.changelog/13282.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_resource_manager_capability` (beta)
3+
```

google-beta/fwmodels/provider_model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ type ProviderModel struct {
161161
PubsubLiteCustomEndpoint types.String `tfsdk:"pubsub_lite_custom_endpoint"`
162162
RedisCustomEndpoint types.String `tfsdk:"redis_custom_endpoint"`
163163
ResourceManagerCustomEndpoint types.String `tfsdk:"resource_manager_custom_endpoint"`
164+
ResourceManager3CustomEndpoint types.String `tfsdk:"resource_manager3_custom_endpoint"`
164165
RuntimeConfigCustomEndpoint types.String `tfsdk:"runtime_config_custom_endpoint"`
165166
SecretManagerCustomEndpoint types.String `tfsdk:"secret_manager_custom_endpoint"`
166167
SecretManagerRegionalCustomEndpoint types.String `tfsdk:"secret_manager_regional_custom_endpoint"`

google-beta/fwprovider/framework_provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
899899
transport_tpg.CustomEndpointValidator(),
900900
},
901901
},
902+
"resource_manager3_custom_endpoint": &schema.StringAttribute{
903+
Optional: true,
904+
Validators: []validator.String{
905+
transport_tpg.CustomEndpointValidator(),
906+
},
907+
},
902908
"runtime_config_custom_endpoint": &schema.StringAttribute{
903909
Optional: true,
904910
Validators: []validator.String{

google-beta/provider/provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,11 @@ func Provider() *schema.Provider {
789789
Optional: true,
790790
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
791791
},
792+
"resource_manager3_custom_endpoint": {
793+
Type: schema.TypeString,
794+
Optional: true,
795+
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
796+
},
792797
"runtime_config_custom_endpoint": {
793798
Type: schema.TypeString,
794799
Optional: true,
@@ -1272,6 +1277,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
12721277
config.PubsubLiteBasePath = d.Get("pubsub_lite_custom_endpoint").(string)
12731278
config.RedisBasePath = d.Get("redis_custom_endpoint").(string)
12741279
config.ResourceManagerBasePath = d.Get("resource_manager_custom_endpoint").(string)
1280+
config.ResourceManager3BasePath = d.Get("resource_manager3_custom_endpoint").(string)
12751281
config.RuntimeConfigBasePath = d.Get("runtime_config_custom_endpoint").(string)
12761282
config.SecretManagerBasePath = d.Get("secret_manager_custom_endpoint").(string)
12771283
config.SecretManagerRegionalBasePath = d.Get("secret_manager_regional_custom_endpoint").(string)

google-beta/provider/provider_mmv1_resources.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ import (
127127
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/pubsublite"
128128
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/redis"
129129
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/resourcemanager"
130+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/resourcemanager3"
130131
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/runtimeconfig"
131132
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/secretmanager"
132133
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/secretmanagerregional"
@@ -562,9 +563,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
562563
}
563564

564565
// Resources
565-
// Generated resources: 649
566+
// Generated resources: 650
566567
// Generated IAM resources: 327
567-
// Total generated resources: 976
568+
// Total generated resources: 977
568569
var generatedResources = map[string]*schema.Resource{
569570
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
570571
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
@@ -1372,6 +1373,7 @@ var generatedResources = map[string]*schema.Resource{
13721373
"google_redis_cluster_user_created_connections": redis.ResourceRedisClusterUserCreatedConnections(),
13731374
"google_redis_instance": redis.ResourceRedisInstance(),
13741375
"google_resource_manager_lien": resourcemanager.ResourceResourceManagerLien(),
1376+
"google_resource_manager_capability": resourcemanager3.ResourceResourceManager3Capability(),
13751377
"google_runtimeconfig_config_iam_binding": tpgiamresource.ResourceIamBinding(runtimeconfig.RuntimeConfigConfigIamSchema, runtimeconfig.RuntimeConfigConfigIamUpdaterProducer, runtimeconfig.RuntimeConfigConfigIdParseFunc),
13761378
"google_runtimeconfig_config_iam_member": tpgiamresource.ResourceIamMember(runtimeconfig.RuntimeConfigConfigIamSchema, runtimeconfig.RuntimeConfigConfigIamUpdaterProducer, runtimeconfig.RuntimeConfigConfigIdParseFunc),
13771379
"google_runtimeconfig_config_iam_policy": tpgiamresource.ResourceIamPolicy(runtimeconfig.RuntimeConfigConfigIamSchema, runtimeconfig.RuntimeConfigConfigIamUpdaterProducer, runtimeconfig.RuntimeConfigConfigIdParseFunc),
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
// ----------------------------------------------------------------------------
5+
//
6+
// *** AUTO GENERATED CODE *** Type: MMv1 ***
7+
//
8+
// ----------------------------------------------------------------------------
9+
//
10+
// This file is automatically generated by Magic Modules and manual
11+
// changes will be clobbered when the file is regenerated.
12+
//
13+
// Please read more about how to change this file in
14+
// .github/CONTRIBUTING.md.
15+
//
16+
// ----------------------------------------------------------------------------
17+
18+
package resourcemanager3
19+
20+
import (
21+
"encoding/json"
22+
"errors"
23+
"fmt"
24+
"time"
25+
26+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
27+
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
28+
)
29+
30+
type ResourceManager3OperationWaiter struct {
31+
Config *transport_tpg.Config
32+
UserAgent string
33+
tpgresource.CommonOperationWaiter
34+
}
35+
36+
func (w *ResourceManager3OperationWaiter) QueryOp() (interface{}, error) {
37+
if w == nil {
38+
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
39+
}
40+
// Returns the proper get.
41+
url := fmt.Sprintf("%s%s", w.Config.ResourceManager3BasePath, w.CommonOperationWaiter.Op.Name)
42+
43+
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
44+
Config: w.Config,
45+
Method: "GET",
46+
RawURL: url,
47+
UserAgent: w.UserAgent,
48+
})
49+
}
50+
51+
func createResourceManager3Waiter(config *transport_tpg.Config, op map[string]interface{}, activity, userAgent string) (*ResourceManager3OperationWaiter, error) {
52+
w := &ResourceManager3OperationWaiter{
53+
Config: config,
54+
UserAgent: userAgent,
55+
}
56+
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
57+
return nil, err
58+
}
59+
return w, nil
60+
}
61+
62+
// nolint: deadcode,unused
63+
func ResourceManager3OperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, activity, userAgent string, timeout time.Duration) error {
64+
w, err := createResourceManager3Waiter(config, op, activity, userAgent)
65+
if err != nil {
66+
return err
67+
}
68+
if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil {
69+
return err
70+
}
71+
rawResponse := []byte(w.CommonOperationWaiter.Op.Response)
72+
if len(rawResponse) == 0 {
73+
return errors.New("`resource` not set in operation response")
74+
}
75+
return json.Unmarshal(rawResponse, response)
76+
}
77+
78+
func ResourceManager3OperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, activity, userAgent string, timeout time.Duration) error {
79+
if val, ok := op["name"]; !ok || val == "" {
80+
// This was a synchronous call - there is no operation to wait for.
81+
return nil
82+
}
83+
w, err := createResourceManager3Waiter(config, op, activity, userAgent)
84+
if err != nil {
85+
// If w is nil, the op was synchronous.
86+
return err
87+
}
88+
return tpgresource.OperationWait(w, activity, timeout, config.PollInterval)
89+
}

0 commit comments

Comments
 (0)