Skip to content

Commit

Permalink
chore: Clean up usages of old SDK (#2449)
Browse files Browse the repository at this point in the history
* remove usages of old SDK

* add az2 to vpc endpoint

* Revert "add az2 to vpc endpoint"

This reverts commit ce6f7cc.

* skip flaky test
  • Loading branch information
oarbusi authored Jul 23, 2024
1 parent 85d08fc commit 9831293
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func (r *alertConfigurationRS) Update(ctx context.Context, req resource.UpdateRe
}

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

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

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

_, err := conn.AlertConfigurations.Delete(ctx, ids[EncodedIDKeyProjectID], ids[EncodedIDKeyAlertID])
_, err := connV2.AlertConfigurationsApi.DeleteAlertConfiguration(ctx, ids[EncodedIDKeyProjectID], ids[EncodedIDKeyAlertID]).Execute()
if err != nil {
resp.Diagnostics.AddError(errorReadAlertConf, err.Error())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ func resourceDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.
}

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

projectID, id, err := splitImportID(d.Id())
if err != nil {
return nil, err
}

_, _, err = conn.CloudProviderSnapshotExportBuckets.Get(ctx, *projectID, *id)
_, _, err = conn.CloudBackupsApi.GetExportBucket(ctx, *projectID, *id).Execute()
if err != nil {
return nil, fmt.Errorf("couldn't import snapshot export bucket %s in project %s, error: %s", *id, *projectID, err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func expandExportJobCustomData(d *schema.ResourceData) *[]admin.BackupLabel {
}

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

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

_, _, err := conn.CloudProviderSnapshotExportJobs.Get(ctx, projectID, clusterName, exportID)
_, _, err := connV2.CloudBackupsApi.GetBackupExportJob(ctx, projectID, clusterName, exportID).Execute()
if err != nil {
return nil, fmt.Errorf("couldn't import snapshot export job %s in project %s and cluster %s, error: %s", exportID, projectID, clusterName, err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func checkExists(resourceName string) resource.TestCheckFunc {
if err != nil {
return err
}
_, _, err = acc.Conn().CloudProviderSnapshotExportJobs.Get(context.Background(), projectID, clusterName, exportJobID)
_, _, err = acc.ConnV2().CloudBackupsApi.GetBackupExportJob(context.Background(), projectID, clusterName, exportJobID).Execute()
if err == nil {
return nil
}
Expand Down
2 changes: 0 additions & 2 deletions internal/service/onlinearchive/resource_online_archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,6 @@ func mapCriteria(d *schema.ResourceData) admin.Criteria {
}

func mapSchedule(d *schema.ResourceData) *admin.OnlineArchiveSchedule {
// scheduleInput := &matlas.OnlineArchiveSchedule{

// We have to provide schedule.type="DEFAULT" when the schedule block is not provided or removed
scheduleInput := &admin.OnlineArchiveSchedule{
Type: scheduleTypeDefault,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestAccPrivateEndpointRegionalMode_basic(t *testing.T) {
}

func TestAccPrivateEndpointRegionalMode_conn(t *testing.T) {
acc.SkipTestForCI(t) // needs AWS configuration
var (
endpointResourceSuffix = "atlasple"
resourceSuffix = "atlasrm"
Expand Down Expand Up @@ -168,7 +169,7 @@ func checkExists(resourceName string) resource.TestCheckFunc {
return fmt.Errorf("no ID is set")
}
projectID := rs.Primary.ID
_, _, err := acc.Conn().PrivateEndpoints.GetRegionalizedPrivateEndpointSetting(context.Background(), projectID)
_, _, err := acc.ConnV2().PrivateEndpointServicesApi.GetRegionalizedPrivateEndpointSetting(context.Background(), projectID).Execute()
if err == nil {
return nil
}
Expand All @@ -181,7 +182,7 @@ func checkDestroy(s *terraform.State) error {
if rs.Type != "mongodbatlas_private_endpoint_regional_mode" {
continue
}
setting, _, _ := acc.Conn().PrivateEndpoints.GetRegionalizedPrivateEndpointSetting(context.Background(), rs.Primary.ID)
setting, _, _ := acc.ConnV2().PrivateEndpointServicesApi.GetRegionalizedPrivateEndpointSetting(context.Background(), rs.Primary.ID).Execute()
if setting != nil && setting.Enabled != false {
return fmt.Errorf("Regionalized private endpoint setting for project %q was not properly disabled", rs.Primary.ID)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func checkDestroy(s *terraform.State) error {
if attrs["type"] == "" {
return fmt.Errorf("no type is set")
}
_, _, err := acc.Conn().Integrations.Get(context.Background(), attrs["project_id"], attrs["type"])
_, _, err := acc.ConnV2().ThirdPartyIntegrationsApi.GetThirdPartyIntegration(context.Background(), attrs["project_id"], attrs["type"]).Execute()
if err == nil {
return fmt.Errorf("third party integration service (%s) still exists", attrs["type"])
}
Expand Down Expand Up @@ -496,7 +496,7 @@ func checkExists(resourceName string) resource.TestCheckFunc {
if attrs["type"] == "" {
return fmt.Errorf("no type is set")
}
if _, _, err := acc.Conn().Integrations.Get(context.Background(), attrs["project_id"], attrs["type"]); err == nil {
if _, _, err := acc.ConnV2().ThirdPartyIntegrationsApi.GetThirdPartyIntegration(context.Background(), attrs["project_id"], attrs["type"]).Execute(); err == nil {
return nil
}
return fmt.Errorf("third party integration (%s) does not exist", attrs["project_id"])
Expand Down

0 comments on commit 9831293

Please sign in to comment.