Skip to content

CLOUDP-288862: Delete with latest api version #3990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/cli/clusters/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/usage"
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/watchers"
"github.com/spf13/cobra"
atlasClustersPinned "go.mongodb.org/atlas-sdk/v20240530005/admin"
atlasv2 "go.mongodb.org/atlas-sdk/v20250312003/admin"
)

//go:generate go tool go.uber.org/mock/mockgen -typed -destination=delete_mock_test.go -package=clusters . ClusterDeleter
Expand Down Expand Up @@ -63,12 +63,12 @@ func (opts *DeleteOpts) Run() error {
}

func (opts *DeleteOpts) RunFlexCluster(err error) error {
apiError, ok := atlasClustersPinned.AsError(err)
apiError, ok := atlasv2.AsError(err)
if !ok {
return err
}

if *apiError.ErrorCode != cannotUseFlexWithClusterApisErrorCode {
if apiError.ErrorCode != cannotUseFlexWithClusterApisErrorCode {
return err
}

Expand Down
7 changes: 3 additions & 4 deletions internal/cli/clusters/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import (
"testing"

"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli"
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/pointer"
"github.com/stretchr/testify/require"
atlasClustersPinned "go.mongodb.org/atlas-sdk/v20240530005/admin"
atlasv2 "go.mongodb.org/atlas-sdk/v20250312003/admin"
"go.uber.org/mock/gomock"
)

Expand Down Expand Up @@ -51,8 +50,8 @@ func TestDelete_RunFlexCluster(t *testing.T) {
ctrl := gomock.NewController(t)
mockStore := NewMockClusterDeleter(ctrl)

expectedError := &atlasClustersPinned.GenericOpenAPIError{}
expectedError.SetModel(atlasClustersPinned.ApiError{ErrorCode: pointer.Get(cannotUseFlexWithClusterApisErrorCode)})
expectedError := &atlasv2.GenericOpenAPIError{}
expectedError.SetModel(atlasv2.ApiError{ErrorCode: cannotUseFlexWithClusterApisErrorCode})

deleteOpts := &DeleteOpts{
DeleteOpts: &cli.DeleteOpts{
Expand Down
2 changes: 1 addition & 1 deletion internal/store/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (s *Store) GetClusterAutoScalingConfig(projectID, name string) (*atlasv2.Cl

// DeleteCluster encapsulate the logic to manage different cloud providers.
func (s *Store) DeleteCluster(projectID, name string) error {
_, err := s.clientClusters.ClustersApi.DeleteCluster(s.ctx, projectID, name).Execute()
_, err := s.clientv2.ClustersApi.DeleteCluster(s.ctx, projectID, name).Execute()
return err
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
HTTP/2.0 200 OK
Content-Length: 364
Content-Type: application/vnd.atlas.2023-01-01+json;charset=utf-8
Date: Fri, 20 Jun 2025 14:37:20 GMT
Date: Tue, 17 Jun 2025 13:32:55 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: mdbws
Strict-Transport-Security: max-age=31536000; includeSubdomains;
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 114
X-Envoy-Upstream-Service-Time: 185
X-Frame-Options: DENY
X-Java-Method: ApiGroupTeamsResource::addTeams
X-Java-Version: 17.0.14+7
X-Mongodb-Service-Version: gitHash=c9cc80704805413f1d20ccd4de364bd36cd66b6b; versionString=master
X-Mongodb-Service-Version: gitHash=1ab676b47c305241bdf9a34bc95947dde225deff; versionString=master
X-Permitted-Cross-Domain-Policies: none

{"links":[{"href":"http://localhost:8080/api/atlas/v2/groups/6855721ccd32be2bdf8db2bf/teams?pageNum=1&itemsPerPage=100","rel":"self"}],"results":[{"links":[{"href":"http://localhost:8080/api/atlas/v2/groups/6855721ccd32be2bdf8db2bf/teams/6855721fe16f343ef1ded461","rel":"self"}],"roleNames":["GROUP_READ_ONLY"],"teamId":"6855721fe16f343ef1ded461"}],"totalCount":1}
{"links":[{"href":"http://localhost:8080/api/atlas/v2/groups/68516e85ffb74d59cd662efa/teams?pageNum=1&itemsPerPage=100","rel":"self"}],"results":[{"links":[{"href":"http://localhost:8080/api/atlas/v2/groups/68516e85ffb74d59cd662efa/teams/68516e87ffb74d59cd662f84","rel":"self"}],"roleNames":["GROUP_READ_ONLY"],"teamId":"68516e87ffb74d59cd662f84"}],"totalCount":1}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
HTTP/2.0 204 No Content
Content-Type: application/vnd.atlas.2023-01-01+json;charset=utf-8
Date: Fri, 20 Jun 2025 14:37:21 GMT
Date: Tue, 17 Jun 2025 13:32:56 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: mdbws
Strict-Transport-Security: max-age=31536000; includeSubdomains;
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 110
X-Envoy-Upstream-Service-Time: 128
X-Frame-Options: DENY
X-Java-Method: ApiOrganizationTeamsResource::deleteTeam
X-Java-Version: 17.0.14+7
X-Mongodb-Service-Version: gitHash=c9cc80704805413f1d20ccd4de364bd36cd66b6b; versionString=master
X-Mongodb-Service-Version: gitHash=1ab676b47c305241bdf9a34bc95947dde225deff; versionString=master
X-Permitted-Cross-Domain-Policies: none

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
HTTP/2.0 204 No Content
Content-Type: application/vnd.atlas.2023-01-01+json;charset=utf-8
Date: Fri, 20 Jun 2025 14:37:20 GMT
Date: Tue, 17 Jun 2025 13:32:56 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: mdbws
Strict-Transport-Security: max-age=31536000; includeSubdomains;
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 113
X-Envoy-Upstream-Service-Time: 141
X-Frame-Options: DENY
X-Java-Method: ApiGroupTeamsResource::removeTeam
X-Java-Version: 17.0.14+7
X-Mongodb-Service-Version: gitHash=c9cc80704805413f1d20ccd4de364bd36cd66b6b; versionString=master
X-Mongodb-Service-Version: gitHash=1ab676b47c305241bdf9a34bc95947dde225deff; versionString=master
X-Permitted-Cross-Domain-Policies: none

Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
HTTP/2.0 200 OK
Content-Length: 713
Content-Type: application/vnd.atlas.2025-02-19+json;charset=utf-8
Date: Fri, 20 Jun 2025 14:37:19 GMT
Date: Tue, 17 Jun 2025 13:32:55 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: mdbws
Strict-Transport-Security: max-age=31536000; includeSubdomains;
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 34
X-Envoy-Upstream-Service-Time: 50
X-Frame-Options: DENY
X-Java-Method: ApiOrganizationUsersResource::getOrganizationUsers
X-Java-Version: 17.0.14+7
X-Mongodb-Service-Version: gitHash=c9cc80704805413f1d20ccd4de364bd36cd66b6b; versionString=master
X-Mongodb-Service-Version: gitHash=1ab676b47c305241bdf9a34bc95947dde225deff; versionString=master
X-Permitted-Cross-Domain-Policies: none

{"links":[{"href":"http://localhost:8080/api/atlas/v2/orgs/a0123456789abcdef012345a/users?includeCount=true&pageNum=1&itemsPerPage=1","rel":"self"},{"href":"http://localhost:8080/api/atlas/v2/orgs/a0123456789abcdef012345a/users?includeCount=true&itemsPerPage=1&pageNum=2","rel":"next"}],"results":[{"country":"IE","createdAt":"2020-02-18T10:58:47Z","firstName":"Andrea","id":"5e4bc367c6b0f41bb9bbb178","lastAuth":"2025-06-19T08:26:30Z","lastName":"Angiolillo","mobileNumber":null,"orgMembershipStatus":"ACTIVE","roles":{"groupRoleAssignments":[{"groupId":"b0123456789abcdef012345b","groupRoles":["GROUP_OWNER"]}],"orgRoles":["ORG_OWNER"]},"teamIds":[],"username":"andrea.angiolillo@mongodb.com"}],"totalCount":16}
{"links":[{"href":"http://localhost:8080/api/atlas/v2/orgs/a0123456789abcdef012345a/users?includeCount=true&pageNum=1&itemsPerPage=1","rel":"self"},{"href":"http://localhost:8080/api/atlas/v2/orgs/a0123456789abcdef012345a/users?includeCount=true&itemsPerPage=1&pageNum=2","rel":"next"}],"results":[{"country":"IE","createdAt":"2020-02-18T10:58:47Z","firstName":"Andrea","id":"5e4bc367c6b0f41bb9bbb178","lastAuth":"2025-06-16T07:44:40Z","lastName":"Angiolillo","mobileNumber":null,"orgMembershipStatus":"ACTIVE","roles":{"groupRoleAssignments":[{"groupId":"b0123456789abcdef012345b","groupRoles":["GROUP_OWNER"]}],"orgRoles":["ORG_OWNER"]},"teamIds":[],"username":"andrea.angiolillo@mongodb.com"}],"totalCount":34}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
HTTP/2.0 200 OK
Content-Length: 412
Content-Type: application/vnd.atlas.2023-01-01+json;charset=utf-8
Date: Fri, 20 Jun 2025 14:37:20 GMT
Date: Tue, 17 Jun 2025 13:32:56 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: mdbws
Strict-Transport-Security: max-age=31536000; includeSubdomains;
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 19
X-Envoy-Upstream-Service-Time: 37
X-Frame-Options: DENY
X-Java-Method: ApiGroupTeamsResource::getTeams
X-Java-Version: 17.0.14+7
X-Mongodb-Service-Version: gitHash=c9cc80704805413f1d20ccd4de364bd36cd66b6b; versionString=master
X-Mongodb-Service-Version: gitHash=1ab676b47c305241bdf9a34bc95947dde225deff; versionString=master
X-Permitted-Cross-Domain-Policies: none

{"links":[{"href":"http://localhost:8080/api/atlas/v2/groups/6855721ccd32be2bdf8db2bf/teams?includeCount=true&pageNum=1&itemsPerPage=100","rel":"self"}],"results":[{"links":[{"href":"http://localhost:8080/api/atlas/v2/groups/6855721ccd32be2bdf8db2bf/teams/6855721fe16f343ef1ded461","rel":"self"}],"roleNames":["GROUP_READ_ONLY","GROUP_DATA_ACCESS_READ_ONLY"],"teamId":"6855721fe16f343ef1ded461"}],"totalCount":1}
{"links":[{"href":"http://localhost:8080/api/atlas/v2/groups/68516e85ffb74d59cd662efa/teams?includeCount=true&pageNum=1&itemsPerPage=100","rel":"self"}],"results":[{"links":[{"href":"http://localhost:8080/api/atlas/v2/groups/68516e85ffb74d59cd662efa/teams/68516e87ffb74d59cd662f84","rel":"self"}],"roleNames":["GROUP_READ_ONLY","GROUP_DATA_ACCESS_READ_ONLY"],"teamId":"68516e87ffb74d59cd662f84"}],"totalCount":1}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
HTTP/2.0 201 Created
Content-Length: 1067
Content-Type: application/vnd.atlas.2023-01-01+json;charset=utf-8
Date: Fri, 20 Jun 2025 14:37:16 GMT
Date: Tue, 17 Jun 2025 13:32:53 GMT
Location: http://localhost:8080//api/atlas/v1.0
Referrer-Policy: strict-origin-when-cross-origin
Server: mdbws
Strict-Transport-Security: max-age=31536000; includeSubdomains;
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 2970
X-Envoy-Upstream-Service-Time: 1513
X-Frame-Options: DENY
X-Java-Method: ApiAtlasGroupsResource::addGroup
X-Java-Version: 17.0.14+7
X-Mongodb-Service-Version: gitHash=c9cc80704805413f1d20ccd4de364bd36cd66b6b; versionString=master
X-Mongodb-Service-Version: gitHash=1ab676b47c305241bdf9a34bc95947dde225deff; versionString=master
X-Permitted-Cross-Domain-Policies: none

{"clusterCount":0,"created":"2025-06-20T14:37:19Z","id":"6855721ccd32be2bdf8db2bf","links":[{"href":"http://localhost:8080/api/atlas/v2/groups/6855721ccd32be2bdf8db2bf","rel":"self"},{"href":"http://localhost:8080/api/atlas/v2/groups/6855721ccd32be2bdf8db2bf/containers","rel":"https://cloud.mongodb.com/containers"},{"href":"http://localhost:8080/api/atlas/v2/groups/6855721ccd32be2bdf8db2bf/clusters","rel":"https://cloud.mongodb.com/clusters"},{"href":"http://localhost:8080/api/atlas/v2/groups/6855721ccd32be2bdf8db2bf/databaseUsers","rel":"https://cloud.mongodb.com/databaseUsers"},{"href":"http://localhost:8080/api/atlas/v2/groups/6855721ccd32be2bdf8db2bf/peers","rel":"https://cloud.mongodb.com/peers"},{"href":"http://localhost:8080/api/atlas/v2/groups/6855721ccd32be2bdf8db2bf/processes","rel":"https://cloud.mongodb.com/processes"},{"href":"http://localhost:8080/api/atlas/v2/groups/6855721ccd32be2bdf8db2bf/whitelist","rel":"https://cloud.mongodb.com/whitelist"}],"name":"teams-e2e-648","orgId":"a0123456789abcdef012345a","withDefaultAlertsSettings":true}
{"clusterCount":0,"created":"2025-06-17T13:32:54Z","id":"68516e85ffb74d59cd662efa","links":[{"href":"http://localhost:8080/api/atlas/v2/groups/68516e85ffb74d59cd662efa","rel":"self"},{"href":"http://localhost:8080/api/atlas/v2/groups/68516e85ffb74d59cd662efa/containers","rel":"https://cloud.mongodb.com/containers"},{"href":"http://localhost:8080/api/atlas/v2/groups/68516e85ffb74d59cd662efa/clusters","rel":"https://cloud.mongodb.com/clusters"},{"href":"http://localhost:8080/api/atlas/v2/groups/68516e85ffb74d59cd662efa/databaseUsers","rel":"https://cloud.mongodb.com/databaseUsers"},{"href":"http://localhost:8080/api/atlas/v2/groups/68516e85ffb74d59cd662efa/peers","rel":"https://cloud.mongodb.com/peers"},{"href":"http://localhost:8080/api/atlas/v2/groups/68516e85ffb74d59cd662efa/processes","rel":"https://cloud.mongodb.com/processes"},{"href":"http://localhost:8080/api/atlas/v2/groups/68516e85ffb74d59cd662efa/whitelist","rel":"https://cloud.mongodb.com/whitelist"}],"name":"teams-e2e-381","orgId":"a0123456789abcdef012345a","withDefaultAlertsSettings":true}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
HTTP/2.0 201 Created
Content-Length: 232
Content-Type: application/vnd.atlas.2023-01-01+json;charset=utf-8
Date: Fri, 20 Jun 2025 14:37:19 GMT
Location: http://localhost:8080/orgs/a0123456789abcdef012345a/teams/6855721fe16f343ef1ded461
Date: Tue, 17 Jun 2025 13:32:55 GMT
Location: http://localhost:8080/orgs/a0123456789abcdef012345a/teams/68516e87ffb74d59cd662f84
Referrer-Policy: strict-origin-when-cross-origin
Server: mdbws
Strict-Transport-Security: max-age=31536000; includeSubdomains;
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 138
X-Envoy-Upstream-Service-Time: 188
X-Frame-Options: DENY
X-Java-Method: ApiOrganizationTeamsResource::createTeam
X-Java-Version: 17.0.14+7
X-Mongodb-Service-Version: gitHash=c9cc80704805413f1d20ccd4de364bd36cd66b6b; versionString=master
X-Mongodb-Service-Version: gitHash=1ab676b47c305241bdf9a34bc95947dde225deff; versionString=master
X-Permitted-Cross-Domain-Policies: none

{"id":"6855721fe16f343ef1ded461","links":[{"href":"http://localhost:8080/api/atlas/v2/orgs/a0123456789abcdef012345a/teams/6855721fe16f343ef1ded461","rel":"self"}],"name":"e2e-teams-143","usernames":["andrea.angiolillo@mongodb.com"]}
{"id":"68516e87ffb74d59cd662f84","links":[{"href":"http://localhost:8080/api/atlas/v2/orgs/a0123456789abcdef012345a/teams/68516e87ffb74d59cd662f84","rel":"self"}],"name":"e2e-teams-443","usernames":["andrea.angiolillo@mongodb.com"]}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
HTTP/2.0 200 OK
Content-Length: 389
Content-Length: 419
Content-Type: application/vnd.atlas.2023-01-01+json;charset=utf-8
Date: Fri, 20 Jun 2025 14:37:20 GMT
Date: Tue, 17 Jun 2025 13:32:55 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: mdbws
Strict-Transport-Security: max-age=31536000; includeSubdomains;
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 114
X-Envoy-Upstream-Service-Time: 163
X-Frame-Options: DENY
X-Java-Method: ApiGroupTeamsResource::patchTeam
X-Java-Version: 17.0.14+7
X-Mongodb-Service-Version: gitHash=c9cc80704805413f1d20ccd4de364bd36cd66b6b; versionString=master
X-Mongodb-Service-Version: gitHash=1ab676b47c305241bdf9a34bc95947dde225deff; versionString=master
X-Permitted-Cross-Domain-Policies: none

{"links":[{"href":"http://localhost:8080/api/atlas/v2/groups/6855721ccd32be2bdf8db2bf/teams/6855721fe16f343ef1ded461?pageNum=1&itemsPerPage=100","rel":"self"}],"results":[{"links":[{"href":"http://localhost:8080/api/atlas/v2/groups/6855721ccd32be2bdf8db2bf/teams/6855721fe16f343ef1ded461","rel":"self"}],"roleNames":["GROUP_READ_ONLY"],"teamId":"6855721fe16f343ef1ded461"}],"totalCount":1}
{"links":[{"href":"http://localhost:8080/api/atlas/v2/groups/68516e85ffb74d59cd662efa/teams/68516e87ffb74d59cd662f84?pageNum=1&itemsPerPage=100","rel":"self"}],"results":[{"links":[{"href":"http://localhost:8080/api/atlas/v2/groups/68516e85ffb74d59cd662efa/teams/68516e87ffb74d59cd662f84","rel":"self"}],"roleNames":["GROUP_READ_ONLY","GROUP_DATA_ACCESS_READ_ONLY"],"teamId":"68516e87ffb74d59cd662f84"}],"totalCount":1}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"TestAtlasProjectTeams/rand":"jw=="}
{"TestAtlasProjectTeams/rand":"Abs="}
Loading