openapi: generate
This commit is contained in:
parent
7b343fc686
commit
ccb9c17e7f
@ -28,49 +28,49 @@ type Invoker interface {
|
||||
//
|
||||
// Role Validator changes status from Publishing -> Published.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/publish
|
||||
// POST /submissions/{SubmissionID}/status/publish
|
||||
ActionSubmissionPublish(ctx context.Context, params ActionSubmissionPublishParams) error
|
||||
// ActionSubmissionReject invokes actionSubmissionReject operation.
|
||||
//
|
||||
// Role Reviewer changes status from Submitted -> Rejected.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/reject
|
||||
// POST /submissions/{SubmissionID}/status/reject
|
||||
ActionSubmissionReject(ctx context.Context, params ActionSubmissionRejectParams) error
|
||||
// ActionSubmissionRequestChanges invokes actionSubmissionRequestChanges operation.
|
||||
//
|
||||
// Role Reviewer changes status from Validated|Accepted|Submitted -> ChangesRequested.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/request-changes
|
||||
// POST /submissions/{SubmissionID}/status/request-changes
|
||||
ActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) error
|
||||
// ActionSubmissionRevoke invokes actionSubmissionRevoke operation.
|
||||
//
|
||||
// Role Submitter changes status from Submitted|ChangesRequested -> UnderConstruction.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/revoke
|
||||
// POST /submissions/{SubmissionID}/status/revoke
|
||||
ActionSubmissionRevoke(ctx context.Context, params ActionSubmissionRevokeParams) error
|
||||
// ActionSubmissionSubmit invokes actionSubmissionSubmit operation.
|
||||
//
|
||||
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/submit
|
||||
// POST /submissions/{SubmissionID}/status/submit
|
||||
ActionSubmissionSubmit(ctx context.Context, params ActionSubmissionSubmitParams) error
|
||||
// ActionSubmissionTriggerPublish invokes actionSubmissionTriggerPublish operation.
|
||||
//
|
||||
// Role Admin changes status from Validated -> Publishing.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/trigger-publish
|
||||
// POST /submissions/{SubmissionID}/status/trigger-publish
|
||||
ActionSubmissionTriggerPublish(ctx context.Context, params ActionSubmissionTriggerPublishParams) error
|
||||
// ActionSubmissionTriggerValidate invokes actionSubmissionTriggerValidate operation.
|
||||
//
|
||||
// Role Reviewer triggers validation and changes status from Submitted|Accepted -> Validating.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/trigger-validate
|
||||
// POST /submissions/{SubmissionID}/status/trigger-validate
|
||||
ActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) error
|
||||
// ActionSubmissionValidate invokes actionSubmissionValidate operation.
|
||||
//
|
||||
// Role Validator changes status from Validating -> Validated.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/validate
|
||||
// POST /submissions/{SubmissionID}/status/validate
|
||||
ActionSubmissionValidate(ctx context.Context, params ActionSubmissionValidateParams) error
|
||||
// CreateScript invokes createScript operation.
|
||||
//
|
||||
@ -132,30 +132,30 @@ type Invoker interface {
|
||||
//
|
||||
// GET /submissions
|
||||
ListSubmissions(ctx context.Context, params ListSubmissionsParams) ([]Submission, error)
|
||||
// PatchSubmissionCompleted invokes patchSubmissionCompleted operation.
|
||||
// SetSubmissionCompleted invokes setSubmissionCompleted operation.
|
||||
//
|
||||
// Retrieve map with ID.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/completed
|
||||
PatchSubmissionCompleted(ctx context.Context, params PatchSubmissionCompletedParams) error
|
||||
// PatchSubmissionModel invokes patchSubmissionModel operation.
|
||||
//
|
||||
// Update model following role restrictions.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/model
|
||||
PatchSubmissionModel(ctx context.Context, params PatchSubmissionModelParams) error
|
||||
// POST /submissions/{SubmissionID}/completed
|
||||
SetSubmissionCompleted(ctx context.Context, params SetSubmissionCompletedParams) error
|
||||
// UpdateScript invokes updateScript operation.
|
||||
//
|
||||
// Update the specified script by ID.
|
||||
//
|
||||
// PATCH /scripts/{ScriptID}
|
||||
// POST /scripts/{ScriptID}
|
||||
UpdateScript(ctx context.Context, request *ScriptUpdate, params UpdateScriptParams) error
|
||||
// UpdateScriptPolicy invokes updateScriptPolicy operation.
|
||||
//
|
||||
// Update the specified script policy by ID.
|
||||
//
|
||||
// PATCH /script-policy/id/{ScriptPolicyID}
|
||||
// POST /script-policy/id/{ScriptPolicyID}
|
||||
UpdateScriptPolicy(ctx context.Context, request *ScriptPolicyUpdate, params UpdateScriptPolicyParams) error
|
||||
// UpdateSubmissionModel invokes updateSubmissionModel operation.
|
||||
//
|
||||
// Update model following role restrictions.
|
||||
//
|
||||
// POST /submissions/{SubmissionID}/model
|
||||
UpdateSubmissionModel(ctx context.Context, params UpdateSubmissionModelParams) error
|
||||
}
|
||||
|
||||
// Client implements OAS client.
|
||||
@ -216,7 +216,7 @@ func (c *Client) requestURL(ctx context.Context) *url.URL {
|
||||
//
|
||||
// Role Validator changes status from Publishing -> Published.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/publish
|
||||
// POST /submissions/{SubmissionID}/status/publish
|
||||
func (c *Client) ActionSubmissionPublish(ctx context.Context, params ActionSubmissionPublishParams) error {
|
||||
_, err := c.sendActionSubmissionPublish(ctx, params)
|
||||
return err
|
||||
@ -225,7 +225,7 @@ func (c *Client) ActionSubmissionPublish(ctx context.Context, params ActionSubmi
|
||||
func (c *Client) sendActionSubmissionPublish(ctx context.Context, params ActionSubmissionPublishParams) (res *ActionSubmissionPublishOK, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionPublish"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/publish"),
|
||||
}
|
||||
|
||||
@ -282,7 +282,7 @@ func (c *Client) sendActionSubmissionPublish(ctx context.Context, params ActionS
|
||||
uri.AddPathParts(u, pathParts[:]...)
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "PATCH", u)
|
||||
r, err := ht.NewRequest(ctx, "POST", u)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
@ -340,7 +340,7 @@ func (c *Client) sendActionSubmissionPublish(ctx context.Context, params ActionS
|
||||
//
|
||||
// Role Reviewer changes status from Submitted -> Rejected.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/reject
|
||||
// POST /submissions/{SubmissionID}/status/reject
|
||||
func (c *Client) ActionSubmissionReject(ctx context.Context, params ActionSubmissionRejectParams) error {
|
||||
_, err := c.sendActionSubmissionReject(ctx, params)
|
||||
return err
|
||||
@ -349,7 +349,7 @@ func (c *Client) ActionSubmissionReject(ctx context.Context, params ActionSubmis
|
||||
func (c *Client) sendActionSubmissionReject(ctx context.Context, params ActionSubmissionRejectParams) (res *ActionSubmissionRejectOK, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionReject"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/reject"),
|
||||
}
|
||||
|
||||
@ -406,7 +406,7 @@ func (c *Client) sendActionSubmissionReject(ctx context.Context, params ActionSu
|
||||
uri.AddPathParts(u, pathParts[:]...)
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "PATCH", u)
|
||||
r, err := ht.NewRequest(ctx, "POST", u)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
@ -464,7 +464,7 @@ func (c *Client) sendActionSubmissionReject(ctx context.Context, params ActionSu
|
||||
//
|
||||
// Role Reviewer changes status from Validated|Accepted|Submitted -> ChangesRequested.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/request-changes
|
||||
// POST /submissions/{SubmissionID}/status/request-changes
|
||||
func (c *Client) ActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) error {
|
||||
_, err := c.sendActionSubmissionRequestChanges(ctx, params)
|
||||
return err
|
||||
@ -473,7 +473,7 @@ func (c *Client) ActionSubmissionRequestChanges(ctx context.Context, params Acti
|
||||
func (c *Client) sendActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) (res *ActionSubmissionRequestChangesOK, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionRequestChanges"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/request-changes"),
|
||||
}
|
||||
|
||||
@ -530,7 +530,7 @@ func (c *Client) sendActionSubmissionRequestChanges(ctx context.Context, params
|
||||
uri.AddPathParts(u, pathParts[:]...)
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "PATCH", u)
|
||||
r, err := ht.NewRequest(ctx, "POST", u)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
@ -588,7 +588,7 @@ func (c *Client) sendActionSubmissionRequestChanges(ctx context.Context, params
|
||||
//
|
||||
// Role Submitter changes status from Submitted|ChangesRequested -> UnderConstruction.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/revoke
|
||||
// POST /submissions/{SubmissionID}/status/revoke
|
||||
func (c *Client) ActionSubmissionRevoke(ctx context.Context, params ActionSubmissionRevokeParams) error {
|
||||
_, err := c.sendActionSubmissionRevoke(ctx, params)
|
||||
return err
|
||||
@ -597,7 +597,7 @@ func (c *Client) ActionSubmissionRevoke(ctx context.Context, params ActionSubmis
|
||||
func (c *Client) sendActionSubmissionRevoke(ctx context.Context, params ActionSubmissionRevokeParams) (res *ActionSubmissionRevokeOK, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionRevoke"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/revoke"),
|
||||
}
|
||||
|
||||
@ -654,7 +654,7 @@ func (c *Client) sendActionSubmissionRevoke(ctx context.Context, params ActionSu
|
||||
uri.AddPathParts(u, pathParts[:]...)
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "PATCH", u)
|
||||
r, err := ht.NewRequest(ctx, "POST", u)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
@ -712,7 +712,7 @@ func (c *Client) sendActionSubmissionRevoke(ctx context.Context, params ActionSu
|
||||
//
|
||||
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/submit
|
||||
// POST /submissions/{SubmissionID}/status/submit
|
||||
func (c *Client) ActionSubmissionSubmit(ctx context.Context, params ActionSubmissionSubmitParams) error {
|
||||
_, err := c.sendActionSubmissionSubmit(ctx, params)
|
||||
return err
|
||||
@ -721,7 +721,7 @@ func (c *Client) ActionSubmissionSubmit(ctx context.Context, params ActionSubmis
|
||||
func (c *Client) sendActionSubmissionSubmit(ctx context.Context, params ActionSubmissionSubmitParams) (res *ActionSubmissionSubmitOK, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionSubmit"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/submit"),
|
||||
}
|
||||
|
||||
@ -778,7 +778,7 @@ func (c *Client) sendActionSubmissionSubmit(ctx context.Context, params ActionSu
|
||||
uri.AddPathParts(u, pathParts[:]...)
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "PATCH", u)
|
||||
r, err := ht.NewRequest(ctx, "POST", u)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
@ -836,7 +836,7 @@ func (c *Client) sendActionSubmissionSubmit(ctx context.Context, params ActionSu
|
||||
//
|
||||
// Role Admin changes status from Validated -> Publishing.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/trigger-publish
|
||||
// POST /submissions/{SubmissionID}/status/trigger-publish
|
||||
func (c *Client) ActionSubmissionTriggerPublish(ctx context.Context, params ActionSubmissionTriggerPublishParams) error {
|
||||
_, err := c.sendActionSubmissionTriggerPublish(ctx, params)
|
||||
return err
|
||||
@ -845,7 +845,7 @@ func (c *Client) ActionSubmissionTriggerPublish(ctx context.Context, params Acti
|
||||
func (c *Client) sendActionSubmissionTriggerPublish(ctx context.Context, params ActionSubmissionTriggerPublishParams) (res *ActionSubmissionTriggerPublishOK, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionTriggerPublish"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/trigger-publish"),
|
||||
}
|
||||
|
||||
@ -902,7 +902,7 @@ func (c *Client) sendActionSubmissionTriggerPublish(ctx context.Context, params
|
||||
uri.AddPathParts(u, pathParts[:]...)
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "PATCH", u)
|
||||
r, err := ht.NewRequest(ctx, "POST", u)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
@ -960,7 +960,7 @@ func (c *Client) sendActionSubmissionTriggerPublish(ctx context.Context, params
|
||||
//
|
||||
// Role Reviewer triggers validation and changes status from Submitted|Accepted -> Validating.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/trigger-validate
|
||||
// POST /submissions/{SubmissionID}/status/trigger-validate
|
||||
func (c *Client) ActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) error {
|
||||
_, err := c.sendActionSubmissionTriggerValidate(ctx, params)
|
||||
return err
|
||||
@ -969,7 +969,7 @@ func (c *Client) ActionSubmissionTriggerValidate(ctx context.Context, params Act
|
||||
func (c *Client) sendActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) (res *ActionSubmissionTriggerValidateOK, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionTriggerValidate"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/trigger-validate"),
|
||||
}
|
||||
|
||||
@ -1026,7 +1026,7 @@ func (c *Client) sendActionSubmissionTriggerValidate(ctx context.Context, params
|
||||
uri.AddPathParts(u, pathParts[:]...)
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "PATCH", u)
|
||||
r, err := ht.NewRequest(ctx, "POST", u)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
@ -1084,7 +1084,7 @@ func (c *Client) sendActionSubmissionTriggerValidate(ctx context.Context, params
|
||||
//
|
||||
// Role Validator changes status from Validating -> Validated.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/validate
|
||||
// POST /submissions/{SubmissionID}/status/validate
|
||||
func (c *Client) ActionSubmissionValidate(ctx context.Context, params ActionSubmissionValidateParams) error {
|
||||
_, err := c.sendActionSubmissionValidate(ctx, params)
|
||||
return err
|
||||
@ -1093,7 +1093,7 @@ func (c *Client) ActionSubmissionValidate(ctx context.Context, params ActionSubm
|
||||
func (c *Client) sendActionSubmissionValidate(ctx context.Context, params ActionSubmissionValidateParams) (res *ActionSubmissionValidateOK, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionValidate"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/validate"),
|
||||
}
|
||||
|
||||
@ -1150,7 +1150,7 @@ func (c *Client) sendActionSubmissionValidate(ctx context.Context, params Action
|
||||
uri.AddPathParts(u, pathParts[:]...)
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "PATCH", u)
|
||||
r, err := ht.NewRequest(ctx, "POST", u)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
@ -2406,20 +2406,20 @@ func (c *Client) sendListSubmissions(ctx context.Context, params ListSubmissions
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// PatchSubmissionCompleted invokes patchSubmissionCompleted operation.
|
||||
// SetSubmissionCompleted invokes setSubmissionCompleted operation.
|
||||
//
|
||||
// Retrieve map with ID.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/completed
|
||||
func (c *Client) PatchSubmissionCompleted(ctx context.Context, params PatchSubmissionCompletedParams) error {
|
||||
_, err := c.sendPatchSubmissionCompleted(ctx, params)
|
||||
// POST /submissions/{SubmissionID}/completed
|
||||
func (c *Client) SetSubmissionCompleted(ctx context.Context, params SetSubmissionCompletedParams) error {
|
||||
_, err := c.sendSetSubmissionCompleted(ctx, params)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) sendPatchSubmissionCompleted(ctx context.Context, params PatchSubmissionCompletedParams) (res *PatchSubmissionCompletedOK, err error) {
|
||||
func (c *Client) sendSetSubmissionCompleted(ctx context.Context, params SetSubmissionCompletedParams) (res *SetSubmissionCompletedOK, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("patchSubmissionCompleted"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
otelogen.OperationID("setSubmissionCompleted"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/completed"),
|
||||
}
|
||||
|
||||
@ -2435,7 +2435,7 @@ func (c *Client) sendPatchSubmissionCompleted(ctx context.Context, params PatchS
|
||||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := c.cfg.Tracer.Start(ctx, PatchSubmissionCompletedOperation,
|
||||
ctx, span := c.cfg.Tracer.Start(ctx, SetSubmissionCompletedOperation,
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
clientSpanKind,
|
||||
)
|
||||
@ -2476,7 +2476,7 @@ func (c *Client) sendPatchSubmissionCompleted(ctx context.Context, params PatchS
|
||||
uri.AddPathParts(u, pathParts[:]...)
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "PATCH", u)
|
||||
r, err := ht.NewRequest(ctx, "POST", u)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
@ -2486,7 +2486,7 @@ func (c *Client) sendPatchSubmissionCompleted(ctx context.Context, params PatchS
|
||||
var satisfied bitset
|
||||
{
|
||||
stage = "Security:CookieAuth"
|
||||
switch err := c.securityCookieAuth(ctx, PatchSubmissionCompletedOperation, r); {
|
||||
switch err := c.securityCookieAuth(ctx, SetSubmissionCompletedOperation, r); {
|
||||
case err == nil: // if NO error
|
||||
satisfied[0] |= 1 << 0
|
||||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||||
@ -2522,7 +2522,7 @@ func (c *Client) sendPatchSubmissionCompleted(ctx context.Context, params PatchS
|
||||
defer resp.Body.Close()
|
||||
|
||||
stage = "DecodeResponse"
|
||||
result, err := decodePatchSubmissionCompletedResponse(resp)
|
||||
result, err := decodeSetSubmissionCompletedResponse(resp)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "decode response")
|
||||
}
|
||||
@ -2530,20 +2530,272 @@ func (c *Client) sendPatchSubmissionCompleted(ctx context.Context, params PatchS
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// PatchSubmissionModel invokes patchSubmissionModel operation.
|
||||
// UpdateScript invokes updateScript operation.
|
||||
//
|
||||
// Update model following role restrictions.
|
||||
// Update the specified script by ID.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/model
|
||||
func (c *Client) PatchSubmissionModel(ctx context.Context, params PatchSubmissionModelParams) error {
|
||||
_, err := c.sendPatchSubmissionModel(ctx, params)
|
||||
// POST /scripts/{ScriptID}
|
||||
func (c *Client) UpdateScript(ctx context.Context, request *ScriptUpdate, params UpdateScriptParams) error {
|
||||
_, err := c.sendUpdateScript(ctx, request, params)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) sendPatchSubmissionModel(ctx context.Context, params PatchSubmissionModelParams) (res *PatchSubmissionModelOK, err error) {
|
||||
func (c *Client) sendUpdateScript(ctx context.Context, request *ScriptUpdate, params UpdateScriptParams) (res *UpdateScriptOK, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("patchSubmissionModel"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
otelogen.OperationID("updateScript"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/scripts/{ScriptID}"),
|
||||
}
|
||||
|
||||
// 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, UpdateScriptOperation,
|
||||
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 [2]string
|
||||
pathParts[0] = "/scripts/"
|
||||
{
|
||||
// Encode "ScriptID" parameter.
|
||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||||
Param: "ScriptID",
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
if err := func() error {
|
||||
return e.EncodeValue(conv.Int64ToString(params.ScriptID))
|
||||
}(); 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
|
||||
}
|
||||
uri.AddPathParts(u, pathParts[:]...)
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "POST", u)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
if err := encodeUpdateScriptRequest(request, r); err != nil {
|
||||
return res, errors.Wrap(err, "encode request")
|
||||
}
|
||||
|
||||
{
|
||||
type bitset = [1]uint8
|
||||
var satisfied bitset
|
||||
{
|
||||
stage = "Security:CookieAuth"
|
||||
switch err := c.securityCookieAuth(ctx, UpdateScriptOperation, 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 := decodeUpdateScriptResponse(resp)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "decode response")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateScriptPolicy invokes updateScriptPolicy operation.
|
||||
//
|
||||
// Update the specified script policy by ID.
|
||||
//
|
||||
// POST /script-policy/id/{ScriptPolicyID}
|
||||
func (c *Client) UpdateScriptPolicy(ctx context.Context, request *ScriptPolicyUpdate, params UpdateScriptPolicyParams) error {
|
||||
_, err := c.sendUpdateScriptPolicy(ctx, request, params)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) sendUpdateScriptPolicy(ctx context.Context, request *ScriptPolicyUpdate, params UpdateScriptPolicyParams) (res *UpdateScriptPolicyOK, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("updateScriptPolicy"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/script-policy/id/{ScriptPolicyID}"),
|
||||
}
|
||||
|
||||
// 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, UpdateScriptPolicyOperation,
|
||||
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 [2]string
|
||||
pathParts[0] = "/script-policy/id/"
|
||||
{
|
||||
// Encode "ScriptPolicyID" parameter.
|
||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||||
Param: "ScriptPolicyID",
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
if err := func() error {
|
||||
return e.EncodeValue(conv.Int64ToString(params.ScriptPolicyID))
|
||||
}(); 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
|
||||
}
|
||||
uri.AddPathParts(u, pathParts[:]...)
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "POST", u)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
if err := encodeUpdateScriptPolicyRequest(request, r); err != nil {
|
||||
return res, errors.Wrap(err, "encode request")
|
||||
}
|
||||
|
||||
{
|
||||
type bitset = [1]uint8
|
||||
var satisfied bitset
|
||||
{
|
||||
stage = "Security:CookieAuth"
|
||||
switch err := c.securityCookieAuth(ctx, UpdateScriptPolicyOperation, 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 := decodeUpdateScriptPolicyResponse(resp)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "decode response")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateSubmissionModel invokes updateSubmissionModel operation.
|
||||
//
|
||||
// Update model following role restrictions.
|
||||
//
|
||||
// POST /submissions/{SubmissionID}/model
|
||||
func (c *Client) UpdateSubmissionModel(ctx context.Context, params UpdateSubmissionModelParams) error {
|
||||
_, err := c.sendUpdateSubmissionModel(ctx, params)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) sendUpdateSubmissionModel(ctx context.Context, params UpdateSubmissionModelParams) (res *UpdateSubmissionModelOK, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("updateSubmissionModel"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/model"),
|
||||
}
|
||||
|
||||
@ -2559,7 +2811,7 @@ func (c *Client) sendPatchSubmissionModel(ctx context.Context, params PatchSubmi
|
||||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := c.cfg.Tracer.Start(ctx, PatchSubmissionModelOperation,
|
||||
ctx, span := c.cfg.Tracer.Start(ctx, UpdateSubmissionModelOperation,
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
clientSpanKind,
|
||||
)
|
||||
@ -2632,7 +2884,7 @@ func (c *Client) sendPatchSubmissionModel(ctx context.Context, params PatchSubmi
|
||||
u.RawQuery = q.Values().Encode()
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "PATCH", u)
|
||||
r, err := ht.NewRequest(ctx, "POST", u)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
@ -2642,7 +2894,7 @@ func (c *Client) sendPatchSubmissionModel(ctx context.Context, params PatchSubmi
|
||||
var satisfied bitset
|
||||
{
|
||||
stage = "Security:CookieAuth"
|
||||
switch err := c.securityCookieAuth(ctx, PatchSubmissionModelOperation, r); {
|
||||
switch err := c.securityCookieAuth(ctx, UpdateSubmissionModelOperation, r); {
|
||||
case err == nil: // if NO error
|
||||
satisfied[0] |= 1 << 0
|
||||
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
||||
@ -2678,259 +2930,7 @@ func (c *Client) sendPatchSubmissionModel(ctx context.Context, params PatchSubmi
|
||||
defer resp.Body.Close()
|
||||
|
||||
stage = "DecodeResponse"
|
||||
result, err := decodePatchSubmissionModelResponse(resp)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "decode response")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateScript invokes updateScript operation.
|
||||
//
|
||||
// Update the specified script by ID.
|
||||
//
|
||||
// PATCH /scripts/{ScriptID}
|
||||
func (c *Client) UpdateScript(ctx context.Context, request *ScriptUpdate, params UpdateScriptParams) error {
|
||||
_, err := c.sendUpdateScript(ctx, request, params)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) sendUpdateScript(ctx context.Context, request *ScriptUpdate, params UpdateScriptParams) (res *UpdateScriptOK, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("updateScript"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRouteKey.String("/scripts/{ScriptID}"),
|
||||
}
|
||||
|
||||
// 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, UpdateScriptOperation,
|
||||
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 [2]string
|
||||
pathParts[0] = "/scripts/"
|
||||
{
|
||||
// Encode "ScriptID" parameter.
|
||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||||
Param: "ScriptID",
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
if err := func() error {
|
||||
return e.EncodeValue(conv.Int64ToString(params.ScriptID))
|
||||
}(); 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
|
||||
}
|
||||
uri.AddPathParts(u, pathParts[:]...)
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "PATCH", u)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
if err := encodeUpdateScriptRequest(request, r); err != nil {
|
||||
return res, errors.Wrap(err, "encode request")
|
||||
}
|
||||
|
||||
{
|
||||
type bitset = [1]uint8
|
||||
var satisfied bitset
|
||||
{
|
||||
stage = "Security:CookieAuth"
|
||||
switch err := c.securityCookieAuth(ctx, UpdateScriptOperation, 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 := decodeUpdateScriptResponse(resp)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "decode response")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateScriptPolicy invokes updateScriptPolicy operation.
|
||||
//
|
||||
// Update the specified script policy by ID.
|
||||
//
|
||||
// PATCH /script-policy/id/{ScriptPolicyID}
|
||||
func (c *Client) UpdateScriptPolicy(ctx context.Context, request *ScriptPolicyUpdate, params UpdateScriptPolicyParams) error {
|
||||
_, err := c.sendUpdateScriptPolicy(ctx, request, params)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) sendUpdateScriptPolicy(ctx context.Context, request *ScriptPolicyUpdate, params UpdateScriptPolicyParams) (res *UpdateScriptPolicyOK, err error) {
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("updateScriptPolicy"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRouteKey.String("/script-policy/id/{ScriptPolicyID}"),
|
||||
}
|
||||
|
||||
// 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, UpdateScriptPolicyOperation,
|
||||
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 [2]string
|
||||
pathParts[0] = "/script-policy/id/"
|
||||
{
|
||||
// Encode "ScriptPolicyID" parameter.
|
||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
||||
Param: "ScriptPolicyID",
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
if err := func() error {
|
||||
return e.EncodeValue(conv.Int64ToString(params.ScriptPolicyID))
|
||||
}(); 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
|
||||
}
|
||||
uri.AddPathParts(u, pathParts[:]...)
|
||||
|
||||
stage = "EncodeRequest"
|
||||
r, err := ht.NewRequest(ctx, "PATCH", u)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "create request")
|
||||
}
|
||||
if err := encodeUpdateScriptPolicyRequest(request, r); err != nil {
|
||||
return res, errors.Wrap(err, "encode request")
|
||||
}
|
||||
|
||||
{
|
||||
type bitset = [1]uint8
|
||||
var satisfied bitset
|
||||
{
|
||||
stage = "Security:CookieAuth"
|
||||
switch err := c.securityCookieAuth(ctx, UpdateScriptPolicyOperation, 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 := decodeUpdateScriptPolicyResponse(resp)
|
||||
result, err := decodeUpdateSubmissionModelResponse(resp)
|
||||
if err != nil {
|
||||
return res, errors.Wrap(err, "decode response")
|
||||
}
|
||||
|
@ -34,13 +34,13 @@ func (c *codeRecorder) WriteHeader(status int) {
|
||||
//
|
||||
// Role Validator changes status from Publishing -> Published.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/publish
|
||||
// POST /submissions/{SubmissionID}/status/publish
|
||||
func (s *Server) handleActionSubmissionPublishRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionPublish"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/publish"),
|
||||
}
|
||||
|
||||
@ -229,13 +229,13 @@ func (s *Server) handleActionSubmissionPublishRequest(args [1]string, argsEscape
|
||||
//
|
||||
// Role Reviewer changes status from Submitted -> Rejected.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/reject
|
||||
// POST /submissions/{SubmissionID}/status/reject
|
||||
func (s *Server) handleActionSubmissionRejectRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionReject"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/reject"),
|
||||
}
|
||||
|
||||
@ -424,13 +424,13 @@ func (s *Server) handleActionSubmissionRejectRequest(args [1]string, argsEscaped
|
||||
//
|
||||
// Role Reviewer changes status from Validated|Accepted|Submitted -> ChangesRequested.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/request-changes
|
||||
// POST /submissions/{SubmissionID}/status/request-changes
|
||||
func (s *Server) handleActionSubmissionRequestChangesRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionRequestChanges"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/request-changes"),
|
||||
}
|
||||
|
||||
@ -619,13 +619,13 @@ func (s *Server) handleActionSubmissionRequestChangesRequest(args [1]string, arg
|
||||
//
|
||||
// Role Submitter changes status from Submitted|ChangesRequested -> UnderConstruction.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/revoke
|
||||
// POST /submissions/{SubmissionID}/status/revoke
|
||||
func (s *Server) handleActionSubmissionRevokeRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionRevoke"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/revoke"),
|
||||
}
|
||||
|
||||
@ -814,13 +814,13 @@ func (s *Server) handleActionSubmissionRevokeRequest(args [1]string, argsEscaped
|
||||
//
|
||||
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/submit
|
||||
// POST /submissions/{SubmissionID}/status/submit
|
||||
func (s *Server) handleActionSubmissionSubmitRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionSubmit"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/submit"),
|
||||
}
|
||||
|
||||
@ -1009,13 +1009,13 @@ func (s *Server) handleActionSubmissionSubmitRequest(args [1]string, argsEscaped
|
||||
//
|
||||
// Role Admin changes status from Validated -> Publishing.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/trigger-publish
|
||||
// POST /submissions/{SubmissionID}/status/trigger-publish
|
||||
func (s *Server) handleActionSubmissionTriggerPublishRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionTriggerPublish"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/trigger-publish"),
|
||||
}
|
||||
|
||||
@ -1204,13 +1204,13 @@ func (s *Server) handleActionSubmissionTriggerPublishRequest(args [1]string, arg
|
||||
//
|
||||
// Role Reviewer triggers validation and changes status from Submitted|Accepted -> Validating.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/trigger-validate
|
||||
// POST /submissions/{SubmissionID}/status/trigger-validate
|
||||
func (s *Server) handleActionSubmissionTriggerValidateRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionTriggerValidate"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/trigger-validate"),
|
||||
}
|
||||
|
||||
@ -1399,13 +1399,13 @@ func (s *Server) handleActionSubmissionTriggerValidateRequest(args [1]string, ar
|
||||
//
|
||||
// Role Validator changes status from Validating -> Validated.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/validate
|
||||
// POST /submissions/{SubmissionID}/status/validate
|
||||
func (s *Server) handleActionSubmissionValidateRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("actionSubmissionValidate"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/validate"),
|
||||
}
|
||||
|
||||
@ -3544,22 +3544,22 @@ func (s *Server) handleListSubmissionsRequest(args [0]string, argsEscaped bool,
|
||||
}
|
||||
}
|
||||
|
||||
// handlePatchSubmissionCompletedRequest handles patchSubmissionCompleted operation.
|
||||
// handleSetSubmissionCompletedRequest handles setSubmissionCompleted operation.
|
||||
//
|
||||
// Retrieve map with ID.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/completed
|
||||
func (s *Server) handlePatchSubmissionCompletedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
// POST /submissions/{SubmissionID}/completed
|
||||
func (s *Server) handleSetSubmissionCompletedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("patchSubmissionCompleted"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
otelogen.OperationID("setSubmissionCompleted"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/completed"),
|
||||
}
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), PatchSubmissionCompletedOperation,
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), SetSubmissionCompletedOperation,
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
serverSpanKind,
|
||||
)
|
||||
@ -3614,15 +3614,15 @@ func (s *Server) handlePatchSubmissionCompletedRequest(args [1]string, argsEscap
|
||||
}
|
||||
err error
|
||||
opErrContext = ogenerrors.OperationContext{
|
||||
Name: PatchSubmissionCompletedOperation,
|
||||
ID: "patchSubmissionCompleted",
|
||||
Name: SetSubmissionCompletedOperation,
|
||||
ID: "setSubmissionCompleted",
|
||||
}
|
||||
)
|
||||
{
|
||||
type bitset = [1]uint8
|
||||
var satisfied bitset
|
||||
{
|
||||
sctx, ok, err := s.securityCookieAuth(ctx, PatchSubmissionCompletedOperation, r)
|
||||
sctx, ok, err := s.securityCookieAuth(ctx, SetSubmissionCompletedOperation, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.SecurityError{
|
||||
OperationContext: opErrContext,
|
||||
@ -3664,7 +3664,7 @@ func (s *Server) handlePatchSubmissionCompletedRequest(args [1]string, argsEscap
|
||||
return
|
||||
}
|
||||
}
|
||||
params, err := decodePatchSubmissionCompletedParams(args, argsEscaped, r)
|
||||
params, err := decodeSetSubmissionCompletedParams(args, argsEscaped, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.DecodeParamsError{
|
||||
OperationContext: opErrContext,
|
||||
@ -3675,13 +3675,13 @@ func (s *Server) handlePatchSubmissionCompletedRequest(args [1]string, argsEscap
|
||||
return
|
||||
}
|
||||
|
||||
var response *PatchSubmissionCompletedOK
|
||||
var response *SetSubmissionCompletedOK
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: PatchSubmissionCompletedOperation,
|
||||
OperationName: SetSubmissionCompletedOperation,
|
||||
OperationSummary: "Retrieve map with ID",
|
||||
OperationID: "patchSubmissionCompleted",
|
||||
OperationID: "setSubmissionCompleted",
|
||||
Body: nil,
|
||||
Params: middleware.Parameters{
|
||||
{
|
||||
@ -3694,8 +3694,8 @@ func (s *Server) handlePatchSubmissionCompletedRequest(args [1]string, argsEscap
|
||||
|
||||
type (
|
||||
Request = struct{}
|
||||
Params = PatchSubmissionCompletedParams
|
||||
Response = *PatchSubmissionCompletedOK
|
||||
Params = SetSubmissionCompletedParams
|
||||
Response = *SetSubmissionCompletedOK
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
@ -3704,14 +3704,14 @@ func (s *Server) handlePatchSubmissionCompletedRequest(args [1]string, argsEscap
|
||||
](
|
||||
m,
|
||||
mreq,
|
||||
unpackPatchSubmissionCompletedParams,
|
||||
unpackSetSubmissionCompletedParams,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
err = s.h.PatchSubmissionCompleted(ctx, params)
|
||||
err = s.h.SetSubmissionCompleted(ctx, params)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
err = s.h.PatchSubmissionCompleted(ctx, params)
|
||||
err = s.h.SetSubmissionCompleted(ctx, params)
|
||||
}
|
||||
if err != nil {
|
||||
if errRes, ok := errors.Into[*ErrorStatusCode](err); ok {
|
||||
@ -3730,210 +3730,7 @@ func (s *Server) handlePatchSubmissionCompletedRequest(args [1]string, argsEscap
|
||||
return
|
||||
}
|
||||
|
||||
if err := encodePatchSubmissionCompletedResponse(response, w, span); err != nil {
|
||||
defer recordError("EncodeResponse", err)
|
||||
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// handlePatchSubmissionModelRequest handles patchSubmissionModel operation.
|
||||
//
|
||||
// Update model following role restrictions.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/model
|
||||
func (s *Server) handlePatchSubmissionModelRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("patchSubmissionModel"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/model"),
|
||||
}
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), PatchSubmissionModelOperation,
|
||||
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: PatchSubmissionModelOperation,
|
||||
ID: "patchSubmissionModel",
|
||||
}
|
||||
)
|
||||
{
|
||||
type bitset = [1]uint8
|
||||
var satisfied bitset
|
||||
{
|
||||
sctx, ok, err := s.securityCookieAuth(ctx, PatchSubmissionModelOperation, 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 := decodePatchSubmissionModelParams(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 *PatchSubmissionModelOK
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: PatchSubmissionModelOperation,
|
||||
OperationSummary: "Update model following role restrictions",
|
||||
OperationID: "patchSubmissionModel",
|
||||
Body: nil,
|
||||
Params: middleware.Parameters{
|
||||
{
|
||||
Name: "SubmissionID",
|
||||
In: "path",
|
||||
}: params.SubmissionID,
|
||||
{
|
||||
Name: "ModelID",
|
||||
In: "query",
|
||||
}: params.ModelID,
|
||||
{
|
||||
Name: "VersionID",
|
||||
In: "query",
|
||||
}: params.VersionID,
|
||||
},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
type (
|
||||
Request = struct{}
|
||||
Params = PatchSubmissionModelParams
|
||||
Response = *PatchSubmissionModelOK
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
Params,
|
||||
Response,
|
||||
](
|
||||
m,
|
||||
mreq,
|
||||
unpackPatchSubmissionModelParams,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
err = s.h.PatchSubmissionModel(ctx, params)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
err = s.h.PatchSubmissionModel(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 := encodePatchSubmissionModelResponse(response, w, span); err != nil {
|
||||
if err := encodeSetSubmissionCompletedResponse(response, w, span); err != nil {
|
||||
defer recordError("EncodeResponse", err)
|
||||
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
@ -3946,13 +3743,13 @@ func (s *Server) handlePatchSubmissionModelRequest(args [1]string, argsEscaped b
|
||||
//
|
||||
// Update the specified script by ID.
|
||||
//
|
||||
// PATCH /scripts/{ScriptID}
|
||||
// POST /scripts/{ScriptID}
|
||||
func (s *Server) handleUpdateScriptRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("updateScript"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/scripts/{ScriptID}"),
|
||||
}
|
||||
|
||||
@ -4156,13 +3953,13 @@ func (s *Server) handleUpdateScriptRequest(args [1]string, argsEscaped bool, w h
|
||||
//
|
||||
// Update the specified script policy by ID.
|
||||
//
|
||||
// PATCH /script-policy/id/{ScriptPolicyID}
|
||||
// POST /script-policy/id/{ScriptPolicyID}
|
||||
func (s *Server) handleUpdateScriptPolicyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("updateScriptPolicy"),
|
||||
semconv.HTTPRequestMethodKey.String("PATCH"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/script-policy/id/{ScriptPolicyID}"),
|
||||
}
|
||||
|
||||
@ -4361,3 +4158,206 @@ func (s *Server) handleUpdateScriptPolicyRequest(args [1]string, argsEscaped boo
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// handleUpdateSubmissionModelRequest handles updateSubmissionModel operation.
|
||||
//
|
||||
// Update model following role restrictions.
|
||||
//
|
||||
// POST /submissions/{SubmissionID}/model
|
||||
func (s *Server) handleUpdateSubmissionModelRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("updateSubmissionModel"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/model"),
|
||||
}
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), UpdateSubmissionModelOperation,
|
||||
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: UpdateSubmissionModelOperation,
|
||||
ID: "updateSubmissionModel",
|
||||
}
|
||||
)
|
||||
{
|
||||
type bitset = [1]uint8
|
||||
var satisfied bitset
|
||||
{
|
||||
sctx, ok, err := s.securityCookieAuth(ctx, UpdateSubmissionModelOperation, 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 := decodeUpdateSubmissionModelParams(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 *UpdateSubmissionModelOK
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: UpdateSubmissionModelOperation,
|
||||
OperationSummary: "Update model following role restrictions",
|
||||
OperationID: "updateSubmissionModel",
|
||||
Body: nil,
|
||||
Params: middleware.Parameters{
|
||||
{
|
||||
Name: "SubmissionID",
|
||||
In: "path",
|
||||
}: params.SubmissionID,
|
||||
{
|
||||
Name: "ModelID",
|
||||
In: "query",
|
||||
}: params.ModelID,
|
||||
{
|
||||
Name: "VersionID",
|
||||
In: "query",
|
||||
}: params.VersionID,
|
||||
},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
type (
|
||||
Request = struct{}
|
||||
Params = UpdateSubmissionModelParams
|
||||
Response = *UpdateSubmissionModelOK
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
Params,
|
||||
Response,
|
||||
](
|
||||
m,
|
||||
mreq,
|
||||
unpackUpdateSubmissionModelParams,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
err = s.h.UpdateSubmissionModel(ctx, params)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
err = s.h.UpdateSubmissionModel(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 := encodeUpdateSubmissionModelResponse(response, w, span); err != nil {
|
||||
defer recordError("EncodeResponse", err)
|
||||
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ const (
|
||||
GetScriptPolicyFromHashOperation OperationName = "GetScriptPolicyFromHash"
|
||||
GetSubmissionOperation OperationName = "GetSubmission"
|
||||
ListSubmissionsOperation OperationName = "ListSubmissions"
|
||||
PatchSubmissionCompletedOperation OperationName = "PatchSubmissionCompleted"
|
||||
PatchSubmissionModelOperation OperationName = "PatchSubmissionModel"
|
||||
SetSubmissionCompletedOperation OperationName = "SetSubmissionCompleted"
|
||||
UpdateScriptOperation OperationName = "UpdateScript"
|
||||
UpdateScriptPolicyOperation OperationName = "UpdateScriptPolicy"
|
||||
UpdateSubmissionModelOperation OperationName = "UpdateSubmissionModel"
|
||||
)
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
|
||||
// ActionSubmissionPublishParams is parameters of actionSubmissionPublish operation.
|
||||
type ActionSubmissionPublishParams struct {
|
||||
// The unique identifier for a submission.
|
||||
SubmissionID int64
|
||||
}
|
||||
|
||||
@ -82,6 +83,7 @@ func decodeActionSubmissionPublishParams(args [1]string, argsEscaped bool, r *ht
|
||||
|
||||
// ActionSubmissionRejectParams is parameters of actionSubmissionReject operation.
|
||||
type ActionSubmissionRejectParams struct {
|
||||
// The unique identifier for a submission.
|
||||
SubmissionID int64
|
||||
}
|
||||
|
||||
@ -147,6 +149,7 @@ func decodeActionSubmissionRejectParams(args [1]string, argsEscaped bool, r *htt
|
||||
|
||||
// ActionSubmissionRequestChangesParams is parameters of actionSubmissionRequestChanges operation.
|
||||
type ActionSubmissionRequestChangesParams struct {
|
||||
// The unique identifier for a submission.
|
||||
SubmissionID int64
|
||||
}
|
||||
|
||||
@ -212,6 +215,7 @@ func decodeActionSubmissionRequestChangesParams(args [1]string, argsEscaped bool
|
||||
|
||||
// ActionSubmissionRevokeParams is parameters of actionSubmissionRevoke operation.
|
||||
type ActionSubmissionRevokeParams struct {
|
||||
// The unique identifier for a submission.
|
||||
SubmissionID int64
|
||||
}
|
||||
|
||||
@ -277,6 +281,7 @@ func decodeActionSubmissionRevokeParams(args [1]string, argsEscaped bool, r *htt
|
||||
|
||||
// ActionSubmissionSubmitParams is parameters of actionSubmissionSubmit operation.
|
||||
type ActionSubmissionSubmitParams struct {
|
||||
// The unique identifier for a submission.
|
||||
SubmissionID int64
|
||||
}
|
||||
|
||||
@ -342,6 +347,7 @@ func decodeActionSubmissionSubmitParams(args [1]string, argsEscaped bool, r *htt
|
||||
|
||||
// ActionSubmissionTriggerPublishParams is parameters of actionSubmissionTriggerPublish operation.
|
||||
type ActionSubmissionTriggerPublishParams struct {
|
||||
// The unique identifier for a submission.
|
||||
SubmissionID int64
|
||||
}
|
||||
|
||||
@ -407,6 +413,7 @@ func decodeActionSubmissionTriggerPublishParams(args [1]string, argsEscaped bool
|
||||
|
||||
// ActionSubmissionTriggerValidateParams is parameters of actionSubmissionTriggerValidate operation.
|
||||
type ActionSubmissionTriggerValidateParams struct {
|
||||
// The unique identifier for a submission.
|
||||
SubmissionID int64
|
||||
}
|
||||
|
||||
@ -472,6 +479,7 @@ func decodeActionSubmissionTriggerValidateParams(args [1]string, argsEscaped boo
|
||||
|
||||
// ActionSubmissionValidateParams is parameters of actionSubmissionValidate operation.
|
||||
type ActionSubmissionValidateParams struct {
|
||||
// The unique identifier for a submission.
|
||||
SubmissionID int64
|
||||
}
|
||||
|
||||
@ -537,6 +545,7 @@ func decodeActionSubmissionValidateParams(args [1]string, argsEscaped bool, r *h
|
||||
|
||||
// DeleteScriptParams is parameters of deleteScript operation.
|
||||
type DeleteScriptParams struct {
|
||||
// The unique identifier for a script.
|
||||
ScriptID int64
|
||||
}
|
||||
|
||||
@ -602,6 +611,7 @@ func decodeDeleteScriptParams(args [1]string, argsEscaped bool, r *http.Request)
|
||||
|
||||
// DeleteScriptPolicyParams is parameters of deleteScriptPolicy operation.
|
||||
type DeleteScriptPolicyParams struct {
|
||||
// The unique identifier for a script policy.
|
||||
ScriptPolicyID int64
|
||||
}
|
||||
|
||||
@ -667,6 +677,7 @@ func decodeDeleteScriptPolicyParams(args [1]string, argsEscaped bool, r *http.Re
|
||||
|
||||
// GetScriptParams is parameters of getScript operation.
|
||||
type GetScriptParams struct {
|
||||
// The unique identifier for a script.
|
||||
ScriptID int64
|
||||
}
|
||||
|
||||
@ -732,6 +743,7 @@ func decodeGetScriptParams(args [1]string, argsEscaped bool, r *http.Request) (p
|
||||
|
||||
// GetScriptPolicyParams is parameters of getScriptPolicy operation.
|
||||
type GetScriptPolicyParams struct {
|
||||
// The unique identifier for a script policy.
|
||||
ScriptPolicyID int64
|
||||
}
|
||||
|
||||
@ -846,6 +858,22 @@ func decodeGetScriptPolicyFromHashParams(args [1]string, argsEscaped bool, r *ht
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 16,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 16,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
}).Validate(string(params.FromScriptHash)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
@ -862,6 +890,7 @@ func decodeGetScriptPolicyFromHashParams(args [1]string, argsEscaped bool, r *ht
|
||||
|
||||
// GetSubmissionParams is parameters of getSubmission operation.
|
||||
type GetSubmissionParams struct {
|
||||
// The unique identifier for a submission.
|
||||
SubmissionID int64
|
||||
}
|
||||
|
||||
@ -1009,6 +1038,21 @@ func decodeListSubmissionsParams(args [0]string, argsEscaped bool, r *http.Reque
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := params.Filter.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := value.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
@ -1021,12 +1065,13 @@ func decodeListSubmissionsParams(args [0]string, argsEscaped bool, r *http.Reque
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// PatchSubmissionCompletedParams is parameters of patchSubmissionCompleted operation.
|
||||
type PatchSubmissionCompletedParams struct {
|
||||
// SetSubmissionCompletedParams is parameters of setSubmissionCompleted operation.
|
||||
type SetSubmissionCompletedParams struct {
|
||||
// The unique identifier for a submission.
|
||||
SubmissionID int64
|
||||
}
|
||||
|
||||
func unpackPatchSubmissionCompletedParams(packed middleware.Parameters) (params PatchSubmissionCompletedParams) {
|
||||
func unpackSetSubmissionCompletedParams(packed middleware.Parameters) (params SetSubmissionCompletedParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "SubmissionID",
|
||||
@ -1037,7 +1082,7 @@ func unpackPatchSubmissionCompletedParams(packed middleware.Parameters) (params
|
||||
return params
|
||||
}
|
||||
|
||||
func decodePatchSubmissionCompletedParams(args [1]string, argsEscaped bool, r *http.Request) (params PatchSubmissionCompletedParams, _ error) {
|
||||
func decodeSetSubmissionCompletedParams(args [1]string, argsEscaped bool, r *http.Request) (params SetSubmissionCompletedParams, _ error) {
|
||||
// Decode path: SubmissionID.
|
||||
if err := func() error {
|
||||
param := args[0]
|
||||
@ -1086,14 +1131,147 @@ func decodePatchSubmissionCompletedParams(args [1]string, argsEscaped bool, r *h
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// PatchSubmissionModelParams is parameters of patchSubmissionModel operation.
|
||||
type PatchSubmissionModelParams struct {
|
||||
// UpdateScriptParams is parameters of updateScript operation.
|
||||
type UpdateScriptParams struct {
|
||||
// The unique identifier for a script.
|
||||
ScriptID int64
|
||||
}
|
||||
|
||||
func unpackUpdateScriptParams(packed middleware.Parameters) (params UpdateScriptParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "ScriptID",
|
||||
In: "path",
|
||||
}
|
||||
params.ScriptID = packed[key].(int64)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeUpdateScriptParams(args [1]string, argsEscaped bool, r *http.Request) (params UpdateScriptParams, _ error) {
|
||||
// Decode path: ScriptID.
|
||||
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: "ScriptID",
|
||||
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.ScriptID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "ScriptID",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// UpdateScriptPolicyParams is parameters of updateScriptPolicy operation.
|
||||
type UpdateScriptPolicyParams struct {
|
||||
// The unique identifier for a script policy.
|
||||
ScriptPolicyID int64
|
||||
}
|
||||
|
||||
func unpackUpdateScriptPolicyParams(packed middleware.Parameters) (params UpdateScriptPolicyParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "ScriptPolicyID",
|
||||
In: "path",
|
||||
}
|
||||
params.ScriptPolicyID = packed[key].(int64)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeUpdateScriptPolicyParams(args [1]string, argsEscaped bool, r *http.Request) (params UpdateScriptPolicyParams, _ error) {
|
||||
// Decode path: ScriptPolicyID.
|
||||
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: "ScriptPolicyID",
|
||||
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.ScriptPolicyID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "ScriptPolicyID",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// UpdateSubmissionModelParams is parameters of updateSubmissionModel operation.
|
||||
type UpdateSubmissionModelParams struct {
|
||||
// The unique identifier for a submission.
|
||||
SubmissionID int64
|
||||
ModelID int64
|
||||
VersionID int64
|
||||
}
|
||||
|
||||
func unpackPatchSubmissionModelParams(packed middleware.Parameters) (params PatchSubmissionModelParams) {
|
||||
func unpackUpdateSubmissionModelParams(packed middleware.Parameters) (params UpdateSubmissionModelParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "SubmissionID",
|
||||
@ -1118,7 +1296,7 @@ func unpackPatchSubmissionModelParams(packed middleware.Parameters) (params Patc
|
||||
return params
|
||||
}
|
||||
|
||||
func decodePatchSubmissionModelParams(args [1]string, argsEscaped bool, r *http.Request) (params PatchSubmissionModelParams, _ error) {
|
||||
func decodeUpdateSubmissionModelParams(args [1]string, argsEscaped bool, r *http.Request) (params UpdateSubmissionModelParams, _ error) {
|
||||
q := uri.NewQueryDecoder(r.URL.Query())
|
||||
// Decode path: SubmissionID.
|
||||
if err := func() error {
|
||||
@ -1239,133 +1417,3 @@ func decodePatchSubmissionModelParams(args [1]string, argsEscaped bool, r *http.
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// UpdateScriptParams is parameters of updateScript operation.
|
||||
type UpdateScriptParams struct {
|
||||
ScriptID int64
|
||||
}
|
||||
|
||||
func unpackUpdateScriptParams(packed middleware.Parameters) (params UpdateScriptParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "ScriptID",
|
||||
In: "path",
|
||||
}
|
||||
params.ScriptID = packed[key].(int64)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeUpdateScriptParams(args [1]string, argsEscaped bool, r *http.Request) (params UpdateScriptParams, _ error) {
|
||||
// Decode path: ScriptID.
|
||||
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: "ScriptID",
|
||||
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.ScriptID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "ScriptID",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// UpdateScriptPolicyParams is parameters of updateScriptPolicy operation.
|
||||
type UpdateScriptPolicyParams struct {
|
||||
ScriptPolicyID int64
|
||||
}
|
||||
|
||||
func unpackUpdateScriptPolicyParams(packed middleware.Parameters) (params UpdateScriptPolicyParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "ScriptPolicyID",
|
||||
In: "path",
|
||||
}
|
||||
params.ScriptPolicyID = packed[key].(int64)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeUpdateScriptPolicyParams(args [1]string, argsEscaped bool, r *http.Request) (params UpdateScriptPolicyParams, _ error) {
|
||||
// Decode path: ScriptPolicyID.
|
||||
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: "ScriptPolicyID",
|
||||
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.ScriptPolicyID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "ScriptPolicyID",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
@ -72,6 +72,14 @@ func (s *Server) decodeCreateScriptRequest(r *http.Request) (
|
||||
}
|
||||
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)
|
||||
@ -198,6 +206,14 @@ func (s *Server) decodeCreateSubmissionRequest(r *http.Request) (
|
||||
}
|
||||
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)
|
||||
@ -261,6 +277,14 @@ func (s *Server) decodeUpdateScriptRequest(r *http.Request) (
|
||||
}
|
||||
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)
|
||||
|
@ -3,6 +3,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"mime"
|
||||
"net/http"
|
||||
@ -806,6 +807,15 @@ func decodeGetScriptResponse(resp *http.Response) (res *Script, _ error) {
|
||||
}
|
||||
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)
|
||||
@ -889,6 +899,15 @@ func decodeGetScriptPolicyResponse(resp *http.Response) (res *ScriptPolicy, _ er
|
||||
}
|
||||
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)
|
||||
@ -972,6 +991,15 @@ func decodeGetScriptPolicyFromHashResponse(resp *http.Response) (res *ScriptPoli
|
||||
}
|
||||
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)
|
||||
@ -1055,6 +1083,15 @@ func decodeGetSubmissionResponse(resp *http.Response) (res *Submission, _ error)
|
||||
}
|
||||
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)
|
||||
@ -1151,6 +1188,23 @@ func decodeListSubmissionsResponse(resp *http.Response) (res []Submission, _ err
|
||||
if response == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
var failures []validate.FieldError
|
||||
for i, elem := range response {
|
||||
if err := func() error {
|
||||
if err := elem.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: fmt.Sprintf("[%d]", i),
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return res, errors.Wrap(err, "validate")
|
||||
@ -1205,62 +1259,11 @@ func decodeListSubmissionsResponse(resp *http.Response) (res []Submission, _ err
|
||||
return res, errors.Wrap(defRes, "error")
|
||||
}
|
||||
|
||||
func decodePatchSubmissionCompletedResponse(resp *http.Response) (res *PatchSubmissionCompletedOK, _ error) {
|
||||
func decodeSetSubmissionCompletedResponse(resp *http.Response) (res *SetSubmissionCompletedOK, _ error) {
|
||||
switch resp.StatusCode {
|
||||
case 200:
|
||||
// Code 200.
|
||||
return &PatchSubmissionCompletedOK{}, 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 decodePatchSubmissionModelResponse(resp *http.Response) (res *PatchSubmissionModelOK, _ error) {
|
||||
switch resp.StatusCode {
|
||||
case 200:
|
||||
// Code 200.
|
||||
return &PatchSubmissionModelOK{}, nil
|
||||
return &SetSubmissionCompletedOK{}, nil
|
||||
}
|
||||
// Convenient error response.
|
||||
defRes, err := func() (res *ErrorStatusCode, err error) {
|
||||
@ -1408,3 +1411,54 @@ func decodeUpdateScriptPolicyResponse(resp *http.Response) (res *UpdateScriptPol
|
||||
}
|
||||
return res, errors.Wrap(defRes, "error")
|
||||
}
|
||||
|
||||
func decodeUpdateSubmissionModelResponse(resp *http.Response) (res *UpdateSubmissionModelOK, _ error) {
|
||||
switch resp.StatusCode {
|
||||
case 200:
|
||||
// Code 200.
|
||||
return &UpdateSubmissionModelOK{}, 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")
|
||||
}
|
||||
|
@ -199,14 +199,7 @@ func encodeListSubmissionsResponse(response []Submission, w http.ResponseWriter,
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodePatchSubmissionCompletedResponse(response *PatchSubmissionCompletedOK, w http.ResponseWriter, span trace.Span) error {
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodePatchSubmissionModelResponse(response *PatchSubmissionModelOK, w http.ResponseWriter, span trace.Span) error {
|
||||
func encodeSetSubmissionCompletedResponse(response *SetSubmissionCompletedOK, w http.ResponseWriter, span trace.Span) error {
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
@ -227,6 +220,13 @@ func encodeUpdateScriptPolicyResponse(response *UpdateScriptPolicyOK, w http.Res
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeUpdateSubmissionModelResponse(response *UpdateSubmissionModelOK, w http.ResponseWriter, span trace.Span) error {
|
||||
w.WriteHeader(200)
|
||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||
|
||||
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
|
||||
|
@ -156,12 +156,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
s.handleGetScriptPolicyRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
s.handleUpdateScriptPolicyRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "DELETE,GET,PATCH")
|
||||
s.notAllowed(w, r, "DELETE,GET,POST")
|
||||
}
|
||||
|
||||
return
|
||||
@ -217,12 +217,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
s.handleGetScriptRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
s.handleUpdateScriptRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "DELETE,GET,PATCH")
|
||||
s.notAllowed(w, r, "DELETE,GET,POST")
|
||||
}
|
||||
|
||||
return
|
||||
@ -309,12 +309,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "PATCH":
|
||||
s.handlePatchSubmissionCompletedRequest([1]string{
|
||||
case "POST":
|
||||
s.handleSetSubmissionCompletedRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "PATCH")
|
||||
s.notAllowed(w, r, "POST")
|
||||
}
|
||||
|
||||
return
|
||||
@ -332,12 +332,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "PATCH":
|
||||
s.handlePatchSubmissionModelRequest([1]string{
|
||||
case "POST":
|
||||
s.handleUpdateSubmissionModelRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "PATCH")
|
||||
s.notAllowed(w, r, "POST")
|
||||
}
|
||||
|
||||
return
|
||||
@ -367,12 +367,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
s.handleActionSubmissionPublishRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "PATCH")
|
||||
s.notAllowed(w, r, "POST")
|
||||
}
|
||||
|
||||
return
|
||||
@ -402,12 +402,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
s.handleActionSubmissionRejectRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "PATCH")
|
||||
s.notAllowed(w, r, "POST")
|
||||
}
|
||||
|
||||
return
|
||||
@ -425,12 +425,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
s.handleActionSubmissionRequestChangesRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "PATCH")
|
||||
s.notAllowed(w, r, "POST")
|
||||
}
|
||||
|
||||
return
|
||||
@ -448,12 +448,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
s.handleActionSubmissionRevokeRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "PATCH")
|
||||
s.notAllowed(w, r, "POST")
|
||||
}
|
||||
|
||||
return
|
||||
@ -474,12 +474,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
s.handleActionSubmissionSubmitRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "PATCH")
|
||||
s.notAllowed(w, r, "POST")
|
||||
}
|
||||
|
||||
return
|
||||
@ -509,12 +509,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
s.handleActionSubmissionTriggerPublishRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "PATCH")
|
||||
s.notAllowed(w, r, "POST")
|
||||
}
|
||||
|
||||
return
|
||||
@ -532,12 +532,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
s.handleActionSubmissionTriggerValidateRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "PATCH")
|
||||
s.notAllowed(w, r, "POST")
|
||||
}
|
||||
|
||||
return
|
||||
@ -558,12 +558,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
s.handleActionSubmissionValidateRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, "PATCH")
|
||||
s.notAllowed(w, r, "POST")
|
||||
}
|
||||
|
||||
return
|
||||
@ -786,7 +786,7 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
r.name = UpdateScriptPolicyOperation
|
||||
r.summary = "Update the specified script policy by ID"
|
||||
r.operationID = "updateScriptPolicy"
|
||||
@ -861,7 +861,7 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
r.name = UpdateScriptOperation
|
||||
r.summary = "Update the specified script by ID"
|
||||
r.operationID = "updateScript"
|
||||
@ -967,10 +967,10 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "PATCH":
|
||||
r.name = PatchSubmissionCompletedOperation
|
||||
case "POST":
|
||||
r.name = SetSubmissionCompletedOperation
|
||||
r.summary = "Retrieve map with ID"
|
||||
r.operationID = "patchSubmissionCompleted"
|
||||
r.operationID = "setSubmissionCompleted"
|
||||
r.pathPattern = "/submissions/{SubmissionID}/completed"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
@ -992,10 +992,10 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "PATCH":
|
||||
r.name = PatchSubmissionModelOperation
|
||||
case "POST":
|
||||
r.name = UpdateSubmissionModelOperation
|
||||
r.summary = "Update model following role restrictions"
|
||||
r.operationID = "patchSubmissionModel"
|
||||
r.operationID = "updateSubmissionModel"
|
||||
r.pathPattern = "/submissions/{SubmissionID}/model"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
@ -1029,7 +1029,7 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
r.name = ActionSubmissionPublishOperation
|
||||
r.summary = "Role Validator changes status from Publishing -> Published"
|
||||
r.operationID = "actionSubmissionPublish"
|
||||
@ -1066,7 +1066,7 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
r.name = ActionSubmissionRejectOperation
|
||||
r.summary = "Role Reviewer changes status from Submitted -> Rejected"
|
||||
r.operationID = "actionSubmissionReject"
|
||||
@ -1091,7 +1091,7 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
r.name = ActionSubmissionRequestChangesOperation
|
||||
r.summary = "Role Reviewer changes status from Validated|Accepted|Submitted -> ChangesRequested"
|
||||
r.operationID = "actionSubmissionRequestChanges"
|
||||
@ -1116,7 +1116,7 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
r.name = ActionSubmissionRevokeOperation
|
||||
r.summary = "Role Submitter changes status from Submitted|ChangesRequested -> UnderConstruction"
|
||||
r.operationID = "actionSubmissionRevoke"
|
||||
@ -1144,7 +1144,7 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
r.name = ActionSubmissionSubmitOperation
|
||||
r.summary = "Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted"
|
||||
r.operationID = "actionSubmissionSubmit"
|
||||
@ -1181,7 +1181,7 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
r.name = ActionSubmissionTriggerPublishOperation
|
||||
r.summary = "Role Admin changes status from Validated -> Publishing"
|
||||
r.operationID = "actionSubmissionTriggerPublish"
|
||||
@ -1206,7 +1206,7 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
r.name = ActionSubmissionTriggerValidateOperation
|
||||
r.summary = "Role Reviewer triggers validation and changes status from Submitted|Accepted -> Validating"
|
||||
r.operationID = "actionSubmissionTriggerValidate"
|
||||
@ -1234,7 +1234,7 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "PATCH":
|
||||
case "POST":
|
||||
r.name = ActionSubmissionValidateOperation
|
||||
r.summary = "Role Validator changes status from Validating -> Validated"
|
||||
r.operationID = "actionSubmissionValidate"
|
||||
|
@ -332,12 +332,6 @@ func (s *Pagination) SetLimit(val int32) {
|
||||
s.Limit = val
|
||||
}
|
||||
|
||||
// PatchSubmissionCompletedOK is response for PatchSubmissionCompleted operation.
|
||||
type PatchSubmissionCompletedOK struct{}
|
||||
|
||||
// PatchSubmissionModelOK is response for PatchSubmissionModel operation.
|
||||
type PatchSubmissionModelOK struct{}
|
||||
|
||||
// Ref: #/components/schemas/Script
|
||||
type Script struct {
|
||||
ID int64 `json:"ID"`
|
||||
@ -582,6 +576,9 @@ func (s *ScriptUpdate) SetSubmissionID(val OptInt64) {
|
||||
s.SubmissionID = val
|
||||
}
|
||||
|
||||
// SetSubmissionCompletedOK is response for SetSubmissionCompleted operation.
|
||||
type SetSubmissionCompletedOK struct{}
|
||||
|
||||
// Ref: #/components/schemas/Submission
|
||||
type Submission struct {
|
||||
ID int64 `json:"ID"`
|
||||
@ -852,3 +849,6 @@ type UpdateScriptOK struct{}
|
||||
|
||||
// UpdateScriptPolicyOK is response for UpdateScriptPolicy operation.
|
||||
type UpdateScriptPolicyOK struct{}
|
||||
|
||||
// UpdateSubmissionModelOK is response for UpdateSubmissionModel operation.
|
||||
type UpdateSubmissionModelOK struct{}
|
||||
|
@ -12,49 +12,49 @@ type Handler interface {
|
||||
//
|
||||
// Role Validator changes status from Publishing -> Published.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/publish
|
||||
// POST /submissions/{SubmissionID}/status/publish
|
||||
ActionSubmissionPublish(ctx context.Context, params ActionSubmissionPublishParams) error
|
||||
// ActionSubmissionReject implements actionSubmissionReject operation.
|
||||
//
|
||||
// Role Reviewer changes status from Submitted -> Rejected.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/reject
|
||||
// POST /submissions/{SubmissionID}/status/reject
|
||||
ActionSubmissionReject(ctx context.Context, params ActionSubmissionRejectParams) error
|
||||
// ActionSubmissionRequestChanges implements actionSubmissionRequestChanges operation.
|
||||
//
|
||||
// Role Reviewer changes status from Validated|Accepted|Submitted -> ChangesRequested.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/request-changes
|
||||
// POST /submissions/{SubmissionID}/status/request-changes
|
||||
ActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) error
|
||||
// ActionSubmissionRevoke implements actionSubmissionRevoke operation.
|
||||
//
|
||||
// Role Submitter changes status from Submitted|ChangesRequested -> UnderConstruction.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/revoke
|
||||
// POST /submissions/{SubmissionID}/status/revoke
|
||||
ActionSubmissionRevoke(ctx context.Context, params ActionSubmissionRevokeParams) error
|
||||
// ActionSubmissionSubmit implements actionSubmissionSubmit operation.
|
||||
//
|
||||
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/submit
|
||||
// POST /submissions/{SubmissionID}/status/submit
|
||||
ActionSubmissionSubmit(ctx context.Context, params ActionSubmissionSubmitParams) error
|
||||
// ActionSubmissionTriggerPublish implements actionSubmissionTriggerPublish operation.
|
||||
//
|
||||
// Role Admin changes status from Validated -> Publishing.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/trigger-publish
|
||||
// POST /submissions/{SubmissionID}/status/trigger-publish
|
||||
ActionSubmissionTriggerPublish(ctx context.Context, params ActionSubmissionTriggerPublishParams) error
|
||||
// ActionSubmissionTriggerValidate implements actionSubmissionTriggerValidate operation.
|
||||
//
|
||||
// Role Reviewer triggers validation and changes status from Submitted|Accepted -> Validating.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/trigger-validate
|
||||
// POST /submissions/{SubmissionID}/status/trigger-validate
|
||||
ActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) error
|
||||
// ActionSubmissionValidate implements actionSubmissionValidate operation.
|
||||
//
|
||||
// Role Validator changes status from Validating -> Validated.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/validate
|
||||
// POST /submissions/{SubmissionID}/status/validate
|
||||
ActionSubmissionValidate(ctx context.Context, params ActionSubmissionValidateParams) error
|
||||
// CreateScript implements createScript operation.
|
||||
//
|
||||
@ -116,30 +116,30 @@ type Handler interface {
|
||||
//
|
||||
// GET /submissions
|
||||
ListSubmissions(ctx context.Context, params ListSubmissionsParams) ([]Submission, error)
|
||||
// PatchSubmissionCompleted implements patchSubmissionCompleted operation.
|
||||
// SetSubmissionCompleted implements setSubmissionCompleted operation.
|
||||
//
|
||||
// Retrieve map with ID.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/completed
|
||||
PatchSubmissionCompleted(ctx context.Context, params PatchSubmissionCompletedParams) error
|
||||
// PatchSubmissionModel implements patchSubmissionModel operation.
|
||||
//
|
||||
// Update model following role restrictions.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/model
|
||||
PatchSubmissionModel(ctx context.Context, params PatchSubmissionModelParams) error
|
||||
// POST /submissions/{SubmissionID}/completed
|
||||
SetSubmissionCompleted(ctx context.Context, params SetSubmissionCompletedParams) error
|
||||
// UpdateScript implements updateScript operation.
|
||||
//
|
||||
// Update the specified script by ID.
|
||||
//
|
||||
// PATCH /scripts/{ScriptID}
|
||||
// POST /scripts/{ScriptID}
|
||||
UpdateScript(ctx context.Context, req *ScriptUpdate, params UpdateScriptParams) error
|
||||
// UpdateScriptPolicy implements updateScriptPolicy operation.
|
||||
//
|
||||
// Update the specified script policy by ID.
|
||||
//
|
||||
// PATCH /script-policy/id/{ScriptPolicyID}
|
||||
// POST /script-policy/id/{ScriptPolicyID}
|
||||
UpdateScriptPolicy(ctx context.Context, req *ScriptPolicyUpdate, params UpdateScriptPolicyParams) error
|
||||
// UpdateSubmissionModel implements updateSubmissionModel operation.
|
||||
//
|
||||
// Update model following role restrictions.
|
||||
//
|
||||
// POST /submissions/{SubmissionID}/model
|
||||
UpdateSubmissionModel(ctx context.Context, params UpdateSubmissionModelParams) error
|
||||
// NewError creates *ErrorStatusCode from error returned by handler.
|
||||
//
|
||||
// Used for common default response.
|
||||
|
@ -17,7 +17,7 @@ var _ Handler = UnimplementedHandler{}
|
||||
//
|
||||
// Role Validator changes status from Publishing -> Published.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/publish
|
||||
// POST /submissions/{SubmissionID}/status/publish
|
||||
func (UnimplementedHandler) ActionSubmissionPublish(ctx context.Context, params ActionSubmissionPublishParams) error {
|
||||
return ht.ErrNotImplemented
|
||||
}
|
||||
@ -26,7 +26,7 @@ func (UnimplementedHandler) ActionSubmissionPublish(ctx context.Context, params
|
||||
//
|
||||
// Role Reviewer changes status from Submitted -> Rejected.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/reject
|
||||
// POST /submissions/{SubmissionID}/status/reject
|
||||
func (UnimplementedHandler) ActionSubmissionReject(ctx context.Context, params ActionSubmissionRejectParams) error {
|
||||
return ht.ErrNotImplemented
|
||||
}
|
||||
@ -35,7 +35,7 @@ func (UnimplementedHandler) ActionSubmissionReject(ctx context.Context, params A
|
||||
//
|
||||
// Role Reviewer changes status from Validated|Accepted|Submitted -> ChangesRequested.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/request-changes
|
||||
// POST /submissions/{SubmissionID}/status/request-changes
|
||||
func (UnimplementedHandler) ActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) error {
|
||||
return ht.ErrNotImplemented
|
||||
}
|
||||
@ -44,7 +44,7 @@ func (UnimplementedHandler) ActionSubmissionRequestChanges(ctx context.Context,
|
||||
//
|
||||
// Role Submitter changes status from Submitted|ChangesRequested -> UnderConstruction.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/revoke
|
||||
// POST /submissions/{SubmissionID}/status/revoke
|
||||
func (UnimplementedHandler) ActionSubmissionRevoke(ctx context.Context, params ActionSubmissionRevokeParams) error {
|
||||
return ht.ErrNotImplemented
|
||||
}
|
||||
@ -53,7 +53,7 @@ func (UnimplementedHandler) ActionSubmissionRevoke(ctx context.Context, params A
|
||||
//
|
||||
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/submit
|
||||
// POST /submissions/{SubmissionID}/status/submit
|
||||
func (UnimplementedHandler) ActionSubmissionSubmit(ctx context.Context, params ActionSubmissionSubmitParams) error {
|
||||
return ht.ErrNotImplemented
|
||||
}
|
||||
@ -62,7 +62,7 @@ func (UnimplementedHandler) ActionSubmissionSubmit(ctx context.Context, params A
|
||||
//
|
||||
// Role Admin changes status from Validated -> Publishing.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/trigger-publish
|
||||
// POST /submissions/{SubmissionID}/status/trigger-publish
|
||||
func (UnimplementedHandler) ActionSubmissionTriggerPublish(ctx context.Context, params ActionSubmissionTriggerPublishParams) error {
|
||||
return ht.ErrNotImplemented
|
||||
}
|
||||
@ -71,7 +71,7 @@ func (UnimplementedHandler) ActionSubmissionTriggerPublish(ctx context.Context,
|
||||
//
|
||||
// Role Reviewer triggers validation and changes status from Submitted|Accepted -> Validating.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/trigger-validate
|
||||
// POST /submissions/{SubmissionID}/status/trigger-validate
|
||||
func (UnimplementedHandler) ActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) error {
|
||||
return ht.ErrNotImplemented
|
||||
}
|
||||
@ -80,7 +80,7 @@ func (UnimplementedHandler) ActionSubmissionTriggerValidate(ctx context.Context,
|
||||
//
|
||||
// Role Validator changes status from Validating -> Validated.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/status/validate
|
||||
// POST /submissions/{SubmissionID}/status/validate
|
||||
func (UnimplementedHandler) ActionSubmissionValidate(ctx context.Context, params ActionSubmissionValidateParams) error {
|
||||
return ht.ErrNotImplemented
|
||||
}
|
||||
@ -175,21 +175,12 @@ func (UnimplementedHandler) ListSubmissions(ctx context.Context, params ListSubm
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// PatchSubmissionCompleted implements patchSubmissionCompleted operation.
|
||||
// SetSubmissionCompleted implements setSubmissionCompleted operation.
|
||||
//
|
||||
// Retrieve map with ID.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/completed
|
||||
func (UnimplementedHandler) PatchSubmissionCompleted(ctx context.Context, params PatchSubmissionCompletedParams) error {
|
||||
return ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// PatchSubmissionModel implements patchSubmissionModel operation.
|
||||
//
|
||||
// Update model following role restrictions.
|
||||
//
|
||||
// PATCH /submissions/{SubmissionID}/model
|
||||
func (UnimplementedHandler) PatchSubmissionModel(ctx context.Context, params PatchSubmissionModelParams) error {
|
||||
// POST /submissions/{SubmissionID}/completed
|
||||
func (UnimplementedHandler) SetSubmissionCompleted(ctx context.Context, params SetSubmissionCompletedParams) error {
|
||||
return ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
@ -197,7 +188,7 @@ func (UnimplementedHandler) PatchSubmissionModel(ctx context.Context, params Pat
|
||||
//
|
||||
// Update the specified script by ID.
|
||||
//
|
||||
// PATCH /scripts/{ScriptID}
|
||||
// POST /scripts/{ScriptID}
|
||||
func (UnimplementedHandler) UpdateScript(ctx context.Context, req *ScriptUpdate, params UpdateScriptParams) error {
|
||||
return ht.ErrNotImplemented
|
||||
}
|
||||
@ -206,11 +197,20 @@ func (UnimplementedHandler) UpdateScript(ctx context.Context, req *ScriptUpdate,
|
||||
//
|
||||
// Update the specified script policy by ID.
|
||||
//
|
||||
// PATCH /script-policy/id/{ScriptPolicyID}
|
||||
// POST /script-policy/id/{ScriptPolicyID}
|
||||
func (UnimplementedHandler) UpdateScriptPolicy(ctx context.Context, req *ScriptPolicyUpdate, params UpdateScriptPolicyParams) error {
|
||||
return ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// UpdateSubmissionModel implements updateSubmissionModel operation.
|
||||
//
|
||||
// Update model following role restrictions.
|
||||
//
|
||||
// POST /submissions/{SubmissionID}/model
|
||||
func (UnimplementedHandler) UpdateSubmissionModel(ctx context.Context, params UpdateSubmissionModelParams) error {
|
||||
return ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// NewError creates *ErrorStatusCode from error returned by handler.
|
||||
//
|
||||
// Used for common default response.
|
||||
|
@ -59,3 +59,317 @@ func (s *Pagination) Validate() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Script) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 16,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 16,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
}).Validate(string(s.Hash)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "Hash",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 1048576,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
}).Validate(string(s.Source)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "Source",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ScriptCreate) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 1048576,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
}).Validate(string(s.Source)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "Source",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ScriptPolicy) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 16,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 16,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
}).Validate(string(s.FromScriptHash)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "FromScriptHash",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ScriptUpdate) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if value, ok := s.Source.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 1048576,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "Source",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Submission) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 128,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
}).Validate(string(s.DisplayName)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "DisplayName",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 128,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
}).Validate(string(s.Creator)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "Creator",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SubmissionCreate) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 128,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
}).Validate(string(s.DisplayName)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "DisplayName",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 128,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
}).Validate(string(s.Creator)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "Creator",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SubmissionFilter) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if value, ok := s.DisplayName.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 128,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "DisplayName",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.Creator.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 128,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "Creator",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user