//set a dashboard and return details
set a dashboard and return details
// set a dashboard and return details
func (a APIClient) SetDashboard(dSpec v1alpha1.DashboardSpec) (dStatus v1alpha1.DashboardStatus,
	err error) {
	folderid := 0
	var found bool
	board := sdk.Board{}
	err = json.Unmarshal([]byte(dSpec.Content), &board)
	if err != nil {
		dStatus.Message = err.Error()
		return dStatus, err
	}
	if len(dSpec.Folder) != 0 {
		folderid, _, found, err = a.GetFolderByName(dSpec.Folder)
	}
	if !found {
		dStatus.Message = "Folder not found"
		return dStatus, err
	}
	params := sdk.SetDashboardParams{
		FolderID:  folderid,
		Overwrite: true,
	}
	statusMessage, err := a.Client.SetDashboard(a.Context, board, params)
	if err != nil {
		dStatus.Message = err.Error()
	}
	return processStatusMessage(statusMessage), err
}
func ( a APIClient ) SetDashboard ( dSpec v1alpha1 . DashboardSpec ) ( dStatus v1alpha1 . DashboardStatus , err error ) { folderid := 0 var found bool board := sdk . Board { } err = json . Unmarshal ( [ ] byte ( dSpec . Content ) , & board ) if err != nil { dStatus . Message = err . Error ( ) return dStatus , err } if len ( dSpec . Folder ) != 0 { folderid , _ , found , err = a . GetFolderByName ( dSpec . Folder ) } if ! found { dStatus . Message = " " return dStatus , err } params := sdk . SetDashboardParams { FolderID : folderid , Overwrite : true , } statusMessage , err := a . Client . SetDashboard ( a . Context , board , params ) if err != nil { dStatus . Message = err . Error ( ) } return processStatusMessage ( statusMessage ) , err }
set a dashboard and return details
set a dashboard and return details
// If we find no folder error and retry. Should help orchestrate folder // creation and dashboard deployment to the folder.