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)
| 174 | // "500": |
| 175 | // $ref: "#/responses/InternalServerError" |
| 176 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…