private/apigen: Reorganize and rename files

Change-Id: I430d620bb0940f2186cb884b00cb5eb9729b9744
This commit is contained in:
Moby von Briesen 2022-05-05 10:03:51 -04:00 committed by Ivan Fraixedes
parent 26f495f717
commit 9fc6484600
3 changed files with 33 additions and 26 deletions

30
private/apigen/common.go Normal file
View File

@ -0,0 +1,30 @@
// Copyright (C) 2022 Storj Labs, Inc.
// See LICENSE for copying information.
package apigen
import (
"storj.io/storj/private/api"
)
// API represents specific API's configuration.
type API struct {
Version string
Description string
PackageName string
Auth api.Auth
EndpointGroups []*EndpointGroup
}
// Group adds new endpoints group to API.
func (a *API) Group(name, prefix string) *EndpointGroup {
group := &EndpointGroup{
Name: name,
Prefix: prefix,
Endpoints: make(map[PathMethod]*Endpoint),
}
a.EndpointGroups = append(a.EndpointGroups, group)
return group
}

View File

@ -17,33 +17,10 @@ import (
"golang.org/x/text/language"
"storj.io/common/uuid"
"storj.io/storj/private/api"
)
// API represents specific API's configuration.
type API struct {
Version string
Description string
PackageName string
Auth api.Auth
EndpointGroups []*EndpointGroup
}
// Group adds new endpoints group to API.
func (a *API) Group(name, prefix string) *EndpointGroup {
group := &EndpointGroup{
Name: name,
Prefix: prefix,
Endpoints: make(map[PathMethod]*Endpoint),
}
a.EndpointGroups = append(a.EndpointGroups, group)
return group
}
// MustWrite writes generated code into a file.
func (a *API) MustWrite(path string) {
// MustWriteGo writes generated Go code into a file.
func (a *API) MustWriteGo(path string) {
generated, err := a.generateGo()
if err != nil {
panic(errs.Wrap(err))

View File

@ -79,5 +79,5 @@ func main() {
})
}
a.MustWrite("satellite/console/consoleweb/consoleapi/api.gen.go")
a.MustWriteGo("satellite/console/consoleweb/consoleapi/api.gen.go")
}