openapi: generate
This commit is contained in:
parent
0b1e7085e3
commit
f52e0a91a2
@ -29,6 +29,12 @@ func trimTrailingSlashes(u *url.URL) {
|
|||||||
|
|
||||||
// Invoker invokes operations described by OpenAPI v3 specification.
|
// Invoker invokes operations described by OpenAPI v3 specification.
|
||||||
type Invoker interface {
|
type Invoker interface {
|
||||||
|
// ActionSubmissionAccepted invokes actionSubmissionAccepted operation.
|
||||||
|
//
|
||||||
|
// Role Reviewer manually resets validating softlock and changes status from Validating -> Accepted.
|
||||||
|
//
|
||||||
|
// POST /submissions/{SubmissionID}/status/reset-validating
|
||||||
|
ActionSubmissionAccepted(ctx context.Context, params ActionSubmissionAcceptedParams) error
|
||||||
// ActionSubmissionReject invokes actionSubmissionReject operation.
|
// ActionSubmissionReject invokes actionSubmissionReject operation.
|
||||||
//
|
//
|
||||||
// Role Reviewer changes status from Submitted -> Rejected.
|
// Role Reviewer changes status from Submitted -> Rejected.
|
||||||
@ -65,6 +71,12 @@ type Invoker interface {
|
|||||||
//
|
//
|
||||||
// POST /submissions/{SubmissionID}/status/trigger-validate
|
// POST /submissions/{SubmissionID}/status/trigger-validate
|
||||||
ActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) error
|
ActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) error
|
||||||
|
// ActionSubmissionValidated invokes actionSubmissionValidated operation.
|
||||||
|
//
|
||||||
|
// Role Admin manually resets uploading softlock and changes status from Uploading -> Validated.
|
||||||
|
//
|
||||||
|
// POST /submissions/{SubmissionID}/status/reset-uploading
|
||||||
|
ActionSubmissionValidated(ctx context.Context, params ActionSubmissionValidatedParams) error
|
||||||
// CreateScript invokes createScript operation.
|
// CreateScript invokes createScript operation.
|
||||||
//
|
//
|
||||||
// Create a new script.
|
// Create a new script.
|
||||||
@ -212,6 +224,130 @@ func (c *Client) requestURL(ctx context.Context) *url.URL {
|
|||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ActionSubmissionAccepted invokes actionSubmissionAccepted operation.
|
||||||
|
//
|
||||||
|
// Role Reviewer manually resets validating softlock and changes status from Validating -> Accepted.
|
||||||
|
//
|
||||||
|
// POST /submissions/{SubmissionID}/status/reset-validating
|
||||||
|
func (c *Client) ActionSubmissionAccepted(ctx context.Context, params ActionSubmissionAcceptedParams) error {
|
||||||
|
_, err := c.sendActionSubmissionAccepted(ctx, params)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) sendActionSubmissionAccepted(ctx context.Context, params ActionSubmissionAcceptedParams) (res *ActionSubmissionAcceptedNoContent, err error) {
|
||||||
|
otelAttrs := []attribute.KeyValue{
|
||||||
|
otelogen.OperationID("actionSubmissionAccepted"),
|
||||||
|
semconv.HTTPRequestMethodKey.String("POST"),
|
||||||
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/reset-validating"),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run stopwatch.
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
||||||
|
elapsedDuration := time.Since(startTime)
|
||||||
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Increment request counter.
|
||||||
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||||||
|
|
||||||
|
// Start a span for this request.
|
||||||
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionSubmissionAcceptedOperation,
|
||||||
|
trace.WithAttributes(otelAttrs...),
|
||||||
|
clientSpanKind,
|
||||||
|
)
|
||||||
|
// Track stage for error reporting.
|
||||||
|
var stage string
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
span.RecordError(err)
|
||||||
|
span.SetStatus(codes.Error, stage)
|
||||||
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||||||
|
}
|
||||||
|
span.End()
|
||||||
|
}()
|
||||||
|
|
||||||
|
stage = "BuildURL"
|
||||||
|
u := uri.Clone(c.requestURL(ctx))
|
||||||
|
var pathParts [3]string
|
||||||
|
pathParts[0] = "/submissions/"
|
||||||
|
{
|
||||||
|
// Encode "SubmissionID" parameter.
|
||||||
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||||||
|
Param: "SubmissionID",
|
||||||
|
Style: uri.PathStyleSimple,
|
||||||
|
Explode: false,
|
||||||
|
})
|
||||||
|
if err := func() error {
|
||||||
|
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
||||||
|
}(); err != nil {
|
||||||
|
return res, errors.Wrap(err, "encode path")
|
||||||
|
}
|
||||||
|
encoded, err := e.Result()
|
||||||
|
if err != nil {
|
||||||
|
return res, errors.Wrap(err, "encode path")
|
||||||
|
}
|
||||||
|
pathParts[1] = encoded
|
||||||
|
}
|
||||||
|
pathParts[2] = "/status/reset-validating"
|
||||||
|
uri.AddPathParts(u, pathParts[:]...)
|
||||||
|
|
||||||
|
stage = "EncodeRequest"
|
||||||
|
r, err := ht.NewRequest(ctx, "POST", u)
|
||||||
|
if err != nil {
|
||||||
|
return res, errors.Wrap(err, "create request")
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
type bitset = [1]uint8
|
||||||
|
var satisfied bitset
|
||||||
|
{
|
||||||
|
stage = "Security:CookieAuth"
|
||||||
|
switch err := c.securityCookieAuth(ctx, ActionSubmissionAcceptedOperation, r); {
|
||||||
|
case err == nil: // if NO error
|
||||||
|
satisfied[0] |= 1 << 0
|
||||||
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||||||
|
// Skip this security.
|
||||||
|
default:
|
||||||
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ok := func() bool {
|
||||||
|
nextRequirement:
|
||||||
|
for _, requirement := range []bitset{
|
||||||
|
{0b00000001},
|
||||||
|
} {
|
||||||
|
for i, mask := range requirement {
|
||||||
|
if satisfied[i]&mask != mask {
|
||||||
|
continue nextRequirement
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}(); !ok {
|
||||||
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage = "SendRequest"
|
||||||
|
resp, err := c.cfg.Client.Do(r)
|
||||||
|
if err != nil {
|
||||||
|
return res, errors.Wrap(err, "do request")
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
stage = "DecodeResponse"
|
||||||
|
result, err := decodeActionSubmissionAcceptedResponse(resp)
|
||||||
|
if err != nil {
|
||||||
|
return res, errors.Wrap(err, "decode response")
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
// ActionSubmissionReject invokes actionSubmissionReject operation.
|
// ActionSubmissionReject invokes actionSubmissionReject operation.
|
||||||
//
|
//
|
||||||
// Role Reviewer changes status from Submitted -> Rejected.
|
// Role Reviewer changes status from Submitted -> Rejected.
|
||||||
@ -956,6 +1092,130 @@ func (c *Client) sendActionSubmissionTriggerValidate(ctx context.Context, params
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ActionSubmissionValidated invokes actionSubmissionValidated operation.
|
||||||
|
//
|
||||||
|
// Role Admin manually resets uploading softlock and changes status from Uploading -> Validated.
|
||||||
|
//
|
||||||
|
// POST /submissions/{SubmissionID}/status/reset-uploading
|
||||||
|
func (c *Client) ActionSubmissionValidated(ctx context.Context, params ActionSubmissionValidatedParams) error {
|
||||||
|
_, err := c.sendActionSubmissionValidated(ctx, params)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) sendActionSubmissionValidated(ctx context.Context, params ActionSubmissionValidatedParams) (res *ActionSubmissionValidatedNoContent, err error) {
|
||||||
|
otelAttrs := []attribute.KeyValue{
|
||||||
|
otelogen.OperationID("actionSubmissionValidated"),
|
||||||
|
semconv.HTTPRequestMethodKey.String("POST"),
|
||||||
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/reset-uploading"),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run stopwatch.
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
||||||
|
elapsedDuration := time.Since(startTime)
|
||||||
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Increment request counter.
|
||||||
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||||||
|
|
||||||
|
// Start a span for this request.
|
||||||
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionSubmissionValidatedOperation,
|
||||||
|
trace.WithAttributes(otelAttrs...),
|
||||||
|
clientSpanKind,
|
||||||
|
)
|
||||||
|
// Track stage for error reporting.
|
||||||
|
var stage string
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
span.RecordError(err)
|
||||||
|
span.SetStatus(codes.Error, stage)
|
||||||
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||||||
|
}
|
||||||
|
span.End()
|
||||||
|
}()
|
||||||
|
|
||||||
|
stage = "BuildURL"
|
||||||
|
u := uri.Clone(c.requestURL(ctx))
|
||||||
|
var pathParts [3]string
|
||||||
|
pathParts[0] = "/submissions/"
|
||||||
|
{
|
||||||
|
// Encode "SubmissionID" parameter.
|
||||||
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||||||
|
Param: "SubmissionID",
|
||||||
|
Style: uri.PathStyleSimple,
|
||||||
|
Explode: false,
|
||||||
|
})
|
||||||
|
if err := func() error {
|
||||||
|
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
||||||
|
}(); err != nil {
|
||||||
|
return res, errors.Wrap(err, "encode path")
|
||||||
|
}
|
||||||
|
encoded, err := e.Result()
|
||||||
|
if err != nil {
|
||||||
|
return res, errors.Wrap(err, "encode path")
|
||||||
|
}
|
||||||
|
pathParts[1] = encoded
|
||||||
|
}
|
||||||
|
pathParts[2] = "/status/reset-uploading"
|
||||||
|
uri.AddPathParts(u, pathParts[:]...)
|
||||||
|
|
||||||
|
stage = "EncodeRequest"
|
||||||
|
r, err := ht.NewRequest(ctx, "POST", u)
|
||||||
|
if err != nil {
|
||||||
|
return res, errors.Wrap(err, "create request")
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
type bitset = [1]uint8
|
||||||
|
var satisfied bitset
|
||||||
|
{
|
||||||
|
stage = "Security:CookieAuth"
|
||||||
|
switch err := c.securityCookieAuth(ctx, ActionSubmissionValidatedOperation, r); {
|
||||||
|
case err == nil: // if NO error
|
||||||
|
satisfied[0] |= 1 << 0
|
||||||
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||||||
|
// Skip this security.
|
||||||
|
default:
|
||||||
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ok := func() bool {
|
||||||
|
nextRequirement:
|
||||||
|
for _, requirement := range []bitset{
|
||||||
|
{0b00000001},
|
||||||
|
} {
|
||||||
|
for i, mask := range requirement {
|
||||||
|
if satisfied[i]&mask != mask {
|
||||||
|
continue nextRequirement
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}(); !ok {
|
||||||
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage = "SendRequest"
|
||||||
|
resp, err := c.cfg.Client.Do(r)
|
||||||
|
if err != nil {
|
||||||
|
return res, errors.Wrap(err, "do request")
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
stage = "DecodeResponse"
|
||||||
|
result, err := decodeActionSubmissionValidatedResponse(resp)
|
||||||
|
if err != nil {
|
||||||
|
return res, errors.Wrap(err, "decode response")
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
// CreateScript invokes createScript operation.
|
// CreateScript invokes createScript operation.
|
||||||
//
|
//
|
||||||
// Create a new script.
|
// Create a new script.
|
||||||
|
@ -30,6 +30,201 @@ func (c *codeRecorder) WriteHeader(status int) {
|
|||||||
c.ResponseWriter.WriteHeader(status)
|
c.ResponseWriter.WriteHeader(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleActionSubmissionAcceptedRequest handles actionSubmissionAccepted operation.
|
||||||
|
//
|
||||||
|
// Role Reviewer manually resets validating softlock and changes status from Validating -> Accepted.
|
||||||
|
//
|
||||||
|
// POST /submissions/{SubmissionID}/status/reset-validating
|
||||||
|
func (s *Server) handleActionSubmissionAcceptedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||||
|
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||||
|
w = statusWriter
|
||||||
|
otelAttrs := []attribute.KeyValue{
|
||||||
|
otelogen.OperationID("actionSubmissionAccepted"),
|
||||||
|
semconv.HTTPRequestMethodKey.String("POST"),
|
||||||
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/reset-validating"),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start a span for this request.
|
||||||
|
ctx, span := s.cfg.Tracer.Start(r.Context(), ActionSubmissionAcceptedOperation,
|
||||||
|
trace.WithAttributes(otelAttrs...),
|
||||||
|
serverSpanKind,
|
||||||
|
)
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
// Add Labeler to context.
|
||||||
|
labeler := &Labeler{attrs: otelAttrs}
|
||||||
|
ctx = contextWithLabeler(ctx, labeler)
|
||||||
|
|
||||||
|
// Run stopwatch.
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
elapsedDuration := time.Since(startTime)
|
||||||
|
|
||||||
|
attrSet := labeler.AttributeSet()
|
||||||
|
attrs := attrSet.ToSlice()
|
||||||
|
code := statusWriter.status
|
||||||
|
if code != 0 {
|
||||||
|
codeAttr := semconv.HTTPResponseStatusCode(code)
|
||||||
|
attrs = append(attrs, codeAttr)
|
||||||
|
span.SetAttributes(codeAttr)
|
||||||
|
}
|
||||||
|
attrOpt := metric.WithAttributes(attrs...)
|
||||||
|
|
||||||
|
// Increment request counter.
|
||||||
|
s.requests.Add(ctx, 1, attrOpt)
|
||||||
|
|
||||||
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
||||||
|
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
|
||||||
|
}()
|
||||||
|
|
||||||
|
var (
|
||||||
|
recordError = func(stage string, err error) {
|
||||||
|
span.RecordError(err)
|
||||||
|
|
||||||
|
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
|
||||||
|
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
|
||||||
|
// 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 {
|
||||||
|
span.SetStatus(codes.Error, stage)
|
||||||
|
}
|
||||||
|
|
||||||
|
attrSet := labeler.AttributeSet()
|
||||||
|
attrs := attrSet.ToSlice()
|
||||||
|
if code != 0 {
|
||||||
|
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
|
||||||
|
}
|
||||||
|
|
||||||
|
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
|
||||||
|
}
|
||||||
|
err error
|
||||||
|
opErrContext = ogenerrors.OperationContext{
|
||||||
|
Name: ActionSubmissionAcceptedOperation,
|
||||||
|
ID: "actionSubmissionAccepted",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
{
|
||||||
|
type bitset = [1]uint8
|
||||||
|
var satisfied bitset
|
||||||
|
{
|
||||||
|
sctx, ok, err := s.securityCookieAuth(ctx, ActionSubmissionAcceptedOperation, r)
|
||||||
|
if err != nil {
|
||||||
|
err = &ogenerrors.SecurityError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Security: "CookieAuth",
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||||
|
defer recordError("Security:CookieAuth", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok {
|
||||||
|
satisfied[0] |= 1 << 0
|
||||||
|
ctx = sctx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ok := func() bool {
|
||||||
|
nextRequirement:
|
||||||
|
for _, requirement := range []bitset{
|
||||||
|
{0b00000001},
|
||||||
|
} {
|
||||||
|
for i, mask := range requirement {
|
||||||
|
if satisfied[i]&mask != mask {
|
||||||
|
continue nextRequirement
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}(); !ok {
|
||||||
|
err = &ogenerrors.SecurityError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
|
||||||
|
}
|
||||||
|
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||||
|
defer recordError("Security", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
params, err := decodeActionSubmissionAcceptedParams(args, argsEscaped, r)
|
||||||
|
if err != nil {
|
||||||
|
err = &ogenerrors.DecodeParamsError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
defer recordError("DecodeParams", err)
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var response *ActionSubmissionAcceptedNoContent
|
||||||
|
if m := s.cfg.Middleware; m != nil {
|
||||||
|
mreq := middleware.Request{
|
||||||
|
Context: ctx,
|
||||||
|
OperationName: ActionSubmissionAcceptedOperation,
|
||||||
|
OperationSummary: "Role Reviewer manually resets validating softlock and changes status from Validating -> Accepted",
|
||||||
|
OperationID: "actionSubmissionAccepted",
|
||||||
|
Body: nil,
|
||||||
|
Params: middleware.Parameters{
|
||||||
|
{
|
||||||
|
Name: "SubmissionID",
|
||||||
|
In: "path",
|
||||||
|
}: params.SubmissionID,
|
||||||
|
},
|
||||||
|
Raw: r,
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
Request = struct{}
|
||||||
|
Params = ActionSubmissionAcceptedParams
|
||||||
|
Response = *ActionSubmissionAcceptedNoContent
|
||||||
|
)
|
||||||
|
response, err = middleware.HookMiddleware[
|
||||||
|
Request,
|
||||||
|
Params,
|
||||||
|
Response,
|
||||||
|
](
|
||||||
|
m,
|
||||||
|
mreq,
|
||||||
|
unpackActionSubmissionAcceptedParams,
|
||||||
|
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||||
|
err = s.h.ActionSubmissionAccepted(ctx, params)
|
||||||
|
return response, err
|
||||||
|
},
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
err = s.h.ActionSubmissionAccepted(ctx, params)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
if errRes, ok := errors.Into[*ErrorStatusCode](err); ok {
|
||||||
|
if err := encodeErrorResponse(errRes, w, span); err != nil {
|
||||||
|
defer recordError("Internal", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if errors.Is(err, ht.ErrNotImplemented) {
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
|
||||||
|
defer recordError("Internal", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := encodeActionSubmissionAcceptedResponse(response, w, span); err != nil {
|
||||||
|
defer recordError("EncodeResponse", err)
|
||||||
|
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// handleActionSubmissionRejectRequest handles actionSubmissionReject operation.
|
// handleActionSubmissionRejectRequest handles actionSubmissionReject operation.
|
||||||
//
|
//
|
||||||
// Role Reviewer changes status from Submitted -> Rejected.
|
// Role Reviewer changes status from Submitted -> Rejected.
|
||||||
@ -1200,6 +1395,201 @@ func (s *Server) handleActionSubmissionTriggerValidateRequest(args [1]string, ar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleActionSubmissionValidatedRequest handles actionSubmissionValidated operation.
|
||||||
|
//
|
||||||
|
// Role Admin manually resets uploading softlock and changes status from Uploading -> Validated.
|
||||||
|
//
|
||||||
|
// POST /submissions/{SubmissionID}/status/reset-uploading
|
||||||
|
func (s *Server) handleActionSubmissionValidatedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||||
|
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||||
|
w = statusWriter
|
||||||
|
otelAttrs := []attribute.KeyValue{
|
||||||
|
otelogen.OperationID("actionSubmissionValidated"),
|
||||||
|
semconv.HTTPRequestMethodKey.String("POST"),
|
||||||
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/reset-uploading"),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start a span for this request.
|
||||||
|
ctx, span := s.cfg.Tracer.Start(r.Context(), ActionSubmissionValidatedOperation,
|
||||||
|
trace.WithAttributes(otelAttrs...),
|
||||||
|
serverSpanKind,
|
||||||
|
)
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
// Add Labeler to context.
|
||||||
|
labeler := &Labeler{attrs: otelAttrs}
|
||||||
|
ctx = contextWithLabeler(ctx, labeler)
|
||||||
|
|
||||||
|
// Run stopwatch.
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
elapsedDuration := time.Since(startTime)
|
||||||
|
|
||||||
|
attrSet := labeler.AttributeSet()
|
||||||
|
attrs := attrSet.ToSlice()
|
||||||
|
code := statusWriter.status
|
||||||
|
if code != 0 {
|
||||||
|
codeAttr := semconv.HTTPResponseStatusCode(code)
|
||||||
|
attrs = append(attrs, codeAttr)
|
||||||
|
span.SetAttributes(codeAttr)
|
||||||
|
}
|
||||||
|
attrOpt := metric.WithAttributes(attrs...)
|
||||||
|
|
||||||
|
// Increment request counter.
|
||||||
|
s.requests.Add(ctx, 1, attrOpt)
|
||||||
|
|
||||||
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
||||||
|
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
|
||||||
|
}()
|
||||||
|
|
||||||
|
var (
|
||||||
|
recordError = func(stage string, err error) {
|
||||||
|
span.RecordError(err)
|
||||||
|
|
||||||
|
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
|
||||||
|
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
|
||||||
|
// 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 {
|
||||||
|
span.SetStatus(codes.Error, stage)
|
||||||
|
}
|
||||||
|
|
||||||
|
attrSet := labeler.AttributeSet()
|
||||||
|
attrs := attrSet.ToSlice()
|
||||||
|
if code != 0 {
|
||||||
|
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
|
||||||
|
}
|
||||||
|
|
||||||
|
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
|
||||||
|
}
|
||||||
|
err error
|
||||||
|
opErrContext = ogenerrors.OperationContext{
|
||||||
|
Name: ActionSubmissionValidatedOperation,
|
||||||
|
ID: "actionSubmissionValidated",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
{
|
||||||
|
type bitset = [1]uint8
|
||||||
|
var satisfied bitset
|
||||||
|
{
|
||||||
|
sctx, ok, err := s.securityCookieAuth(ctx, ActionSubmissionValidatedOperation, r)
|
||||||
|
if err != nil {
|
||||||
|
err = &ogenerrors.SecurityError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Security: "CookieAuth",
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||||
|
defer recordError("Security:CookieAuth", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok {
|
||||||
|
satisfied[0] |= 1 << 0
|
||||||
|
ctx = sctx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ok := func() bool {
|
||||||
|
nextRequirement:
|
||||||
|
for _, requirement := range []bitset{
|
||||||
|
{0b00000001},
|
||||||
|
} {
|
||||||
|
for i, mask := range requirement {
|
||||||
|
if satisfied[i]&mask != mask {
|
||||||
|
continue nextRequirement
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}(); !ok {
|
||||||
|
err = &ogenerrors.SecurityError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
|
||||||
|
}
|
||||||
|
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||||
|
defer recordError("Security", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
params, err := decodeActionSubmissionValidatedParams(args, argsEscaped, r)
|
||||||
|
if err != nil {
|
||||||
|
err = &ogenerrors.DecodeParamsError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
defer recordError("DecodeParams", err)
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var response *ActionSubmissionValidatedNoContent
|
||||||
|
if m := s.cfg.Middleware; m != nil {
|
||||||
|
mreq := middleware.Request{
|
||||||
|
Context: ctx,
|
||||||
|
OperationName: ActionSubmissionValidatedOperation,
|
||||||
|
OperationSummary: "Role Admin manually resets uploading softlock and changes status from Uploading -> Validated",
|
||||||
|
OperationID: "actionSubmissionValidated",
|
||||||
|
Body: nil,
|
||||||
|
Params: middleware.Parameters{
|
||||||
|
{
|
||||||
|
Name: "SubmissionID",
|
||||||
|
In: "path",
|
||||||
|
}: params.SubmissionID,
|
||||||
|
},
|
||||||
|
Raw: r,
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
Request = struct{}
|
||||||
|
Params = ActionSubmissionValidatedParams
|
||||||
|
Response = *ActionSubmissionValidatedNoContent
|
||||||
|
)
|
||||||
|
response, err = middleware.HookMiddleware[
|
||||||
|
Request,
|
||||||
|
Params,
|
||||||
|
Response,
|
||||||
|
](
|
||||||
|
m,
|
||||||
|
mreq,
|
||||||
|
unpackActionSubmissionValidatedParams,
|
||||||
|
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||||
|
err = s.h.ActionSubmissionValidated(ctx, params)
|
||||||
|
return response, err
|
||||||
|
},
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
err = s.h.ActionSubmissionValidated(ctx, params)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
if errRes, ok := errors.Into[*ErrorStatusCode](err); ok {
|
||||||
|
if err := encodeErrorResponse(errRes, w, span); err != nil {
|
||||||
|
defer recordError("Internal", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if errors.Is(err, ht.ErrNotImplemented) {
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
|
||||||
|
defer recordError("Internal", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := encodeActionSubmissionValidatedResponse(response, w, span); err != nil {
|
||||||
|
defer recordError("EncodeResponse", err)
|
||||||
|
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// handleCreateScriptRequest handles createScript operation.
|
// handleCreateScriptRequest handles createScript operation.
|
||||||
//
|
//
|
||||||
// Create a new script.
|
// Create a new script.
|
||||||
|
@ -6,12 +6,14 @@ package api
|
|||||||
type OperationName = string
|
type OperationName = string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
ActionSubmissionAcceptedOperation OperationName = "ActionSubmissionAccepted"
|
||||||
ActionSubmissionRejectOperation OperationName = "ActionSubmissionReject"
|
ActionSubmissionRejectOperation OperationName = "ActionSubmissionReject"
|
||||||
ActionSubmissionRequestChangesOperation OperationName = "ActionSubmissionRequestChanges"
|
ActionSubmissionRequestChangesOperation OperationName = "ActionSubmissionRequestChanges"
|
||||||
ActionSubmissionRevokeOperation OperationName = "ActionSubmissionRevoke"
|
ActionSubmissionRevokeOperation OperationName = "ActionSubmissionRevoke"
|
||||||
ActionSubmissionSubmitOperation OperationName = "ActionSubmissionSubmit"
|
ActionSubmissionSubmitOperation OperationName = "ActionSubmissionSubmit"
|
||||||
ActionSubmissionTriggerUploadOperation OperationName = "ActionSubmissionTriggerUpload"
|
ActionSubmissionTriggerUploadOperation OperationName = "ActionSubmissionTriggerUpload"
|
||||||
ActionSubmissionTriggerValidateOperation OperationName = "ActionSubmissionTriggerValidate"
|
ActionSubmissionTriggerValidateOperation OperationName = "ActionSubmissionTriggerValidate"
|
||||||
|
ActionSubmissionValidatedOperation OperationName = "ActionSubmissionValidated"
|
||||||
CreateScriptOperation OperationName = "CreateScript"
|
CreateScriptOperation OperationName = "CreateScript"
|
||||||
CreateScriptPolicyOperation OperationName = "CreateScriptPolicy"
|
CreateScriptPolicyOperation OperationName = "CreateScriptPolicy"
|
||||||
CreateSubmissionOperation OperationName = "CreateSubmission"
|
CreateSubmissionOperation OperationName = "CreateSubmission"
|
||||||
|
@ -15,6 +15,72 @@ import (
|
|||||||
"github.com/ogen-go/ogen/validate"
|
"github.com/ogen-go/ogen/validate"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ActionSubmissionAcceptedParams is parameters of actionSubmissionAccepted operation.
|
||||||
|
type ActionSubmissionAcceptedParams struct {
|
||||||
|
// The unique identifier for a submission.
|
||||||
|
SubmissionID int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func unpackActionSubmissionAcceptedParams(packed middleware.Parameters) (params ActionSubmissionAcceptedParams) {
|
||||||
|
{
|
||||||
|
key := middleware.ParameterKey{
|
||||||
|
Name: "SubmissionID",
|
||||||
|
In: "path",
|
||||||
|
}
|
||||||
|
params.SubmissionID = packed[key].(int64)
|
||||||
|
}
|
||||||
|
return params
|
||||||
|
}
|
||||||
|
|
||||||
|
func decodeActionSubmissionAcceptedParams(args [1]string, argsEscaped bool, r *http.Request) (params ActionSubmissionAcceptedParams, _ error) {
|
||||||
|
// Decode path: SubmissionID.
|
||||||
|
if err := func() error {
|
||||||
|
param := args[0]
|
||||||
|
if argsEscaped {
|
||||||
|
unescaped, err := url.PathUnescape(args[0])
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "unescape path")
|
||||||
|
}
|
||||||
|
param = unescaped
|
||||||
|
}
|
||||||
|
if len(param) > 0 {
|
||||||
|
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
||||||
|
Param: "SubmissionID",
|
||||||
|
Value: param,
|
||||||
|
Style: uri.PathStyleSimple,
|
||||||
|
Explode: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err := func() error {
|
||||||
|
val, err := d.DecodeValue()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
c, err := conv.ToInt64(val)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
params.SubmissionID = c
|
||||||
|
return nil
|
||||||
|
}(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return validate.ErrFieldRequired
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}(); err != nil {
|
||||||
|
return params, &ogenerrors.DecodeParamError{
|
||||||
|
Name: "SubmissionID",
|
||||||
|
In: "path",
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return params, nil
|
||||||
|
}
|
||||||
|
|
||||||
// ActionSubmissionRejectParams is parameters of actionSubmissionReject operation.
|
// ActionSubmissionRejectParams is parameters of actionSubmissionReject operation.
|
||||||
type ActionSubmissionRejectParams struct {
|
type ActionSubmissionRejectParams struct {
|
||||||
// The unique identifier for a submission.
|
// The unique identifier for a submission.
|
||||||
@ -411,6 +477,72 @@ func decodeActionSubmissionTriggerValidateParams(args [1]string, argsEscaped boo
|
|||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ActionSubmissionValidatedParams is parameters of actionSubmissionValidated operation.
|
||||||
|
type ActionSubmissionValidatedParams struct {
|
||||||
|
// The unique identifier for a submission.
|
||||||
|
SubmissionID int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func unpackActionSubmissionValidatedParams(packed middleware.Parameters) (params ActionSubmissionValidatedParams) {
|
||||||
|
{
|
||||||
|
key := middleware.ParameterKey{
|
||||||
|
Name: "SubmissionID",
|
||||||
|
In: "path",
|
||||||
|
}
|
||||||
|
params.SubmissionID = packed[key].(int64)
|
||||||
|
}
|
||||||
|
return params
|
||||||
|
}
|
||||||
|
|
||||||
|
func decodeActionSubmissionValidatedParams(args [1]string, argsEscaped bool, r *http.Request) (params ActionSubmissionValidatedParams, _ error) {
|
||||||
|
// Decode path: SubmissionID.
|
||||||
|
if err := func() error {
|
||||||
|
param := args[0]
|
||||||
|
if argsEscaped {
|
||||||
|
unescaped, err := url.PathUnescape(args[0])
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "unescape path")
|
||||||
|
}
|
||||||
|
param = unescaped
|
||||||
|
}
|
||||||
|
if len(param) > 0 {
|
||||||
|
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
||||||
|
Param: "SubmissionID",
|
||||||
|
Value: param,
|
||||||
|
Style: uri.PathStyleSimple,
|
||||||
|
Explode: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err := func() error {
|
||||||
|
val, err := d.DecodeValue()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
c, err := conv.ToInt64(val)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
params.SubmissionID = c
|
||||||
|
return nil
|
||||||
|
}(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return validate.ErrFieldRequired
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}(); err != nil {
|
||||||
|
return params, &ogenerrors.DecodeParamError{
|
||||||
|
Name: "SubmissionID",
|
||||||
|
In: "path",
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return params, nil
|
||||||
|
}
|
||||||
|
|
||||||
// DeleteScriptParams is parameters of deleteScript operation.
|
// DeleteScriptParams is parameters of deleteScript operation.
|
||||||
type DeleteScriptParams struct {
|
type DeleteScriptParams struct {
|
||||||
// The unique identifier for a script.
|
// The unique identifier for a script.
|
||||||
|
@ -15,6 +15,57 @@ import (
|
|||||||
"github.com/ogen-go/ogen/validate"
|
"github.com/ogen-go/ogen/validate"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
func decodeActionSubmissionRejectResponse(resp *http.Response) (res *ActionSubmissionRejectNoContent, _ error) {
|
func decodeActionSubmissionRejectResponse(resp *http.Response) (res *ActionSubmissionRejectNoContent, _ error) {
|
||||||
switch resp.StatusCode {
|
switch resp.StatusCode {
|
||||||
case 204:
|
case 204:
|
||||||
@ -321,6 +372,57 @@ func decodeActionSubmissionTriggerValidateResponse(resp *http.Response) (res *Ac
|
|||||||
return res, errors.Wrap(defRes, "error")
|
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) {
|
||||||
|
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) {
|
func decodeCreateScriptResponse(resp *http.Response) (res *ID, _ error) {
|
||||||
switch resp.StatusCode {
|
switch resp.StatusCode {
|
||||||
case 201:
|
case 201:
|
||||||
|
@ -13,6 +13,13 @@ import (
|
|||||||
ht "github.com/ogen-go/ogen/http"
|
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 encodeActionSubmissionRejectResponse(response *ActionSubmissionRejectNoContent, w http.ResponseWriter, span trace.Span) error {
|
func encodeActionSubmissionRejectResponse(response *ActionSubmissionRejectNoContent, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.WriteHeader(204)
|
w.WriteHeader(204)
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
||||||
@ -55,6 +62,13 @@ func encodeActionSubmissionTriggerValidateResponse(response *ActionSubmissionTri
|
|||||||
return nil
|
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 {
|
func encodeCreateScriptResponse(response *ID, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
w.WriteHeader(201)
|
w.WriteHeader(201)
|
||||||
|
@ -406,6 +406,64 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 's': // Prefix: "set-"
|
||||||
|
|
||||||
|
if l := len("set-"); len(elem) >= l && elem[0:l] == "set-" {
|
||||||
|
elem = elem[l:]
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(elem) == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
switch elem[0] {
|
||||||
|
case 'u': // Prefix: "uploading"
|
||||||
|
|
||||||
|
if l := len("uploading"); len(elem) >= l && elem[0:l] == "uploading" {
|
||||||
|
elem = elem[l:]
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(elem) == 0 {
|
||||||
|
// Leaf node.
|
||||||
|
switch r.Method {
|
||||||
|
case "POST":
|
||||||
|
s.handleActionSubmissionValidatedRequest([1]string{
|
||||||
|
args[0],
|
||||||
|
}, elemIsEscaped, w, r)
|
||||||
|
default:
|
||||||
|
s.notAllowed(w, r, "POST")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'v': // Prefix: "validating"
|
||||||
|
|
||||||
|
if l := len("validating"); len(elem) >= l && elem[0:l] == "validating" {
|
||||||
|
elem = elem[l:]
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(elem) == 0 {
|
||||||
|
// Leaf node.
|
||||||
|
switch r.Method {
|
||||||
|
case "POST":
|
||||||
|
s.handleActionSubmissionAcceptedRequest([1]string{
|
||||||
|
args[0],
|
||||||
|
}, elemIsEscaped, w, r)
|
||||||
|
default:
|
||||||
|
s.notAllowed(w, r, "POST")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
case 'v': // Prefix: "voke"
|
case 'v': // Prefix: "voke"
|
||||||
|
|
||||||
if l := len("voke"); len(elem) >= l && elem[0:l] == "voke" {
|
if l := len("voke"); len(elem) >= l && elem[0:l] == "voke" {
|
||||||
@ -1023,6 +1081,68 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 's': // Prefix: "set-"
|
||||||
|
|
||||||
|
if l := len("set-"); len(elem) >= l && elem[0:l] == "set-" {
|
||||||
|
elem = elem[l:]
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(elem) == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
switch elem[0] {
|
||||||
|
case 'u': // Prefix: "uploading"
|
||||||
|
|
||||||
|
if l := len("uploading"); len(elem) >= l && elem[0:l] == "uploading" {
|
||||||
|
elem = elem[l:]
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(elem) == 0 {
|
||||||
|
// Leaf node.
|
||||||
|
switch method {
|
||||||
|
case "POST":
|
||||||
|
r.name = ActionSubmissionValidatedOperation
|
||||||
|
r.summary = "Role Admin manually resets uploading softlock and changes status from Uploading -> Validated"
|
||||||
|
r.operationID = "actionSubmissionValidated"
|
||||||
|
r.pathPattern = "/submissions/{SubmissionID}/status/reset-uploading"
|
||||||
|
r.args = args
|
||||||
|
r.count = 1
|
||||||
|
return r, true
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'v': // Prefix: "validating"
|
||||||
|
|
||||||
|
if l := len("validating"); len(elem) >= l && elem[0:l] == "validating" {
|
||||||
|
elem = elem[l:]
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(elem) == 0 {
|
||||||
|
// Leaf node.
|
||||||
|
switch method {
|
||||||
|
case "POST":
|
||||||
|
r.name = ActionSubmissionAcceptedOperation
|
||||||
|
r.summary = "Role Reviewer manually resets validating softlock and changes status from Validating -> Accepted"
|
||||||
|
r.operationID = "actionSubmissionAccepted"
|
||||||
|
r.pathPattern = "/submissions/{SubmissionID}/status/reset-validating"
|
||||||
|
r.args = args
|
||||||
|
r.count = 1
|
||||||
|
return r, true
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
case 'v': // Prefix: "voke"
|
case 'v': // Prefix: "voke"
|
||||||
|
|
||||||
if l := len("voke"); len(elem) >= l && elem[0:l] == "voke" {
|
if l := len("voke"); len(elem) >= l && elem[0:l] == "voke" {
|
||||||
|
@ -11,6 +11,9 @@ func (s *ErrorStatusCode) Error() string {
|
|||||||
return fmt.Sprintf("code %d: %+v", s.StatusCode, s.Response)
|
return fmt.Sprintf("code %d: %+v", s.StatusCode, s.Response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ActionSubmissionAcceptedNoContent is response for ActionSubmissionAccepted operation.
|
||||||
|
type ActionSubmissionAcceptedNoContent struct{}
|
||||||
|
|
||||||
// ActionSubmissionRejectNoContent is response for ActionSubmissionReject operation.
|
// ActionSubmissionRejectNoContent is response for ActionSubmissionReject operation.
|
||||||
type ActionSubmissionRejectNoContent struct{}
|
type ActionSubmissionRejectNoContent struct{}
|
||||||
|
|
||||||
@ -29,6 +32,9 @@ type ActionSubmissionTriggerUploadNoContent struct{}
|
|||||||
// ActionSubmissionTriggerValidateNoContent is response for ActionSubmissionTriggerValidate operation.
|
// ActionSubmissionTriggerValidateNoContent is response for ActionSubmissionTriggerValidate operation.
|
||||||
type ActionSubmissionTriggerValidateNoContent struct{}
|
type ActionSubmissionTriggerValidateNoContent struct{}
|
||||||
|
|
||||||
|
// ActionSubmissionValidatedNoContent is response for ActionSubmissionValidated operation.
|
||||||
|
type ActionSubmissionValidatedNoContent struct{}
|
||||||
|
|
||||||
type CookieAuth struct {
|
type CookieAuth struct {
|
||||||
APIKey string
|
APIKey string
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,12 @@ import (
|
|||||||
|
|
||||||
// Handler handles operations described by OpenAPI v3 specification.
|
// Handler handles operations described by OpenAPI v3 specification.
|
||||||
type Handler interface {
|
type Handler interface {
|
||||||
|
// ActionSubmissionAccepted implements actionSubmissionAccepted operation.
|
||||||
|
//
|
||||||
|
// Role Reviewer manually resets validating softlock and changes status from Validating -> Accepted.
|
||||||
|
//
|
||||||
|
// POST /submissions/{SubmissionID}/status/reset-validating
|
||||||
|
ActionSubmissionAccepted(ctx context.Context, params ActionSubmissionAcceptedParams) error
|
||||||
// ActionSubmissionReject implements actionSubmissionReject operation.
|
// ActionSubmissionReject implements actionSubmissionReject operation.
|
||||||
//
|
//
|
||||||
// Role Reviewer changes status from Submitted -> Rejected.
|
// Role Reviewer changes status from Submitted -> Rejected.
|
||||||
@ -44,6 +50,12 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// POST /submissions/{SubmissionID}/status/trigger-validate
|
// POST /submissions/{SubmissionID}/status/trigger-validate
|
||||||
ActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) error
|
ActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) error
|
||||||
|
// ActionSubmissionValidated implements actionSubmissionValidated operation.
|
||||||
|
//
|
||||||
|
// Role Admin manually resets uploading softlock and changes status from Uploading -> Validated.
|
||||||
|
//
|
||||||
|
// POST /submissions/{SubmissionID}/status/reset-uploading
|
||||||
|
ActionSubmissionValidated(ctx context.Context, params ActionSubmissionValidatedParams) error
|
||||||
// CreateScript implements createScript operation.
|
// CreateScript implements createScript operation.
|
||||||
//
|
//
|
||||||
// Create a new script.
|
// Create a new script.
|
||||||
|
@ -13,6 +13,15 @@ type UnimplementedHandler struct{}
|
|||||||
|
|
||||||
var _ Handler = UnimplementedHandler{}
|
var _ Handler = UnimplementedHandler{}
|
||||||
|
|
||||||
|
// ActionSubmissionAccepted implements actionSubmissionAccepted operation.
|
||||||
|
//
|
||||||
|
// Role Reviewer manually resets validating softlock and changes status from Validating -> Accepted.
|
||||||
|
//
|
||||||
|
// POST /submissions/{SubmissionID}/status/reset-validating
|
||||||
|
func (UnimplementedHandler) ActionSubmissionAccepted(ctx context.Context, params ActionSubmissionAcceptedParams) error {
|
||||||
|
return ht.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
// ActionSubmissionReject implements actionSubmissionReject operation.
|
// ActionSubmissionReject implements actionSubmissionReject operation.
|
||||||
//
|
//
|
||||||
// Role Reviewer changes status from Submitted -> Rejected.
|
// Role Reviewer changes status from Submitted -> Rejected.
|
||||||
@ -67,6 +76,15 @@ func (UnimplementedHandler) ActionSubmissionTriggerValidate(ctx context.Context,
|
|||||||
return ht.ErrNotImplemented
|
return ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ActionSubmissionValidated implements actionSubmissionValidated operation.
|
||||||
|
//
|
||||||
|
// Role Admin manually resets uploading softlock and changes status from Uploading -> Validated.
|
||||||
|
//
|
||||||
|
// POST /submissions/{SubmissionID}/status/reset-uploading
|
||||||
|
func (UnimplementedHandler) ActionSubmissionValidated(ctx context.Context, params ActionSubmissionValidatedParams) error {
|
||||||
|
return ht.ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
// CreateScript implements createScript operation.
|
// CreateScript implements createScript operation.
|
||||||
//
|
//
|
||||||
// Create a new script.
|
// Create a new script.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user