Cyclops 4 HPC is the purpose built stack to support large HPC centers with resource accounting and billing of cluster as well as cloud resources.
cyclops-4-hpc/services/credit-system/restapi/operations/credit_management/decrease_credit_parameters.go

152 lines
3.7 KiB

// Code generated by go-swagger; DO NOT EDIT.
package credit_management
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// NewDecreaseCreditParams creates a new DecreaseCreditParams object
// no default values defined in spec.
func NewDecreaseCreditParams() DecreaseCreditParams {
return DecreaseCreditParams{}
}
// DecreaseCreditParams contains all the bound params for the decrease credit operation
// typically these are obtained from a http.Request
//
// swagger:parameters decreaseCredit
type DecreaseCreditParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*Amount to be decreased
Required: true
In: query
*/
Amount float64
/*Id of the account to be checked
Required: true
In: path
*/
ID string
/*Medium (cash/credit) to be used in the accounting
Required: true
In: path
*/
Medium string
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls.
//
// To ensure default values, the struct must have been initialized with NewDecreaseCreditParams() beforehand.
func (o *DecreaseCreditParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
qs := runtime.Values(r.URL.Query())
qAmount, qhkAmount, _ := qs.GetOK("amount")
if err := o.bindAmount(qAmount, qhkAmount, route.Formats); err != nil {
res = append(res, err)
}
rID, rhkID, _ := route.Params.GetOK("id")
if err := o.bindID(rID, rhkID, route.Formats); err != nil {
res = append(res, err)
}
rMedium, rhkMedium, _ := route.Params.GetOK("medium")
if err := o.bindMedium(rMedium, rhkMedium, route.Formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// bindAmount binds and validates parameter Amount from query.
func (o *DecreaseCreditParams) bindAmount(rawData []string, hasKey bool, formats strfmt.Registry) error {
if !hasKey {
return errors.Required("amount", "query", rawData)
}
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: true
// AllowEmptyValue: false
if err := validate.RequiredString("amount", "query", raw); err != nil {
return err
}
value, err := swag.ConvertFloat64(raw)
if err != nil {
return errors.InvalidType("amount", "query", "float64", raw)
}
o.Amount = value
return nil
}
// bindID binds and validates parameter ID from path.
func (o *DecreaseCreditParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: true
// Parameter is provided by construction from the route
o.ID = raw
return nil
}
// bindMedium binds and validates parameter Medium from path.
func (o *DecreaseCreditParams) bindMedium(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: true
// Parameter is provided by construction from the route
o.Medium = raw
if err := o.validateMedium(formats); err != nil {
return err
}
return nil
}
// validateMedium carries on validations for parameter Medium
func (o *DecreaseCreditParams) validateMedium(formats strfmt.Registry) error {
if err := validate.EnumCase("medium", "path", o.Medium, []interface{}{"credit", "cash"}, true); err != nil {
return err
}
return nil
}