handleDeleteDB when running in persistent config mode, deletes a database config from the bucket and removes it from the current node. In non-persistent mode, the endpoint just removes the database from the node.
()
| 1401 | // handleDeleteDB when running in persistent config mode, deletes a database config from the bucket and removes it from the current node. |
| 1402 | // In non-persistent mode, the endpoint just removes the database from the node. |
| 1403 | func (h *handler) handleDeleteDB() error { |
| 1404 | h.assertAdminOnly() |
| 1405 | dbName := h.PathVar("db") |
| 1406 | |
| 1407 | var bucket string |
| 1408 | |
| 1409 | if h.server.persistentConfig { |
| 1410 | bucket, _ = h.server.bucketNameFromDbName(h.ctx(), dbName) |
| 1411 | err := h.server.BootstrapContext.DeleteConfig(h.ctx(), bucket, h.server.Config.Bootstrap.ConfigGroupID, dbName) |
| 1412 | if err != nil { |
| 1413 | return base.HTTPErrorf(http.StatusInternalServerError, "couldn't remove database %q from bucket %q: %s", base.MD(dbName), base.MD(bucket), err.Error()) |
| 1414 | } |
| 1415 | h.server.RemoveDatabase(h.ctx(), dbName, fmt.Sprintf("called from %s", h.rq.URL)) // unhandled 404 to allow broken config deletion (CBG-2420) |
| 1416 | h.writeRawJSON([]byte("{}")) |
| 1417 | base.Audit(h.ctx(), base.AuditIDDeleteDatabase, nil) |
| 1418 | return nil |
| 1419 | } |
| 1420 | |
| 1421 | if !h.server.RemoveDatabase(h.ctx(), dbName, fmt.Sprintf("called from %s", h.rq.URL)) { |
| 1422 | return base.HTTPErrorf(http.StatusNotFound, "no such database %q", dbName) |
| 1423 | } |
| 1424 | h.writeRawJSON([]byte("{}")) |
| 1425 | base.Audit(h.ctx(), base.AuditIDDeleteDatabase, nil) |
| 1426 | return nil |
| 1427 | } |
| 1428 | |
| 1429 | // handleGetRawDoc returns the raw version of the stored document for diagnostic purposes. |
| 1430 | // It can optionally redact UserData in the sync metadata and allows a custom salt for correlating with collected logs. |
nothing calls this directly
no test coverage detected