diff --git a/go.mod b/go.mod index aa97e9f6ea..435690736e 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,6 @@ require ( github.com/stretchr/testify v1.9.0 github.com/zclconf/go-cty v1.14.4 go.mongodb.org/atlas v0.36.0 - go.mongodb.org/atlas-sdk/v20231001002 v20231001002.0.0 go.mongodb.org/atlas-sdk/v20231115008 v20231115008.5.0 go.mongodb.org/realm v0.1.0 ) diff --git a/go.sum b/go.sum index a31d14f894..3e0466c813 100644 --- a/go.sum +++ b/go.sum @@ -774,8 +774,6 @@ github.com/zclconf/go-cty-yaml v1.0.2/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgK go.mongodb.org/atlas v0.12.0/go.mod h1:wVCnHcm/7/IfTjEB6K8K35PLG70yGz8BdkRwX0oK9/M= go.mongodb.org/atlas v0.36.0 h1:m05S3AO7zkl+bcG1qaNsEKBnAqnKx2FDwLooHpIG3j4= go.mongodb.org/atlas v0.36.0/go.mod h1:nfPldE9dSama6G2IbIzmEza02Ly7yFZjMMVscaM0uEc= -go.mongodb.org/atlas-sdk/v20231001002 v20231001002.0.0 h1:h1X2CGKyN1UFvNs69vp7xpufbbreq6p7bbrg5uJ1sxw= -go.mongodb.org/atlas-sdk/v20231001002 v20231001002.0.0/go.mod h1:4TAUPaWPFNSbi8c1hbQLr1wAdkmqi48O7zvyXjBM+a8= go.mongodb.org/atlas-sdk/v20231115008 v20231115008.5.0 h1:OuV1HfIpZUZa4+BKvtrvDlNqnilkCkdHspuZok6KAbM= go.mongodb.org/atlas-sdk/v20231115008 v20231115008.5.0/go.mod h1:0707RpWIrNFZ6Msy/dwRDCzC5JVDon61JoOqcbfCujg= go.mongodb.org/realm v0.1.0 h1:zJiXyLaZrznQ+Pz947ziSrDKUep39DO4SfA0Fzx8M4M= diff --git a/internal/config/client.go b/internal/config/client.go index bfd819e661..5f71b53ac8 100644 --- a/internal/config/client.go +++ b/internal/config/client.go @@ -9,8 +9,8 @@ import ( "strings" "time" - admin20231001002 "go.mongodb.org/atlas-sdk/v20231001002/admin" "go.mongodb.org/atlas-sdk/v20231115008/admin" + admin20231115008 "go.mongodb.org/atlas-sdk/v20231115008/admin" matlasClient "go.mongodb.org/atlas/mongodbatlas" realmAuth "go.mongodb.org/realm/auth" "go.mongodb.org/realm/realm" @@ -31,7 +31,7 @@ const ( type MongoDBClient struct { Atlas *matlasClient.Client AtlasV2 *admin.APIClient - Atlas20231001002 *admin20231001002.APIClient // Needed to avoid breaking changes in federated_settings_identity_provider resource. + Atlas20231115008 *admin20231115008.APIClient // Needed to avoid breaking changes in federated_settings_identity_provider resource. Config *Config } @@ -104,7 +104,7 @@ func (c *Config) NewClient(ctx context.Context) (any, error) { if err != nil { return nil, err } - sdk20231001002Client, err := c.newSDK20231001002Client(client) + sdk20231115008Client, err := c.newSDK20231115008Client(client) if err != nil { return nil, err } @@ -112,7 +112,7 @@ func (c *Config) NewClient(ctx context.Context) (any, error) { clients := &MongoDBClient{ Atlas: atlasClient, AtlasV2: sdkV2Client, - Atlas20231001002: sdk20231001002Client, + Atlas20231115008: sdk20231115008Client, Config: c, } @@ -135,15 +135,15 @@ func (c *Config) newSDKV2Client(client *http.Client) (*admin.APIClient, error) { return sdkv2, nil } -func (c *Config) newSDK20231001002Client(client *http.Client) (*admin20231001002.APIClient, error) { - opts := []admin20231001002.ClientModifier{ - admin20231001002.UseHTTPClient(client), - admin20231001002.UseUserAgent(userAgent(c)), - admin20231001002.UseBaseURL(c.BaseURL), - admin20231001002.UseDebug(false)} +func (c *Config) newSDK20231115008Client(client *http.Client) (*admin20231115008.APIClient, error) { + opts := []admin20231115008.ClientModifier{ + admin20231115008.UseHTTPClient(client), + admin20231115008.UseUserAgent(userAgent(c)), + admin20231115008.UseBaseURL(c.BaseURL), + admin20231115008.UseDebug(false)} // Initialize the MongoDB Versioned Atlas Client. - sdkv2, err := admin20231001002.NewClient(opts...) + sdkv2, err := admin20231115008.NewClient(opts...) if err != nil { return nil, err } diff --git a/internal/service/federatedsettingsidentityprovider/data_source_federated_settings_identity_providers.go b/internal/service/federatedsettingsidentityprovider/data_source_federated_settings_identity_providers.go index c8523bdfdf..b5ec85c2c0 100644 --- a/internal/service/federatedsettingsidentityprovider/data_source_federated_settings_identity_providers.go +++ b/internal/service/federatedsettingsidentityprovider/data_source_federated_settings_identity_providers.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" - "go.mongodb.org/atlas-sdk/v20231115008/admin" + admin20231115008 "go.mongodb.org/atlas-sdk/v20231115008/admin" ) func PluralDataSource() *schema.Resource { @@ -255,7 +255,7 @@ func dataSourceMongoDBAtlasFederatedSettingsIdentityProvidersRead(ctx context.Co return diag.FromErr(errors.New("federation_settings_id must be configured")) } - params := &admin.ListIdentityProvidersApiParams{ + params := &admin20231115008.ListIdentityProvidersApiParams{ FederationSettingsId: federationSettingsID.(string), Protocol: &[]string{OIDC, SAML}, } diff --git a/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider.go b/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider.go index 05ee569840..5a0481469d 100644 --- a/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider.go +++ b/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider.go @@ -5,10 +5,10 @@ import ( "strings" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20231115008/admin" + admin20231115008 "go.mongodb.org/atlas-sdk/v20231115008/admin" ) -func FlattenFederatedSettingsIdentityProvider(federatedSettingsIdentityProvider []admin.FederationIdentityProvider) []map[string]any { +func FlattenFederatedSettingsIdentityProvider(federatedSettingsIdentityProvider []admin20231115008.FederationIdentityProvider) []map[string]any { var federatedSettingsIdentityProviderMap []map[string]any if len(federatedSettingsIdentityProvider) > 0 { federatedSettingsIdentityProviderMap = make([]map[string]any, len(federatedSettingsIdentityProvider)) @@ -42,7 +42,7 @@ func FlattenFederatedSettingsIdentityProvider(federatedSettingsIdentityProvider return federatedSettingsIdentityProviderMap } -func FlattenAssociatedOrgs(associatedOrgs []admin.ConnectedOrgConfig) []map[string]any { +func FlattenAssociatedOrgs(associatedOrgs []admin20231115008.ConnectedOrgConfig) []map[string]any { var associatedOrgsMap []map[string]any if len(associatedOrgs) == 0 { @@ -77,7 +77,7 @@ func FlattenAssociatedOrgs(associatedOrgs []admin.ConnectedOrgConfig) []map[stri return associatedOrgsMap } -type mRoleAssignmentV2 []admin.RoleAssignment +type mRoleAssignmentV2 []admin20231115008.RoleAssignment func (ra mRoleAssignmentV2) Len() int { return len(ra) } func (ra mRoleAssignmentV2) Swap(i, j int) { ra[i], ra[j] = ra[j], ra[i] } @@ -97,7 +97,7 @@ func (ra mRoleAssignmentV2) Less(i, j int) bool { return *ra[i].Role < *ra[j].Role } -func FlattenRoleAssignments(roleAssignments []admin.RoleAssignment) []map[string]any { +func FlattenRoleAssignments(roleAssignments []admin20231115008.RoleAssignment) []map[string]any { sort.Sort(mRoleAssignmentV2(roleAssignments)) var roleAssignmentsMap []map[string]any @@ -117,7 +117,7 @@ func FlattenRoleAssignments(roleAssignments []admin.RoleAssignment) []map[string return roleAssignmentsMap } -func FlattenFederatedUser(federatedUsers []admin.FederatedUser) []map[string]any { +func FlattenFederatedUser(federatedUsers []admin20231115008.FederatedUser) []map[string]any { var userConflictsMap []map[string]any if len(federatedUsers) == 0 { @@ -138,7 +138,7 @@ func FlattenFederatedUser(federatedUsers []admin.FederatedUser) []map[string]any return userConflictsMap } -type authFederationoleMappingsByGroupName []admin.AuthFederationRoleMapping +type authFederationoleMappingsByGroupName []admin20231115008.AuthFederationRoleMapping func (ra authFederationoleMappingsByGroupName) Len() int { return len(ra) } func (ra authFederationoleMappingsByGroupName) Swap(i, j int) { ra[i], ra[j] = ra[j], ra[i] } @@ -147,7 +147,7 @@ func (ra authFederationoleMappingsByGroupName) Less(i, j int) bool { return ra[i].ExternalGroupName < ra[j].ExternalGroupName } -func FlattenAuthFederationRoleMapping(roleMappings []admin.AuthFederationRoleMapping) []map[string]any { +func FlattenAuthFederationRoleMapping(roleMappings []admin20231115008.AuthFederationRoleMapping) []map[string]any { sort.Sort(authFederationoleMappingsByGroupName(roleMappings)) var roleMappingsMap []map[string]any @@ -167,7 +167,7 @@ func FlattenAuthFederationRoleMapping(roleMappings []admin.AuthFederationRoleMap return roleMappingsMap } -func FlattenPemFileInfo(pemFileInfo admin.PemFileInfo) []map[string]any { +func FlattenPemFileInfo(pemFileInfo admin20231115008.PemFileInfo) []map[string]any { var pemFileInfoMap []map[string]any if certificates := pemFileInfo.GetCertificates(); len(certificates) > 0 { @@ -182,7 +182,7 @@ func FlattenPemFileInfo(pemFileInfo admin.PemFileInfo) []map[string]any { return pemFileInfoMap } -func FlattenFederatedSettingsCertificates(certificates []admin.X509Certificate) []map[string]any { +func FlattenFederatedSettingsCertificates(certificates []admin20231115008.X509Certificate) []map[string]any { var certificatesMap []map[string]any if len(certificates) > 0 { diff --git a/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider_test.go b/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider_test.go index 3b99ff733c..5dcb15d8c1 100644 --- a/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider_test.go +++ b/internal/service/federatedsettingsidentityprovider/model_federated_settings_identity_provider_test.go @@ -7,7 +7,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/federatedsettingsidentityprovider" "github.com/stretchr/testify/assert" - "go.mongodb.org/atlas-sdk/v20231115008/admin" + admin20231115008 "go.mongodb.org/atlas-sdk/v20231115008/admin" ) var ( @@ -47,7 +47,7 @@ var ( requestedScopes = []string{"requestedScopes"} userClaim = "userClaim" - roleAssignments = []admin.RoleAssignment{ + roleAssignments = []admin20231115008.RoleAssignment{ { GroupId: &groupID, OrgId: &organizationID, @@ -61,7 +61,7 @@ var ( "role": &role, }, } - pemCertificates = []admin.X509Certificate{ + pemCertificates = []admin20231115008.X509Certificate{ { NotAfter: ¬After, NotBefore: ¬Before, @@ -73,7 +73,7 @@ var ( "not_before": conversion.TimePtrToStringPtr(¬Before), }, } - federationRoleMapping = []admin.AuthFederationRoleMapping{ + federationRoleMapping = []admin20231115008.AuthFederationRoleMapping{ { ExternalGroupName: externalGroupName, Id: &roleAssignmentsID, @@ -87,7 +87,7 @@ var ( "role_assignments": flattenedRoleAssignments, }, } - federatedUser = []admin.FederatedUser{ + federatedUser = []admin20231115008.FederatedUser{ { EmailAddress: emailAddress, FederationSettingsId: federationSettingsID, @@ -105,7 +105,7 @@ var ( "user_id": &userID, }, } - associatedOrgs = []admin.ConnectedOrgConfig{ + associatedOrgs = []admin20231115008.ConnectedOrgConfig{ { DomainAllowList: &domainAllowList, DomainRestrictionEnabled: domainRestrictionEnabled, @@ -127,7 +127,7 @@ var ( "user_conflicts": nil, }, } - pemFileInfo = admin.PemFileInfo{ + pemFileInfo = admin20231115008.PemFileInfo{ FileName: &fileName, Certificates: &pemCertificates, } @@ -142,7 +142,7 @@ var ( func TestFlattenRoleAssignments(t *testing.T) { testCases := []struct { name string - input []admin.RoleAssignment + input []admin20231115008.RoleAssignment output []map[string]any }{ { @@ -152,7 +152,7 @@ func TestFlattenRoleAssignments(t *testing.T) { }, { name: "Empty FlattenRoleAssignments", - input: []admin.RoleAssignment{}, + input: []admin20231115008.RoleAssignment{}, output: nil, }, } @@ -167,7 +167,7 @@ func TestFlattenRoleAssignments(t *testing.T) { func TestFlattenFederatedUser(t *testing.T) { testCases := []struct { name string - input []admin.FederatedUser + input []admin20231115008.FederatedUser output []map[string]any }{ { @@ -177,7 +177,7 @@ func TestFlattenFederatedUser(t *testing.T) { }, { name: "Empty FlattenFederatedUser", - input: []admin.FederatedUser{}, + input: []admin20231115008.FederatedUser{}, output: nil, }, } @@ -192,7 +192,7 @@ func TestFlattenFederatedUser(t *testing.T) { func TestFlattenAuthFederationRoleMapping(t *testing.T) { testCases := []struct { name string - input []admin.AuthFederationRoleMapping + input []admin20231115008.AuthFederationRoleMapping output []map[string]any }{ { @@ -202,7 +202,7 @@ func TestFlattenAuthFederationRoleMapping(t *testing.T) { }, { name: "Empty FlattenAuthFederationRoleMapping", - input: []admin.AuthFederationRoleMapping{}, + input: []admin20231115008.AuthFederationRoleMapping{}, output: nil, }, } @@ -217,7 +217,7 @@ func TestFlattenAuthFederationRoleMapping(t *testing.T) { func TestFlattenFederatedSettingsCertificates(t *testing.T) { testCases := []struct { name string - input []admin.X509Certificate + input []admin20231115008.X509Certificate output []map[string]any }{ { @@ -227,7 +227,7 @@ func TestFlattenFederatedSettingsCertificates(t *testing.T) { }, { name: "Empty FlattenFederatedSettingsCertificates", - input: []admin.X509Certificate{}, + input: []admin20231115008.X509Certificate{}, output: nil, }, } @@ -242,7 +242,7 @@ func TestFlattenFederatedSettingsCertificates(t *testing.T) { func TestFlattenPemFileInfo(t *testing.T) { testCases := []struct { name string - input admin.PemFileInfo + input admin20231115008.PemFileInfo output []map[string]any }{ { @@ -252,7 +252,7 @@ func TestFlattenPemFileInfo(t *testing.T) { }, { name: "Empty FlattenPemFileInfo", - input: admin.PemFileInfo{}, + input: admin20231115008.PemFileInfo{}, output: nil, }, } @@ -267,7 +267,7 @@ func TestFlattenPemFileInfo(t *testing.T) { func TestFlattenAssociatedOrgs(t *testing.T) { testCases := []struct { name string - input []admin.ConnectedOrgConfig + input []admin20231115008.ConnectedOrgConfig output []map[string]any }{ { @@ -277,7 +277,7 @@ func TestFlattenAssociatedOrgs(t *testing.T) { }, { name: "Non empty FlattenAssociatedOrgs with UserConflics", - input: []admin.ConnectedOrgConfig{ + input: []admin20231115008.ConnectedOrgConfig{ { DomainAllowList: &domainAllowList, DomainRestrictionEnabled: domainRestrictionEnabled, @@ -302,7 +302,7 @@ func TestFlattenAssociatedOrgs(t *testing.T) { }, { name: "Empty FlattenAssociatedOrgs", - input: []admin.ConnectedOrgConfig{}, + input: []admin20231115008.ConnectedOrgConfig{}, output: nil, }, } @@ -322,12 +322,12 @@ func TestFlattenFederatedSettingsIdentityProvider(t *testing.T) { var nilBoolPtr *bool testCases := []struct { name string - input []admin.FederationIdentityProvider + input []admin20231115008.FederationIdentityProvider output []map[string]any }{ { name: "Non empty SAML FlattenFederatedSettingsIdentityProvider", - input: []admin.FederationIdentityProvider{ + input: []admin20231115008.FederationIdentityProvider{ { AcsUrl: &acsURL, AssociatedDomains: &associatedDomains, @@ -373,7 +373,7 @@ func TestFlattenFederatedSettingsIdentityProvider(t *testing.T) { }, { name: "Non empty OIDC FlattenFederatedSettingsIdentityProvider", - input: []admin.FederationIdentityProvider{ + input: []admin20231115008.FederationIdentityProvider{ { AssociatedDomains: &associatedDomains, AssociatedOrgs: &associatedOrgs, @@ -415,7 +415,7 @@ func TestFlattenFederatedSettingsIdentityProvider(t *testing.T) { }, { name: "Empty FlattenFederatedSettingsIdentityProvider", - input: []admin.FederationIdentityProvider{}, + input: []admin20231115008.FederationIdentityProvider{}, output: nil, }, } diff --git a/internal/service/federatedsettingsidentityprovider/resource_federated_settings_identity_provider.go b/internal/service/federatedsettingsidentityprovider/resource_federated_settings_identity_provider.go index d1e2f9eecc..5bcd2c130a 100644 --- a/internal/service/federatedsettingsidentityprovider/resource_federated_settings_identity_provider.go +++ b/internal/service/federatedsettingsidentityprovider/resource_federated_settings_identity_provider.go @@ -7,13 +7,12 @@ import ( "net/http" "regexp" - "go.mongodb.org/atlas-sdk/v20231115008/admin" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/spf13/cast" + admin20231115008 "go.mongodb.org/atlas-sdk/v20231115008/admin" ) const SAML = "SAML" @@ -224,7 +223,7 @@ func resourceMongoDBAtlasFederatedSettingsIdentityProviderUpdate(ctx context.Con federationSettingsID := ids["federation_settings_id"] oktaIdpID := ids["okta_idp_id"] - updateRequest := new(admin.FederationIdentityProviderUpdate) + updateRequest := new(admin20231115008.FederationIdentityProviderUpdate) _, _, err := connV2.FederatedAuthenticationApi.GetIdentityProvider(context.Background(), federationSettingsID, oktaIdpID).Execute() if err != nil {