Skip to content

Commit 27126fe

Browse files
authored
feat: Adds SkipDefaultAlertsSettings and GenAIFeaturesEnabled to MongoDB::Atlas::Organization schema (#1275)
1 parent d9dd9cb commit 27126fe

File tree

7 files changed

+109
-24
lines changed

7 files changed

+109
-24
lines changed

cfn-resources/organization/cmd/resource/model.go

Lines changed: 13 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cfn-resources/organization/cmd/resource/resource.go

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"net/http"
2222
"time"
2323

24-
"go.mongodb.org/atlas-sdk/v20231115014/admin"
24+
"go.mongodb.org/atlas-sdk/v20241113004/admin"
2525

2626
"github.com/aws-cloudformation/cloudformation-cli-go-plugin/cfn/handler"
2727
"github.com/aws/aws-sdk-go/service/cloudformation"
@@ -76,7 +76,7 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler
7676
if peErr != nil {
7777
return *peErr, nil
7878
}
79-
conn := client.Atlas20231115014
79+
conn := client.AtlasSDK
8080
ctx := context.Background()
8181

8282
_, _, err := secrets.Get(&req, *currentModel.AwsSecretName)
@@ -88,12 +88,14 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler
8888
}
8989

9090
apikeyInputs := setAPIkeyInputs(currentModel)
91+
setDefaultsIfNotDefined(currentModel)
9192

9293
// Set the roles from model
9394
orgInput := &admin.CreateOrganizationRequest{
94-
ApiKey: apikeyInputs,
95-
OrgOwnerId: currentModel.OrgOwnerId,
96-
Name: *currentModel.Name,
95+
ApiKey: apikeyInputs,
96+
OrgOwnerId: currentModel.OrgOwnerId,
97+
Name: *currentModel.Name,
98+
SkipDefaultAlertsSettings: currentModel.SkipDefaultAlertsSettings,
9799
}
98100
if currentModel.FederatedSettingsId != nil {
99101
orgInput.FederationSettingsId = currentModel.FederatedSettingsId
@@ -121,7 +123,7 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler
121123
if peErr != nil {
122124
return *peErr, nil
123125
}
124-
conn = newOrgClient.Atlas20231115014
126+
conn = newOrgClient.AtlasSDK
125127
if _, _, errUpdate := conn.OrganizationsApi.UpdateOrganizationSettings(ctx, orgID, newOrganizationSettings(currentModel)).Execute(); errUpdate != nil {
126128
return handleError(response, constants.CREATE, err)
127129
}
@@ -145,7 +147,7 @@ func Read(req handler.Request, prevModel *Model, currentModel *Model) (handler.P
145147
return *peErr, nil
146148
}
147149

148-
model, response, err := currentModel.getOrgDetails(context.Background(), newOrgClient.Atlas20231115014, currentModel)
150+
model, response, err := currentModel.getOrgDetails(context.Background(), newOrgClient.AtlasSDK, currentModel)
149151
if err != nil {
150152
return handleError(response, constants.READ, err)
151153
}
@@ -167,11 +169,13 @@ func Update(req handler.Request, prevModel *Model, currentModel *Model) (handler
167169
if peErr != nil {
168170
return *peErr, nil
169171
}
170-
conn := newOrgClient.Atlas20231115014
172+
conn := newOrgClient.AtlasSDK
171173
ctx := context.Background()
172174

173-
atlasOrg := admin.AtlasOrganization{Id: currentModel.OrgId, Name: *currentModel.Name}
174-
if _, response, err := conn.OrganizationsApi.RenameOrganization(ctx, *currentModel.OrgId, &atlasOrg).Execute(); err != nil {
175+
setDefaultsIfNotDefined(currentModel)
176+
atlasOrg := admin.AtlasOrganization{Id: currentModel.OrgId, Name: *currentModel.Name, SkipDefaultAlertsSettings: currentModel.SkipDefaultAlertsSettings}
177+
178+
if _, response, err := conn.OrganizationsApi.UpdateOrganization(ctx, *currentModel.OrgId, &atlasOrg).Execute(); err != nil {
175179
return handleError(response, constants.UPDATE, err)
176180
}
177181

@@ -197,7 +201,7 @@ func Delete(req handler.Request, prevModel *Model, currentModel *Model) (handler
197201
if peErr != nil {
198202
return *peErr, nil
199203
}
200-
conn := newOrgClient.Atlas20231115014
204+
conn := newOrgClient.AtlasSDK
201205
ctx := context.Background()
202206

203207
// Callback
@@ -301,6 +305,7 @@ func (model *Model) getOrgDetails(ctx context.Context, conn *admin.APIClient, cu
301305
model.Name = util.Pointer(org.Name)
302306
model.OrgId = org.Id
303307
model.IsDeleted = org.IsDeleted
308+
model.SkipDefaultAlertsSettings = org.SkipDefaultAlertsSettings
304309

305310
settings, _, err := conn.OrganizationsApi.GetOrganizationSettings(ctx, org.GetId()).Execute()
306311
if err != nil {
@@ -309,6 +314,7 @@ func (model *Model) getOrgDetails(ctx context.Context, conn *admin.APIClient, cu
309314
model.ApiAccessListRequired = settings.ApiAccessListRequired
310315
model.MultiFactorAuthRequired = settings.MultiFactorAuthRequired
311316
model.RestrictEmployeeAccess = settings.RestrictEmployeeAccess
317+
model.GenAIFeaturesEnabled = settings.GenAIFeaturesEnabled
312318

313319
return model, response, nil
314320
}
@@ -352,5 +358,18 @@ func newOrganizationSettings(model *Model) *admin.OrganizationSettings {
352358
ApiAccessListRequired: model.ApiAccessListRequired,
353359
MultiFactorAuthRequired: model.MultiFactorAuthRequired,
354360
RestrictEmployeeAccess: model.RestrictEmployeeAccess,
361+
GenAIFeaturesEnabled: model.GenAIFeaturesEnabled,
362+
}
363+
}
364+
365+
func setDefaultsIfNotDefined(m *Model) {
366+
if m == nil {
367+
return
368+
}
369+
if m.SkipDefaultAlertsSettings == nil {
370+
m.SkipDefaultAlertsSettings = util.Pointer(true)
371+
}
372+
if m.GenAIFeaturesEnabled == nil {
373+
m.GenAIFeaturesEnabled = util.Pointer(true)
355374
}
356375
}

cfn-resources/organization/docs/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ To declare this entity in your AWS CloudFormation template, use the following sy
1818
"<a href="#orgownerid" title="OrgOwnerId">OrgOwnerId</a>" : <i>String</i>,
1919
"<a href="#profile" title="Profile">Profile</a>" : <i>String</i>,
2020
"<a href="#awssecretname" title="AwsSecretName">AwsSecretName</a>" : <i>String</i>,
21+
"<a href="#skipdefaultalertssettings" title="SkipDefaultAlertsSettings">SkipDefaultAlertsSettings</a>" : <i>Boolean</i>,
22+
"<a href="#genaifeaturesenabled" title="GenAIFeaturesEnabled">GenAIFeaturesEnabled</a>" : <i>Boolean</i>,
2123
"<a href="#isdeleted" title="IsDeleted">IsDeleted</a>" : <i>Boolean</i>,
2224
"<a href="#apiaccesslistrequired" title="ApiAccessListRequired">ApiAccessListRequired</a>" : <i>Boolean</i>,
2325
"<a href="#multifactorauthrequired" title="MultiFactorAuthRequired">MultiFactorAuthRequired</a>" : <i>Boolean</i>,
@@ -37,6 +39,8 @@ Properties:
3739
<a href="#orgownerid" title="OrgOwnerId">OrgOwnerId</a>: <i>String</i>
3840
<a href="#profile" title="Profile">Profile</a>: <i>String</i>
3941
<a href="#awssecretname" title="AwsSecretName">AwsSecretName</a>: <i>String</i>
42+
<a href="#skipdefaultalertssettings" title="SkipDefaultAlertsSettings">SkipDefaultAlertsSettings</a>: <i>Boolean</i>
43+
<a href="#genaifeaturesenabled" title="GenAIFeaturesEnabled">GenAIFeaturesEnabled</a>: <i>Boolean</i>
4044
<a href="#isdeleted" title="IsDeleted">IsDeleted</a>: <i>Boolean</i>
4145
<a href="#apiaccesslistrequired" title="ApiAccessListRequired">ApiAccessListRequired</a>: <i>Boolean</i>
4246
<a href="#multifactorauthrequired" title="MultiFactorAuthRequired">MultiFactorAuthRequired</a>: <i>Boolean</i>
@@ -109,6 +113,26 @@ _Type_: String
109113

110114
_Update requires_: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)
111115

116+
#### SkipDefaultAlertsSettings
117+
118+
Disables automatic alert creation. When set to `true`, Atlas doesn't automatically create organization-level alerts. Defaults to `true` for new Atlas Organizations created with the provider to prevent infrastructure drift caused by creation of new alerts.
119+
120+
_Required_: No
121+
122+
_Type_: Boolean
123+
124+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
125+
126+
#### GenAIFeaturesEnabled
127+
128+
Flag that indicates whether this organization has access to generative AI features. This setting only applies to Atlas Commercial and defaults to `true`. With this setting on, Project Owners may be able to enable or disable individual AI features at the project level. To learn more, see https://www.mongodb.com/docs/generative-ai-faq/
129+
130+
_Required_: No
131+
132+
_Type_: Boolean
133+
134+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
135+
112136
#### IsDeleted
113137

114138
Flag that indicates whether this organization has been deleted.

cfn-resources/organization/mongodb-atlas-organization.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@
5151
"description": "AwsSecretName used to set newly created Org credentials information.",
5252
"default": "default"
5353
},
54+
"SkipDefaultAlertsSettings": {
55+
"type": "boolean",
56+
"description": "Disables automatic alert creation. When set to `true`, Atlas doesn't automatically create organization-level alerts. Defaults to `true` for new Atlas Organizations created with the provider to prevent infrastructure drift caused by creation of new alerts.",
57+
"default": true
58+
},
59+
"GenAIFeaturesEnabled": {
60+
"type": "boolean",
61+
"description": "Flag that indicates whether this organization has access to generative AI features. This setting only applies to Atlas Commercial and defaults to `true`. With this setting on, Project Owners may be able to enable or disable individual AI features at the project level. To learn more, see https://www.mongodb.com/docs/generative-ai-faq/",
62+
"default": true
63+
},
5464
"OrgId": {
5565
"type": "string",
5666
"description": "Unique 24-hexadecimal digit string that identifies the organization that contains your projects. Use the /orgs endpoint to retrieve all organizations to which the authenticated user has access.",

cfn-resources/organization/test/inputs_1_create.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@
1212
},
1313
"MultiFactorAuthRequired": "true",
1414
"RestrictEmployeeAccess": "false",
15-
"ApiAccessListRequired": "false"
15+
"ApiAccessListRequired": "false",
16+
"SkipDefaultAlertsSettings": "true",
17+
"GenAIFeaturesEnabled": "true"
1618
}

cfn-resources/organization/test/inputs_1_update.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@
1212
},
1313
"MultiFactorAuthRequired": "true",
1414
"RestrictEmployeeAccess": "true",
15-
"ApiAccessListRequired": "false"
15+
"ApiAccessListRequired": "false",
16+
"SkipDefaultAlertsSettings": "false",
17+
"GenAIFeaturesEnabled": "false"
1618
}

examples/organization/organization.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,26 @@
6161
"false"
6262
],
6363
"Default": "false"
64+
},
65+
"SkipDefaultAlertsSettings": {
66+
"Type": "String",
67+
"ConstraintDescription": "boolean",
68+
"AllowedValues": [
69+
"true",
70+
"false"
71+
],
72+
"Default": "true",
73+
"Description": "SkipDefaultAlertsSettings"
74+
},
75+
"GenAIFeaturesEnabled": {
76+
"Type": "String",
77+
"ConstraintDescription": "boolean",
78+
"AllowedValues": [
79+
"true",
80+
"false"
81+
],
82+
"Default": "true",
83+
"Description": "Flag that indicates whether this organization has access to generative AI features. This setting only applies to Atlas Commercial and defaults to `true`. With this setting on, Project Owners may be able to enable or disable individual AI features at the project level. To learn more, see https://www.mongodb.com/docs/generative-ai-faq/"
6484
}
6585
},
6686
"Mappings": {},
@@ -113,6 +133,12 @@
113133
},
114134
"RestrictEmployeeAccess": {
115135
"Ref": "RestrictEmployeeAccess"
136+
},
137+
"SkipDefaultAlertsSettings": {
138+
"Ref": "SkipDefaultAlertsSettings"
139+
},
140+
"GenAIFeaturesEnabled": {
141+
"Ref": "GenAIFeaturesEnabled"
116142
}
117143
}
118144
}

0 commit comments

Comments
 (0)