Skip to content

Commit 9831293

Browse files
authored
chore: Clean up usages of old SDK (#2449)
* remove usages of old SDK * add az2 to vpc endpoint * Revert "add az2 to vpc endpoint" This reverts commit ce6f7cc. * skip flaky test
1 parent 85d08fc commit 9831293

File tree

7 files changed

+12
-13
lines changed

7 files changed

+12
-13
lines changed

internal/service/alertconfiguration/resource_alert_configuration.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ func (r *alertConfigurationRS) Update(ctx context.Context, req resource.UpdateRe
520520
}
521521

522522
func (r *alertConfigurationRS) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
523-
conn := r.Client.Atlas
523+
connV2 := r.Client.AtlasV2
524524

525525
var alertConfigState TfAlertConfigurationRSModel
526526
resp.Diagnostics.Append(req.State.Get(ctx, &alertConfigState)...)
@@ -530,7 +530,7 @@ func (r *alertConfigurationRS) Delete(ctx context.Context, req resource.DeleteRe
530530

531531
ids := conversion.DecodeStateID(alertConfigState.ID.ValueString())
532532

533-
_, err := conn.AlertConfigurations.Delete(ctx, ids[EncodedIDKeyProjectID], ids[EncodedIDKeyAlertID])
533+
_, err := connV2.AlertConfigurationsApi.DeleteAlertConfiguration(ctx, ids[EncodedIDKeyProjectID], ids[EncodedIDKeyAlertID]).Execute()
534534
if err != nil {
535535
resp.Diagnostics.AddError(errorReadAlertConf, err.Error())
536536
}

internal/service/cloudbackupsnapshotexportbucket/resource_cloud_backup_snapshot_export_bucket.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@ func resourceDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.
162162
}
163163

164164
func resourceImportState(ctx context.Context, d *schema.ResourceData, meta any) ([]*schema.ResourceData, error) {
165-
conn := meta.(*config.MongoDBClient).Atlas
165+
conn := meta.(*config.MongoDBClient).AtlasV2
166166

167167
projectID, id, err := splitImportID(d.Id())
168168
if err != nil {
169169
return nil, err
170170
}
171171

172-
_, _, err = conn.CloudProviderSnapshotExportBuckets.Get(ctx, *projectID, *id)
172+
_, _, err = conn.CloudBackupsApi.GetExportBucket(ctx, *projectID, *id).Execute()
173173
if err != nil {
174174
return nil, fmt.Errorf("couldn't import snapshot export bucket %s in project %s, error: %s", *id, *projectID, err)
175175
}

internal/service/cloudbackupsnapshotexportjob/resource_cloud_backup_snapshot_export_job.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ func expandExportJobCustomData(d *schema.ResourceData) *[]admin.BackupLabel {
290290
}
291291

292292
func resourceImportState(ctx context.Context, d *schema.ResourceData, meta any) ([]*schema.ResourceData, error) {
293-
conn := meta.(*config.MongoDBClient).Atlas
293+
connV2 := meta.(*config.MongoDBClient).AtlasV2
294294

295295
parts := strings.SplitN(d.Id(), "--", 3)
296296
if len(parts) != 3 {
@@ -301,7 +301,7 @@ func resourceImportState(ctx context.Context, d *schema.ResourceData, meta any)
301301
clusterName := parts[1]
302302
exportID := parts[2]
303303

304-
_, _, err := conn.CloudProviderSnapshotExportJobs.Get(ctx, projectID, clusterName, exportID)
304+
_, _, err := connV2.CloudBackupsApi.GetBackupExportJob(ctx, projectID, clusterName, exportID).Execute()
305305
if err != nil {
306306
return nil, fmt.Errorf("couldn't import snapshot export job %s in project %s and cluster %s, error: %s", exportID, projectID, clusterName, err)
307307
}

internal/service/cloudbackupsnapshotexportjob/resource_cloud_backup_snapshot_export_job_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func checkExists(resourceName string) resource.TestCheckFunc {
8282
if err != nil {
8383
return err
8484
}
85-
_, _, err = acc.Conn().CloudProviderSnapshotExportJobs.Get(context.Background(), projectID, clusterName, exportJobID)
85+
_, _, err = acc.ConnV2().CloudBackupsApi.GetBackupExportJob(context.Background(), projectID, clusterName, exportJobID).Execute()
8686
if err == nil {
8787
return nil
8888
}

internal/service/onlinearchive/resource_online_archive.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,6 @@ func mapCriteria(d *schema.ResourceData) admin.Criteria {
633633
}
634634

635635
func mapSchedule(d *schema.ResourceData) *admin.OnlineArchiveSchedule {
636-
// scheduleInput := &matlas.OnlineArchiveSchedule{
637-
638636
// We have to provide schedule.type="DEFAULT" when the schedule block is not provided or removed
639637
scheduleInput := &admin.OnlineArchiveSchedule{
640638
Type: scheduleTypeDefault,

internal/service/privateendpointregionalmode/resource_private_endpoint_regional_mode_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func TestAccPrivateEndpointRegionalMode_basic(t *testing.T) {
1717
}
1818

1919
func TestAccPrivateEndpointRegionalMode_conn(t *testing.T) {
20+
acc.SkipTestForCI(t) // needs AWS configuration
2021
var (
2122
endpointResourceSuffix = "atlasple"
2223
resourceSuffix = "atlasrm"
@@ -168,7 +169,7 @@ func checkExists(resourceName string) resource.TestCheckFunc {
168169
return fmt.Errorf("no ID is set")
169170
}
170171
projectID := rs.Primary.ID
171-
_, _, err := acc.Conn().PrivateEndpoints.GetRegionalizedPrivateEndpointSetting(context.Background(), projectID)
172+
_, _, err := acc.ConnV2().PrivateEndpointServicesApi.GetRegionalizedPrivateEndpointSetting(context.Background(), projectID).Execute()
172173
if err == nil {
173174
return nil
174175
}
@@ -181,7 +182,7 @@ func checkDestroy(s *terraform.State) error {
181182
if rs.Type != "mongodbatlas_private_endpoint_regional_mode" {
182183
continue
183184
}
184-
setting, _, _ := acc.Conn().PrivateEndpoints.GetRegionalizedPrivateEndpointSetting(context.Background(), rs.Primary.ID)
185+
setting, _, _ := acc.ConnV2().PrivateEndpointServicesApi.GetRegionalizedPrivateEndpointSetting(context.Background(), rs.Primary.ID).Execute()
185186
if setting != nil && setting.Enabled != false {
186187
return fmt.Errorf("Regionalized private endpoint setting for project %q was not properly disabled", rs.Primary.ID)
187188
}

internal/service/thirdpartyintegration/resource_third_party_integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ func checkDestroy(s *terraform.State) error {
342342
if attrs["type"] == "" {
343343
return fmt.Errorf("no type is set")
344344
}
345-
_, _, err := acc.Conn().Integrations.Get(context.Background(), attrs["project_id"], attrs["type"])
345+
_, _, err := acc.ConnV2().ThirdPartyIntegrationsApi.GetThirdPartyIntegration(context.Background(), attrs["project_id"], attrs["type"]).Execute()
346346
if err == nil {
347347
return fmt.Errorf("third party integration service (%s) still exists", attrs["type"])
348348
}
@@ -496,7 +496,7 @@ func checkExists(resourceName string) resource.TestCheckFunc {
496496
if attrs["type"] == "" {
497497
return fmt.Errorf("no type is set")
498498
}
499-
if _, _, err := acc.Conn().Integrations.Get(context.Background(), attrs["project_id"], attrs["type"]); err == nil {
499+
if _, _, err := acc.ConnV2().ThirdPartyIntegrationsApi.GetThirdPartyIntegration(context.Background(), attrs["project_id"], attrs["type"]).Execute(); err == nil {
500500
return nil
501501
}
502502
return fmt.Errorf("third party integration (%s) does not exist", attrs["project_id"])

0 commit comments

Comments
 (0)