2024-12-14 19:55:56 +00:00
|
|
|
// Code generated by ogen, DO NOT EDIT.
|
|
|
|
|
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"mime"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/go-faster/errors"
|
|
|
|
"github.com/go-faster/jx"
|
|
|
|
|
|
|
|
"github.com/ogen-go/ogen/ogenerrors"
|
|
|
|
"github.com/ogen-go/ogen/validate"
|
|
|
|
)
|
|
|
|
|
2024-12-18 02:12:00 +00:00
|
|
|
func decodeActionSubmissionAcceptedResponse(resp *http.Response) (res *ActionSubmissionAcceptedNoContent, _ error) {
|
|
|
|
switch resp.StatusCode {
|
|
|
|
case 204:
|
|
|
|
// Code 204.
|
|
|
|
return &ActionSubmissionAcceptedNoContent{}, nil
|
|
|
|
}
|
|
|
|
// Convenient error response.
|
|
|
|
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
|
|
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
buf, err := io.ReadAll(resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var response Error
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.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 res, err
|
|
|
|
}
|
|
|
|
return &ErrorStatusCode{
|
|
|
|
StatusCode: resp.StatusCode,
|
|
|
|
Response: response,
|
|
|
|
}, nil
|
|
|
|
default:
|
|
|
|
return res, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
|
|
}
|
|
|
|
return res, errors.Wrap(defRes, "error")
|
|
|
|
}
|
|
|
|
|
2024-12-14 19:55:56 +00:00
|
|
|
func decodeActionSubmissionReleasedResponse(resp *http.Response) (res *ActionSubmissionReleasedNoContent, _ error) {
|
|
|
|
switch resp.StatusCode {
|
|
|
|
case 204:
|
|
|
|
// Code 204.
|
|
|
|
return &ActionSubmissionReleasedNoContent{}, nil
|
|
|
|
}
|
|
|
|
// Convenient error response.
|
|
|
|
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
|
|
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
buf, err := io.ReadAll(resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var response Error
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.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 res, err
|
|
|
|
}
|
|
|
|
return &ErrorStatusCode{
|
|
|
|
StatusCode: resp.StatusCode,
|
|
|
|
Response: response,
|
|
|
|
}, nil
|
|
|
|
default:
|
|
|
|
return res, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
|
|
}
|
|
|
|
return res, errors.Wrap(defRes, "error")
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeActionSubmissionUploadedResponse(resp *http.Response) (res *ActionSubmissionUploadedNoContent, _ error) {
|
|
|
|
switch resp.StatusCode {
|
|
|
|
case 204:
|
|
|
|
// Code 204.
|
|
|
|
return &ActionSubmissionUploadedNoContent{}, nil
|
|
|
|
}
|
|
|
|
// Convenient error response.
|
|
|
|
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
|
|
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
buf, err := io.ReadAll(resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var response Error
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.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 res, err
|
|
|
|
}
|
|
|
|
return &ErrorStatusCode{
|
|
|
|
StatusCode: resp.StatusCode,
|
|
|
|
Response: response,
|
|
|
|
}, nil
|
|
|
|
default:
|
|
|
|
return res, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
|
|
}
|
|
|
|
return res, errors.Wrap(defRes, "error")
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeActionSubmissionValidatedResponse(resp *http.Response) (res *ActionSubmissionValidatedNoContent, _ error) {
|
|
|
|
switch resp.StatusCode {
|
|
|
|
case 204:
|
|
|
|
// Code 204.
|
|
|
|
return &ActionSubmissionValidatedNoContent{}, nil
|
|
|
|
}
|
|
|
|
// Convenient error response.
|
|
|
|
defRes, err := func() (res *ErrorStatusCode, err error) {
|
2024-12-18 02:12:00 +00:00
|
|
|
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
buf, err := io.ReadAll(resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var response Error
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.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 res, err
|
|
|
|
}
|
|
|
|
return &ErrorStatusCode{
|
|
|
|
StatusCode: resp.StatusCode,
|
|
|
|
Response: response,
|
|
|
|
}, nil
|
|
|
|
default:
|
|
|
|
return res, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
|
|
}
|
|
|
|
return res, errors.Wrap(defRes, "error")
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeCreateScriptResponse(resp *http.Response) (res *ID, _ error) {
|
|
|
|
switch resp.StatusCode {
|
|
|
|
case 201:
|
|
|
|
// Code 201.
|
|
|
|
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
buf, err := io.ReadAll(resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var response ID
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.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 res, err
|
|
|
|
}
|
|
|
|
return &response, nil
|
|
|
|
default:
|
|
|
|
return res, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Convenient error response.
|
|
|
|
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
|
|
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
buf, err := io.ReadAll(resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var response Error
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.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 res, err
|
|
|
|
}
|
|
|
|
return &ErrorStatusCode{
|
|
|
|
StatusCode: resp.StatusCode,
|
|
|
|
Response: response,
|
|
|
|
}, nil
|
|
|
|
default:
|
|
|
|
return res, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
|
|
}
|
|
|
|
return res, errors.Wrap(defRes, "error")
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeCreateScriptPolicyResponse(resp *http.Response) (res *ID, _ error) {
|
|
|
|
switch resp.StatusCode {
|
|
|
|
case 201:
|
|
|
|
// Code 201.
|
|
|
|
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
buf, err := io.ReadAll(resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var response ID
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.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 res, err
|
|
|
|
}
|
|
|
|
return &response, nil
|
|
|
|
default:
|
|
|
|
return res, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Convenient error response.
|
|
|
|
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
|
|
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
buf, err := io.ReadAll(resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var response Error
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.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 res, err
|
|
|
|
}
|
|
|
|
return &ErrorStatusCode{
|
|
|
|
StatusCode: resp.StatusCode,
|
|
|
|
Response: response,
|
|
|
|
}, nil
|
|
|
|
default:
|
|
|
|
return res, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
|
|
}
|
|
|
|
return res, errors.Wrap(defRes, "error")
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeGetScriptResponse(resp *http.Response) (res *Script, _ error) {
|
|
|
|
switch resp.StatusCode {
|
|
|
|
case 200:
|
|
|
|
// Code 200.
|
|
|
|
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
buf, err := io.ReadAll(resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var response Script
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.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 res, err
|
|
|
|
}
|
|
|
|
// Validate response.
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.Validate(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}(); err != nil {
|
|
|
|
return res, errors.Wrap(err, "validate")
|
|
|
|
}
|
|
|
|
return &response, nil
|
|
|
|
default:
|
|
|
|
return res, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Convenient error response.
|
|
|
|
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
|
|
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
buf, err := io.ReadAll(resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var response Error
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.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 res, err
|
|
|
|
}
|
|
|
|
return &ErrorStatusCode{
|
|
|
|
StatusCode: resp.StatusCode,
|
|
|
|
Response: response,
|
|
|
|
}, nil
|
|
|
|
default:
|
|
|
|
return res, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
|
|
}
|
|
|
|
return res, errors.Wrap(defRes, "error")
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeGetScriptPolicyFromHashResponse(resp *http.Response) (res *ScriptPolicy, _ error) {
|
|
|
|
switch resp.StatusCode {
|
|
|
|
case 200:
|
|
|
|
// Code 200.
|
|
|
|
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
buf, err := io.ReadAll(resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var response ScriptPolicy
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.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 res, err
|
|
|
|
}
|
|
|
|
// Validate response.
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.Validate(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}(); err != nil {
|
|
|
|
return res, errors.Wrap(err, "validate")
|
|
|
|
}
|
|
|
|
return &response, nil
|
|
|
|
default:
|
|
|
|
return res, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Convenient error response.
|
|
|
|
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
|
|
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
buf, err := io.ReadAll(resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var response Error
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.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 res, err
|
|
|
|
}
|
|
|
|
return &ErrorStatusCode{
|
|
|
|
StatusCode: resp.StatusCode,
|
|
|
|
Response: response,
|
|
|
|
}, nil
|
|
|
|
default:
|
|
|
|
return res, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
|
|
}
|
|
|
|
return res, errors.Wrap(defRes, "error")
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeUpdateSubmissionModelResponse(resp *http.Response) (res *UpdateSubmissionModelNoContent, _ error) {
|
|
|
|
switch resp.StatusCode {
|
|
|
|
case 204:
|
|
|
|
// Code 204.
|
|
|
|
return &UpdateSubmissionModelNoContent{}, nil
|
|
|
|
}
|
|
|
|
// Convenient error response.
|
|
|
|
defRes, err := func() (res *ErrorStatusCode, err error) {
|
2024-12-14 19:55:56 +00:00
|
|
|
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrap(err, "parse media type")
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
case ct == "application/json":
|
|
|
|
buf, err := io.ReadAll(resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
d := jx.DecodeBytes(buf)
|
|
|
|
|
|
|
|
var response Error
|
|
|
|
if err := func() error {
|
|
|
|
if err := response.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 res, err
|
|
|
|
}
|
|
|
|
return &ErrorStatusCode{
|
|
|
|
StatusCode: resp.StatusCode,
|
|
|
|
Response: response,
|
|
|
|
}, nil
|
|
|
|
default:
|
|
|
|
return res, validate.InvalidContentType(ct)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
if err != nil {
|
|
|
|
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
|
|
}
|
|
|
|
return res, errors.Wrap(defRes, "error")
|
|
|
|
}
|