aboutsummaryrefslogtreecommitdiff
path: root/website.go
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2023-09-25 23:00:57 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2023-09-25 23:00:57 +0200
commit982bd8a43c50bb5845b694dbd0b3e0ffbf43dad7 (patch)
treea0b711018858b8daf918c9f066562a6f9afc04f8 /website.go
parent08287375736a0a57c03b4bd6d9c222dc5567db6e (diff)
downloadguichet-982bd8a43c50bb5845b694dbd0b3e0ffbf43dad7.tar.gz
guichet-982bd8a43c50bb5845b694dbd0b3e0ffbf43dad7.zip
done with APIapi
Diffstat (limited to 'website.go')
-rw-r--r--website.go33
1 files changed, 19 insertions, 14 deletions
diff --git a/website.go b/website.go
index 6e86b19..7e89a41 100644
--- a/website.go
+++ b/website.go
@@ -22,11 +22,11 @@ var (
type WebsiteId struct {
- Pretty string
- Internal string
- Alt []string
- Expanded bool
- Url string
+ Pretty string `json:"name"`
+ Internal string `json:"-"`
+ Alt []string `json:"alt_name"`
+ Expanded bool `json:"expanded"`
+ Url string `json:"domain"`
}
func NewWebsiteId(id string, aliases []string) *WebsiteId {
@@ -50,7 +50,7 @@ func NewWebsiteIdFromBucketInfo(binfo *garage.BucketInfo) *WebsiteId {
}
type WebsiteController struct {
- User *LoggedUser
+ User *LoggedUser
WebsiteIdx map[string]*WebsiteId
PrettyList []string
WebsiteCount QuotaStat
@@ -80,12 +80,17 @@ func NewWebsiteController(user *LoggedUser) (*WebsiteController, error) {
return &WebsiteController { user, idx, wlist, quota }, nil
}
-func (w *WebsiteController) List() []*WebsiteId {
+type WebsiteDescribe struct {
+ AllowedWebsites *QuotaStat `json:"quota"`
+ Websites []*WebsiteId `json:"vhosts"`
+}
+
+func (w *WebsiteController) Describe() *WebsiteDescribe {
r := make([]*WebsiteId, 0, len(w.PrettyList))
for _, k := range w.PrettyList {
r = append(r, w.WebsiteIdx[k])
}
- return r
+ return &WebsiteDescribe { &w.WebsiteCount, r }
}
func (w *WebsiteController) Inspect(pretty string) (*WebsiteView, error) {
@@ -117,8 +122,8 @@ func (w *WebsiteController) Patch(pretty string, patch *WebsitePatch) (*WebsiteV
urQuota := garage.NewUpdateBucketRequestQuotas()
urQuota.SetMaxSize(w.User.Quota.WebsiteSizeAdjust(binfo.Quotas.GetMaxSize()))
urQuota.SetMaxObjects(w.User.Quota.WebsiteObjectAdjust(binfo.Quotas.GetMaxObjects()))
- if patch.size != nil {
- urQuota.SetMaxSize(w.User.Quota.WebsiteSizeAdjust(*patch.size))
+ if patch.Size != nil {
+ urQuota.SetMaxSize(w.User.Quota.WebsiteSizeAdjust(*patch.Size))
}
// Build the update
@@ -205,9 +210,9 @@ func (w *WebsiteController) Delete(pretty string) error {
type WebsiteView struct {
- Name *WebsiteId
- Size QuotaStat
- Files QuotaStat
+ Name *WebsiteId `json:"identified_as"`
+ Size QuotaStat `json:"quota_size"`
+ Files QuotaStat `json:"quota_files"`
}
func NewWebsiteView(binfo *garage.BucketInfo) *WebsiteView {
@@ -220,5 +225,5 @@ func NewWebsiteView(binfo *garage.BucketInfo) *WebsiteView {
}
type WebsitePatch struct {
- size *int64
+ Size *int64 `json:"quota_size"`
}