35 lines
943 B
Go
35 lines
943 B
Go
package apihandler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.agecem.com/agecem/agecem-org/apiresponse"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
// V1SeedPOST créé des buckets dans minio selon la liste de buckets dans server.documents.buckets
|
|
// Les buckets sont créés avec paramètres par défaut, et sont ensuite visible dans /v1/bucket.
|
|
func (h *V1Handler) V1SeedPOST(c echo.Context) error {
|
|
var response apiresponse.V1SeedPOST
|
|
|
|
new_buckets, err := h.MediaClient.Seed()
|
|
response.Data.Buckets = new_buckets
|
|
if err != nil {
|
|
response.SetStatusCode(http.StatusInternalServerError)
|
|
response.Message = "Error during mediaClient.Seed()"
|
|
response.Error = err.Error()
|
|
|
|
return c.JSON(response.StatusCode(), response)
|
|
}
|
|
|
|
if len(new_buckets) == 0 {
|
|
response.Message = "All buckets already exist"
|
|
|
|
} else {
|
|
response.Message = "Buckets successfully created"
|
|
}
|
|
|
|
response.SetStatusCode(http.StatusOK)
|
|
|
|
return c.JSON(response.StatusCode(), response)
|
|
}
|