aboutsummaryrefslogtreecommitdiffstats
path: root/golang
diff options
context:
space:
mode:
Diffstat (limited to 'golang')
-rw-r--r--golang/api/handlers/editing.go104
-rw-r--r--golang/api/handlers/entities.go13
-rw-r--r--golang/cmd/fatcatd/serve.go29
-rw-r--r--golang/gen/models/release_entity.go136
-rw-r--r--golang/gen/restapi/configure_fatcat.go20
-rw-r--r--golang/gen/restapi/embedded_spec.go106
6 files changed, 407 insertions, 1 deletions
diff --git a/golang/api/handlers/editing.go b/golang/api/handlers/editing.go
new file mode 100644
index 00000000..b0c006cb
--- /dev/null
+++ b/golang/api/handlers/editing.go
@@ -0,0 +1,104 @@
+
+package handlers
+
+import (
+ "github.com/go-pg/pg"
+ //"github.com/go-openapi/swag"
+ "github.com/go-openapi/runtime/middleware"
+ //log "github.com/sirupsen/logrus"
+
+ //"git.archive.org/bnewbold/fatcat/golang/gen/models"
+ "git.archive.org/bnewbold/fatcat/golang/gen/restapi/operations"
+)
+
+type Editor struct {
+ Id int64
+ Username string
+ IsAdmin bool
+ ActiveEditgroupId int64
+ ActiveEditgroup *Editgroup
+}
+
+type Editgroup struct {
+ Id int64
+ ExtraJson string
+ EditorId int64
+ Editor *Editor
+ Description string
+}
+
+type Changelog struct {
+ Id int64
+ EditgroupId int64
+ Editgroup *Editgroup
+ Timestamp string // XXX: timestamp
+}
+
+func GetOrCreateEditgroup() Editgroup {
+ // XXX
+ eg := Editgroup{}
+ return eg
+}
+
+func NewGetEditorUsernameHandler(db *pg.DB) operations.GetEditorUsernameHandler {
+ return &getEditorUsername{db: db}
+}
+type getEditorUsername struct {
+ db *pg.DB
+}
+func (d *getEditorUsername) Handle(params operations.GetEditorUsernameParams) middleware.Responder {
+ return middleware.NotImplemented("operation .PostCreatorID has not yet been implemented")
+}
+
+
+func NewGetEditorUsernameChangelogHandler(db *pg.DB) operations.GetEditorUsernameChangelogHandler {
+ return &getEditorUsernameChangelog{db: db}
+}
+type getEditorUsernameChangelog struct {
+ db *pg.DB
+}
+func (d *getEditorUsernameChangelog) Handle(params operations.GetEditorUsernameChangelogParams) middleware.Responder {
+ return middleware.NotImplemented("operation .PostCreatorID has not yet been implemented")
+}
+
+func NewGetEditgroupIDHandler(db *pg.DB) operations.GetEditgroupIDHandler {
+ return &getEditgroupID{db: db}
+}
+type getEditgroupID struct {
+ db *pg.DB
+}
+func (d *getEditgroupID) Handle(params operations.GetEditgroupIDParams) middleware.Responder {
+ return middleware.NotImplemented("operation .PostCreatorID has not yet been implemented")
+}
+
+/*
+func NewGetEditgroupIDHandler(db *pg.DB) operations.GetEditgroupIDHandler {
+ return &getEditgroupID{db: db}
+}
+type getCreatorID struct {
+ db *pg.DB
+}
+func (d *getCreatorID) Handle(params operations.GetEditgroupIDParams) middleware.Responder {
+ return middleware.NotImplemented("operation .PostCreatorID has not yet been implemented")
+}
+*/
+
+func NewPostEditgroupHandler(db *pg.DB) operations.PostEditgroupHandler {
+ return &postEditgroup{db: db}
+}
+type postEditgroup struct {
+ db *pg.DB
+}
+func (d *postEditgroup) Handle(params operations.PostEditgroupParams) middleware.Responder {
+ return middleware.NotImplemented("operation .PostEditgroupID has not yet been implemented")
+}
+
+func NewPostEditgroupIDAcceptHandler(db *pg.DB) operations.PostEditgroupIDAcceptHandler {
+ return &postEditgroupIDAccept{db: db}
+}
+type postEditgroupIDAccept struct {
+ db *pg.DB
+}
+func (d *postEditgroupIDAccept) Handle(params operations.PostEditgroupIDAcceptParams) middleware.Responder {
+ return middleware.NotImplemented("operation .PostEditgroupIDAcceptID has not yet been implemented")
+}
diff --git a/golang/api/handlers/entities.go b/golang/api/handlers/entities.go
index beed633a..a2fb7db8 100644
--- a/golang/api/handlers/entities.go
+++ b/golang/api/handlers/entities.go
@@ -75,6 +75,19 @@ func (d *getCreatorID) Handle(params operations.GetCreatorIDParams) middleware.R
return operations.NewGetCreatorIDOK().WithPayload(api_entity)
}
+func NewGetCreatorLookupHandler(db *pg.DB) operations.GetCreatorLookupHandler {
+ return &getCreatorLookup{db: db}
+}
+
+type getCreatorLookup struct {
+ db *pg.DB
+}
+
+func (d *getCreatorLookup) Handle(params operations.GetCreatorLookupParams) middleware.Responder {
+ // get-or-create editgroup based on current editor (session)
+ // insert new rev, ident, and edit
+ return middleware.NotImplemented("operation .GetCreatorLookup has not yet been implemented")
+}
func NewPostCreatorHandler(db *pg.DB) operations.PostCreatorHandler {
return &postCreator{db: db}
diff --git a/golang/cmd/fatcatd/serve.go b/golang/cmd/fatcatd/serve.go
index 638fe6ce..6f44e009 100644
--- a/golang/cmd/fatcatd/serve.go
+++ b/golang/cmd/fatcatd/serve.go
@@ -57,6 +57,35 @@ func main_serve() {
// register all the many handlers here
api.GetCreatorIDHandler = handlers.NewGetCreatorIDHandler(db);
api.PostCreatorHandler = handlers.NewPostCreatorHandler(db);
+ api.GetCreatorLookupHandler = handlers.NewGetCreatorLookupHandler(db);
+/*
+ api.GetCreatorLookupHandler = operations.GetCreatorLookupHandlerFunc(func(params operations.GetCreatorLookupParams) middleware.Responder {
+ return middleware.NotImplemented("operation .GetCreatorLookup has not yet been implemented")
+ })
+*/
+
+ api.GetEditgroupIDHandler = handlers.NewGetEditgroupIDHandler(db);
+ api.GetEditorUsernameHandler = handlers.NewGetEditorUsernameHandler(db);
+ api.GetEditorUsernameChangelogHandler = handlers.NewGetEditorUsernameChangelogHandler(db);
+ api.PostEditgroupHandler = handlers.NewPostEditgroupHandler(db);
+ api.PostEditgroupIDAcceptHandler = handlers.NewPostEditgroupIDAcceptHandler(db);
+/*
+ api.GetEditgroupIDHandler = operations.GetEditgroupIDHandlerFunc(func(params operations.GetEditgroupIDParams) middleware.Responder {
+ return middleware.NotImplemented("operation .GetEditgroupID has not yet been implemented")
+ })
+ api.GetEditorUsernameHandler = operations.GetEditorUsernameHandlerFunc(func(params operations.GetEditorUsernameParams) middleware.Responder {
+ return middleware.NotImplemented("operation .GetEditorUsername has not yet been implemented")
+ })
+ api.GetEditorUsernameChangelogHandler = operations.GetEditorUsernameChangelogHandlerFunc(func(params operations.GetEditorUsernameChangelogParams) middleware.Responder {
+ return middleware.NotImplemented("operation .GetEditorUsernameChangelog has not yet been implemented")
+ })
+ api.PostEditgroupHandler = operations.PostEditgroupHandlerFunc(func(params operations.PostEditgroupParams) middleware.Responder {
+ return middleware.NotImplemented("operation .PostEditgroup has not yet been implemented")
+ })
+ api.PostEditgroupIDAcceptHandler = operations.PostEditgroupIDAcceptHandlerFunc(func(params operations.PostEditgroupIDAcceptParams) middleware.Responder {
+ return middleware.NotImplemented("operation .PostEditgroupIDAccept has not yet been implemented")
+ })
+*/
middle := interpose.New()
diff --git a/golang/gen/models/release_entity.go b/golang/gen/models/release_entity.go
new file mode 100644
index 00000000..fa6a345c
--- /dev/null
+++ b/golang/gen/models/release_entity.go
@@ -0,0 +1,136 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+package models
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+import (
+ "encoding/json"
+
+ strfmt "github.com/go-openapi/strfmt"
+
+ "github.com/go-openapi/errors"
+ "github.com/go-openapi/swag"
+ "github.com/go-openapi/validate"
+)
+
+// ReleaseEntity release entity
+// swagger:model release_entity
+type ReleaseEntity struct {
+
+ // ident
+ // Required: true
+ Ident *string `json:"ident"`
+
+ // name
+ Name string `json:"name,omitempty"`
+
+ // orcid
+ Orcid string `json:"orcid,omitempty"`
+
+ // redirect
+ Redirect string `json:"redirect,omitempty"`
+
+ // revision
+ Revision int64 `json:"revision,omitempty"`
+
+ // state
+ // Required: true
+ // Enum: [wip active redirect deleted]
+ State *string `json:"state"`
+}
+
+// Validate validates this release entity
+func (m *ReleaseEntity) Validate(formats strfmt.Registry) error {
+ var res []error
+
+ if err := m.validateIdent(formats); err != nil {
+ res = append(res, err)
+ }
+
+ if err := m.validateState(formats); err != nil {
+ res = append(res, err)
+ }
+
+ if len(res) > 0 {
+ return errors.CompositeValidationError(res...)
+ }
+ return nil
+}
+
+func (m *ReleaseEntity) validateIdent(formats strfmt.Registry) error {
+
+ if err := validate.Required("ident", "body", m.Ident); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+var releaseEntityTypeStatePropEnum []interface{}
+
+func init() {
+ var res []string
+ if err := json.Unmarshal([]byte(`["wip","active","redirect","deleted"]`), &res); err != nil {
+ panic(err)
+ }
+ for _, v := range res {
+ releaseEntityTypeStatePropEnum = append(releaseEntityTypeStatePropEnum, v)
+ }
+}
+
+const (
+
+ // ReleaseEntityStateWip captures enum value "wip"
+ ReleaseEntityStateWip string = "wip"
+
+ // ReleaseEntityStateActive captures enum value "active"
+ ReleaseEntityStateActive string = "active"
+
+ // ReleaseEntityStateRedirect captures enum value "redirect"
+ ReleaseEntityStateRedirect string = "redirect"
+
+ // ReleaseEntityStateDeleted captures enum value "deleted"
+ ReleaseEntityStateDeleted string = "deleted"
+)
+
+// prop value enum
+func (m *ReleaseEntity) validateStateEnum(path, location string, value string) error {
+ if err := validate.Enum(path, location, value, releaseEntityTypeStatePropEnum); err != nil {
+ return err
+ }
+ return nil
+}
+
+func (m *ReleaseEntity) validateState(formats strfmt.Registry) error {
+
+ if err := validate.Required("state", "body", m.State); err != nil {
+ return err
+ }
+
+ // value enum
+ if err := m.validateStateEnum("state", "body", *m.State); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+// MarshalBinary interface implementation
+func (m *ReleaseEntity) MarshalBinary() ([]byte, error) {
+ if m == nil {
+ return nil, nil
+ }
+ return swag.WriteJSON(m)
+}
+
+// UnmarshalBinary interface implementation
+func (m *ReleaseEntity) UnmarshalBinary(b []byte) error {
+ var res ReleaseEntity
+ if err := swag.ReadJSON(b, &res); err != nil {
+ return err
+ }
+ *m = res
+ return nil
+}
diff --git a/golang/gen/restapi/configure_fatcat.go b/golang/gen/restapi/configure_fatcat.go
index 94e7f3e2..e101a019 100644
--- a/golang/gen/restapi/configure_fatcat.go
+++ b/golang/gen/restapi/configure_fatcat.go
@@ -14,7 +14,7 @@ import (
"git.archive.org/bnewbold/fatcat/golang/gen/restapi/operations"
)
-//go:generate swagger generate server --target ../gen --name fatcat --spec ../fatcat-openapi2.yml --exclude-main
+//go:generate swagger generate server --target ../gen --name fatcat --spec ../fatcat-openapi2.json --exclude-main
func configureFlags(api *operations.FatcatAPI) {
// api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... }
@@ -37,9 +37,27 @@ func configureAPI(api *operations.FatcatAPI) http.Handler {
api.GetCreatorIDHandler = operations.GetCreatorIDHandlerFunc(func(params operations.GetCreatorIDParams) middleware.Responder {
return middleware.NotImplemented("operation .GetCreatorID has not yet been implemented")
})
+ api.GetCreatorLookupHandler = operations.GetCreatorLookupHandlerFunc(func(params operations.GetCreatorLookupParams) middleware.Responder {
+ return middleware.NotImplemented("operation .GetCreatorLookup has not yet been implemented")
+ })
+ api.GetEditgroupIDHandler = operations.GetEditgroupIDHandlerFunc(func(params operations.GetEditgroupIDParams) middleware.Responder {
+ return middleware.NotImplemented("operation .GetEditgroupID has not yet been implemented")
+ })
+ api.GetEditorUsernameHandler = operations.GetEditorUsernameHandlerFunc(func(params operations.GetEditorUsernameParams) middleware.Responder {
+ return middleware.NotImplemented("operation .GetEditorUsername has not yet been implemented")
+ })
+ api.GetEditorUsernameChangelogHandler = operations.GetEditorUsernameChangelogHandlerFunc(func(params operations.GetEditorUsernameChangelogParams) middleware.Responder {
+ return middleware.NotImplemented("operation .GetEditorUsernameChangelog has not yet been implemented")
+ })
api.PostCreatorHandler = operations.PostCreatorHandlerFunc(func(params operations.PostCreatorParams) middleware.Responder {
return middleware.NotImplemented("operation .PostCreator has not yet been implemented")
})
+ api.PostEditgroupHandler = operations.PostEditgroupHandlerFunc(func(params operations.PostEditgroupParams) middleware.Responder {
+ return middleware.NotImplemented("operation .PostEditgroup has not yet been implemented")
+ })
+ api.PostEditgroupIDAcceptHandler = operations.PostEditgroupIDAcceptHandlerFunc(func(params operations.PostEditgroupIDAcceptParams) middleware.Responder {
+ return middleware.NotImplemented("operation .PostEditgroupIDAccept has not yet been implemented")
+ })
api.ServerShutdown = func() {}
diff --git a/golang/gen/restapi/embedded_spec.go b/golang/gen/restapi/embedded_spec.go
index 32753475..8e2a9ac4 100644
--- a/golang/gen/restapi/embedded_spec.go
+++ b/golang/gen/restapi/embedded_spec.go
@@ -382,6 +382,39 @@ func init() {
}
}
},
+ "release_entity": {
+ "type": "object",
+ "required": [
+ "ident",
+ "state"
+ ],
+ "properties": {
+ "ident": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "orcid": {
+ "type": "string"
+ },
+ "redirect": {
+ "type": "string"
+ },
+ "revision": {
+ "type": "integer"
+ },
+ "state": {
+ "type": "string",
+ "enum": [
+ "wip",
+ "active",
+ "redirect",
+ "deleted"
+ ]
+ }
+ }
+ },
"success": {
"type": "object",
"required": [
@@ -393,6 +426,26 @@ func init() {
}
}
}
+ },
+ "x-entity-props": {
+ "ident": {
+ "type": "string"
+ },
+ "redirect": {
+ "type": "string"
+ },
+ "revision": {
+ "type": "integer"
+ },
+ "state": {
+ "enum": [
+ "wip",
+ "active",
+ "redirect",
+ "deleted"
+ ],
+ "type": "string"
+ }
}
}`))
FlatSwaggerJSON = json.RawMessage([]byte(`{
@@ -760,6 +813,39 @@ func init() {
}
}
},
+ "release_entity": {
+ "type": "object",
+ "required": [
+ "ident",
+ "state"
+ ],
+ "properties": {
+ "ident": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "orcid": {
+ "type": "string"
+ },
+ "redirect": {
+ "type": "string"
+ },
+ "revision": {
+ "type": "integer"
+ },
+ "state": {
+ "type": "string",
+ "enum": [
+ "wip",
+ "active",
+ "redirect",
+ "deleted"
+ ]
+ }
+ }
+ },
"success": {
"type": "object",
"required": [
@@ -771,6 +857,26 @@ func init() {
}
}
}
+ },
+ "x-entity-props": {
+ "ident": {
+ "type": "string"
+ },
+ "redirect": {
+ "type": "string"
+ },
+ "revision": {
+ "type": "integer"
+ },
+ "state": {
+ "enum": [
+ "wip",
+ "active",
+ "redirect",
+ "deleted"
+ ],
+ "type": "string"
+ }
}
}`))
}