133 lines
3.5 KiB
Go
133 lines
3.5 KiB
Go
// Code generated by ogen, DO NOT EDIT.
|
|
|
|
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/go-faster/errors"
|
|
"github.com/go-faster/jx"
|
|
"go.opentelemetry.io/otel/codes"
|
|
"go.opentelemetry.io/otel/trace"
|
|
|
|
ht "github.com/ogen-go/ogen/http"
|
|
)
|
|
|
|
func encodeActionSubmissionAcceptedResponse(response *ActionSubmissionAcceptedNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
w.WriteHeader(204)
|
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
|
|
return nil
|
|
}
|
|
|
|
func encodeActionSubmissionReleasedResponse(response *ActionSubmissionReleasedNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
w.WriteHeader(204)
|
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
|
|
return nil
|
|
}
|
|
|
|
func encodeActionSubmissionUploadedResponse(response *ActionSubmissionUploadedNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
w.WriteHeader(204)
|
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
|
|
return nil
|
|
}
|
|
|
|
func encodeActionSubmissionValidatedResponse(response *ActionSubmissionValidatedNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
w.WriteHeader(204)
|
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
|
|
return nil
|
|
}
|
|
|
|
func encodeCreateScriptResponse(response *ID, w http.ResponseWriter, span trace.Span) error {
|
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
w.WriteHeader(201)
|
|
span.SetStatus(codes.Ok, http.StatusText(201))
|
|
|
|
e := new(jx.Encoder)
|
|
response.Encode(e)
|
|
if _, err := e.WriteTo(w); err != nil {
|
|
return errors.Wrap(err, "write")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func encodeCreateScriptPolicyResponse(response *ID, w http.ResponseWriter, span trace.Span) error {
|
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
w.WriteHeader(201)
|
|
span.SetStatus(codes.Ok, http.StatusText(201))
|
|
|
|
e := new(jx.Encoder)
|
|
response.Encode(e)
|
|
if _, err := e.WriteTo(w); err != nil {
|
|
return errors.Wrap(err, "write")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func encodeGetScriptResponse(response *Script, 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))
|
|
|
|
e := new(jx.Encoder)
|
|
response.Encode(e)
|
|
if _, err := e.WriteTo(w); err != nil {
|
|
return errors.Wrap(err, "write")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func encodeGetScriptPolicyFromHashResponse(response *ScriptPolicy, 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))
|
|
|
|
e := new(jx.Encoder)
|
|
response.Encode(e)
|
|
if _, err := e.WriteTo(w); err != nil {
|
|
return errors.Wrap(err, "write")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func encodeUpdateSubmissionModelResponse(response *UpdateSubmissionModelNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
w.WriteHeader(204)
|
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
|
|
return nil
|
|
}
|
|
|
|
func encodeErrorResponse(response *ErrorStatusCode, w http.ResponseWriter, span trace.Span) error {
|
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
code := response.StatusCode
|
|
if code == 0 {
|
|
// Set default status code.
|
|
code = http.StatusOK
|
|
}
|
|
w.WriteHeader(code)
|
|
if st := http.StatusText(code); code >= http.StatusBadRequest {
|
|
span.SetStatus(codes.Error, st)
|
|
} else {
|
|
span.SetStatus(codes.Ok, st)
|
|
}
|
|
|
|
e := new(jx.Encoder)
|
|
response.Response.Encode(e)
|
|
if _, err := e.WriteTo(w); err != nil {
|
|
return errors.Wrap(err, "write")
|
|
}
|
|
|
|
if code >= http.StatusInternalServerError {
|
|
return errors.Wrapf(ht.ErrInternalServerErrorResponse, "code: %d, message: %s", code, http.StatusText(code))
|
|
}
|
|
return nil
|
|
|
|
}
|