MCPcopy
hub / github.com/lxc/incus / storagePoolBucketBackupsGet

Function storagePoolBucketBackupsGet

cmd/incusd/storage_buckets_backup.go:176–252  ·  view source on GitHub ↗

swagger:operation GET /1.0/storage-pools/{poolName}/buckets/{bucketName}/backups storage storage_pool_buckets_backups_get Get the storage bucket backups Returns a list of storage bucket backups (URLs). --- produces: - application/json parameters: - in: path name: poolName description: Storage poo

(d *Daemon, r *http.Request)

Source from the content-addressed store, hash-verified

174// "500":
175// $ref: "#/responses/InternalServerError"
176func storagePoolBucketBackupsGet(d *Daemon, r *http.Request) response.Response {
177 s := d.State()
178
179 resp := forwardedResponseIfTargetIsRemote(s, r)
180 if resp != nil {
181 return resp
182 }
183
184 projectName, err := project.StorageBucketProject(r.Context(), s.DB.Cluster, request.ProjectParam(r))
185 if err != nil {
186 return response.SmartError(err)
187 }
188
189 // Get the name of the storage bucket.
190 bucketName, err := pathVar(r, "bucketName")
191 if err != nil {
192 return response.SmartError(err)
193 }
194
195 // Get the name of the storage pool the bucket is supposed to be attached to.
196 poolName, err := pathVar(r, "poolName")
197 if err != nil {
198 return response.SmartError(err)
199 }
200
201 // Get the storage pool itself.
202 var poolID int64
203
204 err = s.DB.Cluster.Transaction(r.Context(), func(ctx context.Context, tx *db.ClusterTx) error {
205 var err error
206
207 poolID, _, _, err = tx.GetStoragePool(ctx, poolName)
208
209 return err
210 })
211 if err != nil {
212 return response.SmartError(err)
213 }
214
215 // Handle the request.
216 recursion := localUtil.IsRecursionRequest(r)
217
218 var bucketBackups []db.StoragePoolBucketBackup
219
220 err = s.DB.Cluster.Transaction(r.Context(), func(ctx context.Context, tx *db.ClusterTx) error {
221 bucketBackups, err = tx.GetStoragePoolBucketBackups(ctx, projectName, bucketName, poolID)
222 return err
223 })
224 if err != nil {
225 return response.SmartError(err)
226 }
227
228 backups := make([]*backup.BucketBackup, len(bucketBackups))
229
230 for i, b := range bucketBackups {
231 _, backupName, _ := api.GetParentAndSnapshotName(b.Name)
232 backups[i] = backup.NewBucketBackup(s, projectName, poolName, bucketName, b.ID, backupName, b.CreationDate, b.ExpiryDate)
233 }

Callers

nothing calls this directly

Calls 15

StorageBucketProjectFunction · 0.92
ProjectParamFunction · 0.92
SmartErrorFunction · 0.92
GetParentAndSnapshotNameFunction · 0.92
NewBucketBackupFunction · 0.92
NewURLFunction · 0.92
SyncResponseFunction · 0.92
pathVarFunction · 0.85
ContextMethod · 0.80
SplitMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…