This commit is contained in:
Anatoly Antonov 2026-05-18 02:09:07 +09:00
parent c4f355a32e
commit 7a8d5d13fa
72 changed files with 4510 additions and 4104 deletions

View file

@ -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)