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
required: false
schema:
$ref: '#/components/schemas/Prediction/Parameters'
$ref: '#/components/schemas/PredictionParameters'
style: form
explode: true
requestBody:
@ -22,14 +22,14 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Prediction/Parameters'
$ref: '#/components/schemas/PredictionParameters'
responses:
"200":
description: "Prediction response"
content:
application/json:
schema:
$ref: '#/components/schemas/Prediction/Result'
$ref: '#/components/schemas/PredictionResult'
default:
description: Error
content:
@ -48,8 +48,7 @@ components:
type: string
details:
type: string
Prediction:
Parameters:
PredictionParameters:
type: object
properties:
launch_latitude: # TODO: altitude not required with fallback to https://github.com/priyeshpatel/ruaumoko Go analog
@ -91,7 +90,7 @@ components:
dataset:
type: string
format: date-time
Result: #
PredictionResult:
type: object
required:
- 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
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.
//
// 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.
@ -87,12 +87,12 @@ func (c *Client) requestURL(ctx context.Context) *url.URL {
// Perform preidction.
//
// 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)
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{
otelogen.OperationID("performPrediction"),
semconv.HTTPRequestMethodKey.String("POST"),

View file

@ -3,13 +3,13 @@
package gsn
// setDefaults set default value of fields.
func (s *Parameters) setDefaults() {
func (s *PredictionParameters) setDefaults() {
{
val := bool(false)
s.Interpolate.SetTo(val)
}
{
val := ParametersFormat("json")
val := PredictionParametersFormat("json")
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 {
mreq := middleware.Request{
Context: ctx,
@ -148,9 +148,9 @@ func (s *Server) handlePerformPredictionRequest(args [0]string, argsEscaped bool
}
type (
Request = OptParameters
Request = OptPredictionParameters
Params = PerformPredictionParams
Response = *Result
Response = *PredictionResult
)
response, err = middleware.HookMiddleware[
Request,

View file

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

View file

@ -12,7 +12,7 @@ import (
// PerformPredictionParams is parameters of performPrediction operation.
type PerformPredictionParams struct {
Parameters OptParameters
Parameters OptPredictionParameters
}
func unpackPerformPredictionParams(packed middleware.Parameters) (params PerformPredictionParams) {
@ -22,7 +22,7 @@ func unpackPerformPredictionParams(packed middleware.Parameters) (params Perform
In: "query",
}
if v, ok := packed[key]; ok {
params.Parameters = v.(OptParameters)
params.Parameters = v.(OptPredictionParameters)
}
}
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.DecodeParam(cfg, func(d uri.Decoder) error {
var paramsDotParametersVal Parameters
var paramsDotParametersVal PredictionParameters
if err := func() error {
return paramsDotParametersVal.DecodeURI(d)
}(); err != nil {

View file

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

View file

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

View file

@ -14,7 +14,7 @@ import (
"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 {
case 200:
// Code 200.
@ -30,7 +30,7 @@ func decodePerformPredictionResponse(resp *http.Response) (res *Result, _ error)
}
d := jx.DecodeBytes(buf)
var response Result
var response PredictionResult
if err := func() error {
if err := response.Decode(d); err != nil {
return err

View file

@ -13,7 +13,7 @@ import (
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.WriteHeader(200)
span.SetStatus(codes.Ok, http.StatusText(200))

View file

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

View file

@ -13,7 +13,7 @@ type Handler interface {
// Perform preidction.
//
// 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.
//
// Used for common default response.

View file

@ -18,7 +18,7 @@ var _ Handler = UnimplementedHandler{}
// Perform preidction.
//
// 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
}

View file

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

View file

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