CloudMigrations: create snapshot for Notification Templates (#94676)

* CloudMigrations: create snapshot for Notification Templates

* CloudMigrations: add notification templates resource to frontend
This commit is contained in:
Matheus Macabu
2024-10-15 12:55:33 +02:00
committed by GitHub
parent f97f489c2c
commit 016dea1143
9 changed files with 100 additions and 6 deletions
@@ -33,6 +33,7 @@ var currentMigrationTypes = []cloudmigration.MigrateDataType{
cloudmigration.LibraryElementDataType,
cloudmigration.DashboardDataType,
cloudmigration.MuteTimingType,
cloudmigration.NotificationTemplateType,
}
func (s *Service) getMigrationDataJSON(ctx context.Context, signedInUser *user.SignedInUser) (*cloudmigration.MigrateDataRequest, error) {
@@ -66,9 +67,17 @@ func (s *Service) getMigrationDataJSON(ctx context.Context, signedInUser *user.S
return nil, err
}
// Alerts: Notification Templates
notificationTemplates, err := s.getNotificationTemplates(ctx, signedInUser)
if err != nil {
s.log.Error("Failed to get alert notification templates", "err", err)
return nil, err
}
migrationDataSlice := make(
[]cloudmigration.MigrateDataRequestItem, 0,
len(dataSources)+len(dashs)+len(folders)+len(libraryElements)+len(muteTimings),
len(dataSources)+len(dashs)+len(folders)+len(libraryElements)+
len(muteTimings)+len(notificationTemplates),
)
for _, ds := range dataSources {
@@ -124,6 +133,15 @@ func (s *Service) getMigrationDataJSON(ctx context.Context, signedInUser *user.S
})
}
for _, notificationTemplate := range notificationTemplates {
migrationDataSlice = append(migrationDataSlice, cloudmigration.MigrateDataRequestItem{
Type: cloudmigration.NotificationTemplateType,
RefID: notificationTemplate.Name,
Name: notificationTemplate.Name,
Data: notificationTemplate,
})
}
// Obtain the names of parent elements for Dashboard and Folders data types
parentNamesByType, err := s.getParentNames(ctx, signedInUser, dashs, folders, libraryElements)
if err != nil {