feat: implemented service/transport/main layers

This commit is contained in:
Anatoly Antonov 2025-06-21 22:06:32 +03:00
parent 5158c5d7c9
commit bcb9ace54c
29 changed files with 804 additions and 393 deletions

View file

@ -14,7 +14,7 @@ paths:
name: parameters name: parameters
required: false required: false
schema: schema:
$ref: '#/components/schemas/Prediction/Parameters' $ref: '#/components/schemas/PredictionParameters'
style: form style: form
explode: true explode: true
requestBody: requestBody:
@ -22,14 +22,14 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/Prediction/Parameters' $ref: '#/components/schemas/PredictionParameters'
responses: responses:
"200": "200":
description: "Prediction response" description: "Prediction response"
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/Prediction/Result' $ref: '#/components/schemas/PredictionResult'
default: default:
description: Error description: Error
content: content:
@ -48,8 +48,7 @@ components:
type: string type: string
details: details:
type: string type: string
Prediction: PredictionParameters:
Parameters:
type: object type: object
properties: properties:
launch_latitude: # TODO: altitude not required with fallback to https://github.com/priyeshpatel/ruaumoko Go analog launch_latitude: # TODO: altitude not required with fallback to https://github.com/priyeshpatel/ruaumoko Go analog
@ -91,7 +90,7 @@ components:
dataset: dataset:
type: string type: string
format: date-time format: date-time
Result: # PredictionResult:
type: object type: object
required: required:
- metadata - metadata

41
cmd/api/main.go Normal file
View file

@ -0,0 +1,41 @@
package main
import (
"git.intra.yksa.space/gsn/predictor/internal/service"
"git.intra.yksa.space/gsn/predictor/internal/transport/rest"
"git.intra.yksa.space/gsn/predictor/internal/transport/rest/handler"
"go.uber.org/zap"
)
const (
servicePrefix = "PREDICTOR"
)
func main() {
lg, err := zap.NewProduction()
if err != nil {
panic(err)
}
svc := service.New()
handler := handler.New(svc)
restConfig, err := rest.NewConfig(servicePrefix)
if err != nil {
lg.Fatal("failed to init transport config", zap.Error(err))
}
transport, err := rest.New(lg, handler, restConfig)
if err != nil {
lg.Fatal("failed to init transport", zap.Error(err))
}
for {
transport.Run()
if r := recover(); r != nil {
lg.Error("panic occured", zap.Any("recover", r))
}
}
}

32
go.mod
View file

@ -1,3 +1,35 @@
module git.intra.yksa.space/gsn/predictor module git.intra.yksa.space/gsn/predictor
go 1.24.4 go 1.24.4
require (
github.com/caarlos0/env/v11 v11.3.1
github.com/go-faster/errors v0.7.1
github.com/go-faster/jx v1.1.0
github.com/ogen-go/ogen v1.14.0
go.opentelemetry.io/otel v1.36.0
go.opentelemetry.io/otel/metric v1.36.0
go.opentelemetry.io/otel/trace v1.36.0
go.uber.org/zap v1.27.0
)
require (
github.com/dlclark/regexp2 v1.11.5 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-faster/yaml v0.4.6 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/segmentio/asm v1.2.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 // indirect
golang.org/x/net v0.40.0 // indirect
golang.org/x/sync v0.14.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.25.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

77
go.sum Normal file
View file

@ -0,0 +1,77 @@
github.com/caarlos0/env/v11 v11.3.1 h1:cArPWC15hWmEt+gWk7YBi7lEXTXCvpaSdCiZE2X5mCA=
github.com/caarlos0/env/v11 v11.3.1/go.mod h1:qupehSf/Y0TUTsxKywqRt/vJjN5nz6vauiYEUUr8P4U=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=
github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-faster/errors v0.7.1 h1:MkJTnDoEdi9pDabt1dpWf7AA8/BaSYZqibYyhZ20AYg=
github.com/go-faster/errors v0.7.1/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7FPGZP2quo=
github.com/go-faster/jx v1.1.0 h1:ZsW3wD+snOdmTDy9eIVgQdjUpXRRV4rqW8NS3t+20bg=
github.com/go-faster/jx v1.1.0/go.mod h1:vKDNikrKoyUmpzaJ0OkIkRQClNHFX/nF3dnTJZb3skg=
github.com/go-faster/yaml v0.4.6 h1:lOK/EhI04gCpPgPhgt0bChS6bvw7G3WwI8xxVe0sw9I=
github.com/go-faster/yaml v0.4.6/go.mod h1:390dRIvV4zbnO7qC9FGo6YYutc+wyyUSHBgbXL52eXk=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/ogen-go/ogen v1.14.0 h1:TU1Nj4z9UBsAfTkf+IhuNNp7igdFQKqkk9+6/y4XuWg=
github.com/ogen-go/ogen v1.14.0/go.mod h1:Iw1vkqkx6SU7I9th5ceP+fVPJ6Wge4e3kAVzAxJEpPE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg=
go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E=
go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE=
go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs=
go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w=
go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 h1:Di6/M8l0O2lCLc6VVRWhgCiApHV8MnQurBnFSHsQtNY=
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View file

@ -0,0 +1,7 @@
package ds
type PredictionParameters struct {
}
type PredicitonResult struct {
}

View file

@ -0,0 +1,25 @@
package errcodes
import (
"strings"
)
type ErrorCode struct {
StatusCode int
Message string
Details string
}
var errorCodeCounter int32
func New(statusCode int, message string, details ...string) *ErrorCode {
return &ErrorCode{
StatusCode: statusCode,
Message: message,
Details: strings.Join(details, " "),
}
}
func (e *ErrorCode) Error() string {
return e.Message
}

23
internal/pkg/log/log.go Normal file
View file

@ -0,0 +1,23 @@
package log
import (
"context"
"go.uber.org/zap"
)
type ctxLogKey struct{}
func ToCtx(ctx context.Context, lg *zap.Logger) context.Context {
return context.WithValue(ctx, ctxLogKey{}, lg)
}
func Ctx(ctx context.Context) *zap.Logger {
lg, ok := ctx.Value(ctxLogKey{}).(*zap.Logger)
if !ok || lg == nil {
zap.L().Error("no logger in context, using global")
return zap.L()
}
return lg
}

16
internal/service/deps.go Normal file
View file

@ -0,0 +1,16 @@
package service
import (
"context"
"time"
)
type Redis interface {
Lock(ctx context.Context, key string, ttl time.Duration) (func(context.Context), error)
Set(key string, value []byte, ttl time.Duration) error
Get(key string) ([]byte, error)
}
type Downloader interface {
Download(ctx context.Context)
}

View file

@ -0,0 +1,13 @@
package service
import (
"context"
"net/http"
"git.intra.yksa.space/gsn/predictor/internal/pkg/ds"
"git.intra.yksa.space/gsn/predictor/internal/pkg/errcodes"
)
func (s *Service) PerformPrediction(ctx context.Context, params ds.PredictionParameters) ([]ds.PredicitonResult, error) {
return nil, errcodes.New(http.StatusNotImplemented, "not implemented", "please wait")
}

View file

@ -0,0 +1,10 @@
package service
type Service struct {
redis Redis
downloader Downloader
}
func New() *Service {
return &Service{}
}

View file

@ -0,0 +1,44 @@
package middleware
import (
"time"
"git.intra.yksa.space/gsn/predictor/internal/pkg/errcodes"
"git.intra.yksa.space/gsn/predictor/internal/pkg/log"
"github.com/ogen-go/ogen/middleware"
"go.uber.org/zap"
)
func Logging(logger *zap.Logger) middleware.Middleware {
return func(req middleware.Request, next func(req middleware.Request) (middleware.Response, error)) (middleware.Response, error) {
lg := logger.With(
zap.String("operationId", req.OperationID),
)
lg.Info("started request")
req.Context = log.ToCtx(req.Context, lg)
start := time.Now()
resp, err := next(req)
dur := time.Since(start).Microseconds()
if err != nil {
if errcode, ok := err.(*errcodes.ErrorCode); ok {
lg.Error("request error",
zap.Int("status_code", errcode.StatusCode),
zap.String("message", errcode.Message),
zap.String("details", errcode.Details),
)
} else {
lg.Error("request internal error",
zap.Error(err),
)
}
}
lg.Info("done request", zap.Float64("duration_ms", float64(dur)/float64(1000)))
return resp, err
}
}

View file

@ -0,0 +1,23 @@
package rest
import (
"fmt"
env "github.com/caarlos0/env/v11"
)
type Config struct {
Port int `env:"PORT" envDefault:"8080"`
}
func NewConfig(servicePrefix string) (*Config, error) {
cfg := &Config{}
if err := env.ParseWithOptions(cfg, env.Options{
PrefixTagName: fmt.Sprintf("%s_REST_", servicePrefix),
}); err != nil {
return nil, err
}
return cfg, nil
}

View file

@ -0,0 +1,11 @@
package handler
import (
"context"
"git.intra.yksa.space/gsn/predictor/internal/pkg/ds"
)
type Service interface {
PerformPrediction(ctx context.Context, params ds.PredictionParameters) ([]ds.PredicitonResult, error)
}

View file

@ -0,0 +1,52 @@
package handler
import (
"context"
"net/http"
"git.intra.yksa.space/gsn/predictor/internal/pkg/errcodes"
api "git.intra.yksa.space/gsn/predictor/pkg/rest"
)
var (
_ api.Handler = (*Handler)(nil)
)
type Handler struct {
svc Service
}
func New(svc Service) *Handler {
return &Handler{
svc: svc,
}
}
func (h *Handler) PerformPrediction(ctx context.Context, req api.OptPredictionParameters, params api.PerformPredictionParams) (*api.PredictionResult, error) {
return nil, errcodes.New(http.StatusNotImplemented, "not implemented", "please wait")
}
func (h *Handler) NewError(ctx context.Context, err error) *api.ErrorStatusCode {
if errcode, ok := err.(*errcodes.ErrorCode); ok {
resp := api.Error{
Message: errcode.Message,
}
if errcode.Details != "" {
resp.Details = api.NewOptString(errcode.Details)
}
return &api.ErrorStatusCode{
StatusCode: errcode.StatusCode,
Response: resp,
}
}
return &api.ErrorStatusCode{
StatusCode: http.StatusInternalServerError,
Response: api.Error{
Message: "undefined internal error",
Details: api.NewOptString(err.Error()),
},
}
}

View file

@ -0,0 +1,38 @@
package rest
import (
"fmt"
"net/http"
"git.intra.yksa.space/gsn/predictor/internal/transport/middleware"
handler "git.intra.yksa.space/gsn/predictor/internal/transport/rest/handler"
api "git.intra.yksa.space/gsn/predictor/pkg/rest"
"go.uber.org/zap"
)
type Transport struct {
lg *zap.Logger
cfg *Config
srv *api.Server
}
func New(lg *zap.Logger, handler *handler.Handler, cfg *Config) (*Transport, error) {
srv, err := api.NewServer(handler, api.WithMiddleware(middleware.Logging(lg)))
if err != nil {
return nil, err
}
return &Transport{
lg: lg,
srv: srv,
cfg: cfg,
}, nil
}
func (t *Transport) Run() {
t.lg.Info("started")
if err := http.ListenAndServe(fmt.Sprintf(":%d", t.cfg.Port), t.srv); err != nil {
panic(err)
}
}

View file

@ -32,7 +32,7 @@ type Invoker interface {
// Perform preidction. // Perform preidction.
// //
// POST /api/v1/prediction // POST /api/v1/prediction
PerformPrediction(ctx context.Context, request OptParameters, params PerformPredictionParams) (*Result, error) PerformPrediction(ctx context.Context, request OptPredictionParameters, params PerformPredictionParams) (*PredictionResult, error)
} }
// Client implements OAS client. // Client implements OAS client.
@ -87,12 +87,12 @@ func (c *Client) requestURL(ctx context.Context) *url.URL {
// Perform preidction. // Perform preidction.
// //
// POST /api/v1/prediction // POST /api/v1/prediction
func (c *Client) PerformPrediction(ctx context.Context, request OptParameters, params PerformPredictionParams) (*Result, error) { func (c *Client) PerformPrediction(ctx context.Context, request OptPredictionParameters, params PerformPredictionParams) (*PredictionResult, error) {
res, err := c.sendPerformPrediction(ctx, request, params) res, err := c.sendPerformPrediction(ctx, request, params)
return res, err return res, err
} }
func (c *Client) sendPerformPrediction(ctx context.Context, request OptParameters, params PerformPredictionParams) (res *Result, err error) { func (c *Client) sendPerformPrediction(ctx context.Context, request OptPredictionParameters, params PerformPredictionParams) (res *PredictionResult, err error) {
otelAttrs := []attribute.KeyValue{ otelAttrs := []attribute.KeyValue{
otelogen.OperationID("performPrediction"), otelogen.OperationID("performPrediction"),
semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRequestMethodKey.String("POST"),

View file

@ -3,13 +3,13 @@
package gsn package gsn
// setDefaults set default value of fields. // setDefaults set default value of fields.
func (s *Parameters) setDefaults() { func (s *PredictionParameters) setDefaults() {
{ {
val := bool(false) val := bool(false)
s.Interpolate.SetTo(val) s.Interpolate.SetTo(val)
} }
{ {
val := ParametersFormat("json") val := PredictionParametersFormat("json")
s.Format.SetTo(val) s.Format.SetTo(val)
} }
} }

View file

@ -130,7 +130,7 @@ func (s *Server) handlePerformPredictionRequest(args [0]string, argsEscaped bool
} }
}() }()
var response *Result var response *PredictionResult
if m := s.cfg.Middleware; m != nil { if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{ mreq := middleware.Request{
Context: ctx, Context: ctx,
@ -148,9 +148,9 @@ func (s *Server) handlePerformPredictionRequest(args [0]string, argsEscaped bool
} }
type ( type (
Request = OptParameters Request = OptPredictionParameters
Params = PerformPredictionParams Params = PerformPredictionParams
Response = *Result Response = *PredictionResult
) )
response, err = middleware.HookMiddleware[ response, err = middleware.HookMiddleware[
Request, Request,

View file

@ -232,18 +232,18 @@ func (s *OptFloat64) UnmarshalJSON(data []byte) error {
return s.Decode(d) return s.Decode(d)
} }
// Encode encodes Parameters as json. // Encode encodes PredictionParameters as json.
func (o OptParameters) Encode(e *jx.Encoder) { func (o OptPredictionParameters) Encode(e *jx.Encoder) {
if !o.Set { if !o.Set {
return return
} }
o.Value.Encode(e) o.Value.Encode(e)
} }
// Decode decodes Parameters from json. // Decode decodes PredictionParameters from json.
func (o *OptParameters) Decode(d *jx.Decoder) error { func (o *OptPredictionParameters) Decode(d *jx.Decoder) error {
if o == nil { if o == nil {
return errors.New("invalid: unable to decode OptParameters to nil") return errors.New("invalid: unable to decode OptPredictionParameters to nil")
} }
o.Set = true o.Set = true
if err := o.Value.Decode(d); err != nil { if err := o.Value.Decode(d); err != nil {
@ -253,30 +253,30 @@ func (o *OptParameters) Decode(d *jx.Decoder) error {
} }
// MarshalJSON implements stdjson.Marshaler. // MarshalJSON implements stdjson.Marshaler.
func (s OptParameters) MarshalJSON() ([]byte, error) { func (s OptPredictionParameters) MarshalJSON() ([]byte, error) {
e := jx.Encoder{} e := jx.Encoder{}
s.Encode(&e) s.Encode(&e)
return e.Bytes(), nil return e.Bytes(), nil
} }
// UnmarshalJSON implements stdjson.Unmarshaler. // UnmarshalJSON implements stdjson.Unmarshaler.
func (s *OptParameters) UnmarshalJSON(data []byte) error { func (s *OptPredictionParameters) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data) d := jx.DecodeBytes(data)
return s.Decode(d) return s.Decode(d)
} }
// Encode encodes ParametersFormat as json. // Encode encodes PredictionParametersFormat as json.
func (o OptParametersFormat) Encode(e *jx.Encoder) { func (o OptPredictionParametersFormat) Encode(e *jx.Encoder) {
if !o.Set { if !o.Set {
return return
} }
e.Str(string(o.Value)) e.Str(string(o.Value))
} }
// Decode decodes ParametersFormat from json. // Decode decodes PredictionParametersFormat from json.
func (o *OptParametersFormat) Decode(d *jx.Decoder) error { func (o *OptPredictionParametersFormat) Decode(d *jx.Decoder) error {
if o == nil { if o == nil {
return errors.New("invalid: unable to decode OptParametersFormat to nil") return errors.New("invalid: unable to decode OptPredictionParametersFormat to nil")
} }
o.Set = true o.Set = true
if err := o.Value.Decode(d); err != nil { if err := o.Value.Decode(d); err != nil {
@ -286,30 +286,30 @@ func (o *OptParametersFormat) Decode(d *jx.Decoder) error {
} }
// MarshalJSON implements stdjson.Marshaler. // MarshalJSON implements stdjson.Marshaler.
func (s OptParametersFormat) MarshalJSON() ([]byte, error) { func (s OptPredictionParametersFormat) MarshalJSON() ([]byte, error) {
e := jx.Encoder{} e := jx.Encoder{}
s.Encode(&e) s.Encode(&e)
return e.Bytes(), nil return e.Bytes(), nil
} }
// UnmarshalJSON implements stdjson.Unmarshaler. // UnmarshalJSON implements stdjson.Unmarshaler.
func (s *OptParametersFormat) UnmarshalJSON(data []byte) error { func (s *OptPredictionParametersFormat) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data) d := jx.DecodeBytes(data)
return s.Decode(d) return s.Decode(d)
} }
// Encode encodes ParametersProfile as json. // Encode encodes PredictionParametersProfile as json.
func (o OptParametersProfile) Encode(e *jx.Encoder) { func (o OptPredictionParametersProfile) Encode(e *jx.Encoder) {
if !o.Set { if !o.Set {
return return
} }
e.Str(string(o.Value)) e.Str(string(o.Value))
} }
// Decode decodes ParametersProfile from json. // Decode decodes PredictionParametersProfile from json.
func (o *OptParametersProfile) Decode(d *jx.Decoder) error { func (o *OptPredictionParametersProfile) Decode(d *jx.Decoder) error {
if o == nil { if o == nil {
return errors.New("invalid: unable to decode OptParametersProfile to nil") return errors.New("invalid: unable to decode OptPredictionParametersProfile to nil")
} }
o.Set = true o.Set = true
if err := o.Value.Decode(d); err != nil { if err := o.Value.Decode(d); err != nil {
@ -319,14 +319,14 @@ func (o *OptParametersProfile) Decode(d *jx.Decoder) error {
} }
// MarshalJSON implements stdjson.Marshaler. // MarshalJSON implements stdjson.Marshaler.
func (s OptParametersProfile) MarshalJSON() ([]byte, error) { func (s OptPredictionParametersProfile) MarshalJSON() ([]byte, error) {
e := jx.Encoder{} e := jx.Encoder{}
s.Encode(&e) s.Encode(&e)
return e.Bytes(), nil return e.Bytes(), nil
} }
// UnmarshalJSON implements stdjson.Unmarshaler. // UnmarshalJSON implements stdjson.Unmarshaler.
func (s *OptParametersProfile) UnmarshalJSON(data []byte) error { func (s *OptPredictionParametersProfile) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data) d := jx.DecodeBytes(data)
return s.Decode(d) return s.Decode(d)
} }
@ -367,14 +367,14 @@ func (s *OptString) UnmarshalJSON(data []byte) error {
} }
// Encode implements json.Marshaler. // Encode implements json.Marshaler.
func (s *Parameters) Encode(e *jx.Encoder) { func (s *PredictionParameters) Encode(e *jx.Encoder) {
e.ObjStart() e.ObjStart()
s.encodeFields(e) s.encodeFields(e)
e.ObjEnd() e.ObjEnd()
} }
// encodeFields encodes fields. // encodeFields encodes fields.
func (s *Parameters) encodeFields(e *jx.Encoder) { func (s *PredictionParameters) encodeFields(e *jx.Encoder) {
{ {
if s.LaunchLatitude.Set { if s.LaunchLatitude.Set {
e.FieldStart("launch_latitude") e.FieldStart("launch_latitude")
@ -467,7 +467,7 @@ func (s *Parameters) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfParameters = [15]string{ var jsonFieldsNameOfPredictionParameters = [15]string{
0: "launch_latitude", 0: "launch_latitude",
1: "launch_longitude", 1: "launch_longitude",
2: "launch_datetime", 2: "launch_datetime",
@ -485,10 +485,10 @@ var jsonFieldsNameOfParameters = [15]string{
14: "dataset", 14: "dataset",
} }
// Decode decodes Parameters from json. // Decode decodes PredictionParameters from json.
func (s *Parameters) Decode(d *jx.Decoder) error { func (s *PredictionParameters) Decode(d *jx.Decoder) error {
if s == nil { if s == nil {
return errors.New("invalid: unable to decode Parameters to nil") return errors.New("invalid: unable to decode PredictionParameters to nil")
} }
s.setDefaults() s.setDefaults()
@ -649,116 +649,116 @@ func (s *Parameters) Decode(d *jx.Decoder) error {
} }
return nil return nil
}); err != nil { }); err != nil {
return errors.Wrap(err, "decode Parameters") return errors.Wrap(err, "decode PredictionParameters")
} }
return nil return nil
} }
// MarshalJSON implements stdjson.Marshaler. // MarshalJSON implements stdjson.Marshaler.
func (s *Parameters) MarshalJSON() ([]byte, error) { func (s *PredictionParameters) MarshalJSON() ([]byte, error) {
e := jx.Encoder{} e := jx.Encoder{}
s.Encode(&e) s.Encode(&e)
return e.Bytes(), nil return e.Bytes(), nil
} }
// UnmarshalJSON implements stdjson.Unmarshaler. // UnmarshalJSON implements stdjson.Unmarshaler.
func (s *Parameters) UnmarshalJSON(data []byte) error { func (s *PredictionParameters) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data) d := jx.DecodeBytes(data)
return s.Decode(d) return s.Decode(d)
} }
// Encode encodes ParametersFormat as json. // Encode encodes PredictionParametersFormat as json.
func (s ParametersFormat) Encode(e *jx.Encoder) { func (s PredictionParametersFormat) Encode(e *jx.Encoder) {
e.Str(string(s)) e.Str(string(s))
} }
// Decode decodes ParametersFormat from json. // Decode decodes PredictionParametersFormat from json.
func (s *ParametersFormat) Decode(d *jx.Decoder) error { func (s *PredictionParametersFormat) Decode(d *jx.Decoder) error {
if s == nil { if s == nil {
return errors.New("invalid: unable to decode ParametersFormat to nil") return errors.New("invalid: unable to decode PredictionParametersFormat to nil")
} }
v, err := d.StrBytes() v, err := d.StrBytes()
if err != nil { if err != nil {
return err return err
} }
// Try to use constant string. // Try to use constant string.
switch ParametersFormat(v) { switch PredictionParametersFormat(v) {
case ParametersFormatJSON: case PredictionParametersFormatJSON:
*s = ParametersFormatJSON *s = PredictionParametersFormatJSON
default: default:
*s = ParametersFormat(v) *s = PredictionParametersFormat(v)
} }
return nil return nil
} }
// MarshalJSON implements stdjson.Marshaler. // MarshalJSON implements stdjson.Marshaler.
func (s ParametersFormat) MarshalJSON() ([]byte, error) { func (s PredictionParametersFormat) MarshalJSON() ([]byte, error) {
e := jx.Encoder{} e := jx.Encoder{}
s.Encode(&e) s.Encode(&e)
return e.Bytes(), nil return e.Bytes(), nil
} }
// UnmarshalJSON implements stdjson.Unmarshaler. // UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ParametersFormat) UnmarshalJSON(data []byte) error { func (s *PredictionParametersFormat) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data) d := jx.DecodeBytes(data)
return s.Decode(d) return s.Decode(d)
} }
// Encode encodes ParametersProfile as json. // Encode encodes PredictionParametersProfile as json.
func (s ParametersProfile) Encode(e *jx.Encoder) { func (s PredictionParametersProfile) Encode(e *jx.Encoder) {
e.Str(string(s)) e.Str(string(s))
} }
// Decode decodes ParametersProfile from json. // Decode decodes PredictionParametersProfile from json.
func (s *ParametersProfile) Decode(d *jx.Decoder) error { func (s *PredictionParametersProfile) Decode(d *jx.Decoder) error {
if s == nil { if s == nil {
return errors.New("invalid: unable to decode ParametersProfile to nil") return errors.New("invalid: unable to decode PredictionParametersProfile to nil")
} }
v, err := d.StrBytes() v, err := d.StrBytes()
if err != nil { if err != nil {
return err return err
} }
// Try to use constant string. // Try to use constant string.
switch ParametersProfile(v) { switch PredictionParametersProfile(v) {
case ParametersProfileStandardProfile: case PredictionParametersProfileStandardProfile:
*s = ParametersProfileStandardProfile *s = PredictionParametersProfileStandardProfile
case ParametersProfileFloatProfile: case PredictionParametersProfileFloatProfile:
*s = ParametersProfileFloatProfile *s = PredictionParametersProfileFloatProfile
case ParametersProfileReverseProfile: case PredictionParametersProfileReverseProfile:
*s = ParametersProfileReverseProfile *s = PredictionParametersProfileReverseProfile
case ParametersProfileCustomProfile: case PredictionParametersProfileCustomProfile:
*s = ParametersProfileCustomProfile *s = PredictionParametersProfileCustomProfile
default: default:
*s = ParametersProfile(v) *s = PredictionParametersProfile(v)
} }
return nil return nil
} }
// MarshalJSON implements stdjson.Marshaler. // MarshalJSON implements stdjson.Marshaler.
func (s ParametersProfile) MarshalJSON() ([]byte, error) { func (s PredictionParametersProfile) MarshalJSON() ([]byte, error) {
e := jx.Encoder{} e := jx.Encoder{}
s.Encode(&e) s.Encode(&e)
return e.Bytes(), nil return e.Bytes(), nil
} }
// UnmarshalJSON implements stdjson.Unmarshaler. // UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ParametersProfile) UnmarshalJSON(data []byte) error { func (s *PredictionParametersProfile) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data) d := jx.DecodeBytes(data)
return s.Decode(d) return s.Decode(d)
} }
// Encode implements json.Marshaler. // Encode implements json.Marshaler.
func (s *Result) Encode(e *jx.Encoder) { func (s *PredictionResult) Encode(e *jx.Encoder) {
e.ObjStart() e.ObjStart()
s.encodeFields(e) s.encodeFields(e)
e.ObjEnd() e.ObjEnd()
} }
// encodeFields encodes fields. // encodeFields encodes fields.
func (s *Result) encodeFields(e *jx.Encoder) { func (s *PredictionResult) encodeFields(e *jx.Encoder) {
{ {
e.FieldStart("metadata") e.FieldStart("metadata")
s.Metadata.Encode(e) s.Metadata.Encode(e)
@ -773,15 +773,15 @@ func (s *Result) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfResult = [2]string{ var jsonFieldsNameOfPredictionResult = [2]string{
0: "metadata", 0: "metadata",
1: "prediction", 1: "prediction",
} }
// Decode decodes Result from json. // Decode decodes PredictionResult from json.
func (s *Result) Decode(d *jx.Decoder) error { func (s *PredictionResult) Decode(d *jx.Decoder) error {
if s == nil { if s == nil {
return errors.New("invalid: unable to decode Result to nil") return errors.New("invalid: unable to decode PredictionResult to nil")
} }
var requiredBitSet [1]uint8 var requiredBitSet [1]uint8
@ -800,9 +800,9 @@ func (s *Result) Decode(d *jx.Decoder) error {
case "prediction": case "prediction":
requiredBitSet[0] |= 1 << 1 requiredBitSet[0] |= 1 << 1
if err := func() error { if err := func() error {
s.Prediction = make([]ResultPredictionItem, 0) s.Prediction = make([]PredictionResultPredictionItem, 0)
if err := d.Arr(func(d *jx.Decoder) error { if err := d.Arr(func(d *jx.Decoder) error {
var elem ResultPredictionItem var elem PredictionResultPredictionItem
if err := elem.Decode(d); err != nil { if err := elem.Decode(d); err != nil {
return err return err
} }
@ -820,7 +820,7 @@ func (s *Result) Decode(d *jx.Decoder) error {
} }
return nil return nil
}); err != nil { }); err != nil {
return errors.Wrap(err, "decode Result") return errors.Wrap(err, "decode PredictionResult")
} }
// Validate required fields. // Validate required fields.
var failures []validate.FieldError var failures []validate.FieldError
@ -837,8 +837,8 @@ func (s *Result) Decode(d *jx.Decoder) error {
bitIdx := bits.TrailingZeros8(result) bitIdx := bits.TrailingZeros8(result)
fieldIdx := i*8 + bitIdx fieldIdx := i*8 + bitIdx
var name string var name string
if fieldIdx < len(jsonFieldsNameOfResult) { if fieldIdx < len(jsonFieldsNameOfPredictionResult) {
name = jsonFieldsNameOfResult[fieldIdx] name = jsonFieldsNameOfPredictionResult[fieldIdx]
} else { } else {
name = strconv.Itoa(fieldIdx) name = strconv.Itoa(fieldIdx)
} }
@ -859,27 +859,27 @@ func (s *Result) Decode(d *jx.Decoder) error {
} }
// MarshalJSON implements stdjson.Marshaler. // MarshalJSON implements stdjson.Marshaler.
func (s *Result) MarshalJSON() ([]byte, error) { func (s *PredictionResult) MarshalJSON() ([]byte, error) {
e := jx.Encoder{} e := jx.Encoder{}
s.Encode(&e) s.Encode(&e)
return e.Bytes(), nil return e.Bytes(), nil
} }
// UnmarshalJSON implements stdjson.Unmarshaler. // UnmarshalJSON implements stdjson.Unmarshaler.
func (s *Result) UnmarshalJSON(data []byte) error { func (s *PredictionResult) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data) d := jx.DecodeBytes(data)
return s.Decode(d) return s.Decode(d)
} }
// Encode implements json.Marshaler. // Encode implements json.Marshaler.
func (s *ResultMetadata) Encode(e *jx.Encoder) { func (s *PredictionResultMetadata) Encode(e *jx.Encoder) {
e.ObjStart() e.ObjStart()
s.encodeFields(e) s.encodeFields(e)
e.ObjEnd() e.ObjEnd()
} }
// encodeFields encodes fields. // encodeFields encodes fields.
func (s *ResultMetadata) encodeFields(e *jx.Encoder) { func (s *PredictionResultMetadata) encodeFields(e *jx.Encoder) {
{ {
e.FieldStart("complete_datetime") e.FieldStart("complete_datetime")
json.EncodeDateTime(e, s.CompleteDatetime) json.EncodeDateTime(e, s.CompleteDatetime)
@ -890,15 +890,15 @@ func (s *ResultMetadata) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfResultMetadata = [2]string{ var jsonFieldsNameOfPredictionResultMetadata = [2]string{
0: "complete_datetime", 0: "complete_datetime",
1: "start_datetime", 1: "start_datetime",
} }
// Decode decodes ResultMetadata from json. // Decode decodes PredictionResultMetadata from json.
func (s *ResultMetadata) Decode(d *jx.Decoder) error { func (s *PredictionResultMetadata) Decode(d *jx.Decoder) error {
if s == nil { if s == nil {
return errors.New("invalid: unable to decode ResultMetadata to nil") return errors.New("invalid: unable to decode PredictionResultMetadata to nil")
} }
var requiredBitSet [1]uint8 var requiredBitSet [1]uint8
@ -933,7 +933,7 @@ func (s *ResultMetadata) Decode(d *jx.Decoder) error {
} }
return nil return nil
}); err != nil { }); err != nil {
return errors.Wrap(err, "decode ResultMetadata") return errors.Wrap(err, "decode PredictionResultMetadata")
} }
// Validate required fields. // Validate required fields.
var failures []validate.FieldError var failures []validate.FieldError
@ -950,8 +950,8 @@ func (s *ResultMetadata) Decode(d *jx.Decoder) error {
bitIdx := bits.TrailingZeros8(result) bitIdx := bits.TrailingZeros8(result)
fieldIdx := i*8 + bitIdx fieldIdx := i*8 + bitIdx
var name string var name string
if fieldIdx < len(jsonFieldsNameOfResultMetadata) { if fieldIdx < len(jsonFieldsNameOfPredictionResultMetadata) {
name = jsonFieldsNameOfResultMetadata[fieldIdx] name = jsonFieldsNameOfPredictionResultMetadata[fieldIdx]
} else { } else {
name = strconv.Itoa(fieldIdx) name = strconv.Itoa(fieldIdx)
} }
@ -972,27 +972,27 @@ func (s *ResultMetadata) Decode(d *jx.Decoder) error {
} }
// MarshalJSON implements stdjson.Marshaler. // MarshalJSON implements stdjson.Marshaler.
func (s *ResultMetadata) MarshalJSON() ([]byte, error) { func (s *PredictionResultMetadata) MarshalJSON() ([]byte, error) {
e := jx.Encoder{} e := jx.Encoder{}
s.Encode(&e) s.Encode(&e)
return e.Bytes(), nil return e.Bytes(), nil
} }
// UnmarshalJSON implements stdjson.Unmarshaler. // UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ResultMetadata) UnmarshalJSON(data []byte) error { func (s *PredictionResultMetadata) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data) d := jx.DecodeBytes(data)
return s.Decode(d) return s.Decode(d)
} }
// Encode implements json.Marshaler. // Encode implements json.Marshaler.
func (s *ResultPredictionItem) Encode(e *jx.Encoder) { func (s *PredictionResultPredictionItem) Encode(e *jx.Encoder) {
e.ObjStart() e.ObjStart()
s.encodeFields(e) s.encodeFields(e)
e.ObjEnd() e.ObjEnd()
} }
// encodeFields encodes fields. // encodeFields encodes fields.
func (s *ResultPredictionItem) encodeFields(e *jx.Encoder) { func (s *PredictionResultPredictionItem) encodeFields(e *jx.Encoder) {
{ {
e.FieldStart("stage") e.FieldStart("stage")
s.Stage.Encode(e) s.Stage.Encode(e)
@ -1007,15 +1007,15 @@ func (s *ResultPredictionItem) encodeFields(e *jx.Encoder) {
} }
} }
var jsonFieldsNameOfResultPredictionItem = [2]string{ var jsonFieldsNameOfPredictionResultPredictionItem = [2]string{
0: "stage", 0: "stage",
1: "trajectory", 1: "trajectory",
} }
// Decode decodes ResultPredictionItem from json. // Decode decodes PredictionResultPredictionItem from json.
func (s *ResultPredictionItem) Decode(d *jx.Decoder) error { func (s *PredictionResultPredictionItem) Decode(d *jx.Decoder) error {
if s == nil { if s == nil {
return errors.New("invalid: unable to decode ResultPredictionItem to nil") return errors.New("invalid: unable to decode PredictionResultPredictionItem to nil")
} }
var requiredBitSet [1]uint8 var requiredBitSet [1]uint8
@ -1034,9 +1034,9 @@ func (s *ResultPredictionItem) Decode(d *jx.Decoder) error {
case "trajectory": case "trajectory":
requiredBitSet[0] |= 1 << 1 requiredBitSet[0] |= 1 << 1
if err := func() error { if err := func() error {
s.Trajectory = make([]ResultPredictionItemTrajectoryItem, 0) s.Trajectory = make([]PredictionResultPredictionItemTrajectoryItem, 0)
if err := d.Arr(func(d *jx.Decoder) error { if err := d.Arr(func(d *jx.Decoder) error {
var elem ResultPredictionItemTrajectoryItem var elem PredictionResultPredictionItemTrajectoryItem
if err := elem.Decode(d); err != nil { if err := elem.Decode(d); err != nil {
return err return err
} }
@ -1054,7 +1054,7 @@ func (s *ResultPredictionItem) Decode(d *jx.Decoder) error {
} }
return nil return nil
}); err != nil { }); err != nil {
return errors.Wrap(err, "decode ResultPredictionItem") return errors.Wrap(err, "decode PredictionResultPredictionItem")
} }
// Validate required fields. // Validate required fields.
var failures []validate.FieldError var failures []validate.FieldError
@ -1071,8 +1071,8 @@ func (s *ResultPredictionItem) Decode(d *jx.Decoder) error {
bitIdx := bits.TrailingZeros8(result) bitIdx := bits.TrailingZeros8(result)
fieldIdx := i*8 + bitIdx fieldIdx := i*8 + bitIdx
var name string var name string
if fieldIdx < len(jsonFieldsNameOfResultPredictionItem) { if fieldIdx < len(jsonFieldsNameOfPredictionResultPredictionItem) {
name = jsonFieldsNameOfResultPredictionItem[fieldIdx] name = jsonFieldsNameOfPredictionResultPredictionItem[fieldIdx]
} else { } else {
name = strconv.Itoa(fieldIdx) name = strconv.Itoa(fieldIdx)
} }
@ -1093,75 +1093,75 @@ func (s *ResultPredictionItem) Decode(d *jx.Decoder) error {
} }
// MarshalJSON implements stdjson.Marshaler. // MarshalJSON implements stdjson.Marshaler.
func (s *ResultPredictionItem) MarshalJSON() ([]byte, error) { func (s *PredictionResultPredictionItem) MarshalJSON() ([]byte, error) {
e := jx.Encoder{} e := jx.Encoder{}
s.Encode(&e) s.Encode(&e)
return e.Bytes(), nil return e.Bytes(), nil
} }
// UnmarshalJSON implements stdjson.Unmarshaler. // UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ResultPredictionItem) UnmarshalJSON(data []byte) error { func (s *PredictionResultPredictionItem) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data) d := jx.DecodeBytes(data)
return s.Decode(d) return s.Decode(d)
} }
// Encode encodes ResultPredictionItemStage as json. // Encode encodes PredictionResultPredictionItemStage as json.
func (s ResultPredictionItemStage) Encode(e *jx.Encoder) { func (s PredictionResultPredictionItemStage) Encode(e *jx.Encoder) {
e.Str(string(s)) e.Str(string(s))
} }
// Decode decodes ResultPredictionItemStage from json. // Decode decodes PredictionResultPredictionItemStage from json.
func (s *ResultPredictionItemStage) Decode(d *jx.Decoder) error { func (s *PredictionResultPredictionItemStage) Decode(d *jx.Decoder) error {
if s == nil { if s == nil {
return errors.New("invalid: unable to decode ResultPredictionItemStage to nil") return errors.New("invalid: unable to decode PredictionResultPredictionItemStage to nil")
} }
v, err := d.StrBytes() v, err := d.StrBytes()
if err != nil { if err != nil {
return err return err
} }
// Try to use constant string. // Try to use constant string.
switch ResultPredictionItemStage(v) { switch PredictionResultPredictionItemStage(v) {
case ResultPredictionItemStageAscent: case PredictionResultPredictionItemStageAscent:
*s = ResultPredictionItemStageAscent *s = PredictionResultPredictionItemStageAscent
case ResultPredictionItemStageDescent: case PredictionResultPredictionItemStageDescent:
*s = ResultPredictionItemStageDescent *s = PredictionResultPredictionItemStageDescent
default: default:
*s = ResultPredictionItemStage(v) *s = PredictionResultPredictionItemStage(v)
} }
return nil return nil
} }
// MarshalJSON implements stdjson.Marshaler. // MarshalJSON implements stdjson.Marshaler.
func (s ResultPredictionItemStage) MarshalJSON() ([]byte, error) { func (s PredictionResultPredictionItemStage) MarshalJSON() ([]byte, error) {
e := jx.Encoder{} e := jx.Encoder{}
s.Encode(&e) s.Encode(&e)
return e.Bytes(), nil return e.Bytes(), nil
} }
// UnmarshalJSON implements stdjson.Unmarshaler. // UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ResultPredictionItemStage) UnmarshalJSON(data []byte) error { func (s *PredictionResultPredictionItemStage) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data) d := jx.DecodeBytes(data)
return s.Decode(d) return s.Decode(d)
} }
// Encode implements json.Marshaler. // Encode implements json.Marshaler.
func (s *ResultPredictionItemTrajectoryItem) Encode(e *jx.Encoder) { func (s *PredictionResultPredictionItemTrajectoryItem) Encode(e *jx.Encoder) {
e.ObjStart() e.ObjStart()
s.encodeFields(e) s.encodeFields(e)
e.ObjEnd() e.ObjEnd()
} }
// encodeFields encodes fields. // encodeFields encodes fields.
func (s *ResultPredictionItemTrajectoryItem) encodeFields(e *jx.Encoder) { func (s *PredictionResultPredictionItemTrajectoryItem) encodeFields(e *jx.Encoder) {
} }
var jsonFieldsNameOfResultPredictionItemTrajectoryItem = [0]string{} var jsonFieldsNameOfPredictionResultPredictionItemTrajectoryItem = [0]string{}
// Decode decodes ResultPredictionItemTrajectoryItem from json. // Decode decodes PredictionResultPredictionItemTrajectoryItem from json.
func (s *ResultPredictionItemTrajectoryItem) Decode(d *jx.Decoder) error { func (s *PredictionResultPredictionItemTrajectoryItem) Decode(d *jx.Decoder) error {
if s == nil { if s == nil {
return errors.New("invalid: unable to decode ResultPredictionItemTrajectoryItem to nil") return errors.New("invalid: unable to decode PredictionResultPredictionItemTrajectoryItem to nil")
} }
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
@ -1170,21 +1170,21 @@ func (s *ResultPredictionItemTrajectoryItem) Decode(d *jx.Decoder) error {
return d.Skip() return d.Skip()
} }
}); err != nil { }); err != nil {
return errors.Wrap(err, "decode ResultPredictionItemTrajectoryItem") return errors.Wrap(err, "decode PredictionResultPredictionItemTrajectoryItem")
} }
return nil return nil
} }
// MarshalJSON implements stdjson.Marshaler. // MarshalJSON implements stdjson.Marshaler.
func (s *ResultPredictionItemTrajectoryItem) MarshalJSON() ([]byte, error) { func (s *PredictionResultPredictionItemTrajectoryItem) MarshalJSON() ([]byte, error) {
e := jx.Encoder{} e := jx.Encoder{}
s.Encode(&e) s.Encode(&e)
return e.Bytes(), nil return e.Bytes(), nil
} }
// UnmarshalJSON implements stdjson.Unmarshaler. // UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ResultPredictionItemTrajectoryItem) UnmarshalJSON(data []byte) error { func (s *PredictionResultPredictionItemTrajectoryItem) UnmarshalJSON(data []byte) error {
d := jx.DecodeBytes(data) d := jx.DecodeBytes(data)
return s.Decode(d) return s.Decode(d)
} }

View file

@ -12,7 +12,7 @@ import (
// PerformPredictionParams is parameters of performPrediction operation. // PerformPredictionParams is parameters of performPrediction operation.
type PerformPredictionParams struct { type PerformPredictionParams struct {
Parameters OptParameters Parameters OptPredictionParameters
} }
func unpackPerformPredictionParams(packed middleware.Parameters) (params PerformPredictionParams) { func unpackPerformPredictionParams(packed middleware.Parameters) (params PerformPredictionParams) {
@ -22,7 +22,7 @@ func unpackPerformPredictionParams(packed middleware.Parameters) (params Perform
In: "query", In: "query",
} }
if v, ok := packed[key]; ok { if v, ok := packed[key]; ok {
params.Parameters = v.(OptParameters) params.Parameters = v.(OptPredictionParameters)
} }
} }
return params return params
@ -41,7 +41,7 @@ func decodePerformPredictionParams(args [0]string, argsEscaped bool, r *http.Req
if err := q.HasParam(cfg); err == nil { if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error { if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
var paramsDotParametersVal Parameters var paramsDotParametersVal PredictionParameters
if err := func() error { if err := func() error {
return paramsDotParametersVal.DecodeURI(d) return paramsDotParametersVal.DecodeURI(d)
}(); err != nil { }(); err != nil {

View file

@ -15,7 +15,7 @@ import (
) )
func (s *Server) decodePerformPredictionRequest(r *http.Request) ( func (s *Server) decodePerformPredictionRequest(r *http.Request) (
req OptParameters, req OptPredictionParameters,
close func() error, close func() error,
rerr error, rerr error,
) { ) {
@ -57,7 +57,7 @@ func (s *Server) decodePerformPredictionRequest(r *http.Request) (
d := jx.DecodeBytes(buf) d := jx.DecodeBytes(buf)
var request OptParameters var request OptPredictionParameters
if err := func() error { if err := func() error {
request.Reset() request.Reset()
if err := request.Decode(d); err != nil { if err := request.Decode(d); err != nil {

View file

@ -12,7 +12,7 @@ import (
) )
func encodePerformPredictionRequest( func encodePerformPredictionRequest(
req OptParameters, req OptPredictionParameters,
r *http.Request, r *http.Request,
) error { ) error {
const contentType = "application/json" const contentType = "application/json"

View file

@ -14,7 +14,7 @@ import (
"github.com/ogen-go/ogen/validate" "github.com/ogen-go/ogen/validate"
) )
func decodePerformPredictionResponse(resp *http.Response) (res *Result, _ error) { func decodePerformPredictionResponse(resp *http.Response) (res *PredictionResult, _ error) {
switch resp.StatusCode { switch resp.StatusCode {
case 200: case 200:
// Code 200. // Code 200.
@ -30,7 +30,7 @@ func decodePerformPredictionResponse(resp *http.Response) (res *Result, _ error)
} }
d := jx.DecodeBytes(buf) d := jx.DecodeBytes(buf)
var response Result var response PredictionResult
if err := func() error { if err := func() error {
if err := response.Decode(d); err != nil { if err := response.Decode(d); err != nil {
return err return err

View file

@ -13,7 +13,7 @@ import (
ht "github.com/ogen-go/ogen/http" ht "github.com/ogen-go/ogen/http"
) )
func encodePerformPredictionResponse(response *Result, w http.ResponseWriter, span trace.Span) error { func encodePerformPredictionResponse(response *PredictionResult, w http.ResponseWriter, span trace.Span) error {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(200) w.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200)) span.SetStatus(codes.Ok, http.StatusText(200))

View file

@ -203,38 +203,38 @@ func (o OptFloat64) Or(d float64) float64 {
return d return d
} }
// NewOptParameters returns new OptParameters with value set to v. // NewOptPredictionParameters returns new OptPredictionParameters with value set to v.
func NewOptParameters(v Parameters) OptParameters { func NewOptPredictionParameters(v PredictionParameters) OptPredictionParameters {
return OptParameters{ return OptPredictionParameters{
Value: v, Value: v,
Set: true, Set: true,
} }
} }
// OptParameters is optional Parameters. // OptPredictionParameters is optional PredictionParameters.
type OptParameters struct { type OptPredictionParameters struct {
Value Parameters Value PredictionParameters
Set bool Set bool
} }
// IsSet returns true if OptParameters was set. // IsSet returns true if OptPredictionParameters was set.
func (o OptParameters) IsSet() bool { return o.Set } func (o OptPredictionParameters) IsSet() bool { return o.Set }
// Reset unsets value. // Reset unsets value.
func (o *OptParameters) Reset() { func (o *OptPredictionParameters) Reset() {
var v Parameters var v PredictionParameters
o.Value = v o.Value = v
o.Set = false o.Set = false
} }
// SetTo sets value to v. // SetTo sets value to v.
func (o *OptParameters) SetTo(v Parameters) { func (o *OptPredictionParameters) SetTo(v PredictionParameters) {
o.Set = true o.Set = true
o.Value = v o.Value = v
} }
// Get returns value and boolean that denotes whether value was set. // Get returns value and boolean that denotes whether value was set.
func (o OptParameters) Get() (v Parameters, ok bool) { func (o OptPredictionParameters) Get() (v PredictionParameters, ok bool) {
if !o.Set { if !o.Set {
return v, false return v, false
} }
@ -242,45 +242,45 @@ func (o OptParameters) Get() (v Parameters, ok bool) {
} }
// Or returns value if set, or given parameter if does not. // Or returns value if set, or given parameter if does not.
func (o OptParameters) Or(d Parameters) Parameters { func (o OptPredictionParameters) Or(d PredictionParameters) PredictionParameters {
if v, ok := o.Get(); ok { if v, ok := o.Get(); ok {
return v return v
} }
return d return d
} }
// NewOptParametersFormat returns new OptParametersFormat with value set to v. // NewOptPredictionParametersFormat returns new OptPredictionParametersFormat with value set to v.
func NewOptParametersFormat(v ParametersFormat) OptParametersFormat { func NewOptPredictionParametersFormat(v PredictionParametersFormat) OptPredictionParametersFormat {
return OptParametersFormat{ return OptPredictionParametersFormat{
Value: v, Value: v,
Set: true, Set: true,
} }
} }
// OptParametersFormat is optional ParametersFormat. // OptPredictionParametersFormat is optional PredictionParametersFormat.
type OptParametersFormat struct { type OptPredictionParametersFormat struct {
Value ParametersFormat Value PredictionParametersFormat
Set bool Set bool
} }
// IsSet returns true if OptParametersFormat was set. // IsSet returns true if OptPredictionParametersFormat was set.
func (o OptParametersFormat) IsSet() bool { return o.Set } func (o OptPredictionParametersFormat) IsSet() bool { return o.Set }
// Reset unsets value. // Reset unsets value.
func (o *OptParametersFormat) Reset() { func (o *OptPredictionParametersFormat) Reset() {
var v ParametersFormat var v PredictionParametersFormat
o.Value = v o.Value = v
o.Set = false o.Set = false
} }
// SetTo sets value to v. // SetTo sets value to v.
func (o *OptParametersFormat) SetTo(v ParametersFormat) { func (o *OptPredictionParametersFormat) SetTo(v PredictionParametersFormat) {
o.Set = true o.Set = true
o.Value = v o.Value = v
} }
// Get returns value and boolean that denotes whether value was set. // Get returns value and boolean that denotes whether value was set.
func (o OptParametersFormat) Get() (v ParametersFormat, ok bool) { func (o OptPredictionParametersFormat) Get() (v PredictionParametersFormat, ok bool) {
if !o.Set { if !o.Set {
return v, false return v, false
} }
@ -288,45 +288,45 @@ func (o OptParametersFormat) Get() (v ParametersFormat, ok bool) {
} }
// Or returns value if set, or given parameter if does not. // Or returns value if set, or given parameter if does not.
func (o OptParametersFormat) Or(d ParametersFormat) ParametersFormat { func (o OptPredictionParametersFormat) Or(d PredictionParametersFormat) PredictionParametersFormat {
if v, ok := o.Get(); ok { if v, ok := o.Get(); ok {
return v return v
} }
return d return d
} }
// NewOptParametersProfile returns new OptParametersProfile with value set to v. // NewOptPredictionParametersProfile returns new OptPredictionParametersProfile with value set to v.
func NewOptParametersProfile(v ParametersProfile) OptParametersProfile { func NewOptPredictionParametersProfile(v PredictionParametersProfile) OptPredictionParametersProfile {
return OptParametersProfile{ return OptPredictionParametersProfile{
Value: v, Value: v,
Set: true, Set: true,
} }
} }
// OptParametersProfile is optional ParametersProfile. // OptPredictionParametersProfile is optional PredictionParametersProfile.
type OptParametersProfile struct { type OptPredictionParametersProfile struct {
Value ParametersProfile Value PredictionParametersProfile
Set bool Set bool
} }
// IsSet returns true if OptParametersProfile was set. // IsSet returns true if OptPredictionParametersProfile was set.
func (o OptParametersProfile) IsSet() bool { return o.Set } func (o OptPredictionParametersProfile) IsSet() bool { return o.Set }
// Reset unsets value. // Reset unsets value.
func (o *OptParametersProfile) Reset() { func (o *OptPredictionParametersProfile) Reset() {
var v ParametersProfile var v PredictionParametersProfile
o.Value = v o.Value = v
o.Set = false o.Set = false
} }
// SetTo sets value to v. // SetTo sets value to v.
func (o *OptParametersProfile) SetTo(v ParametersProfile) { func (o *OptPredictionParametersProfile) SetTo(v PredictionParametersProfile) {
o.Set = true o.Set = true
o.Value = v o.Value = v
} }
// Get returns value and boolean that denotes whether value was set. // Get returns value and boolean that denotes whether value was set.
func (o OptParametersProfile) Get() (v ParametersProfile, ok bool) { func (o OptPredictionParametersProfile) Get() (v PredictionParametersProfile, ok bool) {
if !o.Set { if !o.Set {
return v, false return v, false
} }
@ -334,7 +334,7 @@ func (o OptParametersProfile) Get() (v ParametersProfile, ok bool) {
} }
// Or returns value if set, or given parameter if does not. // Or returns value if set, or given parameter if does not.
func (o OptParametersProfile) Or(d ParametersProfile) ParametersProfile { func (o OptPredictionParametersProfile) Or(d PredictionParametersProfile) PredictionParametersProfile {
if v, ok := o.Get(); ok { if v, ok := o.Get(); ok {
return v return v
} }
@ -387,13 +387,13 @@ func (o OptString) Or(d string) string {
return d return d
} }
// Ref: #/components/schemas/Prediction/Parameters // Ref: #/components/schemas/PredictionParameters
type Parameters struct { type PredictionParameters struct {
LaunchLatitude OptFloat64 `json:"launch_latitude"` LaunchLatitude OptFloat64 `json:"launch_latitude"`
LaunchLongitude OptFloat64 `json:"launch_longitude"` LaunchLongitude OptFloat64 `json:"launch_longitude"`
LaunchDatetime OptDateTime `json:"launch_datetime"` LaunchDatetime OptDateTime `json:"launch_datetime"`
LaunchAltitude OptFloat64 `json:"launch_altitude"` LaunchAltitude OptFloat64 `json:"launch_altitude"`
Profile OptParametersProfile `json:"profile"` Profile OptPredictionParametersProfile `json:"profile"`
AscentRate OptFloat64 `json:"ascent_rate"` AscentRate OptFloat64 `json:"ascent_rate"`
BurstAltitude OptFloat64 `json:"burst_altitude"` BurstAltitude OptFloat64 `json:"burst_altitude"`
DescentRate OptFloat64 `json:"descent_rate"` DescentRate OptFloat64 `json:"descent_rate"`
@ -404,177 +404,177 @@ type Parameters struct {
// Base64 encoded descent curve. // Base64 encoded descent curve.
DescentCurve OptString `json:"descent_curve"` DescentCurve OptString `json:"descent_curve"`
Interpolate OptBool `json:"interpolate"` Interpolate OptBool `json:"interpolate"`
Format OptParametersFormat `json:"format"` Format OptPredictionParametersFormat `json:"format"`
Dataset OptDateTime `json:"dataset"` Dataset OptDateTime `json:"dataset"`
} }
// GetLaunchLatitude returns the value of LaunchLatitude. // GetLaunchLatitude returns the value of LaunchLatitude.
func (s *Parameters) GetLaunchLatitude() OptFloat64 { func (s *PredictionParameters) GetLaunchLatitude() OptFloat64 {
return s.LaunchLatitude return s.LaunchLatitude
} }
// GetLaunchLongitude returns the value of LaunchLongitude. // GetLaunchLongitude returns the value of LaunchLongitude.
func (s *Parameters) GetLaunchLongitude() OptFloat64 { func (s *PredictionParameters) GetLaunchLongitude() OptFloat64 {
return s.LaunchLongitude return s.LaunchLongitude
} }
// GetLaunchDatetime returns the value of LaunchDatetime. // GetLaunchDatetime returns the value of LaunchDatetime.
func (s *Parameters) GetLaunchDatetime() OptDateTime { func (s *PredictionParameters) GetLaunchDatetime() OptDateTime {
return s.LaunchDatetime return s.LaunchDatetime
} }
// GetLaunchAltitude returns the value of LaunchAltitude. // GetLaunchAltitude returns the value of LaunchAltitude.
func (s *Parameters) GetLaunchAltitude() OptFloat64 { func (s *PredictionParameters) GetLaunchAltitude() OptFloat64 {
return s.LaunchAltitude return s.LaunchAltitude
} }
// GetProfile returns the value of Profile. // GetProfile returns the value of Profile.
func (s *Parameters) GetProfile() OptParametersProfile { func (s *PredictionParameters) GetProfile() OptPredictionParametersProfile {
return s.Profile return s.Profile
} }
// GetAscentRate returns the value of AscentRate. // GetAscentRate returns the value of AscentRate.
func (s *Parameters) GetAscentRate() OptFloat64 { func (s *PredictionParameters) GetAscentRate() OptFloat64 {
return s.AscentRate return s.AscentRate
} }
// GetBurstAltitude returns the value of BurstAltitude. // GetBurstAltitude returns the value of BurstAltitude.
func (s *Parameters) GetBurstAltitude() OptFloat64 { func (s *PredictionParameters) GetBurstAltitude() OptFloat64 {
return s.BurstAltitude return s.BurstAltitude
} }
// GetDescentRate returns the value of DescentRate. // GetDescentRate returns the value of DescentRate.
func (s *Parameters) GetDescentRate() OptFloat64 { func (s *PredictionParameters) GetDescentRate() OptFloat64 {
return s.DescentRate return s.DescentRate
} }
// GetFloatAltitude returns the value of FloatAltitude. // GetFloatAltitude returns the value of FloatAltitude.
func (s *Parameters) GetFloatAltitude() OptFloat64 { func (s *PredictionParameters) GetFloatAltitude() OptFloat64 {
return s.FloatAltitude return s.FloatAltitude
} }
// GetStopDatetime returns the value of StopDatetime. // GetStopDatetime returns the value of StopDatetime.
func (s *Parameters) GetStopDatetime() OptDateTime { func (s *PredictionParameters) GetStopDatetime() OptDateTime {
return s.StopDatetime return s.StopDatetime
} }
// GetAscentCurve returns the value of AscentCurve. // GetAscentCurve returns the value of AscentCurve.
func (s *Parameters) GetAscentCurve() OptString { func (s *PredictionParameters) GetAscentCurve() OptString {
return s.AscentCurve return s.AscentCurve
} }
// GetDescentCurve returns the value of DescentCurve. // GetDescentCurve returns the value of DescentCurve.
func (s *Parameters) GetDescentCurve() OptString { func (s *PredictionParameters) GetDescentCurve() OptString {
return s.DescentCurve return s.DescentCurve
} }
// GetInterpolate returns the value of Interpolate. // GetInterpolate returns the value of Interpolate.
func (s *Parameters) GetInterpolate() OptBool { func (s *PredictionParameters) GetInterpolate() OptBool {
return s.Interpolate return s.Interpolate
} }
// GetFormat returns the value of Format. // GetFormat returns the value of Format.
func (s *Parameters) GetFormat() OptParametersFormat { func (s *PredictionParameters) GetFormat() OptPredictionParametersFormat {
return s.Format return s.Format
} }
// GetDataset returns the value of Dataset. // GetDataset returns the value of Dataset.
func (s *Parameters) GetDataset() OptDateTime { func (s *PredictionParameters) GetDataset() OptDateTime {
return s.Dataset return s.Dataset
} }
// SetLaunchLatitude sets the value of LaunchLatitude. // SetLaunchLatitude sets the value of LaunchLatitude.
func (s *Parameters) SetLaunchLatitude(val OptFloat64) { func (s *PredictionParameters) SetLaunchLatitude(val OptFloat64) {
s.LaunchLatitude = val s.LaunchLatitude = val
} }
// SetLaunchLongitude sets the value of LaunchLongitude. // SetLaunchLongitude sets the value of LaunchLongitude.
func (s *Parameters) SetLaunchLongitude(val OptFloat64) { func (s *PredictionParameters) SetLaunchLongitude(val OptFloat64) {
s.LaunchLongitude = val s.LaunchLongitude = val
} }
// SetLaunchDatetime sets the value of LaunchDatetime. // SetLaunchDatetime sets the value of LaunchDatetime.
func (s *Parameters) SetLaunchDatetime(val OptDateTime) { func (s *PredictionParameters) SetLaunchDatetime(val OptDateTime) {
s.LaunchDatetime = val s.LaunchDatetime = val
} }
// SetLaunchAltitude sets the value of LaunchAltitude. // SetLaunchAltitude sets the value of LaunchAltitude.
func (s *Parameters) SetLaunchAltitude(val OptFloat64) { func (s *PredictionParameters) SetLaunchAltitude(val OptFloat64) {
s.LaunchAltitude = val s.LaunchAltitude = val
} }
// SetProfile sets the value of Profile. // SetProfile sets the value of Profile.
func (s *Parameters) SetProfile(val OptParametersProfile) { func (s *PredictionParameters) SetProfile(val OptPredictionParametersProfile) {
s.Profile = val s.Profile = val
} }
// SetAscentRate sets the value of AscentRate. // SetAscentRate sets the value of AscentRate.
func (s *Parameters) SetAscentRate(val OptFloat64) { func (s *PredictionParameters) SetAscentRate(val OptFloat64) {
s.AscentRate = val s.AscentRate = val
} }
// SetBurstAltitude sets the value of BurstAltitude. // SetBurstAltitude sets the value of BurstAltitude.
func (s *Parameters) SetBurstAltitude(val OptFloat64) { func (s *PredictionParameters) SetBurstAltitude(val OptFloat64) {
s.BurstAltitude = val s.BurstAltitude = val
} }
// SetDescentRate sets the value of DescentRate. // SetDescentRate sets the value of DescentRate.
func (s *Parameters) SetDescentRate(val OptFloat64) { func (s *PredictionParameters) SetDescentRate(val OptFloat64) {
s.DescentRate = val s.DescentRate = val
} }
// SetFloatAltitude sets the value of FloatAltitude. // SetFloatAltitude sets the value of FloatAltitude.
func (s *Parameters) SetFloatAltitude(val OptFloat64) { func (s *PredictionParameters) SetFloatAltitude(val OptFloat64) {
s.FloatAltitude = val s.FloatAltitude = val
} }
// SetStopDatetime sets the value of StopDatetime. // SetStopDatetime sets the value of StopDatetime.
func (s *Parameters) SetStopDatetime(val OptDateTime) { func (s *PredictionParameters) SetStopDatetime(val OptDateTime) {
s.StopDatetime = val s.StopDatetime = val
} }
// SetAscentCurve sets the value of AscentCurve. // SetAscentCurve sets the value of AscentCurve.
func (s *Parameters) SetAscentCurve(val OptString) { func (s *PredictionParameters) SetAscentCurve(val OptString) {
s.AscentCurve = val s.AscentCurve = val
} }
// SetDescentCurve sets the value of DescentCurve. // SetDescentCurve sets the value of DescentCurve.
func (s *Parameters) SetDescentCurve(val OptString) { func (s *PredictionParameters) SetDescentCurve(val OptString) {
s.DescentCurve = val s.DescentCurve = val
} }
// SetInterpolate sets the value of Interpolate. // SetInterpolate sets the value of Interpolate.
func (s *Parameters) SetInterpolate(val OptBool) { func (s *PredictionParameters) SetInterpolate(val OptBool) {
s.Interpolate = val s.Interpolate = val
} }
// SetFormat sets the value of Format. // SetFormat sets the value of Format.
func (s *Parameters) SetFormat(val OptParametersFormat) { func (s *PredictionParameters) SetFormat(val OptPredictionParametersFormat) {
s.Format = val s.Format = val
} }
// SetDataset sets the value of Dataset. // SetDataset sets the value of Dataset.
func (s *Parameters) SetDataset(val OptDateTime) { func (s *PredictionParameters) SetDataset(val OptDateTime) {
s.Dataset = val s.Dataset = val
} }
type ParametersFormat string type PredictionParametersFormat string
const ( const (
ParametersFormatJSON ParametersFormat = "json" PredictionParametersFormatJSON PredictionParametersFormat = "json"
) )
// AllValues returns all ParametersFormat values. // AllValues returns all PredictionParametersFormat values.
func (ParametersFormat) AllValues() []ParametersFormat { func (PredictionParametersFormat) AllValues() []PredictionParametersFormat {
return []ParametersFormat{ return []PredictionParametersFormat{
ParametersFormatJSON, PredictionParametersFormatJSON,
} }
} }
// MarshalText implements encoding.TextMarshaler. // MarshalText implements encoding.TextMarshaler.
func (s ParametersFormat) MarshalText() ([]byte, error) { func (s PredictionParametersFormat) MarshalText() ([]byte, error) {
switch s { switch s {
case ParametersFormatJSON: case PredictionParametersFormatJSON:
return []byte(s), nil return []byte(s), nil
default: default:
return nil, errors.Errorf("invalid value: %q", s) return nil, errors.Errorf("invalid value: %q", s)
@ -582,45 +582,45 @@ func (s ParametersFormat) MarshalText() ([]byte, error) {
} }
// UnmarshalText implements encoding.TextUnmarshaler. // UnmarshalText implements encoding.TextUnmarshaler.
func (s *ParametersFormat) UnmarshalText(data []byte) error { func (s *PredictionParametersFormat) UnmarshalText(data []byte) error {
switch ParametersFormat(data) { switch PredictionParametersFormat(data) {
case ParametersFormatJSON: case PredictionParametersFormatJSON:
*s = ParametersFormatJSON *s = PredictionParametersFormatJSON
return nil return nil
default: default:
return errors.Errorf("invalid value: %q", data) return errors.Errorf("invalid value: %q", data)
} }
} }
type ParametersProfile string type PredictionParametersProfile string
const ( const (
ParametersProfileStandardProfile ParametersProfile = "standard_profile" PredictionParametersProfileStandardProfile PredictionParametersProfile = "standard_profile"
ParametersProfileFloatProfile ParametersProfile = "float_profile" PredictionParametersProfileFloatProfile PredictionParametersProfile = "float_profile"
ParametersProfileReverseProfile ParametersProfile = "reverse_profile" PredictionParametersProfileReverseProfile PredictionParametersProfile = "reverse_profile"
ParametersProfileCustomProfile ParametersProfile = "custom_profile" PredictionParametersProfileCustomProfile PredictionParametersProfile = "custom_profile"
) )
// AllValues returns all ParametersProfile values. // AllValues returns all PredictionParametersProfile values.
func (ParametersProfile) AllValues() []ParametersProfile { func (PredictionParametersProfile) AllValues() []PredictionParametersProfile {
return []ParametersProfile{ return []PredictionParametersProfile{
ParametersProfileStandardProfile, PredictionParametersProfileStandardProfile,
ParametersProfileFloatProfile, PredictionParametersProfileFloatProfile,
ParametersProfileReverseProfile, PredictionParametersProfileReverseProfile,
ParametersProfileCustomProfile, PredictionParametersProfileCustomProfile,
} }
} }
// MarshalText implements encoding.TextMarshaler. // MarshalText implements encoding.TextMarshaler.
func (s ParametersProfile) MarshalText() ([]byte, error) { func (s PredictionParametersProfile) MarshalText() ([]byte, error) {
switch s { switch s {
case ParametersProfileStandardProfile: case PredictionParametersProfileStandardProfile:
return []byte(s), nil return []byte(s), nil
case ParametersProfileFloatProfile: case PredictionParametersProfileFloatProfile:
return []byte(s), nil return []byte(s), nil
case ParametersProfileReverseProfile: case PredictionParametersProfileReverseProfile:
return []byte(s), nil return []byte(s), nil
case ParametersProfileCustomProfile: case PredictionParametersProfileCustomProfile:
return []byte(s), nil return []byte(s), nil
default: default:
return nil, errors.Errorf("invalid value: %q", s) return nil, errors.Errorf("invalid value: %q", s)
@ -628,122 +628,122 @@ func (s ParametersProfile) MarshalText() ([]byte, error) {
} }
// UnmarshalText implements encoding.TextUnmarshaler. // UnmarshalText implements encoding.TextUnmarshaler.
func (s *ParametersProfile) UnmarshalText(data []byte) error { func (s *PredictionParametersProfile) UnmarshalText(data []byte) error {
switch ParametersProfile(data) { switch PredictionParametersProfile(data) {
case ParametersProfileStandardProfile: case PredictionParametersProfileStandardProfile:
*s = ParametersProfileStandardProfile *s = PredictionParametersProfileStandardProfile
return nil return nil
case ParametersProfileFloatProfile: case PredictionParametersProfileFloatProfile:
*s = ParametersProfileFloatProfile *s = PredictionParametersProfileFloatProfile
return nil return nil
case ParametersProfileReverseProfile: case PredictionParametersProfileReverseProfile:
*s = ParametersProfileReverseProfile *s = PredictionParametersProfileReverseProfile
return nil return nil
case ParametersProfileCustomProfile: case PredictionParametersProfileCustomProfile:
*s = ParametersProfileCustomProfile *s = PredictionParametersProfileCustomProfile
return nil return nil
default: default:
return errors.Errorf("invalid value: %q", data) return errors.Errorf("invalid value: %q", data)
} }
} }
// Ref: #/components/schemas/Prediction/Result // Ref: #/components/schemas/PredictionResult
type Result struct { type PredictionResult struct {
Metadata ResultMetadata `json:"metadata"` Metadata PredictionResultMetadata `json:"metadata"`
Prediction []ResultPredictionItem `json:"prediction"` Prediction []PredictionResultPredictionItem `json:"prediction"`
} }
// GetMetadata returns the value of Metadata. // GetMetadata returns the value of Metadata.
func (s *Result) GetMetadata() ResultMetadata { func (s *PredictionResult) GetMetadata() PredictionResultMetadata {
return s.Metadata return s.Metadata
} }
// GetPrediction returns the value of Prediction. // GetPrediction returns the value of Prediction.
func (s *Result) GetPrediction() []ResultPredictionItem { func (s *PredictionResult) GetPrediction() []PredictionResultPredictionItem {
return s.Prediction return s.Prediction
} }
// SetMetadata sets the value of Metadata. // SetMetadata sets the value of Metadata.
func (s *Result) SetMetadata(val ResultMetadata) { func (s *PredictionResult) SetMetadata(val PredictionResultMetadata) {
s.Metadata = val s.Metadata = val
} }
// SetPrediction sets the value of Prediction. // SetPrediction sets the value of Prediction.
func (s *Result) SetPrediction(val []ResultPredictionItem) { func (s *PredictionResult) SetPrediction(val []PredictionResultPredictionItem) {
s.Prediction = val s.Prediction = val
} }
type ResultMetadata struct { type PredictionResultMetadata struct {
CompleteDatetime time.Time `json:"complete_datetime"` CompleteDatetime time.Time `json:"complete_datetime"`
StartDatetime time.Time `json:"start_datetime"` StartDatetime time.Time `json:"start_datetime"`
} }
// GetCompleteDatetime returns the value of CompleteDatetime. // GetCompleteDatetime returns the value of CompleteDatetime.
func (s *ResultMetadata) GetCompleteDatetime() time.Time { func (s *PredictionResultMetadata) GetCompleteDatetime() time.Time {
return s.CompleteDatetime return s.CompleteDatetime
} }
// GetStartDatetime returns the value of StartDatetime. // GetStartDatetime returns the value of StartDatetime.
func (s *ResultMetadata) GetStartDatetime() time.Time { func (s *PredictionResultMetadata) GetStartDatetime() time.Time {
return s.StartDatetime return s.StartDatetime
} }
// SetCompleteDatetime sets the value of CompleteDatetime. // SetCompleteDatetime sets the value of CompleteDatetime.
func (s *ResultMetadata) SetCompleteDatetime(val time.Time) { func (s *PredictionResultMetadata) SetCompleteDatetime(val time.Time) {
s.CompleteDatetime = val s.CompleteDatetime = val
} }
// SetStartDatetime sets the value of StartDatetime. // SetStartDatetime sets the value of StartDatetime.
func (s *ResultMetadata) SetStartDatetime(val time.Time) { func (s *PredictionResultMetadata) SetStartDatetime(val time.Time) {
s.StartDatetime = val s.StartDatetime = val
} }
type ResultPredictionItem struct { type PredictionResultPredictionItem struct {
Stage ResultPredictionItemStage `json:"stage"` Stage PredictionResultPredictionItemStage `json:"stage"`
Trajectory []ResultPredictionItemTrajectoryItem `json:"trajectory"` Trajectory []PredictionResultPredictionItemTrajectoryItem `json:"trajectory"`
} }
// GetStage returns the value of Stage. // GetStage returns the value of Stage.
func (s *ResultPredictionItem) GetStage() ResultPredictionItemStage { func (s *PredictionResultPredictionItem) GetStage() PredictionResultPredictionItemStage {
return s.Stage return s.Stage
} }
// GetTrajectory returns the value of Trajectory. // GetTrajectory returns the value of Trajectory.
func (s *ResultPredictionItem) GetTrajectory() []ResultPredictionItemTrajectoryItem { func (s *PredictionResultPredictionItem) GetTrajectory() []PredictionResultPredictionItemTrajectoryItem {
return s.Trajectory return s.Trajectory
} }
// SetStage sets the value of Stage. // SetStage sets the value of Stage.
func (s *ResultPredictionItem) SetStage(val ResultPredictionItemStage) { func (s *PredictionResultPredictionItem) SetStage(val PredictionResultPredictionItemStage) {
s.Stage = val s.Stage = val
} }
// SetTrajectory sets the value of Trajectory. // SetTrajectory sets the value of Trajectory.
func (s *ResultPredictionItem) SetTrajectory(val []ResultPredictionItemTrajectoryItem) { func (s *PredictionResultPredictionItem) SetTrajectory(val []PredictionResultPredictionItemTrajectoryItem) {
s.Trajectory = val s.Trajectory = val
} }
type ResultPredictionItemStage string type PredictionResultPredictionItemStage string
const ( const (
ResultPredictionItemStageAscent ResultPredictionItemStage = "ascent" PredictionResultPredictionItemStageAscent PredictionResultPredictionItemStage = "ascent"
ResultPredictionItemStageDescent ResultPredictionItemStage = "descent" PredictionResultPredictionItemStageDescent PredictionResultPredictionItemStage = "descent"
) )
// AllValues returns all ResultPredictionItemStage values. // AllValues returns all PredictionResultPredictionItemStage values.
func (ResultPredictionItemStage) AllValues() []ResultPredictionItemStage { func (PredictionResultPredictionItemStage) AllValues() []PredictionResultPredictionItemStage {
return []ResultPredictionItemStage{ return []PredictionResultPredictionItemStage{
ResultPredictionItemStageAscent, PredictionResultPredictionItemStageAscent,
ResultPredictionItemStageDescent, PredictionResultPredictionItemStageDescent,
} }
} }
// MarshalText implements encoding.TextMarshaler. // MarshalText implements encoding.TextMarshaler.
func (s ResultPredictionItemStage) MarshalText() ([]byte, error) { func (s PredictionResultPredictionItemStage) MarshalText() ([]byte, error) {
switch s { switch s {
case ResultPredictionItemStageAscent: case PredictionResultPredictionItemStageAscent:
return []byte(s), nil return []byte(s), nil
case ResultPredictionItemStageDescent: case PredictionResultPredictionItemStageDescent:
return []byte(s), nil return []byte(s), nil
default: default:
return nil, errors.Errorf("invalid value: %q", s) return nil, errors.Errorf("invalid value: %q", s)
@ -751,17 +751,17 @@ func (s ResultPredictionItemStage) MarshalText() ([]byte, error) {
} }
// UnmarshalText implements encoding.TextUnmarshaler. // UnmarshalText implements encoding.TextUnmarshaler.
func (s *ResultPredictionItemStage) UnmarshalText(data []byte) error { func (s *PredictionResultPredictionItemStage) UnmarshalText(data []byte) error {
switch ResultPredictionItemStage(data) { switch PredictionResultPredictionItemStage(data) {
case ResultPredictionItemStageAscent: case PredictionResultPredictionItemStageAscent:
*s = ResultPredictionItemStageAscent *s = PredictionResultPredictionItemStageAscent
return nil return nil
case ResultPredictionItemStageDescent: case PredictionResultPredictionItemStageDescent:
*s = ResultPredictionItemStageDescent *s = PredictionResultPredictionItemStageDescent
return nil return nil
default: default:
return errors.Errorf("invalid value: %q", data) return errors.Errorf("invalid value: %q", data)
} }
} }
type ResultPredictionItemTrajectoryItem struct{} type PredictionResultPredictionItemTrajectoryItem struct{}

View file

@ -13,7 +13,7 @@ type Handler interface {
// Perform preidction. // Perform preidction.
// //
// POST /api/v1/prediction // POST /api/v1/prediction
PerformPrediction(ctx context.Context, req OptParameters, params PerformPredictionParams) (*Result, error) PerformPrediction(ctx context.Context, req OptPredictionParameters, params PerformPredictionParams) (*PredictionResult, error)
// NewError creates *ErrorStatusCode from error returned by handler. // NewError creates *ErrorStatusCode from error returned by handler.
// //
// Used for common default response. // Used for common default response.

View file

@ -18,7 +18,7 @@ var _ Handler = UnimplementedHandler{}
// Perform preidction. // Perform preidction.
// //
// POST /api/v1/prediction // POST /api/v1/prediction
func (UnimplementedHandler) PerformPrediction(ctx context.Context, req OptParameters, params PerformPredictionParams) (r *Result, _ error) { func (UnimplementedHandler) PerformPrediction(ctx context.Context, req OptPredictionParameters, params PerformPredictionParams) (r *PredictionResult, _ error) {
return r, ht.ErrNotImplemented return r, ht.ErrNotImplemented
} }

View file

@ -11,8 +11,8 @@ import (
"github.com/ogen-go/ogen/uri" "github.com/ogen-go/ogen/uri"
) )
// EncodeURI encodes Parameters as URI form. // EncodeURI encodes PredictionParameters as URI form.
func (s *Parameters) EncodeURI(e uri.Encoder) error { func (s *PredictionParameters) EncodeURI(e uri.Encoder) error {
if err := e.EncodeField("launch_latitude", func(e uri.Encoder) error { if err := e.EncodeField("launch_latitude", func(e uri.Encoder) error {
if val, ok := s.LaunchLatitude.Get(); ok { if val, ok := s.LaunchLatitude.Get(); ok {
return e.EncodeValue(conv.Float64ToString(val)) return e.EncodeValue(conv.Float64ToString(val))
@ -136,7 +136,7 @@ func (s *Parameters) EncodeURI(e uri.Encoder) error {
return nil return nil
} }
var uriFieldsNameOfParameters = [15]string{ var uriFieldsNameOfPredictionParameters = [15]string{
0: "launch_latitude", 0: "launch_latitude",
1: "launch_longitude", 1: "launch_longitude",
2: "launch_datetime", 2: "launch_datetime",
@ -154,10 +154,10 @@ var uriFieldsNameOfParameters = [15]string{
14: "dataset", 14: "dataset",
} }
// DecodeURI decodes Parameters from URI form. // DecodeURI decodes PredictionParameters from URI form.
func (s *Parameters) DecodeURI(d uri.Decoder) error { func (s *PredictionParameters) DecodeURI(d uri.Decoder) error {
if s == nil { if s == nil {
return errors.New("invalid: unable to decode Parameters to nil") return errors.New("invalid: unable to decode PredictionParameters to nil")
} }
s.setDefaults() s.setDefaults()
@ -261,7 +261,7 @@ func (s *Parameters) DecodeURI(d uri.Decoder) error {
} }
case "profile": case "profile":
if err := func() error { if err := func() error {
var sDotProfileVal ParametersProfile var sDotProfileVal PredictionParametersProfile
if err := func() error { if err := func() error {
val, err := d.DecodeValue() val, err := d.DecodeValue()
if err != nil { if err != nil {
@ -273,7 +273,7 @@ func (s *Parameters) DecodeURI(d uri.Decoder) error {
return err return err
} }
sDotProfileVal = ParametersProfile(c) sDotProfileVal = PredictionParametersProfile(c)
return nil return nil
}(); err != nil { }(); err != nil {
return err return err
@ -477,7 +477,7 @@ func (s *Parameters) DecodeURI(d uri.Decoder) error {
} }
case "format": case "format":
if err := func() error { if err := func() error {
var sDotFormatVal ParametersFormat var sDotFormatVal PredictionParametersFormat
if err := func() error { if err := func() error {
val, err := d.DecodeValue() val, err := d.DecodeValue()
if err != nil { if err != nil {
@ -489,7 +489,7 @@ func (s *Parameters) DecodeURI(d uri.Decoder) error {
return err return err
} }
sDotFormatVal = ParametersFormat(c) sDotFormatVal = PredictionParametersFormat(c)
return nil return nil
}(); err != nil { }(); err != nil {
return err return err
@ -528,7 +528,7 @@ func (s *Parameters) DecodeURI(d uri.Decoder) error {
} }
return nil return nil
}); err != nil { }); err != nil {
return errors.Wrap(err, "decode Parameters") return errors.Wrap(err, "decode PredictionParameters")
} }
return nil return nil

View file

@ -10,7 +10,7 @@ import (
"github.com/ogen-go/ogen/validate" "github.com/ogen-go/ogen/validate"
) )
func (s *Parameters) Validate() error { func (s *PredictionParameters) Validate() error {
if s == nil { if s == nil {
return validate.ErrNilPointer return validate.ErrNilPointer
} }
@ -184,7 +184,7 @@ func (s *Parameters) Validate() error {
return nil return nil
} }
func (s ParametersFormat) Validate() error { func (s PredictionParametersFormat) Validate() error {
switch s { switch s {
case "json": case "json":
return nil return nil
@ -193,7 +193,7 @@ func (s ParametersFormat) Validate() error {
} }
} }
func (s ParametersProfile) Validate() error { func (s PredictionParametersProfile) Validate() error {
switch s { switch s {
case "standard_profile": case "standard_profile":
return nil return nil
@ -208,7 +208,7 @@ func (s ParametersProfile) Validate() error {
} }
} }
func (s *Result) Validate() error { func (s *PredictionResult) Validate() error {
if s == nil { if s == nil {
return validate.ErrNilPointer return validate.ErrNilPointer
} }
@ -248,7 +248,7 @@ func (s *Result) Validate() error {
return nil return nil
} }
func (s *ResultPredictionItem) Validate() error { func (s *PredictionResultPredictionItem) Validate() error {
if s == nil { if s == nil {
return validate.ErrNilPointer return validate.ErrNilPointer
} }
@ -282,7 +282,7 @@ func (s *ResultPredictionItem) Validate() error {
return nil return nil
} }
func (s ResultPredictionItemStage) Validate() error { func (s PredictionResultPredictionItemStage) Validate() error {
switch s { switch s {
case "ascent": case "ascent":
return nil return nil