github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/inventory/inventory_models/paging.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package inventory_models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "context" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/strfmt" 13 "github.com/go-openapi/swag" 14 "github.com/go-openapi/validate" 15 ) 16 17 // Paging Paging 18 // 19 // Paging data 20 // 21 // swagger:model paging 22 type Paging struct { 23 24 // The total number of items available 25 // Required: true 26 // Minimum: 0 27 AvailableCount *int64 `json:"available_count"` 28 29 // The number of items on this page 30 // Required: true 31 // Minimum: 0 32 ItemCount *int64 `json:"item_count"` 33 34 // The maximum number of items that could be returned 35 // Required: true 36 // Minimum: 1 37 Limit *int64 `json:"limit"` 38 39 // The page number of this result set 40 // Required: true 41 // Minimum: 1 42 Page *int64 `json:"page"` 43 44 // The total number of pages 45 // Required: true 46 // Minimum: 1 47 PageCount *int64 `json:"page_count"` 48 } 49 50 // Validate validates this paging 51 func (m *Paging) Validate(formats strfmt.Registry) error { 52 var res []error 53 54 if err := m.validateAvailableCount(formats); err != nil { 55 res = append(res, err) 56 } 57 58 if err := m.validateItemCount(formats); err != nil { 59 res = append(res, err) 60 } 61 62 if err := m.validateLimit(formats); err != nil { 63 res = append(res, err) 64 } 65 66 if err := m.validatePage(formats); err != nil { 67 res = append(res, err) 68 } 69 70 if err := m.validatePageCount(formats); err != nil { 71 res = append(res, err) 72 } 73 74 if len(res) > 0 { 75 return errors.CompositeValidationError(res...) 76 } 77 return nil 78 } 79 80 func (m *Paging) validateAvailableCount(formats strfmt.Registry) error { 81 82 if err := validate.Required("available_count", "body", m.AvailableCount); err != nil { 83 return err 84 } 85 86 if err := validate.MinimumInt("available_count", "body", *m.AvailableCount, 0, false); err != nil { 87 return err 88 } 89 90 return nil 91 } 92 93 func (m *Paging) validateItemCount(formats strfmt.Registry) error { 94 95 if err := validate.Required("item_count", "body", m.ItemCount); err != nil { 96 return err 97 } 98 99 if err := validate.MinimumInt("item_count", "body", *m.ItemCount, 0, false); err != nil { 100 return err 101 } 102 103 return nil 104 } 105 106 func (m *Paging) validateLimit(formats strfmt.Registry) error { 107 108 if err := validate.Required("limit", "body", m.Limit); err != nil { 109 return err 110 } 111 112 if err := validate.MinimumInt("limit", "body", *m.Limit, 1, false); err != nil { 113 return err 114 } 115 116 return nil 117 } 118 119 func (m *Paging) validatePage(formats strfmt.Registry) error { 120 121 if err := validate.Required("page", "body", m.Page); err != nil { 122 return err 123 } 124 125 if err := validate.MinimumInt("page", "body", *m.Page, 1, false); err != nil { 126 return err 127 } 128 129 return nil 130 } 131 132 func (m *Paging) validatePageCount(formats strfmt.Registry) error { 133 134 if err := validate.Required("page_count", "body", m.PageCount); err != nil { 135 return err 136 } 137 138 if err := validate.MinimumInt("page_count", "body", *m.PageCount, 1, false); err != nil { 139 return err 140 } 141 142 return nil 143 } 144 145 // ContextValidate validates this paging based on context it is used 146 func (m *Paging) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 147 return nil 148 } 149 150 // MarshalBinary interface implementation 151 func (m *Paging) MarshalBinary() ([]byte, error) { 152 if m == nil { 153 return nil, nil 154 } 155 return swag.WriteJSON(m) 156 } 157 158 // UnmarshalBinary interface implementation 159 func (m *Paging) UnmarshalBinary(b []byte) error { 160 var res Paging 161 if err := swag.ReadJSON(b, &res); err != nil { 162 return err 163 } 164 *m = res 165 return nil 166 }