Skip to content

Commit a3f6d71

Browse files
Add SendUserProvidedResourceTags to third party integrations resource
1 parent a12defc commit a3f6d71

File tree

4 files changed

+59
-53
lines changed

4 files changed

+59
-53
lines changed

cfn-resources/third-party-integration/cmd/resource/model.go

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

cfn-resources/third-party-integration/cmd/resource/resource.go

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
log "github.com/mongodb/mongodbatlas-cloudformation-resources/util/logger"
2626
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/progressevent"
2727
"github.com/mongodb/mongodbatlas-cloudformation-resources/util/validator"
28-
"go.mongodb.org/atlas-sdk/v20231115002/admin"
28+
"go.mongodb.org/atlas-sdk/v20250312005/admin"
2929
)
3030

3131
var RequiredFields = []string{constants.IntegrationType, constants.ProjectID}
@@ -76,7 +76,7 @@ func Create(req handler.Request, prevModel *Model, currentModel *Model) (handler
7676
}
7777

7878
requestBody := modelToIntegration(currentModel)
79-
integrations, resModel, err := client.Atlas20231115002.ThirdPartyIntegrationsApi.CreateThirdPartyIntegration(context.Background(), *IntegrationType, *ProjectID, requestBody).Execute()
79+
integrations, resModel, err := client.AtlasSDK.ThirdPartyIntegrationsApi.CreateThirdPartyIntegration(context.Background(), *IntegrationType, *ProjectID, requestBody).Execute()
8080
if err != nil {
8181
if apiError, ok := admin.AsError(err); ok && *apiError.Error == http.StatusConflict {
8282
return progressevent.GetFailedEventByCode("INTEGRATION_ALREADY_CONFIGURED.", cloudformation.HandlerErrorCodeAlreadyExists), nil
@@ -108,7 +108,7 @@ func Read(req handler.Request, prevModel *Model, currentModel *Model) (handler.P
108108
ProjectID := currentModel.ProjectId
109109
IntegrationType := currentModel.Type
110110

111-
integration, res, err := client.Atlas20231115002.ThirdPartyIntegrationsApi.GetThirdPartyIntegration(context.Background(), *ProjectID, *IntegrationType).Execute()
111+
integration, res, err := client.AtlasSDK.ThirdPartyIntegrationsApi.GetThirdPartyIntegration(context.Background(), *ProjectID, *IntegrationType).Execute()
112112

113113
if err != nil {
114114
return progressevent.GetFailedEventByResponse(err.Error(), res), nil
@@ -139,13 +139,13 @@ func Update(req handler.Request, prevModel *Model, currentModel *Model) (handler
139139
ProjectID := currentModel.ProjectId
140140
IntegrationType := currentModel.Type
141141

142-
integration, res, err := client.Atlas20231115002.ThirdPartyIntegrationsApi.GetThirdPartyIntegration(context.Background(), *ProjectID, *IntegrationType).Execute()
142+
integration, res, err := client.AtlasSDK.ThirdPartyIntegrationsApi.GetThirdPartyIntegration(context.Background(), *ProjectID, *IntegrationType).Execute()
143143
if err != nil {
144144
return progressevent.GetFailedEventByResponse(err.Error(), res), nil
145145
}
146146

147147
updateIntegrationFromSchema(currentModel, integration)
148-
integrations, res, err := client.Atlas20231115002.ThirdPartyIntegrationsApi.UpdateThirdPartyIntegration(context.Background(), *IntegrationType, *ProjectID, integration).Execute()
148+
integrations, res, err := client.AtlasSDK.ThirdPartyIntegrationsApi.UpdateThirdPartyIntegration(context.Background(), *IntegrationType, *ProjectID, integration).Execute()
149149
if err != nil {
150150
return progressevent.GetFailedEventByResponse(err.Error(), res), nil
151151
}
@@ -156,7 +156,7 @@ func Update(req handler.Request, prevModel *Model, currentModel *Model) (handler
156156
}, nil
157157
}
158158

159-
func updateIntegrationFromSchema(currentModel *Model, integration *admin.ThridPartyIntegration) {
159+
func updateIntegrationFromSchema(currentModel *Model, integration *admin.ThirdPartyIntegration) {
160160
if util.IsStringPresent(currentModel.Url) && !util.AreStringPtrEqual(currentModel.Url, integration.Url) {
161161
integration.Url = currentModel.Url
162162
}
@@ -196,12 +196,13 @@ func updateIntegrationFromSchema(currentModel *Model, integration *admin.ThridPa
196196
if util.IsStringPresent(currentModel.ServiceDiscovery) && !util.AreStringPtrEqual(currentModel.ServiceDiscovery, integration.ServiceDiscovery) {
197197
integration.ServiceDiscovery = currentModel.ServiceDiscovery
198198
}
199-
if util.IsStringPresent(currentModel.Scheme) && !util.AreStringPtrEqual(currentModel.Scheme, integration.Scheme) {
200-
integration.Scheme = currentModel.Scheme
201-
}
202199
if currentModel.Enabled != nil && currentModel.Enabled != integration.Enabled {
203200
integration.Enabled = currentModel.Enabled
204201
}
202+
203+
if currentModel.SendUserProvidedResourceTags != nil {
204+
integration.SendUserProvidedResourceTags = currentModel.SendUserProvidedResourceTags
205+
}
205206
}
206207

207208
func Delete(req handler.Request, prevModel *Model, currentModel *Model) (handler.ProgressEvent, error) {
@@ -223,7 +224,7 @@ func Delete(req handler.Request, prevModel *Model, currentModel *Model) (handler
223224
ProjectID := currentModel.ProjectId
224225
IntegrationType := currentModel.Type
225226

226-
_, res, err = client.Atlas20231115002.ThirdPartyIntegrationsApi.DeleteThirdPartyIntegration(context.Background(), *IntegrationType, *ProjectID).Execute()
227+
res, err = client.AtlasSDK.ThirdPartyIntegrationsApi.DeleteThirdPartyIntegration(context.Background(), *IntegrationType, *ProjectID).Execute()
227228

228229
if err != nil {
229230
return progressevent.GetFailedEventByResponse(err.Error(), res), nil
@@ -251,7 +252,7 @@ func List(req handler.Request, prevModel *Model, currentModel *Model) (handler.P
251252

252253
var res *http.Response
253254
ProjectID := currentModel.ProjectId
254-
integrations, res, err := client.Atlas20231115002.ThirdPartyIntegrationsApi.ListThirdPartyIntegrations(context.Background(), *ProjectID).Execute()
255+
integrations, res, err := client.AtlasSDK.ThirdPartyIntegrationsApi.ListThirdPartyIntegrations(context.Background(), *ProjectID).Execute()
255256
if err != nil {
256257
return progressevent.GetFailedEventByResponse(err.Error(), res), nil
257258
}
@@ -270,18 +271,15 @@ func List(req handler.Request, prevModel *Model, currentModel *Model) (handler.P
270271
}, nil
271272
}
272273

273-
func modelToIntegration(currentModel *Model) (out *admin.ThridPartyIntegration) {
274-
out = &admin.ThridPartyIntegration{}
274+
func modelToIntegration(currentModel *Model) (out *admin.ThirdPartyIntegration) {
275+
out = &admin.ThirdPartyIntegration{}
275276

276277
if util.IsStringPresent(currentModel.Type) {
277278
out.Type = currentModel.Type
278279
}
279280
if currentModel.Enabled != nil {
280281
out.Enabled = currentModel.Enabled
281282
}
282-
if util.IsStringPresent(currentModel.Scheme) {
283-
out.Scheme = currentModel.Scheme
284-
}
285283
if util.IsStringPresent(currentModel.ServiceDiscovery) {
286284
out.ServiceDiscovery = currentModel.ServiceDiscovery
287285
}
@@ -322,10 +320,13 @@ func modelToIntegration(currentModel *Model) (out *admin.ThridPartyIntegration)
322320
out.ApiKey = currentModel.ApiKey
323321
}
324322

323+
if currentModel.SendUserProvidedResourceTags != nil {
324+
out.SendUserProvidedResourceTags = currentModel.SendUserProvidedResourceTags
325+
}
325326
return out
326327
}
327328

328-
func integrationToModel(currentModel Model, integration *admin.ThridPartyIntegration) Model {
329+
func integrationToModel(currentModel Model, integration *admin.ThirdPartyIntegration) Model {
329330
// if "Enabled" is not set in the inputs we dont want to return "Enabled" in outputs
330331
enabled := currentModel.Enabled != nil
331332

@@ -341,5 +342,6 @@ func integrationToModel(currentModel Model, integration *admin.ThridPartyIntegra
341342
if !enabled {
342343
out.Enabled = nil
343344
}
345+
344346
return out
345347
}

cfn-resources/third-party-integration/docs/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ To declare this entity in your AWS CloudFormation template, use the following sy
3131
"<a href="#scheme" title="Scheme">Scheme</a>" : <i>String</i>,
3232
"<a href="#enabled" title="Enabled">Enabled</a>" : <i>Boolean</i>,
3333
"<a href="#listenaddress" title="ListenAddress">ListenAddress</a>" : <i>String</i>,
34-
"<a href="#tlspempath" title="TlsPemPath">TlsPemPath</a>" : <i>String</i>
34+
"<a href="#tlspempath" title="TlsPemPath">TlsPemPath</a>" : <i>String</i>,
35+
"<a href="#senduserprovidedresourcetags" title="SendUserProvidedResourceTags">SendUserProvidedResourceTags</a>" : <i>Boolean</i>
3536
}
3637
}
3738
</pre>
@@ -61,6 +62,7 @@ Properties:
6162
<a href="#enabled" title="Enabled">Enabled</a>: <i>Boolean</i>
6263
<a href="#listenaddress" title="ListenAddress">ListenAddress</a>: <i>String</i>
6364
<a href="#tlspempath" title="TlsPemPath">TlsPemPath</a>: <i>String</i>
65+
<a href="#senduserprovidedresourcetags" title="SendUserProvidedResourceTags">SendUserProvidedResourceTags</a>: <i>Boolean</i>
6466
</pre>
6567

6668
## Properties
@@ -271,3 +273,13 @@ _Type_: String
271273

272274
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
273275

276+
#### SendUserProvidedResourceTags
277+
278+
Flag that indicates whether to send user-provided resource tags.
279+
280+
_Required_: No
281+
282+
_Type_: Boolean
283+
284+
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
285+

cfn-resources/third-party-integration/mongodb-atlas-thirdpartyintegration.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
"/properties/UserName",
5555
"/properties/ServiceDiscovery",
5656
"/properties/Scheme",
57-
"/properties/Enabled"
57+
"/properties/Enabled",
58+
"/properties/SendUserProvidedResourceTags"
5859
],
5960
"properties": {
6061
"ProjectId": {
@@ -156,6 +157,10 @@
156157
"TlsPemPath": {
157158
"type": "string",
158159
"description": "Root-relative path to the Transport Layer Security (TLS) Privacy Enhanced Mail (PEM) key and certificate file on the host."
160+
},
161+
"SendUserProvidedResourceTags": {
162+
"type": "boolean",
163+
"description": "Flag that indicates whether to send user-provided resource tags."
159164
}
160165
},
161166
"typeName": "MongoDB::Atlas::ThirdPartyIntegration",

0 commit comments

Comments
 (0)