2021-12-10 17:15:33 +00:00
|
|
|
// Copyright (C) 2022 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
//go:generate go run ./
|
|
|
|
|
|
|
|
import (
|
2022-02-17 13:49:07 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"storj.io/common/uuid"
|
2021-12-10 17:15:33 +00:00
|
|
|
"storj.io/storj/private/apigen"
|
2022-02-17 13:49:07 +00:00
|
|
|
"storj.io/storj/satellite/accounting"
|
2021-12-10 17:15:33 +00:00
|
|
|
"storj.io/storj/satellite/console"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2022-01-11 13:20:02 +00:00
|
|
|
a := &apigen.API{
|
|
|
|
Version: "v1",
|
|
|
|
Description: "",
|
|
|
|
PackageName: "consoleapi",
|
|
|
|
}
|
2021-12-10 17:15:33 +00:00
|
|
|
|
|
|
|
{
|
2022-01-11 13:20:02 +00:00
|
|
|
g := a.Group("ProjectManagement", "projects")
|
2021-12-10 17:15:33 +00:00
|
|
|
|
|
|
|
g.Get("/", &apigen.Endpoint{
|
2022-01-11 13:20:02 +00:00
|
|
|
Name: "Get Projects",
|
|
|
|
Description: "Gets all projects user has",
|
2022-02-17 13:49:07 +00:00
|
|
|
MethodName: "GenGetUsersProjects",
|
2021-12-10 17:15:33 +00:00
|
|
|
Response: []console.Project{},
|
|
|
|
})
|
2022-01-11 13:20:02 +00:00
|
|
|
|
2022-02-17 13:49:07 +00:00
|
|
|
g.Get("/bucket-rollup", &apigen.Endpoint{
|
apigen: endpoint to get all buckets usage by project ID
Added new endpoint to get all bucket rollups by bucket ID.
Example of response:
vitalii:~/Documents$ ./testapi.sh
HTTP/1.1 200 OK
Content-Type: application/json
Date: Mon, 07 Mar 2022 11:18:55 GMT
Content-Length: 671
[{"projectID":"a9b2b1b6-714a-4c49-99f1-6a53d0852525","bucketName":"demo-bucket","totalStoredData":0.0026272243089674662,"totalSegments":0.05000107166666666,"objectCount":0.03333373083333333,"metadataSize":1.6750359008333334e-9,"repairEgress":0,"getEgress":0,"auditEgress":0,"since":"2022-03-01T11:00:00Z","before":"2022-03-07T11:17:07Z"},{"projectID":"a9b2b1b6-714a-4c49-99f1-6a53d0852525","bucketName":"qwe","totalStoredData":0.000018436725422435552,"totalSegments":0.016667081388888887,"objectCount":0.016667081388888887,"metadataSize":1.933381441111111e-9,"repairEgress":0,"getEgress":0,"auditEgress":0,"since":"2022-03-01T11:00:00Z","before":"2022-03-07T11:17:07Z"}]
Change-Id: I8b04b24dbc67b78be5c309ce542bf03d6f67e65d
2022-03-07 11:20:28 +00:00
|
|
|
Name: "Get Project's Single Bucket Usage",
|
|
|
|
Description: "Gets project's single bucket usage by bucket ID",
|
2022-02-17 13:49:07 +00:00
|
|
|
MethodName: "GenGetSingleBucketUsageRollup",
|
|
|
|
Response: &accounting.BucketUsageRollup{},
|
|
|
|
Params: []apigen.Param{
|
|
|
|
apigen.NewParam("projectID", uuid.UUID{}),
|
|
|
|
apigen.NewParam("bucket", ""),
|
|
|
|
apigen.NewParam("since", time.Time{}),
|
|
|
|
apigen.NewParam("before", time.Time{}),
|
|
|
|
},
|
|
|
|
})
|
apigen: endpoint to get all buckets usage by project ID
Added new endpoint to get all bucket rollups by bucket ID.
Example of response:
vitalii:~/Documents$ ./testapi.sh
HTTP/1.1 200 OK
Content-Type: application/json
Date: Mon, 07 Mar 2022 11:18:55 GMT
Content-Length: 671
[{"projectID":"a9b2b1b6-714a-4c49-99f1-6a53d0852525","bucketName":"demo-bucket","totalStoredData":0.0026272243089674662,"totalSegments":0.05000107166666666,"objectCount":0.03333373083333333,"metadataSize":1.6750359008333334e-9,"repairEgress":0,"getEgress":0,"auditEgress":0,"since":"2022-03-01T11:00:00Z","before":"2022-03-07T11:17:07Z"},{"projectID":"a9b2b1b6-714a-4c49-99f1-6a53d0852525","bucketName":"qwe","totalStoredData":0.000018436725422435552,"totalSegments":0.016667081388888887,"objectCount":0.016667081388888887,"metadataSize":1.933381441111111e-9,"repairEgress":0,"getEgress":0,"auditEgress":0,"since":"2022-03-01T11:00:00Z","before":"2022-03-07T11:17:07Z"}]
Change-Id: I8b04b24dbc67b78be5c309ce542bf03d6f67e65d
2022-03-07 11:20:28 +00:00
|
|
|
|
|
|
|
g.Get("/bucket-rollups", &apigen.Endpoint{
|
|
|
|
Name: "Get Project's All Buckets Usage",
|
|
|
|
Description: "Gets project's all buckets usage",
|
|
|
|
MethodName: "GenGetBucketUsageRollups",
|
|
|
|
Response: []accounting.BucketUsageRollup{},
|
|
|
|
Params: []apigen.Param{
|
|
|
|
apigen.NewParam("projectID", uuid.UUID{}),
|
|
|
|
apigen.NewParam("since", time.Time{}),
|
|
|
|
apigen.NewParam("before", time.Time{}),
|
|
|
|
},
|
|
|
|
})
|
2021-12-10 17:15:33 +00:00
|
|
|
}
|
2022-01-11 13:20:02 +00:00
|
|
|
|
2022-02-11 15:06:52 +00:00
|
|
|
a.MustWrite("satellite/console/consoleweb/consoleapi/api.gen.go")
|
2021-12-10 17:15:33 +00:00
|
|
|
}
|