openapi: GET /script-policy endpoint to list script policies
This commit is contained in:
@ -954,6 +954,117 @@ func decodeGetSubmissionParams(args [1]string, argsEscaped bool, r *http.Request
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ListScriptPolicyParams is parameters of listScriptPolicy operation.
|
||||
type ListScriptPolicyParams struct {
|
||||
Page Pagination
|
||||
Filter OptScriptPolicyFilter
|
||||
}
|
||||
|
||||
func unpackListScriptPolicyParams(packed middleware.Parameters) (params ListScriptPolicyParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "page",
|
||||
In: "query",
|
||||
}
|
||||
params.Page = packed[key].(Pagination)
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "filter",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.Filter = v.(OptScriptPolicyFilter)
|
||||
}
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeListScriptPolicyParams(args [0]string, argsEscaped bool, r *http.Request) (params ListScriptPolicyParams, _ error) {
|
||||
q := uri.NewQueryDecoder(r.URL.Query())
|
||||
// Decode query: page.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "page",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
Fields: []uri.QueryParameterObjectField{{Name: "Page", Required: true}, {Name: "Limit", Required: true}},
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
return params.Page.DecodeURI(d)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := params.Page.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "page",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode query: filter.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "filter",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
Fields: []uri.QueryParameterObjectField{{Name: "ID", Required: false}, {Name: "FromScriptHash", Required: false}, {Name: "ToScriptID", Required: false}, {Name: "Policy", Required: false}},
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotFilterVal ScriptPolicyFilter
|
||||
if err := func() error {
|
||||
return paramsDotFilterVal.DecodeURI(d)
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.Filter.SetTo(paramsDotFilterVal)
|
||||
return nil
|
||||
}); 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 {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "filter",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ListSubmissionsParams is parameters of listSubmissions operation.
|
||||
type ListSubmissionsParams struct {
|
||||
Page Pagination
|
||||
|
Reference in New Issue
Block a user