當前位置: 首頁>>代碼示例>>Golang>>正文


Golang CreateDashboardSnapshotCommand.UserId方法代碼示例

本文整理匯總了Golang中github.com/grafana/grafana/pkg/models.CreateDashboardSnapshotCommand.UserId方法的典型用法代碼示例。如果您正苦於以下問題:Golang CreateDashboardSnapshotCommand.UserId方法的具體用法?Golang CreateDashboardSnapshotCommand.UserId怎麽用?Golang CreateDashboardSnapshotCommand.UserId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/grafana/grafana/pkg/models.CreateDashboardSnapshotCommand的用法示例。


在下文中一共展示了CreateDashboardSnapshotCommand.UserId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: CreateDashboardSnapshot

func CreateDashboardSnapshot(c *middleware.Context, cmd m.CreateDashboardSnapshotCommand) {
	if cmd.External {
		// external snapshot ref requires key and delete key
		if cmd.Key == "" || cmd.DeleteKey == "" {
			c.JsonApiErr(400, "Missing key and delete key for external snapshot", nil)
			return
		}

		cmd.OrgId = -1
		cmd.UserId = -1
		metrics.M_Api_Dashboard_Snapshot_External.Inc(1)
	} else {
		cmd.Key = util.GetRandomString(32)
		cmd.DeleteKey = util.GetRandomString(32)
		cmd.OrgId = c.OrgId
		cmd.UserId = c.UserId
		metrics.M_Api_Dashboard_Snapshot_Create.Inc(1)
	}

	if err := bus.Dispatch(&cmd); err != nil {
		c.JsonApiErr(500, "Failed to create snaphost", err)
		return
	}

	c.JSON(200, util.DynMap{
		"key":       cmd.Key,
		"deleteKey": cmd.DeleteKey,
		"url":       setting.ToAbsUrl("dashboard/snapshot/" + cmd.Key),
		"deleteUrl": setting.ToAbsUrl("api/snapshots-delete/" + cmd.DeleteKey),
	})
}
開發者ID:chengweiv5,項目名稱:grafana,代碼行數:31,代碼來源:dashboard_snapshot.go


注:本文中的github.com/grafana/grafana/pkg/models.CreateDashboardSnapshotCommand.UserId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。