func setUpNotifications()

in main.go [30:63]


func setUpNotifications(vidispine_url *url.URL, requestor *vidispine.VSRequestor, callbackUrl *url.URL) {
	/*
		we define the information that we are checking for with these three arrays. They all need to have the same number
		of (top-level) elements. The first element of `expectedNotificationTypes` is another array consisting of the "notification
		type" parameter for the first entity type and the first element of `requiredSubpaths` is the subpath of `callbackUrl`
		where we want that notification delivered
	*/
	expectedEntityTypes := []string{"job", "metadata", "item", "shape"}
	expectedNotificationTypes := [][]string{
		{"stop", "update", "create"},
		{"modify"},
		{"create", "delete"},
		{"create", "modify", "delete"},
	}
	requiredSubpaths := []string{"/job", "/item/metadata", "/item", "/item/shape"}
	log.Print("Checking for our notifications in ", vidispine_url.String())

	for entityIndex, et := range expectedEntityTypes {
		for _, nt := range expectedNotificationTypes[entityIndex] {
			notificationPresent, check_err := SearchForMyNotification(requestor, callbackUrl.String()+requiredSubpaths[entityIndex], et, nt)
			if check_err != nil {
				log.Fatal("Could not check for notification: ", check_err)
			}

			if !notificationPresent {
				log.Printf("INFO setUpNotifications missing %s %s notification", et, nt)
				createErr := CreateNotification(requestor, callbackUrl.String()+requiredSubpaths[entityIndex], et, nt)
				if createErr != nil {
					log.Fatal("Could not create notification: ", createErr)
				}
			}
		}
	}
}