MCPcopy Create free account
hub / github.com/aptly-dev/aptly / apiSnapshotsList

Function apiSnapshotsList

api/snapshot.go:25–51  ·  view source on GitHub ↗

@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)

Source from the content-addressed store, hash-verified

23// @Success 200 {array} snapshotResponse
24// @Router /api/snapshots [get]
25func 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
53type snapshotsCreateFromMirrorParams struct {
54 // Name of snapshot to create

Callers

nothing calls this directly

Calls 8

SnapshotCollectionMethod · 0.95
newSnapshotResponseFunction · 0.85
AbortWithJSONErrorFunction · 0.85
NewCollectionFactoryMethod · 0.80
ForEachSortedMethod · 0.80
GetMethod · 0.65
QueryMethod · 0.65
LoadCompleteMethod · 0.45

Tested by

no test coverage detected