Skip to content

Commit f9b45fb

Browse files
Migration center group (#9425) (#16549)
* Update parser * Correctly parse immutable * More fixes * Remove log line * Fix rubocop * Parser updates * Build product info * Updates to parser, refactor * Enum handling * Add migration center group and preference set * Migration tests * Tests * Only Group * Revert others * Format * Formatting yaml * Formatting yaml * Formatting yaml * Copyright * Update test * PR feedback, description fix [upstream:94a3d7919bfe6dac80333b77f4f6267339d59984] Signed-off-by: Modular Magician <[email protected]>
1 parent 04d0e59 commit f9b45fb

14 files changed

+1138
-2
lines changed

.changelog/9425.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_migration_center_group`
3+
```

.teamcity/components/generated/services.kt

+5
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,11 @@ var services = mapOf(
441441
"displayName" to "Memcache",
442442
"path" to "./google/services/memcache"
443443
),
444+
"migrationcenter" to mapOf(
445+
"name" to "migrationcenter",
446+
"displayName" to "Migrationcenter",
447+
"path" to "./google/services/migrationcenter"
448+
),
444449
"mlengine" to mapOf(
445450
"name" to "mlengine",
446451
"displayName" to "Mlengine",

google/fwmodels/provider_model.go

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ type ProviderModel struct {
9696
LoggingCustomEndpoint types.String `tfsdk:"logging_custom_endpoint"`
9797
LookerCustomEndpoint types.String `tfsdk:"looker_custom_endpoint"`
9898
MemcacheCustomEndpoint types.String `tfsdk:"memcache_custom_endpoint"`
99+
MigrationCenterCustomEndpoint types.String `tfsdk:"migration_center_custom_endpoint"`
99100
MLEngineCustomEndpoint types.String `tfsdk:"ml_engine_custom_endpoint"`
100101
MonitoringCustomEndpoint types.String `tfsdk:"monitoring_custom_endpoint"`
101102
NetworkConnectivityCustomEndpoint types.String `tfsdk:"network_connectivity_custom_endpoint"`

google/fwprovider/framework_provider.go

+6
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
556556
transport_tpg.CustomEndpointValidator(),
557557
},
558558
},
559+
"migration_center_custom_endpoint": &schema.StringAttribute{
560+
Optional: true,
561+
Validators: []validator.String{
562+
transport_tpg.CustomEndpointValidator(),
563+
},
564+
},
559565
"ml_engine_custom_endpoint": &schema.StringAttribute{
560566
Optional: true,
561567
Validators: []validator.String{

google/fwtransport/framework_config.go

+10
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ type FrameworkProviderConfig struct {
121121
LoggingBasePath string
122122
LookerBasePath string
123123
MemcacheBasePath string
124+
MigrationCenterBasePath string
124125
MLEngineBasePath string
125126
MonitoringBasePath string
126127
NetworkConnectivityBasePath string
@@ -261,6 +262,7 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context,
261262
p.LoggingBasePath = data.LoggingCustomEndpoint.ValueString()
262263
p.LookerBasePath = data.LookerCustomEndpoint.ValueString()
263264
p.MemcacheBasePath = data.MemcacheCustomEndpoint.ValueString()
265+
p.MigrationCenterBasePath = data.MigrationCenterCustomEndpoint.ValueString()
264266
p.MLEngineBasePath = data.MLEngineCustomEndpoint.ValueString()
265267
p.MonitoringBasePath = data.MonitoringCustomEndpoint.ValueString()
266268
p.NetworkConnectivityBasePath = data.NetworkConnectivityCustomEndpoint.ValueString()
@@ -979,6 +981,14 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo
979981
data.MemcacheCustomEndpoint = types.StringValue(customEndpoint.(string))
980982
}
981983
}
984+
if data.MigrationCenterCustomEndpoint.IsNull() {
985+
customEndpoint := transport_tpg.MultiEnvDefault([]string{
986+
"GOOGLE_MIGRATION_CENTER_CUSTOM_ENDPOINT",
987+
}, transport_tpg.DefaultBasePaths[transport_tpg.MigrationCenterBasePathKey])
988+
if customEndpoint != nil {
989+
data.MigrationCenterCustomEndpoint = types.StringValue(customEndpoint.(string))
990+
}
991+
}
982992
if data.MLEngineCustomEndpoint.IsNull() {
983993
customEndpoint := transport_tpg.MultiEnvDefault([]string{
984994
"GOOGLE_ML_ENGINE_CUSTOM_ENDPOINT",

google/provider/provider.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import (
8484
"github.com/hashicorp/terraform-provider-google/google/services/logging"
8585
"github.com/hashicorp/terraform-provider-google/google/services/looker"
8686
"github.com/hashicorp/terraform-provider-google/google/services/memcache"
87+
"github.com/hashicorp/terraform-provider-google/google/services/migrationcenter"
8788
"github.com/hashicorp/terraform-provider-google/google/services/mlengine"
8889
"github.com/hashicorp/terraform-provider-google/google/services/monitoring"
8990
"github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity"
@@ -594,6 +595,11 @@ func Provider() *schema.Provider {
594595
Optional: true,
595596
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
596597
},
598+
"migration_center_custom_endpoint": {
599+
Type: schema.TypeString,
600+
Optional: true,
601+
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
602+
},
597603
"ml_engine_custom_endpoint": {
598604
Type: schema.TypeString,
599605
Optional: true,
@@ -1028,9 +1034,9 @@ func DatasourceMapWithErrors() (map[string]*schema.Resource, error) {
10281034
})
10291035
}
10301036

1031-
// Generated resources: 339
1037+
// Generated resources: 340
10321038
// Generated IAM resources: 210
1033-
// Total generated resources: 549
1039+
// Total generated resources: 550
10341040
func ResourceMap() map[string]*schema.Resource {
10351041
resourceMap, _ := ResourceMapWithErrors()
10361042
return resourceMap
@@ -1457,6 +1463,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
14571463
"google_logging_metric": logging.ResourceLoggingMetric(),
14581464
"google_looker_instance": looker.ResourceLookerInstance(),
14591465
"google_memcache_instance": memcache.ResourceMemcacheInstance(),
1466+
"google_migration_center_group": migrationcenter.ResourceMigrationCenterGroup(),
14601467
"google_ml_engine_model": mlengine.ResourceMLEngineModel(),
14611468
"google_monitoring_alert_policy": monitoring.ResourceMonitoringAlertPolicy(),
14621469
"google_monitoring_service": monitoring.ResourceMonitoringGenericService(),
@@ -1930,6 +1937,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
19301937
config.LoggingBasePath = d.Get("logging_custom_endpoint").(string)
19311938
config.LookerBasePath = d.Get("looker_custom_endpoint").(string)
19321939
config.MemcacheBasePath = d.Get("memcache_custom_endpoint").(string)
1940+
config.MigrationCenterBasePath = d.Get("migration_center_custom_endpoint").(string)
19331941
config.MLEngineBasePath = d.Get("ml_engine_custom_endpoint").(string)
19341942
config.MonitoringBasePath = d.Get("monitoring_custom_endpoint").(string)
19351943
config.NetworkConnectivityBasePath = d.Get("network_connectivity_custom_endpoint").(string)
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 migrationcenter
19+
20+
import (
21+
"encoding/json"
22+
"errors"
23+
"fmt"
24+
"time"
25+
26+
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
27+
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
28+
)
29+
30+
type MigrationCenterOperationWaiter struct {
31+
Config *transport_tpg.Config
32+
UserAgent string
33+
Project string
34+
tpgresource.CommonOperationWaiter
35+
}
36+
37+
func (w *MigrationCenterOperationWaiter) 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.MigrationCenterBasePath, 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 createMigrationCenterWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*MigrationCenterOperationWaiter, error) {
54+
w := &MigrationCenterOperationWaiter{
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 MigrationCenterOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
67+
w, err := createMigrationCenterWaiter(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 MigrationCenterOperationWaitTime(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 := createMigrationCenterWaiter(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)