Skip to content
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

INTMDB-311: Feature Add: Prometheus and Microsoft Team to the Third Party Integration Settings #284

Merged
merged 2 commits into from
Apr 4, 2022
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
39 changes: 23 additions & 16 deletions mongodbatlas/third_party_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the unit test to use these new properties?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expanded tests to cover Teams and Prometheus feature added

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 bool `json:"enabled,omitempty"`
}

// ThirdPartyIntegrations contains the response from the endpoint.
Expand Down
94 changes: 86 additions & 8 deletions mongodbatlas/third_party_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}`)
})

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}`)
})

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}`)
})

Expand Down Expand Up @@ -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 {
Expand Down