From 18ef33419ce7099e3df9532f52f7731d45ba06eb Mon Sep 17 00:00:00 2001 From: admin <33664051+martinstibbe@users.noreply.github.com> Date: Tue, 29 Mar 2022 20:58:22 -0500 Subject: [PATCH 1/2] INTMDB-311: Feature Add: Prometheus and Microsoft Team to the Third Party Integration Settings --- mongodbatlas/third_party_integration.go | 39 +++++++++++++++---------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/mongodbatlas/third_party_integration.go b/mongodbatlas/third_party_integration.go index 2d015b5f3..b38a0b6f7 100644 --- a/mongodbatlas/third_party_integration.go +++ b/mongodbatlas/third_party_integration.go @@ -29,22 +29,29 @@ var _ IntegrationsService = &IntegrationsServiceOp{} // ThirdPartyIntegration contains parameters for different third-party services. type ThirdPartyIntegration struct { - Type string `json:"type,omitempty"` - LicenseKey string `json:"licenseKey,omitempty"` - AccountID string `json:"accountId,omitempty"` - WriteToken string `json:"writeToken,omitempty"` - ReadToken string `json:"readToken,omitempty"` - APIKey string `json:"apiKey,omitempty"` - Region string `json:"region,omitempty"` - ServiceKey string `json:"serviceKey,omitempty"` - APIToken string `json:"apiToken,omitempty"` - TeamName string `json:"teamName,omitempty"` - ChannelName string `json:"channelName,omitempty"` - RoutingKey string `json:"routingKey,omitempty"` - FlowName string `json:"flowName,omitempty"` - OrgName string `json:"orgName,omitempty"` - URL string `json:"url,omitempty"` - Secret string `json:"secret,omitempty"` + Type string `json:"type,omitempty"` + LicenseKey string `json:"licenseKey,omitempty"` + AccountID string `json:"accountId,omitempty"` + WriteToken string `json:"writeToken,omitempty"` + ReadToken string `json:"readToken,omitempty"` + APIKey string `json:"apiKey,omitempty"` + Region string `json:"region,omitempty"` + ServiceKey string `json:"serviceKey,omitempty"` + APIToken string `json:"apiToken,omitempty"` + TeamName string `json:"teamName,omitempty"` + ChannelName string `json:"channelName,omitempty"` + RoutingKey string `json:"routingKey,omitempty"` + FlowName string `json:"flowName,omitempty"` + OrgName string `json:"orgName,omitempty"` + URL string `json:"url,omitempty"` + Secret string `json:"secret,omitempty"` + Name string `json:"name,omitempty"` + MicrosoftTeamsWebhookURL string `json:"microsoftTeamsWebhookUrl,omitempty"` + UserName string `json:"username,omitempty"` + Password string `json:"password,omitempty"` + ServiceDiscovery string `json:"serviceDiscovery,omitempty"` + Scheme string `json:"scheme,omitempty"` + Enabled string `json:"enabled,omitempty"` } // ThirdPartyIntegrations contains the response from the endpoint. From 86b34ba344cd64be2985ab885ebf15ee130399f3 Mon Sep 17 00:00:00 2001 From: admin <33664051+martinstibbe@users.noreply.github.com> Date: Sun, 3 Apr 2022 14:36:24 -0500 Subject: [PATCH 2/2] Expand tests for Teams and Prometheus change Enabled to boolean --- mongodbatlas/third_party_integration.go | 2 +- mongodbatlas/third_party_integration_test.go | 94 ++++++++++++++++++-- 2 files changed, 87 insertions(+), 9 deletions(-) diff --git a/mongodbatlas/third_party_integration.go b/mongodbatlas/third_party_integration.go index b38a0b6f7..76998f72b 100644 --- a/mongodbatlas/third_party_integration.go +++ b/mongodbatlas/third_party_integration.go @@ -51,7 +51,7 @@ type ThirdPartyIntegration struct { Password string `json:"password,omitempty"` ServiceDiscovery string `json:"serviceDiscovery,omitempty"` Scheme string `json:"scheme,omitempty"` - Enabled string `json:"enabled,omitempty"` + Enabled bool `json:"enabled,omitempty"` } // ThirdPartyIntegrations contains the response from the endpoint. diff --git a/mongodbatlas/third_party_integration_test.go b/mongodbatlas/third_party_integration_test.go index 2b0f340d8..5e40f4ac8 100644 --- a/mongodbatlas/third_party_integration_test.go +++ b/mongodbatlas/third_party_integration_test.go @@ -34,9 +34,22 @@ func TestThirdPartyIntegration_List(t *testing.T) { "channelName": "My Channel", "teamName": "My Team", "type": "SLACK" + }, + { + "MicrosoftTeamsWebhookURL": "https://teams.microsoft.com/webhook", + "Name": "MyTeam", + "type": "MICROSOFT_TEAMS" + }, + { + "enabled": true, + "scheme": "http", + "serviceDiscovery": "112233", + "password": "myPassword", + "username": "myUser", + "type": "PROMETHEUS" } ], - "totalCount": 2 + "totalCount": 4 }`) }) @@ -64,8 +77,21 @@ func TestThirdPartyIntegration_List(t *testing.T) { TeamName: "My Team", ChannelName: "My Channel", }, + { + Type: "MICROSOFT_TEAMS", + Name: "MyTeam", + MicrosoftTeamsWebhookURL: "https://teams.microsoft.com/webhook", + }, + { + Type: "PROMETHEUS", + UserName: "myUser", + Password: "myPassword", + ServiceDiscovery: "112233", + Scheme: "http", + Enabled: true, + }, }, - TotalCount: 2, + TotalCount: 4, } if diff := deep.Equal(integrationAPIKeys, expected); diff != nil { @@ -151,9 +177,22 @@ func TestThirdPartyIntegration_Create(t *testing.T) { "channelName": "My Channel", "teamName": "My Team", "type": "SLACK" - } + }, + { + "MicrosoftTeamsWebhookURL": "https://teams.microsoft.com/webhook", + "Name": "MyTeam", + "type": "MICROSOFT_TEAMS" + }, + { + "enabled": true, + "scheme": "http", + "serviceDiscovery": "112233", + "password": "myPassword", + "username": "myUser", + "type": "PROMETHEUS" + } ], - "totalCount": 2 + "totalCount": 4 }`) }) @@ -187,8 +226,21 @@ func TestThirdPartyIntegration_Create(t *testing.T) { TeamName: "My Team", ChannelName: "My Channel", }, + { + Type: "MICROSOFT_TEAMS", + Name: "MyTeam", + MicrosoftTeamsWebhookURL: "https://teams.microsoft.com/webhook", + }, + { + Type: "PROMETHEUS", + UserName: "myUser", + Password: "myPassword", + ServiceDiscovery: "112233", + Scheme: "http", + Enabled: true, + }, }, - TotalCount: 2, + TotalCount: 4, } if diff := deep.Equal(integrationAPIKeys, expected); diff != nil { @@ -223,9 +275,22 @@ func TestThirdPartyIntegration_Replace(t *testing.T) { "channelName": "My Channel", "teamName": "My Team", "type": "SLACK" - } + }, + { + "MicrosoftTeamsWebhookURL": "https://teams.microsoft.com/webhook", + "Name": "MyTeam", + "type": "MICROSOFT_TEAMS" + }, + { + "enabled": true, + "scheme": "http", + "serviceDiscovery": "112233", + "password": "myPassword", + "username": "myUser", + "type": "PROMETHEUS" + } ], - "totalCount": 2 + "totalCount": 4 }`) }) @@ -259,8 +324,21 @@ func TestThirdPartyIntegration_Replace(t *testing.T) { TeamName: "My Team", ChannelName: "My Channel", }, + { + Type: "MICROSOFT_TEAMS", + Name: "MyTeam", + MicrosoftTeamsWebhookURL: "https://teams.microsoft.com/webhook", + }, + { + Type: "PROMETHEUS", + UserName: "myUser", + Password: "myPassword", + ServiceDiscovery: "112233", + Scheme: "http", + Enabled: true, + }, }, - TotalCount: 2, + TotalCount: 4, } if diff := deep.Equal(integrationAPIKeys, expected); diff != nil {