2024-11-26 01:22:45 +00:00
|
|
|
// Code generated by ogen, DO NOT EDIT.
|
|
|
|
|
|
|
|
package api
|
2024-11-27 23:38:17 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"mime"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/go-faster/errors"
|
|
|
|
"github.com/go-faster/jx"
|
|
|
|
"go.uber.org/multierr"
|
|
|
|
|
|
|
|
"github.com/ogen-go/ogen/ogenerrors"
|
|
|
|
"github.com/ogen-go/ogen/validate"
|
|
|
|
)
|
|
|
|
|
2024-12-06 00:36:15 +00:00
|
|
|
func (s *Server) decodeCreateScriptRequest(r *http.Request) (
|
2024-12-06 02:48:26 +00:00
|
|
|
req *ScriptCreate,
|
2024-12-06 00:36:15 +00:00
|
|
|
close func() error,
|
|
|
|
rerr error,
|
|
|
|
) {
|
|
|
|
var closers []func() error
|
|
|
|
close = func() error {
|
|
|
|
var merr error
|
|
|
|
// Close in reverse order, to match defer behavior.
|
|
|
|
for i := len(closers) - 1; i >= 0; i-- {
|
|
|
|
c := closers[i]
|
|
|
|
merr = multierr.Append(merr, c())
|
|
|
|
}
|
|
|
|
return merr
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
if rerr != nil {
|
|
|
|
rerr = multierr.Append(rerr, close())
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return req, close, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
if r.ContentLength == 0 {
|
2024-12-06 02:48:26 +00:00
|
|
|
return req, close, validate.ErrBodyRequired
|
2024-12-06 00:36:15 +00:00
|
|
|
}
|
|
|
|
buf, err := io.ReadAll(r.Body)
|
|
|
|
if err != nil {
|
|
|
|
return req, close, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(buf) == 0 {
|
2024-12-06 02:48:26 +00:00
|
|
|
return req, close, validate.ErrBodyRequired
|
2024-12-06 00:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
2024-12-06 02:48:26 +00:00
|
|
|
var request ScriptCreate
|
2024-12-06 00:36:15 +00:00
|
|
|
if err := func() error {
|
|
|
|
if err := request.Decode(d); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := d.Skip(); err != io.EOF {
|
|
|
|
return errors.New("unexpected trailing data")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}(); err != nil {
|
|
|
|
err = &ogenerrors.DecodeBodyError{
|
|
|
|
ContentType: ct,
|
|
|
|
Body: buf,
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
return req, close, err
|
|
|
|
}
|
2024-12-10 06:06:33 +00:00
|
|
|
if err := func() error {
|
|
|
|
if err := request.Validate(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}(); err != nil {
|
|
|
|
return req, close, errors.Wrap(err, "validate")
|
|
|
|
}
|
2024-12-06 02:48:26 +00:00
|
|
|
return &request, close, nil
|
2024-12-06 00:36:15 +00:00
|
|
|
default:
|
|
|
|
return req, close, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) decodeCreateScriptPolicyRequest(r *http.Request) (
|
2024-12-06 02:48:26 +00:00
|
|
|
req *ScriptPolicyCreate,
|
2024-12-06 00:36:15 +00:00
|
|
|
close func() error,
|
|
|
|
rerr error,
|
|
|
|
) {
|
|
|
|
var closers []func() error
|
|
|
|
close = func() error {
|
|
|
|
var merr error
|
|
|
|
// Close in reverse order, to match defer behavior.
|
|
|
|
for i := len(closers) - 1; i >= 0; i-- {
|
|
|
|
c := closers[i]
|
|
|
|
merr = multierr.Append(merr, c())
|
|
|
|
}
|
|
|
|
return merr
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
if rerr != nil {
|
|
|
|
rerr = multierr.Append(rerr, close())
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return req, close, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
if r.ContentLength == 0 {
|
2024-12-06 02:48:26 +00:00
|
|
|
return req, close, validate.ErrBodyRequired
|
2024-12-06 00:36:15 +00:00
|
|
|
}
|
|
|
|
buf, err := io.ReadAll(r.Body)
|
|
|
|
if err != nil {
|
|
|
|
return req, close, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(buf) == 0 {
|
2024-12-06 02:48:26 +00:00
|
|
|
return req, close, validate.ErrBodyRequired
|
2024-12-06 00:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
2024-12-06 02:48:26 +00:00
|
|
|
var request ScriptPolicyCreate
|
2024-12-06 00:36:15 +00:00
|
|
|
if err := func() error {
|
|
|
|
if err := request.Decode(d); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := d.Skip(); err != io.EOF {
|
|
|
|
return errors.New("unexpected trailing data")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}(); err != nil {
|
|
|
|
err = &ogenerrors.DecodeBodyError{
|
|
|
|
ContentType: ct,
|
|
|
|
Body: buf,
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
return req, close, err
|
|
|
|
}
|
2024-12-06 02:48:26 +00:00
|
|
|
return &request, close, nil
|
2024-12-06 00:36:15 +00:00
|
|
|
default:
|
|
|
|
return req, close, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-27 23:38:17 +00:00
|
|
|
func (s *Server) decodeCreateSubmissionRequest(r *http.Request) (
|
2024-12-06 02:48:26 +00:00
|
|
|
req *SubmissionCreate,
|
2024-11-27 23:38:17 +00:00
|
|
|
close func() error,
|
|
|
|
rerr error,
|
|
|
|
) {
|
|
|
|
var closers []func() error
|
|
|
|
close = func() error {
|
|
|
|
var merr error
|
|
|
|
// Close in reverse order, to match defer behavior.
|
|
|
|
for i := len(closers) - 1; i >= 0; i-- {
|
|
|
|
c := closers[i]
|
|
|
|
merr = multierr.Append(merr, c())
|
|
|
|
}
|
|
|
|
return merr
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
if rerr != nil {
|
|
|
|
rerr = multierr.Append(rerr, close())
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return req, close, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
if r.ContentLength == 0 {
|
2024-12-06 02:48:26 +00:00
|
|
|
return req, close, validate.ErrBodyRequired
|
2024-11-27 23:38:17 +00:00
|
|
|
}
|
|
|
|
buf, err := io.ReadAll(r.Body)
|
|
|
|
if err != nil {
|
|
|
|
return req, close, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(buf) == 0 {
|
2024-12-06 02:48:26 +00:00
|
|
|
return req, close, validate.ErrBodyRequired
|
2024-11-27 23:38:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
2024-12-06 02:48:26 +00:00
|
|
|
var request SubmissionCreate
|
2024-11-27 23:38:17 +00:00
|
|
|
if err := func() error {
|
|
|
|
if err := request.Decode(d); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := d.Skip(); err != io.EOF {
|
|
|
|
return errors.New("unexpected trailing data")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}(); err != nil {
|
|
|
|
err = &ogenerrors.DecodeBodyError{
|
|
|
|
ContentType: ct,
|
|
|
|
Body: buf,
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
return req, close, err
|
|
|
|
}
|
2024-12-10 06:06:33 +00:00
|
|
|
if err := func() error {
|
|
|
|
if err := request.Validate(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}(); err != nil {
|
|
|
|
return req, close, errors.Wrap(err, "validate")
|
2024-12-14 06:43:32 +00:00
|
|
|
}
|
|
|
|
return &request, close, nil
|
|
|
|
default:
|
|
|
|
return req, close, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) decodeListScriptPolicyRequest(r *http.Request) (
|
|
|
|
req *ListScriptPolicyReq,
|
|
|
|
close func() error,
|
|
|
|
rerr error,
|
|
|
|
) {
|
|
|
|
var closers []func() error
|
|
|
|
close = func() error {
|
|
|
|
var merr error
|
|
|
|
// Close in reverse order, to match defer behavior.
|
|
|
|
for i := len(closers) - 1; i >= 0; i-- {
|
|
|
|
c := closers[i]
|
|
|
|
merr = multierr.Append(merr, c())
|
|
|
|
}
|
|
|
|
return merr
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
if rerr != nil {
|
|
|
|
rerr = multierr.Append(rerr, close())
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return req, close, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
if r.ContentLength == 0 {
|
|
|
|
return req, close, validate.ErrBodyRequired
|
|
|
|
}
|
|
|
|
buf, err := io.ReadAll(r.Body)
|
|
|
|
if err != nil {
|
|
|
|
return req, close, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(buf) == 0 {
|
|
|
|
return req, close, validate.ErrBodyRequired
|
|
|
|
}
|
|
|
|
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var request ListScriptPolicyReq
|
|
|
|
if err := func() error {
|
|
|
|
if err := request.Decode(d); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := d.Skip(); err != io.EOF {
|
|
|
|
return errors.New("unexpected trailing data")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}(); err != nil {
|
|
|
|
err = &ogenerrors.DecodeBodyError{
|
|
|
|
ContentType: ct,
|
|
|
|
Body: buf,
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
return req, close, err
|
|
|
|
}
|
|
|
|
if err := func() error {
|
|
|
|
if err := request.Validate(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}(); err != nil {
|
|
|
|
return req, close, errors.Wrap(err, "validate")
|
|
|
|
}
|
|
|
|
return &request, close, nil
|
|
|
|
default:
|
|
|
|
return req, close, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) decodeListSubmissionsRequest(r *http.Request) (
|
|
|
|
req *ListSubmissionsReq,
|
|
|
|
close func() error,
|
|
|
|
rerr error,
|
|
|
|
) {
|
|
|
|
var closers []func() error
|
|
|
|
close = func() error {
|
|
|
|
var merr error
|
|
|
|
// Close in reverse order, to match defer behavior.
|
|
|
|
for i := len(closers) - 1; i >= 0; i-- {
|
|
|
|
c := closers[i]
|
|
|
|
merr = multierr.Append(merr, c())
|
|
|
|
}
|
|
|
|
return merr
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
if rerr != nil {
|
|
|
|
rerr = multierr.Append(rerr, close())
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return req, close, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
if r.ContentLength == 0 {
|
|
|
|
return req, close, validate.ErrBodyRequired
|
|
|
|
}
|
|
|
|
buf, err := io.ReadAll(r.Body)
|
|
|
|
if err != nil {
|
|
|
|
return req, close, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(buf) == 0 {
|
|
|
|
return req, close, validate.ErrBodyRequired
|
|
|
|
}
|
|
|
|
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var request ListSubmissionsReq
|
|
|
|
if err := func() error {
|
|
|
|
if err := request.Decode(d); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := d.Skip(); err != io.EOF {
|
|
|
|
return errors.New("unexpected trailing data")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}(); err != nil {
|
|
|
|
err = &ogenerrors.DecodeBodyError{
|
|
|
|
ContentType: ct,
|
|
|
|
Body: buf,
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
return req, close, err
|
|
|
|
}
|
|
|
|
if err := func() error {
|
|
|
|
if err := request.Validate(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}(); err != nil {
|
|
|
|
return req, close, errors.Wrap(err, "validate")
|
2024-12-10 06:06:33 +00:00
|
|
|
}
|
2024-12-06 02:48:26 +00:00
|
|
|
return &request, close, nil
|
2024-11-27 23:38:17 +00:00
|
|
|
default:
|
|
|
|
return req, close, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}
|
2024-12-06 00:36:15 +00:00
|
|
|
|
|
|
|
func (s *Server) decodeUpdateScriptRequest(r *http.Request) (
|
2024-12-06 02:48:26 +00:00
|
|
|
req *ScriptUpdate,
|
2024-12-06 00:36:15 +00:00
|
|
|
close func() error,
|
|
|
|
rerr error,
|
|
|
|
) {
|
|
|
|
var closers []func() error
|
|
|
|
close = func() error {
|
|
|
|
var merr error
|
|
|
|
// Close in reverse order, to match defer behavior.
|
|
|
|
for i := len(closers) - 1; i >= 0; i-- {
|
|
|
|
c := closers[i]
|
|
|
|
merr = multierr.Append(merr, c())
|
|
|
|
}
|
|
|
|
return merr
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
if rerr != nil {
|
|
|
|
rerr = multierr.Append(rerr, close())
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return req, close, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
if r.ContentLength == 0 {
|
2024-12-06 02:48:26 +00:00
|
|
|
return req, close, validate.ErrBodyRequired
|
2024-12-06 00:36:15 +00:00
|
|
|
}
|
|
|
|
buf, err := io.ReadAll(r.Body)
|
|
|
|
if err != nil {
|
|
|
|
return req, close, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(buf) == 0 {
|
2024-12-06 02:48:26 +00:00
|
|
|
return req, close, validate.ErrBodyRequired
|
2024-12-06 00:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
2024-12-06 02:48:26 +00:00
|
|
|
var request ScriptUpdate
|
2024-12-06 00:36:15 +00:00
|
|
|
if err := func() error {
|
|
|
|
if err := request.Decode(d); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := d.Skip(); err != io.EOF {
|
|
|
|
return errors.New("unexpected trailing data")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}(); err != nil {
|
|
|
|
err = &ogenerrors.DecodeBodyError{
|
|
|
|
ContentType: ct,
|
|
|
|
Body: buf,
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
return req, close, err
|
|
|
|
}
|
2024-12-10 06:06:33 +00:00
|
|
|
if err := func() error {
|
|
|
|
if err := request.Validate(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}(); err != nil {
|
|
|
|
return req, close, errors.Wrap(err, "validate")
|
|
|
|
}
|
2024-12-06 02:48:26 +00:00
|
|
|
return &request, close, nil
|
2024-12-06 00:36:15 +00:00
|
|
|
default:
|
|
|
|
return req, close, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) decodeUpdateScriptPolicyRequest(r *http.Request) (
|
2024-12-06 02:48:26 +00:00
|
|
|
req *ScriptPolicyUpdate,
|
2024-12-06 00:36:15 +00:00
|
|
|
close func() error,
|
|
|
|
rerr error,
|
|
|
|
) {
|
|
|
|
var closers []func() error
|
|
|
|
close = func() error {
|
|
|
|
var merr error
|
|
|
|
// Close in reverse order, to match defer behavior.
|
|
|
|
for i := len(closers) - 1; i >= 0; i-- {
|
|
|
|
c := closers[i]
|
|
|
|
merr = multierr.Append(merr, c())
|
|
|
|
}
|
|
|
|
return merr
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
if rerr != nil {
|
|
|
|
rerr = multierr.Append(rerr, close())
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return req, close, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
if r.ContentLength == 0 {
|
2024-12-06 02:48:26 +00:00
|
|
|
return req, close, validate.ErrBodyRequired
|
2024-12-06 00:36:15 +00:00
|
|
|
}
|
|
|
|
buf, err := io.ReadAll(r.Body)
|
|
|
|
if err != nil {
|
|
|
|
return req, close, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(buf) == 0 {
|
2024-12-06 02:48:26 +00:00
|
|
|
return req, close, validate.ErrBodyRequired
|
2024-12-06 00:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
2024-12-06 02:48:26 +00:00
|
|
|
var request ScriptPolicyUpdate
|
2024-12-06 00:36:15 +00:00
|
|
|
if err := func() error {
|
|
|
|
if err := request.Decode(d); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := d.Skip(); err != io.EOF {
|
|
|
|
return errors.New("unexpected trailing data")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}(); err != nil {
|
|
|
|
err = &ogenerrors.DecodeBodyError{
|
|
|
|
ContentType: ct,
|
|
|
|
Body: buf,
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
return req, close, err
|
|
|
|
}
|
2024-12-06 02:48:26 +00:00
|
|
|
return &request, close, nil
|
2024-12-06 00:36:15 +00:00
|
|
|
default:
|
|
|
|
return req, close, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}
|