// Code generated by go-swagger; DO NOT EDIT. package models // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command import ( "encoding/json" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" "github.com/lib/pq" ) // BillRun bill run // // swagger:model BillRun type BillRun struct { // amount invoiced AmountInvoiced float64 `json:"AmountInvoiced,omitempty" gorm:"type:numeric(23,13)"` // creation timestamp // Format: date-time CreationTimestamp strfmt.DateTime `json:"CreationTimestamp,omitempty" gorm:"type:timestamptz"` // execution type ExecutionType string `json:"ExecutionType,omitempty"` // ID // Format: uuid ID strfmt.UUID `json:"ID,omitempty" gorm:"type:uuid;primary_key;unique;default:md5(random()::text || clock_timestamp()::text)::uuid"` // invoices count InvoicesCount int64 `json:"InvoicesCount,omitempty"` // invoices error count InvoicesErrorCount int64 `json:"InvoicesErrorCount,omitempty"` // invoices error list InvoicesErrorList pq.StringArray `json:"InvoicesErrorList,omitempty" gorm:"type:text[]"` // invoices list InvoicesList []*InvoiceMetadata `json:"InvoicesList" gorm:"-"` // invoices processed count InvoicesProcessedCount int64 `json:"InvoicesProcessedCount,omitempty"` // organizations involved OrganizationsInvolved pq.StringArray `json:"OrganizationsInvolved,omitempty" gorm:"type:text[]"` // status // Enum: [ERROR FINISHED PROCESSING QUEUED] Status *string `json:"Status,omitempty" gorm:"default:QUEUED"` } // Validate validates this bill run func (m *BillRun) Validate(formats strfmt.Registry) error { var res []error if err := m.validateCreationTimestamp(formats); err != nil { res = append(res, err) } if err := m.validateID(formats); err != nil { res = append(res, err) } if err := m.validateInvoicesList(formats); err != nil { res = append(res, err) } if err := m.validateStatus(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *BillRun) validateCreationTimestamp(formats strfmt.Registry) error { if swag.IsZero(m.CreationTimestamp) { // not required return nil } if err := validate.FormatOf("CreationTimestamp", "body", "date-time", m.CreationTimestamp.String(), formats); err != nil { return err } return nil } func (m *BillRun) validateID(formats strfmt.Registry) error { if swag.IsZero(m.ID) { // not required return nil } if err := validate.FormatOf("ID", "body", "uuid", m.ID.String(), formats); err != nil { return err } return nil } func (m *BillRun) validateInvoicesList(formats strfmt.Registry) error { if swag.IsZero(m.InvoicesList) { // not required return nil } for i := 0; i < len(m.InvoicesList); i++ { if swag.IsZero(m.InvoicesList[i]) { // not required continue } if m.InvoicesList[i] != nil { if err := m.InvoicesList[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("InvoicesList" + "." + strconv.Itoa(i)) } return err } } } return nil } var billRunTypeStatusPropEnum []interface{} func init() { var res []string if err := json.Unmarshal([]byte(`["ERROR","FINISHED","PROCESSING","QUEUED"]`), &res); err != nil { panic(err) } for _, v := range res { billRunTypeStatusPropEnum = append(billRunTypeStatusPropEnum, v) } } const ( // BillRunStatusERROR captures enum value "ERROR" BillRunStatusERROR string = "ERROR" // BillRunStatusFINISHED captures enum value "FINISHED" BillRunStatusFINISHED string = "FINISHED" // BillRunStatusPROCESSING captures enum value "PROCESSING" BillRunStatusPROCESSING string = "PROCESSING" // BillRunStatusQUEUED captures enum value "QUEUED" BillRunStatusQUEUED string = "QUEUED" ) // prop value enum func (m *BillRun) validateStatusEnum(path, location string, value string) error { if err := validate.EnumCase(path, location, value, billRunTypeStatusPropEnum, true); err != nil { return err } return nil } func (m *BillRun) validateStatus(formats strfmt.Registry) error { if swag.IsZero(m.Status) { // not required return nil } // value enum if err := m.validateStatusEnum("Status", "body", *m.Status); err != nil { return err } return nil } // MarshalBinary interface implementation func (m *BillRun) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } return swag.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *BillRun) UnmarshalBinary(b []byte) error { var res BillRun if err := swag.ReadJSON(b, &res); err != nil { return err } *m = res return nil }