rewrite
This commit is contained in:
parent
c4f355a32e
commit
7a8d5d13fa
72 changed files with 4510 additions and 4104 deletions
|
|
@ -1,18 +1,19 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"strings"
|
||||
|
||||
ht "github.com/ogen-go/ogen/http"
|
||||
"github.com/ogen-go/ogen/middleware"
|
||||
"github.com/ogen-go/ogen/ogenerrors"
|
||||
"github.com/ogen-go/ogen/otelogen"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -32,6 +33,7 @@ type otelConfig struct {
|
|||
Tracer trace.Tracer
|
||||
MeterProvider metric.MeterProvider
|
||||
Meter metric.Meter
|
||||
Attributes []attribute.KeyValue
|
||||
}
|
||||
|
||||
func (cfg *otelConfig) initOTEL() {
|
||||
|
|
@ -81,18 +83,8 @@ func (o otelOptionFunc) applyServer(c *serverConfig) {
|
|||
|
||||
func newServerConfig(opts ...ServerOption) serverConfig {
|
||||
cfg := serverConfig{
|
||||
NotFound: http.NotFound,
|
||||
MethodNotAllowed: func(w http.ResponseWriter, r *http.Request, allowed string) {
|
||||
status := http.StatusMethodNotAllowed
|
||||
if r.Method == "OPTIONS" {
|
||||
w.Header().Set("Access-Control-Allow-Methods", allowed)
|
||||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
|
||||
status = http.StatusNoContent
|
||||
} else {
|
||||
w.Header().Set("Allow", allowed)
|
||||
}
|
||||
w.WriteHeader(status)
|
||||
},
|
||||
NotFound: http.NotFound,
|
||||
MethodNotAllowed: nil,
|
||||
ErrorHandler: ogenerrors.DefaultErrorHandler,
|
||||
Middleware: nil,
|
||||
MaxMultipartMemory: 32 << 20, // 32 MB
|
||||
|
|
@ -115,8 +107,44 @@ func (s baseServer) notFound(w http.ResponseWriter, r *http.Request) {
|
|||
s.cfg.NotFound(w, r)
|
||||
}
|
||||
|
||||
func (s baseServer) notAllowed(w http.ResponseWriter, r *http.Request, allowed string) {
|
||||
s.cfg.MethodNotAllowed(w, r, allowed)
|
||||
type notAllowedParams struct {
|
||||
allowedMethods string
|
||||
allowedHeaders map[string]string
|
||||
acceptPost string
|
||||
acceptPatch string
|
||||
}
|
||||
|
||||
func (s baseServer) notAllowed(w http.ResponseWriter, r *http.Request, params notAllowedParams) {
|
||||
h := w.Header()
|
||||
isOptions := r.Method == "OPTIONS"
|
||||
if isOptions {
|
||||
h.Set("Access-Control-Allow-Methods", params.allowedMethods)
|
||||
if params.allowedHeaders != nil {
|
||||
m := r.Header.Get("Access-Control-Request-Method")
|
||||
if m != "" {
|
||||
allowedHeaders, ok := params.allowedHeaders[strings.ToUpper(m)]
|
||||
if ok {
|
||||
h.Set("Access-Control-Allow-Headers", allowedHeaders)
|
||||
}
|
||||
}
|
||||
}
|
||||
if params.acceptPost != "" {
|
||||
h.Set("Accept-Post", params.acceptPost)
|
||||
}
|
||||
if params.acceptPatch != "" {
|
||||
h.Set("Accept-Patch", params.acceptPatch)
|
||||
}
|
||||
}
|
||||
if s.cfg.MethodNotAllowed != nil {
|
||||
s.cfg.MethodNotAllowed(w, r, params.allowedMethods)
|
||||
return
|
||||
}
|
||||
status := http.StatusNoContent
|
||||
if !isOptions {
|
||||
h.Set("Allow", params.allowedMethods)
|
||||
status = http.StatusMethodNotAllowed
|
||||
}
|
||||
w.WriteHeader(status)
|
||||
}
|
||||
|
||||
func (cfg serverConfig) baseServer() (s baseServer, err error) {
|
||||
|
|
@ -215,6 +243,13 @@ func WithMeterProvider(provider metric.MeterProvider) Option {
|
|||
})
|
||||
}
|
||||
|
||||
// WithAttributes specifies default otel attributes.
|
||||
func WithAttributes(attributes ...attribute.KeyValue) Option {
|
||||
return otelOptionFunc(func(cfg *otelConfig) {
|
||||
cfg.Attributes = attributes
|
||||
})
|
||||
}
|
||||
|
||||
// WithClient specifies http client to use.
|
||||
func WithClient(client ht.Client) ClientOption {
|
||||
return optionFunc[clientConfig](func(cfg *clientConfig) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -9,16 +9,15 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-faster/errors"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"github.com/ogen-go/ogen/conv"
|
||||
ht "github.com/ogen-go/ogen/http"
|
||||
"github.com/ogen-go/ogen/otelogen"
|
||||
"github.com/ogen-go/ogen/uri"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.39.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
func trimTrailingSlashes(u *url.URL) {
|
||||
|
|
@ -33,7 +32,7 @@ type Invoker interface {
|
|||
// Perform prediction.
|
||||
//
|
||||
// GET /api/v1/prediction
|
||||
PerformPrediction(ctx context.Context, params PerformPredictionParams) (*PredictionResult, error)
|
||||
PerformPrediction(ctx context.Context, params PerformPredictionParams) (*PredictionResponse, error)
|
||||
// ReadinessCheck invokes readinessCheck operation.
|
||||
//
|
||||
// Readiness check.
|
||||
|
|
@ -47,14 +46,6 @@ type Client struct {
|
|||
serverURL *url.URL
|
||||
baseClient
|
||||
}
|
||||
type errorHandler interface {
|
||||
NewError(ctx context.Context, err error) *ErrorStatusCode
|
||||
}
|
||||
|
||||
var _ Handler = struct {
|
||||
errorHandler
|
||||
*Client
|
||||
}{}
|
||||
|
||||
// NewClient initializes new Client defined by OAS.
|
||||
func NewClient(serverURL string, opts ...ClientOption) (*Client, error) {
|
||||
|
|
@ -94,17 +85,18 @@ func (c *Client) requestURL(ctx context.Context) *url.URL {
|
|||
// Perform prediction.
|
||||
//
|
||||
// GET /api/v1/prediction
|
||||
func (c *Client) PerformPrediction(ctx context.Context, params PerformPredictionParams) (*PredictionResult, error) {
|
||||
func (c *Client) PerformPrediction(ctx context.Context, params PerformPredictionParams) (*PredictionResponse, error) {
|
||||
res, err := c.sendPerformPrediction(ctx, params)
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *Client) sendPerformPrediction(ctx context.Context, params PerformPredictionParams) (res *PredictionResult, err error) {
|
||||
func (c *Client) sendPerformPrediction(ctx context.Context, params PerformPredictionParams) (res *PredictionResponse, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("performPrediction"),
|
||||
semconv.HTTPRequestMethodKey.String("GET"),
|
||||
semconv.HTTPRouteKey.String("/api/v1/prediction"),
|
||||
semconv.URLTemplateKey.String("/api/v1/prediction"),
|
||||
}
|
||||
otelAttrs = append(otelAttrs, c.cfg.Attributes...)
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
|
|
@ -150,10 +142,7 @@ func (c *Client) sendPerformPrediction(ctx context.Context, params PerformPredic
|
|||
}
|
||||
|
||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := params.LaunchLatitude.Get(); ok {
|
||||
return e.EncodeValue(conv.Float64ToString(val))
|
||||
}
|
||||
return nil
|
||||
return e.EncodeValue(conv.Float64ToString(params.LaunchLatitude))
|
||||
}); err != nil {
|
||||
return res, errors.Wrap(err, "encode query")
|
||||
}
|
||||
|
|
@ -167,10 +156,7 @@ func (c *Client) sendPerformPrediction(ctx context.Context, params PerformPredic
|
|||
}
|
||||
|
||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := params.LaunchLongitude.Get(); ok {
|
||||
return e.EncodeValue(conv.Float64ToString(val))
|
||||
}
|
||||
return nil
|
||||
return e.EncodeValue(conv.Float64ToString(params.LaunchLongitude))
|
||||
}); err != nil {
|
||||
return res, errors.Wrap(err, "encode query")
|
||||
}
|
||||
|
|
@ -184,10 +170,7 @@ func (c *Client) sendPerformPrediction(ctx context.Context, params PerformPredic
|
|||
}
|
||||
|
||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := params.LaunchDatetime.Get(); ok {
|
||||
return e.EncodeValue(conv.DateTimeToString(val))
|
||||
}
|
||||
return nil
|
||||
return e.EncodeValue(conv.DateTimeToString(params.LaunchDatetime))
|
||||
}); err != nil {
|
||||
return res, errors.Wrap(err, "encode query")
|
||||
}
|
||||
|
|
@ -311,74 +294,6 @@ func (c *Client) sendPerformPrediction(ctx context.Context, params PerformPredic
|
|||
return res, errors.Wrap(err, "encode query")
|
||||
}
|
||||
}
|
||||
{
|
||||
// Encode "ascent_curve" parameter.
|
||||
cfg := uri.QueryParameterEncodingConfig{
|
||||
Name: "ascent_curve",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := params.AscentCurve.Get(); ok {
|
||||
return e.EncodeValue(conv.StringToString(val))
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return res, errors.Wrap(err, "encode query")
|
||||
}
|
||||
}
|
||||
{
|
||||
// Encode "descent_curve" parameter.
|
||||
cfg := uri.QueryParameterEncodingConfig{
|
||||
Name: "descent_curve",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := params.DescentCurve.Get(); ok {
|
||||
return e.EncodeValue(conv.StringToString(val))
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return res, errors.Wrap(err, "encode query")
|
||||
}
|
||||
}
|
||||
{
|
||||
// Encode "interpolate" parameter.
|
||||
cfg := uri.QueryParameterEncodingConfig{
|
||||
Name: "interpolate",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := params.Interpolate.Get(); ok {
|
||||
return e.EncodeValue(conv.BoolToString(val))
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return res, errors.Wrap(err, "encode query")
|
||||
}
|
||||
}
|
||||
{
|
||||
// Encode "format" parameter.
|
||||
cfg := uri.QueryParameterEncodingConfig{
|
||||
Name: "format",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := params.Format.Get(); ok {
|
||||
return e.EncodeValue(conv.StringToString(string(val)))
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return res, errors.Wrap(err, "encode query")
|
||||
}
|
||||
}
|
||||
{
|
||||
// Encode "dataset" parameter.
|
||||
cfg := uri.QueryParameterEncodingConfig{
|
||||
|
|
@ -409,7 +324,8 @@ func (c *Client) sendPerformPrediction(ctx context.Context, params PerformPredic
|
|||
if err != nil {
|
||||
return res, errors.Wrap(err, "do request")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body := resp.Body
|
||||
defer body.Close()
|
||||
|
||||
stage = "DecodeResponse"
|
||||
result, err := decodePerformPredictionResponse(resp)
|
||||
|
|
@ -434,8 +350,9 @@ func (c *Client) sendReadinessCheck(ctx context.Context) (res *ReadinessResponse
|
|||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("readinessCheck"),
|
||||
semconv.HTTPRequestMethodKey.String("GET"),
|
||||
semconv.HTTPRouteKey.String("/ready"),
|
||||
semconv.URLTemplateKey.String("/ready"),
|
||||
}
|
||||
otelAttrs = append(otelAttrs, c.cfg.Attributes...)
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
|
|
@ -481,7 +398,8 @@ func (c *Client) sendReadinessCheck(ctx context.Context) (res *ReadinessResponse
|
|||
if err != nil {
|
||||
return res, errors.Wrap(err, "do request")
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body := resp.Body
|
||||
defer body.Close()
|
||||
|
||||
stage = "DecodeResponse"
|
||||
result, err := decodeReadinessCheckResponse(resp)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -8,16 +8,15 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-faster/errors"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
ht "github.com/ogen-go/ogen/http"
|
||||
"github.com/ogen-go/ogen/middleware"
|
||||
"github.com/ogen-go/ogen/ogenerrors"
|
||||
"github.com/ogen-go/ogen/otelogen"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.39.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
type codeRecorder struct {
|
||||
|
|
@ -30,6 +29,10 @@ func (c *codeRecorder) WriteHeader(status int) {
|
|||
c.ResponseWriter.WriteHeader(status)
|
||||
}
|
||||
|
||||
func (c *codeRecorder) Unwrap() http.ResponseWriter {
|
||||
return c.ResponseWriter
|
||||
}
|
||||
|
||||
// handlePerformPredictionRequest handles performPrediction operation.
|
||||
//
|
||||
// Perform prediction.
|
||||
|
|
@ -43,6 +46,8 @@ func (s *Server) handlePerformPredictionRequest(args [0]string, argsEscaped bool
|
|||
semconv.HTTPRequestMethodKey.String("GET"),
|
||||
semconv.HTTPRouteKey.String("/api/v1/prediction"),
|
||||
}
|
||||
// Add attributes from config.
|
||||
otelAttrs = append(otelAttrs, s.cfg.Attributes...)
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), PerformPredictionOperation,
|
||||
|
|
@ -86,7 +91,7 @@ func (s *Server) handlePerformPredictionRequest(args [0]string, argsEscaped bool
|
|||
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
|
||||
// max redirects exceeded), in which case status MUST be set to Error.
|
||||
code := statusWriter.status
|
||||
if code >= 100 && code < 500 {
|
||||
if code < 100 || code >= 500 {
|
||||
span.SetStatus(codes.Error, stage)
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +120,9 @@ func (s *Server) handlePerformPredictionRequest(args [0]string, argsEscaped bool
|
|||
return
|
||||
}
|
||||
|
||||
var response *PredictionResult
|
||||
var rawBody []byte
|
||||
|
||||
var response *PredictionResponse
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
|
|
@ -123,6 +130,7 @@ func (s *Server) handlePerformPredictionRequest(args [0]string, argsEscaped bool
|
|||
OperationSummary: "Perform prediction",
|
||||
OperationID: "performPrediction",
|
||||
Body: nil,
|
||||
RawBody: rawBody,
|
||||
Params: middleware.Parameters{
|
||||
{
|
||||
Name: "launch_latitude",
|
||||
|
|
@ -164,22 +172,6 @@ func (s *Server) handlePerformPredictionRequest(args [0]string, argsEscaped bool
|
|||
Name: "stop_datetime",
|
||||
In: "query",
|
||||
}: params.StopDatetime,
|
||||
{
|
||||
Name: "ascent_curve",
|
||||
In: "query",
|
||||
}: params.AscentCurve,
|
||||
{
|
||||
Name: "descent_curve",
|
||||
In: "query",
|
||||
}: params.DescentCurve,
|
||||
{
|
||||
Name: "interpolate",
|
||||
In: "query",
|
||||
}: params.Interpolate,
|
||||
{
|
||||
Name: "format",
|
||||
In: "query",
|
||||
}: params.Format,
|
||||
{
|
||||
Name: "dataset",
|
||||
In: "query",
|
||||
|
|
@ -191,7 +183,7 @@ func (s *Server) handlePerformPredictionRequest(args [0]string, argsEscaped bool
|
|||
type (
|
||||
Request = struct{}
|
||||
Params = PerformPredictionParams
|
||||
Response = *PredictionResult
|
||||
Response = *PredictionResponse
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
|
|
@ -248,6 +240,8 @@ func (s *Server) handleReadinessCheckRequest(args [0]string, argsEscaped bool, w
|
|||
semconv.HTTPRequestMethodKey.String("GET"),
|
||||
semconv.HTTPRouteKey.String("/ready"),
|
||||
}
|
||||
// Add attributes from config.
|
||||
otelAttrs = append(otelAttrs, s.cfg.Attributes...)
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), ReadinessCheckOperation,
|
||||
|
|
@ -291,7 +285,7 @@ func (s *Server) handleReadinessCheckRequest(args [0]string, argsEscaped bool, w
|
|||
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
|
||||
// max redirects exceeded), in which case status MUST be set to Error.
|
||||
code := statusWriter.status
|
||||
if code >= 100 && code < 500 {
|
||||
if code < 100 || code >= 500 {
|
||||
span.SetStatus(codes.Error, stage)
|
||||
}
|
||||
|
||||
|
|
@ -306,6 +300,8 @@ func (s *Server) handleReadinessCheckRequest(args [0]string, argsEscaped bool, w
|
|||
err error
|
||||
)
|
||||
|
||||
var rawBody []byte
|
||||
|
||||
var response *ReadinessResponse
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
|
|
@ -314,6 +310,7 @@ func (s *Server) handleReadinessCheckRequest(args [0]string, argsEscaped bool, w
|
|||
OperationSummary: "Readiness check",
|
||||
OperationID: "readinessCheck",
|
||||
Body: nil,
|
||||
RawBody: rawBody,
|
||||
Params: middleware.Parameters{},
|
||||
Raw: r,
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
||||
import (
|
||||
"github.com/ogen-go/ogen/middleware"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
||||
// OperationName is the ogen operation name
|
||||
type OperationName = string
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-faster/errors"
|
||||
|
||||
"github.com/ogen-go/ogen/conv"
|
||||
"github.com/ogen-go/ogen/middleware"
|
||||
"github.com/ogen-go/ogen/ogenerrors"
|
||||
|
|
@ -17,21 +16,17 @@ import (
|
|||
|
||||
// PerformPredictionParams is parameters of performPrediction operation.
|
||||
type PerformPredictionParams struct {
|
||||
LaunchLatitude OptFloat64
|
||||
LaunchLongitude OptFloat64
|
||||
LaunchDatetime OptDateTime
|
||||
LaunchAltitude OptFloat64
|
||||
Profile OptPerformPredictionProfile
|
||||
AscentRate OptFloat64
|
||||
BurstAltitude OptFloat64
|
||||
DescentRate OptFloat64
|
||||
FloatAltitude OptFloat64
|
||||
StopDatetime OptDateTime
|
||||
AscentCurve OptString
|
||||
DescentCurve OptString
|
||||
Interpolate OptBool
|
||||
Format OptPerformPredictionFormat
|
||||
Dataset OptDateTime
|
||||
LaunchLatitude float64
|
||||
LaunchLongitude float64
|
||||
LaunchDatetime time.Time
|
||||
LaunchAltitude OptFloat64 `json:",omitempty,omitzero"`
|
||||
Profile OptPerformPredictionProfile `json:",omitempty,omitzero"`
|
||||
AscentRate OptFloat64 `json:",omitempty,omitzero"`
|
||||
BurstAltitude OptFloat64 `json:",omitempty,omitzero"`
|
||||
DescentRate OptFloat64 `json:",omitempty,omitzero"`
|
||||
FloatAltitude OptFloat64 `json:",omitempty,omitzero"`
|
||||
StopDatetime OptDateTime `json:",omitempty,omitzero"`
|
||||
Dataset OptDateTime `json:",omitempty,omitzero"`
|
||||
}
|
||||
|
||||
func unpackPerformPredictionParams(packed middleware.Parameters) (params PerformPredictionParams) {
|
||||
|
|
@ -40,27 +35,21 @@ func unpackPerformPredictionParams(packed middleware.Parameters) (params Perform
|
|||
Name: "launch_latitude",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.LaunchLatitude = v.(OptFloat64)
|
||||
}
|
||||
params.LaunchLatitude = packed[key].(float64)
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "launch_longitude",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.LaunchLongitude = v.(OptFloat64)
|
||||
}
|
||||
params.LaunchLongitude = packed[key].(float64)
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "launch_datetime",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.LaunchDatetime = v.(OptDateTime)
|
||||
}
|
||||
params.LaunchDatetime = packed[key].(time.Time)
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
|
|
@ -125,42 +114,6 @@ func unpackPerformPredictionParams(packed middleware.Parameters) (params Perform
|
|||
params.StopDatetime = v.(OptDateTime)
|
||||
}
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "ascent_curve",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.AscentCurve = v.(OptString)
|
||||
}
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "descent_curve",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.DescentCurve = v.(OptString)
|
||||
}
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "interpolate",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.Interpolate = v.(OptBool)
|
||||
}
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "format",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.Format = v.(OptPerformPredictionFormat)
|
||||
}
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "dataset",
|
||||
|
|
@ -185,43 +138,31 @@ 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 paramsDotLaunchLatitudeVal float64
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToFloat64(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotLaunchLatitudeVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
params.LaunchLatitude.SetTo(paramsDotLaunchLatitudeVal)
|
||||
|
||||
c, err := conv.ToFloat64(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.LaunchLatitude = c
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := params.LaunchLatitude.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := (validate.Float{}).Validate(float64(params.LaunchLatitude)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
|
|
@ -241,43 +182,31 @@ 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 paramsDotLaunchLongitudeVal float64
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToFloat64(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotLaunchLongitudeVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
params.LaunchLongitude.SetTo(paramsDotLaunchLongitudeVal)
|
||||
|
||||
c, err := conv.ToFloat64(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.LaunchLongitude = c
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := params.LaunchLongitude.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := (validate.Float{}).Validate(float64(params.LaunchLongitude)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
|
|
@ -297,28 +226,23 @@ 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 paramsDotLaunchDatetimeVal time.Time
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToDateTime(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotLaunchDatetimeVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
params.LaunchDatetime.SetTo(paramsDotLaunchDatetimeVal)
|
||||
|
||||
c, err := conv.ToDateTime(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.LaunchDatetime = c
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
|
|
@ -384,6 +308,11 @@ func decodePerformPredictionParams(args [0]string, argsEscaped bool, r *http.Req
|
|||
Err: err,
|
||||
}
|
||||
}
|
||||
// Set default value for query: profile.
|
||||
{
|
||||
val := PerformPredictionProfile("standard_profile")
|
||||
params.Profile.SetTo(val)
|
||||
}
|
||||
// Decode query: profile.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
|
|
@ -705,185 +634,6 @@ func decodePerformPredictionParams(args [0]string, argsEscaped bool, r *http.Req
|
|||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode query: ascent_curve.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "ascent_curve",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotAscentCurveVal string
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToString(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotAscentCurveVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.AscentCurve.SetTo(paramsDotAscentCurveVal)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "ascent_curve",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode query: descent_curve.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "descent_curve",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotDescentCurveVal string
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToString(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotDescentCurveVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.DescentCurve.SetTo(paramsDotDescentCurveVal)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "descent_curve",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode query: interpolate.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "interpolate",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotInterpolateVal bool
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToBool(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotInterpolateVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.Interpolate.SetTo(paramsDotInterpolateVal)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "interpolate",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode query: format.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "format",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotFormatVal PerformPredictionFormat
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToString(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotFormatVal = PerformPredictionFormat(c)
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.Format.SetTo(paramsDotFormatVal)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := params.Format.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := value.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "format",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode query: dataset.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
|
@ -9,12 +9,11 @@ import (
|
|||
|
||||
"github.com/go-faster/errors"
|
||||
"github.com/go-faster/jx"
|
||||
|
||||
"github.com/ogen-go/ogen/ogenerrors"
|
||||
"github.com/ogen-go/ogen/validate"
|
||||
)
|
||||
|
||||
func decodePerformPredictionResponse(resp *http.Response) (res *PredictionResult, _ error) {
|
||||
func decodePerformPredictionResponse(resp *http.Response) (res *PredictionResponse, _ error) {
|
||||
switch resp.StatusCode {
|
||||
case 200:
|
||||
// Code 200.
|
||||
|
|
@ -30,7 +29,7 @@ func decodePerformPredictionResponse(resp *http.Response) (res *PredictionResult
|
|||
}
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var response PredictionResult
|
||||
var response PredictionResponse
|
||||
if err := func() error {
|
||||
if err := response.Decode(d); err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-faster/errors"
|
||||
"github.com/go-faster/jx"
|
||||
ht "github.com/ogen-go/ogen/http"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
ht "github.com/ogen-go/ogen/http"
|
||||
)
|
||||
|
||||
func encodePerformPredictionResponse(response *PredictionResult, w http.ResponseWriter, span trace.Span) error {
|
||||
func encodePerformPredictionResponse(response *PredictionResponse, 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))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
|
@ -74,7 +74,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
case "GET":
|
||||
s.handlePerformPredictionRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET")
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET",
|
||||
allowedHeaders: nil,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
|
|
@ -94,7 +99,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
case "GET":
|
||||
s.handleReadinessCheckRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "GET")
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET",
|
||||
allowedHeaders: nil,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
|
|
@ -109,12 +119,13 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// Route is route object.
|
||||
type Route struct {
|
||||
name string
|
||||
summary string
|
||||
operationID string
|
||||
pathPattern string
|
||||
count int
|
||||
args [0]string
|
||||
name string
|
||||
summary string
|
||||
operationID string
|
||||
operationGroup string
|
||||
pathPattern string
|
||||
count int
|
||||
args [0]string
|
||||
}
|
||||
|
||||
// Name returns ogen operation name.
|
||||
|
|
@ -134,6 +145,11 @@ func (r Route) OperationID() string {
|
|||
return r.operationID
|
||||
}
|
||||
|
||||
// OperationGroup returns the x-ogen-operation-group value.
|
||||
func (r Route) OperationGroup() string {
|
||||
return r.operationGroup
|
||||
}
|
||||
|
||||
// PathPattern returns OpenAPI path.
|
||||
func (r Route) PathPattern() string {
|
||||
return r.pathPattern
|
||||
|
|
@ -209,6 +225,7 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||
r.name = PerformPredictionOperation
|
||||
r.summary = "Perform prediction"
|
||||
r.operationID = "performPrediction"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/prediction"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
|
|
@ -233,6 +250,7 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||
r.name = ReadinessCheckOperation
|
||||
r.summary = "Readiness check"
|
||||
r.operationID = "readinessCheck"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/ready"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/go-faster/errors"
|
||||
"github.com/go-faster/jx"
|
||||
)
|
||||
|
||||
func (s *ErrorStatusCode) Error() string {
|
||||
|
|
@ -15,28 +16,42 @@ func (s *ErrorStatusCode) Error() string {
|
|||
|
||||
// Ref: #/components/schemas/Error
|
||||
type Error struct {
|
||||
Message string `json:"message"`
|
||||
Details OptString `json:"details"`
|
||||
Error ErrorError `json:"error"`
|
||||
}
|
||||
|
||||
// GetMessage returns the value of Message.
|
||||
func (s *Error) GetMessage() string {
|
||||
return s.Message
|
||||
// GetError returns the value of Error.
|
||||
func (s *Error) GetError() ErrorError {
|
||||
return s.Error
|
||||
}
|
||||
|
||||
// GetDetails returns the value of Details.
|
||||
func (s *Error) GetDetails() OptString {
|
||||
return s.Details
|
||||
// SetError sets the value of Error.
|
||||
func (s *Error) SetError(val ErrorError) {
|
||||
s.Error = val
|
||||
}
|
||||
|
||||
// SetMessage sets the value of Message.
|
||||
func (s *Error) SetMessage(val string) {
|
||||
s.Message = val
|
||||
type ErrorError struct {
|
||||
Type string `json:"type"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// SetDetails sets the value of Details.
|
||||
func (s *Error) SetDetails(val OptString) {
|
||||
s.Details = val
|
||||
// GetType returns the value of Type.
|
||||
func (s *ErrorError) GetType() string {
|
||||
return s.Type
|
||||
}
|
||||
|
||||
// GetDescription returns the value of Description.
|
||||
func (s *ErrorError) GetDescription() string {
|
||||
return s.Description
|
||||
}
|
||||
|
||||
// SetType sets the value of Type.
|
||||
func (s *ErrorError) SetType(val string) {
|
||||
s.Type = val
|
||||
}
|
||||
|
||||
// SetDescription sets the value of Description.
|
||||
func (s *ErrorError) SetDescription(val string) {
|
||||
s.Description = val
|
||||
}
|
||||
|
||||
// ErrorStatusCode wraps Error with StatusCode.
|
||||
|
|
@ -65,52 +80,6 @@ func (s *ErrorStatusCode) SetResponse(val Error) {
|
|||
s.Response = val
|
||||
}
|
||||
|
||||
// NewOptBool returns new OptBool with value set to v.
|
||||
func NewOptBool(v bool) OptBool {
|
||||
return OptBool{
|
||||
Value: v,
|
||||
Set: true,
|
||||
}
|
||||
}
|
||||
|
||||
// OptBool is optional bool.
|
||||
type OptBool struct {
|
||||
Value bool
|
||||
Set bool
|
||||
}
|
||||
|
||||
// IsSet returns true if OptBool was set.
|
||||
func (o OptBool) IsSet() bool { return o.Set }
|
||||
|
||||
// Reset unsets value.
|
||||
func (o *OptBool) Reset() {
|
||||
var v bool
|
||||
o.Value = v
|
||||
o.Set = false
|
||||
}
|
||||
|
||||
// SetTo sets value to v.
|
||||
func (o *OptBool) SetTo(v bool) {
|
||||
o.Set = true
|
||||
o.Value = v
|
||||
}
|
||||
|
||||
// Get returns value and boolean that denotes whether value was set.
|
||||
func (o OptBool) Get() (v bool, ok bool) {
|
||||
if !o.Set {
|
||||
return v, false
|
||||
}
|
||||
return o.Value, true
|
||||
}
|
||||
|
||||
// Or returns value if set, or given parameter if does not.
|
||||
func (o OptBool) Or(d bool) bool {
|
||||
if v, ok := o.Get(); ok {
|
||||
return v
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
// NewOptDateTime returns new OptDateTime with value set to v.
|
||||
func NewOptDateTime(v time.Time) OptDateTime {
|
||||
return OptDateTime{
|
||||
|
|
@ -203,52 +172,6 @@ func (o OptFloat64) Or(d float64) float64 {
|
|||
return d
|
||||
}
|
||||
|
||||
// NewOptPerformPredictionFormat returns new OptPerformPredictionFormat with value set to v.
|
||||
func NewOptPerformPredictionFormat(v PerformPredictionFormat) OptPerformPredictionFormat {
|
||||
return OptPerformPredictionFormat{
|
||||
Value: v,
|
||||
Set: true,
|
||||
}
|
||||
}
|
||||
|
||||
// OptPerformPredictionFormat is optional PerformPredictionFormat.
|
||||
type OptPerformPredictionFormat struct {
|
||||
Value PerformPredictionFormat
|
||||
Set bool
|
||||
}
|
||||
|
||||
// IsSet returns true if OptPerformPredictionFormat was set.
|
||||
func (o OptPerformPredictionFormat) IsSet() bool { return o.Set }
|
||||
|
||||
// Reset unsets value.
|
||||
func (o *OptPerformPredictionFormat) Reset() {
|
||||
var v PerformPredictionFormat
|
||||
o.Value = v
|
||||
o.Set = false
|
||||
}
|
||||
|
||||
// SetTo sets value to v.
|
||||
func (o *OptPerformPredictionFormat) SetTo(v PerformPredictionFormat) {
|
||||
o.Set = true
|
||||
o.Value = v
|
||||
}
|
||||
|
||||
// Get returns value and boolean that denotes whether value was set.
|
||||
func (o OptPerformPredictionFormat) Get() (v PerformPredictionFormat, ok bool) {
|
||||
if !o.Set {
|
||||
return v, false
|
||||
}
|
||||
return o.Value, true
|
||||
}
|
||||
|
||||
// Or returns value if set, or given parameter if does not.
|
||||
func (o OptPerformPredictionFormat) Or(d PerformPredictionFormat) PerformPredictionFormat {
|
||||
if v, ok := o.Get(); ok {
|
||||
return v
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
// NewOptPerformPredictionProfile returns new OptPerformPredictionProfile with value set to v.
|
||||
func NewOptPerformPredictionProfile(v PerformPredictionProfile) OptPerformPredictionProfile {
|
||||
return OptPerformPredictionProfile{
|
||||
|
|
@ -295,6 +218,98 @@ func (o OptPerformPredictionProfile) Or(d PerformPredictionProfile) PerformPredi
|
|||
return d
|
||||
}
|
||||
|
||||
// NewOptPredictionResponseRequest returns new OptPredictionResponseRequest with value set to v.
|
||||
func NewOptPredictionResponseRequest(v PredictionResponseRequest) OptPredictionResponseRequest {
|
||||
return OptPredictionResponseRequest{
|
||||
Value: v,
|
||||
Set: true,
|
||||
}
|
||||
}
|
||||
|
||||
// OptPredictionResponseRequest is optional PredictionResponseRequest.
|
||||
type OptPredictionResponseRequest struct {
|
||||
Value PredictionResponseRequest
|
||||
Set bool
|
||||
}
|
||||
|
||||
// IsSet returns true if OptPredictionResponseRequest was set.
|
||||
func (o OptPredictionResponseRequest) IsSet() bool { return o.Set }
|
||||
|
||||
// Reset unsets value.
|
||||
func (o *OptPredictionResponseRequest) Reset() {
|
||||
var v PredictionResponseRequest
|
||||
o.Value = v
|
||||
o.Set = false
|
||||
}
|
||||
|
||||
// SetTo sets value to v.
|
||||
func (o *OptPredictionResponseRequest) SetTo(v PredictionResponseRequest) {
|
||||
o.Set = true
|
||||
o.Value = v
|
||||
}
|
||||
|
||||
// Get returns value and boolean that denotes whether value was set.
|
||||
func (o OptPredictionResponseRequest) Get() (v PredictionResponseRequest, ok bool) {
|
||||
if !o.Set {
|
||||
return v, false
|
||||
}
|
||||
return o.Value, true
|
||||
}
|
||||
|
||||
// Or returns value if set, or given parameter if does not.
|
||||
func (o OptPredictionResponseRequest) Or(d PredictionResponseRequest) PredictionResponseRequest {
|
||||
if v, ok := o.Get(); ok {
|
||||
return v
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
// NewOptPredictionResponseWarnings returns new OptPredictionResponseWarnings with value set to v.
|
||||
func NewOptPredictionResponseWarnings(v PredictionResponseWarnings) OptPredictionResponseWarnings {
|
||||
return OptPredictionResponseWarnings{
|
||||
Value: v,
|
||||
Set: true,
|
||||
}
|
||||
}
|
||||
|
||||
// OptPredictionResponseWarnings is optional PredictionResponseWarnings.
|
||||
type OptPredictionResponseWarnings struct {
|
||||
Value PredictionResponseWarnings
|
||||
Set bool
|
||||
}
|
||||
|
||||
// IsSet returns true if OptPredictionResponseWarnings was set.
|
||||
func (o OptPredictionResponseWarnings) IsSet() bool { return o.Set }
|
||||
|
||||
// Reset unsets value.
|
||||
func (o *OptPredictionResponseWarnings) Reset() {
|
||||
var v PredictionResponseWarnings
|
||||
o.Value = v
|
||||
o.Set = false
|
||||
}
|
||||
|
||||
// SetTo sets value to v.
|
||||
func (o *OptPredictionResponseWarnings) SetTo(v PredictionResponseWarnings) {
|
||||
o.Set = true
|
||||
o.Value = v
|
||||
}
|
||||
|
||||
// Get returns value and boolean that denotes whether value was set.
|
||||
func (o OptPredictionResponseWarnings) Get() (v PredictionResponseWarnings, ok bool) {
|
||||
if !o.Set {
|
||||
return v, false
|
||||
}
|
||||
return o.Value, true
|
||||
}
|
||||
|
||||
// Or returns value if set, or given parameter if does not.
|
||||
func (o OptPredictionResponseWarnings) Or(d PredictionResponseWarnings) PredictionResponseWarnings {
|
||||
if v, ok := o.Get(); ok {
|
||||
return v
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
// NewOptString returns new OptString with value set to v.
|
||||
func NewOptString(v string) OptString {
|
||||
return OptString{
|
||||
|
|
@ -341,47 +356,11 @@ func (o OptString) Or(d string) string {
|
|||
return d
|
||||
}
|
||||
|
||||
type PerformPredictionFormat string
|
||||
|
||||
const (
|
||||
PerformPredictionFormatJSON PerformPredictionFormat = "json"
|
||||
)
|
||||
|
||||
// AllValues returns all PerformPredictionFormat values.
|
||||
func (PerformPredictionFormat) AllValues() []PerformPredictionFormat {
|
||||
return []PerformPredictionFormat{
|
||||
PerformPredictionFormatJSON,
|
||||
}
|
||||
}
|
||||
|
||||
// MarshalText implements encoding.TextMarshaler.
|
||||
func (s PerformPredictionFormat) MarshalText() ([]byte, error) {
|
||||
switch s {
|
||||
case PerformPredictionFormatJSON:
|
||||
return []byte(s), nil
|
||||
default:
|
||||
return nil, errors.Errorf("invalid value: %q", s)
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalText implements encoding.TextUnmarshaler.
|
||||
func (s *PerformPredictionFormat) UnmarshalText(data []byte) error {
|
||||
switch PerformPredictionFormat(data) {
|
||||
case PerformPredictionFormatJSON:
|
||||
*s = PerformPredictionFormatJSON
|
||||
return nil
|
||||
default:
|
||||
return errors.Errorf("invalid value: %q", data)
|
||||
}
|
||||
}
|
||||
|
||||
type PerformPredictionProfile string
|
||||
|
||||
const (
|
||||
PerformPredictionProfileStandardProfile PerformPredictionProfile = "standard_profile"
|
||||
PerformPredictionProfileFloatProfile PerformPredictionProfile = "float_profile"
|
||||
PerformPredictionProfileReverseProfile PerformPredictionProfile = "reverse_profile"
|
||||
PerformPredictionProfileCustomProfile PerformPredictionProfile = "custom_profile"
|
||||
)
|
||||
|
||||
// AllValues returns all PerformPredictionProfile values.
|
||||
|
|
@ -389,8 +368,6 @@ func (PerformPredictionProfile) AllValues() []PerformPredictionProfile {
|
|||
return []PerformPredictionProfile{
|
||||
PerformPredictionProfileStandardProfile,
|
||||
PerformPredictionProfileFloatProfile,
|
||||
PerformPredictionProfileReverseProfile,
|
||||
PerformPredictionProfileCustomProfile,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -401,10 +378,6 @@ func (s PerformPredictionProfile) MarshalText() ([]byte, error) {
|
|||
return []byte(s), nil
|
||||
case PerformPredictionProfileFloatProfile:
|
||||
return []byte(s), nil
|
||||
case PerformPredictionProfileReverseProfile:
|
||||
return []byte(s), nil
|
||||
case PerformPredictionProfileCustomProfile:
|
||||
return []byte(s), nil
|
||||
default:
|
||||
return nil, errors.Errorf("invalid value: %q", s)
|
||||
}
|
||||
|
|
@ -419,114 +392,134 @@ func (s *PerformPredictionProfile) UnmarshalText(data []byte) error {
|
|||
case PerformPredictionProfileFloatProfile:
|
||||
*s = PerformPredictionProfileFloatProfile
|
||||
return nil
|
||||
case PerformPredictionProfileReverseProfile:
|
||||
*s = PerformPredictionProfileReverseProfile
|
||||
return nil
|
||||
case PerformPredictionProfileCustomProfile:
|
||||
*s = PerformPredictionProfileCustomProfile
|
||||
return nil
|
||||
default:
|
||||
return errors.Errorf("invalid value: %q", data)
|
||||
}
|
||||
}
|
||||
|
||||
// Ref: #/components/schemas/PredictionResult
|
||||
type PredictionResult struct {
|
||||
Metadata PredictionResultMetadata `json:"metadata"`
|
||||
Prediction []PredictionResultPredictionItem `json:"prediction"`
|
||||
// Ref: #/components/schemas/PredictionResponse
|
||||
type PredictionResponse struct {
|
||||
Request OptPredictionResponseRequest `json:"request"`
|
||||
Prediction []PredictionResponsePredictionItem `json:"prediction"`
|
||||
Metadata PredictionResponseMetadata `json:"metadata"`
|
||||
Warnings OptPredictionResponseWarnings `json:"warnings"`
|
||||
}
|
||||
|
||||
// GetMetadata returns the value of Metadata.
|
||||
func (s *PredictionResult) GetMetadata() PredictionResultMetadata {
|
||||
return s.Metadata
|
||||
// GetRequest returns the value of Request.
|
||||
func (s *PredictionResponse) GetRequest() OptPredictionResponseRequest {
|
||||
return s.Request
|
||||
}
|
||||
|
||||
// GetPrediction returns the value of Prediction.
|
||||
func (s *PredictionResult) GetPrediction() []PredictionResultPredictionItem {
|
||||
func (s *PredictionResponse) GetPrediction() []PredictionResponsePredictionItem {
|
||||
return s.Prediction
|
||||
}
|
||||
|
||||
// SetMetadata sets the value of Metadata.
|
||||
func (s *PredictionResult) SetMetadata(val PredictionResultMetadata) {
|
||||
s.Metadata = val
|
||||
// GetMetadata returns the value of Metadata.
|
||||
func (s *PredictionResponse) GetMetadata() PredictionResponseMetadata {
|
||||
return s.Metadata
|
||||
}
|
||||
|
||||
// GetWarnings returns the value of Warnings.
|
||||
func (s *PredictionResponse) GetWarnings() OptPredictionResponseWarnings {
|
||||
return s.Warnings
|
||||
}
|
||||
|
||||
// SetRequest sets the value of Request.
|
||||
func (s *PredictionResponse) SetRequest(val OptPredictionResponseRequest) {
|
||||
s.Request = val
|
||||
}
|
||||
|
||||
// SetPrediction sets the value of Prediction.
|
||||
func (s *PredictionResult) SetPrediction(val []PredictionResultPredictionItem) {
|
||||
func (s *PredictionResponse) SetPrediction(val []PredictionResponsePredictionItem) {
|
||||
s.Prediction = val
|
||||
}
|
||||
|
||||
type PredictionResultMetadata struct {
|
||||
CompleteDatetime time.Time `json:"complete_datetime"`
|
||||
StartDatetime time.Time `json:"start_datetime"`
|
||||
// SetMetadata sets the value of Metadata.
|
||||
func (s *PredictionResponse) SetMetadata(val PredictionResponseMetadata) {
|
||||
s.Metadata = val
|
||||
}
|
||||
|
||||
// GetCompleteDatetime returns the value of CompleteDatetime.
|
||||
func (s *PredictionResultMetadata) GetCompleteDatetime() time.Time {
|
||||
return s.CompleteDatetime
|
||||
// SetWarnings sets the value of Warnings.
|
||||
func (s *PredictionResponse) SetWarnings(val OptPredictionResponseWarnings) {
|
||||
s.Warnings = val
|
||||
}
|
||||
|
||||
type PredictionResponseMetadata struct {
|
||||
StartDatetime time.Time `json:"start_datetime"`
|
||||
CompleteDatetime time.Time `json:"complete_datetime"`
|
||||
}
|
||||
|
||||
// GetStartDatetime returns the value of StartDatetime.
|
||||
func (s *PredictionResultMetadata) GetStartDatetime() time.Time {
|
||||
func (s *PredictionResponseMetadata) GetStartDatetime() time.Time {
|
||||
return s.StartDatetime
|
||||
}
|
||||
|
||||
// SetCompleteDatetime sets the value of CompleteDatetime.
|
||||
func (s *PredictionResultMetadata) SetCompleteDatetime(val time.Time) {
|
||||
s.CompleteDatetime = val
|
||||
// GetCompleteDatetime returns the value of CompleteDatetime.
|
||||
func (s *PredictionResponseMetadata) GetCompleteDatetime() time.Time {
|
||||
return s.CompleteDatetime
|
||||
}
|
||||
|
||||
// SetStartDatetime sets the value of StartDatetime.
|
||||
func (s *PredictionResultMetadata) SetStartDatetime(val time.Time) {
|
||||
func (s *PredictionResponseMetadata) SetStartDatetime(val time.Time) {
|
||||
s.StartDatetime = val
|
||||
}
|
||||
|
||||
type PredictionResultPredictionItem struct {
|
||||
Stage PredictionResultPredictionItemStage `json:"stage"`
|
||||
Trajectory []PredictionResultPredictionItemTrajectoryItem `json:"trajectory"`
|
||||
// SetCompleteDatetime sets the value of CompleteDatetime.
|
||||
func (s *PredictionResponseMetadata) SetCompleteDatetime(val time.Time) {
|
||||
s.CompleteDatetime = val
|
||||
}
|
||||
|
||||
type PredictionResponsePredictionItem struct {
|
||||
Stage PredictionResponsePredictionItemStage `json:"stage"`
|
||||
Trajectory []PredictionResponsePredictionItemTrajectoryItem `json:"trajectory"`
|
||||
}
|
||||
|
||||
// GetStage returns the value of Stage.
|
||||
func (s *PredictionResultPredictionItem) GetStage() PredictionResultPredictionItemStage {
|
||||
func (s *PredictionResponsePredictionItem) GetStage() PredictionResponsePredictionItemStage {
|
||||
return s.Stage
|
||||
}
|
||||
|
||||
// GetTrajectory returns the value of Trajectory.
|
||||
func (s *PredictionResultPredictionItem) GetTrajectory() []PredictionResultPredictionItemTrajectoryItem {
|
||||
func (s *PredictionResponsePredictionItem) GetTrajectory() []PredictionResponsePredictionItemTrajectoryItem {
|
||||
return s.Trajectory
|
||||
}
|
||||
|
||||
// SetStage sets the value of Stage.
|
||||
func (s *PredictionResultPredictionItem) SetStage(val PredictionResultPredictionItemStage) {
|
||||
func (s *PredictionResponsePredictionItem) SetStage(val PredictionResponsePredictionItemStage) {
|
||||
s.Stage = val
|
||||
}
|
||||
|
||||
// SetTrajectory sets the value of Trajectory.
|
||||
func (s *PredictionResultPredictionItem) SetTrajectory(val []PredictionResultPredictionItemTrajectoryItem) {
|
||||
func (s *PredictionResponsePredictionItem) SetTrajectory(val []PredictionResponsePredictionItemTrajectoryItem) {
|
||||
s.Trajectory = val
|
||||
}
|
||||
|
||||
type PredictionResultPredictionItemStage string
|
||||
type PredictionResponsePredictionItemStage string
|
||||
|
||||
const (
|
||||
PredictionResultPredictionItemStageAscent PredictionResultPredictionItemStage = "ascent"
|
||||
PredictionResultPredictionItemStageDescent PredictionResultPredictionItemStage = "descent"
|
||||
PredictionResponsePredictionItemStageAscent PredictionResponsePredictionItemStage = "ascent"
|
||||
PredictionResponsePredictionItemStageDescent PredictionResponsePredictionItemStage = "descent"
|
||||
PredictionResponsePredictionItemStageFloat PredictionResponsePredictionItemStage = "float"
|
||||
)
|
||||
|
||||
// AllValues returns all PredictionResultPredictionItemStage values.
|
||||
func (PredictionResultPredictionItemStage) AllValues() []PredictionResultPredictionItemStage {
|
||||
return []PredictionResultPredictionItemStage{
|
||||
PredictionResultPredictionItemStageAscent,
|
||||
PredictionResultPredictionItemStageDescent,
|
||||
// AllValues returns all PredictionResponsePredictionItemStage values.
|
||||
func (PredictionResponsePredictionItemStage) AllValues() []PredictionResponsePredictionItemStage {
|
||||
return []PredictionResponsePredictionItemStage{
|
||||
PredictionResponsePredictionItemStageAscent,
|
||||
PredictionResponsePredictionItemStageDescent,
|
||||
PredictionResponsePredictionItemStageFloat,
|
||||
}
|
||||
}
|
||||
|
||||
// MarshalText implements encoding.TextMarshaler.
|
||||
func (s PredictionResultPredictionItemStage) MarshalText() ([]byte, error) {
|
||||
func (s PredictionResponsePredictionItemStage) MarshalText() ([]byte, error) {
|
||||
switch s {
|
||||
case PredictionResultPredictionItemStageAscent:
|
||||
case PredictionResponsePredictionItemStageAscent:
|
||||
return []byte(s), nil
|
||||
case PredictionResultPredictionItemStageDescent:
|
||||
case PredictionResponsePredictionItemStageDescent:
|
||||
return []byte(s), nil
|
||||
case PredictionResponsePredictionItemStageFloat:
|
||||
return []byte(s), nil
|
||||
default:
|
||||
return nil, errors.Errorf("invalid value: %q", s)
|
||||
|
|
@ -534,20 +527,23 @@ func (s PredictionResultPredictionItemStage) MarshalText() ([]byte, error) {
|
|||
}
|
||||
|
||||
// UnmarshalText implements encoding.TextUnmarshaler.
|
||||
func (s *PredictionResultPredictionItemStage) UnmarshalText(data []byte) error {
|
||||
switch PredictionResultPredictionItemStage(data) {
|
||||
case PredictionResultPredictionItemStageAscent:
|
||||
*s = PredictionResultPredictionItemStageAscent
|
||||
func (s *PredictionResponsePredictionItemStage) UnmarshalText(data []byte) error {
|
||||
switch PredictionResponsePredictionItemStage(data) {
|
||||
case PredictionResponsePredictionItemStageAscent:
|
||||
*s = PredictionResponsePredictionItemStageAscent
|
||||
return nil
|
||||
case PredictionResultPredictionItemStageDescent:
|
||||
*s = PredictionResultPredictionItemStageDescent
|
||||
case PredictionResponsePredictionItemStageDescent:
|
||||
*s = PredictionResponsePredictionItemStageDescent
|
||||
return nil
|
||||
case PredictionResponsePredictionItemStageFloat:
|
||||
*s = PredictionResponsePredictionItemStageFloat
|
||||
return nil
|
||||
default:
|
||||
return errors.Errorf("invalid value: %q", data)
|
||||
}
|
||||
}
|
||||
|
||||
type PredictionResultPredictionItemTrajectoryItem struct {
|
||||
type PredictionResponsePredictionItemTrajectoryItem struct {
|
||||
Datetime time.Time `json:"datetime"`
|
||||
Latitude float64 `json:"latitude"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
|
|
@ -555,50 +551,162 @@ type PredictionResultPredictionItemTrajectoryItem struct {
|
|||
}
|
||||
|
||||
// GetDatetime returns the value of Datetime.
|
||||
func (s *PredictionResultPredictionItemTrajectoryItem) GetDatetime() time.Time {
|
||||
func (s *PredictionResponsePredictionItemTrajectoryItem) GetDatetime() time.Time {
|
||||
return s.Datetime
|
||||
}
|
||||
|
||||
// GetLatitude returns the value of Latitude.
|
||||
func (s *PredictionResultPredictionItemTrajectoryItem) GetLatitude() float64 {
|
||||
func (s *PredictionResponsePredictionItemTrajectoryItem) GetLatitude() float64 {
|
||||
return s.Latitude
|
||||
}
|
||||
|
||||
// GetLongitude returns the value of Longitude.
|
||||
func (s *PredictionResultPredictionItemTrajectoryItem) GetLongitude() float64 {
|
||||
func (s *PredictionResponsePredictionItemTrajectoryItem) GetLongitude() float64 {
|
||||
return s.Longitude
|
||||
}
|
||||
|
||||
// GetAltitude returns the value of Altitude.
|
||||
func (s *PredictionResultPredictionItemTrajectoryItem) GetAltitude() float64 {
|
||||
func (s *PredictionResponsePredictionItemTrajectoryItem) GetAltitude() float64 {
|
||||
return s.Altitude
|
||||
}
|
||||
|
||||
// SetDatetime sets the value of Datetime.
|
||||
func (s *PredictionResultPredictionItemTrajectoryItem) SetDatetime(val time.Time) {
|
||||
func (s *PredictionResponsePredictionItemTrajectoryItem) SetDatetime(val time.Time) {
|
||||
s.Datetime = val
|
||||
}
|
||||
|
||||
// SetLatitude sets the value of Latitude.
|
||||
func (s *PredictionResultPredictionItemTrajectoryItem) SetLatitude(val float64) {
|
||||
func (s *PredictionResponsePredictionItemTrajectoryItem) SetLatitude(val float64) {
|
||||
s.Latitude = val
|
||||
}
|
||||
|
||||
// SetLongitude sets the value of Longitude.
|
||||
func (s *PredictionResultPredictionItemTrajectoryItem) SetLongitude(val float64) {
|
||||
func (s *PredictionResponsePredictionItemTrajectoryItem) SetLongitude(val float64) {
|
||||
s.Longitude = val
|
||||
}
|
||||
|
||||
// SetAltitude sets the value of Altitude.
|
||||
func (s *PredictionResultPredictionItemTrajectoryItem) SetAltitude(val float64) {
|
||||
func (s *PredictionResponsePredictionItemTrajectoryItem) SetAltitude(val float64) {
|
||||
s.Altitude = val
|
||||
}
|
||||
|
||||
type PredictionResponseRequest struct {
|
||||
Dataset OptString `json:"dataset"`
|
||||
LaunchLatitude OptFloat64 `json:"launch_latitude"`
|
||||
LaunchLongitude OptFloat64 `json:"launch_longitude"`
|
||||
LaunchDatetime OptString `json:"launch_datetime"`
|
||||
LaunchAltitude OptFloat64 `json:"launch_altitude"`
|
||||
Profile OptString `json:"profile"`
|
||||
AscentRate OptFloat64 `json:"ascent_rate"`
|
||||
BurstAltitude OptFloat64 `json:"burst_altitude"`
|
||||
DescentRate OptFloat64 `json:"descent_rate"`
|
||||
}
|
||||
|
||||
// GetDataset returns the value of Dataset.
|
||||
func (s *PredictionResponseRequest) GetDataset() OptString {
|
||||
return s.Dataset
|
||||
}
|
||||
|
||||
// GetLaunchLatitude returns the value of LaunchLatitude.
|
||||
func (s *PredictionResponseRequest) GetLaunchLatitude() OptFloat64 {
|
||||
return s.LaunchLatitude
|
||||
}
|
||||
|
||||
// GetLaunchLongitude returns the value of LaunchLongitude.
|
||||
func (s *PredictionResponseRequest) GetLaunchLongitude() OptFloat64 {
|
||||
return s.LaunchLongitude
|
||||
}
|
||||
|
||||
// GetLaunchDatetime returns the value of LaunchDatetime.
|
||||
func (s *PredictionResponseRequest) GetLaunchDatetime() OptString {
|
||||
return s.LaunchDatetime
|
||||
}
|
||||
|
||||
// GetLaunchAltitude returns the value of LaunchAltitude.
|
||||
func (s *PredictionResponseRequest) GetLaunchAltitude() OptFloat64 {
|
||||
return s.LaunchAltitude
|
||||
}
|
||||
|
||||
// GetProfile returns the value of Profile.
|
||||
func (s *PredictionResponseRequest) GetProfile() OptString {
|
||||
return s.Profile
|
||||
}
|
||||
|
||||
// GetAscentRate returns the value of AscentRate.
|
||||
func (s *PredictionResponseRequest) GetAscentRate() OptFloat64 {
|
||||
return s.AscentRate
|
||||
}
|
||||
|
||||
// GetBurstAltitude returns the value of BurstAltitude.
|
||||
func (s *PredictionResponseRequest) GetBurstAltitude() OptFloat64 {
|
||||
return s.BurstAltitude
|
||||
}
|
||||
|
||||
// GetDescentRate returns the value of DescentRate.
|
||||
func (s *PredictionResponseRequest) GetDescentRate() OptFloat64 {
|
||||
return s.DescentRate
|
||||
}
|
||||
|
||||
// SetDataset sets the value of Dataset.
|
||||
func (s *PredictionResponseRequest) SetDataset(val OptString) {
|
||||
s.Dataset = val
|
||||
}
|
||||
|
||||
// SetLaunchLatitude sets the value of LaunchLatitude.
|
||||
func (s *PredictionResponseRequest) SetLaunchLatitude(val OptFloat64) {
|
||||
s.LaunchLatitude = val
|
||||
}
|
||||
|
||||
// SetLaunchLongitude sets the value of LaunchLongitude.
|
||||
func (s *PredictionResponseRequest) SetLaunchLongitude(val OptFloat64) {
|
||||
s.LaunchLongitude = val
|
||||
}
|
||||
|
||||
// SetLaunchDatetime sets the value of LaunchDatetime.
|
||||
func (s *PredictionResponseRequest) SetLaunchDatetime(val OptString) {
|
||||
s.LaunchDatetime = val
|
||||
}
|
||||
|
||||
// SetLaunchAltitude sets the value of LaunchAltitude.
|
||||
func (s *PredictionResponseRequest) SetLaunchAltitude(val OptFloat64) {
|
||||
s.LaunchAltitude = val
|
||||
}
|
||||
|
||||
// SetProfile sets the value of Profile.
|
||||
func (s *PredictionResponseRequest) SetProfile(val OptString) {
|
||||
s.Profile = val
|
||||
}
|
||||
|
||||
// SetAscentRate sets the value of AscentRate.
|
||||
func (s *PredictionResponseRequest) SetAscentRate(val OptFloat64) {
|
||||
s.AscentRate = val
|
||||
}
|
||||
|
||||
// SetBurstAltitude sets the value of BurstAltitude.
|
||||
func (s *PredictionResponseRequest) SetBurstAltitude(val OptFloat64) {
|
||||
s.BurstAltitude = val
|
||||
}
|
||||
|
||||
// SetDescentRate sets the value of DescentRate.
|
||||
func (s *PredictionResponseRequest) SetDescentRate(val OptFloat64) {
|
||||
s.DescentRate = val
|
||||
}
|
||||
|
||||
type PredictionResponseWarnings map[string]jx.Raw
|
||||
|
||||
func (s *PredictionResponseWarnings) init() PredictionResponseWarnings {
|
||||
m := *s
|
||||
if m == nil {
|
||||
m = map[string]jx.Raw{}
|
||||
*s = m
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
// Ref: #/components/schemas/ReadinessResponse
|
||||
type ReadinessResponse struct {
|
||||
Status ReadinessResponseStatus `json:"status"`
|
||||
LastUpdate OptDateTime `json:"last_update"`
|
||||
IsFresh OptBool `json:"is_fresh"`
|
||||
DatasetTime OptDateTime `json:"dataset_time"`
|
||||
ErrorMessage OptString `json:"error_message"`
|
||||
}
|
||||
|
||||
|
|
@ -607,14 +715,9 @@ func (s *ReadinessResponse) GetStatus() ReadinessResponseStatus {
|
|||
return s.Status
|
||||
}
|
||||
|
||||
// GetLastUpdate returns the value of LastUpdate.
|
||||
func (s *ReadinessResponse) GetLastUpdate() OptDateTime {
|
||||
return s.LastUpdate
|
||||
}
|
||||
|
||||
// GetIsFresh returns the value of IsFresh.
|
||||
func (s *ReadinessResponse) GetIsFresh() OptBool {
|
||||
return s.IsFresh
|
||||
// GetDatasetTime returns the value of DatasetTime.
|
||||
func (s *ReadinessResponse) GetDatasetTime() OptDateTime {
|
||||
return s.DatasetTime
|
||||
}
|
||||
|
||||
// GetErrorMessage returns the value of ErrorMessage.
|
||||
|
|
@ -627,14 +730,9 @@ func (s *ReadinessResponse) SetStatus(val ReadinessResponseStatus) {
|
|||
s.Status = val
|
||||
}
|
||||
|
||||
// SetLastUpdate sets the value of LastUpdate.
|
||||
func (s *ReadinessResponse) SetLastUpdate(val OptDateTime) {
|
||||
s.LastUpdate = val
|
||||
}
|
||||
|
||||
// SetIsFresh sets the value of IsFresh.
|
||||
func (s *ReadinessResponse) SetIsFresh(val OptBool) {
|
||||
s.IsFresh = val
|
||||
// SetDatasetTime sets the value of DatasetTime.
|
||||
func (s *ReadinessResponse) SetDatasetTime(val OptDateTime) {
|
||||
s.DatasetTime = val
|
||||
}
|
||||
|
||||
// SetErrorMessage sets the value of ErrorMessage.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -13,7 +13,7 @@ type Handler interface {
|
|||
// Perform prediction.
|
||||
//
|
||||
// GET /api/v1/prediction
|
||||
PerformPrediction(ctx context.Context, params PerformPredictionParams) (*PredictionResult, error)
|
||||
PerformPrediction(ctx context.Context, params PerformPredictionParams) (*PredictionResponse, error)
|
||||
// ReadinessCheck implements readinessCheck operation.
|
||||
//
|
||||
// Readiness check.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -18,7 +18,7 @@ var _ Handler = UnimplementedHandler{}
|
|||
// Perform prediction.
|
||||
//
|
||||
// GET /api/v1/prediction
|
||||
func (UnimplementedHandler) PerformPrediction(ctx context.Context, params PerformPredictionParams) (r *PredictionResult, _ error) {
|
||||
func (UnimplementedHandler) PerformPrediction(ctx context.Context, params PerformPredictionParams) (r *PredictionResponse, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,45 +1,49 @@
|
|||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package gsn
|
||||
package rest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-faster/errors"
|
||||
|
||||
"github.com/ogen-go/ogen/validate"
|
||||
)
|
||||
|
||||
func (s PerformPredictionFormat) Validate() error {
|
||||
switch s {
|
||||
case "json":
|
||||
return nil
|
||||
default:
|
||||
return errors.Errorf("invalid value: %v", s)
|
||||
}
|
||||
}
|
||||
|
||||
func (s PerformPredictionProfile) Validate() error {
|
||||
switch s {
|
||||
case "standard_profile":
|
||||
return nil
|
||||
case "float_profile":
|
||||
return nil
|
||||
case "reverse_profile":
|
||||
return nil
|
||||
case "custom_profile":
|
||||
return nil
|
||||
default:
|
||||
return errors.Errorf("invalid value: %v", s)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PredictionResult) Validate() error {
|
||||
func (s *PredictionResponse) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if value, ok := s.Request.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := value.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "request",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if s.Prediction == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
|
|
@ -74,7 +78,7 @@ func (s *PredictionResult) Validate() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *PredictionResultPredictionItem) Validate() error {
|
||||
func (s *PredictionResponsePredictionItem) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
|
@ -125,18 +129,20 @@ func (s *PredictionResultPredictionItem) Validate() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s PredictionResultPredictionItemStage) Validate() error {
|
||||
func (s PredictionResponsePredictionItemStage) Validate() error {
|
||||
switch s {
|
||||
case "ascent":
|
||||
return nil
|
||||
case "descent":
|
||||
return nil
|
||||
case "float":
|
||||
return nil
|
||||
default:
|
||||
return errors.Errorf("invalid value: %v", s)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PredictionResultPredictionItemTrajectoryItem) Validate() error {
|
||||
func (s *PredictionResponsePredictionItemTrajectoryItem) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
|
@ -181,6 +187,126 @@ func (s *PredictionResultPredictionItemTrajectoryItem) Validate() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *PredictionResponseRequest) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if value, ok := s.LaunchLatitude.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "launch_latitude",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.LaunchLongitude.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "launch_longitude",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.LaunchAltitude.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "launch_altitude",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.AscentRate.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "ascent_rate",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.BurstAltitude.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "burst_altitude",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.DescentRate.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.Float{}).Validate(float64(value)); err != nil {
|
||||
return errors.Wrap(err, "float")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "descent_rate",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ReadinessResponse) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
package scheduler
|
||||
|
||||
import (
|
||||
"git.intra.yksa.space/gsn/predictor/internal/pkg/errcodes"
|
||||
env "github.com/caarlos0/env/v11"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Enabled bool `env:"ENABLED" envDefault:"true"`
|
||||
}
|
||||
|
||||
func NewConfig() (*Config, error) {
|
||||
cfg := &Config{}
|
||||
if err := env.ParseWithOptions(cfg, env.Options{
|
||||
PrefixTagName: "GSN_PREDICTOR_SCHEDULER_",
|
||||
}); err != nil {
|
||||
return nil, errcodes.Wrap(err, "failed to parse scheduler config")
|
||||
}
|
||||
return cfg, nil
|
||||
}
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
package scheduler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.intra.yksa.space/gsn/predictor/internal/pkg/errcodes"
|
||||
"git.intra.yksa.space/gsn/predictor/internal/pkg/log"
|
||||
"github.com/go-co-op/gocron"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type Job interface {
|
||||
GetInterval() time.Duration
|
||||
GetTimeout() time.Duration
|
||||
GetCount() int
|
||||
GetAsync() bool
|
||||
Execute(context.Context) error
|
||||
}
|
||||
|
||||
type Scheduler struct {
|
||||
scheduler *gocron.Scheduler
|
||||
}
|
||||
|
||||
func New() *Scheduler {
|
||||
scheduler := gocron.NewScheduler(time.UTC)
|
||||
return &Scheduler{
|
||||
scheduler: scheduler,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Scheduler) AddJob(job Job) error {
|
||||
interval := job.GetInterval()
|
||||
timeout := job.GetTimeout()
|
||||
count := job.GetCount()
|
||||
async := job.GetAsync()
|
||||
|
||||
// Validate job parameters
|
||||
if !async && count != 1 {
|
||||
return errcodes.ErrSchedulerInvalidJob
|
||||
}
|
||||
if timeout > interval {
|
||||
return errcodes.ErrSchedulerTimeoutTooLong
|
||||
}
|
||||
|
||||
// Create job function with timeout
|
||||
jobFunc := func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
logger := log.Ctx(ctx)
|
||||
if err := job.Execute(ctx); err != nil {
|
||||
logger.Error("job execution failed",
|
||||
zap.Error(err),
|
||||
zap.Duration("interval", interval),
|
||||
zap.Duration("timeout", timeout))
|
||||
} else {
|
||||
logger.Debug("job executed successfully",
|
||||
zap.Duration("interval", interval),
|
||||
zap.Duration("timeout", timeout))
|
||||
}
|
||||
}
|
||||
|
||||
// Add job to scheduler
|
||||
schedulerJob := s.scheduler.Every(interval)
|
||||
|
||||
if !async {
|
||||
schedulerJob = schedulerJob.SingletonMode()
|
||||
}
|
||||
|
||||
if count > 0 {
|
||||
schedulerJob = schedulerJob.LimitRunsTo(count)
|
||||
}
|
||||
|
||||
schedulerJob.Do(jobFunc)
|
||||
|
||||
log.Ctx(context.Background()).Info("job added to scheduler",
|
||||
zap.Duration("interval", interval),
|
||||
zap.Duration("timeout", timeout),
|
||||
zap.Int("count", count),
|
||||
zap.Bool("async", async))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Scheduler) Start() {
|
||||
s.scheduler.StartAsync()
|
||||
log.Ctx(context.Background()).Info("scheduler started")
|
||||
}
|
||||
|
||||
func (s *Scheduler) Stop() {
|
||||
s.scheduler.Stop()
|
||||
log.Ctx(context.Background()).Info("scheduler stopped")
|
||||
}
|
||||
|
||||
func (s *Scheduler) IsRunning() bool {
|
||||
return s.scheduler.IsRunning()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue