Skip to content

Commit 978a2ab

Browse files
Adding Parallelstore Beta Service Provider (#9910) (#7209)
[upstream:6a68afaf8470a20f1e06d6bb603cc6bf0abbd34f] Signed-off-by: Modular Magician <[email protected]>
1 parent 3017b58 commit 978a2ab

14 files changed

+1443
-2
lines changed

.changelog/9910.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_parallelstore_instance`
3+
```

google-beta/fwmodels/provider_model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ type ProviderModel struct {
126126
OrgPolicyCustomEndpoint types.String `tfsdk:"org_policy_custom_endpoint"`
127127
OSConfigCustomEndpoint types.String `tfsdk:"os_config_custom_endpoint"`
128128
OSLoginCustomEndpoint types.String `tfsdk:"os_login_custom_endpoint"`
129+
ParallelstoreCustomEndpoint types.String `tfsdk:"parallelstore_custom_endpoint"`
129130
PrivatecaCustomEndpoint types.String `tfsdk:"privateca_custom_endpoint"`
130131
PublicCACustomEndpoint types.String `tfsdk:"public_ca_custom_endpoint"`
131132
PubsubCustomEndpoint types.String `tfsdk:"pubsub_custom_endpoint"`

google-beta/fwprovider/framework_provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
734734
transport_tpg.CustomEndpointValidator(),
735735
},
736736
},
737+
"parallelstore_custom_endpoint": &schema.StringAttribute{
738+
Optional: true,
739+
Validators: []validator.String{
740+
transport_tpg.CustomEndpointValidator(),
741+
},
742+
},
737743
"privateca_custom_endpoint": &schema.StringAttribute{
738744
Optional: true,
739745
Validators: []validator.String{

google-beta/fwtransport/framework_config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ type FrameworkProviderConfig struct {
149149
OrgPolicyBasePath string
150150
OSConfigBasePath string
151151
OSLoginBasePath string
152+
ParallelstoreBasePath string
152153
PrivatecaBasePath string
153154
PublicCABasePath string
154155
PubsubBasePath string
@@ -316,6 +317,7 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context,
316317
p.OrgPolicyBasePath = data.OrgPolicyCustomEndpoint.ValueString()
317318
p.OSConfigBasePath = data.OSConfigCustomEndpoint.ValueString()
318319
p.OSLoginBasePath = data.OSLoginCustomEndpoint.ValueString()
320+
p.ParallelstoreBasePath = data.ParallelstoreCustomEndpoint.ValueString()
319321
p.PrivatecaBasePath = data.PrivatecaCustomEndpoint.ValueString()
320322
p.PublicCABasePath = data.PublicCACustomEndpoint.ValueString()
321323
p.PubsubBasePath = data.PubsubCustomEndpoint.ValueString()
@@ -1257,6 +1259,14 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo
12571259
data.OSLoginCustomEndpoint = types.StringValue(customEndpoint.(string))
12581260
}
12591261
}
1262+
if data.ParallelstoreCustomEndpoint.IsNull() {
1263+
customEndpoint := transport_tpg.MultiEnvDefault([]string{
1264+
"GOOGLE_PARALLELSTORE_CUSTOM_ENDPOINT",
1265+
}, transport_tpg.DefaultBasePaths[transport_tpg.ParallelstoreBasePathKey])
1266+
if customEndpoint != nil {
1267+
data.ParallelstoreCustomEndpoint = types.StringValue(customEndpoint.(string))
1268+
}
1269+
}
12601270
if data.PrivatecaCustomEndpoint.IsNull() {
12611271
customEndpoint := transport_tpg.MultiEnvDefault([]string{
12621272
"GOOGLE_PRIVATECA_CUSTOM_ENDPOINT",

google-beta/provider/provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,11 @@ func Provider() *schema.Provider {
635635
Optional: true,
636636
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
637637
},
638+
"parallelstore_custom_endpoint": {
639+
Type: schema.TypeString,
640+
Optional: true,
641+
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
642+
},
638643
"privateca_custom_endpoint": {
639644
Type: schema.TypeString,
640645
Optional: true,
@@ -1098,6 +1103,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
10981103
config.OrgPolicyBasePath = d.Get("org_policy_custom_endpoint").(string)
10991104
config.OSConfigBasePath = d.Get("os_config_custom_endpoint").(string)
11001105
config.OSLoginBasePath = d.Get("os_login_custom_endpoint").(string)
1106+
config.ParallelstoreBasePath = d.Get("parallelstore_custom_endpoint").(string)
11011107
config.PrivatecaBasePath = d.Get("privateca_custom_endpoint").(string)
11021108
config.PublicCABasePath = d.Get("public_ca_custom_endpoint").(string)
11031109
config.PubsubBasePath = d.Get("pubsub_custom_endpoint").(string)

google-beta/provider/provider_mmv1_resources.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ import (
103103
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/orgpolicy"
104104
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/osconfig"
105105
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/oslogin"
106+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/parallelstore"
106107
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/privateca"
107108
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/publicca"
108109
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/pubsub"
@@ -443,9 +444,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
443444
}
444445

445446
// Resources
446-
// Generated resources: 456
447+
// Generated resources: 457
447448
// Generated IAM resources: 267
448-
// Total generated resources: 723
449+
// Total generated resources: 724
449450
var generatedResources = map[string]*schema.Resource{
450451
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
451452
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
@@ -1030,6 +1031,7 @@ var generatedResources = map[string]*schema.Resource{
10301031
"google_os_config_guest_policies": osconfig.ResourceOSConfigGuestPolicies(),
10311032
"google_os_config_patch_deployment": osconfig.ResourceOSConfigPatchDeployment(),
10321033
"google_os_login_ssh_public_key": oslogin.ResourceOSLoginSSHPublicKey(),
1034+
"google_parallelstore_instance": parallelstore.ResourceParallelstoreInstance(),
10331035
"google_privateca_ca_pool": privateca.ResourcePrivatecaCaPool(),
10341036
"google_privateca_ca_pool_iam_binding": tpgiamresource.ResourceIamBinding(privateca.PrivatecaCaPoolIamSchema, privateca.PrivatecaCaPoolIamUpdaterProducer, privateca.PrivatecaCaPoolIdParseFunc),
10351037
"google_privateca_ca_pool_iam_member": tpgiamresource.ResourceIamMember(privateca.PrivatecaCaPoolIamSchema, privateca.PrivatecaCaPoolIamUpdaterProducer, privateca.PrivatecaCaPoolIdParseFunc),
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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 parallelstore
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 ParallelstoreOperationWaiter struct {
31+
Config *transport_tpg.Config
32+
UserAgent string
33+
Project string
34+
tpgresource.CommonOperationWaiter
35+
}
36+
37+
func (w *ParallelstoreOperationWaiter) QueryOp() (interface{}, error) {
38+
if w == nil {
39+
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
40+
}
41+
// Returns the proper get.
42+
url := fmt.Sprintf("%s%s", w.Config.ParallelstoreBasePath, w.CommonOperationWaiter.Op.Name)
43+
44+
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
45+
Config: w.Config,
46+
Method: "GET",
47+
Project: w.Project,
48+
RawURL: url,
49+
UserAgent: w.UserAgent,
50+
})
51+
}
52+
53+
func createParallelstoreWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*ParallelstoreOperationWaiter, error) {
54+
w := &ParallelstoreOperationWaiter{
55+
Config: config,
56+
UserAgent: userAgent,
57+
Project: project,
58+
}
59+
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
60+
return nil, err
61+
}
62+
return w, nil
63+
}
64+
65+
// nolint: deadcode,unused
66+
func ParallelstoreOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
67+
w, err := createParallelstoreWaiter(config, op, project, activity, userAgent)
68+
if err != nil {
69+
return err
70+
}
71+
if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil {
72+
return err
73+
}
74+
rawResponse := []byte(w.CommonOperationWaiter.Op.Response)
75+
if len(rawResponse) == 0 {
76+
return errors.New("`resource` not set in operation response")
77+
}
78+
return json.Unmarshal(rawResponse, response)
79+
}
80+
81+
func ParallelstoreOperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
82+
if val, ok := op["name"]; !ok || val == "" {
83+
// This was a synchronous call - there is no operation to wait for.
84+
return nil
85+
}
86+
w, err := createParallelstoreWaiter(config, op, project, activity, userAgent)
87+
if err != nil {
88+
// If w is nil, the op was synchronous.
89+
return err
90+
}
91+
return tpgresource.OperationWait(w, activity, timeout, config.PollInterval)
92+
}

0 commit comments

Comments
 (0)