Skip to content

Commit 07f0770

Browse files
Add support for Database Migration Services - Connection Profile resource (#7447) (#14383)
Signed-off-by: Modular Magician <[email protected]>
1 parent b0215fc commit 07f0770

13 files changed

+4140
-358
lines changed

.changelog/7447.txt

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

google/config.go

+193-184
Large diffs are not rendered by default.

google/config_test_utils.go

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func configureTestBasePaths(c *Config, url string) {
5353
c.ComputeBasePath = url
5454
c.ContainerAnalysisBasePath = url
5555
c.ContainerAttachedBasePath = url
56+
c.DatabaseMigrationServiceBasePath = url
5657
c.DataCatalogBasePath = url
5758
c.DataFusionBasePath = url
5859
c.DataLossPreventionBasePath = url
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// ----------------------------------------------------------------------------
2+
//
3+
// *** AUTO GENERATED CODE *** Type: MMv1 ***
4+
//
5+
// ----------------------------------------------------------------------------
6+
//
7+
// This file is automatically generated by Magic Modules and manual
8+
// changes will be clobbered when the file is regenerated.
9+
//
10+
// Please read more about how to change this file in
11+
// .github/CONTRIBUTING.md.
12+
//
13+
// ----------------------------------------------------------------------------
14+
15+
package google
16+
17+
import (
18+
"fmt"
19+
"time"
20+
)
21+
22+
type DatabaseMigrationServiceOperationWaiter struct {
23+
Config *Config
24+
UserAgent string
25+
Project string
26+
CommonOperationWaiter
27+
}
28+
29+
func (w *DatabaseMigrationServiceOperationWaiter) QueryOp() (interface{}, error) {
30+
if w == nil {
31+
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
32+
}
33+
// Returns the proper get.
34+
url := fmt.Sprintf("%s%s", w.Config.DatabaseMigrationServiceBasePath, w.CommonOperationWaiter.Op.Name)
35+
36+
return SendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
37+
}
38+
39+
func createDatabaseMigrationServiceWaiter(config *Config, op map[string]interface{}, project, activity, userAgent string) (*DatabaseMigrationServiceOperationWaiter, error) {
40+
w := &DatabaseMigrationServiceOperationWaiter{
41+
Config: config,
42+
UserAgent: userAgent,
43+
Project: project,
44+
}
45+
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
46+
return nil, err
47+
}
48+
return w, nil
49+
}
50+
51+
func DatabaseMigrationServiceOperationWaitTime(config *Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
52+
if val, ok := op["name"]; !ok || val == "" {
53+
// This was a synchronous call - there is no operation to wait for.
54+
return nil
55+
}
56+
w, err := createDatabaseMigrationServiceWaiter(config, op, project, activity, userAgent)
57+
if err != nil {
58+
// If w is nil, the op was synchronous.
59+
return err
60+
}
61+
return OperationWait(w, activity, timeout, config.PollInterval)
62+
}

google/framework_config.go

+9
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func (p *frameworkProvider) LoadAndValidateFramework(ctx context.Context, data P
9494
p.ComputeBasePath = data.ComputeCustomEndpoint.ValueString()
9595
p.ContainerAnalysisBasePath = data.ContainerAnalysisCustomEndpoint.ValueString()
9696
p.ContainerAttachedBasePath = data.ContainerAttachedCustomEndpoint.ValueString()
97+
p.DatabaseMigrationServiceBasePath = data.DatabaseMigrationServiceCustomEndpoint.ValueString()
9798
p.DataCatalogBasePath = data.DataCatalogCustomEndpoint.ValueString()
9899
p.DataFusionBasePath = data.DataFusionCustomEndpoint.ValueString()
99100
p.DataLossPreventionBasePath = data.DataLossPreventionCustomEndpoint.ValueString()
@@ -526,6 +527,14 @@ func (p *frameworkProvider) HandleDefaults(ctx context.Context, data *ProviderMo
526527
data.ContainerAttachedCustomEndpoint = types.StringValue(customEndpoint.(string))
527528
}
528529
}
530+
if data.DatabaseMigrationServiceCustomEndpoint.IsNull() {
531+
customEndpoint := MultiEnvDefault([]string{
532+
"GOOGLE_DATABASE_MIGRATION_SERVICE_CUSTOM_ENDPOINT",
533+
}, DefaultBasePaths[DatabaseMigrationServiceBasePathKey])
534+
if customEndpoint != nil {
535+
data.DatabaseMigrationServiceCustomEndpoint = types.StringValue(customEndpoint.(string))
536+
}
537+
}
529538
if data.DataCatalogCustomEndpoint.IsNull() {
530539
customEndpoint := MultiEnvDefault([]string{
531540
"GOOGLE_DATA_CATALOG_CUSTOM_ENDPOINT",

google/framework_provider.go

+93-86
Original file line numberDiff line numberDiff line change
@@ -55,92 +55,93 @@ type frameworkProvider struct {
5555
version string
5656

5757
// paths for client setup
58-
AccessApprovalBasePath string
59-
AccessContextManagerBasePath string
60-
ActiveDirectoryBasePath string
61-
AlloydbBasePath string
62-
ApigeeBasePath string
63-
AppEngineBasePath string
64-
ArtifactRegistryBasePath string
65-
BeyondcorpBasePath string
66-
BigQueryBasePath string
67-
BigqueryAnalyticsHubBasePath string
68-
BigqueryConnectionBasePath string
69-
BigqueryDatapolicyBasePath string
70-
BigqueryDataTransferBasePath string
71-
BigqueryReservationBasePath string
72-
BigtableBasePath string
73-
BillingBasePath string
74-
BinaryAuthorizationBasePath string
75-
CertificateManagerBasePath string
76-
CloudAssetBasePath string
77-
CloudBuildBasePath string
78-
CloudFunctionsBasePath string
79-
Cloudfunctions2BasePath string
80-
CloudIdentityBasePath string
81-
CloudIdsBasePath string
82-
CloudIotBasePath string
83-
CloudRunBasePath string
84-
CloudRunV2BasePath string
85-
CloudSchedulerBasePath string
86-
CloudTasksBasePath string
87-
ComputeBasePath string
88-
ContainerAnalysisBasePath string
89-
ContainerAttachedBasePath string
90-
DataCatalogBasePath string
91-
DataFusionBasePath string
92-
DataLossPreventionBasePath string
93-
DataplexBasePath string
94-
DataprocBasePath string
95-
DataprocMetastoreBasePath string
96-
DatastoreBasePath string
97-
DatastreamBasePath string
98-
DeploymentManagerBasePath string
99-
DialogflowBasePath string
100-
DialogflowCXBasePath string
101-
DNSBasePath string
102-
DocumentAIBasePath string
103-
EssentialContactsBasePath string
104-
FilestoreBasePath string
105-
FirestoreBasePath string
106-
GameServicesBasePath string
107-
GKEBackupBasePath string
108-
GKEHubBasePath string
109-
HealthcareBasePath string
110-
IAM2BasePath string
111-
IAMBetaBasePath string
112-
IAMWorkforcePoolBasePath string
113-
IapBasePath string
114-
IdentityPlatformBasePath string
115-
KMSBasePath string
116-
LoggingBasePath string
117-
MemcacheBasePath string
118-
MLEngineBasePath string
119-
MonitoringBasePath string
120-
NetworkManagementBasePath string
121-
NetworkServicesBasePath string
122-
NotebooksBasePath string
123-
OSConfigBasePath string
124-
OSLoginBasePath string
125-
PrivatecaBasePath string
126-
PubsubBasePath string
127-
PubsubLiteBasePath string
128-
RedisBasePath string
129-
ResourceManagerBasePath string
130-
SecretManagerBasePath string
131-
SecurityCenterBasePath string
132-
ServiceManagementBasePath string
133-
ServiceUsageBasePath string
134-
SourceRepoBasePath string
135-
SpannerBasePath string
136-
SQLBasePath string
137-
StorageBasePath string
138-
StorageTransferBasePath string
139-
TagsBasePath string
140-
TPUBasePath string
141-
VertexAIBasePath string
142-
VPCAccessBasePath string
143-
WorkflowsBasePath string
58+
AccessApprovalBasePath string
59+
AccessContextManagerBasePath string
60+
ActiveDirectoryBasePath string
61+
AlloydbBasePath string
62+
ApigeeBasePath string
63+
AppEngineBasePath string
64+
ArtifactRegistryBasePath string
65+
BeyondcorpBasePath string
66+
BigQueryBasePath string
67+
BigqueryAnalyticsHubBasePath string
68+
BigqueryConnectionBasePath string
69+
BigqueryDatapolicyBasePath string
70+
BigqueryDataTransferBasePath string
71+
BigqueryReservationBasePath string
72+
BigtableBasePath string
73+
BillingBasePath string
74+
BinaryAuthorizationBasePath string
75+
CertificateManagerBasePath string
76+
CloudAssetBasePath string
77+
CloudBuildBasePath string
78+
CloudFunctionsBasePath string
79+
Cloudfunctions2BasePath string
80+
CloudIdentityBasePath string
81+
CloudIdsBasePath string
82+
CloudIotBasePath string
83+
CloudRunBasePath string
84+
CloudRunV2BasePath string
85+
CloudSchedulerBasePath string
86+
CloudTasksBasePath string
87+
ComputeBasePath string
88+
ContainerAnalysisBasePath string
89+
ContainerAttachedBasePath string
90+
DatabaseMigrationServiceBasePath string
91+
DataCatalogBasePath string
92+
DataFusionBasePath string
93+
DataLossPreventionBasePath string
94+
DataplexBasePath string
95+
DataprocBasePath string
96+
DataprocMetastoreBasePath string
97+
DatastoreBasePath string
98+
DatastreamBasePath string
99+
DeploymentManagerBasePath string
100+
DialogflowBasePath string
101+
DialogflowCXBasePath string
102+
DNSBasePath string
103+
DocumentAIBasePath string
104+
EssentialContactsBasePath string
105+
FilestoreBasePath string
106+
FirestoreBasePath string
107+
GameServicesBasePath string
108+
GKEBackupBasePath string
109+
GKEHubBasePath string
110+
HealthcareBasePath string
111+
IAM2BasePath string
112+
IAMBetaBasePath string
113+
IAMWorkforcePoolBasePath string
114+
IapBasePath string
115+
IdentityPlatformBasePath string
116+
KMSBasePath string
117+
LoggingBasePath string
118+
MemcacheBasePath string
119+
MLEngineBasePath string
120+
MonitoringBasePath string
121+
NetworkManagementBasePath string
122+
NetworkServicesBasePath string
123+
NotebooksBasePath string
124+
OSConfigBasePath string
125+
OSLoginBasePath string
126+
PrivatecaBasePath string
127+
PubsubBasePath string
128+
PubsubLiteBasePath string
129+
RedisBasePath string
130+
ResourceManagerBasePath string
131+
SecretManagerBasePath string
132+
SecurityCenterBasePath string
133+
ServiceManagementBasePath string
134+
ServiceUsageBasePath string
135+
SourceRepoBasePath string
136+
SpannerBasePath string
137+
SQLBasePath string
138+
StorageBasePath string
139+
StorageTransferBasePath string
140+
TagsBasePath string
141+
TPUBasePath string
142+
VertexAIBasePath string
143+
VPCAccessBasePath string
144+
WorkflowsBasePath string
144145
}
145146

146147
// Metadata returns the provider type name.
@@ -407,6 +408,12 @@ func (p *frameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
407408
CustomEndpointValidator(),
408409
},
409410
},
411+
"database_migration_service_custom_endpoint": &schema.StringAttribute{
412+
Optional: true,
413+
Validators: []validator.String{
414+
CustomEndpointValidator(),
415+
},
416+
},
410417
"data_catalog_custom_endpoint": &schema.StringAttribute{
411418
Optional: true,
412419
Validators: []validator.String{

google/provider.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ func Provider() *schema.Provider {
277277
Optional: true,
278278
ValidateFunc: validateCustomEndpoint,
279279
},
280+
"database_migration_service_custom_endpoint": {
281+
Type: schema.TypeString,
282+
Optional: true,
283+
ValidateFunc: validateCustomEndpoint,
284+
},
280285
"data_catalog_custom_endpoint": {
281286
Type: schema.TypeString,
282287
Optional: true,
@@ -712,9 +717,9 @@ func Provider() *schema.Provider {
712717
return provider
713718
}
714719

715-
// Generated resources: 282
720+
// Generated resources: 283
716721
// Generated IAM resources: 186
717-
// Total generated resources: 468
722+
// Total generated resources: 469
718723
func ResourceMap() map[string]*schema.Resource {
719724
resourceMap, _ := ResourceMapWithErrors()
720725
return resourceMap
@@ -937,6 +942,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
937942
"google_container_analysis_note": ResourceContainerAnalysisNote(),
938943
"google_container_analysis_occurrence": ResourceContainerAnalysisOccurrence(),
939944
"google_container_attached_cluster": ResourceContainerAttachedCluster(),
945+
"google_database_migration_service_connection_profile": ResourceDatabaseMigrationServiceConnectionProfile(),
940946
"google_data_catalog_entry": ResourceDataCatalogEntry(),
941947
"google_data_catalog_entry_group": ResourceDataCatalogEntryGroup(),
942948
"google_data_catalog_entry_group_iam_binding": ResourceIamBinding(DataCatalogEntryGroupIamSchema, DataCatalogEntryGroupIamUpdaterProducer, DataCatalogEntryGroupIdParseFunc),
@@ -1445,6 +1451,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
14451451
config.ComputeBasePath = d.Get("compute_custom_endpoint").(string)
14461452
config.ContainerAnalysisBasePath = d.Get("container_analysis_custom_endpoint").(string)
14471453
config.ContainerAttachedBasePath = d.Get("container_attached_custom_endpoint").(string)
1454+
config.DatabaseMigrationServiceBasePath = d.Get("database_migration_service_custom_endpoint").(string)
14481455
config.DataCatalogBasePath = d.Get("data_catalog_custom_endpoint").(string)
14491456
config.DataFusionBasePath = d.Get("data_fusion_custom_endpoint").(string)
14501457
config.DataLossPreventionBasePath = d.Get("data_loss_prevention_custom_endpoint").(string)

0 commit comments

Comments
 (0)