@Summary List Snapshots @Description **Get list of snapshots** @Description @Description Each snapshot is returned as in “show” API. @Tags Snapshots @Produce json @Success 200 {array} snapshotResponse @Router /api/snapshots [get]
(c *gin.Context)
| 23 | // @Success 200 {array} snapshotResponse |
| 24 | // @Router /api/snapshots [get] |
| 25 | func apiSnapshotsList(c *gin.Context) { |
| 26 | SortMethodString := c.Request.URL.Query().Get("sort") |
| 27 | |
| 28 | collectionFactory := context.NewCollectionFactory() |
| 29 | collection := collectionFactory.SnapshotCollection() |
| 30 | |
| 31 | if SortMethodString == "" { |
| 32 | SortMethodString = "name" |
| 33 | } |
| 34 | |
| 35 | result := []snapshotResponse{} |
| 36 | err := collection.ForEachSorted(SortMethodString, func(snapshot *deb.Snapshot) error { |
| 37 | err := collection.LoadComplete(snapshot) |
| 38 | if err != nil { |
| 39 | return err |
| 40 | } |
| 41 | |
| 42 | result = append(result, newSnapshotResponse(snapshot)) |
| 43 | return nil |
| 44 | }) |
| 45 | if err != nil { |
| 46 | AbortWithJSONError(c, 500, err) |
| 47 | return |
| 48 | } |
| 49 | |
| 50 | c.JSON(200, result) |
| 51 | } |
| 52 | |
| 53 | type snapshotsCreateFromMirrorParams struct { |
| 54 | // Name of snapshot to create |
nothing calls this directly
no test coverage detected